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

Require phpstan/phpstan 2 #17

Merged
merged 10 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"symfony/cache": "^7.0",
"symfony/cache-contracts": "^3.5",
"symfony/http-client": "^6.0 || ^7.0",
"thecodingmachine/safe": "^2.0",
"thecodingmachine/safe": "^2.0 || ^3.0",
"webmozart/assert": "^1.11"
},
"require-dev": {
Expand All @@ -34,10 +34,10 @@
"ergebnis/php-cs-fixer-config": "^6.28",
"ergebnis/test-util": "^1.5",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-webmozart-assert": "^1.0",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-webmozart-assert": "^2.0",
"phpunit/phpunit": "^9.0",
"thecodingmachine/phpstan-safe-rule": "^1.0"
"thecodingmachine/phpstan-safe-rule": "^1.4"
},
"config": {
"sort-packages": true,
Expand Down
98 changes: 63 additions & 35 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,82 +1,110 @@
parameters:
ignoreErrors:
-
message: "#^Method Storyblok\\\\Api\\\\Bridge\\\\Faker\\\\Provider\\\\StoryblokProvider\\:\\:assetResponse\\(\\) should return array\\{asset\\: array\\{filename\\: string, created_at\\: string, updated_at\\: string, expire_at\\: string\\|null, content_length\\: int, signed_url\\: string, content_type\\: string\\}\\} but returns array\\.$#"
message: '#^Property Storyblok\\Api\\Domain\\Value\\Datasource\:\:\$dimensions \(list\<Storyblok\\Api\\Domain\\Value\\DatasourceDimension\>\) does not accept array\<Storyblok\\Api\\Domain\\Value\\DatasourceDimension\>\.$#'
identifier: assign.propertyType
count: 1
path: src/Bridge/Faker/Provider/StoryblokProvider.php
path: src/Domain/Value/Datasource.php

-
message: "#^Method Storyblok\\\\Api\\\\Bridge\\\\Faker\\\\Provider\\\\StoryblokProvider\\:\\:datasourceDimensionResponse\\(\\) should return array\\{id\\: int, name\\: string, entry_value\\: string, datasource_id\\: int, created_at\\: string, updated_at\\: string\\} but returns array\\.$#"
message: '#^Property Storyblok\\Api\\Domain\\Value\\Field\\FieldCollection\:\:\$items \(list\<Storyblok\\Api\\Domain\\Value\\Field\\Field\>\) does not accept array\<int\<0, max\>, Storyblok\\Api\\Domain\\Value\\Field\\Field\>\.$#'
identifier: assign.propertyType
count: 1
path: src/Bridge/Faker/Provider/StoryblokProvider.php
path: src/Domain/Value/Field/FieldCollection.php

-
message: "#^Method Storyblok\\\\Api\\\\Bridge\\\\Faker\\\\Provider\\\\StoryblokProvider\\:\\:datasourceEntriesResponse\\(\\) should return array\\{datasource_entries\\: array\\<int, array\\{id\\: int, name\\: string, value\\: string, dimension_value\\: string\\|null\\}\\>\\} but returns array\\.$#"
message: '#^PHPDoc tag @return contains unresolvable type\.$#'
identifier: return.unresolvableType
count: 1
path: src/Bridge/Faker/Provider/StoryblokProvider.php
path: src/Domain/Value/Filter/FilterCollection.php

-
message: "#^Method Storyblok\\\\Api\\\\Bridge\\\\Faker\\\\Provider\\\\StoryblokProvider\\:\\:datasourceEntryResponse\\(\\) should return array\\{id\\: int, name\\: string, value\\: string, dimension_value\\: string\\|null\\} but returns array\\.$#"
message: '#^Property Storyblok\\Api\\Domain\\Value\\Filter\\FilterCollection\:\:\$items \(list\<Storyblok\\Api\\Domain\\Value\\Filter\\Filters\\Filter\>\) does not accept array\<int\<0, max\>, Storyblok\\Api\\Domain\\Value\\Filter\\Filters\\Filter\>\.$#'
identifier: assign.propertyType
count: 1
path: src/Bridge/Faker/Provider/StoryblokProvider.php
path: src/Domain/Value/Filter/FilterCollection.php

-
message: "#^Method Storyblok\\\\Api\\\\Bridge\\\\Faker\\\\Provider\\\\StoryblokProvider\\:\\:datasourceResponse\\(\\) should return array\\{id\\: int, name\\: string, slug\\: string, dimensions\\: array\\<int, array\\{id\\: int, name\\: string, entry_value\\: string, datasource_id\\: int, created_at\\: string, updated_at\\: string\\}\\>\\} but returns array\\.$#"
message: '#^Property Storyblok\\Api\\Domain\\Value\\IdCollection\:\:\$items \(list\<Storyblok\\Api\\Domain\\Value\\Id\>\) does not accept array\<int\<0, max\>, Storyblok\\Api\\Domain\\Value\\Id\>\.$#'
identifier: assign.propertyType
count: 1
path: src/Bridge/Faker/Provider/StoryblokProvider.php
path: src/Domain/Value/IdCollection.php

-
message: "#^Method Storyblok\\\\Api\\\\Bridge\\\\Faker\\\\Provider\\\\StoryblokProvider\\:\\:datasourcesResponse\\(\\) should return array\\{datasources\\: array\\<int, array\\<string, mixed\\>\\>\\} but returns array\\.$#"
message: '#^Property Storyblok\\Api\\Domain\\Value\\Link\:\:\$alternates \(list\<Storyblok\\Api\\Domain\\Value\\LinkAlternate\>\) does not accept array\<Storyblok\\Api\\Domain\\Value\\LinkAlternate\>\.$#'
identifier: assign.propertyType
count: 1
path: src/Bridge/Faker/Provider/StoryblokProvider.php
path: src/Domain/Value/Link.php

-
message: "#^Method Storyblok\\\\Api\\\\Bridge\\\\Faker\\\\Provider\\\\StoryblokProvider\\:\\:linkAlternateResponse\\(\\) should return array\\{lang\\: string, name\\: string, path\\: string, published\\: bool, translated_slug\\: string\\} but returns array\\.$#"
message: '#^Property Storyblok\\Api\\Domain\\Value\\Resolver\\RelationCollection\:\:\$items \(list\<Storyblok\\Api\\Domain\\Value\\Resolver\\Relation\>\) does not accept array\<int\<0, max\>, Storyblok\\Api\\Domain\\Value\\Resolver\\Relation\>\.$#'
identifier: assign.propertyType
count: 1
path: src/Bridge/Faker/Provider/StoryblokProvider.php
path: src/Domain/Value/Resolver/RelationCollection.php

-
message: "#^Method Storyblok\\\\Api\\\\Bridge\\\\Faker\\\\Provider\\\\StoryblokProvider\\:\\:linkResponse\\(\\) should return array\\{uuid\\: string, id\\: int, parent_id\\: int\\|null, name\\: string, slug\\: string, path\\: string, real_path\\: string, is_folder\\: bool, \\.\\.\\.\\} but returns array\\.$#"
message: '#^Property Storyblok\\Api\\Domain\\Value\\Tag\\TagCollection\:\:\$items \(list\<Storyblok\\Api\\Domain\\Value\\Tag\\Tag\>\) does not accept array\<int\<0, max\>, Storyblok\\Api\\Domain\\Value\\Tag\\Tag\>\.$#'
identifier: assign.propertyType
count: 1
path: src/Bridge/Faker/Provider/StoryblokProvider.php
path: src/Domain/Value/Tag/TagCollection.php

-
message: "#^Method Storyblok\\\\Api\\\\Bridge\\\\Faker\\\\Provider\\\\StoryblokProvider\\:\\:linksResponse\\(\\) should return array\\{links\\: array\\<int, array\\<string, mixed\\>\\>\\} but returns array\\.$#"
message: '#^Method Storyblok\\Api\\Request\\StoriesRequest\:\:toArray\(\) should return array\{language\: string, page\: int, per_page\: int, sort_by\?\: string, filter_query\?\: list\<mixed\>, with_tag\?\: string, excluding_fields\?\: string, excluding_ids\?\: string, \.\.\.\} but returns array\{language\: string, page\: int, per_page\: int, sort_by\?\: string, filter_query\?\: array, with_tag\?\: string, excluding_fields\?\: string, excluding_ids\?\: string, \.\.\.\}\.$#'
identifier: return.type
count: 1
path: src/Bridge/Faker/Provider/StoryblokProvider.php
path: src/Request/StoriesRequest.php

-
message: "#^Method Storyblok\\\\Api\\\\Bridge\\\\Faker\\\\Provider\\\\StoryblokProvider\\:\\:spaceResponse\\(\\) should return array\\{id\\: int, name\\: string, domain\\: string, version\\: int, language_codes\\: array\\<int, string\\>\\} but returns array\\.$#"
message: '#^Property Storyblok\\Api\\Response\\DatasourceEntriesResponse\:\:\$datasourceEntries \(list\<Storyblok\\Api\\Domain\\Value\\DatasourceEntry\>\) does not accept array\<Storyblok\\Api\\Domain\\Value\\DatasourceEntry\>\.$#'
identifier: assign.propertyType
count: 1
path: src/Bridge/Faker/Provider/StoryblokProvider.php
path: src/Response/DatasourceEntriesResponse.php

-
message: "#^Method Storyblok\\\\Api\\\\Bridge\\\\Faker\\\\Provider\\\\StoryblokProvider\\:\\:storiesResponse\\(\\) should return array\\{cv\\: int, stories\\: array\\<int, array\\<string, mixed\\>\\>, links\\: array\\<string\\>, rels\\: array\\<string\\>\\} but returns array\\.$#"
message: '#^Property Storyblok\\Api\\Response\\DatasourcesResponse\:\:\$datasources \(list\<Storyblok\\Api\\Domain\\Value\\Datasource\>\) does not accept array\<Storyblok\\Api\\Domain\\Value\\Datasource\>\.$#'
identifier: assign.propertyType
count: 1
path: src/Bridge/Faker/Provider/StoryblokProvider.php
path: src/Response/DatasourcesResponse.php

-
message: "#^Method Storyblok\\\\Api\\\\Bridge\\\\Faker\\\\Provider\\\\StoryblokProvider\\:\\:storyResponse\\(\\) should return array\\{cv\\: int, story\\: array\\<string, mixed\\>, links\\: array\\<string\\>, rels\\: array\\<string\\>\\} but returns array\\.$#"
message: '#^Property Storyblok\\Api\\Response\\TagsResponse\:\:\$tags \(list\<Storyblok\\Api\\Domain\\Value\\Tag\>\) does not accept array\<Storyblok\\Api\\Domain\\Value\\Tag\>\.$#'
identifier: assign.propertyType
count: 1
path: src/Bridge/Faker/Provider/StoryblokProvider.php
path: src/Response/TagsResponse.php

-
message: "#^Method Storyblok\\\\Api\\\\Bridge\\\\Faker\\\\Provider\\\\StoryblokProvider\\:\\:tagsResponse\\(\\) should return array\\{tags\\: array\\<int, array\\{name\\: string, taggings_count\\: int\\}\\>\\} but returns array\\.$#"
message: '#^Cannot call method format\(\) on DateTimeImmutable\|null\.$#'
identifier: method.nonObject
count: 1
path: src/Bridge/Faker/Provider/StoryblokProvider.php
path: tests/Unit/Domain/Value/AssetTest.php

-
message: "#^Method Storyblok\\\\Api\\\\Domain\\\\Value\\\\Filter\\\\FilterCollection\\:\\:toArray\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Domain/Value/Filter/FilterCollection.php
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertEmpty\(\) with Storyblok\\Api\\Domain\\Value\\Field\\FieldCollection will always evaluate to false\.$#'
identifier: staticMethod.impossibleType
count: 2
path: tests/Unit/Domain/Value/Field/FieldCollectionTest.php

-
message: "#^PHPDoc tag @return contains unresolvable type\\.$#"
count: 1
path: src/Domain/Value/Filter/FilterCollection.php
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertEmpty\(\) with Storyblok\\Api\\Domain\\Value\\Filter\\FilterCollection will always evaluate to false\.$#'
identifier: staticMethod.impossibleType
count: 2
path: tests/Unit/Domain/Value/Filter/FilterCollectionTest.php
Comment on lines +88 to +91
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a false positive, otherwise our test would fail


-
message: "#^Cannot call method format\\(\\) on DateTimeImmutable\\|null\\.$#"
count: 1
path: tests/Unit/Domain/Value/AssetTest.php
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertEmpty\(\) with Storyblok\\Api\\Domain\\Value\\IdCollection will always evaluate to false\.$#'
identifier: staticMethod.impossibleType
count: 2
path: tests/Unit/Domain/Value/IdCollectionTest.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertEmpty\(\) with Storyblok\\Api\\Domain\\Value\\Resolver\\RelationCollection will always evaluate to false\.$#'
identifier: staticMethod.impossibleType
count: 2
path: tests/Unit/Domain/Value/Resolver/RelationCollectionTest.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertEmpty\(\) with Storyblok\\Api\\Domain\\Value\\Tag\\TagCollection will always evaluate to false\.$#'
identifier: staticMethod.impossibleType
count: 2
path: tests/Unit/Domain/Value/Tag/TagCollectionTest.php

5 changes: 5 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ includes:
- phpstan-baseline.neon

parameters:
ignoreErrors:
-
identifier: missingType.iterableValue
-
identifier: staticMethod.alreadyNarrowedType
inferPrivatePropertyTypeFromConstructor: true
level: 8
paths:
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Value/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
public bool $isPublished;

/**
* @var list<LinkAlternate>1
* @var list<LinkAlternate>
*/
public array $alternates;

Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Value/Total.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(
}

/**
* @param array<string, list<string>> $headers
* @param array<string, array<string>> $headers
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes some errors, but I am in favor of keeping the list

*/
public static function fromHeaders(array $headers): self
{
Expand Down