cvuorinen / phpdoc-markdown-public

phpDocumentor template that generates Markdown documentation of the public API
MIT License
34 stars 27 forks source link

Doesn't work properly with PHP 7.2 #4

Open maxalmonte14 opened 6 years ago

maxalmonte14 commented 6 years ago

I'm trying to parse some class and apparently it crash when a class implements Countable interface.

PHP Warning:  count(): Parameter must be an array or an object that implements Countable in /home/max/Desktop/documentator/vendor/phpdocumentor/phpdocumentor/src/phpDocumentor/Plugin/Core/Descriptor/Validator/Constraints/Functions/IsArgumentInDocBlockValidator.php on line 33

Also, it doesn't recognize nullable return types, if one of your classes use nullable return types like the following:

public function get() ?StdClass
{
    //...
}

You end up with an error like this:

Parse Error: Syntax error, unexpected '?' on line 100
cvuorinen commented 6 years ago

I think both of these errors are with phpDocumentor. Their v3 should add support for PHP 7 scalar type hints and presumably also nullable return types, but it's still alpha.

You could still try to upgrade it and see how it works. But my library does not do parsing of the source code so there's not much I can do other than wait for the new stable release.

maxalmonte14 commented 6 years ago

So, this package only works properly with PHP 5.x?

What a pity.

I think this behavior should be documented in the README, by doing this you will avoid future open issues about the topic.

chris-ruskai commented 5 years ago

Forking the project and changing the phpdocumentor/phpdocumentor version to dev-master allows for the successful generation of Markdown for PHP 7.2.

maxalmonte14 commented 5 years ago

Thank you so much for the tip @chris-ruskai, it would be great if this change could also be applied to a new branch in the official repository.

chris-ruskai commented 5 years ago

No problem. I suspect such a change would break too many people's minimum-stability restrictions in their composer.json files since phpdocumentor 3 is still super alpha (It is so alpha that it still barfs on access modifiers for class constants.).