That looks like a very specific black magic. Not sure it is a good idea to 
provide such ability.

On Wednesday, March 29, 2017 at 7:48:10 PM UTC+3, David Rodrigues wrote:
>
> There some cases where it turn need. For instance, on Eloquent (from 
> Laravel) we have a feature called "scope", that is a method prefixed by 
> this term that is called by it radical, instead. For instance:
>
> public function scopeFilterByName($name) { ... }
>
>
> You should call this method like $query->filterByName($name) instead of 
> $query->scopeFilterByName($name).
>
> Currently we could declare it directly on class, like:
>
> /** @method void filterByName($name) */
> class MyClass extends Model { ... }
>
>
> But is hard to IDE, for instance, understand that it is related to 
> scopeFilterByName().
>
> Then my suggestion is make this declaration directly on method that 
> supports that:
>
> /** @method filterByName($name) */
> public function scopeFilterByName($name) { ... }
>
>
> *The advantages:*
>
>
>    1. IDE could detects exactly "who" is the real method, then read all 
>    parameters related, description, etc.;
>    2. The @method return typehint is optional, when not declared, copy 
>    from real method, if declared, override that;
>    3. The @method parameters is optional, when not declared, copy from 
>    real method, if declared, override that;
>
> ---
>
> The same case could be applied to properties.
>
> Again, on Eloquent, we have a feature called relations, that is declared 
> as methods, but called as properties.
>
> /** @property User[] $users */
> class MyClass extends Model {
>     ...
>
>     /** @return HasMany */
>     public function users() { ... }
> }
>
>
> Currently that is the way that we should declares it, but again, IDE can't 
> understand it to identify that this property is a relation declared by 
> users() method.
>
> Then it should be the solution:
>
> class MyClass extends Model {
>     ...
>
>     /**
>
>           * @property User[] $users
>
>      * @return HasMany 
>
>           */
>
>     public function users() { ... }
> }
>
>
> The advantages are basically the same that @method.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "PHP 
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to php-fig+unsubscr...@googlegroups.com.
To post to this group, send email to php-fig@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/583385cf-9d6a-4b67-80f2-f150aa6d88f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to