PHP question: It looks like it's possible to "use", and therefore alias, a namespaced constant. Is there any way to do the same thing with a namespaced class constant?
@kboyd Ignore the eval() part of that, btw. It's just an artifact of trying to do it all in one file.
@pollita Hmm. I guess that's about the same as what I saw (using a temp variable to store the constant's value). Was mostly hoping there was a convenient way to avoid the temp variable.
@kboyd What temp variable?
@pollita Sorry, I didn't provide full context (since it was just some code I was glancing at). I wanted to replace a temporary variable inside a method that was storing a deeply-namespaced class constant's value, with a use statement & alias. The temporary variable only exists because it's more readable than the full reference to the class constant.
@kboyd I thought about making RFC for that as well as for aliasing static methods the way functions are used. AFAIK this is doable and proposed syntax could be `use static const MyClass::CONST_NAME;` & `use static function MyClass::staticMethodName;` maybe I should draft it
Welcome to the PHP Community on Mastodon! We're a friendly little Mastodon instance providing a place for PHP developers to discuss topics related to PHP, as well as topics unrelated to PHP. First and foremost, we're about building community, and that doesn't always involve technical discussion, so feel free to go off-topic and have fun.
Before you get started, make sure you check out our code of conduct.
Thank you to Jakob Westhoff for allowing the use of the photograph "elePHPants walking through the light."