scotteh/php-dom-wrapper

PHP Docs for type hinting

Closed this issue · 3 comments

I've been playing with this lib and it's really helpful. One issue I've experienced:

I am using PHPStorm and notices that the find isn't showing the object type for return which breaks the type-hinting.

en___volumes_code_projects_elasticnews_en__-____cli_scrape-test_php__elastic_news

It seem the problem starts in the class Document. The traits are use in this order
use CommonTrait; use TraversalTrait; use ManipulationTrait;
the find method is in both the traversal and manipulation traits (didn't understand the need) and the ManipulationTrait just has an reference to the TraversalTrait where the find is properly defined.

I think either the ManipulationTrait methods should be fully documented (if there is a case you really need them) or if you use the TraversalTrait last in the Document, it's methods will "win" and the type hinting works as expected.

I would lean towards removing the method from ManipulationTrait as it is defined as abstract and has no implementations except for the TraversalTrait (AFAIK). But you might have some plan I haven't understood.

What version are you currently using? The older pre 1.0 versions have this, but these abstracts were removed from more recent versions.

ugg.. I saw there was a new version and did the update (lots of things were updated.) before submitting this. I thought I had a the new version - but I forgot to update the composer.json and it wasn't update.

Sorry - all good now! Thanks again.

No worries, glad you are finding it helpful.