Title: PhpStan does not consider usage of Phpunit Assert::assertNotEmpty and Assert::assertContainsOnlyInstancesOf when returning an Array · Issue #158 · phpstan/phpstan-phpunit · GitHub
Open Graph Title: PhpStan does not consider usage of Phpunit Assert::assertNotEmpty and Assert::assertContainsOnlyInstancesOf when returning an Array · Issue #158 · phpstan/phpstan-phpunit
X Title: PhpStan does not consider usage of Phpunit Assert::assertNotEmpty and Assert::assertContainsOnlyInstancesOf when returning an Array · Issue #158 · phpstan/phpstan-phpunit
Description: Hello, I am building a test returning an array of entities to be used in some others tests marked with @depends. Despite I check that my returned array is not empty an contains only instances of a specific class, phpstan keeps alerting t...
Open Graph Description: Hello, I am building a test returning an array of entities to be used in some others tests marked with @depends. Despite I check that my returned array is not empty an contains only instances of a ...
X Description: Hello, I am building a test returning an array of entities to be used in some others tests marked with @depends. Despite I check that my returned array is not empty an contains only instances of a ...
Opengraph URL: https://github.com/phpstan/phpstan-phpunit/issues/158
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PhpStan does not consider usage of Phpunit Assert::assertNotEmpty and Assert::assertContainsOnlyInstancesOf when returning an Array","articleBody":"Hello,\r\n\r\nI am building a test returning an array of entities to be used in some others tests marked with `@depends`.\r\nDespite I check that my returned array is not empty an contains only instances of a specific class, phpstan keeps alerting\r\nthat my returned value does not match. Here is my code: \r\n\r\n```php\r\n /**\r\n * @return Post[]\r\n *\r\n * @throws \\Exception\r\n */\r\n public function testFindForHomePageReturnsCollectionOfPosts(): array\r\n {\r\n $testSubject = self::getContainer()->get(PostRepository::class);\r\n if (!$testSubject instanceof PostRepository) {\r\n throw new ServiceNotFoundException(PostRepository::class);\r\n }\r\n\r\n $result = $testSubject->findForHomePage()->toArray();\r\n self::assertNotEmpty($result);\r\n self::assertContainsOnlyInstancesOf(Post::class, $result);\r\n\r\n return $result;\r\n }\r\n```\r\n\r\nAnd the alert thrown by phpstan (line 34 is the `return $result` statement): \r\n\r\n\r\nContext: \r\n---\r\nSymfony 6.2 KernelTestCase\r\nphpunit/phpunit 9.5.25\r\nsymfony/phpunit-bridge 6.2.0\r\n\r\nPhpStan 1.9.3\r\nextensions:\r\n - phpstan-phpunit 1.3.2\r\n - phpstan-doctrine 1.3.18\r\n - phpstan-symfony 1.2.15\r\n - phpstan/phpstan-webmozart-assert 1.2.1\r\n\r\nThanks a lot for your help :) \r\n","author":{"url":"https://github.com/Lreus","@type":"Person","name":"Lreus"},"datePublished":"2022-12-16T09:36:05Z","url":"https://github.com/phpstan/phpstan-phpunit/issues/158"}
| 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:41574cf5-b64d-f779-96ff-7a3c59390db0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CE7C:2EEABC:47A06D:6458F5:6B006B61 |
| html-safe-nonce | 7e356454c35f63511c184b57dd85bd952f4cf88efe12819305672bba3c4e4b03 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRTdDOjJFRUFCQzo0N0EwNkQ6NjQ1OEY1OjZCMDA2QjYxIiwidmlzaXRvcl9pZCI6IjYyMjkyMDIwMjI3OTc2OTk5MzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7bd19809146f9e8100a2a4a74f189f96abf159e4700c153713b3541f6465ec69 |
| hovercard-subject-tag | issue:1499883487 |
| 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/158/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ff5c938cdb4d99d3cc98d748fd30dc087c4a96abb2eaa9da0dc32196bac0aa0d/phpstan/phpstan-phpunit/issues/158 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ff5c938cdb4d99d3cc98d748fd30dc087c4a96abb2eaa9da0dc32196bac0aa0d/phpstan/phpstan-phpunit/issues/158 |
| og:image:alt | Hello, I am building a test returning an array of entities to be used in some others tests marked with @depends. Despite I check that my returned array is not empty an contains only instances of a ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Lreus |
| 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