theseer / phpdox

Documentation generator for PHP Code using standard technology (SRC, DOCBLOCK, XML and XSLT)
http://phpdox.de
Other
599 stars 121 forks source link

phpunit enricher errors #169

Closed temp closed 10 years ago

temp commented 10 years ago

Working on my own project I got a lot of errors using the phpunit enricher. I cloned phpdox and tried it with your project, same result.

My steps:

  1. call phpunit
  2. call phpdox

Which resulted in hundreds of the following errors:

[28.10.2014 - 10:57:09] Enricher PHPUnit Coverage XML initialized successfully
[28.10.2014 - 10:57:09] Starting event loop.

....xmlXPathCompOpEval: function translate not found
XPath error : Unregistered function
xmlXPathCompiledEval: 2 objects left on the stack.
...xmlXPathCompOpEval: function translate not found
XPath error : Unregistered function
xmlXPathCompiledEval: 2 objects left on the stack.
.xmlXPathCompOpEval: function translate not found
XPath error : Unregistered function
xmlXPathCompiledEval: 2 objects left on the stack.
.xmlXPathCompOpEval: function translate not found
XPath error : Unregistered function
...
theseer commented 10 years ago

This is a very bizarre error as the function "translate" which is claimed to be missing is a standard xpath feature that as far as I know cannot even be disabled or removed (- at least not from within PHP and without patching libxml).

What OS are you operating under and what LibXML- and LibXSLT-Versions are you using?

temp commented 10 years ago

I'm using php 5.5.18 from macports on Mac OS X Yosemite.

Here are the relevant exceprts from php -i:

libxml

libXML support => active
libXML Compiled Version => 2.9.2
libXML Loaded Version => 20902
libXML streams => enabled

xsl

XSL => enabled
libxslt Version => 1.1.28
libxslt compiled against libxml Version => 2.9.1
EXSLT => enabled
libexslt Version => 1.1.28
theseer commented 10 years ago

@belanur Since I don't have a mac, would you have a chance to verify that for me?

sebastianheuer commented 10 years ago

Sure, I will have a look tonight.

sebastianheuer commented 10 years ago

Can't reproduce the reported issue with PHP 5.5.15 (installed via MacPorts) on Yosemite. Using the current master of phpdox the output looks fine:

$ phpunit
PHPUnit 4.2.2 by Sebastian Bergmann.

Configuration read from /Users/sebastian/projects/phpdoxtest/phpunit.xml.dist

.

Time: 180 ms, Memory: 7.75Mb

OK (1 test, 1 assertion)

Generating code coverage report in PHPUnit XML format ... done
$ phpdox
phpDox 0.6.6 - Copyright (C) 2010 - 2014 by Arne Blankerts

[28.10.2014 - 17:56:12] Using config file './phpdox.xml'
[28.10.2014 - 17:56:12] Registered enricher 'build'
[28.10.2014 - 17:56:12] Registered enricher 'git'
[28.10.2014 - 17:56:12] Registered enricher 'checkstyle'
[28.10.2014 - 17:56:12] Registered enricher 'pmd'
[28.10.2014 - 17:56:12] Registered enricher 'phpunit'
[28.10.2014 - 17:56:12] Registered enricher 'phploc'
[28.10.2014 - 17:56:12] Registered output engine 'xml'
[28.10.2014 - 17:56:12] Registered output engine 'html'
[28.10.2014 - 17:56:12] Starting to process project 'phpdox'
[28.10.2014 - 17:56:12] Starting collector
[28.10.2014 - 17:56:12] Scanning directory './src' for files to process

c                                                   [1]

[28.10.2014 - 17:56:12] Saving results to directory './build/phpdox/xml'
[28.10.2014 - 17:56:12] Collector process completed

[28.10.2014 - 17:56:12] Starting generator
[28.10.2014 - 17:56:12] Loading enrichers
[28.10.2014 - 17:56:12] Enricher Build Information initialized successfully
[28.10.2014 - 17:56:12] Enricher PHPUnit Coverage XML initialized successfully
[28.10.2014 - 17:56:12] Starting event loop.

...............                                     [15]

[28.10.2014 - 17:56:12] Generator process completed
[28.10.2014 - 17:56:12] Processing project 'phpdox' completed.

Time: 0 seconds, Memory: 3.25Mb

Apparently my libxml version is slightly lower:

$ php -i | grep xslt
libxslt Version => 1.1.28
libxslt compiled against libxml Version => 2.9.1
libexslt Version => 1.1.28

@theseer : could this be a namespace-related problem? If translate() was not available at all, there would be more errors throughout the whole generation process, not only within the PHPUnit enricher.

temp commented 10 years ago

@belanur are your sure you're using the current master? In your log it says:

$ phpdox
phpDox 0.6.6 - Copyright (C) 2010 - 2014 by Arne Blankerts

On my call it says:

$ phpdox
phpDox %development% - Copyright (C) 2010 - 2014 by Arne Blankerts

I installed phpdox via composer:

$ c global show --installed | grep theseer
theseer/directoryscanner               1.3.0              A recursive [...]
theseer/fdomdocument                   1.6.0              The classes [...]
theseer/fxsl                           1.1.0              An XSL [...]
theseer/phpdox                         0.7.0              A fast [...]
sebastianheuer commented 10 years ago

@temp I copied the wrong output, sorry about that. Here is the output of the master cloned directly from github:

$ ../phpdox/composer/bin/phpdox
phpDox 0.7.0-22-g96317ac - Copyright (C) 2010 - 2014 by Arne Blankerts

[29.10.2014 - 10:44:52] Using config file './phpdox.xml'
[29.10.2014 - 10:44:52] Registered collector backend 'parser'
[29.10.2014 - 10:44:52] Registered enricher 'build'
[29.10.2014 - 10:44:52] Registered enricher 'git'
[29.10.2014 - 10:44:52] Registered enricher 'checkstyle'
[29.10.2014 - 10:44:52] Registered enricher 'phpcs'
[29.10.2014 - 10:44:52] Registered enricher 'pmd'
[29.10.2014 - 10:44:52] Registered enricher 'phpunit'
[29.10.2014 - 10:44:52] Registered enricher 'phploc'
[29.10.2014 - 10:44:52] Registered output engine 'xml'
[29.10.2014 - 10:44:52] Registered output engine 'html'
[29.10.2014 - 10:44:52] Starting to process project 'phpdox'
[29.10.2014 - 10:44:52] Starting collector
[29.10.2014 - 10:44:52] Scanning directory './src' for files to process

c                                                   [1]

[29.10.2014 - 10:44:52] Saving results to directory '/Users/sebastian/projects/wiese/phpdoxtest/build/phpdox/xml'
[29.10.2014 - 10:44:52] Collector process completed

[29.10.2014 - 10:44:52] Starting generator
[29.10.2014 - 10:44:52] Loading enrichers
[29.10.2014 - 10:44:52] Enricher Build Information initialized successfully
[29.10.2014 - 10:44:52] Enricher PHPUnit Coverage XML initialized successfully
[29.10.2014 - 10:44:52] Starting event loop.

.................                                   [17]

[29.10.2014 - 10:44:52] Generator process completed
[29.10.2014 - 10:44:52] Processing project 'phpdox' completed.

Time: 300 ms, Memory: 2.75Mb
temp commented 10 years ago

Weird. Might this be an incompatible change in libxml, since your version is lower? I'm seeing xml-related errors in pdepend now, as well.

Warning: DOMNode::cloneNode(): ID jdepend.bad already defined in /Users/swentz/.composer/vendor/pdepend/pdepend/src/main/php/PDepend/Report/Jdepend/Chart.php on line 202
...
Warning: DOMNode::cloneNode(): ID jdepend.legend already defined in /Users/swentz/.composer/vendor/pdepend/pdepend/src/main/php/PDepend/Report/Jdepend/Chart.php on line 225
...
theseer commented 10 years ago

I fail to reproduce this even with LibXML 2.9.2 installed:

$ xmllint --version
xmllint: using libxml version 20902
   compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 FTP HTTP DTDValid HTML Legacy C14N Catalog XPath XPointer XInclude Iconv ISO8859X Unicode Regexps Automata Expr Schemas Schematron Modules Debug Zlib Lzma 
$ xsltproc --version
Using libxml 20902, libxslt 10128 and libexslt 817
xsltproc was compiled against libxml 20901, libxslt 10128 and libexslt 817
libxslt 10128 was compiled against libxml 20901
libexslt 817 was compiled against libxml 20901

Same version difference here (read: compiled against 2.9.1)

Since phpDox works for me with those lib versions, i also hacked two small testcases:

PHP

<?php
error_reporting(-1);
$dom = new DOMDocument();
$dom->loadXML('<?xml version="1.0" ?><ns:woot xmlns:ns="x:n" />');

$tpl = new DOMDocument();
$tpl->loadXML('<?xml version="1.0" ?>' .
    '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">' .
    '<xsl:template match="/">' .
    ' <r><xsl:value-of select="translate(\'woot\',\'o\',\'0\')" /></r>' .
    '</xsl:template>' .
    '</xsl:stylesheet>'
    );

$xsl = new XSLTProcessor();
$xsl->importStylesheet($tpl);
echo $xsl->transformToXML($dom);
$php testcase.php
<?xml version="1.0"?>
<r>w00t</r>

XSLTProc

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <r><xsl:value-of select="translate('woot','o','0')" /></r>
    </xsl:template>
</xsl:stylesheet>
<?xml version="1.0" ?>
<ns:woot xmlns:ns="x:n" />
$ xsltproc template.xsl demo.xml 
<?xml version="1.0"?>
<r>w00t</r>

Can you verify if the results are the same for you?

temp commented 10 years ago

Here we go:

$ php testcase.php
xmlXPathCompOpEval: function translate not found
XPath error : Unregistered function
xmlXPathCompiledEval: 2 objects left on the stack.
runtime error: file /Users/swentz/ line 1 element value-of
XPath evaluation returned no result.
<?xml version="1.0"?>
<r/>
$ xsltproc template.xsl demo.xml
<?xml version="1.0"?>
<r>w00t</r>
temp commented 10 years ago

Just checked it out with php-5.6, from macports, with the same extensions, and same xml/xsl lib versions, and it works fine. Both phpdox and your testcase.

theseer commented 10 years ago

Interesting results...

The fact the cli testcase using xsltproc works, shows that within libxslt/libxml2 the function is there and working as expected. Only the PHP binding seems to have issues. Issues, I cannot reproduce on my linux system here even if i go down to 5.5.18.

You could use my small PHP testcase and file a bug with macports as this wouldn't be phpDox specific but more of a general problem. Maybe they can reproduce it and supply a fix.

From phpDox' perspective, this seems to be a problem with your PHP environment and so far I don't see what I could do to mitigate it. Thus, I'll be closing this issue.

temp commented 10 years ago

Agreed, since I can use it with php-5.6. Thanks!