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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 19:11:40
Script start
Timing: Jan 18 2025 19:11:40
Module start 'layout'
Timing: Jan 18 2025 19:11:40
Module start 'content'
Timing: Jan 18 2025 19:11:40
Module end 'content'
Timing: Jan 18 2025 19:11:40
Script end

Main resources:

Total runtime0.7452 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0076 587.9375152.6250
Module start 'layout' 0.00760.0035 740.562539.4453
Module start 'content' 0.01110.7325 780.0078543.3672
Module end 'content' 0.74360.0016 1,323.375012.1563
Script end 0.7452  1,335.5313 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.4671160.0002
Check MTime0.00140.1936160.0001
Mysql Total
Database connection0.00160.212910.0016
Mysqli_queries0.684991.9022570.0120
Looping result0.00060.0775550.0000
Template Total0.698893.820.3494
Template load0.00300.401820.0015
Template processing0.695893.372620.3479
Template load and register function0.00010.014210.0001
states
state_id_array0.00640.854410.0064
state_identifier_array0.00140.183820.0007
Override
Cache load0.00260.3432290.0001
Sytem overhead
Fetch class attribute can translate value0.00060.073920.0003
Fetch class attribute name0.00130.168540.0003
XML
Image XML parsing0.00080.100820.0004
class_abstraction
Instantiating content class attribute0.00000.001750.0000
General
dbfile0.00090.1148170.0001
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 21
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs