Use Class_::getProperty() (#5555)

* Use `Class_::getProperty()`

* Update src/NodeManipulator/ClassInsertManipulator.php

Co-authored-by: Abdul Malik Ikhsan <samsonasik@gmail.com>

Co-authored-by: Tomas Votruba <tomas.vot@gmail.com>
Co-authored-by: Abdul Malik Ikhsan <samsonasik@gmail.com>
This commit is contained in:
Ruud Kamphuis 2021-02-15 15:06:35 +01:00 committed by GitHub
parent c0240e8bfd
commit 19c876f01e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -154,20 +154,9 @@ final class ClassInsertManipulator
return false;
}
/**
* Waits on https://github.com/nikic/PHP-Parser/pull/646
*/
private function hasClassProperty(Class_ $class, string $name): bool
{
foreach ($class->getProperties() as $property) {
if (! $this->nodeNameResolver->isName($property, $name)) {
continue;
}
return true;
}
return false;
return $class->getProperty($name) instanceof Property;
}
private function addTraitUse(Class_ $class, TraitUse $traitUse): void