-
-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
47 additions
and
9 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
PHPCompatibility/Docs/Variables/NewUniformVariableSyntaxStandard.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0"?> | ||
<documentation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://phpcsstandards.github.io/PHPCSDevTools/phpcsdocs.xsd" | ||
title="New Uniform Variable Syntax" | ||
> | ||
<standard> | ||
<![CDATA[ | ||
As of PHP 7.0, indirect access to variables, properties and methods will now be evaluated strictly in left-to-right order. | ||
Prior to PHP 7.0, certain expressions would be interpreted using a right-to-left evaluation order, which means that the result of these expressions will be different in PHP 5.x versus PHP 7.x. | ||
The evaluation order can be made explicit and enforced to be the same PHP cross-version by using curly braces to clarify how the expression should be evaluated. | ||
]]> | ||
</standard> | ||
<code_comparison> | ||
<code title="Cross-version compatible: Using curly braces to explicitly enforce a specific evaluation order."> | ||
<![CDATA[ | ||
echo $<em>{</em>$var['key1']['key2']<em>}</em>; | ||
echo $obj-><em>{</em>$var['key']<em>}</em>; | ||
echo $obj-><em>{</em>$var['key']<em>}</em>(); | ||
echo MyClass::<em>{</em>$var['key']<em>}</em>(); | ||
]]> | ||
</code> | ||
<code title="Cross-version INcompatible: Without curly braces the interpretation of these indirect accesses to variables, properties and methods will behave different in PHP <= 5.6 versus PHP 7.0+."> | ||
<![CDATA[ | ||
echo <em>$$var['key1']['key2']</em>; | ||
echo <em>$obj->$var['key']</em>; | ||
echo <em>$obj->$var['key']()</em>; | ||
echo <em>MyClass::$var['key']()</em>; | ||
]]> | ||
</code> | ||
</code_comparison> | ||
</documentation> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,7 +109,9 @@ public function dataNoFalsePositives() | |
[27], | ||
[28], | ||
[42], | ||
[49], | ||
[47], | ||
[48], | ||
[51], | ||
]; | ||
} | ||
|
||
|