Skip to content

Commit aa3a4e1

Browse files
committed
[+]: fix some errors, found by live examples
from "laravel/framework"
1 parent 5f96b1d commit aa3a4e1

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

src/voku/SimplePhpParser/Model/PHPFunction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function readObjectFromPhpNode($node, $dummy = null): self
101101
}
102102

103103
foreach ($node->getParams() as $parameter) {
104-
$paramNameTmp = $parameter->var->name;
104+
$paramNameTmp = $parameter->var instanceof \PhpParser\Node\Expr\Variable ? $parameter->var->name : '?';
105105
\assert(\is_string($paramNameTmp));
106106

107107
if (isset($this->parameters[$paramNameTmp])) {

src/voku/SimplePhpParser/Model/PHPInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ public function readObjectFromBetterReflection($interface): self
100100
&&
101101
\interface_exists($parentInterface, true)
102102
) {
103-
$reflectionInterface = ReflectionClass::createFromName($this->name);
104-
$class = (new self($this->parserContainer))->readObjectFromBetterReflection($reflectionInterface);
105-
$this->parserContainer->addInterface($class);
103+
$reflectionInterface = ReflectionClass::createFromName($parentInterface);
104+
$parentInterfaceNew = (new self($this->parserContainer))->readObjectFromBetterReflection($reflectionInterface);
105+
$this->parserContainer->addInterface($parentInterfaceNew);
106106
}
107107
}
108108

src/voku/SimplePhpParser/Model/PHPProperty.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ public function readObjectFromBetterReflection($property): self
136136
$this->is_static = $property->isStatic();
137137

138138
if ($this->is_static) {
139-
$this->defaultValue = $property->getValue();
139+
if (\class_exists($property->getDeclaringClass()->getName(), true)) {
140+
$this->defaultValue = $property->getValue();
141+
}
140142

141143
if ($this->defaultValue !== null) {
142144
$this->typeFromDefaultValue = Utils::normalizePhpType(\gettype($this->defaultValue));

src/voku/SimplePhpParser/Parsers/PhpCodeParser.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,10 @@ private static function getCode(
313313
continue;
314314
}
315315

316+
if (\substr($path, -\strlen('.php')) !== '.php') {
317+
continue;
318+
}
319+
316320
foreach ($pathExcludeRegex as $regex) {
317321
if (\preg_match($regex, $path)) {
318322
continue 2;

0 commit comments

Comments
 (0)