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

Incorrect behavior of ReturnTypeFromReturnNewRector #6595

Closed
CoeusCC opened this issue Jul 27, 2021 · 4 comments · Fixed by rectorphp/rector-src#603
Closed

Incorrect behavior of ReturnTypeFromReturnNewRector #6595

CoeusCC opened this issue Jul 27, 2021 · 4 comments · Fixed by rectorphp/rector-src#603
Labels

Comments

@CoeusCC
Copy link

CoeusCC commented Jul 27, 2021

Bug Report

Subject Details
Rector version 0.11.40
Installed as "rector/rector": "^0.11.40"

Minimal PHP Code Causing Issue

See https://getrector.org/demo/1ebef269-093c-6afe-9c29-afdc8959befb

<?php

final class DemoFile
{
    public function run()
    {
        return new self();
    }
}

Responsible rules

  • ReturnTypeFromReturnNewRector

Expected Behavior

The return type should either be:

public function run(): self {}

...without the leading slash (global namespace), or the name of the class. I'm uncertain what the implications of choosing for the user would be as inheritance may come into play.

@CoeusCC CoeusCC added the bug label Jul 27, 2021
@samsonasik
Copy link
Member

@CoeusCC
Copy link
Author

CoeusCC commented Jul 28, 2021

I'd be happy to. Is there some documentation for this? This is my first interaction with this repository, and I'm not familiar with the failing fixtures concept. I'm sure it's quite simple, but I'm uninitiated.

@samsonasik
Copy link
Member

You can click "Create a test" button at https://getrector.org/demo/1ebef269-093c-6afe-9c29-afdc8959befb

@CoeusCC
Copy link
Author

CoeusCC commented Jul 28, 2021

Ah, wonderful. I'll do just that.

Bl00D4NGEL pushed a commit to Bl00D4NGEL/rector-src that referenced this issue Aug 5, 2021
samsonasik added a commit to rectorphp/rector-src that referenced this issue Aug 5, 2021
TomasVotruba pushed a commit to rectorphp/rector-src that referenced this issue Aug 5, 2021
…rnNewRector (#603)

* Add failing test fixture for ReturnTypeFromReturnNewRector

# Failing Test for ReturnTypeFromReturnNewRector

Based on https://getrector.org/demo/1ebef269-093c-6afe-9c29-afdc8959befb

refs rectorphp/rector#6595

* Closes #602 Fixes rectorphp/rector#6595

* final touch

* centralize check in TypeFactory

* mixed

* clean up

Co-authored-by: Dominik Peters <kuhlesdominik@gmx.de>
TomasVotruba pushed a commit to rectorphp/rector-src that referenced this issue Aug 6, 2021
* Add failing test fixture for ReturnTypeFromReturnNewRector

# Failing Test for ReturnTypeFromReturnNewRector

Based on https://getrector.org/demo/1ebef269-093c-6afe-9c29-afdc8959befb

refs rectorphp/rector#6595

* Add failing test fixture for RemoveUnusedPrivateMethodRector

# Failing Test for RemoveUnusedPrivateMethodRector

Based on https://getrector.org/demo/1ebf50d7-992f-63ba-9a8a-bd39c81b9232

refs: rectorphp/rector#6613

* fix test case skip_abstract_private_method_in_trait.php.inc

* remove file from previous PR

* fix fixture by moving namespace to top

* import TraitUse

* use AstResolver

* added test case to check if non-abstract private methods are considered

* refac: moved "is used" checks into it's own class to reduce class complexity

* rename constructor arg to represent class name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants