Skip to content

Commit d004f12

Browse files
fprochazkadg
authored andcommitted
PhpGenerator: fixed non-associative arrays $properties, $methods and $parameters
1 parent 83e0d14 commit d004f12

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/PhpGenerator/ClassType.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class ClassType extends Nette\Object
6666
public $methods = array();
6767

6868

69-
/** @return Class */
69+
/** @return ClassType */
7070
public static function from($from)
7171
{
7272
$from = $from instanceof \ReflectionClass ? $from : new \ReflectionClass($from);
@@ -90,11 +90,11 @@ public static function from($from)
9090
}
9191
}
9292
foreach ($from->getProperties() as $prop) {
93-
$class->properties[] = Property::from($prop);
93+
$class->properties[$prop->getName()] = Property::from($prop);
9494
}
9595
foreach ($from->getMethods() as $method) {
9696
if ($method->getDeclaringClass() == $from) { // intentionally ==
97-
$class->methods[] = Method::from($method);
97+
$class->methods[$method->getName()] = Method::from($method);
9898
}
9999
}
100100
return $class;

src/PhpGenerator/Method.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static function from($from)
6969
$method = new static;
7070
$method->name = $from->getName();
7171
foreach ($from->getParameters() as $param) {
72-
$method->parameters[] = Parameter::from($param);
72+
$method->parameters[$param->getName()] = Parameter::from($param);
7373
}
7474
$method->static = $from->isStatic();
7575
$method->visibility = $from->isPrivate() ? 'private' : ($from->isProtected() ? 'protected' : '');
@@ -90,7 +90,7 @@ public function addParameter($name, $defaultValue = NULL)
9090
if (func_num_args() > 1) {
9191
$param->setOptional(TRUE)->setDefaultValue($defaultValue);
9292
}
93-
return $this->parameters[] = $param->setName($name);
93+
return $this->parameters[$name] = $param->setName($name);
9494
}
9595

9696

0 commit comments

Comments
 (0)