Title: `assertGreaterThan()` does not narrow array · Issue #350 · phpstan/phpstan-phpunit · GitHub
Open Graph Title: `assertGreaterThan()` does not narrow array · Issue #350 · phpstan/phpstan-phpunit
X Title: `assertGreaterThan()` does not narrow array · Issue #350 · phpstan/phpstan-phpunit
Description: phpstan-phpunit is able to narrow a array via self::assertTrue(count($arr) > 2) to a non-empty-array, but the same is not true for self::assertGreaterThan(2, count($arr));. the following snippet should be analyzable without type expectat...
Open Graph Description: phpstan-phpunit is able to narrow a array via self::assertTrue(count($arr) > 2) to a non-empty-array, but the same is not true for self::assertGreaterThan(2, count($arr));. the following snippet sh...
X Description: phpstan-phpunit is able to narrow a array via self::assertTrue(count($arr) > 2) to a non-empty-array, but the same is not true for self::assertGreaterThan(2, count($arr));. the following snippet...
Opengraph URL: https://github.com/phpstan/phpstan-phpunit/issues/350
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`assertGreaterThan()` does not narrow array","articleBody":"phpstan-phpunit is able to narrow a array via `self::assertTrue(count($arr) > 2)` to a `non-empty-array`, but the same is not true for `self::assertGreaterThan(2, count($arr));`.\n\nthe following snippet should be analyzable without type expectation errors:\n\n```php\n\u003c?php\n\nuse function PHPStan\\Testing\\assertType;\n\nclass MyTest extends \\PHPUnit\\Framework\\TestCase {\n\t/** @param string[] $arr */\n\tpublic function testFoo(array $arr):void {\n\t\tif (rand(0,1)) {\n\t\t\tself::assertTrue(count($arr) > 2);\n\t\t\tassertType('non-empty-array\u003cstring> ', $arr);\n\t\t}\n\t\tif (rand(0,1)) {\n\t\t\tself::assertGreaterThan(2, count($arr));\n\t\t\tassertType('non-empty-array\u003cstring> ', $arr);\n\t\t}\n\t}\n}\n```","author":{"url":"https://github.com/staabm","@type":"Person","name":"staabm"},"datePublished":"2026-11-12T14:19:47Z","url":"https://github.com/phpstan/phpstan-phpunit/issues/350"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a43223c8-340c-703e-1588-a7e4c31cb882 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AA74:3E338B:3BDF9E:5242A3:6B006E1B |
| html-safe-nonce | 95a4133f98dcc248c1e5d8a3b7427163079c39b10c16e9f85e6a9659bd9d6168 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQTc0OjNFMzM4QjozQkRGOUU6NTI0MkEzOjZCMDA2RTFCIiwidmlzaXRvcl9pZCI6IjIxNjcwNDE0NjE5ODIzNTkwNjciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 81d56019d6f5e3da541b6718675bf4c50375b51044ffb6c802ba7c2844069715 |
| hovercard-subject-tag | issue:6351773396 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/phpstan/phpstan-phpunit/350/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fe0abc6beb139eaa49e97dedbbbd7843a691a02b928140e1b0c74b84328284cb/phpstan/phpstan-phpunit/issues/350 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fe0abc6beb139eaa49e97dedbbbd7843a691a02b928140e1b0c74b84328284cb/phpstan/phpstan-phpunit/issues/350 |
| og:image:alt | phpstan-phpunit is able to narrow a array via self::assertTrue(count($arr) > 2) to a non-empty-array, but the same is not true for self::assertGreaterThan(2, count($arr));. the following snippet sh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | staabm |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6527e91c60c0b29d16606ff32ac5df8ecdc37a2a62205ea057a14d7762c870fa |
| turbo-cache-control | no-preview |
| go-import | github.com/phpstan/phpstan-phpunit git https://github.com/phpstan/phpstan-phpunit.git |
| octolytics-dimension-user_id | 16435710 |
| octolytics-dimension-user_login | phpstan |
| octolytics-dimension-repository_id | 105883921 |
| octolytics-dimension-repository_nwo | phpstan/phpstan-phpunit |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 105883921 |
| octolytics-dimension-repository_network_root_nwo | phpstan/phpstan-phpunit |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 46f1cd2ae3cd8ae1a81019b5d619742e76f13bbd |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width