Skip to content

Commit

Permalink
CS Fix, dep update
Browse files Browse the repository at this point in the history
  • Loading branch information
Slamdunk committed Apr 14, 2020
1 parent 6a46872 commit 8b05d04
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .php_cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$config = new SlamCsFixer\Config(SlamCsFixer\Config::LIB);
$config = new SlamCsFixer\Config();
$config->getFinder()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
},
"require-dev": {
"phpstan/phpstan-phpunit": "^0.12",
"phpunit/phpunit": "^8.5",
"phpunit/phpunit": "^9.1",
"roave/security-advisories": "dev-master",
"slam/php-cs-fixer-extensions": "^1.19",
"slam/php-cs-fixer-extensions": "^2.0",
"slam/php-debug-r": "^1.6",
"laminas/laminas-cache": "^2.8",
"laminas/laminas-filter": "^2.9",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Reflection\ParametersAcceptorSelector;
use PHPStan\Type\Constant\ConstantStringType;
use PHPStan\Type\DynamicMethodReturnTypeExtension;
use PHPStan\Type\ObjectType;
use PHPStan\Type\StringType;
Expand Down Expand Up @@ -41,16 +40,16 @@ final public function getTypeFromMethodCall(
): Type {
$argType = $scope->getType($methodCall->args[0]->value);
$strings = TypeUtils::getConstantStrings($argType);
$plugin = count($strings) === 1 ? $strings[0]->getValue() : null;
if ($plugin) {
$plugin = 1 === \count($strings) ? $strings[0]->getValue() : null;

if (null !== $plugin) {
$pluginManager = $this->serviceManagerLoader->getServiceLocator($this->getPluginManagerName());

return new ObjectType(\get_class($pluginManager->get($plugin)));
}

if ($argType instanceof StringType) {
$defaultReturnType = ParametersAcceptorSelector::selectFromArgs($scope, $methodCall->args, $methodReflection->getVariants())->getReturnType();
return $defaultReturnType;
if ($argType instanceof StringType) {
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',
Expand Down
3 changes: 1 addition & 2 deletions tests/LaminasIntegration/data/pluginMethodDynamicReturn.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace LaminasPhpStan\Tests\LaminasIntegration\data;

use Laminas\Router\SimpleRouteStack;
use Laminas\View\Renderer\PhpRenderer;
use Laminas\View\Helper\AbstractHelper;
use Laminas\View\Renderer\PhpRenderer;

final class pluginMethodDynamicReturn
{
Expand All @@ -32,5 +32,4 @@ public function getDynamicTypeFromStringVariable(string $name): AbstractHelper
{
return $this->phpRenderer->plugin($name);
}

}

0 comments on commit 8b05d04

Please sign in to comment.