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

Many syntax errors with v4.0.0 after using vimeo/psalm on php7.4 #67

Closed
Tomanhez opened this issue Dec 31, 2020 · 7 comments
Closed

Many syntax errors with v4.0.0 after using vimeo/psalm on php7.4 #67

Tomanhez opened this issue Dec 31, 2020 · 7 comments
Assignees

Comments

@Tomanhez
Copy link

Tomanhez commented Dec 31, 2020

v4.0.0 creates those enigmatic bugs on php7.4 after run vendor/bin/psalm --show-info=false:
I tested it on psalm 4.1, 4.2 and 4.3. Every cases are the same:

Error: Syntax error, unexpected T_STRING, expecting T_PAAMAYIM_NEKUDOTAYIM on line 480
Error: Syntax error, unexpected T_VARIABLE, expecting ')' on line 480
Error: Syntax error, unexpected ')' on line 481
Error: Syntax error, unexpected T_STRING, expecting T_PAAMAYIM_NEKUDOTAYIM on line 495
Error: Syntax error, unexpected T_VARIABLE, expecting ')' on line 495
Error: Syntax error, unexpected ')' on line 496
Error: Syntax error, unexpected T_STRING, expecting T_PAAMAYIM_NEKUDOTAYIM on line 59
Error: Syntax error, unexpected T_VARIABLE, expecting ')' on line 59
Error: Syntax error, unexpected ',' on line 59
Error: Syntax error, unexpected ')' on line 63
Error: Syntax error, unexpected T_STRING, expecting T_PAAMAYIM_NEKUDOTAYIM on line 105
Error: Syntax error, unexpected T_VARIABLE, expecting ')' on line 105
Error: Syntax error, unexpected ')' on line 107
Error: Syntax error, unexpected T_VARIABLE, expecting ')' on line 161
Error: Syntax error, unexpected ',' on line 161
Error: Syntax error, unexpected ')' on line 163
Error: Syntax error, unexpected T_VARIABLE, expecting ')' on line 185
Error: Syntax error, unexpected ',' on line 185
Error: Syntax error, unexpected ')' on line 187
Error: Syntax error, unexpected T_STRING, expecting T_PAAMAYIM_NEKUDOTAYIM on line 161
Error: Syntax error, unexpected T_VARIABLE, expecting ')' on line 161
Error: Syntax error, unexpected ')' on line 161
Error: Process completed with exit code 1.

It occured in Sylius:
Screenshot 2020-12-30 at 20 27 52

@Tomanhez Tomanhez added the Bug Something isn't working label Dec 31, 2020
@Ocramius
Copy link
Member

Can you link a build? We test this component against 7.4 and 8.0, and besides some test fixtures, no PHP 8 syntax should be involved

@froschdesign
Copy link
Member

I think this one: https://github.com/Sylius/Sylius/runs/1629735084?check_suite_focus=true

@Tomanhez
Copy link
Author

Return to v3.5.1 fixed the problem: Sylius/Sylius#12214

@franmomu
Copy link

franmomu commented Jan 3, 2021

If it helps, here another one: https://github.com/sonata-project/sonata-doctrine-extensions/pull/281/checks?check_run_id=1638983910

I have no idea, but looks like static fn is always involved, these are the errors:

vendor/bin/psalm --no-cache
Scanning files...
Analyzing files...

░░░░░░░░░░░░░░░░░░░░░░░░░░░

ERROR: ParseError - vendor/laminas/laminas-code/src/Generator/ClassGenerator.php:480:20 - Syntax error, unexpected T_STRING, expecting T_PAAMAYIM_NEKUDOTAYIM on line 480 (see https://psalm.dev/173)
            static fn (TypeGenerator $interface): bool => $interfaceType->equals($interface)


ERROR: ParseError - vendor/laminas/laminas-code/src/Generator/ClassGenerator.php:480:38 - Syntax error, unexpected T_VARIABLE, expecting ')' on line 480 (see https://psalm.dev/173)
            static fn (TypeGenerator $interface): bool => $interfaceType->equals($interface)


ERROR: ParseError - vendor/laminas/laminas-code/src/Generator/ClassGenerator.php:481:9 - Syntax error, unexpected ')' on line 481 (see https://psalm.dev/173)
        );


ERROR: ParseError - vendor/laminas/laminas-code/src/Generator/ClassGenerator.php:495:20 - Syntax error, unexpected T_STRING, expecting T_PAAMAYIM_NEKUDOTAYIM on line 495 (see https://psalm.dev/173)
            static fn (TypeGenerator $interface): bool => ! $interfaceType->equals($interface)


ERROR: ParseError - vendor/laminas/laminas-code/src/Generator/ClassGenerator.php:495:38 - Syntax error, unexpected T_VARIABLE, expecting ')' on line 495 (see https://psalm.dev/173)
            static fn (TypeGenerator $interface): bool => ! $interfaceType->equals($interface)


ERROR: ParseError - vendor/laminas/laminas-code/src/Generator/ClassGenerator.php:496:9 - Syntax error, unexpected ')' on line 496 (see https://psalm.dev/173)
        );


ERROR: ParseError - vendor/laminas/laminas-code/src/Generator/TypeGenerator.php:59:24 - Syntax error, unexpected T_STRING, expecting T_PAAMAYIM_NEKUDOTAYIM on line 59 (see https://psalm.dev/173)
                static fn(ReflectionNamedType $type): string => self::reflectionNamedTypeToString($type, $currentClass),


ERROR: ParseError - vendor/laminas/laminas-code/src/Generator/TypeGenerator.php:59:47 - Syntax error, unexpected T_VARIABLE, expecting ')' on line 59 (see https://psalm.dev/173)
                static fn(ReflectionNamedType $type): string => self::reflectionNamedTypeToString($type, $currentClass),


ERROR: ParseError - vendor/laminas/laminas-code/src/Generator/TypeGenerator.php:59:120 - Syntax error, unexpected ',' on line 59 (see https://psalm.dev/173)
                static fn(ReflectionNamedType $type): string => self::reflectionNamedTypeToString($type, $currentClass),


ERROR: ParseError - vendor/laminas/laminas-code/src/Generator/TypeGenerator.php:63:13 - Syntax error, unexpected ')' on line 63 (see https://psalm.dev/173)
            )


ERROR: ParseError - vendor/laminas/laminas-code/src/Generator/TypeGenerator.php:105:20 - Syntax error, unexpected T_STRING, expecting T_PAAMAYIM_NEKUDOTAYIM on line 105 (see https://psalm.dev/173)
            static fn(AtomicType $left, AtomicType $right): int


ERROR: ParseError - vendor/laminas/laminas-code/src/Generator/TypeGenerator.php:105:34 - Syntax error, unexpected T_VARIABLE, expecting ')' on line 105 (see https://psalm.dev/173)
            static fn(AtomicType $left, AtomicType $right): int


ERROR: ParseError - vendor/laminas/laminas-code/src/Generator/TypeGenerator.php:107:9 - Syntax error, unexpected ')' on line 107 (see https://psalm.dev/173)
        );


ERROR: ParseError - vendor/laminas/laminas-code/src/Generator/TypeGenerator.php:161:27 - Syntax error, unexpected T_VARIABLE, expecting ')' on line 161 (see https://psalm.dev/173)
            fn(AtomicType $type): string => $type->fullyQualifiedName(),


ERROR: ParseError - vendor/laminas/laminas-code/src/Generator/TypeGenerator.php:161:72 - Syntax error, unexpected ',' on line 161 (see https://psalm.dev/173)
            fn(AtomicType $type): string => $type->fullyQualifiedName(),


ERROR: ParseError - vendor/laminas/laminas-code/src/Generator/TypeGenerator.php:163:9 - Syntax error, unexpected ')' on line 163 (see https://psalm.dev/173)
        );


ERROR: ParseError - vendor/laminas/laminas-code/src/Generator/TypeGenerator.php:185:27 - Syntax error, unexpected T_VARIABLE, expecting ')' on line 185 (see https://psalm.dev/173)
            fn(AtomicType $type): string => $type->type,


ERROR: ParseError - vendor/laminas/laminas-code/src/Generator/TypeGenerator.php:185:56 - Syntax error, unexpected ',' on line 185 (see https://psalm.dev/173)
            fn(AtomicType $type): string => $type->type,


ERROR: ParseError - vendor/laminas/laminas-code/src/Generator/TypeGenerator.php:187:9 - Syntax error, unexpected ')' on line 187 (see https://psalm.dev/173)
        ));


ERROR: ParseError - vendor/laminas/laminas-code/src/Generator/TypeGenerator/AtomicType.php:161:49 - Syntax error, unexpected T_STRING, expecting T_PAAMAYIM_NEKUDOTAYIM on line 161 (see https://psalm.dev/173)
            [] === array_filter($others, static fn (self $type): bool => ! $type->requiresUnionWithStandaloneType())


ERROR: ParseError - vendor/laminas/laminas-code/src/Generator/TypeGenerator/AtomicType.php:161:58 - Syntax error, unexpected T_VARIABLE, expecting ')' on line 161 (see https://psalm.dev/173)
            [] === array_filter($others, static fn (self $type): bool => ! $type->requiresUnionWithStandaloneType())


ERROR: ParseError - vendor/laminas/laminas-code/src/Generator/TypeGenerator/AtomicType.php:161:116 - Syntax error, unexpected ')' on line 161 (see https://psalm.dev/173)
            [] === array_filter($others, static fn (self $type): bool => ! $type->requiresUnionWithStandaloneType())


------------------------------
22 errors found
------------------------------

@Ocramius
Copy link
Member

Ocramius commented Jan 3, 2021

Right, so static fn is indeed PHP 7.4+ syntax.

What I was thinking is that your environment has a very old version of nikic/php-parser (one of the dependencies of vimeo/psalm) installed, and therefore does not understand the syntax of PHP 7.4+. I checked the CI output and you are running with the latest vimeo/psalm and latest nikic/php-parser. You are also running everything on PHP 7.4+, so that shouldn't be a problem.

I wonder why it is the case for your CI though: it almost looks like the parser is running with old PHP version compat.

I run pretty much the same stuff here: https://github.com/Ocramius/ProxyManager/runs/1626964286

Perhaps this is related to nikic/PHP-Parser#690 (comment) deep.in vimeo/psalm?

As you can see, the same tooling and runtime tests verify that there is no syntax issue on PHP 7.4, so I suggest reporting an issue in vimeo/psalm to see if that can get us further in the investigation.

@franmomu
Copy link

franmomu commented Jan 3, 2021

It was easier than it looked like, so if the PHP version is not provided, Psalm infers the PHP version from composer.json and we have set 7.3 as the minimum.

Configuring PHP version in psalm to 7.4 fixes the issue, e.g. executing:

vendor/bin/psalm --php-version=7.4

@Ocramius
Copy link
Member

Ocramius commented Jan 3, 2021

Makes sense 👍

@Ocramius Ocramius closed this as completed Jan 3, 2021
@Ocramius Ocramius removed the Bug Something isn't working label Jan 3, 2021
@Ocramius Ocramius self-assigned this Jan 3, 2021
leofeyer added a commit to contao/contao that referenced this issue Jan 6, 2021
Description
-----------

This should restore compatibility with laminas/laminas-code (see laminas/laminas-code#67).

Commits
-------

245b5da Fix the Psalm configuration
AlexejKossmann pushed a commit to AlexejKossmann/contao that referenced this issue Apr 6, 2021
Description
-----------

This should restore compatibility with laminas/laminas-code (see laminas/laminas-code#67).

Commits
-------

245b5da Fix the Psalm configuration
lchrusciel added a commit to Sylius/Sylius that referenced this issue Nov 2, 2021
This PR was merged into the 1.9 branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | 1.9 1.10 master
| Bug fix?        | no
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| License         | MIT

https://sylius-devs.slack.com/archives/C3EGDG9LY/p1634735181098300

This conflict is not documented in `CONFLICTS.md` anymore, was brought back in this commit:
f80f42d

However according laminas/laminas-code#67 and considering:
https://github.com/Sylius/Sylius/blob/49b070933b32761de08475fafd6d86dca10d40ff/.github/workflows/application.yml#L104 should no longer be an issue.

If it still is, then I guess the build will show it and there should be a new issue opened somewhere.

Commits
-------

0ec9161 Remove undocumented conflict on laminas-code ^4.0
driehle added a commit to driehle/DoctrineORMModule that referenced this issue Nov 8, 2021
This renders the current Psalm baseline useless, see laminas/laminas-code#67 for further information. Hence, the baseline is removed.
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