> Again: the "use extension" isn't bad per se, it's just that the "use" keyword 
> *doesn't do anything*, and never has. It's just an alias. Adding "use 
> extension", though being "slightly different" that just having "use", still 
> means that it's gonna be on top of the PHP file, many IDEs already fold these 
> statements for readability.

What is wrong with folding these statements? 

I think you’re overthinking what will likely end up being the common use case 
in an IDE. The user is going to type something like `$m->extensionMethod()`, 
it’s going to get a red squiggly line under it, they’ll click the suggestion to 
add the `use extension` at the top, and they will move on. 

When the PR goes up for review, the reviewer is going to see it, check if they 
used the right extension, and flag it if they used the wrong one. 



> Something else I am thinking about changing the keyword and applying the 
> extension to a class directly at the same time:

This sounds harsh, so my apologies in advance. 

I reject this functionality.

1. Since extensions are scoped to a single file (which is typically a single 
class) and not global, they don’t encounter many situations where this would 
even be a consideration.
2. Extensions only occupy the path that would otherwise throw a method not 
found exception. They are the method of last resort for a match, so they never 
override functionality. Calling an extension method on any class that didn’t 
have the extension applied always results in an exception being thrown.
3. The functionality you are describing already exists in Traits. Extensions 
are complementary to Traits, not a replacement. For the situation you are 
describing, an Extension is not the right tool and trying to make it fit that 
use case would be damaging to the overall simplicity of them. 

Reply via email to