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

Error: addMethod() on null - PHP 7.4 | PHPDox 0.12.0-dev #420

Open
Tanktiger opened this issue Sep 26, 2022 · 3 comments
Open

Error: addMethod() on null - PHP 7.4 | PHPDox 0.12.0-dev #420

Tanktiger opened this issue Sep 26, 2022 · 3 comments

Comments

@Tanktiger
Copy link

Tanktiger commented Sep 26, 2022

Hello,

i want to generate the documentation for my phalcon PHP code. It worked for several years but now i'm getting this error:

phpDox 0.12.0-dev - Copyright (C) 2010 - 2022 by Arne Blankerts and Contributors

[26.09.2022 - 13:00:00] Using config file 'tests/build/phpdox.xml'
[26.09.2022 - 13:00:00] Registered collector backend 'parser'
[26.09.2022 - 13:00:00] Registered enricher 'build'
[26.09.2022 - 13:00:00] Registered enricher 'git'
[26.09.2022 - 13:00:00] Registered enricher 'checkstyle'
[26.09.2022 - 13:00:00] Registered enricher 'phpcs'
[26.09.2022 - 13:00:00] Registered enricher 'pmd'
[26.09.2022 - 13:00:00] Registered enricher 'phpunit'
[26.09.2022 - 13:00:00] Registered enricher 'phploc'
[26.09.2022 - 13:00:00] Registered output engine 'xml'
[26.09.2022 - 13:00:00] Registered output engine 'html'
[26.09.2022 - 13:00:00] Starting to process project 'platform'
[26.09.2022 - 13:00:00] Starting collector
[26.09.2022 - 13:00:00] Scanning directory '.' for files to process

..................................................      [50]
..................................................      [100]
..................................................      [150]
................................................f.      [200]
...............................................f.f      [250]
..................................................      [300]
..................................................      [350]
..................................................      [400]
..................................................      [450]
..................................................      [500]
..................................................      [550]
.........................f........................      [600]
..................................................      [650]
..................................................      [700]
..................................................      [750]
..................................................      [800]
..................................................      [850]
..................................................      [900]
............

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: 7.4.28 (Linux)
PHPDox Version: 0.12.0-dev
Exception: Error (Code: 0)
Location: /var/www/vendor/theseer/phpdox/src/collector/backend/parser/UnitCollectingVisitor.php (Line 228)

Call to a member function addMethod() on null

#0 /var/www/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(200): TheSeer\phpDox\Collector\Backend\UnitCollectingVisitor->enterNode()
#1 /var/www/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(114): PhpParser\NodeTraverser->traverseArray()
#2 /var/www/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(223): PhpParser\NodeTraverser->traverseNode()
#3 /var/www/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(114): PhpParser\NodeTraverser->traverseArray()
#4 /var/www/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(223): PhpParser\NodeTraverser->traverseNode()
#5 /var/www/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(91): PhpParser\NodeTraverser->traverseArray()
#6 /var/www/vendor/theseer/phpdox/src/collector/backend/parser/PHPParser.php(44): PhpParser\NodeTraverser->traverse()
#7 /var/www/vendor/theseer/phpdox/src/collector/Collector.php(101): TheSeer\phpDox\Collector\Backend\PHPParser->parse()
#8 /var/www/vendor/theseer/phpdox/src/collector/Collector.php(71): TheSeer\phpDox\Collector\Collector->processFile()
#9 /var/www/vendor/theseer/phpdox/src/Application.php(88): TheSeer\phpDox\Collector\Collector->run()
#10 /var/www/vendor/theseer/phpdox/src/CLI.php(120): TheSeer\phpDox\Application->runCollector()
#11 /var/www/vendor/bin/phpdox(21) : eval()'d code(67): TheSeer\phpDox\CLI->run()
#12 /var/www/vendor/bin/phpdox(21): eval()

My XML:

<?xml version="1.0" encoding="utf-8" ?>
<phpdox xmlns="http://xml.phpdox.net/config">
    <project name="platform" source="./" workdir="${basedir}/xml">
        <collector backend="parser">
            <exclude mask="**/vendor/**"/>
        </collector>
        <generator output="${basedir}">
            <build engine="html" output="html"/>
            <enrich base="${basedir}/logs">
                <source type="phploc">
                    <file name="phploc.xml"/>
                </source>

                <source type="phpcs">
                    <file name="checkstyle.xml"/>
                </source>

                <source type="pmd">
                    <file name="pmd.xml"/>
                </source>
            </enrich>
        </generator>
    </project>
</phpdox>

PHPDox is installed via composer and xdebug is installed in version 2.9.8

Does someone know how to fix this issue?

@theseer
Copy link
Owner

theseer commented Sep 27, 2022

I'll try to have a look tomorrow when travelling.

@Tanktiger
Copy link
Author

Hello,
the problem was in a PHPUnit Test class. I don't know why this error is occuring but i removed the class and everything worked.

Here is the class and the problem occurs in the function testDatabaseUtilsGetInstalledMigrationVersion2

<?php

namespace Library\Tests;

use Codeception\PHPUnit\TestCase;
use Library\Helper\Converter;
use Library\Helper\DatabaseUtils;
use Library\Helper\Generator;
use Library\Helper\Hashing;
use Library\Helper\Validator;
use Library\Helper\VersionHelper;

class HelperTest extends TestCase
{
    public function testConverter()
    {
        $this->assertEquals("Test", Converter::firstLetterUp("test"));
        $this->assertEquals("Test", Converter::firstLetterUp("TEST"));
        $this->assertEquals("Test3", Converter::firstLetterUp("TesT3"));

        $this->assertEquals(61445, Converter::hexStringToInteger("F005"));
        $this->assertEquals(61444, Converter::hexStringToInteger("F004"));
        $this->assertEquals(0, Converter::hexStringToInteger("00"));
        $this->assertEquals(4294967295, Converter::hexStringToInteger("FFFFFFFF"));

    }

    public function testGenerator()
    {
        $generated = Generator::uniqueString(4);
        $generated2 = Generator::uniqueString(32);
        $this->assertFalse($generated === $generated2);
        $this->assertEquals(4, strlen($generated));
        $this->assertEquals(32, strlen($generated2));
    }

    public function testHashing()
    {
        $hashedPW = Hashing::hashPassword("test");

        $this->assertTrue(Hashing::verifyPassword("test", $hashedPW));
        $this->assertfalse(Hashing::verifyPassword("test2", $hashedPW));
        $this->assertfalse(Hashing::verifyPassword($hashedPW, "test"));
    }

    public function testValidator()
    {
        $this->assertTrue(Validator::isValidMAC("00:00:00:00:00:00"));
        $this->assertTrue(Validator::isValidMAC("AF:FE:AF:FE:AF:FE"));
        $this->assertTrue(Validator::isValidMAC("01:23:45:67:89:0A"));
        $this->assertTrue(Validator::isValidMAC("BC:CD:DE:EF:FF:11"));
        $this->assertTrue(Validator::isValidMAC("01:23:45:67:89:0a"));
        $this->assertTrue(Validator::isValidMAC("bc:cd:de:ef:ff:11"));
        $this->assertfalse(Validator::isValidMAC("00:00:00:00:00:g0"));
        $this->assertfalse(Validator::isValidMAC("00:00:00:00:00:G0"));
        $this->assertfalse(Validator::isValidMAC("00:00:00:00:00G0"));
        $this->assertfalse(Validator::isValidMAC("00:00:00:00:0010"));
        $this->assertfalse(Validator::isValidMAC("00:00:00:00:00: 0"));
        $this->assertfalse(Validator::isValidMAC("000000000000"));
    }

    /**
     * @runInSeparateProcess
     * @preserveGlobalState disabled
     */
    public function testDatabaseUtilsGetInstalledMigrationVersion2()
    {
        $mock = \Mockery::mock("overload:\\App\\Core\\Models\\SharedMigration");
        $mock->shouldReceive('tableExists')
            ->once()
            ->andReturn(false);

        $migratedVersion = DatabaseUtils::getInstalledMigrationVersion();
        $this->assertNull($migratedVersion);
    }

    /**
     * @runInSeparateProcess
     * @preserveGlobalState disabled
     */
    public function testDatabaseUtilsGetInstalledMigrationVersion3()
    {
        $mock = \Mockery::mock("overload:\\App\\Core\\Models\\SharedMigration");
        $mock->shouldReceive('tableExists')
            ->once()
            ->andReturn(true);
        $mock->shouldReceive('findFirst')
            ->once()
            ->andReturn(false);

        $migratedVersion = DatabaseUtils::getInstalledMigrationVersion();
        $this->assertNull($migratedVersion);
    }
}

@theseer
Copy link
Owner

theseer commented Sep 28, 2022

Thanks for the heads up :)

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

2 participants