From e38e92689165dd7fc7a6e018ce79ea249aa08c93 Mon Sep 17 00:00:00 2001 From: David Molineus Date: Tue, 22 Feb 2022 10:10:57 +0100 Subject: [PATCH] Avoid array index warning --- .../DependencyInjection/Pass/RegisterLibrariesPass.php | 6 ++++-- src/Frontend/DataController.php | 2 +- src/Listener/GeoJsonListener.php | 4 ++-- src/Listener/LoadAssetsListener.php | 4 ++-- src/Listener/RegisterLibrariesListener.php | 4 ++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Bundle/DependencyInjection/Pass/RegisterLibrariesPass.php b/src/Bundle/DependencyInjection/Pass/RegisterLibrariesPass.php index 84b4bdc..55d51b9 100644 --- a/src/Bundle/DependencyInjection/Pass/RegisterLibrariesPass.php +++ b/src/Bundle/DependencyInjection/Pass/RegisterLibrariesPass.php @@ -18,6 +18,8 @@ use Netzmacht\LeafletPHP\Assets; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; +use function array_pad; + /** * Class RegisterLibrariesPass. * @@ -43,12 +45,12 @@ class RegisterLibrariesPass implements CompilerPassInterface foreach ($libraries as $name => $assets) { if (!empty($assets['css'])) { - list ($source, $type) = (array) $assets['css']; + [$source, $type] = array_pad((array) $assets['css'], 2, null); $definition->addMethodCall('registerStylesheet', [$name, $source, $type ?: Assets::TYPE_FILE]); } if (!empty($assets['javascript'])) { - list ($source, $type) = (array) $assets['javascript']; + [$source, $type] = array_pad((array) $assets['javascript'], 2, null); $definition->addMethodCall('registerJavascript', [$name, $source, $type ?: Assets::TYPE_FILE]); } } diff --git a/src/Frontend/DataController.php b/src/Frontend/DataController.php index 563b5e6..75839af 100644 --- a/src/Frontend/DataController.php +++ b/src/Frontend/DataController.php @@ -93,7 +93,7 @@ class DataController $filter = null; } - list($data, $error) = $this->loadData($mapProvider, $input['type'], $input['id'], $filter); + [$data, $error] = $this->loadData($mapProvider, $input['type'], $input['id'], $filter); $this->encodeData($input['format'], $data); } catch (\Exception $e) { if ($this->debugMode) { diff --git a/src/Listener/GeoJsonListener.php b/src/Listener/GeoJsonListener.php index 4f5702f..3b0f37f 100644 --- a/src/Listener/GeoJsonListener.php +++ b/src/Listener/GeoJsonListener.php @@ -178,8 +178,8 @@ final class GeoJsonListener private function parseModelValue(Model $model, &$property) { if (is_array($property)) { - list($property, $type) = $property; - $value = $model->$property; + [$property, $type] = $property; + $value = $model->$property; switch ($type) { case 'array': diff --git a/src/Listener/LoadAssetsListener.php b/src/Listener/LoadAssetsListener.php index e6954c8..e027e8a 100644 --- a/src/Listener/LoadAssetsListener.php +++ b/src/Listener/LoadAssetsListener.php @@ -143,12 +143,12 @@ class LoadAssetsListener $assets = $this->libraries[$library]; if (!empty($assets['css'])) { - list ($source, $type) = (array) $assets['css']; + [$source, $type] = array_pad((array) $assets['css'], 2, null); $this->assets->addStylesheet($source, $type ?: Assets::TYPE_FILE); } if (!empty($assets['javascript'])) { - list ($source, $type) = (array) $assets['javascript']; + [$source, $type] = array_pad((array) $assets['javascript'], 2, null); $this->assets->addJavascript($source, $type ?: Assets::TYPE_FILE); } } diff --git a/src/Listener/RegisterLibrariesListener.php b/src/Listener/RegisterLibrariesListener.php index 96fbc85..e27699c 100644 --- a/src/Listener/RegisterLibrariesListener.php +++ b/src/Listener/RegisterLibrariesListener.php @@ -60,11 +60,11 @@ final class RegisterLibrariesListener { foreach ($this->libraries as $name => $assets) { if (!empty($assets['css'])) { - list ($source, $type) = (array) $assets['css']; + [$source, $type] = array_pad((array) $assets['css'], 2, null); $this->leaflet->registerStylesheet($name, $source, $type ?: Assets::TYPE_FILE); } if (!empty($assets['javascript'])) { - list ($source, $type) = (array) $assets['javascript']; + [$source, $type] = array_pad((array) $assets['javascript'], 2, null); $this->leaflet->registerJavascript($name, $source, $type ?: Assets::TYPE_FILE); } }