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 FQCN types #122

Merged
merged 1 commit into from Nov 9, 2022
Merged

Fix FQCN types #122

merged 1 commit into from Nov 9, 2022

Conversation

herndlm
Copy link
Contributor

@herndlm herndlm commented Nov 9, 2022

Fixes the FQCN types by requiring PHPStan 1.8.7 where the behaviour was fixed causing a BC break here.

Refs: phpstan/phpstan#8118

Likely an expected side effect of this change phpstan/phpstan-src#1758

Also if you check the changed tests files - each of them has other assertions where the backslash was missing, so this was already inconsistent and this is the best way to "fix" it here and move forward IMO.

@szepeviktor
Copy link
Owner

szepeviktor commented Nov 9, 2022

All right.
May I say "Please ask Herr Martin Herndl" to all sub-1.8.7 users?

@szepeviktor szepeviktor merged commit 6572e70 into szepeviktor:master Nov 9, 2022
@herndlm
Copy link
Contributor Author

herndlm commented Nov 9, 2022

please do so :D

@herndlm herndlm deleted the fix-fqcn-types branch November 9, 2022 20:47
@herndlm
Copy link
Contributor Author

herndlm commented Nov 9, 2022

I'll forward them to Ondrej :P

@herndlm
Copy link
Contributor Author

herndlm commented Nov 9, 2022

btw, I know I asked it already and I think you replied that this isn't a well-set-up project or so, but does it make sense to run the tests with lowest and highest deps maybe to catch such things? e.g. if I do composer update --prefer-lowest on local and then run composer test it's currently green. good time to make sure it stays like that maybe :)

@herndlm
Copy link
Contributor Author

herndlm commented Nov 9, 2022

wait it's actually not green, sorry sent too early. there are a couple of type errors...

@szepeviktor
Copy link
Owner

there are a couple of type errors...

Where??

@herndlm
Copy link
Contributor Author

herndlm commented Nov 9, 2022

types that are different in tests I mean, current lowest deps state

phpunit output
1) SzepeViktor\PHPStan\WordPress\Tests\DynamicReturnTypeExtensionTest::testFileAsserts with data set "/Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/data/_get_list_table.php:14" ('type', '/Users/herndlm/Development/so...le.php', PHPStan\Type\Constant\ConstantStringType Object (...), PHPStan\Type\UnionType Object (...), 14)
Expected type WP_List_Table|false, got type bool|object in /Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/data/_get_list_table.php on line 14.
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'WP_List_Table|false'
+'bool|object'

phar:///Users/herndlm/Development/source/git-forks/phpstan-wordpress/vendor/phpstan/phpstan/phpstan.phar/src/Testing/TypeInferenceTestCase.php:58
/Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/DynamicReturnTypeExtensionTest.php:41
phpvfscomposer:///Users/herndlm/Development/source/git-forks/phpstan-wordpress/vendor/phpunit/phpunit/phpunit:60

2) SzepeViktor\PHPStan\WordPress\Tests\DynamicReturnTypeExtensionTest::testFileAsserts with data set "/Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/data/get_object_taxonomies.php:15" ('type', '/Users/herndlm/Development/so...es.php', PHPStan\Type\Constant\ConstantStringType Object (...), PHPStan\Type\ArrayType Object (...), 15)
Expected type array<string|WP_Taxonomy>, got type array in /Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/data/get_object_taxonomies.php on line 15.
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'array<string|WP_Taxonomy>'
+'array'

phar:///Users/herndlm/Development/source/git-forks/phpstan-wordpress/vendor/phpstan/phpstan/phpstan.phar/src/Testing/TypeInferenceTestCase.php:58
/Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/DynamicReturnTypeExtensionTest.php:41
phpvfscomposer:///Users/herndlm/Development/source/git-forks/phpstan-wordpress/vendor/phpunit/phpunit/phpunit:60

3) SzepeViktor\PHPStan\WordPress\Tests\DynamicReturnTypeExtensionTest::testFileAsserts with data set "/Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/data/mysql2date.php:20" ('type', '/Users/herndlm/Development/so...te.php', PHPStan\Type\Constant\ConstantStringType Object (...), PHPStan\Type\UnionType Object (...), 20)
Expected type int|string|false, got type bool|int|string in /Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/data/mysql2date.php on line 20.
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'int|string|false'
+'bool|int|string'

phar:///Users/herndlm/Development/source/git-forks/phpstan-wordpress/vendor/phpstan/phpstan/phpstan.phar/src/Testing/TypeInferenceTestCase.php:58
/Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/DynamicReturnTypeExtensionTest.php:41
phpvfscomposer:///Users/herndlm/Development/source/git-forks/phpstan-wordpress/vendor/phpunit/phpunit/phpunit:60

4) SzepeViktor\PHPStan\WordPress\Tests\DynamicReturnTypeExtensionTest::testFileAsserts with data set "/Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/data/mysql2date.php:21" ('type', '/Users/herndlm/Development/so...te.php', PHPStan\Type\Constant\ConstantStringType Object (...), PHPStan\Type\UnionType Object (...), 21)
Expected type int|string|false, got type bool|int|string in /Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/data/mysql2date.php on line 21.
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'int|string|false'
+'bool|int|string'

phar:///Users/herndlm/Development/source/git-forks/phpstan-wordpress/vendor/phpstan/phpstan/phpstan.phar/src/Testing/TypeInferenceTestCase.php:58
/Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/DynamicReturnTypeExtensionTest.php:41
phpvfscomposer:///Users/herndlm/Development/source/git-forks/phpstan-wordpress/vendor/phpunit/phpunit/phpunit:60

5) SzepeViktor\PHPStan\WordPress\Tests\DynamicReturnTypeExtensionTest::testFileAsserts with data set "/Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/data/mysql2date.php:24" ('type', '/Users/herndlm/Development/so...te.php', PHPStan\Type\Constant\ConstantStringType Object (...), PHPStan\Type\UnionType Object (...), 24)
Expected type int|string|false, got type bool|int|string in /Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/data/mysql2date.php on line 24.
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'int|string|false'
+'bool|int|string'

phar:///Users/herndlm/Development/source/git-forks/phpstan-wordpress/vendor/phpstan/phpstan/phpstan.phar/src/Testing/TypeInferenceTestCase.php:58
/Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/DynamicReturnTypeExtensionTest.php:41
phpvfscomposer:///Users/herndlm/Development/source/git-forks/phpstan-wordpress/vendor/phpunit/phpunit/phpunit:60

6) SzepeViktor\PHPStan\WordPress\Tests\DynamicReturnTypeExtensionTest::testFileAsserts with data set "/Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/data/mysql2date.php:25" ('type', '/Users/herndlm/Development/so...te.php', PHPStan\Type\Constant\ConstantStringType Object (...), PHPStan\Type\UnionType Object (...), 25)
Expected type int|string|false, got type bool|int|string in /Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/data/mysql2date.php on line 25.
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'int|string|false'
+'bool|int|string'

phar:///Users/herndlm/Development/source/git-forks/phpstan-wordpress/vendor/phpstan/phpstan/phpstan.phar/src/Testing/TypeInferenceTestCase.php:58
/Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/DynamicReturnTypeExtensionTest.php:41
phpvfscomposer:///Users/herndlm/Development/source/git-forks/phpstan-wordpress/vendor/phpunit/phpunit/phpunit:60

7) SzepeViktor\PHPStan\WordPress\Tests\DynamicReturnTypeExtensionTest::testFileAsserts with data set "/Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/data/wp_error_parameter.php:180" ('type', '/Users/herndlm/Development/so...er.php', PHPStan\Type\Constant\ConstantStringType Object (...), PHPStan\Type\ErrorType Object (...), 180)
Expected type int<0, max>|false, got type *ERROR* in /Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/data/wp_error_parameter.php on line 180.
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'int<0, max>|false'
+'*ERROR*'

phar:///Users/herndlm/Development/source/git-forks/phpstan-wordpress/vendor/phpstan/phpstan/phpstan.phar/src/Testing/TypeInferenceTestCase.php:58
/Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/DynamicReturnTypeExtensionTest.php:41
phpvfscomposer:///Users/herndlm/Development/source/git-forks/phpstan-wordpress/vendor/phpunit/phpunit/phpunit:60

8) SzepeViktor\PHPStan\WordPress\Tests\DynamicReturnTypeExtensionTest::testFileAsserts with data set "/Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/data/wp_error_parameter.php:183" ('type', '/Users/herndlm/Development/so...er.php', PHPStan\Type\Constant\ConstantStringType Object (...), PHPStan\Type\ErrorType Object (...), 183)
Expected type int<0, max>|false, got type *ERROR* in /Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/data/wp_error_parameter.php on line 183.
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'int<0, max>|false'
+'*ERROR*'

phar:///Users/herndlm/Development/source/git-forks/phpstan-wordpress/vendor/phpstan/phpstan/phpstan.phar/src/Testing/TypeInferenceTestCase.php:58
/Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/DynamicReturnTypeExtensionTest.php:41
phpvfscomposer:///Users/herndlm/Development/source/git-forks/phpstan-wordpress/vendor/phpunit/phpunit/phpunit:60

9) SzepeViktor\PHPStan\WordPress\Tests\DynamicReturnTypeExtensionTest::testFileAsserts with data set "/Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/data/wp_error_parameter.php:186" ('type', '/Users/herndlm/Development/so...er.php', PHPStan\Type\Constant\ConstantStringType Object (...), PHPStan\Type\ErrorType Object (...), 186)
Expected type int<0, max>|WP_Error, got type *ERROR* in /Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/data/wp_error_parameter.php on line 186.
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'int<0, max>|WP_Error'
+'*ERROR*'

phar:///Users/herndlm/Development/source/git-forks/phpstan-wordpress/vendor/phpstan/phpstan/phpstan.phar/src/Testing/TypeInferenceTestCase.php:58
/Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/DynamicReturnTypeExtensionTest.php:41
phpvfscomposer:///Users/herndlm/Development/source/git-forks/phpstan-wordpress/vendor/phpunit/phpunit/phpunit:60

10) SzepeViktor\PHPStan\WordPress\Tests\DynamicReturnTypeExtensionTest::testFileAsserts with data set "/Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/data/wp_error_parameter.php:189" ('type', '/Users/herndlm/Development/so...er.php', PHPStan\Type\Constant\ConstantStringType Object (...), PHPStan\Type\ErrorType Object (...), 189)
Expected type int<0, max>|WP_Error|false, got type *ERROR* in /Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/data/wp_error_parameter.php on line 189.
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'int<0, max>|WP_Error|false'
+'*ERROR*'

phar:///Users/herndlm/Development/source/git-forks/phpstan-wordpress/vendor/phpstan/phpstan/phpstan.phar/src/Testing/TypeInferenceTestCase.php:58
/Users/herndlm/Development/source/git-forks/phpstan-wordpress/tests/DynamicReturnTypeExtensionTest.php:41
phpvfscomposer:///Users/herndlm/Development/source/git-forks/phpstan-wordpress/vendor/phpunit/phpunit/phpunit:60

But I don't know much about them yet. E.g. if I remove stubs support for v4 we only have 7 left (all *ERROR* go away). But I'm not saying deps should be further narrowed, this was just a test. there is more to it most likely and I won't figure it out today. UPDATE: if I only allow stubs for ^6.0 the phpunit fails go away completely, so yes, his is solely caused by the stubs. maybe some tests should be conditional or so hmm.

szepeviktor added a commit that referenced this pull request Nov 9, 2022
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.

None yet

2 participants