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

Not reporting anymore as much parameters for functions #352

Closed
williamdes opened this issue Mar 12, 2023 · 2 comments · Fixed by #360
Closed

Not reporting anymore as much parameters for functions #352

williamdes opened this issue Mar 12, 2023 · 2 comments · Fixed by #360

Comments

@williamdes
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Member

jaapio commented Oct 12, 2023

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.

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

Successfully merging a pull request may close this issue.

2 participants