...
 
Commits (2)
......@@ -2,7 +2,7 @@
"name": "hgraca/app-mapper",
"type": "project",
"license": "MIT",
"description": "A static analysis tool that can draw an application map, which is similar to a application map but more detailed and accurate.",
"description": "A static analysis tool that can draw an application map, which is similar to a DDD contex map but more detailed and accurate.",
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
......
......@@ -24,6 +24,14 @@ final class UnknownParameterException extends ParserException
{
public function __construct(ParamNodeDecorator $searchParamDecorator)
{
parent::__construct('Unknown parameter ' . $searchParamDecorator->getName());
$parameterName = $searchParamDecorator->getName();
$method = $searchParamDecorator->getEnclosingMethodNode();
$methodName = $method->getName();
$className = $method->getEnclosingClassLikeNode()->getName();
parent::__construct(
"Unknown parameter '$parameterName' in method '$methodName' in class '$className'.\n"
. $searchParamDecorator->resolveNodeTreeAsJson()
);
}
}
<?php
declare(strict_types=1);
/*
* This file is part of the Application mapper application,
* following the Explicit Architecture principles.
*
* @link https://herbertograca.com/2017/11/16/explicit-architecture-01-ddd-hexagonal-onion-clean-cqrs-how-i-put-it-all-together
* @link https://herbertograca.com/2018/07/07/more-than-concentric-layers/
*
* (c) Herberto Graça
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Hgraca\AppMapper\Infrastructure\Parser\NikicPhpParser\Visitor\NodeDecorator;
use Hgraca\AppMapper\Infrastructure\Parser\NikicPhpParser\Visitor\TypeCollection;
final class ClosureNodeDecorator extends AbstractNodeDecorator
{
public function resolveTypeCollection(): TypeCollection
{
return new TypeCollection();
}
}
......@@ -50,7 +50,8 @@ final class ParamNodeDecorator extends AbstractNodeDecorator implements NamedNod
$this->getDefaultValueTypeCollection()
);
if ($this->isWithinClass() && !$typeCollection->isConcrete()) {
if ($this->isWithinClass() && !$typeCollection->isConcrete() && !$this->isParameterOfClosure()) {
// FIXME this makes it VERY slow! We need to investigate why and maybe make it optional using a CLI param.
$this->addTypesFromMethodCallsArgument();
}
......@@ -127,14 +128,16 @@ final class ParamNodeDecorator extends AbstractNodeDecorator implements NamedNod
return $this->getFirstParentNodeOfType(ClassMethodNodeDecorator::class);
}
/**
* @return bool
*/
private function isWithinClass(): bool
{
return $this->getEnclosingInterfaceLikeNode() instanceof StmtClassNodeDecorator;
}
private function isParameterOfClosure(): bool
{
return $this->getParentNode() instanceof ClosureNodeDecorator;
}
/**
* @param TypeCollection $typeCollection
*
......