|
|
Log in / Subscribe / Register

PHP struggles with attributes syntax

PHP struggles with attributes syntax

Posted Aug 8, 2020 5:43 UTC (Sat) by iteratedlateralus (guest, #102183)
In reply to: PHP struggles with attributes syntax by flussence
Parent article: PHP struggles with attributes syntax

The backslashes definitely weren't something I totally agreed with. I recall being in #php on Freenode, and saying that the backslash was too much of a shock (especially since it's an escape sequence). I said it would be use if they instead used the :: (the infamous php operator that I can't pronounce).

Something like:

use App::Models::FooBar;

The current syntax, for those who aren't php devs, is:

use \App\Models\FooBar;


to post comments

PHP struggles with attributes syntax

Posted Aug 8, 2020 21:21 UTC (Sat) by jkingweb (subscriber, #113039) [Link] (1 responses)

While you probably know this now, that would have been ambiguous. Is ::foo:::bar::baz() a a call to a function in the ::foo::bar namespace, or to a method of class bar in the ::foo namespace?

PHP struggles with attributes syntax

Posted Aug 9, 2020 6:57 UTC (Sun) by iteratedlateralus (guest, #102183) [Link]

That's very true. Had it not been the static access operator, it might work.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds