-
Notifications
You must be signed in to change notification settings - Fork 22
Support of @mixin annotation #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This needs to be added to the FacadeMethodExtension too since right now it is failing on DB::table('some_table'). The table method is located in Illuminate\Database\Connection and not the root facade Illuminate\Database\DatabaseManager, but the DatabaseManager do have a @mixin for the connection class |
Thanks for the PR! And the tests! Could we break this up into a collaborator, or even a base class method is fine? |
src/BuilderMethodExtension.php
Outdated
if (!isset($this->methods[$classReflection->getName()]) && ( | ||
$classReflection->isSubclassOf(Model::class) | ||
|| preg_match( | ||
'/@mixin\s+' . preg_quote('\\' . Builder::class) . '/', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make the leading slash optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@twistor That /
is the pattern delimiter!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the \\
for the namepsace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, the backslashes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@twistor sorry for delay, but I have a lot of work now, but promise to you to resolve issue in next few days
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@twistor I've moved mixin detection to a separate class and it will return class names without the leading slash, but if you'll try to use such form, for example, in IDE it will show incorrect namespace error (checked in PHPStorm). Of course, in IDE can be used even short class names, because it can parse use section, but in this case it is imposible to detect class namespace from doc block only.
Looks awesome, thanks! |
There are classes in Laravel which may be used as query builder and it's indicated via @mixin annotation, for example, relations. I guess, it is useful to consider this moment.