Skip to content

Rule Rector\ClassMethod\AddArrayReturnDocTypeRector could not process files#3361

Merged
TomasVotruba merged 1 commit intorectorphp:masterfrom
MetalArend:patch-2
May 12, 2020
Merged

Rule Rector\ClassMethod\AddArrayReturnDocTypeRector could not process files#3361
TomasVotruba merged 1 commit intorectorphp:masterfrom
MetalArend:patch-2

Conversation

@MetalArend
Copy link
Copy Markdown
Contributor

I'm in over my head on this one, as I don't really understand what the code is trying to do in that part. But I get errors like:

 [ERROR] Could not process "<filename>" file by "Rector\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector", due to:
"Call to a member function changeReturnType() on null".

The function is being called on $phpDocInfo, which can be null. It is declared in the docblock as being an object of type PhpDocInfo, but it seems that's not always true (in my code at least).

This change is not the right solution! It fixed the processing errors. But it still is not correctly recognizing the classes being added to the docblock, as they show up as long names, even when both 'auto_import_names' and 'import_doc_blocks' are set to true.

I'm not going to use this rector, as it also changes array<int, Example> to Example[], but I wanted to leave this here, as it is throwing a lot of errors, and at first sight it seemed quite easy to spot the problem. I'm not sure how to proceed. I'm going to look into some other rectors, where I have similar processing problems.

@TomasVotruba
Copy link
Copy Markdown
Member

Could you provide minimal code of your this crashes on?

@TomasVotruba
Copy link
Copy Markdown
Member

Mergin as fix.

The failing code would still be great

@TomasVotruba TomasVotruba merged commit 2d26afe into rectorphp:master May 12, 2020
@MetalArend MetalArend deleted the patch-2 branch September 16, 2021 18:13
TomasVotruba added a commit that referenced this pull request Feb 8, 2023
rectorphp/rector-src@5fc8c1a Replace ParametersAcceptorSelector::selectSingle() with ParametersAcceptorSelectorVariantsWrapper::select() when possible (#3361)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants