Fix bug #78226: Don't call __set() on uninitialized typed properties
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 24 Oct 2019 14:36:25 +0000 (16:36 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 25 Oct 2019 14:31:45 +0000 (16:31 +0200)
commitf1848a4b3f807d21415c5a334b461d240b2a83af
tree9ab6c3a2da4518cdc8a06893890ea0ca8c174c42
parent4d8541debbc4f2387879a872b42604ed8b908f58
Fix bug #78226: Don't call __set() on uninitialized typed properties

Assigning to an uninitialized typed property will no longer trigger
a call to __set(). However, calls to __set() are still triggered if
the property is explicitly unset().

This gives us both the behavior people generally expect, and still
allows ORMs to do lazy initialization by unsetting properties.

For PHP 8, we should fine a way to forbid unsetting of declared
properties entirely, and provide a different way to achieve lazy
initialization.
NEWS
Zend/tests/type_declarations/typed_properties_magic_set.phpt [new file with mode: 0644]
Zend/zend_API.c
Zend/zend_inheritance.c
Zend/zend_object_handlers.c
Zend/zend_objects.c
Zend/zend_types.h
ext/opcache/zend_accelerator_util_funcs.c