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

AbstractUnitObject.php (Line 542): Call to a member function getAttribute() on null #190

Closed
throup opened this issue Jan 7, 2015 · 14 comments

Comments

@throup
Copy link

throup commented Jan 7, 2015

Getting the following error when trying to generate documentation after clearing the cache.

phpDox 0.7.0-64-gd70cae2 - Copyright (C) 2010 - 2015 by Arne Blankerts

[07.01.2015 - 16:17:36] Using config file 'build/phpdox.xml'
[07.01.2015 - 16:17:36] Registered collector backend 'parser'
[07.01.2015 - 16:17:36] Registered enricher 'build'
[07.01.2015 - 16:17:36] Registered enricher 'git'
[07.01.2015 - 16:17:36] Registered enricher 'checkstyle'
[07.01.2015 - 16:17:36] Registered enricher 'phpcs'
[07.01.2015 - 16:17:36] Registered enricher 'pmd'
[07.01.2015 - 16:17:36] Registered enricher 'phpunit'
[07.01.2015 - 16:17:36] Registered enricher 'phploc'
[07.01.2015 - 16:17:36] Registered output engine 'xml'
[07.01.2015 - 16:17:36] Registered output engine 'html'
[07.01.2015 - 16:17:36] Starting to process project 'project'
[07.01.2015 - 16:17:36] Starting collector
[07.01.2015 - 16:17:36] Scanning directory '/var/lib/jenkins/workspace/project/build/..' for files to process

..................................................  [50]
..................................................  [100]
...............................                     [131]

[07.01.2015 - 16:17:46] Saving results to directory '/var/lib/jenkins/workspace/project/build/logs/phpdox/xml'
[07.01.2015 - 16:17:50] Resolving inheritance

............................................

Oups... phpDox encountered a problem and has terminated!

It most likely means you've found a bug, so please file a report for this
and paste the following details and the stacktrace (if given) along:

PHP Version: 5.6.4 (Linux)
PHPDox Version: 0.7.0-64-gd70cae2
ErrorException: E_ERROR 
Location: /var/lib/jenkins/workspace/project/vendor/theseer/phpdox/src/collector/project/AbstractUnitObject.php (Line 542)

Call to a member function getAttribute() on null

No stacktrace available

If I run phpdox again (now some caches exist) it compiles the documentation:

phpDox 0.7.0-64-gd70cae2 - Copyright (C) 2010 - 2015 by Arne Blankerts

[07.01.2015 - 16:23:05] Using config file 'build/phpdox.xml'
[07.01.2015 - 16:23:05] Registered collector backend 'parser'
[07.01.2015 - 16:23:05] Registered enricher 'build'
[07.01.2015 - 16:23:05] Registered enricher 'git'
[07.01.2015 - 16:23:05] Registered enricher 'checkstyle'
[07.01.2015 - 16:23:05] Registered enricher 'phpcs'
[07.01.2015 - 16:23:05] Registered enricher 'pmd'
[07.01.2015 - 16:23:05] Registered enricher 'phpunit'
[07.01.2015 - 16:23:05] Registered enricher 'phploc'
[07.01.2015 - 16:23:05] Registered output engine 'xml'
[07.01.2015 - 16:23:05] Registered output engine 'html'
[07.01.2015 - 16:23:05] Starting to process project 'project'
[07.01.2015 - 16:23:05] Starting collector
[07.01.2015 - 16:23:05] Scanning directory '/var/lib/jenkins/workspace/project/build/..' for files to process

cccccccccccccccccccccccccccccccccccccccccccccccccc  [50]
cccccccccccccccccccccccccccccccccccccccccccccccccc  [100]
ccccccccccccccccccccccccccccccc                     [131]

[07.01.2015 - 16:23:05] Saving results to directory '/var/lib/jenkins/workspace/project/build/logs/phpdox/xml'
[07.01.2015 - 16:23:05] Collector process completed

[07.01.2015 - 16:23:05] Starting generator
[07.01.2015 - 16:23:05] Loading enrichers
[07.01.2015 - 16:23:05] Enricher Build Information initialized successfully
[07.01.2015 - 16:23:05] Starting event loop.

..................................................  [50]
..................................................  [100]
..................................................  [150]
..................................................  [200]
..................................................  [250]
..................................................  [300]
..................................................  [350]
..................................................  [400]
..................................................  [450]
..................................................  [500]
..................................................  [550]
..................................................  [600]
..................................................  [650]
..................................................  [700]
..................................................  [750]
..................................................  [800]
..................................................  [850]
..................................................  [900]
..................................................  [950]
..................................................  [1000]
..................................................  [1050]
..................................................  [1100]
..................................................  [1150]
..................................................  [1200]
..................................................  [1250]
..................................................  [1300]
..................................................  [1350]
..................................................  [1400]
..................................................  [1450]
..................................................  [1500]
..................................................  [1550]
..................................................  [1600]
..................................................  [1650]
..................................................  [1700]
..................................................  [1750]
..................................................  [1800]
..................................................  [1850]
..................................................  [1900]
..................................................  [1950]
..................................................  [2000]
..................................................  [2050]
..................                                  [2068]

[07.01.2015 - 16:23:28] Generator process completed
[07.01.2015 - 16:23:28] Processing project 'project' completed.


Time: 23.49 seconds, Memory: 3.00Mb

However, the finished documentation does not include any content from the enrichers.

In case it is relevant, my config file:

<?xml version="1.0" encoding="utf-8" ?>
<phpdox xmlns="http://xml.phpdox.net/config" silent="false">
    <project name="project" source="${basedir}/.." workdir="${basedir}/logs/phpdox/xml">
        <collector publiconly="false" backend="parser">
            <include mask="*/application/**.php" />
            <include mask="*/library/**.php" />
            <exclude mask="*/tests/**" />
            <exclude mask="*/vendor/**" />
            <inheritance resolve="true"/>
        </collector>
        <generator output="${basedir}/docs">
            <enrich base="${basedir}/logs">
                <source type="build" />
                <source type="phploc" />
                <source type="git">
                    <git binary="/usr/bin/git" />
                    <history enabled="true" limit="15" cache="${phpDox.project.workdir}/gitlog.xml" />
                </source>
                <source type="phpcs">
                    <file name="phpcs.xml" />
                </source>
                <source type="pmd">
                    <file name="pmd.xml" />
                </source>
                <source type="phpunit">
                    <coverage path="phpunit/coverage" />
                    <filter directory="${phpDox.project.source}" />
                </source>
            </enrich>
            <build engine="html" enabled="true" output="phpdox">
                <template dir="${phpDox.home}/templates/html" />
                <file extension="xhtml" />
            </build>
        </generator>
    </project>
</phpdox>
@theseer theseer closed this as completed in 9ba205e Jan 7, 2015
@hackel
Copy link

hackel commented Feb 26, 2015

I am still experiencing this exact issue with phpDox 0.7.0-96-g4369b37. I confirmed that the fix is in place in this version. After running a second time, it works.

Oups... phpDox encountered a problem and has terminated!

It most likely means you've found a bug, so please file a report for this
and paste the following details and the stacktrace (if given) along:

PHP Version: 5.6.6-1+deb.sury.org~utopic+1 (Linux)
PHPDox Version: 0.7.0-96-g4369b37
ErrorException: E_ERROR 
Location: /home/hackel/dev/arcstone/quirks/vendor/theseer/phpdox/src/collector/project/AbstractUnitObject.php (Line 346)

Call to a member function setAttribute() on null

No stacktrace available

@theseer
Copy link
Owner

theseer commented Mar 5, 2015

It may look like it's the same issue and I agree it's the same type of problem but in this case it's a different line caused by a different (error) condition.

I'm a bit buffled as how you managed to get phpDox into that state though as I cannot come up with any way to trigger this problem. Would it be possible to provide a (simple?) testcase so I can reproduce and fix this?

@theseer
Copy link
Owner

theseer commented Mar 21, 2015

@ZyanKLee Would it be possible for you to provide me with a small testcase to reproduce this?

@ZyanKLee
Copy link

According to the error message phpdox ran through public function markDependencyAsUnresolved($dependency) and tried to $depNode->setAttribute('unresolved', 'true'); - but I could not find a hint, on which object this function was called. How can I find out?

The application that is parsed by phpdox in my case is closed source, so obviously I can't point you at some repository or else.

@theseer
Copy link
Owner

theseer commented Mar 23, 2015

Some unit of your application extends a class or implements an interface (or possibly uses a trait) where the definition of it cannot be found. That is unfortunate - since it will lead to an incomplete API documentation - but not a problem for phpDox. The purpose of the method the crash occurs in is to set a marker for easier processing (e.g. do not place a link when rendering html).

The crash occurs, because obviously the XPath query does not return any nodes. While the crash can easily be avoided by handling this condition, I really want to understand why that can happen first. And so far I failed to produce a test code that triggers this issue.

@theseer
Copy link
Owner

theseer commented Mar 23, 2015

Commit d18416c adds a new exception for this error condition with additional information that should make debugging this easier.

@ZyanKLee Could you run this against your code again and check whether or not you get a more meaningful output? The bug is of course not yet fixed, just the reporting changed.

@ZyanKLee
Copy link

ok, that seems a lot more helpfull ;)

No dependency "Symfony\Component\Security\Core\User\AdvancedUserInterface" found in unit Project-1\AuthBundle\Entity\User

though that file is present and the interface is declared in that file:

vendor/symfony/symfony/src/Symfony/Component/Security/Core/User/AdvancedUserInterface.php

I'll ask our devs to have a look at it, as well. Just to be sure, this is not an error in our app.

EDIT: Devs say, everything is fine - because we can log in ;)

@theseer
Copy link
Owner

theseer commented Mar 24, 2015

That error message is interesting as "Project-1" is syntactically invalid for a PHP Namespace. A namespace definition may not contain "-".

Can you provide me with the XML file generated for the unit "Project-1\AuthBundle\Entity\User"?
If needed, you may remove all methods in case they contain private information but please leave everything else untouched. If you do not want to provide this via a public board, feel free to directly mail it to me.

@theseer
Copy link
Owner

theseer commented Mar 24, 2015

On related note: The fact your code works doesn't mean that the API documentation has knowledge of the interface. Actually, the very fact you get the error message shows that phpDox cannot resolve the interface Symfony\Component\Security\Core\User\AdvancedUserInterface.
This actually makes some sense as you probably do not include the vendor/ directory for phpDox' processing.

@ZyanKLee
Copy link

ahh, yes. that "Project-1"-thing is a search'n'replace error by me. I replaced the project related facts by replacing them with the placeholder "project-1". In fact this were two uppercase letters, i.e. AB..

Perhaps you can help us with the config. Our phpdox.xml is at "the other bug": #209 (comment)

@theseer
Copy link
Owner

theseer commented Apr 9, 2015

@ZyanKLee: Can you please provide me with the XML file generated for the unit "Project-1\AuthBundle\Entity\User"? Freel free to strip all methods and properties from it. You can send it to my email account.

theseer added a commit that referenced this issue Apr 13, 2015
theseer added a commit that referenced this issue Apr 13, 2015
@theseer
Copy link
Owner

theseer commented Apr 13, 2015

I think I found the reason for this issue.
Could you please verify if the patch fixes the problem for your code base as well?

@ZyanKLee
Copy link

latest master worked for me. thanks for the effort!

@theseer
Copy link
Owner

theseer commented Apr 16, 2015

Thank you for the update. I consider this issue fixed then.

@theseer theseer closed this as completed Apr 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants