Browse Source

Add support for Laminas

tags/1.5.0
Anton Smirnov 1 month ago
parent
commit
6012d94a5a
3 changed files with 14 additions and 5 deletions
  1. +2
    -2
      composer.json
  2. +9
    -1
      src/Containers/Zend/ServiceManagerIterator.php
  3. +3
    -2
      src/Generator.php

+ 2
- 2
composer.json View File

@@ -24,13 +24,13 @@
"php": ">= 7.0"
},
"require-dev": {
"laminas/laminas-servicemanager": "^3.0",
"php-di/php-di": "^6.0",
"pimple/pimple": "^3.0",
"psr/http-server-middleware": "^1.0",
"psy/psysh": "*",
"silex/silex": "^2.0",
"slim/slim": "^3.0",
"sllh/composer-versions-check": "^2.0",
"zendframework/zend-servicemanager": "^3.0"
"sllh/composer-versions-check": "^2.0"
}
}

+ 9
- 1
src/Containers/Zend/ServiceManagerIterator.php View File

@@ -4,7 +4,14 @@ namespace SandFox\PhpStorm\Metadata\Containers\Zend;

use SandFox\PhpStorm\Metadata\Common\Helpers\TypeStrings;
use SandFox\PhpStorm\Metadata\Containers\ContainerIterator;
use Zend\ServiceManager\ServiceManager;

// Laminas replaces Zend so add an alias for the installed one

if (class_exists(\Laminas\ServiceManager\ServiceManager::class)) {
class_alias(\Laminas\ServiceManager\ServiceManager::class, ServiceManager::class);
} elseif (class_exists(\Zend\ServiceManager\ServiceManager::class)) {
class_alias(\Zend\ServiceManager\ServiceManager::class, ServiceManager::class);
}

/**
* @internal
@@ -15,6 +22,7 @@ class ServiceManagerIterator implements ContainerIterator
'overrides' => [
'\\Psr\\Container\\ContainerInterface::get(0)',
'\\Zend\\ServiceManager\\ServiceLocatorInterface::get(0)',
'\\Laminas\\ServiceManager\\ServiceLocatorInterface::get(0)',
],
];


+ 3
- 2
src/Generator.php View File

@@ -3,13 +3,14 @@
namespace SandFox\PhpStorm\Metadata;

use DI\Container as DI;
use Laminas\ServiceManager\ServiceManager as LaminasServiceManager;
use Pimple\Container as Pimple;
use SandFox\PhpStorm\Metadata\Common\Metadata;
use SandFox\PhpStorm\Metadata\Containers\DI\DIIterator;
use SandFox\PhpStorm\Metadata\Containers\Pimple\PimpleIterator;
use SandFox\PhpStorm\Metadata\Containers\StaticMap\StaticMapIterator;
use SandFox\PhpStorm\Metadata\Containers\Zend\ServiceManagerIterator;
use Zend\ServiceManager\ServiceManager;
use Zend\ServiceManager\ServiceManager as ZendServiceManager;

final class Generator
{
@@ -78,7 +79,7 @@ final class Generator
return PimpleIterator::class;
}

if ($container instanceof ServiceManager) {
if ($container instanceof LaminasServiceManager || $container instanceof ZendServiceManager) {
return ServiceManagerIterator::class;
}


Loading…
Cancel
Save