com php-src: Merge branch 'PHP-7.4': Zend/tests/type_declarat ions/typed_properties_class_loading.phpt Zend/zend_ execute.c
| From: | Nikita Popov | Date: | Wed, 23 Oct 2019 10:24:01 +0000 |
| Subject: | com php-src: Merge branch 'PHP-7.4': Zend/tests/type_declarat ions/typed_properties_class_loading.phpt Zend/zend_ execute.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-109027@lists.php.net to get a copy of this message | ||
Commit: 13e0c5f4c944b83e69cf8d0e24066c2e9b31ff65
Author: Nikita Popov <nikita.ppv@gmail.com> Wed, 23 Oct 2019 12:21:32 +0200
Parents: ae46df0cb9c7e128a987f4b6e0f68554be2e012b f8413887816c4cecda75e6ae59dc3d1a74bb4f77
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=13e0c5f4c944b83e69cf8d0e24066c2e9b31ff65
Log:
Merge branch 'PHP-7.4'
* PHP-7.4:
Don't autoload when checking property types
Changed paths:
AM Zend/tests/type_declarations/typed_properties_class_loading.phpt
MM Zend/zend_execute.c
Diff:
diff --cc Zend/tests/type_declarations/typed_properties_class_loading.phpt
index 00000000000,0612624454b..a81bc5b4fe0
mode 000000,100644..100644
--- a/Zend/tests/type_declarations/typed_properties_class_loading.phpt
+++ b/Zend/tests/type_declarations/typed_properties_class_loading.phpt
@@@ -1,0 -1,51 +1,51 @@@
+ --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::$propX must be an instance of X, stdClass used
++Cannot assign stdClass to property Test::$propX of type X
+ object(X)#3 (0) {
+ }
-Typed property Test::$propY must be an instance of Y or null, stdClass used
++Cannot assign stdClass to property Test::$propY of type ?Y
+ object(Y)#4 (0) {
+ }