diff --git a/appendices/migration70/incompatible.xml b/appendices/migration70/incompatible.xml index c0257a82e3..b2adfd91bc 100644 --- a/appendices/migration70/incompatible.xml +++ b/appendices/migration70/incompatible.xml @@ -2,594 +2,11 @@ - Backward Incompatible Changes - - Although most existing PHP 5 code should work without changes, please take - note of some backward incompatible changes: - + Backward incompatible changes - - Changes to variable handling - - - PHP 7 now uses an abstract syntax tree when parsing source files. This has - permitted many improvements to the language which were previously - impossible due to limitations in the parser used in earlier versions of - PHP, but has resulted in the removal of a few special cases for consistency - reasons, which has resulted in backward compatibility breaks. These cases - are detailed in this section. - - - - - Changes to the handling of indirect variables, properties, and methods - - - - Indirect access to variables, properties, and methods will now be - evaluated strictly in left-to-right order, as opposed to the previous mix - of special cases. The table below shows how the order of evaluaiton has - changed. - - - - - Old and new evaluation of indirect expressions - - - - Expression - PHP 5 interpretation - PHP 7 interpretation - - - - - - $$foo['bar']['baz'] - - - ${$foo['bar']['baz']} - - - ($$foo)['bar']['baz'] - - - - - $foo->$bar['baz'] - - - $foo->{$bar['baz']} - - - ($foo->$bar)['baz'] - - - - - $foo->$bar['baz']() - - - $foo->{$bar['baz']}() - - - ($foo->$bar)['baz']() - - - - - Foo::$bar['baz']() - - - Foo::{$bar['baz']}() - - - (Foo::$bar)['baz']() - - - - -
-
- - - Code that used the old right-to-left evaluation order must be rewritten to - explicitly use that evaluation order with curly braces (see the above - middle column). This will make the code both forwards compatible with PHP - 7.x and backwards compatible with PHP 5.x. - -
- - - Changes to <function>list</function> handling - - - - <function>list</function> no longer assigns variables in reverse order - - - - list will now assign values to variables in the - order they are defined, rather than reverse order. In general, this only - affects the case where list is being used in - conjunction with the array [] operator, as shown below: - - - - - -]]> - - &example.outputs.5; - - - int(3) - [1]=> - int(2) - [2]=> - int(1) -} -]]> - - &example.outputs.7; - - - int(1) - [1]=> - int(2) - [2]=> - int(3) -} -]]> - - - - - In general, it is recommended not to rely on the order in which - list assignments occur, as this is an implementation - detail that may change again in the future. - - - - - Empty <function>list</function> assignments have been removed - - - list constructs can no longer be empty, or contain - empty variables. The following are no longer allowed: - - - - - -]]> - - - - - - <function>list</function> cannot unpack <type>string</type>s - - - list can no longer unpack string - variables. str_split should be used instead. - - - - - - - Array ordering when elements are automatically created during by reference - assignments has changed - - - - The order of the elements in an array has changed when those elements have - been automatically created by referencing them in a by reference - assignment. For example: - - - - - -]]> - - &example.outputs.5; - - - &int(1) - ["a"]=> - &int(1) -} -]]> - - &example.outputs.7; - - - &int(1) - ["b"]=> - &int(1) -} -]]> - - - - - - &global; only accepts simple variables - - - Variable variables can - no longer be used with the &global; keyword. The curly brace syntax can be - used to emulate the previous behaviour if required: - - - - - bar; - - // Valid in PHP 5 and 7. - global ${$foo->bar}; - } - ?> - ]]> - - - - - As a general principle, using anything other than a bare variable with - &global; is discouraged. - - - - - - Parentheses around function parameters no longer affect behaviour - - - - In PHP 5, using redundant parentheses around a function parameter could - quiet strict standards warnings when the function parameter was passed by - reference. The warning will now always be issued. - - - - - - ]]> - - &example.outputs; - - - - - -
- - - Changes to &foreach; - - - Minor changes have been made to the behaviour of the &foreach; control - structure, primarily around the handling of the internal array pointer and - modification of the array being iterated over. - - - - &foreach; no longer changes the internal array pointer - - - Prior to PHP 7, the internal array pointer was modified while an array was - being iterated over with &foreach;. This is no longer the case, as shown - in the following example: - - - - - -]]> - - &example.outputs.5; - - - - &example.outputs.7; - - - - - - - - &foreach; by-value operates on a copy of the array - - - When used in the default by-value mode, &foreach; will now operate on a - copy of the array being iterated rather than the array itself. This means - that changes to the array made during iteration will not affect the values - that are iterated. - - - - - &foreach; by-reference has improved iteration behaviour - - - When iterating by-reference, &foreach; will now do a better job of - tracking changes to the array made during iteration. For example, - appending to an array while iterating will now result in the appended - values being iterated over as well: - - - - - -]]> - - &example.outputs.5; - - - - &example.outputs.7; - - - - - - - - Iteration of non-<classname>Traversable</classname> objects - - - Iterating over a non-Traversable object will now - have the same behaviour as iterating over by-reference arrays. This - results in the - improved behaviour when modifying an array during iteration - also being applied when properties are added to or removed from the - object. - - - - - - ASP and script PHP tags removed - - - Support for using ASP and script tags to delimit PHP code has been removed. - The affected tags are: - - - - Removed ASP and script tags - - - - Opening tag - Closing tag - - - - - <% - %> - - - <%= - %> - - - <script language="php"> - </script> - - - -
-
- - - Functions can't have more than one parameter with the same name - - - It is no longer possible to define two function parameters with the same name. - For example, the following method will trigger E_COMPILE_ERROR: - - - - - -]]> - - - - - - $HTTP_RAW_POST_DATA removal - - - $HTTP_RAW_POST_DATA is no longer available. Use the - php://input stream instead. - - - - - Drop #-style comments in INI files - - - Support for #-style comments in INI files has been dropped. ; - is the only possible comment indicator now. - - - - - Invalid Octal Literals - - - Previously, octal literals that contained invalid numbers were silently - truncated (0128 was taken as 012). - Now, an invalid octal literal will cause a parse error. - - - - - Removed functions - - - Following functions have been removed from PHP: - - - - - - call_user_method and call_user_method_array - - - - - mcrypt_generic_end alias in favor of mcrypt_generic_deinit - - - - - deprecated mcrypt_ecb, - mcrypt_cbc, mcrypt_cfb and - mcrypt_ofb in favor of mcrypt_decrypt - with an MCRYPT_MODE_* - - - - - deprecated aliases datefmt_set_timezone_id and - IntlDateFormatter::setTimeZoneID in favor of - datefmt_set_timezone or IntlDateFormatter::setTimeZone - - - - - set_magic_quotes_runtime and its alias magic_quotes_runtime - - - - - set_socket_blocking in favor of its alias stream_set_blocking - - - - - dl from fpm-fcgi - - - - - imagepsbbox, imagepsencodefont, - imagepsextendedfont, imagepsfreefont, - imagepsloadfont, imagepsslantfont, - imagepstext due to T1Lib support removal - - - - - - - Removed INI directives - - - Following &php.ini; directives have been removed from PHP: - - - - - - always_populate_raw_post_data - - - - - asp_tags - - - - - xsl.security_prefs - use XsltProcessor::setSecurityPrefs - instead - - - - + &appendices.migration70.incompatible.variable-handling; + &appendices.migration70.incompatible.foreach; + &appendices.migration70.incompatible.other;
+ + + Changes to &foreach; + + + Minor changes have been made to the behaviour of the &foreach; control + structure, primarily around the handling of the internal array pointer and + modification of the array being iterated over. + + + + &foreach; no longer changes the internal array pointer + + + Prior to PHP 7, the internal array pointer was modified while an array was + being iterated over with &foreach;. This is no longer the case, as shown + in the following example: + + + + + +]]> + + &example.outputs.5; + + + + &example.outputs.7; + + + + + + + + &foreach; by-value operates on a copy of the array + + + When used in the default by-value mode, &foreach; will now operate on a + copy of the array being iterated rather than the array itself. This means + that changes to the array made during iteration will not affect the values + that are iterated. + + + + + &foreach; by-reference has improved iteration behaviour + + + When iterating by-reference, &foreach; will now do a better job of + tracking changes to the array made during iteration. For example, + appending to an array while iterating will now result in the appended + values being iterated over as well: + + + + + +]]> + + &example.outputs.5; + + + + &example.outputs.7; + + + + + + + + Iteration of non-<classname>Traversable</classname> objects + + + Iterating over a non-Traversable object will now + have the same behaviour as iterating over by-reference arrays. This + results in the + improved behaviour when modifying an array during iteration + also being applied when properties are added to or removed from the + object. + + + + + diff --git a/appendices/migration70/incompatible/other.xml b/appendices/migration70/incompatible/other.xml new file mode 100644 index 0000000000..f3f776a307 --- /dev/null +++ b/appendices/migration70/incompatible/other.xml @@ -0,0 +1,197 @@ + + + + + Other backward incompatible changes + + + ASP and script PHP tags removed + + + Support for using ASP and script tags to delimit PHP code has been removed. + The affected tags are: + + + + Removed ASP and script tags + + + + Opening tag + Closing tag + + + + + <% + %> + + + <%= + %> + + + <script language="php"> + </script> + + + +
+
+ + + Functions can't have more than one parameter with the same name + + + It is no longer possible to define two function parameters with the same name. + For example, the following method will trigger E_COMPILE_ERROR: + + + + + +]]> + + + + + + $HTTP_RAW_POST_DATA removal + + + $HTTP_RAW_POST_DATA is no longer available. Use the + php://input stream instead. + + + + + Drop #-style comments in INI files + + + Support for #-style comments in INI files has been dropped. ; + is the only possible comment indicator now. + + + + + Invalid Octal Literals + + + Previously, octal literals that contained invalid numbers were silently + truncated (0128 was taken as 012). + Now, an invalid octal literal will cause a parse error. + + + + + Removed functions + + + Following functions have been removed from PHP: + + + + + + call_user_method and call_user_method_array + + + + + mcrypt_generic_end alias in favor of mcrypt_generic_deinit + + + + + deprecated mcrypt_ecb, + mcrypt_cbc, mcrypt_cfb and + mcrypt_ofb in favor of mcrypt_decrypt + with an MCRYPT_MODE_* + + + + + deprecated aliases datefmt_set_timezone_id and + IntlDateFormatter::setTimeZoneID in favor of + datefmt_set_timezone or IntlDateFormatter::setTimeZone + + + + + set_magic_quotes_runtime and its alias magic_quotes_runtime + + + + + set_socket_blocking in favor of its alias stream_set_blocking + + + + + dl from fpm-fcgi + + + + + imagepsbbox, imagepsencodefont, + imagepsextendedfont, imagepsfreefont, + imagepsloadfont, imagepsslantfont, + imagepstext due to T1Lib support removal + + + + + + + Removed INI directives + + + Following &php.ini; directives have been removed from PHP: + + + + + + always_populate_raw_post_data + + + + + asp_tags + + + + + xsl.security_prefs - use XsltProcessor::setSecurityPrefs + instead + + + + +
+ + diff --git a/appendices/migration70/incompatible/variable-handling.xml b/appendices/migration70/incompatible/variable-handling.xml new file mode 100644 index 0000000000..030baf9aa8 --- /dev/null +++ b/appendices/migration70/incompatible/variable-handling.xml @@ -0,0 +1,325 @@ + + + + + Changes to variable handling + + + PHP 7 now uses an abstract syntax tree when parsing source files. This has + permitted many improvements to the language which were previously + impossible due to limitations in the parser used in earlier versions of + PHP, but has resulted in the removal of a few special cases for consistency + reasons, which has resulted in backward compatibility breaks. These cases + are detailed in this section. + + + + + Changes to the handling of indirect variables, properties, and methods + + + + Indirect access to variables, properties, and methods will now be + evaluated strictly in left-to-right order, as opposed to the previous mix + of special cases. The table below shows how the order of evaluaiton has + changed. + + + + + Old and new evaluation of indirect expressions + + + + Expression + PHP 5 interpretation + PHP 7 interpretation + + + + + + $$foo['bar']['baz'] + + + ${$foo['bar']['baz']} + + + ($$foo)['bar']['baz'] + + + + + $foo->$bar['baz'] + + + $foo->{$bar['baz']} + + + ($foo->$bar)['baz'] + + + + + $foo->$bar['baz']() + + + $foo->{$bar['baz']}() + + + ($foo->$bar)['baz']() + + + + + Foo::$bar['baz']() + + + Foo::{$bar['baz']}() + + + (Foo::$bar)['baz']() + + + + +
+
+ + + Code that used the old right-to-left evaluation order must be rewritten to + explicitly use that evaluation order with curly braces (see the above + middle column). This will make the code both forwards compatible with PHP + 7.x and backwards compatible with PHP 5.x. + +
+ + + Changes to <function>list</function> handling + + + + <function>list</function> no longer assigns variables in reverse order + + + + list will now assign values to variables in the + order they are defined, rather than reverse order. In general, this only + affects the case where list is being used in + conjunction with the array [] operator, as shown below: + + + + + +]]> + + &example.outputs.5; + + + int(3) + [1]=> + int(2) + [2]=> + int(1) +} +]]> + + &example.outputs.7; + + + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +]]> + + + + + In general, it is recommended not to rely on the order in which + list assignments occur, as this is an implementation + detail that may change again in the future. + + + + + Empty <function>list</function> assignments have been removed + + + list constructs can no longer be empty, or contain + empty variables. The following are no longer allowed: + + + + + +]]> + + + + + + <function>list</function> cannot unpack <type>string</type>s + + + list can no longer unpack string + variables. str_split should be used instead. + + + + + + + Array ordering when elements are automatically created during by reference + assignments has changed + + + + The order of the elements in an array has changed when those elements have + been automatically created by referencing them in a by reference + assignment. For example: + + + + + +]]> + + &example.outputs.5; + + + &int(1) + ["a"]=> + &int(1) +} +]]> + + &example.outputs.7; + + + &int(1) + ["b"]=> + &int(1) +} +]]> + + + + + + &global; only accepts simple variables + + + Variable variables can + no longer be used with the &global; keyword. The curly brace syntax can be + used to emulate the previous behaviour if required: + + + + +bar; + + // Valid in PHP 5 and 7. + global ${$foo->bar}; +} +?> +]]> + + + + + As a general principle, using anything other than a bare variable with + &global; is discouraged. + + + + + + Parentheses around function parameters no longer affect behaviour + + + + In PHP 5, using redundant parentheses around a function parameter could + quiet strict standards warnings when the function parameter was passed by + reference. The warning will now always be issued. + + + + + +]]> + + &example.outputs; + + + + + +
+ +