You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

680 lines
22 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
12 years ago
12 years ago
11 years ago
11 years ago
17 years ago
12 years ago
11 years ago
11 years ago
11 years ago
  1. $Id$
  2. PHP X.Y UPGRADE NOTES
  3. 1. Backward Incompatible Changes
  4. 2. New Features
  5. 3. Changes in SAPI modules
  6. 4. Deprecated Functionality
  7. 5. Changed Functions
  8. 6. New Functions
  9. 7. New Classes and Interfaces
  10. 8. Removed Extensions and SAPIs
  11. 9. Other Changes to Extensions
  12. 10. New Global Constants
  13. 11. Changes to INI File Handling
  14. 12. Windows Support
  15. 13. Other Changes
  16. ========================================
  17. 1. Backward Incompatible Changes
  18. ========================================
  19. Language changes
  20. ================
  21. Changes to variable handling
  22. ----------------------------
  23. * Indirect variable, property and method references are now interpreted with
  24. left-to-right semantics. Some examples:
  25. $$foo['bar']['baz'] // interpreted as ($$foo)['bar']['baz']
  26. $foo->$bar['baz'] // interpreted as ($foo->$bar)['baz']
  27. $foo->$bar['baz']() // interpreted as ($foo->$bar)['baz']()
  28. Foo::$bar['baz']() // interpreted as (Foo::$bar)['baz']()
  29. To restore the previous behavior add explicit curly braces:
  30. ${$foo['bar']['baz']}
  31. $foo->{$bar['baz']}
  32. $foo->{$bar['baz']}()
  33. Foo::{$bar['baz']}()
  34. * The global keyword now only accepts simple variables. Instead of
  35. global $$foo->bar;
  36. it is now required to write the following:
  37. global ${$foo->bar};
  38. * Parentheses around variables or function calls no longer have any influence
  39. on behavior. For example the following code, where the result of a function
  40. call is passed to a by-reference function
  41. function getArray() { return [1, 2, 3]; }
  42. $last = array_pop(getArray());
  43. // Strict Standards: Only variables should be passed by reference
  44. $last = array_pop((getArray()));
  45. // Strict Standards: Only variables should be passed by reference
  46. will now throw a strict standards error irregardless of whether parentheses
  47. are used. Previously no notice was generated in the second case.
  48. * Array elements or object properties that are automatically created during
  49. by-reference assignments will now result in a different order. For example
  50. $array = [];
  51. $array["a"] =& $array["b"];
  52. $array["b"] = 1;
  53. var_dump($array);
  54. now results in the array ["a" => 1, "b" => 1], while previously the result
  55. was ["b" => 1, "a" => 1];
  56. Relevant RFCs:
  57. * https://wiki.php.net/rfc/uniform_variable_syntax
  58. * https://wiki.php.net/rfc/abstract_syntax_tree
  59. Changes to list()
  60. -----------------
  61. * list() will no longer assign variables in reverse order. For example
  62. list($array[], $array[], $array[]) = [1, 2, 3];
  63. var_dump($array);
  64. will now result in $array == [1, 2, 3] rather than [3, 2, 1]. Note that only
  65. the **order** of the assignments changed, but the assigned values stay the
  66. same. E.g. a normal usage like
  67. list($a, $b, $c) = [1, 2, 3];
  68. // $a = 1; $b = 2; $c = 3;
  69. will retain its current behavior.
  70. * Empty list() assignments are no longer allowed. As such all of the following
  71. are invalid:
  72. list() = $a;
  73. list(,,) = $a;
  74. list($x, list(), $y) = $a;
  75. * list() no longer supports unpacking strings (while previously this was only
  76. supported in some cases). The code
  77. $string = "xy";
  78. list($x, $y) = $string;
  79. will now result in $x == null and $y == null (without notices) instead of
  80. $x == "x" and $y == "y". Furthermore list() is now always guaranteed to
  81. work with objects implementing ArrayAccess, e.g.
  82. list($a, $b) = (object) new ArrayObject([0, 1]);
  83. will now result in $a == 0 and $b == 1. Previously both $a and $b were null.
  84. Relevant RFCs:
  85. * https://wiki.php.net/rfc/abstract_syntax_tree#changes_to_list
  86. * https://wiki.php.net/rfc/fix_list_behavior_inconsistency
  87. Changes to foreach
  88. ------------------
  89. * Iteration with foreach() no longer has any effect on the internal array
  90. pointer, which can be accessed through the current()/next()/etc family of
  91. functions. For example
  92. $array = [0, 1, 2];
  93. foreach ($array as &$val) {
  94. var_dump(current($array));
  95. }
  96. will now print the value int(0) three times. Previously the output was int(1),
  97. int(2) and bool(false).
  98. * When iterating arrays by-value, foreach will now always operate on a copy of
  99. the array, as such changes to the array during iteration will not influence
  100. iteration behavior. For example
  101. $array = [0, 1, 2];
  102. $ref =& $array; // Necessary to trigger the old behavior
  103. foreach ($array as $val) {
  104. var_dump($val);
  105. unset($array[1]);
  106. }
  107. will now print all three elements (0 1 2), while previously the second element
  108. 1 was skipped (0 2).
  109. * When iterating arrays by-reference, modifications to the array will continue
  110. to influence the iteration. However PHP will now do a better job of
  111. maintaining a correct position in a number of cases. E.g. appending to an
  112. array during by-reference iteration
  113. $array = [0];
  114. foreach ($array as &$val) {
  115. var_dump($val);
  116. $array[1] = 1;
  117. }
  118. will now iterate over the appended element as well. As such the output of this
  119. example will now be "int(0) int(1)", while previously it was only "int(0)".
  120. * Iteration of plain (non-Traversable) objects by-value or by-reference will
  121. behave like by-reference iteration of arrays. This matches the previous
  122. behavior apart from the more accurate position management mentioned in the
  123. previous point.
  124. * Iteration of Traversable objects remains unchanged.
  125. Relevant RFC: https://wiki.php.net/rfc/php7_foreach
  126. Changes to parameter handling
  127. -----------------------------
  128. * It is no longer possible to define two function parameters with the same name.
  129. For example, the following method will trigger a compile-time error:
  130. public function foo($a, $b, $unused, $unused) {
  131. // ...
  132. }
  133. Code like this should be changed to use distinct parameter names, for example:
  134. public function foo($a, $b, $unused1, $unused2) {
  135. // ...
  136. }
  137. * The func_get_arg() and func_get_args() functions will no longer return the
  138. original value that was passed to a parameter and will instead provide the
  139. current value (which might have been modified). For example
  140. function foo($x) {
  141. $x++;
  142. var_dump(func_get_arg(0));
  143. }
  144. foo(1);
  145. will now print "2" instead of "1". This code should be changed to either
  146. perform modifications only after calling func_get_arg(s)
  147. function foo($x) {
  148. var_dump(func_get_arg(0));
  149. $x++;
  150. }
  151. or avoid modifying the parameters altogether:
  152. function foo($x) {
  153. $newX = $x + 1;
  154. var_dump(func_get_arg(0));
  155. }
  156. * Similarly exception backtraces will no longer display the original value that
  157. was passed to a function and show the modified value instead. For example
  158. function foo($x) {
  159. $x = 42;
  160. throw new Exception;
  161. }
  162. foo("string");
  163. will now result in the stack trace
  164. Stack trace:
  165. #0 file.php(4): foo(42)
  166. #1 {main}
  167. while previously it was:
  168. Stack trace:
  169. #0 file.php(4): foo('string')
  170. #1 {main}
  171. While this should not impact runtime behavior of your code, it is worthwhile
  172. to be aware of this difference for debugging purposes.
  173. The same limitation also applies to debug_backtrace() and other functions
  174. inspecting function arguments.
  175. Relevant RFC: https://wiki.php.net/phpng
  176. Changes to integer handling
  177. ---------------------------
  178. * Invalid octal literals (containing digits larger than 7) now produce compile
  179. errors. For example, the following is no longer valid:
  180. $i = 0781; // 8 is not a valid octal digit!
  181. Previously the invalid digits (and any following valid digits) were simply
  182. ignored. As such $i previously held the value 7, because the last two digits
  183. were silently discarded.
  184. * Bitwise shifts by negative numbers will now throw a warning and return false:
  185. var_dump(1 >> -1); // bool(false)
  186. // Warning: Bit shift by negative number
  187. * Left bitwise shifts by a number of bits beyond the bit width of an integer
  188. will always result in 0:
  189. var_dump(1 << 64); // int(0)
  190. Previously the behavior of this code was dependent on the used CPU
  191. architecture. For example on x86 (including x86-64) the result was int(1),
  192. because the shift operand was wrapped.
  193. * Similarly right bitwise shifts by a number of bits beyond the bit width of an
  194. integer will always result in 0 or -1 (depending on sign):
  195. var_dump(1 >> 64); // int(0)
  196. var_dump(-1 >> 64); // int(-1)
  197. Relevant RFC: https://wiki.php.net/rfc/integer_semantics
  198. Changes to string handling
  199. --------------------------
  200. * Strings that contain hexadecimal numbers are no longer considered to be
  201. numeric and don't receive special treatment anymore. Some examples of the
  202. new behavior:
  203. var_dump("0x123" == "291"); // bool(false) (previously true)
  204. var_dump(is_numeric("0x123")); // bool(false) (previously true)
  205. var_dump("0xe" + "0x1"); // int(0) (previously 16)
  206. var_dump(substr("foo", "0x1")); // string(3) "foo" (previously "oo")
  207. // Notice: A non well formed numeric value encountered
  208. filter_var() can be used to check if a string contains a hexadecimal number
  209. or convert such a string into an integer:
  210. $str = "0xffff";
  211. $int = filter_var($str, FILTER_VALIDATE_INT, FILTER_FLAG_ALLOW_HEX);
  212. if (false === $int) {
  213. throw new Exception("Invalid integer!");
  214. }
  215. var_dump($num); // int(65535)
  216. * Due to the addition of the Unicode Codepoint Escape Syntax for double-quoted
  217. strings and heredocs, "\u{" followed by an invalid sequence will now result in
  218. an error:
  219. $str = "\u{xyz}"; // Fatal error: Invalid UTF-8 codepoint escape sequence
  220. To avoid this the leading backslash should be escaped:
  221. $str = "\\u{xyz}"; // Works fine
  222. However, "\u" without a following { is unaffected. As such the following code
  223. won't error and will work the same as before:
  224. $str = "\u202e"; // Works fine
  225. Relevant RFCs:
  226. * https://wiki.php.net/rfc/remove_hex_support_in_numeric_strings
  227. * https://wiki.php.net/rfc/unicode_escape
  228. Changes to error handling
  229. -------------------------
  230. * The new base class of the exception hierarchy is BaseException, from which
  231. Exception extends. Typehints in exception handling code may need to be changed
  232. to account for this.
  233. * Some fatal errors and recoverable fatal errors now throw an EngineException
  234. instead. As EngineException extends BaseException but not Exception, these
  235. exceptions will not caught by existing try/catch blocks.
  236. For the recoverable fatal errors which have been converted into an exception,
  237. it is no longer possible to silently ignore the error from an error handler.
  238. In particular, it is no longer possible to ignore typehint failures.
  239. * Parser errors now generate a ParseException (extends BaseException). Error
  240. handling for eval()s on potentially invalid code should be changed to catch
  241. ParseException in addition to the previous return value / error_get_last()
  242. based handling.
  243. * Constructors of internal classes will now always throw an exception on
  244. failure. Previously some constructors returned NULL or an unusable object.
  245. * The error level of some E_STRICT notices has been changed.
  246. Relevant RFCs:
  247. * https://wiki.php.net/rfc/engine_exceptions_for_php7
  248. * https://wiki.php.net/rfc/internal_constructor_behaviour
  249. * https://wiki.php.net/rfc/reclassify_e_strict
  250. Other language changes
  251. ----------------------
  252. * Removed support for static calls to non-static calls form an incompatible
  253. $this context. In this case $this will not be defined, but the call will be
  254. allowed with a deprecation notice. An example:
  255. class A {
  256. public function test() { var_dump($this); }
  257. }
  258. // Note: Does NOT extend A
  259. class B {
  260. public function callNonStaticMethodOfA() { A::test(); }
  261. }
  262. (new B)->callNonStaticMethodOfA();
  263. // Deprecated: Non-static method A::test() should not be called statically
  264. // Notice: Undefined variable $this
  265. NULL
  266. Note that this only applies to calls from an incompatible context. If class B
  267. extended from A the call would be allowed without any notices.
  268. * It is no longer possible to use the following class, interface and trait names
  269. (case-insensitive):
  270. bool
  271. int
  272. float
  273. string
  274. null
  275. false
  276. true
  277. This applies to class/interface/trait declarations, class_alias() and use
  278. statements.
  279. Furthermore the following class, interface and trait names are now reserved
  280. for future use, but do not yet throw an error when used:
  281. resource
  282. object
  283. mixed
  284. numeric
  285. * The yield language construct no longer requires parentheses when used in an
  286. expression context. It is now a right-associative operator with precedence
  287. between the "print" and "=>" operators. This can result in different behavior
  288. in some cases, for example:
  289. echo yield -1;
  290. // Was previously interpreted as
  291. echo (yield) - 1;
  292. // And is now interpreted as
  293. echo yield (-1);
  294. yield $foo or die;
  295. // Was previously interpreted as
  296. yield ($foo or die);
  297. // And is now interpreted as
  298. (yield $foo) or die;
  299. Such cases can always be resolved by adding additional parentheses.
  300. . Removed ASP (<%) and script (<script language=php>) tags.
  301. (RFC: https://wiki.php.net/rfc/remove_alternative_php_tags)
  302. . Removed support for assigning the result of new by reference.
  303. . Removed support for scoped calls to non-static methods from an incompatible
  304. $this context. See details in https://wiki.php.net/rfc/incompat_ctx.
  305. . Removed support for #-style comments in ini files. Use ;-style comments
  306. instead.
  307. . $HTTP_RAW_POST_DATA is no longer available. Use the php://input stream instead.
  308. Standard library changes
  309. ========================
  310. . call_user_method() and call_user_method_array() no longer exists.
  311. . ob_start() no longer issues an E_ERROR, but instead an E_RECOVERABLE_ERROR in case an
  312. output buffer is created in an output buffer handler.
  313. . Improved zend_qsort(using hybrid sorting algo) for better performance,
  314. and also renamed zend_qsort to zend_sort.
  315. . Added stable sorting algo zend_insert_sort.
  316. . Removed dl() function on fpm-fcgi.
  317. Other
  318. =====
  319. - Curl:
  320. . Removed support for disabling the CURLOPT_SAFE_UPLOAD option. All curl file
  321. uploads must use the curl_file / CURLFile APIs.
  322. - Date:
  323. . Removed $is_dst parameter from mktime() and gmmktime().
  324. - DBA
  325. . dba_delete() now returns false if the key was not found for the inifile
  326. handler, too.
  327. - GMP
  328. . Requires libgmp version 4.2 or newer now.
  329. . gmp_setbit() and gmp_clrbit() now return FALSE for negative indices, making
  330. them consistent with other GMP functions.
  331. - Intl:
  332. . Removed deprecated aliases datefmt_set_timezone_id() and
  333. IntlDateFormatter::setTimeZoneID(). Use datefmt_set_timezone() and
  334. IntlDateFormatter::setTimeZone() instead.
  335. - Mcrypt
  336. . Removed deprecated mcrypt_generic_end() alias in favor of
  337. mcrypt_generic_deinit().
  338. . Removed deprecated mcrypt_ecb(), mcrypt_cbc(), mcrypt_cfb() and mcrypt_ofb()
  339. functions in favor of mcrypt_encrypt() and mcrypt_decrypt() with an
  340. MCRYPT_MODE_* flag.
  341. - Session
  342. . session_start() accepts all INI settings as array. e.g. ['cache_limiter'=>'private']
  343. sets session.cache_limiter=private. It also supports 'read_and_close' which closes
  344. session data immediately after read data.
  345. . Save handler accepts validate_sid(), update_timestamp() which validates session
  346. ID existence, updates timestamp of session data. Compatibility of old user defined
  347. save handler is retained.
  348. . SessionUpdateTimestampHandlerInterface is added. validateSid(), updateTimestamp()
  349. is defined in the interface.
  350. . session.lazy_write(default=On) INI setting enables only write session data when
  351. session data is updated.
  352. - OpenSSL:
  353. . Removed the "rsa_key_size" SSL context option in favor of automatically
  354. setting the appropriate size given the negotiated crypto algorithm.
  355. . Removed "CN_match" and "SNI_server_name" SSL context options. Use automatic
  356. detection or the "peer_name" option instead.
  357. - PCRE:
  358. . Removed support for /e (PREG_REPLACE_EVAL) modifier. Use
  359. preg_reaplace_callback() instead.
  360. - PDO_pgsql:
  361. . Removed PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT attribute in favor of
  362. ATTR_EMULATE_PREPARES.
  363. - Standard:
  364. . Removed string category support in setlocale(). Use the LC_* constants
  365. instead.
  366. . Removed set_magic_quotes_runtime() and its alias magic_quotes_runtime().
  367. - JSON:
  368. . Rejected RFC 7159 incompatible number formats in json_decode string -
  369. top level (07, 0xff, .1, -.1) and all levels ([1.], [1.e1])
  370. . Calling json_decode with 1st argument equal to empty PHP string or value that
  371. after casting to string is empty string (NULL, FALSE) results in JSON syntax error.
  372. - Stream:
  373. . Removed set_socket_blocking() in favor of its alias stream_set_blocking().
  374. - XSL:
  375. . Removed xsl.security_prefs ini option. Use XsltProcessor::setSecurityPrefs()
  376. instead.
  377. ========================================
  378. 2. New Features
  379. ========================================
  380. - Core
  381. . Added group use declarations.
  382. (RFC: https://wiki.php.net/rfc/group_use_declarations)
  383. . Added null coalesce operator (??).
  384. (RFC: https://wiki.php.net/rfc/isset_ternary)
  385. . Support for strings with length >= 2^31 bytes in 64 bit builds.
  386. . Closure::call() method added.
  387. . Added \u{xxxxxx} Unicode Codepoint Escape Syntax for double-quoted strings
  388. and heredocs.
  389. . define() now supports arrays as constant values, fixing an oversight where define() did not support arrays yet const syntax did.
  390. . Added the comparison operator (<=>), aka the spaceship operator.
  391. (RFC: https://wiki.php.net/rfc/combined-comparison-operator)
  392. . Added the yield from operator for delegating Generators like coroutines.
  393. (RFC: https://wiki.php.net/rfc/generator-delegation)
  394. - OpenSSL
  395. . Added "alpn_protocols" SSL context option allowing encrypted client/server
  396. streams to negotiate alternative protocols using the ALPN TLS extension when
  397. built against OpenSSL 1.0.2 or newer. Negotiated protocol information is
  398. accessible through stream_get_meta_data() output.
  399. ========================================
  400. 3. Changes in SAPI modules
  401. ========================================
  402. - FPM
  403. . Fixed bug #65933 (Cannot specify config lines longer than 1024 bytes).
  404. . Listen = port now listen on all addresses (IPv6 and IPv4-mapped).
  405. ========================================
  406. 4. Deprecated Functionality
  407. ========================================
  408. - Core
  409. . PHP 4 style constructors, where the constructor name is the same as the
  410. class name, are now deprecated.
  411. . Static calls to non-static methods are now deprecated.
  412. - OpenSSL
  413. . The "capture_session_meta" SSL context option is now deprecated. Meta
  414. data concerning active crypto on a stream resource is now accessible
  415. through the return result from stream_get_meta_data().
  416. ========================================
  417. 5. Changed Functions
  418. ========================================
  419. - parse_ini_file():
  420. - parse_ini_string():
  421. . Added scanner mode INI_SCANNER_TYPED to yield typed .ini values.
  422. - unserialize():
  423. . Added second parameter for unserialize function
  424. (RFC: https://wiki.php.net/rfc/secure_unserialize) allowing to specify
  425. acceptable classes:
  426. unserialize($foo, ["allowed_classes" => ["MyClass", "MyClass2"]);
  427. ========================================
  428. 6. New Functions
  429. ========================================
  430. - GMP
  431. . Added gmp_random_seed().
  432. - PCRE:
  433. . Added preg_replace_callback_array function
  434. (RFC: https://wiki.php.net/rfc/preg_replace_callback_array)
  435. - Standard
  436. . Added intdiv() function for integer division.
  437. . Added error_clear_last() function to reset error state.
  438. - Zlib:
  439. . Added deflate_init(), deflate_add(), inflate_init(), inflate_add()
  440. functions allowing incremental/streaming compression/decompression.
  441. ========================================
  442. 7. New Classes and Interfaces
  443. ========================================
  444. ========================================
  445. 8. Removed Extensions and SAPIs
  446. ========================================
  447. - sapi/aolserver
  448. - sapi/apache
  449. - sapi/apache_hooks
  450. - sapi/apache2filter
  451. - sapi/caudium
  452. - sapi/continuity
  453. - sapi/isapi
  454. - sapi/milter
  455. - sapi/phttpd
  456. - sapi/pi3web
  457. - sapi/roxen
  458. - sapi/thttpd
  459. - sapi/tux
  460. - sapi/webjames
  461. - ext/mssql
  462. - ext/sybase_ct
  463. For more details see https://wiki.php.net/rfc/removal_of_dead_sapis_and_exts
  464. ========================================
  465. 9. Other Changes to Extensions
  466. ========================================
  467. ========================================
  468. 10. New Global Constants
  469. ========================================
  470. - Core
  471. . PHP_INT_MIN added.
  472. - Zlib
  473. . These constants are added to control flush behavior with the new
  474. incremental deflate_add() and inflate_add() functions:
  475. . ZLIB_NO_FLUSH
  476. . ZLIB_PARTIAL_FLUSH
  477. . ZLIB_SYNC_FLUSH
  478. . ZLIB_FULL_FLUSH
  479. . ZLIB_BLOCK
  480. . ZLIB_FINISH
  481. ========================================
  482. 11. Changes to INI File Handling
  483. ========================================
  484. - Core
  485. . Removed asp_tags ini directive. Trying to enable it will result in a fatal
  486. error.
  487. . Removed always_populate_raw_post_data ini directive.
  488. ========================================
  489. 12. Windows Support
  490. ========================================
  491. - Core
  492. . Support for native 64 bit integers in 64 bit builds.
  493. . Support for large files in 64 bit builds.
  494. - ftp
  495. . The ftp extension is always shipped shared
  496. . For SSL support, the dependency on the openssl extension was abolished. Instead
  497. it depends alone on the openssl library. If it's present at the compile time,
  498. ftp_ssl_connect() is enabled automatically.
  499. - odbc
  500. . The odbc extension is always shipped shared
  501. ========================================
  502. 13. Other Changes
  503. ========================================
  504. - Core
  505. . Instead of being undefined and platform-dependent, NaN and Infinity will
  506. always be zero when casted to integer.
  507. . Calling a method on a non-object no longer raises a fatal error; see
  508. also: https://wiki.php.net/rfc/catchable-call-to-member-of-non-object.
  509. . Error messages for zend_parse_parameters, type hints and conversions now
  510. always say "integer" and "float" instead of "long" and "double".
  511. . Output buffering now continues to work for an aborted connection if
  512. ignore_user_abort is set to true.