Avoid array index warning

This commit is contained in:
David Molineus
2022-02-22 10:10:57 +01:00
parent 700a87bd1f
commit e38e926891
5 changed files with 11 additions and 9 deletions

View File

@@ -18,6 +18,8 @@ use Netzmacht\LeafletPHP\Assets;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use function array_pad;
/** /**
* Class RegisterLibrariesPass. * Class RegisterLibrariesPass.
* *
@@ -43,12 +45,12 @@ class RegisterLibrariesPass implements CompilerPassInterface
foreach ($libraries as $name => $assets) { foreach ($libraries as $name => $assets) {
if (!empty($assets['css'])) { 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]); $definition->addMethodCall('registerStylesheet', [$name, $source, $type ?: Assets::TYPE_FILE]);
} }
if (!empty($assets['javascript'])) { 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]); $definition->addMethodCall('registerJavascript', [$name, $source, $type ?: Assets::TYPE_FILE]);
} }
} }

View File

@@ -93,7 +93,7 @@ class DataController
$filter = null; $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); $this->encodeData($input['format'], $data);
} catch (\Exception $e) { } catch (\Exception $e) {
if ($this->debugMode) { if ($this->debugMode) {

View File

@@ -178,7 +178,7 @@ final class GeoJsonListener
private function parseModelValue(Model $model, &$property) private function parseModelValue(Model $model, &$property)
{ {
if (is_array($property)) { if (is_array($property)) {
list($property, $type) = $property; [$property, $type] = $property;
$value = $model->$property; $value = $model->$property;
switch ($type) { switch ($type) {

View File

@@ -143,12 +143,12 @@ class LoadAssetsListener
$assets = $this->libraries[$library]; $assets = $this->libraries[$library];
if (!empty($assets['css'])) { 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); $this->assets->addStylesheet($source, $type ?: Assets::TYPE_FILE);
} }
if (!empty($assets['javascript'])) { 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); $this->assets->addJavascript($source, $type ?: Assets::TYPE_FILE);
} }
} }

View File

@@ -60,11 +60,11 @@ final class RegisterLibrariesListener
{ {
foreach ($this->libraries as $name => $assets) { foreach ($this->libraries as $name => $assets) {
if (!empty($assets['css'])) { 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); $this->leaflet->registerStylesheet($name, $source, $type ?: Assets::TYPE_FILE);
} }
if (!empty($assets['javascript'])) { 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); $this->leaflet->registerJavascript($name, $source, $type ?: Assets::TYPE_FILE);
} }
} }