diff --git a/language/control-structures/foreach.xml b/language/control-structures/foreach.xml
index a424f4964612..9ffa1ad72475 100644
--- a/language/control-structures/foreach.xml
+++ b/language/control-structures/foreach.xml
@@ -221,11 +221,12 @@ foreach ($array as [, , $c]) {
- A notice will be generated if there aren't enough array elements to fill
- the list:
+ A warning will be generated if there aren't enough array elements to fill
+ the list.
+ Prior to PHP 8.0.0 a notice was generated instead:
-
+
- &example.outputs;
+ &example.outputs.71;
+
+
+
+ &example.outputs.8;
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..1a8799d0e374 100644
--- a/language/oop5/magic.xml
+++ b/language/oop5/magic.xml
@@ -495,7 +495,7 @@ Array
Using __set_state()
-
+
]]>
- &example.outputs;
+ &example.outputs.81;
string(3) "foo"
}
+]]>
+
+ &example.outputs.82;
+
+ 5,
+ 'var2' => 'foo',
+))"
+object(A)#2 (2) {
+ ["var1"]=>
+ int(5)
+ ["var2"]=>
+ string(3) "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
]]>
-
- +, - and . precedence
-
-
-]]>
-
- &example.outputs;
-
-
-
-
Prior to PHP 8, +, - and . 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..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);
?>
]]>
@@ -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..386c5e913f37 100644
--- a/language/predefined/backedenum/from.xml
+++ b/language/predefined/backedenum/from.xml
@@ -71,7 +71,11 @@ $b = Suit::from('B');
diff --git a/reference/mbstring/functions/mb-detect-encoding.xml b/reference/mbstring/functions/mb-detect-encoding.xml
index 692ff51ef435..24972eee086a 100644
--- a/reference/mbstring/functions/mb-detect-encoding.xml
+++ b/reference/mbstring/functions/mb-detect-encoding.xml
@@ -133,7 +133,7 @@
mb_detect_encoding example
-
+
]]>
- &example.outputs;
+ &example.outputs.82;
+
+
+
+ &example.outputs.83;
Effect of strict parameter
-
+
]]>
- &example.outputs;
+ &example.outputs.82;
+
+ &example.outputs.83;
+
+
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 ]
}
}
}
diff --git a/reference/reflection/reflectionfunctionabstract/getreturntype.xml b/reference/reflection/reflectionfunctionabstract/getreturntype.xml
index 157c45706b19..51d44fb7082b 100644
--- a/reference/reflection/reflectionfunctionabstract/getreturntype.xml
+++ b/reference/reflection/reflectionfunctionabstract/getreturntype.xml
@@ -56,35 +56,38 @@ 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.
+
&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