diff --git a/language/control-structures/foreach.xml b/language/control-structures/foreach.xml index a424f4964612..4caeacbbc043 100644 --- a/language/control-structures/foreach.xml +++ b/language/control-structures/foreach.xml @@ -221,11 +221,11 @@ foreach ($array as [, , $c]) { - A notice will be generated if there aren't enough array elements to fill - the list: + If there are not enough array elements to populate the variables, + a warning is emitted; prior to PHP 8.0.0, a notice was emitted instead: - + - &example.outputs; + &example.outputs.71; + + + + &example.outputs.8; diff --git a/language/oop5/anonymous.xml b/language/oop5/anonymous.xml index a551897f0f7b..e7462652727a 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) } ]]> diff --git a/language/oop5/magic.xml b/language/oop5/magic.xml index c37257eed24c..5fc5682e8d23 100644 --- a/language/oop5/magic.xml +++ b/language/oop5/magic.xml @@ -527,7 +527,7 @@ var_dump($c); &example.outputs; 5, 'var2' => 'foo', ))" diff --git a/language/operators/precedence.xml b/language/operators/precedence.xml index 35ac34c0cb7a..4d4adcfdbf24 100644 --- a/language/operators/precedence.xml +++ b/language/operators/precedence.xml @@ -371,32 +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 @@ -414,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 diff --git a/language/operators/type.xml b/language/operators/type.xml index 3c6dd538388b..dd5ffce3fe59 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, using a constant would trigger a compile-time fatal error with the following message: +// instanceof expects an object instance, constant given var_dump(FALSE instanceof stdClass); ?> ]]> @@ -188,7 +191,7 @@ var_dump(FALSE instanceof stdClass); bool(false) bool(false) bool(false) -PHP Fatal error: instanceof expects an object instance, constant given +bool(false) ]]> diff --git a/language/predefined/backedenum/from.xml b/language/predefined/backedenum/from.xml index 4ecd30257c18..395725cab51b 100644 --- a/language/predefined/backedenum/from.xml +++ b/language/predefined/backedenum/from.xml @@ -66,12 +66,12 @@ $b = Suit::from('B'); ?> ]]> - &example.outputs; + &example.outputs.similar; 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; __toString(); ?> ]]> - &example.outputs; + &example.outputs.similar; 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 ] } } } diff --git a/reference/reflection/reflectionfunctionabstract/getreturntype.xml b/reference/reflection/reflectionfunctionabstract/getreturntype.xml index 157c45706b19..94c0f5816093 100644 --- a/reference/reflection/reflectionfunctionabstract/getreturntype.xml +++ b/reference/reflection/reflectionfunctionabstract/getreturntype.xml @@ -61,7 +61,7 @@ int getReturnType()); ]]> @@ -69,16 +69,15 @@ var_dump($reflection2->getReturnType()); &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. - + + Internal functions that return a resource have no declared return type, + because resource cannot be used in a type declaration. + diff --git a/reference/reflection/reflectionfunctionabstract/hasreturntype.xml b/reference/reflection/reflectionfunctionabstract/hasreturntype.xml index 40846a250b97..229d10c3e220 100644 --- a/reference/reflection/reflectionfunctionabstract/hasreturntype.xml +++ b/reference/reflection/reflectionfunctionabstract/hasreturntype.xml @@ -61,7 +61,7 @@ bool(true) hasReturnType()); ]]>