Hey Marco, > On Jan 9, 2020, at 5:04 PM, Marcio Almada <marcio.w...@gmail.com> wrote: > > Regarding the inclusion of new keywords with similar behavior of `:class`: > > Would `Interfaces\FooInterface::trait` or `Traits\FooTrait::interface` > cause a run time error? If I'm not mistaken `::class` can't trigger > error because it can't trigger autoload like `class_exists()` calls > does. > > Currently `::class` can be used to resolve any name like > `trim::class`. IMMO it would be weird to have `::class` with the > current no autoload / error free behavior and then `::trait`, > `::function` and `::interface` triggering autoload and emitting some > error level.
You are absolutely correct. I am so used to PhpStorm highlighting issues that I sometimes assume that PHP will throw an error/warning for the same. So if ::interface and ::trait were added, then (tools like) PhpStorm could have enough information to flag them if developers misspell them or they are otherwise unknown. > And also it would be weird to have `::trait`, `::function` and > `::interface` with the same loose behavior as `::class` Why weird? I can only assume Foo::trait vs. Bar::interface vs. Baz::class would not be hard to grok, and that it would would provide more valuable information to a reader than Foo::class vs. Bar:: class vs. Baz::class. > in that case, it seems less surprising to have just `::class` > everywhere instead. How so? I was very surprised when I first realized that I could do MyInterface::class, but I would not have been surprised by MyInterface::interface. > `::function` That said you bring up one I did not but would also like ::function as well as `::method` and even ::var or ::variable and ::const or ::constant. -Mike -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php