Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation Class Instantiation #1801

Merged
merged 2 commits into from
Sep 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>