[php-src] Issue #11502: Properties can be declared without existing in classes!!

From: Date: Wed, 21 Jun 2023 21:07:15 +0000
Subject: [php-src] Issue #11502: Properties can be declared without existing in classes!!
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244777@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11502 Author: zabuzara ### Description The following code: ```php <?php class MySelfDefined { // properties } $instance = new MySelfDefined(); $instance->any_property = "i'm in"; $instance->another_time = "i'm also in"; print_r($instance); echo $instance->any_property; echo $instance->another_time; ?> ``` Resulted in this output: ``` MySelfDefined Object ( [any_property] => i'm in [another_time] => i'm also in ) i'm in i'm also in ``` But I expected this output instead: ``` As i know you can not put any property in the classes without using magic functions in PHP. It should showing FATAL Error or something related to this possible thing. ``` The following code with existing FilesystemIterator: ```php <?php $obj = new FilesystemIterator('.'); $obj->can_i_also_in = "Yes why not!!!"; print_r($obj); ?> ``` Resulted in this output: ``` FilesystemIterator Object ( [can_i_also_in] => Yes why not!!! [pathName:SplFileInfo:private] => ./entity-framework [fileName:SplFileInfo:private] => entity-framework [glob:DirectoryIterator:private] => [subPathName:RecursiveDirectoryIterator:private] => ) ``` But I expected this output instead: ``` FilesystemIterator Object ( [pathName:SplFileInfo:private] => ./entity-framework [fileName:SplFileInfo:private] => entity-framework [glob:DirectoryIterator:private] => [subPathName:RecursiveDirectoryIterator:private] => ) ``` ### PHP Version PHP 8.1.14 (cli) (built: Jan 5 2023 19:43:29) (NTS) ### Operating System macOS Monterey v 12.6.6

« previous php.bugs (#244777) next »