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

ReflectionParam->getClass() returns null with nullable typehint #6064

Open
HRMsimon opened this issue Aug 19, 2015 · 1 comment
Open

ReflectionParam->getClass() returns null with nullable typehint #6064

HRMsimon opened this issue Aug 19, 2015 · 1 comment
Labels

Comments

@HRMsimon
Copy link

<?hh

class A {
  public function b(?A $c) {}
}

var_dump((new ReflectionMethod('A', 'b'))->getParameters()[0]->getClass());

Outputs null when it should be returning a ReflectionClass instance of A (as it does without the nullability type hint)

@paulbiss
Copy link
Contributor

This would appear to be intentional, we seem to forgo setting the type field for any non-vanilla-PHP type annotation, which would cause getClass to be null:

    auto const nonExtendedConstraint =
      fpi.typeConstraint.hasConstraint() &&
      !fpi.typeConstraint.isExtended();
    auto const type = nonExtendedConstraint ? fpi.typeConstraint.typeName()
      : staticEmptyString();

auto const nonExtendedConstraint =
fpi.typeConstraint.hasConstraint() &&
!fpi.typeConstraint.isExtended();
auto const type = nonExtendedConstraint ? fpi.typeConstraint.typeName()
: staticEmptyString();

@paulbiss paulbiss added the hack label Aug 19, 2015
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

2 participants