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 1 commit
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 object name and open parenthesis when instantiating new object.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Don't use spaces between object name and open parenthesis when instantiating new object.
Don't use spaces between the object name and the open parenthesis when instantiating new object.

]]>
</standard>
<code_comparison>
<code title="Valid: no spaces between object name and parenthesis.">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<code title="Valid: no spaces between object name and parenthesis.">
<code title="Valid: no whitespace between the object name and the parenthesis.">

<![CDATA[
$a = new Foobar();
]]>
</code>
<code title="Invalid: spaces between object name and parenthesis.">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<code title="Invalid: spaces between object name and parenthesis.">
<code title="Invalid: a space between the object name and the parenthesis.">

<![CDATA[
$a = new Foobar<em> </em>();
]]>
</code>
</code_comparison>
<standard>
<![CDATA[
Object instantiation by reference is not supported by PHP anymore.
FORTE-WP marked this conversation as resolved.
Show resolved Hide resolved
]]>
</standard>
<code_comparison>
<code title="Valid: object instantiation without reference.">
<![CDATA[
$a = new Foobar();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$a = new Foobar();
$a = <em>new</em> Foobar();

]]>
</code>
<code title="Invalid: object instantiation by reference.">
<![CDATA[
$a = <em>&</em> new Foobar();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$a = <em>&</em> new Foobar();
$a = <em>& new</em> Foobar();

]]>
</code>
</code_comparison>
</documentation>