[VarExporter] fix exporting array indexes
This commit is contained in:
parent
85b313d532
commit
3c936f447b
@ -232,7 +232,7 @@ class Exporter
|
||||
if (!\is_int($k) || 1 !== $k - $j) {
|
||||
$code .= self::export($k, $subIndent).' => ';
|
||||
}
|
||||
if (\is_int($k)) {
|
||||
if (\is_int($k) && $k > $j) {
|
||||
$j = $k;
|
||||
}
|
||||
$code .= self::export($v, $subIndent).",\n";
|
||||
|
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
5 => true,
|
||||
1 => true,
|
||||
2 => true,
|
||||
true,
|
||||
];
|
@ -112,6 +112,7 @@ class VarExporterTest extends TestCase
|
||||
|
||||
yield array('bool', true, true);
|
||||
yield array('simple-array', array(123, array('abc')), true);
|
||||
yield array('partially-indexed-array', array(5 => true, 1 => true, 2 => true, 6 => true), true);
|
||||
yield array('datetime', \DateTime::createFromFormat('U', 0));
|
||||
|
||||
$value = new \ArrayObject();
|
||||
|
Reference in New Issue
Block a user