Skip to content

Commit

Permalink
Dep update (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
Slamdunk authored May 10, 2021
1 parent f743b61 commit aae048a
Show file tree
Hide file tree
Showing 36 changed files with 93 additions and 179 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/tests export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.php_cs export-ignore
.php-cs-fixer.php export-ignore
Makefile export-ignore
phpstan.neon export-ignore
phpunit.xml export-ignore
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.idea/
tmp/
vendor/
.php_cs.cache
.php-cs-fixer.cache
.phpunit.result.cache
composer.lock
File renamed without changes.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ all: csfix static-analysis test
@echo "Done."

vendor: composer.json
composer update
composer update --ignore-platform-reqs
touch vendor

.PHONY: csfix
Expand Down
45 changes: 29 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,37 @@
],
"require": {
"php": "^7.4 || ^8.0",
"laminas/laminas-mvc": "^3.1.1",
"phpstan/phpstan": "^0.12.50"
"laminas/laminas-mvc": "^3.2.0",
"phpstan/phpstan": "^0.12.86"
},
"conflict": {
"laminas/laminas-cache": "<2.11",
"laminas/laminas-filter": "<2.11",
"laminas/laminas-form": "<2.16",
"laminas/laminas-hydrator": "<4.0",
"laminas/laminas-i18n": "<2.11",
"laminas/laminas-inputfilter": "<2.12",
"laminas/laminas-log": "<2.13",
"laminas/laminas-mail": "<2.14",
"laminas/laminas-paginator": "<2.10",
"laminas/laminas-validator": "<2.14"
},
"require-dev": {
"laminas/laminas-cache": "^2.9.0",
"laminas/laminas-filter": "^2.9.4",
"laminas/laminas-form": "^2.15.0",
"laminas/laminas-hydrator": "^3.2 || ^4.0",
"laminas/laminas-i18n": "^2.10.3",
"laminas/laminas-inputfilter": "^2.10.1",
"laminas/laminas-log": "^2.12.0",
"laminas/laminas-mail": "^2.12.3",
"laminas/laminas-paginator": "^2.9.0",
"laminas/laminas-validator": "^2.13.4",
"phpstan/phpstan-phpunit": "^0.12.16",
"phpunit/phpunit": "^9.4.2",
"slam/php-cs-fixer-extensions": "^2.0.0",
"slam/php-debug-r": "^1.6.1"
"laminas/laminas-cache": "^2.11.1",
"laminas/laminas-filter": "^2.11.0",
"laminas/laminas-form": "^2.16.3",
"laminas/laminas-hydrator": "^4.1.0",
"laminas/laminas-i18n": "^2.11.1",
"laminas/laminas-inputfilter": "^2.12.0",
"laminas/laminas-log": "^2.13.1",
"laminas/laminas-mail": "^2.14.0",
"laminas/laminas-paginator": "^2.10.0",
"laminas/laminas-validator": "^2.14.4",
"malukenho/mcbumpface": "^1.1.5",
"phpstan/phpstan-phpunit": "^0.12.18",
"phpunit/phpunit": "^9.5.4",
"slam/php-cs-fixer-extensions": "^v3.0.1",
"slam/php-debug-r": "^v1.7.0"
},
"extra": {
"phpstan": {
Expand Down
10 changes: 2 additions & 8 deletions src/Rules/Laminas/ServiceManagerGetMethodCallRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,9 @@
*/
final class ServiceManagerGetMethodCallRule implements Rule
{
/**
* @var Broker
*/
private $broker;
private Broker $broker;

/**
* @var ServiceManagerLoader
*/
private $serviceManagerLoader;
private ServiceManagerLoader $serviceManagerLoader;

public function __construct(Broker $broker, ServiceManagerLoader $serviceManagerLoader)
{
Expand Down
18 changes: 5 additions & 13 deletions src/ServiceManagerLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@

final class ServiceManagerLoader
{
/**
* @var ServiceLocatorInterface
*/
private $serviceLocator;
private ?UnmappedAliasServiceLocatorProxy $serviceLocator = null;

/**
* @var string[]
*/
private $knownModules = [
private array $knownModules = [
\Laminas\Cache\Module::class,
\Laminas\Filter\Module::class,
\Laminas\Form\Module::class,
Expand All @@ -38,7 +35,7 @@ final class ServiceManagerLoader
/**
* @var array<string, true>
*/
private $serviceManagerNames = [
private array $serviceManagerNames = [
ServiceManager::class => true,
ServiceLocatorInterface::class => true,
InteropContainerInterface::class => true,
Expand All @@ -60,12 +57,7 @@ public function __construct(?string $serviceManagerLoader)
throw new \PHPStan\ShouldNotHappenException(\sprintf('Loader "%s" doesn\'t return a ServiceManager instance', $serviceManagerLoader));
}

$this->setServiceLocator($serviceManager);
}

private function setServiceLocator(ServiceLocatorInterface $serviceLocator): void
{
$this->serviceLocator = new UnmappedAliasServiceLocatorProxy($serviceLocator);
$this->serviceLocator = new UnmappedAliasServiceLocatorProxy($serviceManager);
}

public function getServiceLocator(string $serviceManagerName): ServiceLocatorInterface
Expand All @@ -86,7 +78,7 @@ public function getServiceLocator(string $serviceManagerName): ServiceLocatorInt
$serviceManager->setService('ApplicationConfig', $config);
$serviceManager->get(ModuleManager::class)->loadModules();

$this->setServiceLocator($serviceManager);
$this->serviceLocator = new UnmappedAliasServiceLocatorProxy($serviceManager);
}

$serviceLocator = $this->serviceLocator;
Expand Down
10 changes: 2 additions & 8 deletions src/Type/Laminas/ControllerPluginClassReflectionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,9 @@

final class ControllerPluginClassReflectionExtension implements BrokerAwareExtension, MethodsClassReflectionExtension
{
/**
* @var ServiceManagerLoader
*/
private $serviceManagerLoader;
private ServiceManagerLoader $serviceManagerLoader;

/**
* @var Broker
*/
private $broker;
private Broker $broker;

public function __construct(ServiceManagerLoader $serviceManagerLoader)
{
Expand Down
5 changes: 1 addition & 4 deletions src/Type/Laminas/ObjectServiceManagerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@

final class ObjectServiceManagerType extends ObjectType
{
/**
* @var string
*/
private $serviceName;
private string $serviceName;

public function __construct(string $className, string $serviceName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@

abstract class AbstractPluginMethodDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension
{
/**
* @var ServiceManagerLoader
*/
private $serviceManagerLoader;
private ServiceManagerLoader $serviceManagerLoader;

final public function __construct(ServiceManagerLoader $serviceManagerLoader)
{
Expand Down Expand Up @@ -52,7 +49,8 @@ final public function getTypeFromMethodCall(
return ParametersAcceptorSelector::selectFromArgs($scope, $methodCall->args, $methodReflection->getVariants())->getReturnType();
}

throw new \PHPStan\ShouldNotHappenException(\sprintf('Argument passed to %s::%s should be a string, %s given',
throw new \PHPStan\ShouldNotHappenException(\sprintf(
'Argument passed to %s::%s should be a string, %s given',
$methodReflection->getDeclaringClass()->getName(),
$methodReflection->getName(),
$argType->describe(VerbosityLevel::value())
Expand Down
15 changes: 3 additions & 12 deletions src/Type/Laminas/PluginMethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,11 @@

final class PluginMethodReflection implements MethodReflection
{
/**
* @var ClassReflection
*/
private $declaringClass;
private ClassReflection $declaringClass;

/**
* @var string
*/
private $name;
private string $name;

/**
* @var ObjectType
*/
private $returnType;
private ObjectType $returnType;

public function __construct(
ClassReflection $declaringClass,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@

abstract class AbstractServiceGetterDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension
{
/**
* @var ServiceManagerLoader
*/
private $serviceManagerLoader;
private ServiceManagerLoader $serviceManagerLoader;

/**
* @var array<string, string>
*/
protected $methodToServiceMap = [
protected array $methodToServiceMap = [
'getApplication' => 'Application',
'getRenderer' => RendererInterface::class,
'getRequest' => 'Request',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class ViewHelperGetterDynamicReturnTypeExtension extends AbstractServiceGe
/**
* @var array<string, string>
*/
protected $methodToServiceMap = [
protected array $methodToServiceMap = [
'getView' => RendererInterface::class,
];

Expand Down
12 changes: 3 additions & 9 deletions src/Type/Laminas/ServiceManagerGetDynamicReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,9 @@

final class ServiceManagerGetDynamicReturnTypeExtension implements BrokerAwareExtension, DynamicMethodReturnTypeExtension
{
/**
* @var ServiceManagerLoader
*/
private $serviceManagerLoader;

/**
* @var Broker
*/
private $broker;
private ServiceManagerLoader $serviceManagerLoader;

private Broker $broker;

public function __construct(ServiceManagerLoader $serviceManagerLoader)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,13 @@ public function hasProperty(ClassReflection $classReflection, string $propertyNa
public function getProperty(ClassReflection $classReflection, string $propertyName): PropertyReflection
{
return new class($classReflection, $propertyName, $this->getGetterName($propertyName), $this->getSetterName($propertyName)) implements PropertyReflection {
/**
* @var ClassReflection
*/
private $classReflection;
/**
* @var string
*/
private $propertyName;
/**
* @var string
*/
private $getterName;
/**
* @var string
*/
private $setterName;
private ClassReflection $classReflection;

private string $propertyName;

private string $getterName;

private string $setterName;

public function __construct(ClassReflection $classReflection, string $propertyName, string $getterName, string $setterName)
{
Expand Down
17 changes: 2 additions & 15 deletions src/UnmappedAliasServiceLocatorProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

namespace LaminasPhpStan;

use Laminas\Cache\PatternPluginManager;
use Laminas\Cache\PatternPluginManager\PatternPluginManagerV3Polyfill;
use Laminas\Form\FormElementManager\FormElementManagerV3Polyfill;
use Laminas\Log\FilterPluginManager as LogFilterPluginManager;
use Laminas\Log\FormatterPluginManager as LogFormatterPluginManager;
use Laminas\Log\ProcessorPluginManager as LogProcessorPluginManager;
Expand All @@ -18,28 +15,18 @@

final class UnmappedAliasServiceLocatorProxy implements ServiceLocatorInterface
{
/**
* @var ServiceLocatorInterface
*/
private $serviceLocator;
private ServiceLocatorInterface $serviceLocator;

/**
* @var array<string, string>
*/
private $knownUnmappedAliasToClassServices = [
private array $knownUnmappedAliasToClassServices = [
ControllerManager::class => 'ControllerManager',
FormElementManagerV3Polyfill::class => 'FormElementManager',
HelperPluginManager::class => 'ViewHelperManager',
LogFilterPluginManager::class => 'LogFilterManager',
LogFormatterPluginManager::class => 'LogFormatterManager',
LogProcessorPluginManager::class => 'LogProcessorManager',
LogWriterPluginManager::class => 'LogWriterManager',
PatternPluginManagerV3Polyfill::class => PatternPluginManager::class,

// As string to not autoload them in static analysis, otherwise we would get
// a PHP Warning: Declaration of [...] should be compatible with [...] error
'\Laminas\Form\FormElementManager\FormElementManager' . 'V2Polyfill' => 'FormElementManager',
'\Laminas\Cache\PatternPluginManager\PatternPluginManager' . 'V2Polyfill' => PatternPluginManager::class,
];

public function __construct(ServiceLocatorInterface $serviceLocator)
Expand Down
2 changes: 1 addition & 1 deletion tests/LaminasIntegration/data/controllerMethod-0.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"message": "The service \"foobar\" was not configured in Laminas\\Mvc\\Controller\\ControllerManager.",
"line": 25,
"line": 22,
"ignorable": true
}
]
5 changes: 1 addition & 4 deletions tests/LaminasIntegration/data/controllerMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@

final class controllerMethod
{
/**
* @var ControllerManager
*/
private $controllerManager;
private ControllerManager $controllerManager;

public function __construct(ServiceManager $serviceManager)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[
{
"message": "Call to an undefined method Laminas\\View\\Helper\\Url::foobar().",
"line": 22,
"line": 19,
"ignorable": true
},
{
"message": "Call to an undefined method Laminas\\View\\Helper\\AbstractHelper::foobar().",
"line": 28,
"line": 25,
"ignorable": true
}
]
5 changes: 1 addition & 4 deletions tests/LaminasIntegration/data/pluginMethodDynamicReturn.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@

final class pluginMethodDynamicReturn
{
/**
* @var PhpRenderer
*/
private $phpRenderer;
private PhpRenderer $phpRenderer;

public function getDynamicTypeFromStaticString(): void
{
Expand Down
Loading

0 comments on commit aae048a

Please sign in to comment.