bug #29741 [VarExporter] fix exporting array indexes (xabbuh)
This PR was merged into the 4.2 branch.
Discussion
----------
[VarExporter] fix exporting array indexes
| Q | A
| ------------- | ---
| Branch? | 4.2
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #29715
| License | MIT
| Doc PR |
Commits
-------
3c936f447b
[VarExporter] fix exporting array indexes
This commit is contained in:
commit
113ba10f8f
@ -232,7 +232,7 @@ class Exporter
|
|||||||
if (!\is_int($k) || 1 !== $k - $j) {
|
if (!\is_int($k) || 1 !== $k - $j) {
|
||||||
$code .= self::export($k, $subIndent).' => ';
|
$code .= self::export($k, $subIndent).' => ';
|
||||||
}
|
}
|
||||||
if (\is_int($k)) {
|
if (\is_int($k) && $k > $j) {
|
||||||
$j = $k;
|
$j = $k;
|
||||||
}
|
}
|
||||||
$code .= self::export($v, $subIndent).",\n";
|
$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('bool', true, true);
|
||||||
yield array('simple-array', array(123, array('abc')), 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));
|
yield array('datetime', \DateTime::createFromFormat('U', 0));
|
||||||
|
|
||||||
$value = new \ArrayObject();
|
$value = new \ArrayObject();
|
||||||
|
Reference in New Issue
Block a user