xarxaprod-wp-theme/vendor/wp-coding-standards/wpcs/WordPress/Docs/Classes/ClassInstantiationStandard.xml

54 lines
1.5 KiB
XML
Raw Normal View History

2024-01-09 16:13:20 +01:00
<documentation title="Class Instantiation">
<standard>
<![CDATA[
Instantiation of an object should be done with parenthesis.
]]>
</standard>
<code_comparison>
<code title="Valid: with parenthesis.">
<![CDATA[
$a = new Foobar<em>()</em>;
]]>
</code>
<code title="Invalid: without parenthesis.">
<![CDATA[
$a = new Foobar;
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
Don't use spaces between the object name and the open parenthesis when instantiating new object.
]]>
</standard>
<code_comparison>
<code title="Valid: no whitespace between the object name and the parenthesis.">
<![CDATA[
$a = new Foobar();
]]>
</code>
<code title="Invalid: a space between the object name and the parenthesis.">
<![CDATA[
$a = new Foobar<em> </em>();
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
Assigning the return value of "new" by reference was deprecated in PHP 5.3 and removed in PHP 7.0. New by reference should no longer be used.
]]>
</standard>
<code_comparison>
<code title="Valid: object instantiation without reference.">
<![CDATA[
$a = <em>new</em> Foobar();
]]>
</code>
<code title="Invalid: object instantiation by reference.">
<![CDATA[
$a = <em>& new</em> Foobar();
]]>
</code>
</code_comparison>
</documentation>