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

Add support for PHPStan 2.0 extensions #4328

Closed
llaville opened this issue Nov 30, 2024 · 3 comments · Fixed by #4337
Closed

Add support for PHPStan 2.0 extensions #4328

llaville opened this issue Nov 30, 2024 · 3 comments · Fixed by #4337
Assignees
Labels
enhancement New feature or request

Comments

@llaville
Copy link
Collaborator

Is your feature request related to a problem? Please describe.

Yesterday, I've replaced my old PHPStan baseline error file by the phpstan/phpstan-doctrine official extension.

See llaville/php-compatinfo-db@db3913d

While if works fine locally and in MegaLinter v8.1 context which have only PHPStan 1.x support, it does not work with MegaLinter v8.2 or greater that have added PHPStan 2.x support only.

PHPStan 1.x locally

phpstan1_locally

Megalinter 8.3 context

phpstan2_extension

Reproductible with PHPStan 2.x locally

phpstan2_locally

Describe the solution you'd like

I've tried to upgrade PHPStan locally for testing purpose

upgrade_phpstan

And run analysis again.
Even if PHPStan 2.0 show me more errors than PHPStan 1.12, it works as expected : the phpstan/phpstan-doctrine official extension is well detected and used.

PHPStan 2.0.2 analysis results
[email protected] in /shared/backups/bartlett/php-compatinfo-db $ composer code:check
A script named bin would override a Composer command and has been skipped
> vendor/bin/phpstan analyse --configuration .github/linters/phpstan.neon.dist --ansi --verbose
 121/121 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% 11 secs

 ------ -------------------------------------------------------------------------------------------------
  Line   Application/Command/Build/BuildHandler.php
 ------ -------------------------------------------------------------------------------------------------
  60     Call to function is_array() with array<int<0, max>, class-string> will always evaluate to true.
         🪪  function.alreadyNarrowedType
 ------ -------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------
  Line   Application/Kernel/AbstractKernel.php
 ------ -------------------------------------------------------------------------------------------------------------------------
  173    Instanceof between Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface and
         Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface will always evaluate to true.
         🪪  instanceof.alwaysTrue
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  179    Instanceof between Symfony\Component\DependencyInjection\Extension\ExtensionInterface and
         Symfony\Component\DependencyInjection\Extension\ExtensionInterface will always evaluate to true.
         🪪  instanceof.alwaysTrue
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
 ------ -------------------------------------------------------------------------------------------------------------------------

 ------ ------------------------------------------------------------------------------------------------------------------------------------
  Line   Domain/Factory/ExtensionVersionProviderTrait.php (in context of class Bartlett\CompatInfoDb\Application\Query\ListRef\ListHandler)
 ------ ------------------------------------------------------------------------------------------------------------------------------------
  52     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  56     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  60     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  64     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  68     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  72     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  77     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  81     If condition is always true.
         🪪  if.alwaysTrue
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  85     Unreachable statement - code above always terminates.
         🪪  deadCode.unreachable
  104    If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  108    If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
 ------ ------------------------------------------------------------------------------------------------------------------------------------

 ------ ------------------------------------------------------------------------------------------------------------------------------
  Line   Domain/Factory/ExtensionVersionProviderTrait.php (in context of class Bartlett\CompatInfoDb\Domain\Factory\ExtensionFactory)
 ------ ------------------------------------------------------------------------------------------------------------------------------
  52     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  56     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  60     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  64     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  68     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  72     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  77     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  81     If condition is always true.
         🪪  if.alwaysTrue
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  85     Unreachable statement - code above always terminates.
         🪪  deadCode.unreachable
  104    If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  108    If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
 ------ ------------------------------------------------------------------------------------------------------------------------------

 ------ ---------------------------------------------------------------------------------------------------------------------------------------
  Line   Domain/Factory/ExtensionVersionProviderTrait.php (in context of class Bartlett\CompatInfoDb\Presentation\Console\Command\ListCommand)
 ------ ---------------------------------------------------------------------------------------------------------------------------------------
  52     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  56     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  60     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  64     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  68     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  72     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  77     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  81     If condition is always true.
         🪪  if.alwaysTrue
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  85     Unreachable statement - code above always terminates.
         🪪  deadCode.unreachable
  104    If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  108    If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
 ------ ---------------------------------------------------------------------------------------------------------------------------------------

 ------ -----------------------------------------------------------------------------------------------------------------------------------
  Line   Domain/Factory/LibraryVersionProviderTrait.php (in context of class Bartlett\CompatInfoDb\Application\Query\Doctor\DoctorHandler)
 ------ -----------------------------------------------------------------------------------------------------------------------------------
  103    Call to function method_exists() with 'Imagick' and 'getVersion' will always evaluate to true.
         🪪  function.alreadyNarrowedType
  161    Call to function method_exists() with 'sqlite3' and 'version' will always evaluate to true.
         🪪  function.alreadyNarrowedType
 ------ -----------------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------------------
  Line   Domain/Factory/LibraryVersionProviderTrait.php (in context of class Bartlett\CompatInfoDb\Presentation\Console\Command\ShowCommand)
 ------ -------------------------------------------------------------------------------------------------------------------------------------
  103    Call to function method_exists() with 'Imagick' and 'getVersion' will always evaluate to true.
         🪪  function.alreadyNarrowedType
  161    Call to function method_exists() with 'sqlite3' and 'version' will always evaluate to true.
         🪪  function.alreadyNarrowedType
 ------ -------------------------------------------------------------------------------------------------------------------------------------

 ------ --------------------------------------------------------------------------------------------------------------------------------
  Line   Infrastructure/Persistence/Doctrine/Hydrator/ClassHydrator.php
 ------ --------------------------------------------------------------------------------------------------------------------------------
  35     Method Bartlett\CompatInfoDb\Infrastructure\Persistence\Doctrine\Hydrator\ClassHydrator::extract() should return array<string,
         bool|DateTimeImmutable|string|null> but returns array<string, array<string, string|null>|bool|string|null>.
         🪪  return.type
 ------ --------------------------------------------------------------------------------------------------------------------------------

 ------ -----------------------------------------------------------------------------------------------------------------------------------
  Line   Infrastructure/Persistence/Doctrine/Hydrator/ConstantHydrator.php
 ------ -----------------------------------------------------------------------------------------------------------------------------------
  34     Method Bartlett\CompatInfoDb\Infrastructure\Persistence\Doctrine\Hydrator\ConstantHydrator::extract() should return array<string,
         bool|DateTimeImmutable|string|null> but returns array<string, array<string, string|null>|string|null>.
         🪪  return.type
 ------ -----------------------------------------------------------------------------------------------------------------------------------

 ------ -----------------------------------------------------------------------------------------------------------------------------------
  Line   Infrastructure/Persistence/Doctrine/Hydrator/FunctionHydrator.php
 ------ -----------------------------------------------------------------------------------------------------------------------------------
  36     Method Bartlett\CompatInfoDb\Infrastructure\Persistence\Doctrine\Hydrator\FunctionHydrator::extract() should return array<string,
         bool|DateTimeImmutable|string|null> but returns array<string, array<string|null>|bool|string|null>.
         🪪  return.type
 ------ -----------------------------------------------------------------------------------------------------------------------------------

 ------ -----------------------------------------------------------------------------------------------------------------------------------
  Line   Infrastructure/Persistence/Doctrine/Hydrator/IniEntryHydrator.php
 ------ -----------------------------------------------------------------------------------------------------------------------------------
  33     Method Bartlett\CompatInfoDb\Infrastructure\Persistence\Doctrine\Hydrator\IniEntryHydrator::extract() should return array<string,
         bool|DateTimeImmutable|string|null> but returns array<string, array<string, string|null>|string|null>.
         🪪  return.type
 ------ -----------------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------
  Line   Presentation/Console/Command/AboutCommand.php
 ------ -------------------------------------------------------------------------------------------------------------------------
  46     PHPDoc tag @var with type Bartlett\CompatInfoDb\Presentation\Console\ApplicationInterface is not subtype of native type
         Symfony\Component\Console\Application|null.
         🪪  varTag.nativeType
 ------ -------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------
  Line   Presentation/Console/Command/Debug/ContainerDebugCommand.php
 ------ -------------------------------------------------------------------------------------------------------------------------
  58     PHPDoc tag @var with type Bartlett\CompatInfoDb\Presentation\Console\ApplicationInterface is not subtype of native type
         Symfony\Component\Console\Application|null.
         🪪  varTag.nativeType
 ------ -------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------
  Line   Presentation/Console/Command/DiagnoseCommand.php
 ------ -------------------------------------------------------------------------------------------------------------------------
  70     PHPDoc tag @var with type Bartlett\CompatInfoDb\Presentation\Console\ApplicationInterface is not subtype of native type
         Symfony\Component\Console\Application|null.
         🪪  varTag.nativeType
 ------ -------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------
  Line   Presentation/Console/Command/DoctorCommand.php
 ------ -------------------------------------------------------------------------------------------------------------------------
  58     PHPDoc tag @var with type Bartlett\CompatInfoDb\Presentation\Console\ApplicationInterface is not subtype of native type
         Symfony\Component\Console\Application|null.
         🪪  varTag.nativeType
 ------ -------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------
  Line   Presentation/Console/Command/InitCommand.php
 ------ -------------------------------------------------------------------------------------------------------------------------
  64     PHPDoc tag @var with type Bartlett\CompatInfoDb\Presentation\Console\ApplicationInterface is not subtype of native type
         Symfony\Component\Console\Application|null.
         🪪  varTag.nativeType
 ------ -------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------
  Line   Presentation/Console/Command/ListCommand.php
 ------ -------------------------------------------------------------------------------------------------------------------------
  73     PHPDoc tag @var with type Bartlett\CompatInfoDb\Presentation\Console\ApplicationInterface is not subtype of native type
         Symfony\Component\Console\Application|null.
         🪪  varTag.nativeType
 ------ -------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------
  Line   Presentation/Console/Command/NewCommand.php
 ------ -------------------------------------------------------------------------------------------------------------------------
  84     PHPDoc tag @var with type Bartlett\CompatInfoDb\Presentation\Console\ApplicationInterface is not subtype of native type
         Symfony\Component\Console\Application|null.
         🪪  varTag.nativeType
 ------ -------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------
  Line   Presentation/Console/Command/PolyfillCommand.php
 ------ -------------------------------------------------------------------------------------------------------------------------
  74     PHPDoc tag @var with type Bartlett\CompatInfoDb\Presentation\Console\ApplicationInterface is not subtype of native type
         Symfony\Component\Console\Application|null.
         🪪  varTag.nativeType
 ------ -------------------------------------------------------------------------------------------------------------------------

 ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  Line   Presentation/Console/Command/ShowCommand.php

 ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  226    Call to function method_exists() with

         Bartlett\CompatInfoDb\Domain\ValueObject\Class_|Bartlett\CompatInfoDb\Domain\ValueObject\Constant_|Bartlett\CompatInfoDb\Domain\ValueObject\Function_|Bartlett\CompatInfoDb\Domain\ValueObject\IniEntry
         and 'getDeprecated' will always evaluate to true.

         🪪  function.alreadyNarrowedType

         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in

            your .github/linters/phpstan.neon.dist.

  303    Instanceof between Bartlett\CompatInfoDb\Domain\ValueObject\Class_ and Bartlett\CompatInfoDb\Domain\ValueObject\Class_ will always

         evaluate to true.

         🪪  instanceof.alwaysTrue

         💡 Remove remaining cases below this one and this error will disappear too.

 ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


 [ERROR] Found 54 errors


Elapsed time: 12 seconds
Used memory: 544 MB
Script vendor/bin/phpstan analyse --configuration .github/linters/phpstan.neon.dist --ansi --verbose handling the code:check event returned with error code 1

Describe alternatives you've considered

Add support to both PHPStan 1.x and 2.x into MegaLinter v8 to allow a smooth transition to all PHP users

Additional context

@nvuillam I've noticed old lines that we should removed too : Could you confirm this point ?
https://github.com/oxsecurity/megalinter/blob/v8.3.0/megalinter/descriptors/php.megalinter-descriptor.yml#L111-L112

@llaville llaville added the enhancement New feature or request label Nov 30, 2024
@llaville
Copy link
Collaborator Author

Solution found !

By adding support to https://github.com/phpstan/extension-installer, we can now run PHPStan analysis with v1.12 or v2.0 without raising

--Error detail:
Invalid configuration:
Service 'doctrineTypeDescriptorRegistry': Service 'doctrineTypeDescriptorRegistry': Class or interface 'PHPStan\Type\Doctrine\DefaultDescriptorRegistry' not found.

In my own situation, the phpstan/phpstan-doctrine installed on my project is well detected and used either by PHPStan 1.12 (MegaLinter 8.1) or PHPStan 2.0 (MegaLinter 8.2+)

{
    "require-dev": {
        "phpstan/phpstan": "^1.12",
        "phpstan/extension-installer": "^1.0",
        "phpstan/phpstan-doctrine": "^1.5"
    },
    "config": {
        "allow-plugins": {
            "phpstan/extension-installer": true
        }
    }
}
PHPStan analysis results
[email protected] in /shared/backups/bartlett/php-compatinfo-db $ composer bin phpstan up
[bamarni-bin] Checking namespace vendor-bin/phpstan
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 2 updates, 0 removals
  - Downgrading phpstan/phpstan (2.0.3 => 1.12.12)
  - Downgrading phpstan/phpstan-doctrine (2.0.0 => 1.5.6)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 2 updates, 0 removals
  - Downgrading phpstan/phpstan (2.0.3 => 1.12.12): Extracting archive
  - Downgrading phpstan/phpstan-doctrine (2.0.0 => 1.5.6): Extracting archive
Generating autoload files
1 package you are using is looking for funding.
Use the `composer fund` command to find out more!
phpstan/extension-installer: Extensions installed
> phpstan/phpstan-doctrine: installed
No security vulnerability advisories found.

[email protected] in /shared/backups/bartlett/php-compatinfo-db $ composer code:check
A script named bin would override a Composer command and has been skipped
> vendor/bin/phpstan analyse --configuration .github/linters/phpstan.neon.dist --ansi --verbose
 121/121 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% 12 secs



 [OK] No errors


Elapsed time: 13 seconds
Used memory: 579 MB
[email protected] in /shared/backups/bartlett/php-compatinfo-db $ /shared/backups/php/phpstan-2.0.phar analyse --configuration .github/linters/phpstan.neon.dist --ansi --verbose
 121/121 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% 10 secs

 ------ -------------------------------------------------------------------------------------------------
  Line   Application/Command/Build/BuildHandler.php
 ------ -------------------------------------------------------------------------------------------------
  60     Call to function is_array() with array<int<0, max>, class-string> will always evaluate to true.
         🪪  function.alreadyNarrowedType
 ------ -------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------
  Line   Application/Kernel/AbstractKernel.php
 ------ -------------------------------------------------------------------------------------------------------------------------
  173    Instanceof between Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface and
         Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface will always evaluate to true.
         🪪  instanceof.alwaysTrue
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  179    Instanceof between Symfony\Component\DependencyInjection\Extension\ExtensionInterface and
         Symfony\Component\DependencyInjection\Extension\ExtensionInterface will always evaluate to true.
         🪪  instanceof.alwaysTrue
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
 ------ -------------------------------------------------------------------------------------------------------------------------

 ------ ------------------------------------------------------------------------------------------------------------------------------------
  Line   Domain/Factory/ExtensionVersionProviderTrait.php (in context of class Bartlett\CompatInfoDb\Application\Query\ListRef\ListHandler)
 ------ ------------------------------------------------------------------------------------------------------------------------------------
  52     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  56     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  60     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  64     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  68     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  72     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  77     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  81     If condition is always true.
         🪪  if.alwaysTrue
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  85     Unreachable statement - code above always terminates.
         🪪  deadCode.unreachable
  104    If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  108    If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
 ------ ------------------------------------------------------------------------------------------------------------------------------------

 ------ ------------------------------------------------------------------------------------------------------------------------------
  Line   Domain/Factory/ExtensionVersionProviderTrait.php (in context of class Bartlett\CompatInfoDb\Domain\Factory\ExtensionFactory)
 ------ ------------------------------------------------------------------------------------------------------------------------------
  52     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  56     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  60     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  64     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  68     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  72     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  77     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  81     If condition is always true.
         🪪  if.alwaysTrue
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  85     Unreachable statement - code above always terminates.
         🪪  deadCode.unreachable
  104    If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  108    If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
 ------ ------------------------------------------------------------------------------------------------------------------------------

 ------ ---------------------------------------------------------------------------------------------------------------------------------------
  Line   Domain/Factory/ExtensionVersionProviderTrait.php (in context of class Bartlett\CompatInfoDb\Presentation\Console\Command\ListCommand)
 ------ ---------------------------------------------------------------------------------------------------------------------------------------
  52     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  56     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  60     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  64     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  68     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  72     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  77     If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  81     If condition is always true.
         🪪  if.alwaysTrue
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  85     Unreachable statement - code above always terminates.
         🪪  deadCode.unreachable
  104    If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
  108    If condition is always false.
         🪪  if.alwaysFalse
         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in
            your .github/linters/phpstan.neon.dist.
 ------ ---------------------------------------------------------------------------------------------------------------------------------------

 ------ -----------------------------------------------------------------------------------------------------------------------------------
  Line   Domain/Factory/LibraryVersionProviderTrait.php (in context of class Bartlett\CompatInfoDb\Application\Query\Doctor\DoctorHandler)
 ------ -----------------------------------------------------------------------------------------------------------------------------------
  103    Call to function method_exists() with 'Imagick' and 'getVersion' will always evaluate to true.
         🪪  function.alreadyNarrowedType
  161    Call to function method_exists() with 'sqlite3' and 'version' will always evaluate to true.
         🪪  function.alreadyNarrowedType
 ------ -----------------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------------------
  Line   Domain/Factory/LibraryVersionProviderTrait.php (in context of class Bartlett\CompatInfoDb\Presentation\Console\Command\ShowCommand)
 ------ -------------------------------------------------------------------------------------------------------------------------------------
  103    Call to function method_exists() with 'Imagick' and 'getVersion' will always evaluate to true.
         🪪  function.alreadyNarrowedType
  161    Call to function method_exists() with 'sqlite3' and 'version' will always evaluate to true.
         🪪  function.alreadyNarrowedType
 ------ -------------------------------------------------------------------------------------------------------------------------------------

 ------ ----------------------------------------------------------------------------------------------------------------------------------
  Line   Infrastructure/Persistence/Doctrine/Entity/ClassRelationship.php
 ------ ----------------------------------------------------------------------------------------------------------------------------------
  24     Property Bartlett\CompatInfoDb\Infrastructure\Persistence\Doctrine\Entity\ClassRelationship::$class is never read, only written.
         🪪  property.onlyWritten
         💡 See: https://phpstan.org/developing-extensions/always-read-written-properties
 ------ ----------------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------------
  Line   Infrastructure/Persistence/Doctrine/Entity/ConstantRelationship.php
 ------ -------------------------------------------------------------------------------------------------------------------------------
  24     Property Bartlett\CompatInfoDb\Infrastructure\Persistence\Doctrine\Entity\ConstantRelationship::$constant is never read, only
         written.
         🪪  property.onlyWritten
         💡 See: https://phpstan.org/developing-extensions/always-read-written-properties
 ------ -------------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------------
  Line   Infrastructure/Persistence/Doctrine/Entity/FunctionRelationship.php
 ------ -------------------------------------------------------------------------------------------------------------------------------
  24     Property Bartlett\CompatInfoDb\Infrastructure\Persistence\Doctrine\Entity\FunctionRelationship::$function is never read, only
         written.
         🪪  property.onlyWritten
         💡 See: https://phpstan.org/developing-extensions/always-read-written-properties
 ------ -------------------------------------------------------------------------------------------------------------------------------

 ------ ------------------------------------------------------------------------------------------------------------------------------
  Line   Infrastructure/Persistence/Doctrine/Entity/IniRelationship.php
 ------ ------------------------------------------------------------------------------------------------------------------------------
  24     Property Bartlett\CompatInfoDb\Infrastructure\Persistence\Doctrine\Entity\IniRelationship::$ini is never read, only written.
         🪪  property.onlyWritten
         💡 See: https://phpstan.org/developing-extensions/always-read-written-properties
 ------ ------------------------------------------------------------------------------------------------------------------------------

 ------ ----------------------------------------------------------------------------------------------------------------------
  Line   Infrastructure/Persistence/Doctrine/Entity/Platform.php
 ------ ----------------------------------------------------------------------------------------------------------------------
  29     Property Bartlett\CompatInfoDb\Infrastructure\Persistence\Doctrine\Entity\Platform::$id is never written, only read.
         🪪  property.onlyRead
         💡 See: https://phpstan.org/developing-extensions/always-read-written-properties
 ------ ----------------------------------------------------------------------------------------------------------------------

 ------ --------------------------------------------------------------------------------------------------------------------------------
  Line   Infrastructure/Persistence/Doctrine/Entity/Relationship.php
 ------ --------------------------------------------------------------------------------------------------------------------------------
  24     Property Bartlett\CompatInfoDb\Infrastructure\Persistence\Doctrine\Entity\Relationship::$platform is never read, only written.
         🪪  property.onlyWritten
         💡 See: https://phpstan.org/developing-extensions/always-read-written-properties
 ------ --------------------------------------------------------------------------------------------------------------------------------

 ------ ----------------------------------------------------------------------------------------------------------------------------
  Line   Infrastructure/Persistence/Doctrine/Entity/Release.php
 ------ ----------------------------------------------------------------------------------------------------------------------------
  37     Property Bartlett\CompatInfoDb\Infrastructure\Persistence\Doctrine\Entity\Release::$extension is never read, only written.
         🪪  property.onlyWritten
         💡 See: https://phpstan.org/developing-extensions/always-read-written-properties
 ------ ----------------------------------------------------------------------------------------------------------------------------

 ------ --------------------------------------------------------------------------------------------------------------------------------
  Line   Infrastructure/Persistence/Doctrine/Hydrator/ClassHydrator.php
 ------ --------------------------------------------------------------------------------------------------------------------------------
  35     Method Bartlett\CompatInfoDb\Infrastructure\Persistence\Doctrine\Hydrator\ClassHydrator::extract() should return array<string,
         bool|DateTimeImmutable|string|null> but returns array<string, array<string, string|null>|bool|string|null>.
         🪪  return.type
 ------ --------------------------------------------------------------------------------------------------------------------------------

 ------ -----------------------------------------------------------------------------------------------------------------------------------
  Line   Infrastructure/Persistence/Doctrine/Hydrator/ConstantHydrator.php
 ------ -----------------------------------------------------------------------------------------------------------------------------------
  34     Method Bartlett\CompatInfoDb\Infrastructure\Persistence\Doctrine\Hydrator\ConstantHydrator::extract() should return array<string,
         bool|DateTimeImmutable|string|null> but returns array<string, array<string, string|null>|string|null>.
         🪪  return.type
 ------ -----------------------------------------------------------------------------------------------------------------------------------

 ------ -----------------------------------------------------------------------------------------------------------------------------------
  Line   Infrastructure/Persistence/Doctrine/Hydrator/FunctionHydrator.php
 ------ -----------------------------------------------------------------------------------------------------------------------------------
  36     Method Bartlett\CompatInfoDb\Infrastructure\Persistence\Doctrine\Hydrator\FunctionHydrator::extract() should return array<string,
         bool|DateTimeImmutable|string|null> but returns array<string, array<string|null>|bool|string|null>.
         🪪  return.type
 ------ -----------------------------------------------------------------------------------------------------------------------------------

 ------ -----------------------------------------------------------------------------------------------------------------------------------
  Line   Infrastructure/Persistence/Doctrine/Hydrator/IniEntryHydrator.php
 ------ -----------------------------------------------------------------------------------------------------------------------------------
  33     Method Bartlett\CompatInfoDb\Infrastructure\Persistence\Doctrine\Hydrator\IniEntryHydrator::extract() should return array<string,
         bool|DateTimeImmutable|string|null> but returns array<string, array<string, string|null>|string|null>.
         🪪  return.type
 ------ -----------------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------
  Line   Presentation/Console/Command/AboutCommand.php
 ------ -------------------------------------------------------------------------------------------------------------------------
  46     PHPDoc tag @var with type Bartlett\CompatInfoDb\Presentation\Console\ApplicationInterface is not subtype of native type
         Symfony\Component\Console\Application|null.
         🪪  varTag.nativeType
 ------ -------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------
  Line   Presentation/Console/Command/Debug/ContainerDebugCommand.php
 ------ -------------------------------------------------------------------------------------------------------------------------
  58     PHPDoc tag @var with type Bartlett\CompatInfoDb\Presentation\Console\ApplicationInterface is not subtype of native type
         Symfony\Component\Console\Application|null.
         🪪  varTag.nativeType
 ------ -------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------
  Line   Presentation/Console/Command/DiagnoseCommand.php
 ------ -------------------------------------------------------------------------------------------------------------------------
  70     PHPDoc tag @var with type Bartlett\CompatInfoDb\Presentation\Console\ApplicationInterface is not subtype of native type
         Symfony\Component\Console\Application|null.
         🪪  varTag.nativeType
 ------ -------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------
  Line   Presentation/Console/Command/DoctorCommand.php
 ------ -------------------------------------------------------------------------------------------------------------------------
  58     PHPDoc tag @var with type Bartlett\CompatInfoDb\Presentation\Console\ApplicationInterface is not subtype of native type
         Symfony\Component\Console\Application|null.
         🪪  varTag.nativeType
 ------ -------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------
  Line   Presentation/Console/Command/InitCommand.php
 ------ -------------------------------------------------------------------------------------------------------------------------
  64     PHPDoc tag @var with type Bartlett\CompatInfoDb\Presentation\Console\ApplicationInterface is not subtype of native type
         Symfony\Component\Console\Application|null.
         🪪  varTag.nativeType
 ------ -------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------
  Line   Presentation/Console/Command/ListCommand.php
 ------ -------------------------------------------------------------------------------------------------------------------------
  73     PHPDoc tag @var with type Bartlett\CompatInfoDb\Presentation\Console\ApplicationInterface is not subtype of native type
         Symfony\Component\Console\Application|null.
         🪪  varTag.nativeType
 ------ -------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------
  Line   Presentation/Console/Command/NewCommand.php
 ------ -------------------------------------------------------------------------------------------------------------------------
  84     PHPDoc tag @var with type Bartlett\CompatInfoDb\Presentation\Console\ApplicationInterface is not subtype of native type
         Symfony\Component\Console\Application|null.
         🪪  varTag.nativeType
 ------ -------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------------------------------------------------
  Line   Presentation/Console/Command/PolyfillCommand.php
 ------ -------------------------------------------------------------------------------------------------------------------------
  74     PHPDoc tag @var with type Bartlett\CompatInfoDb\Presentation\Console\ApplicationInterface is not subtype of native type
         Symfony\Component\Console\Application|null.
         🪪  varTag.nativeType
 ------ -------------------------------------------------------------------------------------------------------------------------

 ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  Line   Presentation/Console/Command/ShowCommand.php

 ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  226    Call to function method_exists() with

         Bartlett\CompatInfoDb\Domain\ValueObject\Class_|Bartlett\CompatInfoDb\Domain\ValueObject\Constant_|Bartlett\CompatInfoDb\Domain\ValueObject\Function_|Bartlett\CompatInfoDb\Domain\ValueObject\IniEntry
         and 'getDeprecated' will always evaluate to true.

         🪪  function.alreadyNarrowedType

         💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in

            your .github/linters/phpstan.neon.dist.

  303    Instanceof between Bartlett\CompatInfoDb\Domain\ValueObject\Class_ and Bartlett\CompatInfoDb\Domain\ValueObject\Class_ will always

         evaluate to true.

         🪪  instanceof.alwaysTrue

         💡 Remove remaining cases below this one and this error will disappear too.

 ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


 [ERROR] Found 61 errors


Elapsed time: 13 seconds
Used memory: 613.67 MB

So, if I keep continue to run MegaLinter 8.1 (PHPStan 1.12) my project won't raised error in my CI, and will let me a chance to fix new PHPStan issue detected on next days.

llaville added a commit to llaville/php-compatinfo-db that referenced this issue Nov 30, 2024
@llaville
Copy link
Collaborator Author

Tip

For PHP users that are in front of same issue : PHP_PHPSTAN_DISABLE_ERRORS come to the rescue

See llaville/php-compatinfo-db@efd2ecd
And MegaLinter 8.1 run with this context
https://github.com/llaville/php-compatinfo-db/actions/runs/12095049625/job/33727909267

llaville added a commit that referenced this issue Dec 2, 2024
@llaville llaville self-assigned this Dec 2, 2024
llaville added a commit that referenced this issue Dec 2, 2024
@llaville
Copy link
Collaborator Author

llaville commented Dec 2, 2024

PR to solved it is running ...

echoix pushed a commit that referenced this issue Dec 3, 2024
* fix issue #4328

* [MegaLinter] Apply linters fixes

* [build-command] Update generated files

---------

Co-authored-by: llaville <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant