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\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]);
}
}

View File

@@ -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) {

View File

@@ -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':

View File

@@ -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);
}
}

View File

@@ -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);
}
}