~ubuntu-branches/ubuntu/saucy/php-codesniffer/saucy

« back to all changes in this revision

Viewing changes to PHP_CodeSniffer-1.1.0/CodeSniffer/Standards/PEAR/Docs/Files/IncludingFileStandard.xml

  • Committer: Bazaar Package Importer
  • Author(s): Jack Bates
  • Date: 2008-10-01 17:39:43 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20081001173943-2dy06n1e8zwyw1o8
Tags: 1.1.0-1
* New upstream release
* Acknowledge NMU, thanks Jan

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<documentation title="Including Code">
 
2
    <standard>
 
3
    <![CDATA[
 
4
    Anywhere you are unconditionally including a class file, use <em>require_once</em>. Anywhere you are conditionally including a class file (for example, factory methods), use <em>include_once</em>. Either of these will ensure that class files are included only once. They share the same file list, so you don't need to worry about mixing them - a file included with <em>require_once</em> will not be included again by <em>include_once</em>.
 
5
    ]]>
 
6
    </standard>
 
7
    <standard>
 
8
    <![CDATA[
 
9
    Note that <em>include_once</em> and <em>require_once</em> are statements, not functions. Parentheses should not surround the subject filename.
 
10
    ]]>
 
11
    </standard>
 
12
    <code_comparison>
 
13
        <code title="Valid: used as statement">
 
14
        <![CDATA[
 
15
require_once 'PHP/CodeSniffer.php';
 
16
        ]]>
 
17
        </code>
 
18
        <code title="Invalid: used as function">
 
19
        <![CDATA[
 
20
require_once<em>(</em>'PHP/CodeSniffer.php'<em>)</em>;
 
21
        ]]>
 
22
        </code>
 
23
    </code_comparison>
 
24
</documentation>