PluginProbe
Media Cloud Sync / 1.4.2
Media Cloud Sync v1.4.2
1.4.2 1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 All 36 releases
← All changes | includes/sdk/s3/Aws/EndpointV2/Ruleset/RulesetStandardLibrary.php +8 -2 1.2.13 → 1.4.2 View file →
@@ -54,8 +54,13 @@
54 54 * @return mixed
55 55 */
56 56 public function getAttr($from, $path)
57 57 {
58 + // Handles the case where "[<int|string]" is provided as the top-level path
59 + if (\preg_match('/^\\[(\\w+)\\]$/', $path, $matches)) {
60 + $index = \is_numeric($matches[1]) ? (int) $matches[1] : $matches[1];
61 + return $from[$index] ?? null;
62 + }
58 63 $parts = \explode('.', $path);
59 64 foreach ($parts as $part) {
60 65 $sliceIdx = \strpos($part, '[');
61 66 if ($sliceIdx !== \false) {
@@ -61,10 +66,11 @@
61 66 if ($sliceIdx !== \false) {
62 67 if (\substr($part, -1) !== ']') {
63 68 return null;
64 69 }
65 - $slice = \intval(\substr($part, $sliceIdx + 1, \strlen($part) - 1));
66 - $from = isset($from[\substr($part, 0, $sliceIdx)][$slice]) ? $from[\substr($part, 0, $sliceIdx)][$slice] : null;
70 + $slice = (int) \substr($part, $sliceIdx + 1, \strlen($part) - 1);
71 + $fromIndex = \substr($part, 0, $sliceIdx);
72 + $from = $from[$fromIndex][$slice] ?? null;
67 73 } else {
68 74 $from = $from[$part];
69 75 }
70 76 }