1<documentation title="Class Declaration"> 2 <standard> 3 <![CDATA[ 4 Each class must be in a file by itself and must be under a namespace (a top-level vendor name). 5 ]]> 6 </standard> 7 <code_comparison> 8 <code title="Valid: One class in a file."> 9 <![CDATA[ 10<?php 11namespace Foo; 12 13<em>class Bar</em> { 14} 15 ]]> 16 </code> 17 <code title="Invalid: Multiple classes in a single file."> 18 <![CDATA[ 19<?php 20namespace Foo; 21 22<em>class Bar</em> { 23} 24 25<em>class Baz</em> { 26} 27 ]]> 28 </code> 29 </code_comparison> 30 <code_comparison> 31 <code title="Valid: A vendor-level namespace is used."> 32 <![CDATA[ 33<?php 34<em>namespace Foo;</em> 35 36class Bar { 37} 38 ]]> 39 </code> 40 <code title="Invalid: No namespace used in file."> 41 <![CDATA[ 42<?php 43class Bar { 44} 45 ]]> 46 </code> 47 </code_comparison> 48</documentation> 49