<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Paladin</id>
	<title>Joomla! Documentation - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Paladin"/>
	<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/Special:Contributions/Paladin"/>
	<updated>2026-06-27T05:31:26Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=31496</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=31496"/>
		<updated>2010-10-19T17:46:55Z</updated>

		<summary type="html">&lt;p&gt;Paladin: Corrected unit test file naming convention&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{cookiejar}}&lt;br /&gt;
== News and Updates ==&lt;br /&gt;
2009 10 06: Tests now depend on the SVN version of PHPUnit 3.4.1.&lt;br /&gt;
&lt;br /&gt;
2008 06 24: Update to reflect move of PHPUnit code from branch to trunk (former trunk now in /branches/old_simpletest).&lt;br /&gt;
&lt;br /&gt;
2008 06 22: Add information on limiting tests by version.&lt;br /&gt;
&lt;br /&gt;
2008 06 21: Added --class-exclude, --sequence-exclude, and --test-exclude options.&lt;br /&gt;
&lt;br /&gt;
2008 06 21: PHPUnit has been updated to version 3.2.21 with SVN rev 10436. Please update.&lt;br /&gt;
&lt;br /&gt;
== Unit Testing ==&lt;br /&gt;
Unit testing is not only an essential part of a good Quality Control program, it is an aid to development as well. Writing new tests before writing code helps focus the developer on the problem at hand. The practice also encourages writing smaller, more loosely coupled, more reusable, and more maintainable code units and these benefits often outweigh the benefits gained by treating unit tests solely as a QC tool. When used in this manner correctness becomes more a by-product of the process than the goal.&lt;br /&gt;
For a good general discussion of unit testing, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== The Testing Hierarchy: Unit, Subsystem, Integrated ===&lt;br /&gt;
Software testing systems usually run through a spectrum from &amp;quot;pure&amp;quot; unit tests through to fully integrated systems tests. We&#039;ve described low level unit tests above. Integrated testing typically involves some sort of script that simulates user actions and then verifies that the result matches what&#039;s expected. This sort of &amp;quot;end to end&amp;quot; test verifies that all parts of the system are working correctly.&lt;br /&gt;
&lt;br /&gt;
It&#039;s unfortunate that there is no clear nomenclature to describe all the intermediate stages of testing. The next stage beyond testing a single unit of code is subsystem testing. A subsystem test verifies that two or more units of code are interacting correctly to produce the desired result. In the simplest case, a subsystem test can be created simply by replacing mock objects with real objects and running unit tests on the top level module. In practise, this tends to not work as well as expected, because the original unit test data wasn&#039;t designed for a subsystem test, or because the nature of the test cases needs to be changed in order to fully test the subsystem. After all there is little point in simply repeating the unit test cases; the objective of a subsystem test should be to test boundary conditions and special cases that would be difficult to duplicate in unit tests.&lt;br /&gt;
&lt;br /&gt;
Once a subsystem has been tested, it can be integrated into a larger system, which is still a subset of the whole product. Tests can be written for larger and larger subsystems, but at each stage the complexity of the tests increases. At some point, the effort required to hand craft tests exceeds the benefits of running them. This is where integrated testing comes in.&lt;br /&gt;
&lt;br /&gt;
Integrated testing involves recording a user&#039;s interaction with the system into a script that can be replayed. The testing framework then compares the system&#039;s response with the expected response and passes or fails the test. The PHPUnit testing framework that we use has the ability to work with [http://seleniumhq.org/ Selenium], a browser based test automation tool. Writing a functional test using Selenium is documented [http://docs.joomla.org/Functional_Testing#Writing_Functional_Tests here].&lt;br /&gt;
&lt;br /&gt;
==== Test Objects ====&lt;br /&gt;
The purpose of unit tests is to isolate a module of code. A test that tests only one thing provides better information than a test that involves several object interactions. But how do we isolate an object from its dependencies? By writing stub classes. [http://xunitpatterns.com/Mocks,%20Fakes,%20Stubs%20and%20Dummies.html xUnit Patterns] defines a the hierarchy of dummy classes, ranging from simple to complex:&lt;br /&gt;
* Dummy - Defines attributes and methods of a dummy class (not particularly useful in PHP).&lt;br /&gt;
* Fake - Provides canned responses to method calls and fixed attribute values. Good for speed.&lt;br /&gt;
* Stub - Allows the test to define responses to method calls (return values, exceptions) to simulate the dependent object.&lt;br /&gt;
* Spy - A Fake or Stub that records method calls and parameters for later analysis.&lt;br /&gt;
* Mock - A Fake or Stub with a set of expectations -- method calls and parameters -- that are automatically verified for correctness.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests.&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk used to contain code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
The PHPUnit tests are found in &#039;&#039;&#039;/tests/unit&#039;&#039;&#039; in the development trunk. See [http://docs.joomla.org/Running_Automated_Tests_for_Version_1.6 Running Automated Tests for Version 1.6] for instructions on setting up unit testing in your IDE.&lt;br /&gt;
&lt;br /&gt;
==== The Unit Test Team ====&lt;br /&gt;
If you can commit to the Joomla code base, then you should consider yourself part of the unit test team!&lt;br /&gt;
&lt;br /&gt;
Writing tests concurrently with code (or even before) is a good way to not only save development time, but a great tool for defending against regressions. Writing tests early in the development cycle also helps identify and resolve design issues sooner, which reduces refactoring.&lt;br /&gt;
&lt;br /&gt;
If you want to get started on unit testing, get in touch with Alan Langford (instance) or Ray Tsai (mihu). Either of us will be happy to help out.&lt;br /&gt;
&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-Test.php, for example JObject-0000-class-Test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;br /&gt;
* The custom test runner is no longer needed. The current tests will run with the latest SVN version of PHPUnit 3.4. This code will eventually become PHPUnit 3.4.1.  Thanks to Sebastian Bergmann for his excellent work on an excellent project!&lt;br /&gt;
&lt;br /&gt;
==== Writing Unit Tests ====&lt;br /&gt;
At risk of stating the obvious, in the &amp;quot;purest&amp;quot; case the purpose of a unit test is to &#039;&#039;isolate a unit of code from its environment and to test the operation of that code&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This isolation is usually achieved by writing dummy classes that emulate the code unit&#039;s environment. These dummy objects can be passive, by simply simulating the environment, or they can be more active, keeping track of how they are being used by the test unit and reporting any variations from the expected behaviour. See [[Unit_Testing_Mock_Objects|Mock Objects in Joomla]] for a detailed example.&lt;br /&gt;
&lt;br /&gt;
An interesting aspect of writing tests is that they become &#039;&#039;de facto&#039;&#039; detailed technical specifications of the interfaces between units of code. The fact that these specifications can be verified in an automated way makes them a superb resource when refactoring code.&lt;br /&gt;
&lt;br /&gt;
The test code has a few templates designed to kick-start a test. They are:&lt;br /&gt;
&lt;br /&gt;
/unittest/sample-datatest-php.txt&lt;br /&gt;
/unittest/sample-simpletest.php.txt&lt;br /&gt;
&lt;br /&gt;
Here are some example tests: [[Unit_Testing_--_a_Simple_Example|Simple Example]], [[Unit_Testing_--_Data_Driven_Example|Data Driven Example]], [[Unit_Testing_--_Plugin_Example|Plugin Example]], [[Unit_Testing_--_UI_Example|UI Example]].&lt;br /&gt;
&lt;br /&gt;
==== Running Unit Tests ====&lt;br /&gt;
Test files follow the form classnameTest.php, for example JObjectTest.php. For tests that are not class based, use the name of the file being tested.&lt;br /&gt;
&lt;br /&gt;
Joomla unit tests use the standard PHPUnit test runner.  See http://www.phpunit.de for documentation.&lt;br /&gt;
&lt;br /&gt;
== How to Get it Running ==&lt;br /&gt;
&lt;br /&gt;
Before you start make sure you have installed PHPUnit and of course PHP (5!) properly...&lt;br /&gt;
&lt;br /&gt;
To get the unit tests to run on your Joomla! installation, perform the following steps:&lt;br /&gt;
* Create an instance of your Joomla! installation. Since you will be using SVN to check out the testing project, you don&#039;t want to check out the Joomla! with SVN. Instead, simply unpack a normal Joomla! archive. If you are using Eclipse, you can create a folder in your Eclipse workspace for the Joomla! installation, but don&#039;t create an Eclipse project yet.&lt;br /&gt;
* In the root checkout (or export) the latest version of the unit test code from SVN &#039;&#039;&amp;quot;/testing/trunk/1.5/unittest&amp;quot;&#039;&#039; or &#039;&#039;&amp;quot;/testing/trunk/1.6/unittest&amp;quot;&#039;&#039; to your installation base. This will create a &#039;&#039;&amp;quot;/unittest&amp;quot;&#039;&#039; sub-folder under your joomla installation. If you are using Eclipse, Import the project from the SVN and use the same folder in your Eclipse workspace you used above.&lt;br /&gt;
* From the command line, change to the unittest directory.&lt;br /&gt;
* Run the unit test from the command prompt using the following command: &amp;lt;code&amp;gt;phpunit tests&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The unit test will the run, and the results are rendered. You will see a series of dots for each passed test and other letters for failed tests. &lt;br /&gt;
&lt;br /&gt;
See http://www.phpunit.de/manual/current/en/textui.html for help using the --filter switch to run only certain tests.  There are also many other command line switches you can use to get results in various formats.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
The provided configurations should work out of the box. We have seen problems with it (currently the cause is unknown). If you get an error like below, the solution is pretty easy.&lt;br /&gt;
&lt;br /&gt;
 file=/var/www/unittest/runtests.php&lt;br /&gt;
 posn=17&lt;br /&gt;
 base=runtests.php&lt;br /&gt;
 /var/www&lt;br /&gt;
  JPATH_BASE does not point to a valid Joomla! installation:&lt;br /&gt;
 JPATH_BASE = /var/www&lt;br /&gt;
  Please modify your copy of &amp;quot;TestConfiguration.php&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Modify the &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file and change the definition of the JPATH_BASE so it points to the path of you Joomla! installation, in the example below the Joomla! installation is installed at &amp;quot;&#039;&#039;/var/www/update&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 define(&#039;JPATH_BASE&#039;, &#039;/var/www/update&#039;);&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&#039;&#039;&#039;Why can&#039;t I use &amp;quot;phpunit &#039;&#039;testname.php&#039;&#039;&amp;quot; to run my tests?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The test facility has to do some work to be able to load the &amp;quot;Joomla!&amp;quot; framework and to be able to inject mock classes. It&#039;s difficult to do this from the PHPUnit test runner, so we built our own. Also, the Joomla test runner has specific options designed to make it easy to select specific tests. Over time we will add more functionality to the test runner so it has many of the capabilities of the phpunit command.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[http://www.phpunit.de/manual/current/en/ PHPUnit Manual]&lt;br /&gt;
&lt;br /&gt;
[[Category:Bug Squad]]&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Testing]]&lt;br /&gt;
[[Category:Automated Testing]]&lt;/div&gt;</summary>
		<author><name>Paladin</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Coding_style_and_standards&amp;diff=31185</id>
		<title>Coding style and standards</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Coding_style_and_standards&amp;diff=31185"/>
		<updated>2010-09-29T22:25:50Z</updated>

		<summary type="html">&lt;p&gt;Paladin: added reference to the Joomla CodeSniffer page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{review}}&lt;br /&gt;
{{RightTOC}}&lt;br /&gt;
remark: The following information has been copied from the old WIKI archive has not yet been reviewed.&lt;br /&gt;
See: http://dev.joomla.org/component/option,com_jd-wiki/Itemid,/id,standards:coding/&lt;br /&gt;
&lt;br /&gt;
Good coding standards are important in any development project, but particularly when multiple developers are working on the same project. Having coding standards helps ensure that the code is of high quality, has fewer bugs, and is easily maintained.&lt;br /&gt;
&lt;br /&gt;
First rule, if in doubt, ask. There is [[Joomla_CodeSniffer|a tool available]] to help your code conform to the standards.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
All files contributed to Joomla must:&lt;br /&gt;
&lt;br /&gt;
* Be stored as ASCII text&lt;br /&gt;
* Use UTF-8 character encoding&lt;br /&gt;
* Be Unix formatted&lt;br /&gt;
** Lines must end only with a line feed (LF). Line feeds are represented as ordinal 10, octal 012 and hex 0A. Do not use carriage returns (CR) like Macintosh computers do or the carriage return/line feed combination (CRLF) like Windows computers do.&lt;br /&gt;
&lt;br /&gt;
New files will normally be added to the code base using Subversion (SVN). All SVN files should have the SVN property set &amp;quot;eol-style=LF&amp;quot;. Also, most Joomla! files will have &amp;quot;$Id&amp;quot; tags in the &amp;quot;@version&amp;quot; line of the Doc block. These require the SVN property &amp;quot;keywords=Id&amp;quot;. See [[Subversion File Properties]] for more information about how to set SVN properties.&lt;br /&gt;
&lt;br /&gt;
== Coding Standards ==&lt;br /&gt;
&lt;br /&gt;
=== Spelling ===&lt;br /&gt;
&lt;br /&gt;
Spelling of class, function, variable and constant names should generally be in accordance with British English rules (en_GB).  However, some exceptions are permitted, for example where common programming names are used that align with the PHP API such as &amp;lt;code&amp;gt;$color&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== E_STRICT-compatible code ===&lt;br /&gt;
&lt;br /&gt;
As of version 1.6, all new code that is suggested for inclusion into Joomla must be E_STRICT-compatible. This means that it must not produce any warnings or errors when PHP&#039;s error reporting level is set to E_ALL | E_STRICT.&lt;br /&gt;
&lt;br /&gt;
=== Indenting and Line Length ===&lt;br /&gt;
&lt;br /&gt;
Use tabs to indent, not spaces. Make sure that the tab-stops are set to only 4 spaces in length.&lt;br /&gt;
&lt;br /&gt;
There is no set limit for line length.  Use your judgment based on the nature of the line and readability.&lt;br /&gt;
&lt;br /&gt;
=== Control Structures ===&lt;br /&gt;
&lt;br /&gt;
These include if, for, while, switch, etc. Here is an example of an if statement, as it is the most complicated of the control structures:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
if ((condition1) || (condition2)) {&lt;br /&gt;
    action1();&lt;br /&gt;
} else if ((condition3) &amp;amp;&amp;amp; (condition4)) {&lt;br /&gt;
    action2();&lt;br /&gt;
} else {&lt;br /&gt;
    defaultAction();&lt;br /&gt;
    anotherAction();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// optional formatting if it improves readability&lt;br /&gt;
if ((condition1) || (condition2)) {&lt;br /&gt;
    action1();&lt;br /&gt;
} else if ((condition3) &amp;amp;&amp;amp; (condition4)) {&lt;br /&gt;
    action2();&lt;br /&gt;
} else {&lt;br /&gt;
    defaultAction();&lt;br /&gt;
    anotherAction();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Control statements should have one space between the control keyword and opening parenthesis, to distinguish them from function calls.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;layouts&#039;&#039;&#039;, the alternative named notation should be used:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
if ((condition1) OR (condition2)) :&lt;br /&gt;
    action1();&lt;br /&gt;
elseif ((condition3) AND (condition4)) :&lt;br /&gt;
    action2();&lt;br /&gt;
else :&lt;br /&gt;
    defaultAction();&lt;br /&gt;
    anotherAction();&lt;br /&gt;
endif;&lt;br /&gt;
&lt;br /&gt;
foreach ($array as $element) :&lt;br /&gt;
    echo $element;&lt;br /&gt;
endforeach;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Logical operators in condition statements should use uppercase words (&amp;lt;code&amp;gt;AND&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;OR&amp;lt;/code&amp;gt;, etc) rather than programmatic notation (&amp;lt;code&amp;gt;&amp;amp;&amp;amp;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;||&amp;lt;/code&amp;gt;, etc).&lt;br /&gt;
&lt;br /&gt;
With the exception of &amp;lt;code&amp;gt;case&amp;lt;/code&amp;gt; statements, curly braces must always be included even though they are technically optional. Having them increases readability and decreases the likelihood of logic errors being introduced when new lines are added.&lt;br /&gt;
&lt;br /&gt;
For switch statements:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
switch (condition) {&lt;br /&gt;
    case 1:&lt;br /&gt;
        doAction1();&lt;br /&gt;
        break;&lt;br /&gt;
    case 2:&lt;br /&gt;
        doAction2();&lt;br /&gt;
        break;&lt;br /&gt;
    default:&lt;br /&gt;
        doDefaultAction();&lt;br /&gt;
        break;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use indenting and line-breaks rather than curly braces in the &amp;lt;code&amp;gt;case&amp;lt;/code&amp;gt; statements to increase readability.  There should be no space between the condition and the colon in the &amp;lt;code&amp;gt;case&amp;lt;/code&amp;gt; statement.&lt;br /&gt;
&lt;br /&gt;
=== Function Calls ===&lt;br /&gt;
&lt;br /&gt;
Functions should be called with no spaces between the function name and the opening parenthesis, and no space between this and the first parameter; a space after the comma between each parameter (if they are present), and no space between the last parameter and the closing parenthesis, and the semicolon. Here&#039;s an example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$var = foo($bar, $baz, $quux);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As displayed above, there should be space before and one space after the equals sign used to assign the return value of a function to a variable. In the case of a block of related assignments, tabs (not spaces) may be inserted to promote readability:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$short          = foo($bar);&lt;br /&gt;
$long_variable  = foo($baz);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Function Definitions ===&lt;br /&gt;
&lt;br /&gt;
Class and function declarations follow this convention:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
function fooFunction($arg1, $arg2 = &#039;&#039;)&lt;br /&gt;
{&lt;br /&gt;
    if (condition) {&lt;br /&gt;
        statement;&lt;br /&gt;
    }&lt;br /&gt;
    return $val;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class fooClass&lt;br /&gt;
{&lt;br /&gt;
    function fooMethod($arg1)&lt;br /&gt;
    {&lt;br /&gt;
        if ($arg) {&lt;br /&gt;
            $result = true;&lt;br /&gt;
        } else {&lt;br /&gt;
            $result = false;&lt;br /&gt;
        }&lt;br /&gt;
        return $result;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Arguments with default values go at the end of the argument list. Always attempt to return a meaningful value from a function if one is appropriate. Here is a slightly longer example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
function connect(&amp;amp;$dsn, $persistent = false)&lt;br /&gt;
{&lt;br /&gt;
    if (is_array($dsn)) {&lt;br /&gt;
        $dsninfo = &amp;amp;$dsn;&lt;br /&gt;
    } else {&lt;br /&gt;
        $dsninfo = DB::parseDSN($dsn);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    if (!$dsninfo OR !$dsninfo[&#039;phptype&#039;]) {&lt;br /&gt;
        return $this-&amp;gt;raiseError();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Comments ===&lt;br /&gt;
&lt;br /&gt;
Inline documentation for classes should follow the PHPDoc convention, similar to Javadoc. More information about PHPDoc can be found here: http://www.phpdoc.org/&lt;br /&gt;
&lt;br /&gt;
See also [[Adding phpDocumentor comments]]&lt;br /&gt;
&lt;br /&gt;
Non-documentation comments are strongly encouraged. A general rule of thumb is that if you look at a section of code and think &amp;quot;Wow, I don&#039;t want to try and describe that&amp;quot;, you need to comment it before you forget how it works.&lt;br /&gt;
&lt;br /&gt;
C style comments (&amp;lt;tt&amp;gt;/* */&amp;lt;/tt&amp;gt;) and standard C++ comments (&amp;lt;tt&amp;gt;//&amp;lt;/tt&amp;gt;) are both satisfactory. Use of Perl/shell style comments (&amp;lt;tt&amp;gt;#&amp;lt;/tt&amp;gt;) is not permitted.&lt;br /&gt;
&lt;br /&gt;
Please note - commented code is not to be committed to trunk or release repositories.&lt;br /&gt;
&lt;br /&gt;
=== Including Code ===&lt;br /&gt;
&lt;br /&gt;
Anywhere you are unconditionally including a class file, use &amp;lt;code&amp;gt;require_once&amp;lt;/code&amp;gt;. Anywhere you are conditionally including a class file (for example, factory methods), use &amp;lt;code&amp;gt;include_once&amp;lt;/code&amp;gt;. Either of these will ensure that class files are included only once. They share the same file list, so you don&#039;t need to worry about mixing them -- a file included with &amp;lt;code&amp;gt;require_once&amp;lt;/code&amp;gt; will not be included again by &amp;lt;/code&amp;gt;include_once&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
;Note: [[php:include_once|include_once]] and [[php:require_once|require_once]] are PHP &#039;&#039;language statements&#039;&#039;, not functions. You don&#039;t need parentheses around the filename to be included.&lt;br /&gt;
&lt;br /&gt;
=== PHP Code Tags ===&lt;br /&gt;
&lt;br /&gt;
Always use &amp;lt;tt&amp;gt;&amp;amp;lt;?php ?&amp;gt;&amp;lt;/tt&amp;gt; to delimit PHP code, not the &amp;lt;tt&amp;gt;&amp;amp;lt;? ?&amp;gt;&amp;lt;/tt&amp;gt; shorthand. This is the most portable way to include PHP code on differing operating systems and setups.&lt;br /&gt;
&lt;br /&gt;
For files that contain only PHP code, the closing tag (&amp;lt;tt&amp;gt;?&amp;gt;&amp;lt;/tt&amp;gt;) is never permitted. It is not required by PHP. Not including it prevents trailing white space from being accidentally injected into the output (see PHP manual on [http://au.php.net/basic-syntax.instruction-separation instruction separation]).&lt;br /&gt;
&lt;br /&gt;
=== SQL Queries ===&lt;br /&gt;
&lt;br /&gt;
SQL keywords are to be written in uppercase, while all other identifiers (which the exception of quoted text obviously) is to be in lowercase. Carriage returns should not be used as [[JDatabase]]::getQuery provides for formatted output.  However, indenting with spaces to improve readability is desireable.&lt;br /&gt;
&lt;br /&gt;
Queries should be wrapped in single quotes (as these text blocks are parsed faster by php).&lt;br /&gt;
&lt;br /&gt;
All quoted strings must use the &#039;&#039;Quote&#039;&#039; method to facilitate future compatibility with other database engines.&lt;br /&gt;
&lt;br /&gt;
All table names should use the &#039;&#039;&#039;&amp;lt;tt&amp;gt;#_&amp;lt;/tt&amp;gt;&#039;&#039;&#039; prefix rather than &amp;lt;tt&amp;gt;jos_&amp;lt;/tt&amp;gt; to access Joomla! contents and allow for the [[screen.config.15#Database_Settings|user defined database prefix]] to be applied.&lt;br /&gt;
&lt;br /&gt;
All expected integer or floating-point variable must be [http://php.net/manual/language.types.type-juggling.php cast] with &amp;lt;tt&amp;gt;(int)&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;(float)&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;(double)&amp;lt;/tt&amp;gt; as appropriate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$state = 1;&lt;br /&gt;
$name  = &#039;bill&#039;;&lt;br /&gt;
$db    = &amp;amp;JFactory::getDBO();&lt;br /&gt;
$query = &#039;SELECT COUNT( c.id ) AS num_articles, u.id, u.username&#039;.&lt;br /&gt;
    &#039; FROM #__content AS c&#039;.&lt;br /&gt;
    &#039; LEFT JOIN #__users AS u ON u.id = c.created_by&#039;.&lt;br /&gt;
    &#039; WHERE c.state = &#039;.(int) $state&lt;br /&gt;
    &#039;  AND u.id IS NOT NULL&#039;.&lt;br /&gt;
    &#039;  AND u.username &amp;lt;&amp;gt; &#039;.$db-&amp;gt;Quote( $name ).&lt;br /&gt;
    &#039; GROUP BY u.id&#039;.&lt;br /&gt;
    &#039;  HAVING COUNT( c.id ) &amp;gt; 0&#039;;&lt;br /&gt;
$db-&amp;gt;setQuery();&lt;br /&gt;
// Output formated query if joomla debug is active:&lt;br /&gt;
if (JDEBUG) {&lt;br /&gt;
    echo $db-&amp;gt;getQuery();&lt;br /&gt;
}&lt;br /&gt;
$stats = $db-&amp;gt;loadObjectList();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Doc Blocks ===&lt;br /&gt;
&lt;br /&gt;
All source code files in the core Joomla distribution must contain the following comment block as the header:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Short description of file&lt;br /&gt;
 *&lt;br /&gt;
 * Longer description of file is optional, but should be included if the file contains multiple classes or non-class material.&lt;br /&gt;
 *&lt;br /&gt;
 * PHP version 5.2.4 (put in the minimum version of PHP expected for the code here to run)&lt;br /&gt;
 *&lt;br /&gt;
 * @version	$Id$&lt;br /&gt;
 * @package	Joomla&lt;br /&gt;
 * @copyright	Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.&lt;br /&gt;
 * @license	GNU/GPL, see LICENSE.php&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;@package&amp;lt;/code&amp;gt; in the header is not required for class-only files.&lt;br /&gt;
&lt;br /&gt;
Classes, functions, constants, class properties and class methods should all be supplied with appropriate DocBlocks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * Short description for class&lt;br /&gt;
 *&lt;br /&gt;
 * Long description for class (if any)...&lt;br /&gt;
 *&lt;br /&gt;
 * @package    PackageName&lt;br /&gt;
 * @subpackage SubPackageName&lt;br /&gt;
 * @link       http://pear.php.net/package/PackageName&lt;br /&gt;
 * @see        NetOther, Net_Sample::Net_Sample()&lt;br /&gt;
 * @since      Class available since Release 1.2.0&lt;br /&gt;
 * @deprecated Class deprecated in Release 2.0.0&lt;br /&gt;
 */&lt;br /&gt;
class JFooBar&lt;br /&gt;
{&lt;br /&gt;
    /**&lt;br /&gt;
     * @var int $id Primary key&lt;br /&gt;
     */&lt;br /&gt;
    public $id = null;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following package names are to be used in the core stack:&lt;br /&gt;
&lt;br /&gt;
* Joomla.Administrator - all files that belong only to the administrator or backend application&lt;br /&gt;
* Joomla.Installation - all files that belong to the installation application&lt;br /&gt;
* Joomla.Plugin - all plugin files&lt;br /&gt;
* Joomla.Site - all files that pertain only to the site or frontend application&lt;br /&gt;
* Joomla.XML-RPC - all files that belong to the XML-RPC server application&lt;br /&gt;
&lt;br /&gt;
The sub-package name will vary according to the extension type:&lt;br /&gt;
&lt;br /&gt;
* Components - the component folder, eg &amp;lt;code&amp;gt;com_content&amp;lt;/code&amp;gt;&lt;br /&gt;
* Modules - the module folder, eg &amp;lt;code&amp;gt;mod_latest_news&amp;lt;/code&amp;gt;&lt;br /&gt;
* Plugins - the folder.element, eg &amp;lt;code&amp;gt;content.pagebreak&amp;lt;/code&amp;gt;&lt;br /&gt;
* Templates - the template folder, eg &amp;lt;code&amp;gt;rhuk_milkyway&amp;lt;/code&amp;gt;&lt;br /&gt;
* Framework - nothing for top level files (such as &amp;lt;code&amp;gt;factory.php&amp;lt;/code&amp;gt;), the first level folder or the first.second level folders as appropriate, eg &amp;lt;code&amp;gt;utilities&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;joomla/utilities/date.php&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;html.html&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;joomla/html/html/email.php&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please note that code contributed to the Joomla stack that will become the copyright of the project is not allowed to include &amp;lt;code&amp;gt;@author&amp;lt;/code&amp;gt; tags.  You should update the contribution log in &amp;lt;tt&amp;gt;CREDITS.php&amp;lt;/tt&amp;gt;.  Joomla&#039;s philosophy is that the code is written &amp;quot;all together&amp;quot; and there is no notion of any one person &#039;owning&#039; any section of code.&lt;br /&gt;
&lt;br /&gt;
Files included from third party sources must leave DocBlocks intact. Layout files use the same DocBlocks as other PHP files. &lt;br /&gt;
&lt;br /&gt;
Note that the &amp;quot;@version $Id&amp;quot; line uses the SVN &amp;quot;keywords=Id&amp;quot; property. See [[Subversion File Properties]] for information about setting this property.&lt;br /&gt;
&lt;br /&gt;
== Naming Conventions ==&lt;br /&gt;
&lt;br /&gt;
=== Classes ===&lt;br /&gt;
&lt;br /&gt;
Classes should be given descriptive names. Avoid using abbreviations where possible. Class names should always begin with an uppercase letter and be written in CamelCase even if using traditionally uppercase acronyms (such as XML, HTML).  One exception is for Joomla framework classes which must begin with an uppercase &#039;J&#039; with the next letter also being uppercase.  For example:&lt;br /&gt;
&lt;br /&gt;
* JHtmlHelper&lt;br /&gt;
* JXmlParser&lt;br /&gt;
* JModel&lt;br /&gt;
&lt;br /&gt;
Third-party developers are advised to namespace their functions with a unique prefix.&lt;br /&gt;
&lt;br /&gt;
=== Functions and Methods ===&lt;br /&gt;
&lt;br /&gt;
Functions and methods should be named using the &amp;quot;studly caps&amp;quot; style (also referred to as &amp;quot;bumpy case&amp;quot; or &amp;quot;camel caps&amp;quot;). The initial letter of the name is lowercase, and each letter that starts a new &amp;quot;word&amp;quot; is capitalized. Function in the Joomla framework must begin with a lowercase &#039;j&#039;.  Some examples:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
connect();&lt;br /&gt;
getData();&lt;br /&gt;
buildSomeWidget();&lt;br /&gt;
jImport();&lt;br /&gt;
jDoSomething();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Private class members (meaning class members that are intended to be used only from within the same class in which they are declared; are preceded by a single underscore. Properties are to be written in underscore format (that is, logical words separated by underscores) and should be all lowercase.  For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class JFooBar&lt;br /&gt;
{&lt;br /&gt;
    // Joomla 1.5 and earlier format&lt;br /&gt;
    var $_status = null;&lt;br /&gt;
&lt;br /&gt;
    function _sort()&lt;br /&gt;
    {&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Joomla 1.6 format&lt;br /&gt;
    private $_status = null;&lt;br /&gt;
&lt;br /&gt;
    protected $field_name = null;&lt;br /&gt;
&lt;br /&gt;
    protected function _sort()&lt;br /&gt;
    {&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Constants ===&lt;br /&gt;
&lt;br /&gt;
Constants should always be all-uppercase, with underscores to separate words. Prefix constant names with the uppercase name of the class/package they are used in. For example, the constants used by the [[JError]] class all begin with &amp;quot;JERROR_&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Global Variables ===&lt;br /&gt;
&lt;br /&gt;
If your package needs to define global variables, their name should start with a single underscore followed by the uppercase class/package name and another underscore. For example, the JError class uses a global variable called $_JERROR_LEVELS.&lt;br /&gt;
&lt;br /&gt;
With PHP5 and later you may use static class properties or constants instead of globals.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
class JWhatever&lt;br /&gt;
{&lt;br /&gt;
    public static $instance = null;&lt;br /&gt;
    const SUCCESS = 1;&lt;br /&gt;
    const FAILURE = 0;&lt;br /&gt;
    // Methods...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Regular and Class Variables ===&lt;br /&gt;
&lt;br /&gt;
Regular variables, follow the same conventions as function.&lt;br /&gt;
&lt;br /&gt;
Class variables should be set to null or some other appropriate default value. Lining up the default values with tabs should only be used if particularly warranted for readability.&lt;br /&gt;
&lt;br /&gt;
=== References ===&lt;br /&gt;
&lt;br /&gt;
When using references, there should be a space before the reference operator and no space between it and the function or variable name.  For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$ref1  = &amp;amp;$this-&amp;gt;_sql;&lt;br /&gt;
$db    = &amp;amp;JFactory::getDBO();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Language Keys ===&lt;br /&gt;
&lt;br /&gt;
NOTE: This part has to be rewritten for 1.6 (JM)&lt;br /&gt;
&lt;br /&gt;
Except for the most common of words, such as &amp;quot;Yes&amp;quot;, &amp;quot;No&amp;quot;, &amp;quot;Show&amp;quot;, &amp;quot;Hide&amp;quot; all language keys should be namespaced to reflect the type of string they represent.  Always consider that if two extensions use the same key, the one loaded last will be the one that displays.  Namespacing should generally relate to the extension displaying the text. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
echo JText::_(&#039;Weblink Link&#039;);&lt;br /&gt;
echo JText::_(&#039;Weblink Title&#039;);&lt;br /&gt;
echo JText::_(&#039;Weblink Description&#039;);&lt;br /&gt;
&lt;br /&gt;
echo JText::_(&#039;Exception An error occurred while saving&#039;);&lt;br /&gt;
?&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TODO: Link to page with &amp;quot;common&amp;quot; strings that can be used for typical actions in components, such a &amp;quot;Save&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Where the same English word is used in two different locations, two different language keys should be used to allow for cases where the translation results in different words or phrases.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// A table column title&lt;br /&gt;
&amp;lt;th&amp;gt;&amp;lt;?php echo JText::_(&#039;Weblink Column Title&#039;);?&amp;gt;&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;&amp;lt;?php echo JText::_(&#039;Weblink Column Link&#039;);?&amp;gt;&amp;lt;/th&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// In the form&lt;br /&gt;
&amp;lt;?php echo JText::_(&#039;Weblink Title&#039;);?&amp;gt;&amp;lt;input name=&amp;quot;title&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;?php echo JText::_(&#039;Weblink Link&#039;);?&amp;gt;&amp;lt;input name=&amp;quot;link&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Toolbar and Linkbar text should be prefixed Toolbar and Linkbar respectively.&lt;br /&gt;
&lt;br /&gt;
The language keys should be written as naturally as possible with spaces, not underscores separating words.  Long phrases can be condensed to reduce keys to a sensible length.  For example, tooltips for an edit field can be written like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php echo JText::_(&#039;Weblink Title&#039;);?&amp;gt;&amp;lt;input name=&amp;quot;title&amp;quot; title=&amp;quot;&amp;lt;?php echo JText::_(&#039;Weblink Title Desc&#039;);?&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The convention used should be governed by common sense, but must be consistent.  In general consider how the language file will look with all keys sorted alphabetically.  Prefixes should be used to group text within a common context (such as column headings).  Suffixes should be used to group elements that logically go together (such as a field name and its description).&lt;br /&gt;
&lt;br /&gt;
Phrases must never be assembled by string concatenation. Each phrase must be represented by a single language key, using sprintf as appropriate to replace dynamic words in the phrase.  Where replacements are made, the word used should be as descriptive as possible and all-uppercase.  This assists the translators to determine the context of the replacement.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
// Not permitted&lt;br /&gt;
echo JText::_(&#039;Deleted &#039;).$n.JText::_(&#039; items&#039;);&lt;br /&gt;
&lt;br /&gt;
// Permitted&lt;br /&gt;
echo JText::sprintf(&#039;Message Deleted NUMBER items&#039;, $n);&lt;br /&gt;
?&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reference in the language file would look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;MESSAGE DELETED NUMBER ITEMS=Deleted %d Item(s)&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If more than one dynamic string is used in a phrase, the printf markers should employ order placement as other languages might change the position of the strings. This is done via %[number]$[printf_type] as follows:&lt;br /&gt;
&lt;br /&gt;
Left to right language:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;PAGE X OF Y=Page %1$d of %2$d&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Right to left language:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;PAGE X OF Y=%2$d of %1$d egaP&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
&lt;br /&gt;
For single controller components, the naming convention is &#039;&#039;[Name]Controller&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Content Controller&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class ContentController extends JController&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The file name will generally be &#039;&#039;controller.php&#039;&#039; and is located in the component folder.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
com_content&lt;br /&gt;
 / controller.php&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a multi-controller components, such as the Banners in the Administrator, the convention is &#039;&#039;[Component]Controller[Name]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Banner Client Controller&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class BannerControllerClient extends JController&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The files will be located in a &amp;lt;tt&amp;gt;/controllers/&amp;lt;/tt&amp;gt; folder under the component folder.  The file names will reflect the name of the controller.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
com_banner&lt;br /&gt;
  /controllers/&lt;br /&gt;
    / banner.php&lt;br /&gt;
    / client.php&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Models===&lt;br /&gt;
&lt;br /&gt;
The naming convention is &#039;&#039;[Component]Model[Name]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Banner Client Model&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class BannerModelClient extends JModel&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The files will be located in a &amp;lt;tt&amp;gt;/models/&amp;lt;/tt&amp;gt; folder under the component folder.  The file names will reflect the name of the model.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
com_banner&lt;br /&gt;
  /models/&lt;br /&gt;
    / banner.php&lt;br /&gt;
    / client.php&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Views ===&lt;br /&gt;
The naming convention is &#039;&#039;[Component]View[Name]&#039;&#039;.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Contact Category View&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class ContactViewCategory extends JView&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The files will be located in a &amp;lt;tt&amp;gt;/view/&amp;lt;/tt&amp;gt; folder under the component folder. The subfolder names will reflect the name of a View.&lt;br /&gt;
&lt;br /&gt;
 com_contact&lt;br /&gt;
  /views/&lt;br /&gt;
    /&#039;&#039;view name 1&#039;&#039;/&lt;br /&gt;
      / view.html.php&lt;br /&gt;
    /&#039;&#039;view name 2&#039;&#039;/&lt;br /&gt;
      / view.html.php&lt;br /&gt;
&lt;br /&gt;
Multi-view components such as com_content may provide an optional &amp;quot;master&amp;quot; view class the specialised views extend from. It is located in the component folder and typically called &#039;&#039;view.php&#039;&#039;. The naming convention is &#039;&#039;[Component]View&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 com_content&lt;br /&gt;
  /views/&lt;br /&gt;
     &amp;lt;span style=&amp;quot;color:#999&amp;quot;&amp;gt;/archive/&amp;lt;/span&amp;gt;&lt;br /&gt;
       / view.html.php&lt;br /&gt;
     &amp;lt;span style=&amp;quot;color:#999&amp;quot;&amp;gt;/article/&amp;lt;/span&amp;gt;&lt;br /&gt;
  / view.php&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
view.php&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Content View&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class ContentView extends JView&lt;br /&gt;
{&lt;br /&gt;
    // Helper Methods&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
views/archive/view.html.php&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Content Archive View&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class ContactViewArchive extends ContentView&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Plugins ===&lt;br /&gt;
&lt;br /&gt;
The naming convention is &#039;&#039;plg[Folder][Element]&#039;&#039; as pointed out in [[How to create a content plugin|the relative HowTo page]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class plgContentPagebreak extends JPlugin&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Layouts ===&lt;br /&gt;
Components may support different Layouts to render the data supplied by a [[#Views|View]] and its [[#Models|Models]]. A Layout file usually contains markup and some PHP code for &#039;&#039;display logic only&#039;&#039;: no functions, no classes.&lt;br /&gt;
&lt;br /&gt;
A Layout consists of at least one .php file and an equally named [[Creating a basic layout.xml file|.xml manifest file]] located in the &amp;lt;tt&amp;gt;/tmpl/&amp;lt;/tt&amp;gt; folder of a View, both reflect the internal name of the Layout. The standard Layout is called &#039;&#039;default&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:#999&amp;quot;&amp;gt;com_content&lt;br /&gt;
   /views/&lt;br /&gt;
     /article/&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:#000&amp;quot;&amp;gt;&lt;br /&gt;
       /tmpl/&lt;br /&gt;
         / default.php&lt;br /&gt;
         / default.xml&lt;br /&gt;
         / form.php&lt;br /&gt;
         / form.xml&lt;br /&gt;
         / pagebreak.php&lt;br /&gt;
         / pagebreak.xml &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Layout may use supplemental .php files to provide more granule control in order to render individual parts or repetitive items of the data.&lt;br /&gt;
&lt;br /&gt;
Users may customize the Layout output via [[#Template Layout Overrides|Template Layout Overrides]].&lt;br /&gt;
&lt;br /&gt;
=== Templates ===&lt;br /&gt;
&lt;br /&gt;
=== Template Layout Overrides ===&lt;/div&gt;</summary>
		<author><name>Paladin</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Joomla_CodeSniffer&amp;diff=31184</id>
		<title>Joomla CodeSniffer</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Joomla_CodeSniffer&amp;diff=31184"/>
		<updated>2010-09-29T22:21:12Z</updated>

		<summary type="html">&lt;p&gt;Paladin: /* A Nose For Joomla */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;(This page needs expanded installation instructions, especially for Windows-based systems.)&lt;br /&gt;
&lt;br /&gt;
== A Nose For Joomla ==&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
This is a custom coding standard for the PHP CodeSniffer that attempts to codify and enforce the Joomla coding standards.&lt;br /&gt;
&lt;br /&gt;
==Why?==&lt;br /&gt;
&lt;br /&gt;
The reasons seem obvious, but one look at reality shows they aren&#039;t, so I&#039;ll enumerate some of them here:&lt;br /&gt;
&lt;br /&gt;
- Coherent and consisting coding practice makes the files look more professional. Conflicting styles in the same project (or worse, the same file) not only look sloppy, they encourage further sloppiness.&lt;br /&gt;
&lt;br /&gt;
- When all code complies with the same standard, bad code is easier for everyone to spot.&lt;br /&gt;
&lt;br /&gt;
- It makes it easier for someone new to a particular file in the project to find and fix errors, or extend functionality.&lt;br /&gt;
&lt;br /&gt;
- If there is no consistent standard maintained, the sometimes developers will reformat the code to suit themselves. This causes a wide range of changes in the code repository, and if there is a later problem, a significant change could be lost in the chaff produced by a diff.&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
&lt;br /&gt;
First you&#039;ll need to install phpcs (http://pear.php.net/package/PHP_CodeSniffer/download/). This set of files is intended to work with phpcs version 1.3, so behavior with any other version is undefined.&lt;br /&gt;
&lt;br /&gt;
Then download and unzip the [http://joomlacode.org/gf/project/jcodesniffer/ Joomla CodeSniffer], and copy the contents of it into /path/to/PHP_CodeSniffer/Standards/Joomla. (The path on some systems is /usr/lib/php/PHP/PHP_CodeSniffer but this varies from system to system. Use &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;pear config-get php_dir&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to find out where the PEAR directory is on your system, then add &amp;quot;/PHP/PHP_CodeSniffer&amp;quot; to it.)&lt;br /&gt;
&lt;br /&gt;
You invoke the custom standard by&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;phpcs --standard=Joomla --tab-width=4 file/to/sniff&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Further documentation on the use of phpcs can be found at: [http://pear.php.net/package/PHP_CodeSniffer/docs]&lt;/div&gt;</summary>
		<author><name>Paladin</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Joomla_CodeSniffer&amp;diff=31183</id>
		<title>Joomla CodeSniffer</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Joomla_CodeSniffer&amp;diff=31183"/>
		<updated>2010-09-29T22:19:32Z</updated>

		<summary type="html">&lt;p&gt;Paladin: /* A Nose For Joomla */ fixed == error&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== A Nose For Joomla ==&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
This is a custom coding standard for the PHP CodeSniffer that attempts to codify and enforce the Joomla coding standards.&lt;br /&gt;
&lt;br /&gt;
==Why?==&lt;br /&gt;
&lt;br /&gt;
The reasons seem obvious, but one look at reality shows they aren&#039;t, so I&#039;ll enumerate some of them here:&lt;br /&gt;
&lt;br /&gt;
- Coherent and consisting coding practice makes the files look more professional. Conflicting styles in the same project (or worse, the same file) not only look sloppy, they encourage further sloppiness.&lt;br /&gt;
&lt;br /&gt;
- When all code complies with the same standard, bad code is easier for everyone to spot.&lt;br /&gt;
&lt;br /&gt;
- It makes it easier for someone new to a particular file in the project to find and fix errors, or extend functionality.&lt;br /&gt;
&lt;br /&gt;
- If there is no consistent standard maintained, the sometimes developers will reformat the code to suit themselves. This causes a wide range of changes in the code repository, and if there is a later problem, a significant change could be lost in the chaff produced by a diff.&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
&lt;br /&gt;
First you&#039;ll need to install phpcs (http://pear.php.net/package/PHP_CodeSniffer/download/). This set of files is intended to work with phpcs version 1.3, so behavior with any other version is undefined.&lt;br /&gt;
&lt;br /&gt;
Then download and unzip the [http://joomlacode.org/gf/project/jcodesniffer/ Joomla CodeSniffer], and copy the contents of it into /path/to/PHP_CodeSniffer/Standards/Joomla. (The path on some systems is /usr/lib/php/PHP/PHP_CodeSniffer but this varies from system to system. Use &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;pear config-get php_dir&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to find out where the PEAR directory is on your system, then add &amp;quot;/PHP/PHP_CodeSniffer&amp;quot; to it.)&lt;br /&gt;
&lt;br /&gt;
You invoke the custom standard by&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;phpcs --standard=Joomla --tab-width=4 file/to/sniff&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Further documentation on the use of phpcs can be found at: [http://pear.php.net/package/PHP_CodeSniffer/docs]&lt;/div&gt;</summary>
		<author><name>Paladin</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Joomla_CodeSniffer&amp;diff=31182</id>
		<title>Joomla CodeSniffer</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Joomla_CodeSniffer&amp;diff=31182"/>
		<updated>2010-09-29T22:19:06Z</updated>

		<summary type="html">&lt;p&gt;Paladin: New page: == A Nose For Joomla ==    This is a custom coding standard for the PHP CodeSniffer that attempts to codify and enforce the Joomla coding standards.  ==Why?--  The reasons seem obvious, bu...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== A Nose For Joomla ==&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
This is a custom coding standard for the PHP CodeSniffer that attempts to codify and enforce the Joomla coding standards.&lt;br /&gt;
&lt;br /&gt;
==Why?--&lt;br /&gt;
&lt;br /&gt;
The reasons seem obvious, but one look at reality shows they aren&#039;t, so I&#039;ll enumerate some of them here:&lt;br /&gt;
&lt;br /&gt;
- Coherent and consisting coding practice makes the files look more professional. Conflicting styles in the same project (or worse, the same file) not only look sloppy, they encourage further sloppiness.&lt;br /&gt;
&lt;br /&gt;
- When all code complies with the same standard, bad code is easier for everyone to spot.&lt;br /&gt;
&lt;br /&gt;
- It makes it easier for someone new to a particular file in the project to find and fix errors, or extend functionality.&lt;br /&gt;
&lt;br /&gt;
- If there is no consistent standard maintained, the sometimes developers will reformat the code to suit themselves. This causes a wide range of changes in the code repository, and if there is a later problem, a significant change could be lost in the chaff produced by a diff.&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
&lt;br /&gt;
First you&#039;ll need to install phpcs (http://pear.php.net/package/PHP_CodeSniffer/download/). This set of files is intended to work with phpcs version 1.3, so behavior with any other version is undefined.&lt;br /&gt;
&lt;br /&gt;
Then download and unzip the [http://joomlacode.org/gf/project/jcodesniffer/ Joomla CodeSniffer], and copy the contents of it into /path/to/PHP_CodeSniffer/Standards/Joomla. (The path on some systems is /usr/lib/php/PHP/PHP_CodeSniffer but this varies from system to system. Use &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;pear config-get php_dir&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to find out where the PEAR directory is on your system, then add &amp;quot;/PHP/PHP_CodeSniffer&amp;quot; to it.)&lt;br /&gt;
&lt;br /&gt;
You invoke the custom standard by&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;phpcs --standard=Joomla --tab-width=4 file/to/sniff&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Further documentation on the use of phpcs can be found at: [http://pear.php.net/package/PHP_CodeSniffer/docs]&lt;/div&gt;</summary>
		<author><name>Paladin</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Coding_style_and_standards&amp;diff=31181</id>
		<title>Coding style and standards</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Coding_style_and_standards&amp;diff=31181"/>
		<updated>2010-09-29T22:07:28Z</updated>

		<summary type="html">&lt;p&gt;Paladin: /* Function Definitions */ The exemplar is *not* the &amp;quot;one true brace&amp;quot; convention, which specifies the opening brace be at the end of the function line, not on a new line&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{review}}&lt;br /&gt;
{{RightTOC}}&lt;br /&gt;
remark: The following information has been copied from the old WIKI archive has not yet been reviewed.&lt;br /&gt;
See: http://dev.joomla.org/component/option,com_jd-wiki/Itemid,/id,standards:coding/&lt;br /&gt;
&lt;br /&gt;
Good coding standards are important in any development project, but particularly when multiple developers are working on the same project. Having coding standards helps ensure that the code is of high quality, has fewer bugs, and is easily maintained.&lt;br /&gt;
&lt;br /&gt;
First rule, if in doubt, ask.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
All files contributed to Joomla must:&lt;br /&gt;
&lt;br /&gt;
* Be stored as ASCII text&lt;br /&gt;
* Use UTF-8 character encoding&lt;br /&gt;
* Be Unix formatted&lt;br /&gt;
** Lines must end only with a line feed (LF). Line feeds are represented as ordinal 10, octal 012 and hex 0A. Do not use carriage returns (CR) like Macintosh computers do or the carriage return/line feed combination (CRLF) like Windows computers do.&lt;br /&gt;
&lt;br /&gt;
New files will normally be added to the code base using Subversion (SVN). All SVN files should have the SVN property set &amp;quot;eol-style=LF&amp;quot;. Also, most Joomla! files will have &amp;quot;$Id&amp;quot; tags in the &amp;quot;@version&amp;quot; line of the Doc block. These require the SVN property &amp;quot;keywords=Id&amp;quot;. See [[Subversion File Properties]] for more information about how to set SVN properties.&lt;br /&gt;
&lt;br /&gt;
== Coding Standards ==&lt;br /&gt;
&lt;br /&gt;
=== Spelling ===&lt;br /&gt;
&lt;br /&gt;
Spelling of class, function, variable and constant names should generally be in accordance with British English rules (en_GB).  However, some exceptions are permitted, for example where common programming names are used that align with the PHP API such as &amp;lt;code&amp;gt;$color&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== E_STRICT-compatible code ===&lt;br /&gt;
&lt;br /&gt;
As of version 1.6, all new code that is suggested for inclusion into Joomla must be E_STRICT-compatible. This means that it must not produce any warnings or errors when PHP&#039;s error reporting level is set to E_ALL | E_STRICT.&lt;br /&gt;
&lt;br /&gt;
=== Indenting and Line Length ===&lt;br /&gt;
&lt;br /&gt;
Use tabs to indent, not spaces. Make sure that the tab-stops are set to only 4 spaces in length.&lt;br /&gt;
&lt;br /&gt;
There is no set limit for line length.  Use your judgment based on the nature of the line and readability.&lt;br /&gt;
&lt;br /&gt;
=== Control Structures ===&lt;br /&gt;
&lt;br /&gt;
These include if, for, while, switch, etc. Here is an example of an if statement, as it is the most complicated of the control structures:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
if ((condition1) || (condition2)) {&lt;br /&gt;
    action1();&lt;br /&gt;
} else if ((condition3) &amp;amp;&amp;amp; (condition4)) {&lt;br /&gt;
    action2();&lt;br /&gt;
} else {&lt;br /&gt;
    defaultAction();&lt;br /&gt;
    anotherAction();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// optional formatting if it improves readability&lt;br /&gt;
if ((condition1) || (condition2)) {&lt;br /&gt;
    action1();&lt;br /&gt;
} else if ((condition3) &amp;amp;&amp;amp; (condition4)) {&lt;br /&gt;
    action2();&lt;br /&gt;
} else {&lt;br /&gt;
    defaultAction();&lt;br /&gt;
    anotherAction();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Control statements should have one space between the control keyword and opening parenthesis, to distinguish them from function calls.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;layouts&#039;&#039;&#039;, the alternative named notation should be used:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
if ((condition1) OR (condition2)) :&lt;br /&gt;
    action1();&lt;br /&gt;
elseif ((condition3) AND (condition4)) :&lt;br /&gt;
    action2();&lt;br /&gt;
else :&lt;br /&gt;
    defaultAction();&lt;br /&gt;
    anotherAction();&lt;br /&gt;
endif;&lt;br /&gt;
&lt;br /&gt;
foreach ($array as $element) :&lt;br /&gt;
    echo $element;&lt;br /&gt;
endforeach;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Logical operators in condition statements should use uppercase words (&amp;lt;code&amp;gt;AND&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;OR&amp;lt;/code&amp;gt;, etc) rather than programmatic notation (&amp;lt;code&amp;gt;&amp;amp;&amp;amp;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;||&amp;lt;/code&amp;gt;, etc).&lt;br /&gt;
&lt;br /&gt;
With the exception of &amp;lt;code&amp;gt;case&amp;lt;/code&amp;gt; statements, curly braces must always be included even though they are technically optional. Having them increases readability and decreases the likelihood of logic errors being introduced when new lines are added.&lt;br /&gt;
&lt;br /&gt;
For switch statements:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
switch (condition) {&lt;br /&gt;
    case 1:&lt;br /&gt;
        doAction1();&lt;br /&gt;
        break;&lt;br /&gt;
    case 2:&lt;br /&gt;
        doAction2();&lt;br /&gt;
        break;&lt;br /&gt;
    default:&lt;br /&gt;
        doDefaultAction();&lt;br /&gt;
        break;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use indenting and line-breaks rather than curly braces in the &amp;lt;code&amp;gt;case&amp;lt;/code&amp;gt; statements to increase readability.  There should be no space between the condition and the colon in the &amp;lt;code&amp;gt;case&amp;lt;/code&amp;gt; statement.&lt;br /&gt;
&lt;br /&gt;
=== Function Calls ===&lt;br /&gt;
&lt;br /&gt;
Functions should be called with no spaces between the function name and the opening parenthesis, and no space between this and the first parameter; a space after the comma between each parameter (if they are present), and no space between the last parameter and the closing parenthesis, and the semicolon. Here&#039;s an example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$var = foo($bar, $baz, $quux);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As displayed above, there should be space before and one space after the equals sign used to assign the return value of a function to a variable. In the case of a block of related assignments, tabs (not spaces) may be inserted to promote readability:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$short          = foo($bar);&lt;br /&gt;
$long_variable  = foo($baz);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Function Definitions ===&lt;br /&gt;
&lt;br /&gt;
Class and function declarations follow this convention:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
function fooFunction($arg1, $arg2 = &#039;&#039;)&lt;br /&gt;
{&lt;br /&gt;
    if (condition) {&lt;br /&gt;
        statement;&lt;br /&gt;
    }&lt;br /&gt;
    return $val;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class fooClass&lt;br /&gt;
{&lt;br /&gt;
    function fooMethod($arg1)&lt;br /&gt;
    {&lt;br /&gt;
        if ($arg) {&lt;br /&gt;
            $result = true;&lt;br /&gt;
        } else {&lt;br /&gt;
            $result = false;&lt;br /&gt;
        }&lt;br /&gt;
        return $result;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Arguments with default values go at the end of the argument list. Always attempt to return a meaningful value from a function if one is appropriate. Here is a slightly longer example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
function connect(&amp;amp;$dsn, $persistent = false)&lt;br /&gt;
{&lt;br /&gt;
    if (is_array($dsn)) {&lt;br /&gt;
        $dsninfo = &amp;amp;$dsn;&lt;br /&gt;
    } else {&lt;br /&gt;
        $dsninfo = DB::parseDSN($dsn);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    if (!$dsninfo OR !$dsninfo[&#039;phptype&#039;]) {&lt;br /&gt;
        return $this-&amp;gt;raiseError();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Comments ===&lt;br /&gt;
&lt;br /&gt;
Inline documentation for classes should follow the PHPDoc convention, similar to Javadoc. More information about PHPDoc can be found here: http://www.phpdoc.org/&lt;br /&gt;
&lt;br /&gt;
See also [[Adding phpDocumentor comments]]&lt;br /&gt;
&lt;br /&gt;
Non-documentation comments are strongly encouraged. A general rule of thumb is that if you look at a section of code and think &amp;quot;Wow, I don&#039;t want to try and describe that&amp;quot;, you need to comment it before you forget how it works.&lt;br /&gt;
&lt;br /&gt;
C style comments (&amp;lt;tt&amp;gt;/* */&amp;lt;/tt&amp;gt;) and standard C++ comments (&amp;lt;tt&amp;gt;//&amp;lt;/tt&amp;gt;) are both satisfactory. Use of Perl/shell style comments (&amp;lt;tt&amp;gt;#&amp;lt;/tt&amp;gt;) is not permitted.&lt;br /&gt;
&lt;br /&gt;
Please note - commented code is not to be committed to trunk or release repositories.&lt;br /&gt;
&lt;br /&gt;
=== Including Code ===&lt;br /&gt;
&lt;br /&gt;
Anywhere you are unconditionally including a class file, use &amp;lt;code&amp;gt;require_once&amp;lt;/code&amp;gt;. Anywhere you are conditionally including a class file (for example, factory methods), use &amp;lt;code&amp;gt;include_once&amp;lt;/code&amp;gt;. Either of these will ensure that class files are included only once. They share the same file list, so you don&#039;t need to worry about mixing them -- a file included with &amp;lt;code&amp;gt;require_once&amp;lt;/code&amp;gt; will not be included again by &amp;lt;/code&amp;gt;include_once&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
;Note: [[php:include_once|include_once]] and [[php:require_once|require_once]] are PHP &#039;&#039;language statements&#039;&#039;, not functions. You don&#039;t need parentheses around the filename to be included.&lt;br /&gt;
&lt;br /&gt;
=== PHP Code Tags ===&lt;br /&gt;
&lt;br /&gt;
Always use &amp;lt;tt&amp;gt;&amp;amp;lt;?php ?&amp;gt;&amp;lt;/tt&amp;gt; to delimit PHP code, not the &amp;lt;tt&amp;gt;&amp;amp;lt;? ?&amp;gt;&amp;lt;/tt&amp;gt; shorthand. This is the most portable way to include PHP code on differing operating systems and setups.&lt;br /&gt;
&lt;br /&gt;
For files that contain only PHP code, the closing tag (&amp;lt;tt&amp;gt;?&amp;gt;&amp;lt;/tt&amp;gt;) is never permitted. It is not required by PHP. Not including it prevents trailing white space from being accidentally injected into the output (see PHP manual on [http://au.php.net/basic-syntax.instruction-separation instruction separation]).&lt;br /&gt;
&lt;br /&gt;
=== SQL Queries ===&lt;br /&gt;
&lt;br /&gt;
SQL keywords are to be written in uppercase, while all other identifiers (which the exception of quoted text obviously) is to be in lowercase. Carriage returns should not be used as [[JDatabase]]::getQuery provides for formatted output.  However, indenting with spaces to improve readability is desireable.&lt;br /&gt;
&lt;br /&gt;
Queries should be wrapped in single quotes (as these text blocks are parsed faster by php).&lt;br /&gt;
&lt;br /&gt;
All quoted strings must use the &#039;&#039;Quote&#039;&#039; method to facilitate future compatibility with other database engines.&lt;br /&gt;
&lt;br /&gt;
All table names should use the &#039;&#039;&#039;&amp;lt;tt&amp;gt;#_&amp;lt;/tt&amp;gt;&#039;&#039;&#039; prefix rather than &amp;lt;tt&amp;gt;jos_&amp;lt;/tt&amp;gt; to access Joomla! contents and allow for the [[screen.config.15#Database_Settings|user defined database prefix]] to be applied.&lt;br /&gt;
&lt;br /&gt;
All expected integer or floating-point variable must be [http://php.net/manual/language.types.type-juggling.php cast] with &amp;lt;tt&amp;gt;(int)&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;(float)&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;(double)&amp;lt;/tt&amp;gt; as appropriate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$state = 1;&lt;br /&gt;
$name  = &#039;bill&#039;;&lt;br /&gt;
$db    = &amp;amp;JFactory::getDBO();&lt;br /&gt;
$query = &#039;SELECT COUNT( c.id ) AS num_articles, u.id, u.username&#039;.&lt;br /&gt;
    &#039; FROM #__content AS c&#039;.&lt;br /&gt;
    &#039; LEFT JOIN #__users AS u ON u.id = c.created_by&#039;.&lt;br /&gt;
    &#039; WHERE c.state = &#039;.(int) $state&lt;br /&gt;
    &#039;  AND u.id IS NOT NULL&#039;.&lt;br /&gt;
    &#039;  AND u.username &amp;lt;&amp;gt; &#039;.$db-&amp;gt;Quote( $name ).&lt;br /&gt;
    &#039; GROUP BY u.id&#039;.&lt;br /&gt;
    &#039;  HAVING COUNT( c.id ) &amp;gt; 0&#039;;&lt;br /&gt;
$db-&amp;gt;setQuery();&lt;br /&gt;
// Output formated query if joomla debug is active:&lt;br /&gt;
if (JDEBUG) {&lt;br /&gt;
    echo $db-&amp;gt;getQuery();&lt;br /&gt;
}&lt;br /&gt;
$stats = $db-&amp;gt;loadObjectList();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Doc Blocks ===&lt;br /&gt;
&lt;br /&gt;
All source code files in the core Joomla distribution must contain the following comment block as the header:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Short description of file&lt;br /&gt;
 *&lt;br /&gt;
 * Longer description of file is optional, but should be included if the file contains multiple classes or non-class material.&lt;br /&gt;
 *&lt;br /&gt;
 * PHP version 5.2.4 (put in the minimum version of PHP expected for the code here to run)&lt;br /&gt;
 *&lt;br /&gt;
 * @version	$Id$&lt;br /&gt;
 * @package	Joomla&lt;br /&gt;
 * @copyright	Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.&lt;br /&gt;
 * @license	GNU/GPL, see LICENSE.php&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;@package&amp;lt;/code&amp;gt; in the header is not required for class-only files.&lt;br /&gt;
&lt;br /&gt;
Classes, functions, constants, class properties and class methods should all be supplied with appropriate DocBlocks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * Short description for class&lt;br /&gt;
 *&lt;br /&gt;
 * Long description for class (if any)...&lt;br /&gt;
 *&lt;br /&gt;
 * @package    PackageName&lt;br /&gt;
 * @subpackage SubPackageName&lt;br /&gt;
 * @link       http://pear.php.net/package/PackageName&lt;br /&gt;
 * @see        NetOther, Net_Sample::Net_Sample()&lt;br /&gt;
 * @since      Class available since Release 1.2.0&lt;br /&gt;
 * @deprecated Class deprecated in Release 2.0.0&lt;br /&gt;
 */&lt;br /&gt;
class JFooBar&lt;br /&gt;
{&lt;br /&gt;
    /**&lt;br /&gt;
     * @var int $id Primary key&lt;br /&gt;
     */&lt;br /&gt;
    public $id = null;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following package names are to be used in the core stack:&lt;br /&gt;
&lt;br /&gt;
* Joomla.Administrator - all files that belong only to the administrator or backend application&lt;br /&gt;
* Joomla.Installation - all files that belong to the installation application&lt;br /&gt;
* Joomla.Plugin - all plugin files&lt;br /&gt;
* Joomla.Site - all files that pertain only to the site or frontend application&lt;br /&gt;
* Joomla.XML-RPC - all files that belong to the XML-RPC server application&lt;br /&gt;
&lt;br /&gt;
The sub-package name will vary according to the extension type:&lt;br /&gt;
&lt;br /&gt;
* Components - the component folder, eg &amp;lt;code&amp;gt;com_content&amp;lt;/code&amp;gt;&lt;br /&gt;
* Modules - the module folder, eg &amp;lt;code&amp;gt;mod_latest_news&amp;lt;/code&amp;gt;&lt;br /&gt;
* Plugins - the folder.element, eg &amp;lt;code&amp;gt;content.pagebreak&amp;lt;/code&amp;gt;&lt;br /&gt;
* Templates - the template folder, eg &amp;lt;code&amp;gt;rhuk_milkyway&amp;lt;/code&amp;gt;&lt;br /&gt;
* Framework - nothing for top level files (such as &amp;lt;code&amp;gt;factory.php&amp;lt;/code&amp;gt;), the first level folder or the first.second level folders as appropriate, eg &amp;lt;code&amp;gt;utilities&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;joomla/utilities/date.php&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;html.html&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;joomla/html/html/email.php&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please note that code contributed to the Joomla stack that will become the copyright of the project is not allowed to include &amp;lt;code&amp;gt;@author&amp;lt;/code&amp;gt; tags.  You should update the contribution log in &amp;lt;tt&amp;gt;CREDITS.php&amp;lt;/tt&amp;gt;.  Joomla&#039;s philosophy is that the code is written &amp;quot;all together&amp;quot; and there is no notion of any one person &#039;owning&#039; any section of code.&lt;br /&gt;
&lt;br /&gt;
Files included from third party sources must leave DocBlocks intact. Layout files use the same DocBlocks as other PHP files. &lt;br /&gt;
&lt;br /&gt;
Note that the &amp;quot;@version $Id&amp;quot; line uses the SVN &amp;quot;keywords=Id&amp;quot; property. See [[Subversion File Properties]] for information about setting this property.&lt;br /&gt;
&lt;br /&gt;
== Naming Conventions ==&lt;br /&gt;
&lt;br /&gt;
=== Classes ===&lt;br /&gt;
&lt;br /&gt;
Classes should be given descriptive names. Avoid using abbreviations where possible. Class names should always begin with an uppercase letter and be written in CamelCase even if using traditionally uppercase acronyms (such as XML, HTML).  One exception is for Joomla framework classes which must begin with an uppercase &#039;J&#039; with the next letter also being uppercase.  For example:&lt;br /&gt;
&lt;br /&gt;
* JHtmlHelper&lt;br /&gt;
* JXmlParser&lt;br /&gt;
* JModel&lt;br /&gt;
&lt;br /&gt;
Third-party developers are advised to namespace their functions with a unique prefix.&lt;br /&gt;
&lt;br /&gt;
=== Functions and Methods ===&lt;br /&gt;
&lt;br /&gt;
Functions and methods should be named using the &amp;quot;studly caps&amp;quot; style (also referred to as &amp;quot;bumpy case&amp;quot; or &amp;quot;camel caps&amp;quot;). The initial letter of the name is lowercase, and each letter that starts a new &amp;quot;word&amp;quot; is capitalized. Function in the Joomla framework must begin with a lowercase &#039;j&#039;.  Some examples:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
connect();&lt;br /&gt;
getData();&lt;br /&gt;
buildSomeWidget();&lt;br /&gt;
jImport();&lt;br /&gt;
jDoSomething();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Private class members (meaning class members that are intended to be used only from within the same class in which they are declared; are preceded by a single underscore. Properties are to be written in underscore format (that is, logical words separated by underscores) and should be all lowercase.  For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class JFooBar&lt;br /&gt;
{&lt;br /&gt;
    // Joomla 1.5 and earlier format&lt;br /&gt;
    var $_status = null;&lt;br /&gt;
&lt;br /&gt;
    function _sort()&lt;br /&gt;
    {&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Joomla 1.6 format&lt;br /&gt;
    private $_status = null;&lt;br /&gt;
&lt;br /&gt;
    protected $field_name = null;&lt;br /&gt;
&lt;br /&gt;
    protected function _sort()&lt;br /&gt;
    {&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Constants ===&lt;br /&gt;
&lt;br /&gt;
Constants should always be all-uppercase, with underscores to separate words. Prefix constant names with the uppercase name of the class/package they are used in. For example, the constants used by the [[JError]] class all begin with &amp;quot;JERROR_&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Global Variables ===&lt;br /&gt;
&lt;br /&gt;
If your package needs to define global variables, their name should start with a single underscore followed by the uppercase class/package name and another underscore. For example, the JError class uses a global variable called $_JERROR_LEVELS.&lt;br /&gt;
&lt;br /&gt;
With PHP5 and later you may use static class properties or constants instead of globals.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
class JWhatever&lt;br /&gt;
{&lt;br /&gt;
    public static $instance = null;&lt;br /&gt;
    const SUCCESS = 1;&lt;br /&gt;
    const FAILURE = 0;&lt;br /&gt;
    // Methods...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Regular and Class Variables ===&lt;br /&gt;
&lt;br /&gt;
Regular variables, follow the same conventions as function.&lt;br /&gt;
&lt;br /&gt;
Class variables should be set to null or some other appropriate default value. Lining up the default values with tabs should only be used if particularly warranted for readability.&lt;br /&gt;
&lt;br /&gt;
=== References ===&lt;br /&gt;
&lt;br /&gt;
When using references, there should be a space before the reference operator and no space between it and the function or variable name.  For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$ref1  = &amp;amp;$this-&amp;gt;_sql;&lt;br /&gt;
$db    = &amp;amp;JFactory::getDBO();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Language Keys ===&lt;br /&gt;
&lt;br /&gt;
NOTE: This part has to be rewritten for 1.6 (JM)&lt;br /&gt;
&lt;br /&gt;
Except for the most common of words, such as &amp;quot;Yes&amp;quot;, &amp;quot;No&amp;quot;, &amp;quot;Show&amp;quot;, &amp;quot;Hide&amp;quot; all language keys should be namespaced to reflect the type of string they represent.  Always consider that if two extensions use the same key, the one loaded last will be the one that displays.  Namespacing should generally relate to the extension displaying the text. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
echo JText::_(&#039;Weblink Link&#039;);&lt;br /&gt;
echo JText::_(&#039;Weblink Title&#039;);&lt;br /&gt;
echo JText::_(&#039;Weblink Description&#039;);&lt;br /&gt;
&lt;br /&gt;
echo JText::_(&#039;Exception An error occurred while saving&#039;);&lt;br /&gt;
?&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TODO: Link to page with &amp;quot;common&amp;quot; strings that can be used for typical actions in components, such a &amp;quot;Save&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Where the same English word is used in two different locations, two different language keys should be used to allow for cases where the translation results in different words or phrases.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// A table column title&lt;br /&gt;
&amp;lt;th&amp;gt;&amp;lt;?php echo JText::_(&#039;Weblink Column Title&#039;);?&amp;gt;&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;&amp;lt;?php echo JText::_(&#039;Weblink Column Link&#039;);?&amp;gt;&amp;lt;/th&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// In the form&lt;br /&gt;
&amp;lt;?php echo JText::_(&#039;Weblink Title&#039;);?&amp;gt;&amp;lt;input name=&amp;quot;title&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;?php echo JText::_(&#039;Weblink Link&#039;);?&amp;gt;&amp;lt;input name=&amp;quot;link&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Toolbar and Linkbar text should be prefixed Toolbar and Linkbar respectively.&lt;br /&gt;
&lt;br /&gt;
The language keys should be written as naturally as possible with spaces, not underscores separating words.  Long phrases can be condensed to reduce keys to a sensible length.  For example, tooltips for an edit field can be written like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php echo JText::_(&#039;Weblink Title&#039;);?&amp;gt;&amp;lt;input name=&amp;quot;title&amp;quot; title=&amp;quot;&amp;lt;?php echo JText::_(&#039;Weblink Title Desc&#039;);?&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The convention used should be governed by common sense, but must be consistent.  In general consider how the language file will look with all keys sorted alphabetically.  Prefixes should be used to group text within a common context (such as column headings).  Suffixes should be used to group elements that logically go together (such as a field name and its description).&lt;br /&gt;
&lt;br /&gt;
Phrases must never be assembled by string concatenation. Each phrase must be represented by a single language key, using sprintf as appropriate to replace dynamic words in the phrase.  Where replacements are made, the word used should be as descriptive as possible and all-uppercase.  This assists the translators to determine the context of the replacement.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
// Not permitted&lt;br /&gt;
echo JText::_(&#039;Deleted &#039;).$n.JText::_(&#039; items&#039;);&lt;br /&gt;
&lt;br /&gt;
// Permitted&lt;br /&gt;
echo JText::sprintf(&#039;Message Deleted NUMBER items&#039;, $n);&lt;br /&gt;
?&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reference in the language file would look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;MESSAGE DELETED NUMBER ITEMS=Deleted %d Item(s)&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If more than one dynamic string is used in a phrase, the printf markers should employ order placement as other languages might change the position of the strings. This is done via %[number]$[printf_type] as follows:&lt;br /&gt;
&lt;br /&gt;
Left to right language:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;PAGE X OF Y=Page %1$d of %2$d&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Right to left language:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;PAGE X OF Y=%2$d of %1$d egaP&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
&lt;br /&gt;
For single controller components, the naming convention is &#039;&#039;[Name]Controller&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Content Controller&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class ContentController extends JController&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The file name will generally be &#039;&#039;controller.php&#039;&#039; and is located in the component folder.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
com_content&lt;br /&gt;
 / controller.php&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a multi-controller components, such as the Banners in the Administrator, the convention is &#039;&#039;[Component]Controller[Name]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Banner Client Controller&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class BannerControllerClient extends JController&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The files will be located in a &amp;lt;tt&amp;gt;/controllers/&amp;lt;/tt&amp;gt; folder under the component folder.  The file names will reflect the name of the controller.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
com_banner&lt;br /&gt;
  /controllers/&lt;br /&gt;
    / banner.php&lt;br /&gt;
    / client.php&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Models===&lt;br /&gt;
&lt;br /&gt;
The naming convention is &#039;&#039;[Component]Model[Name]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Banner Client Model&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class BannerModelClient extends JModel&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The files will be located in a &amp;lt;tt&amp;gt;/models/&amp;lt;/tt&amp;gt; folder under the component folder.  The file names will reflect the name of the model.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
com_banner&lt;br /&gt;
  /models/&lt;br /&gt;
    / banner.php&lt;br /&gt;
    / client.php&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Views ===&lt;br /&gt;
The naming convention is &#039;&#039;[Component]View[Name]&#039;&#039;.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Contact Category View&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class ContactViewCategory extends JView&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The files will be located in a &amp;lt;tt&amp;gt;/view/&amp;lt;/tt&amp;gt; folder under the component folder. The subfolder names will reflect the name of a View.&lt;br /&gt;
&lt;br /&gt;
 com_contact&lt;br /&gt;
  /views/&lt;br /&gt;
    /&#039;&#039;view name 1&#039;&#039;/&lt;br /&gt;
      / view.html.php&lt;br /&gt;
    /&#039;&#039;view name 2&#039;&#039;/&lt;br /&gt;
      / view.html.php&lt;br /&gt;
&lt;br /&gt;
Multi-view components such as com_content may provide an optional &amp;quot;master&amp;quot; view class the specialised views extend from. It is located in the component folder and typically called &#039;&#039;view.php&#039;&#039;. The naming convention is &#039;&#039;[Component]View&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 com_content&lt;br /&gt;
  /views/&lt;br /&gt;
     &amp;lt;span style=&amp;quot;color:#999&amp;quot;&amp;gt;/archive/&amp;lt;/span&amp;gt;&lt;br /&gt;
       / view.html.php&lt;br /&gt;
     &amp;lt;span style=&amp;quot;color:#999&amp;quot;&amp;gt;/article/&amp;lt;/span&amp;gt;&lt;br /&gt;
  / view.php&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
view.php&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Content View&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class ContentView extends JView&lt;br /&gt;
{&lt;br /&gt;
    // Helper Methods&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
views/archive/view.html.php&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Content Archive View&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class ContactViewArchive extends ContentView&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Plugins ===&lt;br /&gt;
&lt;br /&gt;
The naming convention is &#039;&#039;plg[Folder][Element]&#039;&#039; as pointed out in [[How to create a content plugin|the relative HowTo page]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class plgContentPagebreak extends JPlugin&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Layouts ===&lt;br /&gt;
Components may support different Layouts to render the data supplied by a [[#Views|View]] and its [[#Models|Models]]. A Layout file usually contains markup and some PHP code for &#039;&#039;display logic only&#039;&#039;: no functions, no classes.&lt;br /&gt;
&lt;br /&gt;
A Layout consists of at least one .php file and an equally named [[Creating a basic layout.xml file|.xml manifest file]] located in the &amp;lt;tt&amp;gt;/tmpl/&amp;lt;/tt&amp;gt; folder of a View, both reflect the internal name of the Layout. The standard Layout is called &#039;&#039;default&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:#999&amp;quot;&amp;gt;com_content&lt;br /&gt;
   /views/&lt;br /&gt;
     /article/&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:#000&amp;quot;&amp;gt;&lt;br /&gt;
       /tmpl/&lt;br /&gt;
         / default.php&lt;br /&gt;
         / default.xml&lt;br /&gt;
         / form.php&lt;br /&gt;
         / form.xml&lt;br /&gt;
         / pagebreak.php&lt;br /&gt;
         / pagebreak.xml &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Layout may use supplemental .php files to provide more granule control in order to render individual parts or repetitive items of the data.&lt;br /&gt;
&lt;br /&gt;
Users may customize the Layout output via [[#Template Layout Overrides|Template Layout Overrides]].&lt;br /&gt;
&lt;br /&gt;
=== Templates ===&lt;br /&gt;
&lt;br /&gt;
=== Template Layout Overrides ===&lt;/div&gt;</summary>
		<author><name>Paladin</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Coding_style_and_standards&amp;diff=31180</id>
		<title>Coding style and standards</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Coding_style_and_standards&amp;diff=31180"/>
		<updated>2010-09-29T22:00:05Z</updated>

		<summary type="html">&lt;p&gt;Paladin: /* Control Structures */ Edited slightly again to conform with earlier discussions.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{review}}&lt;br /&gt;
{{RightTOC}}&lt;br /&gt;
remark: The following information has been copied from the old WIKI archive has not yet been reviewed.&lt;br /&gt;
See: http://dev.joomla.org/component/option,com_jd-wiki/Itemid,/id,standards:coding/&lt;br /&gt;
&lt;br /&gt;
Good coding standards are important in any development project, but particularly when multiple developers are working on the same project. Having coding standards helps ensure that the code is of high quality, has fewer bugs, and is easily maintained.&lt;br /&gt;
&lt;br /&gt;
First rule, if in doubt, ask.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
All files contributed to Joomla must:&lt;br /&gt;
&lt;br /&gt;
* Be stored as ASCII text&lt;br /&gt;
* Use UTF-8 character encoding&lt;br /&gt;
* Be Unix formatted&lt;br /&gt;
** Lines must end only with a line feed (LF). Line feeds are represented as ordinal 10, octal 012 and hex 0A. Do not use carriage returns (CR) like Macintosh computers do or the carriage return/line feed combination (CRLF) like Windows computers do.&lt;br /&gt;
&lt;br /&gt;
New files will normally be added to the code base using Subversion (SVN). All SVN files should have the SVN property set &amp;quot;eol-style=LF&amp;quot;. Also, most Joomla! files will have &amp;quot;$Id&amp;quot; tags in the &amp;quot;@version&amp;quot; line of the Doc block. These require the SVN property &amp;quot;keywords=Id&amp;quot;. See [[Subversion File Properties]] for more information about how to set SVN properties.&lt;br /&gt;
&lt;br /&gt;
== Coding Standards ==&lt;br /&gt;
&lt;br /&gt;
=== Spelling ===&lt;br /&gt;
&lt;br /&gt;
Spelling of class, function, variable and constant names should generally be in accordance with British English rules (en_GB).  However, some exceptions are permitted, for example where common programming names are used that align with the PHP API such as &amp;lt;code&amp;gt;$color&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== E_STRICT-compatible code ===&lt;br /&gt;
&lt;br /&gt;
As of version 1.6, all new code that is suggested for inclusion into Joomla must be E_STRICT-compatible. This means that it must not produce any warnings or errors when PHP&#039;s error reporting level is set to E_ALL | E_STRICT.&lt;br /&gt;
&lt;br /&gt;
=== Indenting and Line Length ===&lt;br /&gt;
&lt;br /&gt;
Use tabs to indent, not spaces. Make sure that the tab-stops are set to only 4 spaces in length.&lt;br /&gt;
&lt;br /&gt;
There is no set limit for line length.  Use your judgment based on the nature of the line and readability.&lt;br /&gt;
&lt;br /&gt;
=== Control Structures ===&lt;br /&gt;
&lt;br /&gt;
These include if, for, while, switch, etc. Here is an example of an if statement, as it is the most complicated of the control structures:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
if ((condition1) || (condition2)) {&lt;br /&gt;
    action1();&lt;br /&gt;
} else if ((condition3) &amp;amp;&amp;amp; (condition4)) {&lt;br /&gt;
    action2();&lt;br /&gt;
} else {&lt;br /&gt;
    defaultAction();&lt;br /&gt;
    anotherAction();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// optional formatting if it improves readability&lt;br /&gt;
if ((condition1) || (condition2)) {&lt;br /&gt;
    action1();&lt;br /&gt;
} else if ((condition3) &amp;amp;&amp;amp; (condition4)) {&lt;br /&gt;
    action2();&lt;br /&gt;
} else {&lt;br /&gt;
    defaultAction();&lt;br /&gt;
    anotherAction();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Control statements should have one space between the control keyword and opening parenthesis, to distinguish them from function calls.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;layouts&#039;&#039;&#039;, the alternative named notation should be used:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
if ((condition1) OR (condition2)) :&lt;br /&gt;
    action1();&lt;br /&gt;
elseif ((condition3) AND (condition4)) :&lt;br /&gt;
    action2();&lt;br /&gt;
else :&lt;br /&gt;
    defaultAction();&lt;br /&gt;
    anotherAction();&lt;br /&gt;
endif;&lt;br /&gt;
&lt;br /&gt;
foreach ($array as $element) :&lt;br /&gt;
    echo $element;&lt;br /&gt;
endforeach;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Logical operators in condition statements should use uppercase words (&amp;lt;code&amp;gt;AND&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;OR&amp;lt;/code&amp;gt;, etc) rather than programmatic notation (&amp;lt;code&amp;gt;&amp;amp;&amp;amp;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;||&amp;lt;/code&amp;gt;, etc).&lt;br /&gt;
&lt;br /&gt;
With the exception of &amp;lt;code&amp;gt;case&amp;lt;/code&amp;gt; statements, curly braces must always be included even though they are technically optional. Having them increases readability and decreases the likelihood of logic errors being introduced when new lines are added.&lt;br /&gt;
&lt;br /&gt;
For switch statements:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
switch (condition) {&lt;br /&gt;
    case 1:&lt;br /&gt;
        doAction1();&lt;br /&gt;
        break;&lt;br /&gt;
    case 2:&lt;br /&gt;
        doAction2();&lt;br /&gt;
        break;&lt;br /&gt;
    default:&lt;br /&gt;
        doDefaultAction();&lt;br /&gt;
        break;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use indenting and line-breaks rather than curly braces in the &amp;lt;code&amp;gt;case&amp;lt;/code&amp;gt; statements to increase readability.  There should be no space between the condition and the colon in the &amp;lt;code&amp;gt;case&amp;lt;/code&amp;gt; statement.&lt;br /&gt;
&lt;br /&gt;
=== Function Calls ===&lt;br /&gt;
&lt;br /&gt;
Functions should be called with no spaces between the function name and the opening parenthesis, and no space between this and the first parameter; a space after the comma between each parameter (if they are present), and no space between the last parameter and the closing parenthesis, and the semicolon. Here&#039;s an example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$var = foo($bar, $baz, $quux);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As displayed above, there should be space before and one space after the equals sign used to assign the return value of a function to a variable. In the case of a block of related assignments, tabs (not spaces) may be inserted to promote readability:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$short          = foo($bar);&lt;br /&gt;
$long_variable  = foo($baz);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Function Definitions ===&lt;br /&gt;
&lt;br /&gt;
Class and function declarations follow the &amp;quot;one true brace&amp;quot; convention:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
function fooFunction($arg1, $arg2 = &#039;&#039;)&lt;br /&gt;
{&lt;br /&gt;
    if (condition) {&lt;br /&gt;
        statement;&lt;br /&gt;
    }&lt;br /&gt;
    return $val;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class fooClass&lt;br /&gt;
{&lt;br /&gt;
    function fooMethod($arg1)&lt;br /&gt;
    {&lt;br /&gt;
        if ($arg) {&lt;br /&gt;
            $result = true;&lt;br /&gt;
        } else {&lt;br /&gt;
            $result = false;&lt;br /&gt;
        }&lt;br /&gt;
        return $result;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Arguments with default values go at the end of the argument list. Always attempt to return a meaningful value from a function if one is appropriate. Here is a slightly longer example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
function connect(&amp;amp;$dsn, $persistent = false)&lt;br /&gt;
{&lt;br /&gt;
    if (is_array($dsn)) {&lt;br /&gt;
        $dsninfo = &amp;amp;$dsn;&lt;br /&gt;
    } else {&lt;br /&gt;
        $dsninfo = DB::parseDSN($dsn);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    if (!$dsninfo OR !$dsninfo[&#039;phptype&#039;]) {&lt;br /&gt;
        return $this-&amp;gt;raiseError();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Comments ===&lt;br /&gt;
&lt;br /&gt;
Inline documentation for classes should follow the PHPDoc convention, similar to Javadoc. More information about PHPDoc can be found here: http://www.phpdoc.org/&lt;br /&gt;
&lt;br /&gt;
See also [[Adding phpDocumentor comments]]&lt;br /&gt;
&lt;br /&gt;
Non-documentation comments are strongly encouraged. A general rule of thumb is that if you look at a section of code and think &amp;quot;Wow, I don&#039;t want to try and describe that&amp;quot;, you need to comment it before you forget how it works.&lt;br /&gt;
&lt;br /&gt;
C style comments (&amp;lt;tt&amp;gt;/* */&amp;lt;/tt&amp;gt;) and standard C++ comments (&amp;lt;tt&amp;gt;//&amp;lt;/tt&amp;gt;) are both satisfactory. Use of Perl/shell style comments (&amp;lt;tt&amp;gt;#&amp;lt;/tt&amp;gt;) is not permitted.&lt;br /&gt;
&lt;br /&gt;
Please note - commented code is not to be committed to trunk or release repositories.&lt;br /&gt;
&lt;br /&gt;
=== Including Code ===&lt;br /&gt;
&lt;br /&gt;
Anywhere you are unconditionally including a class file, use &amp;lt;code&amp;gt;require_once&amp;lt;/code&amp;gt;. Anywhere you are conditionally including a class file (for example, factory methods), use &amp;lt;code&amp;gt;include_once&amp;lt;/code&amp;gt;. Either of these will ensure that class files are included only once. They share the same file list, so you don&#039;t need to worry about mixing them -- a file included with &amp;lt;code&amp;gt;require_once&amp;lt;/code&amp;gt; will not be included again by &amp;lt;/code&amp;gt;include_once&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
;Note: [[php:include_once|include_once]] and [[php:require_once|require_once]] are PHP &#039;&#039;language statements&#039;&#039;, not functions. You don&#039;t need parentheses around the filename to be included.&lt;br /&gt;
&lt;br /&gt;
=== PHP Code Tags ===&lt;br /&gt;
&lt;br /&gt;
Always use &amp;lt;tt&amp;gt;&amp;amp;lt;?php ?&amp;gt;&amp;lt;/tt&amp;gt; to delimit PHP code, not the &amp;lt;tt&amp;gt;&amp;amp;lt;? ?&amp;gt;&amp;lt;/tt&amp;gt; shorthand. This is the most portable way to include PHP code on differing operating systems and setups.&lt;br /&gt;
&lt;br /&gt;
For files that contain only PHP code, the closing tag (&amp;lt;tt&amp;gt;?&amp;gt;&amp;lt;/tt&amp;gt;) is never permitted. It is not required by PHP. Not including it prevents trailing white space from being accidentally injected into the output (see PHP manual on [http://au.php.net/basic-syntax.instruction-separation instruction separation]).&lt;br /&gt;
&lt;br /&gt;
=== SQL Queries ===&lt;br /&gt;
&lt;br /&gt;
SQL keywords are to be written in uppercase, while all other identifiers (which the exception of quoted text obviously) is to be in lowercase. Carriage returns should not be used as [[JDatabase]]::getQuery provides for formatted output.  However, indenting with spaces to improve readability is desireable.&lt;br /&gt;
&lt;br /&gt;
Queries should be wrapped in single quotes (as these text blocks are parsed faster by php).&lt;br /&gt;
&lt;br /&gt;
All quoted strings must use the &#039;&#039;Quote&#039;&#039; method to facilitate future compatibility with other database engines.&lt;br /&gt;
&lt;br /&gt;
All table names should use the &#039;&#039;&#039;&amp;lt;tt&amp;gt;#_&amp;lt;/tt&amp;gt;&#039;&#039;&#039; prefix rather than &amp;lt;tt&amp;gt;jos_&amp;lt;/tt&amp;gt; to access Joomla! contents and allow for the [[screen.config.15#Database_Settings|user defined database prefix]] to be applied.&lt;br /&gt;
&lt;br /&gt;
All expected integer or floating-point variable must be [http://php.net/manual/language.types.type-juggling.php cast] with &amp;lt;tt&amp;gt;(int)&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;(float)&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;(double)&amp;lt;/tt&amp;gt; as appropriate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$state = 1;&lt;br /&gt;
$name  = &#039;bill&#039;;&lt;br /&gt;
$db    = &amp;amp;JFactory::getDBO();&lt;br /&gt;
$query = &#039;SELECT COUNT( c.id ) AS num_articles, u.id, u.username&#039;.&lt;br /&gt;
    &#039; FROM #__content AS c&#039;.&lt;br /&gt;
    &#039; LEFT JOIN #__users AS u ON u.id = c.created_by&#039;.&lt;br /&gt;
    &#039; WHERE c.state = &#039;.(int) $state&lt;br /&gt;
    &#039;  AND u.id IS NOT NULL&#039;.&lt;br /&gt;
    &#039;  AND u.username &amp;lt;&amp;gt; &#039;.$db-&amp;gt;Quote( $name ).&lt;br /&gt;
    &#039; GROUP BY u.id&#039;.&lt;br /&gt;
    &#039;  HAVING COUNT( c.id ) &amp;gt; 0&#039;;&lt;br /&gt;
$db-&amp;gt;setQuery();&lt;br /&gt;
// Output formated query if joomla debug is active:&lt;br /&gt;
if (JDEBUG) {&lt;br /&gt;
    echo $db-&amp;gt;getQuery();&lt;br /&gt;
}&lt;br /&gt;
$stats = $db-&amp;gt;loadObjectList();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Doc Blocks ===&lt;br /&gt;
&lt;br /&gt;
All source code files in the core Joomla distribution must contain the following comment block as the header:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Short description of file&lt;br /&gt;
 *&lt;br /&gt;
 * Longer description of file is optional, but should be included if the file contains multiple classes or non-class material.&lt;br /&gt;
 *&lt;br /&gt;
 * PHP version 5.2.4 (put in the minimum version of PHP expected for the code here to run)&lt;br /&gt;
 *&lt;br /&gt;
 * @version	$Id$&lt;br /&gt;
 * @package	Joomla&lt;br /&gt;
 * @copyright	Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.&lt;br /&gt;
 * @license	GNU/GPL, see LICENSE.php&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;@package&amp;lt;/code&amp;gt; in the header is not required for class-only files.&lt;br /&gt;
&lt;br /&gt;
Classes, functions, constants, class properties and class methods should all be supplied with appropriate DocBlocks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * Short description for class&lt;br /&gt;
 *&lt;br /&gt;
 * Long description for class (if any)...&lt;br /&gt;
 *&lt;br /&gt;
 * @package    PackageName&lt;br /&gt;
 * @subpackage SubPackageName&lt;br /&gt;
 * @link       http://pear.php.net/package/PackageName&lt;br /&gt;
 * @see        NetOther, Net_Sample::Net_Sample()&lt;br /&gt;
 * @since      Class available since Release 1.2.0&lt;br /&gt;
 * @deprecated Class deprecated in Release 2.0.0&lt;br /&gt;
 */&lt;br /&gt;
class JFooBar&lt;br /&gt;
{&lt;br /&gt;
    /**&lt;br /&gt;
     * @var int $id Primary key&lt;br /&gt;
     */&lt;br /&gt;
    public $id = null;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following package names are to be used in the core stack:&lt;br /&gt;
&lt;br /&gt;
* Joomla.Administrator - all files that belong only to the administrator or backend application&lt;br /&gt;
* Joomla.Installation - all files that belong to the installation application&lt;br /&gt;
* Joomla.Plugin - all plugin files&lt;br /&gt;
* Joomla.Site - all files that pertain only to the site or frontend application&lt;br /&gt;
* Joomla.XML-RPC - all files that belong to the XML-RPC server application&lt;br /&gt;
&lt;br /&gt;
The sub-package name will vary according to the extension type:&lt;br /&gt;
&lt;br /&gt;
* Components - the component folder, eg &amp;lt;code&amp;gt;com_content&amp;lt;/code&amp;gt;&lt;br /&gt;
* Modules - the module folder, eg &amp;lt;code&amp;gt;mod_latest_news&amp;lt;/code&amp;gt;&lt;br /&gt;
* Plugins - the folder.element, eg &amp;lt;code&amp;gt;content.pagebreak&amp;lt;/code&amp;gt;&lt;br /&gt;
* Templates - the template folder, eg &amp;lt;code&amp;gt;rhuk_milkyway&amp;lt;/code&amp;gt;&lt;br /&gt;
* Framework - nothing for top level files (such as &amp;lt;code&amp;gt;factory.php&amp;lt;/code&amp;gt;), the first level folder or the first.second level folders as appropriate, eg &amp;lt;code&amp;gt;utilities&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;joomla/utilities/date.php&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;html.html&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;joomla/html/html/email.php&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please note that code contributed to the Joomla stack that will become the copyright of the project is not allowed to include &amp;lt;code&amp;gt;@author&amp;lt;/code&amp;gt; tags.  You should update the contribution log in &amp;lt;tt&amp;gt;CREDITS.php&amp;lt;/tt&amp;gt;.  Joomla&#039;s philosophy is that the code is written &amp;quot;all together&amp;quot; and there is no notion of any one person &#039;owning&#039; any section of code.&lt;br /&gt;
&lt;br /&gt;
Files included from third party sources must leave DocBlocks intact. Layout files use the same DocBlocks as other PHP files. &lt;br /&gt;
&lt;br /&gt;
Note that the &amp;quot;@version $Id&amp;quot; line uses the SVN &amp;quot;keywords=Id&amp;quot; property. See [[Subversion File Properties]] for information about setting this property.&lt;br /&gt;
&lt;br /&gt;
== Naming Conventions ==&lt;br /&gt;
&lt;br /&gt;
=== Classes ===&lt;br /&gt;
&lt;br /&gt;
Classes should be given descriptive names. Avoid using abbreviations where possible. Class names should always begin with an uppercase letter and be written in CamelCase even if using traditionally uppercase acronyms (such as XML, HTML).  One exception is for Joomla framework classes which must begin with an uppercase &#039;J&#039; with the next letter also being uppercase.  For example:&lt;br /&gt;
&lt;br /&gt;
* JHtmlHelper&lt;br /&gt;
* JXmlParser&lt;br /&gt;
* JModel&lt;br /&gt;
&lt;br /&gt;
Third-party developers are advised to namespace their functions with a unique prefix.&lt;br /&gt;
&lt;br /&gt;
=== Functions and Methods ===&lt;br /&gt;
&lt;br /&gt;
Functions and methods should be named using the &amp;quot;studly caps&amp;quot; style (also referred to as &amp;quot;bumpy case&amp;quot; or &amp;quot;camel caps&amp;quot;). The initial letter of the name is lowercase, and each letter that starts a new &amp;quot;word&amp;quot; is capitalized. Function in the Joomla framework must begin with a lowercase &#039;j&#039;.  Some examples:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
connect();&lt;br /&gt;
getData();&lt;br /&gt;
buildSomeWidget();&lt;br /&gt;
jImport();&lt;br /&gt;
jDoSomething();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Private class members (meaning class members that are intended to be used only from within the same class in which they are declared; are preceded by a single underscore. Properties are to be written in underscore format (that is, logical words separated by underscores) and should be all lowercase.  For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class JFooBar&lt;br /&gt;
{&lt;br /&gt;
    // Joomla 1.5 and earlier format&lt;br /&gt;
    var $_status = null;&lt;br /&gt;
&lt;br /&gt;
    function _sort()&lt;br /&gt;
    {&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Joomla 1.6 format&lt;br /&gt;
    private $_status = null;&lt;br /&gt;
&lt;br /&gt;
    protected $field_name = null;&lt;br /&gt;
&lt;br /&gt;
    protected function _sort()&lt;br /&gt;
    {&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Constants ===&lt;br /&gt;
&lt;br /&gt;
Constants should always be all-uppercase, with underscores to separate words. Prefix constant names with the uppercase name of the class/package they are used in. For example, the constants used by the [[JError]] class all begin with &amp;quot;JERROR_&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Global Variables ===&lt;br /&gt;
&lt;br /&gt;
If your package needs to define global variables, their name should start with a single underscore followed by the uppercase class/package name and another underscore. For example, the JError class uses a global variable called $_JERROR_LEVELS.&lt;br /&gt;
&lt;br /&gt;
With PHP5 and later you may use static class properties or constants instead of globals.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
class JWhatever&lt;br /&gt;
{&lt;br /&gt;
    public static $instance = null;&lt;br /&gt;
    const SUCCESS = 1;&lt;br /&gt;
    const FAILURE = 0;&lt;br /&gt;
    // Methods...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Regular and Class Variables ===&lt;br /&gt;
&lt;br /&gt;
Regular variables, follow the same conventions as function.&lt;br /&gt;
&lt;br /&gt;
Class variables should be set to null or some other appropriate default value. Lining up the default values with tabs should only be used if particularly warranted for readability.&lt;br /&gt;
&lt;br /&gt;
=== References ===&lt;br /&gt;
&lt;br /&gt;
When using references, there should be a space before the reference operator and no space between it and the function or variable name.  For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$ref1  = &amp;amp;$this-&amp;gt;_sql;&lt;br /&gt;
$db    = &amp;amp;JFactory::getDBO();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Language Keys ===&lt;br /&gt;
&lt;br /&gt;
NOTE: This part has to be rewritten for 1.6 (JM)&lt;br /&gt;
&lt;br /&gt;
Except for the most common of words, such as &amp;quot;Yes&amp;quot;, &amp;quot;No&amp;quot;, &amp;quot;Show&amp;quot;, &amp;quot;Hide&amp;quot; all language keys should be namespaced to reflect the type of string they represent.  Always consider that if two extensions use the same key, the one loaded last will be the one that displays.  Namespacing should generally relate to the extension displaying the text. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
echo JText::_(&#039;Weblink Link&#039;);&lt;br /&gt;
echo JText::_(&#039;Weblink Title&#039;);&lt;br /&gt;
echo JText::_(&#039;Weblink Description&#039;);&lt;br /&gt;
&lt;br /&gt;
echo JText::_(&#039;Exception An error occurred while saving&#039;);&lt;br /&gt;
?&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TODO: Link to page with &amp;quot;common&amp;quot; strings that can be used for typical actions in components, such a &amp;quot;Save&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Where the same English word is used in two different locations, two different language keys should be used to allow for cases where the translation results in different words or phrases.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// A table column title&lt;br /&gt;
&amp;lt;th&amp;gt;&amp;lt;?php echo JText::_(&#039;Weblink Column Title&#039;);?&amp;gt;&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;&amp;lt;?php echo JText::_(&#039;Weblink Column Link&#039;);?&amp;gt;&amp;lt;/th&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// In the form&lt;br /&gt;
&amp;lt;?php echo JText::_(&#039;Weblink Title&#039;);?&amp;gt;&amp;lt;input name=&amp;quot;title&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;?php echo JText::_(&#039;Weblink Link&#039;);?&amp;gt;&amp;lt;input name=&amp;quot;link&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Toolbar and Linkbar text should be prefixed Toolbar and Linkbar respectively.&lt;br /&gt;
&lt;br /&gt;
The language keys should be written as naturally as possible with spaces, not underscores separating words.  Long phrases can be condensed to reduce keys to a sensible length.  For example, tooltips for an edit field can be written like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php echo JText::_(&#039;Weblink Title&#039;);?&amp;gt;&amp;lt;input name=&amp;quot;title&amp;quot; title=&amp;quot;&amp;lt;?php echo JText::_(&#039;Weblink Title Desc&#039;);?&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The convention used should be governed by common sense, but must be consistent.  In general consider how the language file will look with all keys sorted alphabetically.  Prefixes should be used to group text within a common context (such as column headings).  Suffixes should be used to group elements that logically go together (such as a field name and its description).&lt;br /&gt;
&lt;br /&gt;
Phrases must never be assembled by string concatenation. Each phrase must be represented by a single language key, using sprintf as appropriate to replace dynamic words in the phrase.  Where replacements are made, the word used should be as descriptive as possible and all-uppercase.  This assists the translators to determine the context of the replacement.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
// Not permitted&lt;br /&gt;
echo JText::_(&#039;Deleted &#039;).$n.JText::_(&#039; items&#039;);&lt;br /&gt;
&lt;br /&gt;
// Permitted&lt;br /&gt;
echo JText::sprintf(&#039;Message Deleted NUMBER items&#039;, $n);&lt;br /&gt;
?&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reference in the language file would look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;MESSAGE DELETED NUMBER ITEMS=Deleted %d Item(s)&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If more than one dynamic string is used in a phrase, the printf markers should employ order placement as other languages might change the position of the strings. This is done via %[number]$[printf_type] as follows:&lt;br /&gt;
&lt;br /&gt;
Left to right language:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;PAGE X OF Y=Page %1$d of %2$d&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Right to left language:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;PAGE X OF Y=%2$d of %1$d egaP&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
&lt;br /&gt;
For single controller components, the naming convention is &#039;&#039;[Name]Controller&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Content Controller&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class ContentController extends JController&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The file name will generally be &#039;&#039;controller.php&#039;&#039; and is located in the component folder.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
com_content&lt;br /&gt;
 / controller.php&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a multi-controller components, such as the Banners in the Administrator, the convention is &#039;&#039;[Component]Controller[Name]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Banner Client Controller&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class BannerControllerClient extends JController&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The files will be located in a &amp;lt;tt&amp;gt;/controllers/&amp;lt;/tt&amp;gt; folder under the component folder.  The file names will reflect the name of the controller.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
com_banner&lt;br /&gt;
  /controllers/&lt;br /&gt;
    / banner.php&lt;br /&gt;
    / client.php&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Models===&lt;br /&gt;
&lt;br /&gt;
The naming convention is &#039;&#039;[Component]Model[Name]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Banner Client Model&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class BannerModelClient extends JModel&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The files will be located in a &amp;lt;tt&amp;gt;/models/&amp;lt;/tt&amp;gt; folder under the component folder.  The file names will reflect the name of the model.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
com_banner&lt;br /&gt;
  /models/&lt;br /&gt;
    / banner.php&lt;br /&gt;
    / client.php&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Views ===&lt;br /&gt;
The naming convention is &#039;&#039;[Component]View[Name]&#039;&#039;.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Contact Category View&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class ContactViewCategory extends JView&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The files will be located in a &amp;lt;tt&amp;gt;/view/&amp;lt;/tt&amp;gt; folder under the component folder. The subfolder names will reflect the name of a View.&lt;br /&gt;
&lt;br /&gt;
 com_contact&lt;br /&gt;
  /views/&lt;br /&gt;
    /&#039;&#039;view name 1&#039;&#039;/&lt;br /&gt;
      / view.html.php&lt;br /&gt;
    /&#039;&#039;view name 2&#039;&#039;/&lt;br /&gt;
      / view.html.php&lt;br /&gt;
&lt;br /&gt;
Multi-view components such as com_content may provide an optional &amp;quot;master&amp;quot; view class the specialised views extend from. It is located in the component folder and typically called &#039;&#039;view.php&#039;&#039;. The naming convention is &#039;&#039;[Component]View&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 com_content&lt;br /&gt;
  /views/&lt;br /&gt;
     &amp;lt;span style=&amp;quot;color:#999&amp;quot;&amp;gt;/archive/&amp;lt;/span&amp;gt;&lt;br /&gt;
       / view.html.php&lt;br /&gt;
     &amp;lt;span style=&amp;quot;color:#999&amp;quot;&amp;gt;/article/&amp;lt;/span&amp;gt;&lt;br /&gt;
  / view.php&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
view.php&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Content View&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class ContentView extends JView&lt;br /&gt;
{&lt;br /&gt;
    // Helper Methods&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
views/archive/view.html.php&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Content Archive View&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class ContactViewArchive extends ContentView&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Plugins ===&lt;br /&gt;
&lt;br /&gt;
The naming convention is &#039;&#039;plg[Folder][Element]&#039;&#039; as pointed out in [[How to create a content plugin|the relative HowTo page]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class plgContentPagebreak extends JPlugin&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Layouts ===&lt;br /&gt;
Components may support different Layouts to render the data supplied by a [[#Views|View]] and its [[#Models|Models]]. A Layout file usually contains markup and some PHP code for &#039;&#039;display logic only&#039;&#039;: no functions, no classes.&lt;br /&gt;
&lt;br /&gt;
A Layout consists of at least one .php file and an equally named [[Creating a basic layout.xml file|.xml manifest file]] located in the &amp;lt;tt&amp;gt;/tmpl/&amp;lt;/tt&amp;gt; folder of a View, both reflect the internal name of the Layout. The standard Layout is called &#039;&#039;default&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:#999&amp;quot;&amp;gt;com_content&lt;br /&gt;
   /views/&lt;br /&gt;
     /article/&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:#000&amp;quot;&amp;gt;&lt;br /&gt;
       /tmpl/&lt;br /&gt;
         / default.php&lt;br /&gt;
         / default.xml&lt;br /&gt;
         / form.php&lt;br /&gt;
         / form.xml&lt;br /&gt;
         / pagebreak.php&lt;br /&gt;
         / pagebreak.xml &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Layout may use supplemental .php files to provide more granule control in order to render individual parts or repetitive items of the data.&lt;br /&gt;
&lt;br /&gt;
Users may customize the Layout output via [[#Template Layout Overrides|Template Layout Overrides]].&lt;br /&gt;
&lt;br /&gt;
=== Templates ===&lt;br /&gt;
&lt;br /&gt;
=== Template Layout Overrides ===&lt;/div&gt;</summary>
		<author><name>Paladin</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Talk:Coding_style_and_standards&amp;diff=31179</id>
		<title>Talk:Coding style and standards</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Talk:Coding_style_and_standards&amp;diff=31179"/>
		<updated>2010-09-29T21:56:51Z</updated>

		<summary type="html">&lt;p&gt;Paladin: /* Studly caps exception? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Shouldn&#039;t the JText not have spaces?&lt;br /&gt;
&lt;br /&gt;
== Studly caps exception? ==&lt;br /&gt;
&lt;br /&gt;
jImport() is given as an example. But the entire codebase is littered with jimport(), as well as lots of 3PD extensions. Do you mean to designate jImport() as the new canonical name for this method, or should we carry this as an exception?&lt;/div&gt;</summary>
		<author><name>Paladin</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Talk:Coding_style_and_standards&amp;diff=31178</id>
		<title>Talk:Coding style and standards</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Talk:Coding_style_and_standards&amp;diff=31178"/>
		<updated>2010-09-29T21:56:35Z</updated>

		<summary type="html">&lt;p&gt;Paladin: /* Studly caps exception? */ new section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Shouldn&#039;t the JText not have spaces?&lt;br /&gt;
&lt;br /&gt;
== Studly caps exception? ==&lt;br /&gt;
&lt;br /&gt;
jImport() is given as an example. But the entire codebase is lettered with jimport(), as well as lots of 3PD extensions. Do you mean to designate jImport() as the new canonical name for this method, or should we carry this as an exception?&lt;/div&gt;</summary>
		<author><name>Paladin</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Coding_style_and_standards&amp;diff=31177</id>
		<title>Coding style and standards</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Coding_style_and_standards&amp;diff=31177"/>
		<updated>2010-09-29T21:52:54Z</updated>

		<summary type="html">&lt;p&gt;Paladin: /* Doc Blocks */ Updated to reflect additional comments and their purpose.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{review}}&lt;br /&gt;
{{RightTOC}}&lt;br /&gt;
remark: The following information has been copied from the old WIKI archive has not yet been reviewed.&lt;br /&gt;
See: http://dev.joomla.org/component/option,com_jd-wiki/Itemid,/id,standards:coding/&lt;br /&gt;
&lt;br /&gt;
Good coding standards are important in any development project, but particularly when multiple developers are working on the same project. Having coding standards helps ensure that the code is of high quality, has fewer bugs, and is easily maintained.&lt;br /&gt;
&lt;br /&gt;
First rule, if in doubt, ask.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
All files contributed to Joomla must:&lt;br /&gt;
&lt;br /&gt;
* Be stored as ASCII text&lt;br /&gt;
* Use UTF-8 character encoding&lt;br /&gt;
* Be Unix formatted&lt;br /&gt;
** Lines must end only with a line feed (LF). Line feeds are represented as ordinal 10, octal 012 and hex 0A. Do not use carriage returns (CR) like Macintosh computers do or the carriage return/line feed combination (CRLF) like Windows computers do.&lt;br /&gt;
&lt;br /&gt;
New files will normally be added to the code base using Subversion (SVN). All SVN files should have the SVN property set &amp;quot;eol-style=LF&amp;quot;. Also, most Joomla! files will have &amp;quot;$Id&amp;quot; tags in the &amp;quot;@version&amp;quot; line of the Doc block. These require the SVN property &amp;quot;keywords=Id&amp;quot;. See [[Subversion File Properties]] for more information about how to set SVN properties.&lt;br /&gt;
&lt;br /&gt;
== Coding Standards ==&lt;br /&gt;
&lt;br /&gt;
=== Spelling ===&lt;br /&gt;
&lt;br /&gt;
Spelling of class, function, variable and constant names should generally be in accordance with British English rules (en_GB).  However, some exceptions are permitted, for example where common programming names are used that align with the PHP API such as &amp;lt;code&amp;gt;$color&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== E_STRICT-compatible code ===&lt;br /&gt;
&lt;br /&gt;
As of version 1.6, all new code that is suggested for inclusion into Joomla must be E_STRICT-compatible. This means that it must not produce any warnings or errors when PHP&#039;s error reporting level is set to E_ALL | E_STRICT.&lt;br /&gt;
&lt;br /&gt;
=== Indenting and Line Length ===&lt;br /&gt;
&lt;br /&gt;
Use tabs to indent, not spaces. Make sure that the tab-stops are set to only 4 spaces in length.&lt;br /&gt;
&lt;br /&gt;
There is no set limit for line length.  Use your judgment based on the nature of the line and readability.&lt;br /&gt;
&lt;br /&gt;
=== Control Structures ===&lt;br /&gt;
&lt;br /&gt;
These include if, for, while, switch, etc. Here is an example of an if statement, as it is the most complicated of the control structures:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
if ((condition1) || (condition2)) {&lt;br /&gt;
    action1();&lt;br /&gt;
} else if ((condition3) &amp;amp;&amp;amp; (condition4)) {&lt;br /&gt;
    action2();&lt;br /&gt;
} else&lt;br /&gt;
{&lt;br /&gt;
   // Use one true brace in control structures&lt;br /&gt;
   // when the block is longer than one line&lt;br /&gt;
    defaultAction();&lt;br /&gt;
    anotherAction();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// optional formatting if it improves readability&lt;br /&gt;
if ((condition1) || (condition2)) {&lt;br /&gt;
    action1();&lt;br /&gt;
}&lt;br /&gt;
else if ((condition3) &amp;amp;&amp;amp; (condition4)) {&lt;br /&gt;
    action2();&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
    defaultAction();&lt;br /&gt;
    anotherAction();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Control statements should have one space between the control keyword and opening parenthesis, to distinguish them from function calls.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;layouts&#039;&#039;&#039;, the alternative named notation should be used:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
if ((condition1) OR (condition2)) :&lt;br /&gt;
    action1();&lt;br /&gt;
elseif ((condition3) AND (condition4)) :&lt;br /&gt;
    action2();&lt;br /&gt;
else :&lt;br /&gt;
    defaultAction();&lt;br /&gt;
    anotherAction();&lt;br /&gt;
endif;&lt;br /&gt;
&lt;br /&gt;
foreach ($array as $element) :&lt;br /&gt;
    echo $element;&lt;br /&gt;
endforeach;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Logical operators in condition statements should use uppercase words (&amp;lt;code&amp;gt;AND&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;OR&amp;lt;/code&amp;gt;, etc) rather than programmatic notation (&amp;lt;code&amp;gt;&amp;amp;&amp;amp;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;||&amp;lt;/code&amp;gt;, etc).&lt;br /&gt;
&lt;br /&gt;
With the exception of &amp;lt;code&amp;gt;case&amp;lt;/code&amp;gt; statements, curly braces must always be included even though they are technically optional. Having them increases readability and decreases the likelihood of logic errors being introduced when new lines are added.&lt;br /&gt;
&lt;br /&gt;
For switch statements:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
switch (condition)&lt;br /&gt;
{&lt;br /&gt;
    case 1:&lt;br /&gt;
        doAction1();&lt;br /&gt;
        break;&lt;br /&gt;
&lt;br /&gt;
    case 2:&lt;br /&gt;
        doAction2();&lt;br /&gt;
        break;&lt;br /&gt;
&lt;br /&gt;
    default:&lt;br /&gt;
        doDefaultAction();&lt;br /&gt;
        break;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use indenting and line-breaks rather than curly braces in the &amp;lt;code&amp;gt;case&amp;lt;/code&amp;gt; statements to increase readability.  There should be no space between the condition and the colon in the &amp;lt;code&amp;gt;case&amp;lt;/code&amp;gt; statement.&lt;br /&gt;
&lt;br /&gt;
=== Function Calls ===&lt;br /&gt;
&lt;br /&gt;
Functions should be called with no spaces between the function name and the opening parenthesis, and no space between this and the first parameter; a space after the comma between each parameter (if they are present), and no space between the last parameter and the closing parenthesis, and the semicolon. Here&#039;s an example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$var = foo($bar, $baz, $quux);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As displayed above, there should be space before and one space after the equals sign used to assign the return value of a function to a variable. In the case of a block of related assignments, tabs (not spaces) may be inserted to promote readability:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$short          = foo($bar);&lt;br /&gt;
$long_variable  = foo($baz);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Function Definitions ===&lt;br /&gt;
&lt;br /&gt;
Class and function declarations follow the &amp;quot;one true brace&amp;quot; convention:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
function fooFunction($arg1, $arg2 = &#039;&#039;)&lt;br /&gt;
{&lt;br /&gt;
    if (condition) {&lt;br /&gt;
        statement;&lt;br /&gt;
    }&lt;br /&gt;
    return $val;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class fooClass&lt;br /&gt;
{&lt;br /&gt;
    function fooMethod($arg1)&lt;br /&gt;
    {&lt;br /&gt;
        if ($arg) {&lt;br /&gt;
            $result = true;&lt;br /&gt;
        } else {&lt;br /&gt;
            $result = false;&lt;br /&gt;
        }&lt;br /&gt;
        return $result;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Arguments with default values go at the end of the argument list. Always attempt to return a meaningful value from a function if one is appropriate. Here is a slightly longer example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
function connect(&amp;amp;$dsn, $persistent = false)&lt;br /&gt;
{&lt;br /&gt;
    if (is_array($dsn)) {&lt;br /&gt;
        $dsninfo = &amp;amp;$dsn;&lt;br /&gt;
    } else {&lt;br /&gt;
        $dsninfo = DB::parseDSN($dsn);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    if (!$dsninfo OR !$dsninfo[&#039;phptype&#039;]) {&lt;br /&gt;
        return $this-&amp;gt;raiseError();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Comments ===&lt;br /&gt;
&lt;br /&gt;
Inline documentation for classes should follow the PHPDoc convention, similar to Javadoc. More information about PHPDoc can be found here: http://www.phpdoc.org/&lt;br /&gt;
&lt;br /&gt;
See also [[Adding phpDocumentor comments]]&lt;br /&gt;
&lt;br /&gt;
Non-documentation comments are strongly encouraged. A general rule of thumb is that if you look at a section of code and think &amp;quot;Wow, I don&#039;t want to try and describe that&amp;quot;, you need to comment it before you forget how it works.&lt;br /&gt;
&lt;br /&gt;
C style comments (&amp;lt;tt&amp;gt;/* */&amp;lt;/tt&amp;gt;) and standard C++ comments (&amp;lt;tt&amp;gt;//&amp;lt;/tt&amp;gt;) are both satisfactory. Use of Perl/shell style comments (&amp;lt;tt&amp;gt;#&amp;lt;/tt&amp;gt;) is not permitted.&lt;br /&gt;
&lt;br /&gt;
Please note - commented code is not to be committed to trunk or release repositories.&lt;br /&gt;
&lt;br /&gt;
=== Including Code ===&lt;br /&gt;
&lt;br /&gt;
Anywhere you are unconditionally including a class file, use &amp;lt;code&amp;gt;require_once&amp;lt;/code&amp;gt;. Anywhere you are conditionally including a class file (for example, factory methods), use &amp;lt;code&amp;gt;include_once&amp;lt;/code&amp;gt;. Either of these will ensure that class files are included only once. They share the same file list, so you don&#039;t need to worry about mixing them -- a file included with &amp;lt;code&amp;gt;require_once&amp;lt;/code&amp;gt; will not be included again by &amp;lt;/code&amp;gt;include_once&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
;Note: [[php:include_once|include_once]] and [[php:require_once|require_once]] are PHP &#039;&#039;language statements&#039;&#039;, not functions. You don&#039;t need parentheses around the filename to be included.&lt;br /&gt;
&lt;br /&gt;
=== PHP Code Tags ===&lt;br /&gt;
&lt;br /&gt;
Always use &amp;lt;tt&amp;gt;&amp;amp;lt;?php ?&amp;gt;&amp;lt;/tt&amp;gt; to delimit PHP code, not the &amp;lt;tt&amp;gt;&amp;amp;lt;? ?&amp;gt;&amp;lt;/tt&amp;gt; shorthand. This is the most portable way to include PHP code on differing operating systems and setups.&lt;br /&gt;
&lt;br /&gt;
For files that contain only PHP code, the closing tag (&amp;lt;tt&amp;gt;?&amp;gt;&amp;lt;/tt&amp;gt;) is never permitted. It is not required by PHP. Not including it prevents trailing white space from being accidentally injected into the output (see PHP manual on [http://au.php.net/basic-syntax.instruction-separation instruction separation]).&lt;br /&gt;
&lt;br /&gt;
=== SQL Queries ===&lt;br /&gt;
&lt;br /&gt;
SQL keywords are to be written in uppercase, while all other identifiers (which the exception of quoted text obviously) is to be in lowercase. Carriage returns should not be used as [[JDatabase]]::getQuery provides for formatted output.  However, indenting with spaces to improve readability is desireable.&lt;br /&gt;
&lt;br /&gt;
Queries should be wrapped in single quotes (as these text blocks are parsed faster by php).&lt;br /&gt;
&lt;br /&gt;
All quoted strings must use the &#039;&#039;Quote&#039;&#039; method to facilitate future compatibility with other database engines.&lt;br /&gt;
&lt;br /&gt;
All table names should use the &#039;&#039;&#039;&amp;lt;tt&amp;gt;#_&amp;lt;/tt&amp;gt;&#039;&#039;&#039; prefix rather than &amp;lt;tt&amp;gt;jos_&amp;lt;/tt&amp;gt; to access Joomla! contents and allow for the [[screen.config.15#Database_Settings|user defined database prefix]] to be applied.&lt;br /&gt;
&lt;br /&gt;
All expected integer or floating-point variable must be [http://php.net/manual/language.types.type-juggling.php cast] with &amp;lt;tt&amp;gt;(int)&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;(float)&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;(double)&amp;lt;/tt&amp;gt; as appropriate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$state = 1;&lt;br /&gt;
$name  = &#039;bill&#039;;&lt;br /&gt;
$db    = &amp;amp;JFactory::getDBO();&lt;br /&gt;
$query = &#039;SELECT COUNT( c.id ) AS num_articles, u.id, u.username&#039;.&lt;br /&gt;
    &#039; FROM #__content AS c&#039;.&lt;br /&gt;
    &#039; LEFT JOIN #__users AS u ON u.id = c.created_by&#039;.&lt;br /&gt;
    &#039; WHERE c.state = &#039;.(int) $state&lt;br /&gt;
    &#039;  AND u.id IS NOT NULL&#039;.&lt;br /&gt;
    &#039;  AND u.username &amp;lt;&amp;gt; &#039;.$db-&amp;gt;Quote( $name ).&lt;br /&gt;
    &#039; GROUP BY u.id&#039;.&lt;br /&gt;
    &#039;  HAVING COUNT( c.id ) &amp;gt; 0&#039;;&lt;br /&gt;
$db-&amp;gt;setQuery();&lt;br /&gt;
// Output formated query if joomla debug is active:&lt;br /&gt;
if (JDEBUG) {&lt;br /&gt;
    echo $db-&amp;gt;getQuery();&lt;br /&gt;
}&lt;br /&gt;
$stats = $db-&amp;gt;loadObjectList();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Doc Blocks ===&lt;br /&gt;
&lt;br /&gt;
All source code files in the core Joomla distribution must contain the following comment block as the header:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Short description of file&lt;br /&gt;
 *&lt;br /&gt;
 * Longer description of file is optional, but should be included if the file contains multiple classes or non-class material.&lt;br /&gt;
 *&lt;br /&gt;
 * PHP version 5.2.4 (put in the minimum version of PHP expected for the code here to run)&lt;br /&gt;
 *&lt;br /&gt;
 * @version	$Id$&lt;br /&gt;
 * @package	Joomla&lt;br /&gt;
 * @copyright	Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.&lt;br /&gt;
 * @license	GNU/GPL, see LICENSE.php&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;@package&amp;lt;/code&amp;gt; in the header is not required for class-only files.&lt;br /&gt;
&lt;br /&gt;
Classes, functions, constants, class properties and class methods should all be supplied with appropriate DocBlocks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * Short description for class&lt;br /&gt;
 *&lt;br /&gt;
 * Long description for class (if any)...&lt;br /&gt;
 *&lt;br /&gt;
 * @package    PackageName&lt;br /&gt;
 * @subpackage SubPackageName&lt;br /&gt;
 * @link       http://pear.php.net/package/PackageName&lt;br /&gt;
 * @see        NetOther, Net_Sample::Net_Sample()&lt;br /&gt;
 * @since      Class available since Release 1.2.0&lt;br /&gt;
 * @deprecated Class deprecated in Release 2.0.0&lt;br /&gt;
 */&lt;br /&gt;
class JFooBar&lt;br /&gt;
{&lt;br /&gt;
    /**&lt;br /&gt;
     * @var int $id Primary key&lt;br /&gt;
     */&lt;br /&gt;
    public $id = null;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following package names are to be used in the core stack:&lt;br /&gt;
&lt;br /&gt;
* Joomla.Administrator - all files that belong only to the administrator or backend application&lt;br /&gt;
* Joomla.Installation - all files that belong to the installation application&lt;br /&gt;
* Joomla.Plugin - all plugin files&lt;br /&gt;
* Joomla.Site - all files that pertain only to the site or frontend application&lt;br /&gt;
* Joomla.XML-RPC - all files that belong to the XML-RPC server application&lt;br /&gt;
&lt;br /&gt;
The sub-package name will vary according to the extension type:&lt;br /&gt;
&lt;br /&gt;
* Components - the component folder, eg &amp;lt;code&amp;gt;com_content&amp;lt;/code&amp;gt;&lt;br /&gt;
* Modules - the module folder, eg &amp;lt;code&amp;gt;mod_latest_news&amp;lt;/code&amp;gt;&lt;br /&gt;
* Plugins - the folder.element, eg &amp;lt;code&amp;gt;content.pagebreak&amp;lt;/code&amp;gt;&lt;br /&gt;
* Templates - the template folder, eg &amp;lt;code&amp;gt;rhuk_milkyway&amp;lt;/code&amp;gt;&lt;br /&gt;
* Framework - nothing for top level files (such as &amp;lt;code&amp;gt;factory.php&amp;lt;/code&amp;gt;), the first level folder or the first.second level folders as appropriate, eg &amp;lt;code&amp;gt;utilities&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;joomla/utilities/date.php&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;html.html&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;joomla/html/html/email.php&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please note that code contributed to the Joomla stack that will become the copyright of the project is not allowed to include &amp;lt;code&amp;gt;@author&amp;lt;/code&amp;gt; tags.  You should update the contribution log in &amp;lt;tt&amp;gt;CREDITS.php&amp;lt;/tt&amp;gt;.  Joomla&#039;s philosophy is that the code is written &amp;quot;all together&amp;quot; and there is no notion of any one person &#039;owning&#039; any section of code.&lt;br /&gt;
&lt;br /&gt;
Files included from third party sources must leave DocBlocks intact. Layout files use the same DocBlocks as other PHP files. &lt;br /&gt;
&lt;br /&gt;
Note that the &amp;quot;@version $Id&amp;quot; line uses the SVN &amp;quot;keywords=Id&amp;quot; property. See [[Subversion File Properties]] for information about setting this property.&lt;br /&gt;
&lt;br /&gt;
== Naming Conventions ==&lt;br /&gt;
&lt;br /&gt;
=== Classes ===&lt;br /&gt;
&lt;br /&gt;
Classes should be given descriptive names. Avoid using abbreviations where possible. Class names should always begin with an uppercase letter and be written in CamelCase even if using traditionally uppercase acronyms (such as XML, HTML).  One exception is for Joomla framework classes which must begin with an uppercase &#039;J&#039; with the next letter also being uppercase.  For example:&lt;br /&gt;
&lt;br /&gt;
* JHtmlHelper&lt;br /&gt;
* JXmlParser&lt;br /&gt;
* JModel&lt;br /&gt;
&lt;br /&gt;
Third-party developers are advised to namespace their functions with a unique prefix.&lt;br /&gt;
&lt;br /&gt;
=== Functions and Methods ===&lt;br /&gt;
&lt;br /&gt;
Functions and methods should be named using the &amp;quot;studly caps&amp;quot; style (also referred to as &amp;quot;bumpy case&amp;quot; or &amp;quot;camel caps&amp;quot;). The initial letter of the name is lowercase, and each letter that starts a new &amp;quot;word&amp;quot; is capitalized. Function in the Joomla framework must begin with a lowercase &#039;j&#039;.  Some examples:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
connect();&lt;br /&gt;
getData();&lt;br /&gt;
buildSomeWidget();&lt;br /&gt;
jImport();&lt;br /&gt;
jDoSomething();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Private class members (meaning class members that are intended to be used only from within the same class in which they are declared; are preceded by a single underscore. Properties are to be written in underscore format (that is, logical words separated by underscores) and should be all lowercase.  For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class JFooBar&lt;br /&gt;
{&lt;br /&gt;
    // Joomla 1.5 and earlier format&lt;br /&gt;
    var $_status = null;&lt;br /&gt;
&lt;br /&gt;
    function _sort()&lt;br /&gt;
    {&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Joomla 1.6 format&lt;br /&gt;
    private $_status = null;&lt;br /&gt;
&lt;br /&gt;
    protected $field_name = null;&lt;br /&gt;
&lt;br /&gt;
    protected function _sort()&lt;br /&gt;
    {&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Constants ===&lt;br /&gt;
&lt;br /&gt;
Constants should always be all-uppercase, with underscores to separate words. Prefix constant names with the uppercase name of the class/package they are used in. For example, the constants used by the [[JError]] class all begin with &amp;quot;JERROR_&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Global Variables ===&lt;br /&gt;
&lt;br /&gt;
If your package needs to define global variables, their name should start with a single underscore followed by the uppercase class/package name and another underscore. For example, the JError class uses a global variable called $_JERROR_LEVELS.&lt;br /&gt;
&lt;br /&gt;
With PHP5 and later you may use static class properties or constants instead of globals.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
class JWhatever&lt;br /&gt;
{&lt;br /&gt;
    public static $instance = null;&lt;br /&gt;
    const SUCCESS = 1;&lt;br /&gt;
    const FAILURE = 0;&lt;br /&gt;
    // Methods...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Regular and Class Variables ===&lt;br /&gt;
&lt;br /&gt;
Regular variables, follow the same conventions as function.&lt;br /&gt;
&lt;br /&gt;
Class variables should be set to null or some other appropriate default value. Lining up the default values with tabs should only be used if particularly warranted for readability.&lt;br /&gt;
&lt;br /&gt;
=== References ===&lt;br /&gt;
&lt;br /&gt;
When using references, there should be a space before the reference operator and no space between it and the function or variable name.  For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$ref1  = &amp;amp;$this-&amp;gt;_sql;&lt;br /&gt;
$db    = &amp;amp;JFactory::getDBO();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Language Keys ===&lt;br /&gt;
&lt;br /&gt;
NOTE: This part has to be rewritten for 1.6 (JM)&lt;br /&gt;
&lt;br /&gt;
Except for the most common of words, such as &amp;quot;Yes&amp;quot;, &amp;quot;No&amp;quot;, &amp;quot;Show&amp;quot;, &amp;quot;Hide&amp;quot; all language keys should be namespaced to reflect the type of string they represent.  Always consider that if two extensions use the same key, the one loaded last will be the one that displays.  Namespacing should generally relate to the extension displaying the text. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
echo JText::_(&#039;Weblink Link&#039;);&lt;br /&gt;
echo JText::_(&#039;Weblink Title&#039;);&lt;br /&gt;
echo JText::_(&#039;Weblink Description&#039;);&lt;br /&gt;
&lt;br /&gt;
echo JText::_(&#039;Exception An error occurred while saving&#039;);&lt;br /&gt;
?&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TODO: Link to page with &amp;quot;common&amp;quot; strings that can be used for typical actions in components, such a &amp;quot;Save&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Where the same English word is used in two different locations, two different language keys should be used to allow for cases where the translation results in different words or phrases.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// A table column title&lt;br /&gt;
&amp;lt;th&amp;gt;&amp;lt;?php echo JText::_(&#039;Weblink Column Title&#039;);?&amp;gt;&amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt;&amp;lt;?php echo JText::_(&#039;Weblink Column Link&#039;);?&amp;gt;&amp;lt;/th&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// In the form&lt;br /&gt;
&amp;lt;?php echo JText::_(&#039;Weblink Title&#039;);?&amp;gt;&amp;lt;input name=&amp;quot;title&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;?php echo JText::_(&#039;Weblink Link&#039;);?&amp;gt;&amp;lt;input name=&amp;quot;link&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Toolbar and Linkbar text should be prefixed Toolbar and Linkbar respectively.&lt;br /&gt;
&lt;br /&gt;
The language keys should be written as naturally as possible with spaces, not underscores separating words.  Long phrases can be condensed to reduce keys to a sensible length.  For example, tooltips for an edit field can be written like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php echo JText::_(&#039;Weblink Title&#039;);?&amp;gt;&amp;lt;input name=&amp;quot;title&amp;quot; title=&amp;quot;&amp;lt;?php echo JText::_(&#039;Weblink Title Desc&#039;);?&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The convention used should be governed by common sense, but must be consistent.  In general consider how the language file will look with all keys sorted alphabetically.  Prefixes should be used to group text within a common context (such as column headings).  Suffixes should be used to group elements that logically go together (such as a field name and its description).&lt;br /&gt;
&lt;br /&gt;
Phrases must never be assembled by string concatenation. Each phrase must be represented by a single language key, using sprintf as appropriate to replace dynamic words in the phrase.  Where replacements are made, the word used should be as descriptive as possible and all-uppercase.  This assists the translators to determine the context of the replacement.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
// Not permitted&lt;br /&gt;
echo JText::_(&#039;Deleted &#039;).$n.JText::_(&#039; items&#039;);&lt;br /&gt;
&lt;br /&gt;
// Permitted&lt;br /&gt;
echo JText::sprintf(&#039;Message Deleted NUMBER items&#039;, $n);&lt;br /&gt;
?&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reference in the language file would look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;MESSAGE DELETED NUMBER ITEMS=Deleted %d Item(s)&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If more than one dynamic string is used in a phrase, the printf markers should employ order placement as other languages might change the position of the strings. This is done via %[number]$[printf_type] as follows:&lt;br /&gt;
&lt;br /&gt;
Left to right language:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;PAGE X OF Y=Page %1$d of %2$d&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Right to left language:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;PAGE X OF Y=%2$d of %1$d egaP&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Controllers ===&lt;br /&gt;
&lt;br /&gt;
For single controller components, the naming convention is &#039;&#039;[Name]Controller&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Content Controller&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class ContentController extends JController&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The file name will generally be &#039;&#039;controller.php&#039;&#039; and is located in the component folder.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
com_content&lt;br /&gt;
 / controller.php&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a multi-controller components, such as the Banners in the Administrator, the convention is &#039;&#039;[Component]Controller[Name]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Banner Client Controller&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class BannerControllerClient extends JController&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The files will be located in a &amp;lt;tt&amp;gt;/controllers/&amp;lt;/tt&amp;gt; folder under the component folder.  The file names will reflect the name of the controller.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
com_banner&lt;br /&gt;
  /controllers/&lt;br /&gt;
    / banner.php&lt;br /&gt;
    / client.php&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Models===&lt;br /&gt;
&lt;br /&gt;
The naming convention is &#039;&#039;[Component]Model[Name]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Banner Client Model&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class BannerModelClient extends JModel&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The files will be located in a &amp;lt;tt&amp;gt;/models/&amp;lt;/tt&amp;gt; folder under the component folder.  The file names will reflect the name of the model.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
com_banner&lt;br /&gt;
  /models/&lt;br /&gt;
    / banner.php&lt;br /&gt;
    / client.php&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Views ===&lt;br /&gt;
The naming convention is &#039;&#039;[Component]View[Name]&#039;&#039;.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Contact Category View&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class ContactViewCategory extends JView&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The files will be located in a &amp;lt;tt&amp;gt;/view/&amp;lt;/tt&amp;gt; folder under the component folder. The subfolder names will reflect the name of a View.&lt;br /&gt;
&lt;br /&gt;
 com_contact&lt;br /&gt;
  /views/&lt;br /&gt;
    /&#039;&#039;view name 1&#039;&#039;/&lt;br /&gt;
      / view.html.php&lt;br /&gt;
    /&#039;&#039;view name 2&#039;&#039;/&lt;br /&gt;
      / view.html.php&lt;br /&gt;
&lt;br /&gt;
Multi-view components such as com_content may provide an optional &amp;quot;master&amp;quot; view class the specialised views extend from. It is located in the component folder and typically called &#039;&#039;view.php&#039;&#039;. The naming convention is &#039;&#039;[Component]View&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 com_content&lt;br /&gt;
  /views/&lt;br /&gt;
     &amp;lt;span style=&amp;quot;color:#999&amp;quot;&amp;gt;/archive/&amp;lt;/span&amp;gt;&lt;br /&gt;
       / view.html.php&lt;br /&gt;
     &amp;lt;span style=&amp;quot;color:#999&amp;quot;&amp;gt;/article/&amp;lt;/span&amp;gt;&lt;br /&gt;
  / view.php&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
view.php&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Content View&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class ContentView extends JView&lt;br /&gt;
{&lt;br /&gt;
    // Helper Methods&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
views/archive/view.html.php&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Content Archive View&lt;br /&gt;
 * @package Joomla&lt;br /&gt;
 */&lt;br /&gt;
class ContactViewArchive extends ContentView&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Plugins ===&lt;br /&gt;
&lt;br /&gt;
The naming convention is &#039;&#039;plg[Folder][Element]&#039;&#039; as pointed out in [[How to create a content plugin|the relative HowTo page]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class plgContentPagebreak extends JPlugin&lt;br /&gt;
{&lt;br /&gt;
    // Methods&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Layouts ===&lt;br /&gt;
Components may support different Layouts to render the data supplied by a [[#Views|View]] and its [[#Models|Models]]. A Layout file usually contains markup and some PHP code for &#039;&#039;display logic only&#039;&#039;: no functions, no classes.&lt;br /&gt;
&lt;br /&gt;
A Layout consists of at least one .php file and an equally named [[Creating a basic layout.xml file|.xml manifest file]] located in the &amp;lt;tt&amp;gt;/tmpl/&amp;lt;/tt&amp;gt; folder of a View, both reflect the internal name of the Layout. The standard Layout is called &#039;&#039;default&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:#999&amp;quot;&amp;gt;com_content&lt;br /&gt;
   /views/&lt;br /&gt;
     /article/&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:#000&amp;quot;&amp;gt;&lt;br /&gt;
       /tmpl/&lt;br /&gt;
         / default.php&lt;br /&gt;
         / default.xml&lt;br /&gt;
         / form.php&lt;br /&gt;
         / form.xml&lt;br /&gt;
         / pagebreak.php&lt;br /&gt;
         / pagebreak.xml &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Layout may use supplemental .php files to provide more granule control in order to render individual parts or repetitive items of the data.&lt;br /&gt;
&lt;br /&gt;
Users may customize the Layout output via [[#Template Layout Overrides|Template Layout Overrides]].&lt;br /&gt;
&lt;br /&gt;
=== Templates ===&lt;br /&gt;
&lt;br /&gt;
=== Template Layout Overrides ===&lt;/div&gt;</summary>
		<author><name>Paladin</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=31084</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=31084"/>
		<updated>2010-09-25T16:42:36Z</updated>

		<summary type="html">&lt;p&gt;Paladin: /* Unit Testing in Joomla! */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{cookiejar}}&lt;br /&gt;
== News and Updates ==&lt;br /&gt;
2009 10 06: Tests now depend on the SVN version of PHPUnit 3.4.1.&lt;br /&gt;
&lt;br /&gt;
2008 06 24: Update to reflect move of PHPUnit code from branch to trunk (former trunk now in /branches/old_simpletest).&lt;br /&gt;
&lt;br /&gt;
2008 06 22: Add information on limiting tests by version.&lt;br /&gt;
&lt;br /&gt;
2008 06 21: Added --class-exclude, --sequence-exclude, and --test-exclude options.&lt;br /&gt;
&lt;br /&gt;
2008 06 21: PHPUnit has been updated to version 3.2.21 with SVN rev 10436. Please update.&lt;br /&gt;
&lt;br /&gt;
== Unit Testing ==&lt;br /&gt;
Unit testing is not only an essential part of a good Quality Control program, it is an aid to development as well. Writing new tests before writing code helps focus the developer on the problem at hand. The practice also encourages writing smaller, more loosely coupled, more reusable, and more maintainable code units and these benefits often outweigh the benefits gained by treating unit tests solely as a QC tool. When used in this manner correctness becomes more a by-product of the process than the goal.&lt;br /&gt;
For a good general discussion of unit testing, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== The Testing Hierarchy: Unit, Subsystem, Integrated ===&lt;br /&gt;
Software testing systems usually run through a spectrum from &amp;quot;pure&amp;quot; unit tests through to fully integrated systems tests. We&#039;ve described low level unit tests above. Integrated testing typically involves some sort of script that simulates user actions and then verifies that the result matches what&#039;s expected. This sort of &amp;quot;end to end&amp;quot; test verifies that all parts of the system are working correctly.&lt;br /&gt;
&lt;br /&gt;
It&#039;s unfortunate that there is no clear nomenclature to describe all the intermediate stages of testing. The next stage beyond testing a single unit of code is subsystem testing. A subsystem test verifies that two or more units of code are interacting correctly to produce the desired result. In the simplest case, a subsystem test can be created simply by replacing mock objects with real objects and running unit tests on the top level module. In practise, this tends to not work as well as expected, because the original unit test data wasn&#039;t designed for a subsystem test, or because the nature of the test cases needs to be changed in order to fully test the subsystem. After all there is little point in simply repeating the unit test cases; the objective of a subsystem test should be to test boundary conditions and special cases that would be difficult to duplicate in unit tests.&lt;br /&gt;
&lt;br /&gt;
Once a subsystem has been tested, it can be integrated into a larger system, which is still a subset of the whole product. Tests can be written for larger and larger subsystems, but at each stage the complexity of the tests increases. At some point, the effort required to hand craft tests exceeds the benefits of running them. This is where integrated testing comes in.&lt;br /&gt;
&lt;br /&gt;
Integrated testing involves recording a user&#039;s interaction with the system into a script that can be replayed. The testing framework then compares the system&#039;s response with the expected response and passes or fails the test. The PHPUnit testing framework that we use has the ability to work with [http://seleniumhq.org/ Selenium], a browser based test automation tool. Writing a functional test using Selenium is documented [http://docs.joomla.org/Functional_Testing#Writing_Functional_Tests here].&lt;br /&gt;
&lt;br /&gt;
==== Test Objects ====&lt;br /&gt;
The purpose of unit tests is to isolate a module of code. A test that tests only one thing provides better information than a test that involves several object interactions. But how do we isolate an object from its dependencies? By writing stub classes. [http://xunitpatterns.com/Mocks,%20Fakes,%20Stubs%20and%20Dummies.html xUnit Patterns] defines a the hierarchy of dummy classes, ranging from simple to complex:&lt;br /&gt;
* Dummy - Defines attributes and methods of a dummy class (not particularly useful in PHP).&lt;br /&gt;
* Fake - Provides canned responses to method calls and fixed attribute values. Good for speed.&lt;br /&gt;
* Stub - Allows the test to define responses to method calls (return values, exceptions) to simulate the dependent object.&lt;br /&gt;
* Spy - A Fake or Stub that records method calls and parameters for later analysis.&lt;br /&gt;
* Mock - A Fake or Stub with a set of expectations -- method calls and parameters -- that are automatically verified for correctness.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests.&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk used to contain code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
The PHPUnit tests are found in &#039;&#039;&#039;/tests/unit&#039;&#039;&#039; in the development trunk. See [http://docs.joomla.org/Running_Automated_Tests_for_Version_1.6 Running Automated Tests for Version 1.6] for instructions on setting up unit testing in your IDE.&lt;br /&gt;
&lt;br /&gt;
==== The Unit Test Team ====&lt;br /&gt;
If you can commit to the Joomla code base, then you should consider yourself part of the unit test team!&lt;br /&gt;
&lt;br /&gt;
Writing tests concurrently with code (or even before) is a good way to not only save development time, but a great tool for defending against regressions. Writing tests early in the development cycle also helps identify and resolve design issues sooner, which reduces refactoring.&lt;br /&gt;
&lt;br /&gt;
If you want to get started on unit testing, get in touch with Alan Langford (instance) or Ray Tsai (mihu). Either of us will be happy to help out.&lt;br /&gt;
&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-Test.php, for example JObject-0000-class-Test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;br /&gt;
* The custom test runner is no longer needed. The current tests will run with the latest SVN version of PHPUnit 3.4. This code will eventually become PHPUnit 3.4.1.  Thanks to Sebastian Bergmann for his excellent work on an excellent project!&lt;br /&gt;
&lt;br /&gt;
==== Writing Unit Tests ====&lt;br /&gt;
At risk of stating the obvious, in the &amp;quot;purest&amp;quot; case the purpose of a unit test is to &#039;&#039;isolate a unit of code from its environment and to test the operation of that code&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This isolation is usually achieved by writing dummy classes that emulate the code unit&#039;s environment. These dummy objects can be passive, by simply simulating the environment, or they can be more active, keeping track of how they are being used by the test unit and reporting any variations from the expected behaviour. See [[Unit_Testing_Mock_Objects|Mock Objects in Joomla]] for a detailed example.&lt;br /&gt;
&lt;br /&gt;
An interesting aspect of writing tests is that they become &#039;&#039;de facto&#039;&#039; detailed technical specifications of the interfaces between units of code. The fact that these specifications can be verified in an automated way makes them a superb resource when refactoring code.&lt;br /&gt;
&lt;br /&gt;
The test code has a few templates designed to kick-start a test. They are:&lt;br /&gt;
&lt;br /&gt;
/unittest/sample-datatest-php.txt&lt;br /&gt;
/unittest/sample-simpletest.php.txt&lt;br /&gt;
&lt;br /&gt;
Here are some example tests: [[Unit_Testing_--_a_Simple_Example|Simple Example]], [[Unit_Testing_--_Data_Driven_Example|Data Driven Example]], [[Unit_Testing_--_Plugin_Example|Plugin Example]], [[Unit_Testing_--_UI_Example|UI Example]].&lt;br /&gt;
&lt;br /&gt;
==== Running Unit Tests ====&lt;br /&gt;
Test files follow the form class-sequence-type-Test.php, for example JObject-0000-class-Test.php. For tests that are not class based, the first element refers to the object being tested. An example of this is the e-mail cloaking plugin test, which is called emailcloak-0000-mode1-Test.php.&lt;br /&gt;
&lt;br /&gt;
Joomla unit tests use the standard PHPUnit test runner.  See http://www.phpunit.de for documentation.&lt;br /&gt;
&lt;br /&gt;
== How to Get it Running ==&lt;br /&gt;
&lt;br /&gt;
Before you start make sure you have installed PHPUnit and of course PHP (5!) properly...&lt;br /&gt;
&lt;br /&gt;
To get the unit tests to run on your Joomla! installation, perform the following steps:&lt;br /&gt;
* Create an instance of your Joomla! installation. Since you will be using SVN to check out the testing project, you don&#039;t want to check out the Joomla! with SVN. Instead, simply unpack a normal Joomla! archive. If you are using Eclipse, you can create a folder in your Eclipse workspace for the Joomla! installation, but don&#039;t create an Eclipse project yet.&lt;br /&gt;
* In the root checkout (or export) the latest version of the unit test code from SVN &#039;&#039;&amp;quot;/testing/trunk/1.5/unittest&amp;quot;&#039;&#039; or &#039;&#039;&amp;quot;/testing/trunk/1.6/unittest&amp;quot;&#039;&#039; to your installation base. This will create a &#039;&#039;&amp;quot;/unittest&amp;quot;&#039;&#039; sub-folder under your joomla installation. If you are using Eclipse, Import the project from the SVN and use the same folder in your Eclipse workspace you used above.&lt;br /&gt;
* From the command line, change to the unittest directory.&lt;br /&gt;
* Run the unit test from the command prompt using the following command: &amp;lt;code&amp;gt;phpunit tests&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The unit test will the run, and the results are rendered. You will see a series of dots for each passed test and other letters for failed tests. &lt;br /&gt;
&lt;br /&gt;
See http://www.phpunit.de/manual/current/en/textui.html for help using the --filter switch to run only certain tests.  There are also many other command line switches you can use to get results in various formats.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
The provided configurations should work out of the box. We have seen problems with it (currently the cause is unknown). If you get an error like below, the solution is pretty easy.&lt;br /&gt;
&lt;br /&gt;
 file=/var/www/unittest/runtests.php&lt;br /&gt;
 posn=17&lt;br /&gt;
 base=runtests.php&lt;br /&gt;
 /var/www&lt;br /&gt;
  JPATH_BASE does not point to a valid Joomla! installation:&lt;br /&gt;
 JPATH_BASE = /var/www&lt;br /&gt;
  Please modify your copy of &amp;quot;TestConfiguration.php&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Modify the &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file and change the definition of the JPATH_BASE so it points to the path of you Joomla! installation, in the example below the Joomla! installation is installed at &amp;quot;&#039;&#039;/var/www/update&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 define(&#039;JPATH_BASE&#039;, &#039;/var/www/update&#039;);&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&#039;&#039;&#039;Why can&#039;t I use &amp;quot;phpunit &#039;&#039;testname.php&#039;&#039;&amp;quot; to run my tests?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The test facility has to do some work to be able to load the &amp;quot;Joomla!&amp;quot; framework and to be able to inject mock classes. It&#039;s difficult to do this from the PHPUnit test runner, so we built our own. Also, the Joomla test runner has specific options designed to make it easy to select specific tests. Over time we will add more functionality to the test runner so it has many of the capabilities of the phpunit command.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[http://www.phpunit.de/manual/current/en/ PHPUnit Manual]&lt;br /&gt;
&lt;br /&gt;
[[Category:Bug Squad]]&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Testing]]&lt;br /&gt;
[[Category:Automated Testing]]&lt;/div&gt;</summary>
		<author><name>Paladin</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=31083</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=31083"/>
		<updated>2010-09-25T16:29:36Z</updated>

		<summary type="html">&lt;p&gt;Paladin: /* Unit Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{cookiejar}}&lt;br /&gt;
== News and Updates ==&lt;br /&gt;
2009 10 06: Tests now depend on the SVN version of PHPUnit 3.4.1.&lt;br /&gt;
&lt;br /&gt;
2008 06 24: Update to reflect move of PHPUnit code from branch to trunk (former trunk now in /branches/old_simpletest).&lt;br /&gt;
&lt;br /&gt;
2008 06 22: Add information on limiting tests by version.&lt;br /&gt;
&lt;br /&gt;
2008 06 21: Added --class-exclude, --sequence-exclude, and --test-exclude options.&lt;br /&gt;
&lt;br /&gt;
2008 06 21: PHPUnit has been updated to version 3.2.21 with SVN rev 10436. Please update.&lt;br /&gt;
&lt;br /&gt;
== Unit Testing ==&lt;br /&gt;
Unit testing is not only an essential part of a good Quality Control program, it is an aid to development as well. Writing new tests before writing code helps focus the developer on the problem at hand. The practice also encourages writing smaller, more loosely coupled, more reusable, and more maintainable code units and these benefits often outweigh the benefits gained by treating unit tests solely as a QC tool. When used in this manner correctness becomes more a by-product of the process than the goal.&lt;br /&gt;
For a good general discussion of unit testing, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== The Testing Hierarchy: Unit, Subsystem, Integrated ===&lt;br /&gt;
Software testing systems usually run through a spectrum from &amp;quot;pure&amp;quot; unit tests through to fully integrated systems tests. We&#039;ve described low level unit tests above. Integrated testing typically involves some sort of script that simulates user actions and then verifies that the result matches what&#039;s expected. This sort of &amp;quot;end to end&amp;quot; test verifies that all parts of the system are working correctly.&lt;br /&gt;
&lt;br /&gt;
It&#039;s unfortunate that there is no clear nomenclature to describe all the intermediate stages of testing. The next stage beyond testing a single unit of code is subsystem testing. A subsystem test verifies that two or more units of code are interacting correctly to produce the desired result. In the simplest case, a subsystem test can be created simply by replacing mock objects with real objects and running unit tests on the top level module. In practise, this tends to not work as well as expected, because the original unit test data wasn&#039;t designed for a subsystem test, or because the nature of the test cases needs to be changed in order to fully test the subsystem. After all there is little point in simply repeating the unit test cases; the objective of a subsystem test should be to test boundary conditions and special cases that would be difficult to duplicate in unit tests.&lt;br /&gt;
&lt;br /&gt;
Once a subsystem has been tested, it can be integrated into a larger system, which is still a subset of the whole product. Tests can be written for larger and larger subsystems, but at each stage the complexity of the tests increases. At some point, the effort required to hand craft tests exceeds the benefits of running them. This is where integrated testing comes in.&lt;br /&gt;
&lt;br /&gt;
Integrated testing involves recording a user&#039;s interaction with the system into a script that can be replayed. The testing framework then compares the system&#039;s response with the expected response and passes or fails the test. The PHPUnit testing framework that we use has the ability to work with [http://seleniumhq.org/ Selenium], a browser based test automation tool. Writing a functional test using Selenium is documented [http://docs.joomla.org/Functional_Testing#Writing_Functional_Tests here].&lt;br /&gt;
&lt;br /&gt;
==== Test Objects ====&lt;br /&gt;
The purpose of unit tests is to isolate a module of code. A test that tests only one thing provides better information than a test that involves several object interactions. But how do we isolate an object from its dependencies? By writing stub classes. [http://xunitpatterns.com/Mocks,%20Fakes,%20Stubs%20and%20Dummies.html xUnit Patterns] defines a the hierarchy of dummy classes, ranging from simple to complex:&lt;br /&gt;
* Dummy - Defines attributes and methods of a dummy class (not particularly useful in PHP).&lt;br /&gt;
* Fake - Provides canned responses to method calls and fixed attribute values. Good for speed.&lt;br /&gt;
* Stub - Allows the test to define responses to method calls (return values, exceptions) to simulate the dependent object.&lt;br /&gt;
* Spy - A Fake or Stub that records method calls and parameters for later analysis.&lt;br /&gt;
* Mock - A Fake or Stub with a set of expectations -- method calls and parameters -- that are automatically verified for correctness.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests.&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk used to contain code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
The PHPUnit tests are available from &#039;&#039;&#039;/testing/trunk&#039;&#039;&#039;. Some new tests have been added, any remaining tests from the SimpleTest days are completely broken. See /testing/branches/old-simpletest if you need to run something from that suite.&lt;br /&gt;
&lt;br /&gt;
The unit tests are located in two places:&lt;br /&gt;
* /testing/trunk/1.5/unittest - these are tests for Joomla! 1.5 (/development/releases/1.5)&lt;br /&gt;
* /testing/trunk/1.6/unittest - there are tests for Joomla! 1.6 (/development/trunk)&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== The Unit Test Team ====&lt;br /&gt;
If you can commit to the Joomla code base, then you should consider yourself part of the unit test team!&lt;br /&gt;
&lt;br /&gt;
Writing tests concurrently with code (or even before) is a good way to not only save development time, but a great tool for defending against regressions. Writing tests early in the development cycle also helps identify and resolve design issues sooner, which reduces refactoring.&lt;br /&gt;
&lt;br /&gt;
If you want to get started on unit testing, get in touch with Alan Langford (instance) or Ray Tsai (mihu). Either of us will be happy to help out.&lt;br /&gt;
&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-Test.php, for example JObject-0000-class-Test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;br /&gt;
* The custom test runner is no longer needed. The current tests will run with the latest SVN version of PHPUnit 3.4. This code will eventually become PHPUnit 3.4.1.  Thanks to Sebastian Bergmann for his excellent work on an excellent project!&lt;br /&gt;
&lt;br /&gt;
==== Writing Unit Tests ====&lt;br /&gt;
At risk of stating the obvious, in the &amp;quot;purest&amp;quot; case the purpose of a unit test is to &#039;&#039;isolate a unit of code from its environment and to test the operation of that code&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This isolation is usually achieved by writing dummy classes that emulate the code unit&#039;s environment. These dummy objects can be passive, by simply simulating the environment, or they can be more active, keeping track of how they are being used by the test unit and reporting any variations from the expected behaviour. See [[Unit_Testing_Mock_Objects|Mock Objects in Joomla]] for a detailed example.&lt;br /&gt;
&lt;br /&gt;
An interesting aspect of writing tests is that they become &#039;&#039;de facto&#039;&#039; detailed technical specifications of the interfaces between units of code. The fact that these specifications can be verified in an automated way makes them a superb resource when refactoring code.&lt;br /&gt;
&lt;br /&gt;
The test code has a few templates designed to kick-start a test. They are:&lt;br /&gt;
&lt;br /&gt;
/unittest/sample-datatest-php.txt&lt;br /&gt;
/unittest/sample-simpletest.php.txt&lt;br /&gt;
&lt;br /&gt;
Here are some example tests: [[Unit_Testing_--_a_Simple_Example|Simple Example]], [[Unit_Testing_--_Data_Driven_Example|Data Driven Example]], [[Unit_Testing_--_Plugin_Example|Plugin Example]], [[Unit_Testing_--_UI_Example|UI Example]].&lt;br /&gt;
&lt;br /&gt;
==== Running Unit Tests ====&lt;br /&gt;
Test files follow the form class-sequence-type-Test.php, for example JObject-0000-class-Test.php. For tests that are not class based, the first element refers to the object being tested. An example of this is the e-mail cloaking plugin test, which is called emailcloak-0000-mode1-Test.php.&lt;br /&gt;
&lt;br /&gt;
Joomla unit tests use the standard PHPUnit test runner.  See http://www.phpunit.de for documentation.&lt;br /&gt;
&lt;br /&gt;
== How to Get it Running ==&lt;br /&gt;
&lt;br /&gt;
Before you start make sure you have installed PHPUnit and of course PHP (5!) properly...&lt;br /&gt;
&lt;br /&gt;
To get the unit tests to run on your Joomla! installation, perform the following steps:&lt;br /&gt;
* Create an instance of your Joomla! installation. Since you will be using SVN to check out the testing project, you don&#039;t want to check out the Joomla! with SVN. Instead, simply unpack a normal Joomla! archive. If you are using Eclipse, you can create a folder in your Eclipse workspace for the Joomla! installation, but don&#039;t create an Eclipse project yet.&lt;br /&gt;
* In the root checkout (or export) the latest version of the unit test code from SVN &#039;&#039;&amp;quot;/testing/trunk/1.5/unittest&amp;quot;&#039;&#039; or &#039;&#039;&amp;quot;/testing/trunk/1.6/unittest&amp;quot;&#039;&#039; to your installation base. This will create a &#039;&#039;&amp;quot;/unittest&amp;quot;&#039;&#039; sub-folder under your joomla installation. If you are using Eclipse, Import the project from the SVN and use the same folder in your Eclipse workspace you used above.&lt;br /&gt;
* From the command line, change to the unittest directory.&lt;br /&gt;
* Run the unit test from the command prompt using the following command: &amp;lt;code&amp;gt;phpunit tests&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The unit test will the run, and the results are rendered. You will see a series of dots for each passed test and other letters for failed tests. &lt;br /&gt;
&lt;br /&gt;
See http://www.phpunit.de/manual/current/en/textui.html for help using the --filter switch to run only certain tests.  There are also many other command line switches you can use to get results in various formats.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
The provided configurations should work out of the box. We have seen problems with it (currently the cause is unknown). If you get an error like below, the solution is pretty easy.&lt;br /&gt;
&lt;br /&gt;
 file=/var/www/unittest/runtests.php&lt;br /&gt;
 posn=17&lt;br /&gt;
 base=runtests.php&lt;br /&gt;
 /var/www&lt;br /&gt;
  JPATH_BASE does not point to a valid Joomla! installation:&lt;br /&gt;
 JPATH_BASE = /var/www&lt;br /&gt;
  Please modify your copy of &amp;quot;TestConfiguration.php&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Modify the &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file and change the definition of the JPATH_BASE so it points to the path of you Joomla! installation, in the example below the Joomla! installation is installed at &amp;quot;&#039;&#039;/var/www/update&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 define(&#039;JPATH_BASE&#039;, &#039;/var/www/update&#039;);&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&#039;&#039;&#039;Why can&#039;t I use &amp;quot;phpunit &#039;&#039;testname.php&#039;&#039;&amp;quot; to run my tests?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The test facility has to do some work to be able to load the &amp;quot;Joomla!&amp;quot; framework and to be able to inject mock classes. It&#039;s difficult to do this from the PHPUnit test runner, so we built our own. Also, the Joomla test runner has specific options designed to make it easy to select specific tests. Over time we will add more functionality to the test runner so it has many of the capabilities of the phpunit command.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[http://www.phpunit.de/manual/current/en/ PHPUnit Manual]&lt;br /&gt;
&lt;br /&gt;
[[Category:Bug Squad]]&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Testing]]&lt;br /&gt;
[[Category:Automated Testing]]&lt;/div&gt;</summary>
		<author><name>Paladin</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Talk:Unit_Testing&amp;diff=31081</id>
		<title>Talk:Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Talk:Unit_Testing&amp;diff=31081"/>
		<updated>2010-09-25T15:59:09Z</updated>

		<summary type="html">&lt;p&gt;Paladin: Is this still relevant?&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The information in this page is completely out of date, but another question is:&lt;br /&gt;
&lt;br /&gt;
Is it relevant, given some of the other documentation on j1.6 unit testing?&lt;br /&gt;
&lt;br /&gt;
If it&#039;s still judged relevant, I&#039;ll be happy to tackle editing the page, but I don&#039;t want to waste my time if the page is just going to be deleted in the end, in favor of other pages.&lt;/div&gt;</summary>
		<author><name>Paladin</name></author>
	</entry>
</feed>