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

UnimplementedAbstractMethod on all enums when running PHAR version on Windows #10747

Closed
Shira-3749 opened this issue Feb 24, 2024 · 3 comments · Fixed by #10748
Closed

UnimplementedAbstractMethod on all enums when running PHAR version on Windows #10747

Shira-3749 opened this issue Feb 24, 2024 · 3 comments · Fixed by #10748

Comments

@Shira-3749
Copy link

Shira-3749 commented Feb 24, 2024

I've encountered an obscure bug when the .phar version of Psalm is run on Windows.

(This only happens with the .phar version. It works in both cases when installed via Composer.)

Psalm 5.22.2@d768d914152dbbf3486c36398802f74e80cfde48
PHP 8.3.3 (cli)

Given this psalm.xml:

<?xml version="1.0"?>
<psalm
    errorLevel="1"
    resolveFromConfigFile="true"
    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"
    findUnusedBaselineEntry="true"
    findUnusedCode="false"
>
    <projectFiles>
        <directory name="src" />
    </projectFiles>
</psalm>

And this simple enum definition in src/Example.php:

<?php

enum Foo {
    case A;
    case B;
}

When I run psalm.phar on the Windows host, I get the following output:

$ ./psalm.phar 
Target PHP version: 8.3 (inferred from current PHP version).
Scanning files...
Analyzing files...

ERROR: UnimplementedAbstractMethod - src/Example.php:3:6 - Method cases is not defined on class Foo, defined abstract in UnitEnum (see https://psalm.dev/101)
enum Foo {

------------------------------
1 errors found
------------------------------

Checks took 0.01 seconds and used 15.275MB of memory
No files analyzed
Psalm was unable to infer types in the codebase

But this passes when run inside a Docker container (based on php:8.3-apache).

root@d519a37baed3:/var/www/html/test/# ./psalm.phar 
Target PHP version: 8.3 (inferred from current PHP version).
Scanning files...
Analyzing files...

░
------------------------------
                              
       No errors found!       
                              
------------------------------

Checks took 1.17 seconds and used 30.963MB of memory
Psalm was unable to infer types in the codebase
Copy link

Hey @Shira-3749, can you reproduce the issue on https://psalm.dev? These will be used as phpunit tests when implementing the feature or fixing this bug.

@weirdan
Copy link
Collaborator

weirdan commented Feb 25, 2024

Reproduced: https://github.com/weirdan/10747

@weirdan
Copy link
Collaborator

weirdan commented Feb 25, 2024

The fun part is that the issue disappear when you extract the phar. Something tells me it's going to be fun to debug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants