Skip to content

Implement compatibility checking #1

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

Open
wants to merge 53 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
c915e06
Set up a compatibility system, implement checks for some types
MidnightDesign Aug 13, 2022
3cbafd3
Implement compatibility checks for scalars
MidnightDesign Aug 13, 2022
1f2b2d7
Implement compatibility checks for null
MidnightDesign Aug 13, 2022
8559e12
Test if all types are compatible with mixed
MidnightDesign Aug 14, 2022
c1109f2
Test compatibility of lists
MidnightDesign Aug 14, 2022
2628e87
Test compatibility of maps
MidnightDesign Aug 14, 2022
0de5d73
Test compatibility of tuples
MidnightDesign Aug 14, 2022
451cafa
Test compatibility of structs and string literals
MidnightDesign Aug 15, 2022
3b5e24a
Fix a bug where string literals weren't considered scalars
MidnightDesign Aug 15, 2022
636697f
Test compatibility of callables
MidnightDesign Aug 15, 2022
3562f1f
Test compatibility of iterables
MidnightDesign Aug 15, 2022
1bdbef3
Add alias tests
MidnightDesign Aug 15, 2022
f086069
Improve compatibility checking with subtype unions
MidnightDesign Aug 16, 2022
36816b8
Fix the PHPStan config
MidnightDesign Aug 16, 2022
8727ad6
Fix some issues uncovered by PHPStan
MidnightDesign Aug 16, 2022
cf2edb3
Remove an unused function import
MidnightDesign Aug 16, 2022
d242100
Don't fail fast
MidnightDesign Aug 16, 2022
e47f7f1
Try adding a blank line
MidnightDesign Aug 16, 2022
60e64f2
Try duplicating the line
MidnightDesign Aug 16, 2022
07027fd
Only run CI on pull requests
MidnightDesign Aug 16, 2022
fc13758
Delete a performance optimization (until we really need it)
MidnightDesign Aug 16, 2022
9d245d9
Clean up
MidnightDesign Aug 16, 2022
eae9f23
Add tests for invalid types
MidnightDesign Aug 30, 2022
5b954bf
Add a missing constructor
MidnightDesign Aug 30, 2022
2df5e7f
Try not including the "string start" matcher in regex
MidnightDesign Aug 30, 2022
ec38208
Try trimming the line
MidnightDesign Aug 30, 2022
1f90768
Try logging non-matches
MidnightDesign Aug 30, 2022
1693032
Try inserting a blank line again
MidnightDesign Aug 30, 2022
59115ca
Try moving the blank line after the bad case
MidnightDesign Aug 30, 2022
8e54719
Blank lines didn't work
MidnightDesign Aug 30, 2022
02ae707
Try outputting the list of compatible types
MidnightDesign Aug 30, 2022
090dcd7
Try dumping everything
MidnightDesign Aug 30, 2022
f453b91
Check for "is file" instead of "is dot"
MidnightDesign Aug 30, 2022
ae7a6db
Try dumping the compatible types
MidnightDesign Aug 30, 2022
083a5b4
Try using is_int() instead of !== false
MidnightDesign Aug 30, 2022
708598a
Fix a bug where the first compatible type was sometimes removed
MidnightDesign Aug 30, 2022
60212e2
Test the `never` type, remove an unnecessary condition
MidnightDesign Aug 30, 2022
5d5e5c0
Kill some mutants
MidnightDesign Aug 30, 2022
6218f8e
Add unit test suite
MidnightDesign Aug 30, 2022
6a2dccc
Kill another mutant
MidnightDesign Aug 30, 2022
627dab3
Kill even more mutants
MidnightDesign Aug 30, 2022
90298fe
Kill some mutants related to booleans
MidnightDesign Aug 30, 2022
eafdae9
Try to kill another mutant
MidnightDesign Aug 30, 2022
3daf422
Try to kill another mutant, part II
MidnightDesign Aug 30, 2022
2bd69af
Kill all the mutants, I guess
MidnightDesign Aug 30, 2022
28acda9
Remove an unused method
MidnightDesign Aug 30, 2022
509219d
Try storing the Infection log as an artifact
MidnightDesign Aug 31, 2022
b241b50
Add `if: always()`` to Infection log upload
MidnightDesign Aug 31, 2022
8c7a2bd
Improve intersections of structs
MidnightDesign Nov 24, 2022
a08e181
Test more
MidnightDesign Feb 22, 2023
ab58095
Help out PHPStan
MidnightDesign Feb 22, 2023
814a55d
Require PHPStan 1.9
MidnightDesign Feb 22, 2023
6c9502c
Kill some mutants
MidnightDesign Feb 22, 2023
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
9 changes: 8 additions & 1 deletion .github/workflows/infection.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Infection

on: [ pull_request, push ]
on: [ pull_request ]

jobs:
build:
Expand Down Expand Up @@ -52,3 +52,10 @@ jobs:
--min-msi=100 \
--min-covered-msi=100 \
--ignore-msi-with-no-mutations

- name: Archive Infection log
uses: actions/upload-artifact@v3
if: always()
with:
name: infection-log
path: infection.log
2 changes: 1 addition & 1 deletion .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: PHPCS

on: [ pull_request, push ]
on: [ pull_request ]

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: PHPStan

on: [ pull_request, push ]
on: [ pull_request ]

jobs:
build:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: PHPUnit

on: [ pull_request, push ]
on: [ pull_request ]

jobs:
build:
Expand All @@ -11,6 +11,7 @@ jobs:
matrix:
php: [ '8.1' ]
prefer-lowest: [ '--prefer-lowest', '' ]
fail-fast: false

name: PHPUnit on PHP ${{ matrix.php }}

Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"require-dev": {
"infection/infection": "^0.26.13",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan": "^1.9",
"phpstan/phpstan-strict-rules": "^1.3",
"phpunit/phpunit": "^9.5",
"slevomat/coding-standard": "^8.1",
Expand All @@ -21,7 +21,8 @@
},
"autoload-dev": {
"psr-4": {
"PhpTypes\\Types\\Tests\\Functional\\": "tests/functional"
"PhpTypes\\Types\\Tests\\Functional\\": "tests/functional",
"PhpTypes\\Types\\Tests\\Unit\\": "tests/unit"
}
},
"config": {
Expand Down
10 changes: 7 additions & 3 deletions infection.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"text": "infection.log"
},
"mutators": {
"@default": true
}
}
"@default": true,
"global-ignoreSourceCodeByRegex": [
"assert\\(.+\\);"
]
},
"timeout": 1
}
7 changes: 0 additions & 7 deletions phpstan.dist.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,3 @@ parameters:
paths:
- src
- tests
scanFiles:
- generated/PhpTypes/Ast/Generated/PhpTypesBaseListener.php
- generated/PhpTypes/Ast/Generated/PhpTypesBaseVisitor.php
- generated/PhpTypes/Ast/Generated/PhpTypesLexer.php
- generated/PhpTypes/Ast/Generated/PhpTypesListener.php
- generated/PhpTypes/Ast/Generated/PhpTypesParser.php
- generated/PhpTypes/Ast/Generated/PhpTypesVisitor.php
3 changes: 3 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<testsuite name="Functional">
<directory>./tests/functional</directory>
</testsuite>
<testsuite name="Unit">
<directory>./tests/unit</directory>
</testsuite>
</testsuites>
<coverage>
<include>
Expand Down
17 changes: 7 additions & 10 deletions src/BoolType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@ public function __construct(public readonly ?bool $value = null)
{
}

public function __toString(): string
{
return match ($this->value) {
null => 'bool',
true => 'true',
false => 'false',
};
}

public function toNode(): NodeInterface
{
return new IdentifierNode((string)$this);
return new IdentifierNode(
match ($this->value) {
null => 'bool',
true => 'true',
false => 'false',
}
);
}
}
8 changes: 6 additions & 2 deletions src/ClassLikeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ final class ClassLikeType extends AbstractType
/**
* @param non-empty-string $name
* @param list<AbstractType> $typeParameters
* @param list<ClassLikeType> $parents
*/
public function __construct(public readonly string $name, public readonly array $typeParameters = [])
{
public function __construct(
public readonly string $name,
public readonly array $typeParameters = [],
public readonly array $parents = [],
) {
}

public function toNode(): NodeInterface
Expand Down
Loading