Skip to content

Commit

Permalink
Merge pull request #1801 from FORTE-WP/temp1
Browse files Browse the repository at this point in the history
Documentation Class Instantiation
  • Loading branch information
jrfnl authored Sep 28, 2019
2 parents 484335b + aecdaa7 commit 0d2f984
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions WordPress/Docs/Classes/ClassInstantiationStandard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<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>

0 comments on commit 0d2f984

Please sign in to comment.