[Validator] Ensure numeric subpaths do not cause errors on PHP 7.4
This commit is contained in:
parent
5d097d2eb5
commit
6244a1ec47
@ -32,6 +32,7 @@ class PropertyPathTest extends TestCase
|
|||||||
['foo', 'bar', 'foo.bar', 'It append the subPath to the basePath'],
|
['foo', 'bar', 'foo.bar', 'It append the subPath to the basePath'],
|
||||||
['foo', '[bar]', 'foo[bar]', 'It does not include the dot separator if subPath uses the array notation'],
|
['foo', '[bar]', 'foo[bar]', 'It does not include the dot separator if subPath uses the array notation'],
|
||||||
['0', 'bar', '0.bar', 'Leading zeros are kept.'],
|
['0', 'bar', '0.bar', 'Leading zeros are kept.'],
|
||||||
|
['0', 1, '0.1', 'Numeric subpaths do not cause PHP 7.4 errors.'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,12 +36,13 @@ class PropertyPath
|
|||||||
*/
|
*/
|
||||||
public static function append($basePath, $subPath)
|
public static function append($basePath, $subPath)
|
||||||
{
|
{
|
||||||
if ('' !== (string) $subPath) {
|
$subPath = (string) $subPath;
|
||||||
|
if ('' !== $subPath) {
|
||||||
if ('[' === $subPath[0]) {
|
if ('[' === $subPath[0]) {
|
||||||
return $basePath.$subPath;
|
return $basePath.$subPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
return '' !== (string) $basePath ? $basePath.'.'.$subPath : $subPath;
|
return '' !== $basePath ? $basePath.'.'.$subPath : $subPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $basePath;
|
return $basePath;
|
||||||
|
Reference in New Issue
Block a user