Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with package tag in a global function #1330

Closed
marcimat opened this issue Jul 7, 2014 · 4 comments
Closed

Bug with package tag in a global function #1330

marcimat opened this issue Jul 7, 2014 · 4 comments
Labels
Milestone

Comments

@marcimat
Copy link
Contributor

marcimat commented Jul 7, 2014

Hi,

With 2.6.0 6c7cb9c , a little file creates a Fatal Error :

/**
 * Demo File
 *
 * Same bug with or without file @package tag.
 *
 * @package Demo
**/

/**
 * A demo function
 *
 * @package Other
**/
function demo() {}

Run with :

autodoc/vendor/phpdocumentor/phpdocumentor/bin/phpdoc -d work/input/demo -t work/output/demo --parseprivate

Makes :

Parsing [...]/work/input/demo/demo.php
PHP Fatal error:  Call to a member function add() on a non-object in  [...]/autodoc/vendor/phpdocumentor/phpdocumentor/src/phpDocumentor/Descriptor/Builder/Reflector/AssemblerAbstract.php on line 49

In fact, it tries to make ->add() on the string "Other"…

@mvriel mvriel added the Bug label Jul 7, 2014
@mvriel mvriel added this to the 2.7 milestone Jul 7, 2014
@marcimat
Copy link
Contributor Author

marcimat commented Jul 7, 2014

A possible correction that seems to work (I'm not sure in fact ^^) : use the specific method setPackage() into the FunctionAssembler, as this is done in ClassAssembler.

diff --git a/src/phpDocumentor/Descriptor/Builder/Reflector/FunctionAssembler.php b/src/phpDocumentor/Descriptor/Builder/Reflector/FunctionAssembler.php
index d772043..01e057a 100644
--- a/src/phpDocumentor/Descriptor/Builder/Reflector/FunctionAssembler.php
+++ b/src/phpDocumentor/Descriptor/Builder/Reflector/FunctionAssembler.php
@@ -62,7 +62,7 @@ class FunctionAssembler extends AssemblerAbstract
         $descriptor->setFullyQualifiedStructuralElementName($reflector->getName() . '()');
         $descriptor->setName($reflector->getShortName());
         $descriptor->setLine($reflector->getLinenumber());
-        $descriptor->getTags()->set('package', $this->extractPackageFromDocBlock($reflector->getDocBlock()) ? : '');
+        $descriptor->setPackage($this->extractPackageFromDocBlock($reflector->getDocBlock()) ? : '');
         $descriptor->setNamespace($this->getFullyQualifiedNamespaceName($reflector));
     }

@mvriel
Copy link
Member

mvriel commented Jul 7, 2014

Actually setPackage is meant to be used with PackageDescriptor objects that are created later. This was a rather unfortunate choice of method naming :S

mvriel added a commit to mvriel/phpDocumentor2 that referenced this issue Jul 8, 2014
In a recent refactoring we removed all notion of string based tags
but put them in TagDescriptors. Apparently I missed a bit of handling
of the package tags and this caused fatal errors later due to typehints.
mvriel added a commit that referenced this issue Jul 8, 2014
#1330: Fix crash when assembling package tags
@mvriel
Copy link
Member

mvriel commented Jul 9, 2014

This issue is resolved in PR #1334 and will be included in a hotfix release this week

@mvriel
Copy link
Member

mvriel commented Jul 9, 2014

FYI: I just released the new version :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants