0

When looking inside Magento 2 core code, I found some commented methods, as it was in Magento 1 :

 * @method string getState()
 * @method string getStatus()

I know how it works technically, and the interest for the developer, but is it a good practice in terms of coding? Does-it add some overhead to magento, or the compilation does the job?

  • It isn't good practice, but you don't have to care about it. Of course You shouldn't push code with commented methods if you really don't have to - I am sure that you will not have to :P – Konrad Siamro Apr 4 '17 at 8:22
  • OK thanks you but can you explain me a little bit why it is a bad practice? Because it is lazy work? Or because it is less clear? – enrico69 Apr 4 '17 at 9:56
  • I think it's not a bad practice. It's helpful for IDE hint suggestion, for example PHPStorm. – Khoa TruongDinh Apr 4 '17 at 10:06
1

As you know Magento work with magic php methods. In current Magento installation you can see most of getter and setter as a realized functions, but Magento still use magic methods.

For developers this phpdoc hints is a big plus. You can get all possible methods by IDE, for example like this - magic hints

| improve this answer | |
  • OK so we shoutd see it as a hint mecanism. For instance to see exactly which kind of attribute could be accessed insise an entity? – enrico69 Apr 4 '17 at 12:27
  • Yes, this is just a hint mechanizm to let you know which attributes can be acessable in class. – Amasty Apr 4 '17 at 14:39

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.