php-src/Zend/tests/bug65911.phpt
Nikita Popov 902d64390e Deprecate implicit dynamic properties
Writing to a proprety that hasn't been declared is deprecated,
unless the class uses the #[AllowDynamicProperties] attribute or
defines __get()/__set().

RFC: https://wiki.php.net/rfc/deprecate_dynamic_properties
2021-11-26 14:10:11 +01:00

26 lines
450 B
PHP

--TEST--
Bug #65911 (scope resolution operator - strange behavior with $this)
--FILE--
<?php
class A {}
class B
{
public $foo;
public function go()
{
$this->foo = 'bar';
echo A::$this->foo; // should not output 'bar'
}
}
$obj = new B();
$obj->go();
?>
--EXPECTF--
Fatal error: Uncaught Error: Access to undeclared static property A::$this in %s:%d
Stack trace:
#0 %s(%d): B->go()
#1 {main}
thrown in %s on line %d