Log in | Back to darenet.org

Web Development

m
(Function Calls)
Line 55: Line 55:
$variableLong = foo($bar1);
$variableLong = foo($bar1);
?></source>
?></source>
 +
 +
== Commenting Code ==
 +
 +
All comments should be written in English, and should in a clear way describe the commented block of code.
 +
 +
Comments can include the following phpDocumentor tags:
 +
 +
* [http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.access.pkg.html @access]
 +
* [http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.author.pkg.html @author]
 +
* [http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.copyright.pkg.html @copyright]
 +
* [http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.deprecated.pkg.html @deprecated]
 +
* [http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.example.pkg.html @example]
 +
* [http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.ignore.pkg.html @ignore]
 +
* [http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.internal.pkg.html @internal]
 +
* [http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.link.pkg.html @link]
 +
* [http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.see.pkg.html @see]
 +
* [http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.since.pkg.html @since]
 +
* [http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.tutorial.pkg.html @tutorial]
 +
* [http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.version.pkg.html @version]
 +
* [http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.inlineinternal.pkg.html inline {@internal}}]
 +
* [http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.inlineinheritdoc.pkg.html inline {@inheritdoc}}]
 +
* [http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.inlinelink.pkg.html inline {@link}}]
 +
 +
PhpDoc tags are very much like JavaDoc tags in Java. Tags are only processed if they are the first thing in a DocBlock line, for example:
 +
<source lang="php" line start=1 >
 +
<?php
 +
/**
 +
* Tag example.
 +
* @author this tag is parsed, but this @version is ignored
 +
* @version 1.0 this tag is also parsed
 +
*/
 +
?></source>
 +
 +
There are 3 inline tags ({@internal}}, {@inheritdoc}} and {@link}}).
 +
<source lang="php" line start=1 >
 +
<?php
 +
/**
 +
* Example of inline phpDoc tags.
 +
*
 +
* This function works hard with {@link foo()} to rule the world.
 +
*/
 +
function bar() {
 +
}
 +
function foo() {
 +
}
 +
?></source>
 +
 +
== Including Files ==
 +
 +
When including files with classes or libraries, use only and always the [http://php.net/require_once require_once] function.
 +
 +
== PHP Tags ==
 +
 +
Always use long tags (<?php ?>) Instead of short tags (<? ?>).

Revision as of 05:49, 2 February 2009

Here we'll attempt to explain the process we'll be using to develop the next generation of the DareNET web site. We will rely heavily on community interaction, whether through the forums or on IRC (#dev). IRC is perhaps the best place to find members of the development team and discuss ideas, latest code and make general comments.

We'll maintain 3 version of the site.

  • stable - for production (the version used on the main site) where stability is more important than features.
  • trunk - development version where features are important and stability is necessary.
  • branches - for testing, and development members interested in the most advanced feature set and willing to refine them some.

In This Guide:

Coding Standards

Adding New Features

No new features should be added to stable or trunk, without having their own tests - which should be passed before committing them to the repository.

Indentation

One tab will be used for indentation.

So, indentation should look like this:

<source lang="php" line start=1 > <?php // base level

   // level 1
       // level 2
   // level 1

// base level ?> </source>

Or:

<source lang="php" line start=1 > $booleanVariable = true; $stringVariable = "moose"; if ($booleanVariable) { echo "Boolean value is true"; if ($stringVariable == "moose") { echo "We have encountered a moose"; } }</source>

Function Calls

Functions should be called without space between function's name and starting bracket. There should be one space between every parameter of a function call.


<source lang="php" line start=1 ><?php $var = foo($bar, $bar2, $bar3); ?></source>

As you can see above there should be one space on both sides of equals sign (=). To increase the readability of the code you can add spaces (or tabs) before the equals sign, but only in the case of a multiple function call presented below:


<source lang="php" line start=1 ><?php $varShort = foo($bar1); $variableLong = foo($bar1); ?></source>

Commenting Code

All comments should be written in English, and should in a clear way describe the commented block of code.

Comments can include the following phpDocumentor tags:

PhpDoc tags are very much like JavaDoc tags in Java. Tags are only processed if they are the first thing in a DocBlock line, for example: <source lang="php" line start=1 > <?php /**

* Tag example.
* @author this tag is parsed, but this @version is ignored
* @version 1.0 this tag is also parsed
  • /

?></source>

There are 3 inline tags ({@internal}}, {@inheritdoc}} and {@link}}). <source lang="php" line start=1 > <?php /**

* Example of inline phpDoc tags.
*
* This function works hard with {@link foo()} to rule the world.
*/

function bar() { } function foo() { } ?></source>

Including Files

When including files with classes or libraries, use only and always the require_once function.

PHP Tags

Always use long tags (<?php ?>) Instead of short tags (<? ?>).