Skip to content

Commit

Permalink
ConditionalTagsExtension - validate structure
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed May 9, 2019
1 parent 71fc794 commit 5e160d4
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/DependencyInjection/ConditionalTagsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,33 @@

namespace PHPStan\DependencyInjection;

use Nette;
use Nette\Schema\Expect;
use PHPStan\Analyser\TypeSpecifierFactory;
use PHPStan\Broker\BrokerFactory;
use PHPStan\PhpDoc\TypeNodeResolverFactory;
use PHPStan\Rules\RegistryFactory;

class ConditionalTagsExtension extends \Nette\DI\CompilerExtension
{

public function getConfigSchema(): Nette\Schema\Schema
{
$bool = Expect::bool();
return Expect::arrayOf(Expect::structure([
BrokerFactory::PROPERTIES_CLASS_REFLECTION_EXTENSION_TAG => $bool,
BrokerFactory::METHODS_CLASS_REFLECTION_EXTENSION_TAG => $bool,
BrokerFactory::DYNAMIC_METHOD_RETURN_TYPE_EXTENSION_TAG => $bool,
BrokerFactory::DYNAMIC_STATIC_METHOD_RETURN_TYPE_EXTENSION_TAG => $bool,
BrokerFactory::DYNAMIC_FUNCTION_RETURN_TYPE_EXTENSION_TAG => $bool,
RegistryFactory::RULE_TAG => $bool,
TypeNodeResolverFactory::EXTENSION_TAG => $bool,
TypeSpecifierFactory::FUNCTION_TYPE_SPECIFYING_EXTENSION_TAG => $bool,
TypeSpecifierFactory::METHOD_TYPE_SPECIFYING_EXTENSION_TAG => $bool,
TypeSpecifierFactory::STATIC_METHOD_TYPE_SPECIFYING_EXTENSION_TAG => $bool,
])->min(1));
}

public function beforeCompile(): void
{
/** @var mixed[] $config */
Expand Down

0 comments on commit 5e160d4

Please sign in to comment.