Bug #78904 [ReO->Csd]: Uninitialized property triggers __get()
| From: | nikic@php.net | Date: | Mon, 09 Dec 2019 07:43:01 +0000 |
| Subject: | Bug #78904 [ReO->Csd]: Uninitialized property triggers __get() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-224149@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78904&edit=1
ID: 78904
Updated by: nikic@php.net
Reported by: public at grik dot net
Summary: Uninitialized property triggers __get()
-Status: Re-Opened
+Status: Closed
Type: Bug
Package: *General Issues
PHP Version: 7.4.0
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=84354c62b37a56816a695b18ebd898f9703a9ad2
Log: Fixed bug #78904: Don't call any magic for uninitialized typed properties
Previous Comments:
------------------------------------------------------------------------
[2019-12-06 15:32:10] public at grik dot net
Thank you. Sorry for filling this ticket up improperly, I did not expect attention.
------------------------------------------------------------------------
[2019-12-06 14:47:19] nikic@php.net
The following pull request has been associated:
Patch Name: Also don't call other magic for uninitialized typed properties
On GitHub: https://github.com/php/php-src/pull/4974
Patch: https://github.com/php/php-src/pull/4974.patch
------------------------------------------------------------------------
[2019-12-06 14:35:10] nikic@php.net
> It would make sense to show a compile-time warning/notice for typed property declarations
> without initial value. Consider it for a later version, please.
Certainly not. There is nothing wrong with a property that does not have an initial value. In fact
nearly all properties shouldn't have one, as most properties get initialized based on
constructor arguments.
Based on preliminary discussion we might change __get() behavior, so I'm reopening this.
I'll prepare a patch asap.
------------------------------------------------------------------------
[2019-12-06 14:19:42] public at grik dot net
It would make sense to show a compile-time warning/notice for typed property declarations without
initial value. Consider it for a later version, please.
If it is not possible, consider adding the way to check if the property is initialized, so framework
authors could process this state in magic getters properly.
------------------------------------------------------------------------
[2019-12-06 14:01:05] nikic@php.net
So, sounds like we should have given __get() the same treatment as __set() in how it interacts with
uninitialized typed properties. I'm not sure if we can still make this change at this point.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=78904
--
Edit this bug report at https://bugs.php.net/bug.php?id=78904&edit=1