tgoop.com/phpyh/451
Create:
Last Update:
Last Update:
new MyClass()->method() без скобок!
Вдохновлённый митапом, разобрался с синтаксисом Bison и закинул свой первый Pull Request в исходники PHP. Это изменение позволит обращаться к объектам, созданным через new
, не оборачивая их в скобки. Во избежание неоднозначности работать будет только при наличии скобок аргументов конструктора.
final class A
{
const CONSTANT = 'constant';
public static $staticProperty = 'staticProperty';
public static function staticMethod() {}
public $property = 'property';
public function method() {}
public function __invoke() {}
}
new A()::CONSTANT;
new A()::$staticProperty;
new A()::staticMethod();
new A()->property;
new A()->method();
new A()();
Поддерживаются также динамические имена классов и анонимные классы (см. тесты).
После первичного одобрения сделаю RFC. Пока накидайте лайков в PR, пожалуйста.
https://github.com/php/php-src/pull/13029
BY Пых
Share with your friend now:
tgoop.com/phpyh/451