phpDocumentor / ReflectionDocBlock

MIT License
9.34k stars 121 forks source link

Not reporting anymore as much parameters for functions #352

Closed williamdes closed 8 months ago

williamdes commented 1 year ago
1) Doctum\Tests\Parser\NodeVisitorTest::testUpdateMethodParametersFromTags
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
 Array &0 (
     0 => 'The "param2" parameter of the method "fun1" is missing a @param tag'
-    1 => 'The method "fun1" has "5" @param tags but only "2" where expected.'
 )

/home/runner/work/doctum/doctum/tests/Parser/NodeVisitorTest.php:402

2) Doctum\Tests\Parser\NodeVisitorTest::testUpdateMethodParametersFromInvalidTags
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
 Array &0 (
     0 => 'The "param2" parameter of the method "fun1" is missing a @param tag'
-    1 => 'The method "fun1" has "6" @param tags but only "2" where expected.'
-    2 => 'The method "fun1" has "1" invalid @param tags.'
-    3 => 'Invalid @param tag on "fun1": "array[\Illuminate\Notifications\Channels\Notification]  $notification"'
+    1 => 'The method "fun1" has "3" @param tags but only "2" where expected.'
 )

/home/runner/work/doctum/doctum/tests/Parser/NodeVisitorTest.php:483

3) Doctum\Tests\Parser\NodeVisitorTest::testUpdateMethodParametersFromInvalidTagsReport
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
-Array &0 (
-    0 => 'The "notification" parameter of the method "fun1" is missing a @param tag'
-    1 => 'The method "fun1" has "1" invalid @param tags.'
-    2 => 'Invalid @param tag on "fun1": "array[\Illuminate\Notifications\Channels\Notification]  $notification"'
-)
+Array &0 ()

/home/runner/work/doctum/doctum/tests/Parser/NodeVisitorTest.php:520

FAILURES!
Tests: 177, Assertions: [36](https://github.com/code-lts/doctum/actions/runs/4397526274/jobs/7700727629#step:7:37)0, Failures: 3.

    /**
     * @see NodeVisitor::updateMethodParametersFromTags
     */
    public function testUpdateMethodParametersFromTags(): void
    {
        $parserContext  = new ParserContext(new TrueFilter(), new DocBlockParser(), new Standard());
        $docBlockParser = new DocBlockParser();
        $docBlockNode   = $docBlockParser->parse(
            '/**' . "\n"
            . '* @param type1 $param1 Description' . "\n"
            . '* @param $param8 Description 4' . "\n"
            . '* @param $param9' . "\n"
            . '* @param foo' . "\n"
            . '* @param type1 $param4 Description 4' . "\n"
            . '**/' . "\n",
            $parserContext
        );

        $visitor  = new NodeVisitor($parserContext);
        $function = new FunctionReflection('fun1', 0);

        $param1 = (new ParameterReflection('param1', 0));
        $param1->setHint('array');
        $function->addParameter($param1);

        $param2 = (new ParameterReflection('param2', 0));
        $function->addParameter($param2);

        $this->assertSame(
            [
                'The "param2" parameter of the method "fun1" is missing a @param tag',
                'The method "fun1" has "5" @param tags but only "2" where expected.',
            ],
            $this->callMethod(
                $visitor,
                'updateMethodParametersFromTags',
                [
                $function,
                $docBlockNode->getTag('param'),
                ]
            )
        );
    }

    /**
     * @see NodeVisitor::updateMethodParametersFromTags
     */
    public function testUpdateMethodParametersFromInvalidTags(): void
    {
        $parserContext  = new ParserContext(new TrueFilter(), new DocBlockParser(), new Standard());
        $docBlockParser = new DocBlockParser();
        $docBlockNode   = $docBlockParser->parse(
            '/**' . "\n"
            . '* @param type1 $param1 Description' . "\n"
            . '* @param $param8 Description 4' . "\n"
            . '* @param $param9' . "\n"
            . '* @param foo' . "\n"
            . '* @param type1 $param4 Description 4' . "\n"
            . '* @param array[\Illuminate\Notifications\Channels\Notification]  $notification' . "\n"
            . '**/' . "\n",
            $parserContext
        );

        $visitor  = new NodeVisitor($parserContext);
        $function = new FunctionReflection('fun1', 0);

        $param1 = (new ParameterReflection('param1', 0));
        $param1->setHint('array');
        $function->addParameter($param1);

        $param2 = (new ParameterReflection('param2', 0));
        $function->addParameter($param2);

        $this->assertSame(
            [
                'The "param2" parameter of the method "fun1" is missing a @param tag',
                'The method "fun1" has "6" @param tags but only "2" where expected.',
                'The method "fun1" has "1" invalid @param tags.',
                'Invalid @param tag on "fun1": "array[\Illuminate\Notifications\Channels\Notification]  $notification"',
            ],
            $this->callMethod(
                $visitor,
                'updateMethodParametersFromTags',
                [
                $function,
                $docBlockNode->getTag('param'),
                ]
            )
        );
    }
williamdes commented 1 year ago

Hi @jaapio

I am looking forward to having Doctum migrate to the new phpstan parser version What can be done for this issue and for me to be able to finish implementing your new version?

jaapio commented 1 year ago

Hi,

I shifted my focus with phpDocumentor towards other features. As I'm just working on the project when I have time I have to choose what comes first. The regressions in this library are hard to fix and I needed some fixes in phpstan to solve this, but they are not accepting my changes because it does not add anything for them.

This means basically that we have to accept the regressions or do some manual parsing again to fix the issues. That takes time, which I do not have unlimited.