Skip to content

Commit c72e05b

Browse files
committed
accept numeric array keys when validating types [Closes #91]
1 parent bce6abc commit c72e05b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/PhpGenerator/ClassType.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ public function removeConstant(string $name): self
464464
*/
465465
public function setCases(array $cases): self
466466
{
467-
(function (EnumCase ...$cases) {})(...$cases);
467+
(function (EnumCase ...$cases) {})(...array_values($cases));
468468
$this->cases = [];
469469
foreach ($cases as $case) {
470470
$this->cases[$case->getName()] = $case;
@@ -502,7 +502,7 @@ public function removeCase(string $name): self
502502
*/
503503
public function setProperties(array $props): self
504504
{
505-
(function (Property ...$props) {})(...$props);
505+
(function (Property ...$props) {})(...array_values($props));
506506
$this->properties = [];
507507
foreach ($props as $v) {
508508
$this->properties[$v->getName()] = $v;
@@ -561,7 +561,7 @@ public function hasProperty(string $name): bool
561561
*/
562562
public function setMethods(array $methods): self
563563
{
564-
(function (Method ...$methods) {})(...$methods);
564+
(function (Method ...$methods) {})(...array_values($methods));
565565
$this->methods = [];
566566
foreach ($methods as $v) {
567567
$this->methods[$v->getName()] = $v;

src/PhpGenerator/Traits/FunctionLike.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function addBody(string $code, array $args = null): self
6969
*/
7070
public function setParameters(array $val): self
7171
{
72-
(function (Parameter ...$val) {})(...$val);
72+
(function (Parameter ...$val) {})(...array_values($val));
7373
$this->parameters = [];
7474
foreach ($val as $v) {
7575
$this->parameters[$v->getName()] = $v;

0 commit comments

Comments
 (0)