5

I got accustomed to using PHPStorm's validation feature, the yellow flags on right of editor showing whenever a method could not be found.

I found that it doesn't recognize magic getter methods, for instance: $attribute->getAttributeCode().

Anyone ever made this work ?

Thank you.

5

most of the issues get resolved if you use n98-magerun to generate the phpstorm meta file https://github.com/netz98/n98-magerun#development-ide-support

If there are cases where this does not happen correctly, please report them, so it can get extended :)

4

You should give magicento a try, it adds a lot of typehints. But I'm not sure on what bases, maybe hard coded, retrieved from the tables?

Beside this, you can define the methods and properties on the class:

/**
  * @property Classname $_name
  * @method Returned_Class methodName(TypeHint $typehint, TypeHint2 $typehint2) And a comment to describe what the method does
  */
class MyClass {}

But both methods are not useable for bad commented core classes :-/

  • I already use magicento. It doesn't resolve either, neither cmd+b goes to the property. – Niloct Apr 9 '14 at 21:15
  • That @method wouldn't be bad since I would have to declare again all methods which are supposed to be magic ? – Niloct Apr 9 '14 at 21:16
  • The problem with magic method is the magic part :D There is no way to determine, what method exists and which doesn't. You can write an code generator which adds all the tables to the classes, but you still don't know what methods are missing... – Fabian Blechschmidt Apr 9 '14 at 21:32
  • 1
    Suppose I have an object with class known, wouldn't it just simply needed to walk through the properties of the class and apply the magic transformation to find getters ? – Niloct Apr 10 '14 at 19:12
  • 2
    Follow this steps to get autocomplete for magic methods without adding @method phpdocs: magicento.com/#magic-method-autocomplete (how Fabian said, Magicento is reading your DB to guess the properties of your model) – Enrique Apr 21 '14 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.