Forums / Developer / PHP coding standards and Eclipse PDT

PHP coding standards and Eclipse PDT

Author Message

Piotrek Karaś

Tuesday 01 January 2008 3:36:19 am

Hello everyone in 2008!

Few questions concerning PHP coding standard:

1) Is there an up-to-date standard description available anywhere? I have just found this:
http://ez.no/ezpublish/documentation/development/standards/php

2) There are two formatting problems that I have when I try to follow the coding style observed in the core eZ Publish PHP files, both in regard to indentation. Eclipse comes with this great formatting tool, but it doesn't seem to obey custom indentation (this is mainly problematic with large array declarations). The other one occurs when ommiting brackets in single-line if statements:

<?php
// automatic formatting works great for brackets:
if( $x )
{
    echo $y;
}
// but destroys indentation when brackets are missing:
else
echo $z; // this line should be indented, I think...
?>

Any suggestions?
Thanks,
Piotrek

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

Bartek Modzelewski

Tuesday 01 January 2008 10:50:44 am

Hello Piotrek,

Check out this doc: http://ez.no/services/eznetwork/development_guidelines
In points 4.3 and 4.4 you will find coding rules for extensions created for eZ Network.
I think the best idea is just to keep brackets even for single line if statements, not only because of Eclipse formating tools.

Bartek

P.S. Happy new 2008 year ! One of my wishes for this year is growing popularity of eZ Publish in Poland :)

Baobaz
http://www.baobaz.com

Piotrek Karaś

Tuesday 01 January 2008 11:30:27 am

Bartek,

Thanks a lot! I wonder if this is exactly up to date, though, as there's still Doxygen and I thought there was a decision to switch to PHPDoc... ;)
But this will be helpful, anyways!

The formatting tools are a serious reason to reconsider coding standards, but even without that problem I like to keep full 'bracketing' of my code, for a number of reasons...

As to the eZ in Poland - yup, same here ;)

Cheers,
Piotrek

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

eZ debug

Timing: Jan 31 2025 01:34:06
Script start
Timing: Jan 31 2025 01:34:06
Module start 'content'
Timing: Jan 31 2025 01:34:06
Module end 'content'
Timing: Jan 31 2025 01:34:07
Script end

Main resources:

Total runtime0.2070 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0069 587.9531370.2891
Module start 'content' 0.00690.0129 958.24221,005.6563
Module end 'content' 0.01990.1871 1,963.89843,894.7109
Script end 0.2070  5,858.6094 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00462.2375200.0002
Check MTime0.00140.6728200.0001
Mysql Total
Database connection0.00060.288410.0006
Mysqli_queries0.111553.83261410.0008
Looping result0.00180.87501390.0000
Template Total0.186790.210.1867
Template load0.00080.405710.0008
Template processing0.185989.782410.1859
Override
Cache load0.00060.286510.0006
Sytem overhead
Fetch class attribute can translate value0.00180.891210.0018
XML
Image XML parsing0.00030.126610.0003
General
dbfile0.00442.1483200.0002
String conversion0.00000.002330.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs