]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.4'
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 23 Oct 2019 10:21:32 +0000 (12:21 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 23 Oct 2019 10:24:01 +0000 (12:24 +0200)
* PHP-7.4:
  Don't autoload when checking property types

1  2 
Zend/tests/type_declarations/typed_properties_class_loading.phpt
Zend/zend_execute.c

index 0000000000000000000000000000000000000000,0612624454be9334a2761e40eda0758e4713596d..a81bc5b4fe091e6dab8d22bcf93e4e8588863ee5
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,51 +1,51 @@@
 -Typed property Test::$propX must be an instance of X, stdClass used
+ --TEST--
+ Typed properties do not invoke the autoloader
+ --FILE--
+ <?php
+ class Test {
+     public X $propX;
+     public ?Y $propY;
+ }
+ spl_autoload_register(function($class) {
+     echo "Loading $class\n";
+ });
+ $test = new Test;
+ try {
+     $test->propX = new stdClass;
+ } catch (TypeError $e) {
+     echo $e->getMessage(), "\n";
+ }
+ if (true) {
+     class X {}
+ }
+ $test->propX = new X;
+ var_dump($test->propX);
+ $test->propY = null;
+ $r =& $test->propY;
+ try {
+     $test->propY = new stdClass;
+ } catch (TypeError $e) {
+     echo $e->getMessage(), "\n";
+ }
+ if (true) {
+     class Y {}
+ }
+ $r = new Y;
+ var_dump($test->propY);
+ ?>
+ --EXPECT--
 -Typed property Test::$propY must be an instance of Y or null, stdClass used
++Cannot assign stdClass to property Test::$propX of type X
+ object(X)#3 (0) {
+ }
++Cannot assign stdClass to property Test::$propY of type ?Y
+ object(Y)#4 (0) {
+ }
Simple merge