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

Update PHPStan to 2.x #1492

Merged
merged 3 commits into from
Nov 27, 2024
Merged

Update PHPStan to 2.x #1492

merged 3 commits into from
Nov 27, 2024

Conversation

Seldaek
Copy link
Member

@Seldaek Seldaek commented Nov 27, 2024

No description provided.

Copy link

private-packagist bot commented Nov 27, 2024

composer.lock

Package changes

Package Operation From To About
composer/composer upgrade 2.8.x-dev 2e7b006 2.8.x-dev 5eeba71 diff
phpstan/phpdoc-parser upgrade 1.33.0 2.0.0 diff
symfony/cache upgrade v7.1.7 v7.1.9 diff
symfony/cache-contracts upgrade v3.5.0 v3.5.1 diff
symfony/dependency-injection upgrade v7.1.8 v7.1.9 diff
symfony/deprecation-contracts upgrade v3.5.0 v3.5.1 diff
symfony/doctrine-bridge upgrade v7.1.6 v7.1.9 diff
symfony/dotenv upgrade v7.1.6 v7.1.9 diff
symfony/event-dispatcher-contracts upgrade v3.5.0 v3.5.1 diff
symfony/http-client upgrade v7.1.8 v7.1.9 diff
symfony/http-client-contracts upgrade v3.5.0 v3.5.1 diff
symfony/http-foundation upgrade v7.1.8 v7.1.9 diff
symfony/http-kernel upgrade v7.1.8 v7.1.9 diff
symfony/options-resolver upgrade v7.1.6 v7.1.9 diff
symfony/property-info upgrade v7.1.8 v7.1.9 diff
symfony/routing upgrade v7.1.6 v7.1.9 diff
symfony/security-core upgrade v7.1.6 v7.1.9 diff
symfony/serializer upgrade v7.1.8 v7.1.9 diff
symfony/service-contracts upgrade v3.5.0 v3.5.1 diff
symfony/translation-contracts upgrade v3.5.0 v3.5.1 diff
symfony/twig-bridge upgrade v7.1.8 v7.1.9 diff
symfony/validator upgrade v7.1.8 v7.1.9 diff

Dev Package changes

Package Operation From To About
phpstan/phpstan upgrade 1.12.11 2.0.2 diff
phpstan/phpstan-deprecation-rules upgrade 1.2.1 2.0.0 diff
phpstan/phpstan-doctrine upgrade 1.5.6 2.0.0 diff
phpstan/phpstan-symfony upgrade 1.4.12 2.0.0 diff
phpstan/phpstan-webmozart-assert upgrade 1.2.11 2.0.0 diff
phpunit/phpunit upgrade 11.4.3 11.4.4 diff
staabm/phpstan-dba upgrade 0.2.85 0.3.1 diff
staabm/phpstan-todo-by upgrade 0.1.32 0.2 diff
symfony/dom-crawler upgrade v7.1.6 v7.1.9 diff
symfony/web-profiler-bundle upgrade v7.1.7 v7.1.9 diff

Settings · Docs · Powered by Private Packagist

@Seldaek
Copy link
Member Author

Seldaek commented Nov 27, 2024

@staabm if I can bug you here.. I left 3 errors out of the baseline because I think they might be bugs in phpstan-dba. At least the last two errors. The first one I think might be a phpstan-doctrine issue rather.

Error 1: Property App\Entity\EmptyReferenceCache::$emptyReferences type     
         mapping mismatch: database can contain array but property expects  
         list<string>.                                                      

I'm not sure if there is a way to express that the DB contains only lists and not arrays.. This would have to be on a "trust me it's true" basis of course. Probably a feature request for phpstan-doctrine?

Error 2: Method App\Entity\PackageRepository::getSuggestCount() should return  
         int<0, max> but returns int.    

I think that could be fixed in phpstan-dba.. a COUNT(*) in a query is guaranteed to produce int<0,max> I believe?

Error 3: Method App\Entity\PhpStatRepository::getStatVersions() should return  
         list<array{version: string, depth: 0|1|2|3}> but returns              
         array<mixed>.   

Not sure what's going on there.. the code is quite simple so I don't understand why it falls back to array here. Is getArrayResult not supported perhaps?

@staabm
Copy link

staabm commented Nov 27, 2024

Error 1: Property App\Entity\EmptyReferenceCache::$emptyReferences type
mapping mismatch: database can contain array but property expects
list.

I guess its a phpstan-doctrine thing.. it doesn't look like related to DBA but more like ORM?

I think that could be fixed in phpstan-dba.. a COUNT(*) in a query is guaranteed to produce int<0,max> I believe?

that should already be supported, in case you enable $config->utilizeSqlAst(true); in the phpstan-dba bootstrap config (it requires the sqlftw/sqlftw optional dependency - caution: this has no license yet).

Not sure what's going on there.. the code is quite simple so I don't understand why it falls back to array here. Is getArrayResult not supported perhaps?

the query builder is not supported in phpstan-dba until now. we don't know yet how the query looks like the builder is returning

@staabm
Copy link

staabm commented Nov 27, 2024

Not sure what's going on there.. the code is quite simple so I don't understand why it falls back to array here. Is getArrayResult not supported perhaps?

maybe thats something phpstan-doctrine can provide, as they already do the query-builder introspection for typing

@stof
Copy link
Contributor

stof commented Nov 27, 2024

This would have to be on a "trust me it's true" basis of course.

I would say that adding this error in the ignored_errors section of your phpstan config could be considered the way to ask phpstan to trust you that your DB does not contain other things than strings.

@stof
Copy link
Contributor

stof commented Nov 27, 2024

I think phpstan-doctrine indeed does not support refining types for array results, only for object hydration.

Copy link

The composer.lock diff comment has been updated to reflect new changes in this PR.

@Seldaek
Copy link
Member Author

Seldaek commented Nov 27, 2024

Ok thanks both. I put two more in the baseline and fixed array columns to be json now so that got rid of the list issue.

@Seldaek Seldaek merged commit 1c4918f into composer:main Nov 27, 2024
3 checks passed
@Seldaek Seldaek deleted the phpstan2 branch November 27, 2024 15:11
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

Successfully merging this pull request may close these issues.

3 participants