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

Reflector needs to convert "parent" as well as "self" #33483

Closed
GrahamCampbell opened this issue Jul 9, 2020 · 4 comments
Closed

Reflector needs to convert "parent" as well as "self" #33483

GrahamCampbell opened this issue Jul 9, 2020 · 4 comments
Assignees
Labels

Comments

@GrahamCampbell
Copy link
Member

Kinda an edge case. I'll fix this soon.

@GrahamCampbell GrahamCampbell self-assigned this Jul 9, 2020
@driesvints driesvints added the bug label Jul 9, 2020
@GrahamCampbell
Copy link
Member Author

GrahamCampbell commented Jul 9, 2020

FYI, this is valid PHP:

<?php

class Foo {}

class Bar extends Foo
{
    function f(parent $x) {}
}

(new Bar)->f(new Foo);

Laravel should be able to method injection on Bar::f, by looking up Foo in the container, but currently it looks for the string parent, by mistake.

@ryangjchandler
Copy link
Contributor

ryangjchandler commented Jul 9, 2020

Is this a problem for 6.x, since running this code in Tinkerwell on 7.x works perfectly fine?

image

@GrahamCampbell
Copy link
Member Author

Maybe you have an old version of 7.x, because the reflector code in the latest 6.x is identical to that in 7.x.

@ryangjchandler
Copy link
Contributor

ryangjchandler commented Jul 9, 2020

Yeah that was it - Tinkerwell's default app is running an older version, just tested on 7.19 and fails.

Should really be as simple as adding this though:

if ($name === 'parent') {
    return $parameter->getDeclaringClass()->getParentClass()->getName();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants