staabm / phpstan-dba

PHPStan based SQL static analysis and type inference for the database access layer
https://staabm.github.io/archive.html#phpstan-dba
MIT License
250 stars 17 forks source link

duplicate stubs error #466

Open staabm opened 1 year ago

staabm commented 1 year ago

need to figure out a way how we can handle these stub errors and test whether we still need these stub files after all

https://github.com/phpstan/phpstan/issues/8378

I cannot reproduce it yet or know the exact circumstances, but I sometimes get errors like

 ------ -----------------------------------------------------------------
  Line   vendor-bin\phpstan\vendor\staabm\phpstan-dba\config\Mysqli.stub
 ------ -----------------------------------------------------------------
  3      Class mysqli_stmt declared multiple times:

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

 ------ ---------------------------------------------------------------------------------------------------------------
  Line   vendor-bin\phpstan\vendor\staabm\phpstan-dba\config\PdoStatement.stub
 ------ ---------------------------------------------------------------------------------------------------------------
  11     Class PDOStatement declared multiple times:
         -
         phar://C:/dvl/Workspace/daiber/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/stubs/PDOStatement.stub
         :8
 ------ ---------------------------------------------------------------------------------------------------------------

 ------ ----------------------------------------------------------------------------------------------------
  Line   vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/stubs/PDOStatement.stub
 ------ ----------------------------------------------------------------------------------------------------
  8      Class PDOStatement declared multiple times:
         - C:/dvl/Workspace/daiber/vendor-bin/phpstan/vendor/staabm/phpstan-dba/config/PdoStatement.stub:11
 ------ ----------------------------------------------------------------------------------------------------

 ------ --------------------------------------------------------------------------
  Line   vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan.phar/stubs/mysqli.stub
 ------ --------------------------------------------------------------------------
  3      Class mysqli_stmt declared multiple times:

 ------ --------------------------------------------------------------------------
staabm commented 1 year ago

see https://github.com/phpstan/phpstan-src/pull/2096

pscheit commented 1 year ago

@staabm since the PdoStatement.stub is now in phpstan-src merged + released, it needs to be removed here, too, right?

staabm commented 1 year ago

It doesn't work yet with stubs from phpstan-src only.

I don't know yet how we can make this error go away.

If you got this error, you can proceed like usual. It is reported only when no result cache exists. As soon as the result cache is generated the error no longer happens

pscheit commented 1 year ago

since we have loaded bleedingEdge.neon I (for now) disabled the feature that detects doubles:

parameters:
    featureToggles:
        duplicateStubs: false  # workaround for: https://github.com/staabm/phpstan-dba/issues/466

in the CI it will fail all the time, cause the result cache isnt existing

pscheit commented 1 year ago

Ondrej sounds like, that there will be no fix. Duplicate stubs are not allowed, when they are in phpstan-src :/

staabm commented 1 year ago

in the CI it will fail all the time, cause the result cache isnt existing

You should enable the result cache in CI. It saves a lot of time. e.g. with GithubActions you can use actions/cache to persist the cache between build jobs