From 6d44e897a1e8a02a6218f1c368cc62cdbc6f47a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AD=A6=E7=94=B0=20=E6=86=B2=E5=A4=AA=E9=83=8E?= Date: Mon, 27 Jul 2026 12:04:43 +0900 Subject: [PATCH 01/13] Update screens for operator semantics that changed Since PHP 8.0 "+" and "-" bind tighter than ".", so the concatenation example no longer prints -1. Its comments were written for the old grouping and stayed behind; the example below it, kept non-interactive, carries that history. Since PHP 7.3 a constant is allowed on the left of instanceof and evaluates to false instead of raising a fatal error; the prose above that example already says so. --- language/operators/precedence.xml | 14 +++++++++----- language/operators/type.xml | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/language/operators/precedence.xml b/language/operators/precedence.xml index 35ac34c0cb7a..d54067490f40 100644 --- a/language/operators/precedence.xml +++ b/language/operators/precedence.xml @@ -377,10 +377,10 @@ $array[$i] = $i++; // may set either index 1 or 2 diff --git a/language/operators/type.xml b/language/operators/type.xml index 3c6dd538388b..6fbcbaa81d63 100644 --- a/language/operators/type.xml +++ b/language/operators/type.xml @@ -188,7 +188,7 @@ var_dump(FALSE instanceof stdClass); bool(false) bool(false) bool(false) -PHP Fatal error: instanceof expects an object instance, constant given +bool(false) ]]> From ff05449654180a6c4f01894c04bfb0b19b38c18c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AD=A6=E7=94=B0=20=E6=86=B2=E5=A4=AA=E9=83=8E?= Date: Mon, 27 Jul 2026 12:04:43 +0900 Subject: [PATCH 02/13] Update screens for diagnostics that changed Reading a missing array key is a warning rather than a notice since PHP 8.0, so the sentence introducing that example moves with the screen. Since PHP 8.2 the ValueError from BackedEnum::from() no longer quotes the enum name. --- language/control-structures/foreach.xml | 6 +++--- language/predefined/backedenum/from.xml | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/language/control-structures/foreach.xml b/language/control-structures/foreach.xml index a424f4964612..c9936f6415c0 100644 --- a/language/control-structures/foreach.xml +++ b/language/control-structures/foreach.xml @@ -221,7 +221,7 @@ foreach ($array as [, , $c]) { - A notice will be generated if there aren't enough array elements to fill + A warning will be generated if there aren't enough array elements to fill the list: @@ -241,10 +241,10 @@ foreach ($array as [$a, $b, $c]) { &example.outputs; diff --git a/language/predefined/backedenum/from.xml b/language/predefined/backedenum/from.xml index 4ecd30257c18..386c5e913f37 100644 --- a/language/predefined/backedenum/from.xml +++ b/language/predefined/backedenum/from.xml @@ -71,7 +71,11 @@ $b = Suit::from('B'); From 2ba57e53f950c21522b8d7379f126a78d6b66200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AD=A6=E7=94=B0=20=E6=86=B2=E5=A4=AA=E9=83=8E?= Date: Mon, 27 Jul 2026 12:04:43 +0900 Subject: [PATCH 03/13] Reflect a tentative return type instead of a built-in function Both pages used array_merge() to show that reflection reports no return type for internal functions. Since PHP 8.0 it does report one, so the examples demonstrated nothing and the paragraph warning about built-ins was no longer true. A method with a tentative return type is the case that still reports none, so the examples use one and point at the accessors that return it. --- .../reflectionfunctionabstract/getreturntype.xml | 15 +++++++++------ .../reflectionfunctionabstract/hasreturntype.xml | 7 +++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/reference/reflection/reflectionfunctionabstract/getreturntype.xml b/reference/reflection/reflectionfunctionabstract/getreturntype.xml index 157c45706b19..b32a4196fdef 100644 --- a/reference/reflection/reflectionfunctionabstract/getreturntype.xml +++ b/reference/reflection/reflectionfunctionabstract/getreturntype.xml @@ -56,28 +56,30 @@ int - Usage on built-in functions + Methods with a tentative return type getReturnType()); +echo $reflection2->getTentativeReturnType(); ]]> &example.outputs; - This is because many internal functions do not have types specified for their - parameters or return values. It is therefore best to avoid using this - method on built-in functions. + A tentative return type is not reported here; use + ReflectionFunctionAbstract::getTentativeReturnType + to obtain it. @@ -85,6 +87,7 @@ null &reftitle.seealso; + ReflectionFunctionAbstract::getTentativeReturnType ReflectionFunctionAbstract::hasReturnType ReflectionType::__toString diff --git a/reference/reflection/reflectionfunctionabstract/hasreturntype.xml b/reference/reflection/reflectionfunctionabstract/hasreturntype.xml index 40846a250b97..0c77adcbeceb 100644 --- a/reference/reflection/reflectionfunctionabstract/hasreturntype.xml +++ b/reference/reflection/reflectionfunctionabstract/hasreturntype.xml @@ -56,20 +56,22 @@ bool(true) - Usage on built-in functions + Methods with a tentative return type hasReturnType()); +var_dump($reflection2->hasTentativeReturnType()); ]]> &example.outputs; @@ -81,6 +83,7 @@ bool(false) ReflectionFunctionAbstract::getReturnType + ReflectionFunctionAbstract::hasTentativeReturnType From 03ad3ca8171fdb35fa33abec23beae68904a17da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AD=A6=E7=94=B0=20=E6=86=B2=E5=A4=AA=E9=83=8E?= Date: Mon, 27 Jul 2026 12:04:43 +0900 Subject: [PATCH 04/13] Regenerate the ReflectionClass::__toString() screen The dump of Exception has drifted across several releases rather than one: property types and defaults are printed differently, tentative return types appeared, and the method count was stale. Regenerated from PHP 8.5 instead of reconstructed. --- .../reflection/reflectionclass/tostring.xml | 84 ++++++++++++++----- 1 file changed, 63 insertions(+), 21 deletions(-) diff --git a/reference/reflection/reflectionclass/tostring.xml b/reference/reflection/reflectionclass/tostring.xml index a72e41b62ab5..b5a2d987c9b8 100644 --- a/reference/reflection/reflectionclass/tostring.xml +++ b/reference/reflection/reflectionclass/tostring.xml @@ -46,7 +46,7 @@ echo $reflectionClass->__toString(); &example.outputs; class Exception ] { +Class [ class Exception implements Stringable, Throwable ] { - Constants [0] { } @@ -58,50 +58,92 @@ Class [ class Exception ] { } - Properties [7] { - Property [ protected $message ] - Property [ private $string ] - Property [ protected $code ] - Property [ protected $file ] - Property [ protected $line ] - Property [ private $trace ] - Property [ private $previous ] + Property [ protected $message = '' ] + Property [ private string $string = '' ] + Property [ protected $code = 0 ] + Property [ protected string $file = '' ] + Property [ protected int $line = 0 ] + Property [ private array $trace = [] ] + Property [ private ?Throwable $previous = NULL ] } - - Methods [10] { - Method [ final private method __clone ] { + - Methods [11] { + Method [ private method __clone ] { + + - Parameters [0] { + } + - Return [ void ] } Method [ public method __construct ] { - Parameters [3] { - Parameter #0 [ $message ] - Parameter #1 [ $code ] - Parameter #2 [ $previous ] + Parameter #0 [ string $message = "" ] + Parameter #1 [ int $code = 0 ] + Parameter #2 [ ?Throwable $previous = null ] } } - Method [ final public method getMessage ] { + Method [ public method __wakeup ] { + + - Parameters [0] { + } + - Tentative return [ void ] } - Method [ final public method getCode ] { + Method [ final public method getMessage ] { + + - Parameters [0] { + } + - Return [ string ] } - Method [ final public method getFile ] { + Method [ final public method getCode ] { + + - Parameters [0] { + } + } + + Method [ final public method getFile ] { + + - Parameters [0] { + } + - Return [ string ] } - Method [ final public method getLine ] { + Method [ final public method getLine ] { + + - Parameters [0] { + } + - Return [ int ] } - Method [ final public method getTrace ] { + Method [ final public method getTrace ] { + + - Parameters [0] { + } + - Return [ array ] } - Method [ final public method getPrevious ] { + Method [ final public method getPrevious ] { + + - Parameters [0] { + } + - Return [ ?Throwable ] } - Method [ final public method getTraceAsString ] { + Method [ final public method getTraceAsString ] { + + - Parameters [0] { + } + - Return [ string ] } - Method [ public method __toString ] { + Method [ public method __toString ] { + + - Parameters [0] { + } + - Return [ string ] } } } From d4e0fc32275967ff0655a8627fc3652dee2b7272 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AD=A6=E7=94=B0=20=E6=86=B2=E5=A4=AA=E9=83=8E?= Date: Mon, 27 Jul 2026 12:04:44 +0900 Subject: [PATCH 05/13] Update screens for how class names are printed Since PHP 8.0 an anonymous class is named after the class it extends. The note further down that page still showed the PHP 7 form, captured on 3v4l.org rather than from the example; the NUL byte the name contains is invisible in a screen, so the note now says so. Since PHP 8.2 var_export() writes class names fully qualified, with a leading backslash. --- language/oop5/anonymous.xml | 13 +++++++------ language/oop5/magic.xml | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/language/oop5/anonymous.xml b/language/oop5/anonymous.xml index e2281847d315..f8562ebcd603 100644 --- a/language/oop5/anonymous.xml +++ b/language/oop5/anonymous.xml @@ -63,8 +63,8 @@ var_dump(new class(10) extends SomeClass implements SomeInterface { &example.outputs; +object(SomeClass@anonymous)#1 (1) { + ["num":"SomeClass@anonymous":private]=> int(10) } ]]> @@ -153,11 +153,12 @@ same class - + Note that anonymous classes are assigned a name by the engine, as demonstrated in the following example. This name has to be regarded an - implementation detail, which should not be relied upon. - + implementation detail, which should not be relied upon. The generated name + contains a NUL byte, which is not visible in the output below. + diff --git a/language/oop5/magic.xml b/language/oop5/magic.xml index 425f3c0a6c6f..43c901d71bfe 100644 --- a/language/oop5/magic.xml +++ b/language/oop5/magic.xml @@ -527,7 +527,7 @@ var_dump($c); &example.outputs; 5, 'var2' => 'foo', ))" From ac7eb8d6af45f4323b8337bb0822e97b964b9c5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AD=A6=E7=94=B0=20=E6=86=B2=E5=A4=AA=E9=83=8E?= Date: Mon, 27 Jul 2026 12:04:44 +0900 Subject: [PATCH 06/13] Update the mb_detect_encoding() screen for its PHP 8.3 behaviour Non-strict detection follows the documented rule since PHP 8.3, so this string now yields ASCII rather than UTF-8. The comment goes with it: it named UTF-8 as the closer match, and the two candidates are in fact equally distant here, so it should not name a winner at all. --- reference/mbstring/functions/mb-detect-encoding.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/reference/mbstring/functions/mb-detect-encoding.xml b/reference/mbstring/functions/mb-detect-encoding.xml index 692ff51ef435..304fd48cfe94 100644 --- a/reference/mbstring/functions/mb-detect-encoding.xml +++ b/reference/mbstring/functions/mb-detect-encoding.xml @@ -178,7 +178,8 @@ string(5) "ASCII" // 'áéóú' encoded in ISO-8859-1 $str = "\xE1\xE9\xF3\xFA"; -// The string is not valid ASCII or UTF-8, but UTF-8 is considered a closer match +// The string is valid in neither encoding: non-strict reports the closest +// match, strict returns false var_dump(mb_detect_encoding($str, ['ASCII', 'UTF-8'], false)); var_dump(mb_detect_encoding($str, ['ASCII', 'UTF-8'], true)); @@ -191,7 +192,7 @@ var_dump(mb_detect_encoding($str, ['ASCII', 'UTF-8', 'ISO-8859-1'], true)); &example.outputs; Date: Sat, 1 Aug 2026 03:08:34 +0900 Subject: [PATCH 07/13] Split the mb_detect_encoding() screens at PHP 8.3 The non-strict change landed in 8.3.0, so 8.2 still prints the old result and one screen cannot cover both. The basic example is split too: its screen already showed only the 8.3 behaviour. --- .../mbstring/functions/mb-detect-encoding.xml | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/reference/mbstring/functions/mb-detect-encoding.xml b/reference/mbstring/functions/mb-detect-encoding.xml index 304fd48cfe94..a330ef899eb9 100644 --- a/reference/mbstring/functions/mb-detect-encoding.xml +++ b/reference/mbstring/functions/mb-detect-encoding.xml @@ -158,7 +158,16 @@ var_dump(mb_detect_encoding($str, $encodings)); ?> ]]> - &example.outputs; + &example.outputs.82; + + + + &example.outputs.83; ]]> - &example.outputs; + &example.outputs.82; + + + + &example.outputs.83; Date: Sat, 1 Aug 2026 03:19:06 +0900 Subject: [PATCH 08/13] Use simpara for the getReturnType() note docbook-cs de7e4fd tightened which elements SimparaSniff accepts, and the sentence this PR rewrites is inline-only. --- .../reflection/reflectionfunctionabstract/getreturntype.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reference/reflection/reflectionfunctionabstract/getreturntype.xml b/reference/reflection/reflectionfunctionabstract/getreturntype.xml index b32a4196fdef..51d44fb7082b 100644 --- a/reference/reflection/reflectionfunctionabstract/getreturntype.xml +++ b/reference/reflection/reflectionfunctionabstract/getreturntype.xml @@ -76,11 +76,11 @@ int - + A tentative return type is not reported here; use ReflectionFunctionAbstract::getTentativeReturnType to obtain it. - + From 21008d6e2dce90acf63a730eb5f0d7974becbb6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AD=A6=E7=94=B0=20=E6=86=B2=E5=A4=AA=E9=83=8E?= Date: Sat, 1 Aug 2026 16:52:16 +0900 Subject: [PATCH 09/13] Merge the . precedence examples and split them at PHP 8.0 --- language/operators/precedence.xml | 59 +++++++++++++++---------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/language/operators/precedence.xml b/language/operators/precedence.xml index d54067490f40..4d4adcfdbf24 100644 --- a/language/operators/precedence.xml +++ b/language/operators/precedence.xml @@ -371,36 +371,6 @@ $array[$i] = $i++; // may set either index 1 or 2 ]]> - - <literal>+</literal>, <literal>-</literal> and <literal>.</literal> precedence - - -]]> - - &example.outputs; - - - - Prior to PHP 8, <literal>+</literal>, <literal>-</literal> and <literal>.</literal> had the same precedence @@ -418,16 +388,43 @@ echo "x minus one equals " . ($x-1) . ", or so I hope\n"; ?> ]]> - &example.outputs; + &example.outputs.71; + + &example.outputs.8; + + + + As of PHP 7.4.0 the first line also emits + Deprecated: The behavior of unparenthesized expressions containing + both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher + precedence. + + + As of PHP 8.0.0 the pitfall is gone, because - now binds + tighter than .. + The second line, which spells out the grouping that used to apply, throws a + TypeError instead, so the third line never + runs. + Although = has a lower precedence than From 83171fa460e150cceb7bdff078ac1a2851fa6b16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AD=A6=E7=94=B0=20=E6=86=B2=E5=A4=AA=E9=83=8E?= Date: Sat, 1 Aug 2026 16:52:35 +0900 Subject: [PATCH 10/13] Note the instanceof constant error removed at PHP 7.3 --- language/operators/type.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/language/operators/type.xml b/language/operators/type.xml index 6fbcbaa81d63..c743ca30116c 100644 --- a/language/operators/type.xml +++ b/language/operators/type.xml @@ -178,6 +178,9 @@ $c = fopen('/tmp/', 'r'); var_dump($a instanceof stdClass); // $a is an integer var_dump($b instanceof stdClass); // $b is NULL var_dump($c instanceof stdClass); // $c is a resource + +// Prior to PHP 7.3.0 this was a compile-time error, so nothing above ran: +// instanceof expects an object instance, constant given var_dump(FALSE instanceof stdClass); ?> ]]> From 4dcf024a91f6edc7e17d7a8706b6cb5981cbec7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AD=A6=E7=94=B0=20=E6=86=B2=E5=A4=AA=E9=83=8E?= Date: Sat, 1 Aug 2026 16:52:57 +0900 Subject: [PATCH 11/13] Split the foreach list() screens at PHP 8.0 --- language/control-structures/foreach.xml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/language/control-structures/foreach.xml b/language/control-structures/foreach.xml index c9936f6415c0..9ffa1ad72475 100644 --- a/language/control-structures/foreach.xml +++ b/language/control-structures/foreach.xml @@ -222,10 +222,11 @@ foreach ($array as [, , $c]) { A warning will be generated if there aren't enough array elements to fill - the list: + the list. + Prior to PHP 8.0.0 a notice was generated instead: - + - &example.outputs; + &example.outputs.71; + + + + &example.outputs.8; Date: Sat, 1 Aug 2026 16:53:16 +0900 Subject: [PATCH 12/13] Split the __set_state() screens at PHP 8.2 --- language/oop5/magic.xml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/language/oop5/magic.xml b/language/oop5/magic.xml index 43c901d71bfe..1a8799d0e374 100644 --- a/language/oop5/magic.xml +++ b/language/oop5/magic.xml @@ -495,7 +495,7 @@ Array Using <link linkend="object.set-state">__set_state()</link> - + ]]> - &example.outputs; + &example.outputs.81; + + 5, + 'var2' => 'foo', +))" +object(A)#2 (2) { + ["var1"]=> + int(5) + ["var2"]=> + string(3) "foo" +} +]]> + + &example.outputs.82; Date: Sat, 1 Aug 2026 16:53:38 +0900 Subject: [PATCH 13/13] Keep Run code off the mb_detect_encoding() PHP 8.2 screen --- reference/mbstring/functions/mb-detect-encoding.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reference/mbstring/functions/mb-detect-encoding.xml b/reference/mbstring/functions/mb-detect-encoding.xml index a330ef899eb9..24972eee086a 100644 --- a/reference/mbstring/functions/mb-detect-encoding.xml +++ b/reference/mbstring/functions/mb-detect-encoding.xml @@ -133,7 +133,7 @@ <function>mb_detect_encoding</function> example - + Effect of <parameter>strict</parameter> parameter - +