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

Fix crush when intersection types used + Fix psalm + Kill mutants #86

Merged
merged 12 commits into from
Feb 18, 2024
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
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
- 'psalm.xml'

push:
branches:
- master
paths-ignore:
- 'docs/**'
- 'README.md'
Expand All @@ -28,4 +30,4 @@ jobs:
os: >-
['ubuntu-latest', 'windows-latest']
php: >-
['8.0', '8.1']
['8.0', '8.1', '8.2', '8.3']
4 changes: 3 additions & 1 deletion .github/workflows/composer-require-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ on:
- 'psalm.xml'

push:
branches:
- master
paths-ignore:
- 'docs/**'
- 'README.md'
Expand All @@ -30,4 +32,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.0']
['8.0', '8.1', '8.2', '8.3']
5 changes: 4 additions & 1 deletion .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
- 'psalm.xml'

push:
branches:
- master
paths-ignore:
- 'docs/**'
- 'README.md'
Expand All @@ -23,9 +25,10 @@ jobs:
mutation:
uses: yiisoft/actions/.github/workflows/roave-infection.yml@master
with:
min-covered-msi: 100
os: >-
['ubuntu-latest']
php: >-
['8.1']
['8.3']
secrets:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
4 changes: 3 additions & 1 deletion .github/workflows/rector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ name: rector
jobs:
rector:
uses: yiisoft/actions/.github/workflows/rector.yml@master
secrets:
token: ${{ secrets.YIISOFT_GITHUB_TOKEN }}
with:
os: >-
['ubuntu-latest']
php: >-
['8.0']
['8.3']
12 changes: 11 additions & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
- 'phpunit.xml.dist'

push:
branches:
- master
paths-ignore:
- 'docs/**'
- 'README.md'
Expand All @@ -28,4 +30,12 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.0', '8.1']
['8.1', '8.2', '8.3']
psalm80:
uses: yiisoft/actions/.github/workflows/psalm.yml@master
with:
psalm-config: psalm80.xml
os: >-
['ubuntu-latest']
php: >-
['8.0']
2 changes: 1 addition & 1 deletion .styleci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
preset: psr12
risky: true

version: 8.1
version: 8.2

finder:
exclude:
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## 3.2.1 under development

- no changes in this release.
- Bug #86: Fix crash when intersection types are used (@vjik)

## 3.2.0 February 12, 2023

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"rector/rector": "^1.0.0",
"roave/infection-static-analysis-plugin": "^1.18",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.6",
"vimeo/psalm": "^4.30|^5.21",
"yiisoft/test-support": "^1.4"
},
"autoload": {
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<testsuite name="Yii Definitions tests">
<directory>./tests/Unit</directory>
<directory phpVersion="8.1" phpVersionOperator=">=">./tests/Php8_1</directory>
<directory phpVersion="8.2" phpVersionOperator=">=">./tests/Php8_2</directory>
</testsuite>
</testsuites>

Expand Down
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress" />
<RiskyTruthyFalsyComparison errorLevel="suppress" />
<InvalidThrow>
<errorLevel type="suppress">
<referencedClass name="Psr\Container\ContainerExceptionInterface" />
Expand Down
25 changes: 25 additions & 0 deletions psalm80.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
findUnusedBaselineEntry="true"
findUnusedCode="false"
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"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress" />
<InvalidThrow>
<errorLevel type="suppress">
<referencedClass name="Psr\Container\ContainerExceptionInterface" />
<referencedClass name="Psr\Container\NotFoundExceptionInterface" />
</errorLevel>
</InvalidThrow>
</issueHandlers>
</psalm>
37 changes: 21 additions & 16 deletions src/DefinitionStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,27 @@ private function isResolvable(string $id, array $building): bool
$isUnionTypeResolvable = false;
$unionTypes = [];
foreach ($type->getTypes() as $unionType) {
if (!$unionType->isBuiltin()) {
$typeName = $unionType->getName();
/**
* @psalm-suppress TypeDoesNotContainType
*
* @link https://github.com/vimeo/psalm/issues/6756
*/
if ($typeName === 'self') {
continue;
}
$unionTypes[] = $typeName;
if ($this->isResolvable($typeName, $building)) {
$isUnionTypeResolvable = true;
/** @infection-ignore-all Mutation don't change behaviour, but degrade performance. */
break;
}
/**
* @psalm-suppress DocblockTypeContradiction Need for PHP 8.0 and 8.1 only
*/
if (!$unionType instanceof ReflectionNamedType || $unionType->isBuiltin()) {
continue;
}

$typeName = $unionType->getName();
/**
* @psalm-suppress TypeDoesNotContainType
*
* @link https://github.com/vimeo/psalm/issues/6756
*/
if ($typeName === 'self') {
continue;
}
$unionTypes[] = $typeName;
if ($this->isResolvable($typeName, $building)) {
$isUnionTypeResolvable = true;
/** @infection-ignore-all Mutation don't change behaviour, but degrade performance. */
break;
}
}

Expand Down
Loading
Loading