Fixing namespace issue - #89
Conversation
The line `use JsonSerializable;` of this file is not being passed on to `tests/Support/_generated/AcceptanceTesterActions.php`. And with the current phpDoc ```php @param array|string|JsonSerializable $params ``` ... phpstan is correctly reporting: > Parameter #2 $params of method Tests\Support\AcceptanceTester::sendPatch() expects array|string|Tests\Support\_generated\JsonSerializable ... So the question is: Is there a way to include the needed `use`s in the generated `TesterAction`s` Or should all occurrences of such "root" classes in the code get prefixed with a `\`?
|
The best solution is to move type information to method signature. public function sendPatch(string $url, array|string|JsonSerializable $params = [], array $files = [])There was an attempt to generate use statements for docblocks at Codeception/Codeception#6267. |
|
So would you say it's better to wait for that other PR? (I certainly can't finish it) One (small) point against the PR, and in favor of using FQCN in the code: |
No, I merged PR to generate docs from type declarations a few days ago, because useless docblocks had been removed in many modules: Codeception/codeception.github.com#646 |
|
OK, so what's the rule for the docs now? If DocBlock is present, take it; if not, take the typehints? In any case: Showing So would you say it's better to wait for some sort of automation, or should I start adding FQCN's here and there? |
Yes, that's right. I removed that |
The line
use JsonSerializable;of this file is not being passed on totests/Support/_generated/AcceptanceTesterActions.php. And with the current phpDoc@param array|string|JsonSerializable $params... phpstan is correctly reporting:
So the question is: Is there a way to include the needed
uses in the generatedTesterActions? Or should all occurrences of such "root" classes in the code get prefixed with a\?