NotionCommotion Posted January 28, 2019 Share Posted January 28, 2019 When using the phpDoc PHAR to parse the following file, it returns Parse Error: Syntax error, unexpected '(' on line 16 No summary was found for this file, and doesn't include the file. The specific script which triggers the error is ($this->prototype)(). I am using the PHAR listed on https://www.phpdoc.org/ which appears to be the same as https://github.com/phpDocumentor/phpDocumentor2/releases/download/v2.9.0/phpDocumentor.phar, and am running PHP 7.1.26. Any guess why I am getting this error? Recommended workarounds? As a hack, I am thinking of adding an ignored function or class who's only missing is to invoke the anonymous function. I've also tried using the PHAR at https://github.com/phpDocumentor/phpDocumentor2/releases/tag/v3.0.0-alpha.3, and while I don't get this error, I don't get any output. I first tried it without downloading the public key but got ssl errors. Is there more to in than just locating the two files in the same directory? Thanks <?php /** * My Summary. * * My Description. */ class Foo { private $prototype; public function __construct() { $this->prototype=function(){ return 'prototype';}; } public function getPrototype() { $prototype=($this->prototype)(); return $prototype; } } [michael@devserver test]$ php /usr/share/phar/phpDocumentor.phar -d ./phpDocDir -t ./phpDocTarget Collecting files .. OK Initializing parser .. OK Parsing files Parsing /var/www/public/test/phpDocDir/testphpdocs.php Parse Error: Syntax error, unexpected '(' on line 16 No summary was found for this file Storing cache in "/var/www/public/test/phpDocTarget" .. OK Load cache .. 0.001s Preparing template "clean" .. 0.011s Preparing 17 transformations .. 0.000s Build "elements" index .. 0.000s Replace textual FQCNs with object aliases .. 0.000s Resolve @link and @see tags in descriptions .. 0.000s Enriches inline example tags with their sources .. 0.000s Build "packages" index .. 0.000s Build "namespaces" index and add namespaces to "elements" .. 0.000s Collect all markers embedded in tags .. 0.000s Transform analyzed project into artifacts .. Applying 17 transformations Initialize writer "phpDocumentor\Plugin\Core\Transformer\Writer\FileIo" Initialize writer "phpDocumentor\Plugin\Twig\Writer\Twig" Initialize writer "phpDocumentor\Plugin\Graphs\Writer\Graph" Execute transformation using writer "FileIo" Execute transformation using writer "FileIo" Execute transformation using writer "FileIo" Execute transformation using writer "FileIo" Execute transformation using writer "FileIo" Execute transformation using writer "twig" Execute transformation using writer "twig" Execute transformation using writer "twig" Execute transformation using writer "twig" Execute transformation using writer "twig" Execute transformation using writer "twig" Execute transformation using writer "twig" Execute transformation using writer "twig" Execute transformation using writer "twig" Execute transformation using writer "twig" Execute transformation using writer "twig" Execute transformation using writer "Graph" 0.073s Analyze results and write report to log .. 0.000s [michael@devserver test]$ Quote Link to comment Share on other sites More sharing options...
NotionCommotion Posted January 28, 2019 Author Share Posted January 28, 2019 Correction, The alpha version seems to work. Guess I will give it a try. I am assuming I was just experiencing a bug in the 2-1/2 year old stable phpDocuments which was fixed in the Alpha version 3. Quote Link to comment Share on other sites More sharing options...
NotionCommotion Posted January 28, 2019 Author Share Posted January 28, 2019 Turns out the alpha version still needs some work so I will use the following as a temporary workaround. function invokeClosure(\Closure $closure, ...$args) { return ($closure)(...$args); } Quote Link to comment Share on other sites More sharing options...
requinix Posted January 28, 2019 Share Posted January 28, 2019 Is phpDoc using its own PHP code parser? Because that syntax was valid. Just as valid as the one you have now (though you don't need that first pair of parentheses). Quote Link to comment Share on other sites More sharing options...
NotionCommotion Posted January 29, 2019 Author Share Posted January 29, 2019 1 hour ago, requinix said: Is phpDoc using its own PHP code parser? Because that syntax was valid. Just as valid as the one you have now (though you don't need that first pair of parentheses). Not sure. How could one tell? Running into more quirks. Do you use it or something else? PS. Yes, the first pair of parentheses are carryover from when I was using $this->myclosure. Quote Link to comment Share on other sites More sharing options...
requinix Posted January 29, 2019 Share Posted January 29, 2019 I don't know, but in a bug report a developer said phpDoc2 doesn't support PHP 7 so they must be using their own parser somewhere in there. Used it? No, I've never really needed to generate API-style documentation. Quote Link to comment Share on other sites More sharing options...
NotionCommotion Posted January 29, 2019 Author Share Posted January 29, 2019 I've read mixed reports about supporting PHP 7. I take it you find benefit of docblocks via your IDE then. Quote Link to comment Share on other sites More sharing options...
requinix Posted January 29, 2019 Share Posted January 29, 2019 Yes. Mostly for the type hints, but occasionally something will be a little more complicated and it's nice to have a reminder (like a callback's signature) right there to see. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.