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

Psalm cuts the first char in the namespace #4086

Closed
arthur-arslanov opened this issue Aug 30, 2020 · 12 comments
Closed

Psalm cuts the first char in the namespace #4086

arthur-arslanov opened this issue Aug 30, 2020 · 12 comments

Comments

@arthur-arslanov
Copy link

I got a lof of errors (something like this):

Class or interface omain\User\Service\PasswordValidatorInterface does not exist (see https:/
/psalm.dev/019)

Namespace is Domain\User... , but psalm cuts the first char

Also there are strange bugs T_NAME_FULLY_QUALIFIED:

ERROR: ParseError - vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php:20:11 - Syntax error, unexpected T_NAME_FULLY_QUALIFIED on line 20 (see https://p
salm.dev/173)
namespace Doctrine\Common\Annotations;

I do not understand why psalm analyzes the vendor folder, although I excluded it

My psalm.xml:

<?xml version="1.0"?>
<psalm
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="https://getpsalm.org/schema/config"
        xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
    <projectFiles>
        <directory name="src" useStrictTypes="true" />
        <ignoreFiles>
            <directory name="vendor" />
        </ignoreFiles>
    </projectFiles>
</psalm>

Please help me

@psalm-github-bot
Copy link

Hey @Arslanoov, can you reproduce the issue on https://psalm.dev ?

@weirdan
Copy link
Collaborator

weirdan commented Aug 30, 2020

Can you provide a repo reproducing the issue?

@arthur-arslanov
Copy link
Author

Can you provide a repo reproducing the issue?

Thanks for your reply.
Here is the link to the repository:
https://github.com/Arslanoov/todo
At the moment, the psalm is not installed there, since I did not manage to install it correctly.
The backend is located in the api folder
At first I assumed that the problem was that I used declare(strict_types=1), but after setting the useStrictTypes="true" it did not disappear, so I created this issue

@arthur-arslanov
Copy link
Author

Hey @Arslanoov, can you reproduce the issue on https://psalm.dev ?

Sorry i don't know how to reproduce it in psalm.dev

@weirdan
Copy link
Collaborator

weirdan commented Aug 30, 2020

You need to start with declaring your dependencies in composer.json (which is currently entirely missing). Laminas config files (config/pipelines.php, config/routes.php, etc) are missing as well.

With that said, I couldn't reproduce the issue locally, even when I figured out most dependencies.

@arthur-arslanov
Copy link
Author

You need to start with declaring your dependencies in composer.json (which is currently entirely missing). Laminas config files (config/pipelines.php, config/routes.php, etc) are missing as well.

With that said, I couldn't reproduce the issue locally, even when I figured out most dependencies.

It’s not missing

https://github.com/Arslanoov/todo/blob/master/api/composer.json
https://github.com/Arslanoov/todo/tree/master/api/config

@weirdan
Copy link
Collaborator

weirdan commented Aug 30, 2020

Confirmed both issues, when running in api folder.

@weirdan
Copy link
Collaborator

weirdan commented Aug 30, 2020

Interesting. Runnig vendor/bin/php-parser from that folder (supplied by nikic/php-parser) on vendor/composer/autoload_static.php produces parse error. However running the same version of php-parser installed elsewhere on that same file results in successfull parsing. So there must be some package that breaks nikic/php-parser.

@weirdan
Copy link
Collaborator

weirdan commented Aug 30, 2020

Isolated to zircote/swagger-php:

$ vendor/bin/php-parse vendor/composer/autoload_static.php > /dev/null 2>&1 ; echo $?
1

$ composer remove zircote/swagger-php
[...]

$ vendor/bin/php-parse vendor/composer/autoload_static.php > /dev/null 2>&1 ; echo $?
0

@arthur-arslanov
Copy link
Author

I found related issue
#1844

@weirdan
Copy link
Collaborator

weirdan commented Aug 30, 2020

So the solution for the time being would be to downgrade zircote/swagger-php to 3.0.4 (composer require zircote/swagger-php:'3.0.0 - 3.0.4'). This gets rid of all the issues you were having as far a I can see.

@arthur-arslanov
Copy link
Author

So the solution for the time being would be to downgrade zircote/swagger-php to 3.0.4 (composer require zircote/swagger-php:'3.0.0 - 3.0.4'). This gets rid of all the issues you were having as far a I can see.

Thank you very much! The error disappeared

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