diff --git a/run-test b/run-test index 58d5485..6052560 100755 --- a/run-test +++ b/run-test @@ -1,3 +1,3 @@ #!/bin/bash rm -rf runtime/addendum/* -vendor/bin/codecept run unit "$@"Test.php +vendor/bin/codecept run unit "$@"Test.php --debug diff --git a/src/Addendum.php b/src/Addendum.php index a978f88..44ec763 100644 --- a/src/Addendum.php +++ b/src/Addendum.php @@ -21,7 +21,9 @@ use Maslosoft\Addendum\Collections\AddendumPlugins; use Maslosoft\Addendum\Interfaces\AnnotatedInterface; use Maslosoft\Addendum\Interfaces\AnnotationInterface; +use Maslosoft\Addendum\Matcher\AnnotationsMatcher; use Maslosoft\Addendum\Matcher\ClassLiteralMatcher; +use Maslosoft\Addendum\Plugins\Matcher\DefencerDecorator; use Maslosoft\Addendum\Plugins\Matcher\UseResolverDecorator; use Maslosoft\Addendum\Reflection\ReflectionAnnotatedClass; use Maslosoft\Addendum\Reflection\ReflectionAnnotatedMethod; @@ -36,6 +38,7 @@ use Psr\Log\NullLogger; use ReflectionClass; use ReflectionException; +use Reflector; class Addendum implements LoggerAwareInterface { @@ -76,6 +79,9 @@ class Addendum implements LoggerAwareInterface 'matcher' => [ ClassLiteralMatcher::class => [ UseResolverDecorator::class + ], + AnnotationsMatcher::class => [ + DefencerDecorator::class ] ] ]; @@ -308,10 +314,10 @@ public static function cacheClear() /** * TODO This should not be static - * @param \Reflector $reflection + * @param Reflector $reflection * @return mixed[] */ - public static function getDocComment(\Reflector $reflection) + public static function getDocComment(Reflector $reflection) { // NOTE: Due to a nature of traits, raw doc parsing is always needed // When using reflection's method `getDocComment` it will return diff --git a/src/Builder/DocComment.php b/src/Builder/DocComment.php index c7188ce..9b37516 100644 --- a/src/Builder/DocComment.php +++ b/src/Builder/DocComment.php @@ -70,6 +70,9 @@ public function forFile($name, $className = null) { $fqn = $className; } + /** + * TODO Use some container here with ArrayAccess interface. Array-like access is *required* here. + */ $result = [ 'namespace' => isset(self::$namespaces[$fqn]) ? self::$namespaces[$fqn] : [], 'use' => isset(self::$use[$fqn]) ? self::$use[$fqn] : [], diff --git a/src/Matcher/AnnotationsMatcher.php b/src/Matcher/AnnotationsMatcher.php index c9cfdf8..6688f82 100644 --- a/src/Matcher/AnnotationsMatcher.php +++ b/src/Matcher/AnnotationsMatcher.php @@ -16,14 +16,21 @@ use Maslosoft\Addendum\Exceptions\ParseException; use Maslosoft\Addendum\Interfaces\Matcher\MatcherInterface; +use Maslosoft\Addendum\Matcher\Helpers\Processor; class AnnotationsMatcher implements MatcherInterface { use Traits\PluginsTrait; + protected function process($string) + { + return Processor::process($this, $string); + } + public function matches($string, &$annotations) { + $string = $this->process($string); $annotations = []; $annotationMatcher = new AnnotationMatcher; $annotationMatcher->setPlugins($this->getPlugins()); diff --git a/src/Plugins/Matcher/DefencerDecorator.php b/src/Plugins/Matcher/DefencerDecorator.php new file mode 100644 index 0000000..714bf4b --- /dev/null +++ b/src/Plugins/Matcher/DefencerDecorator.php @@ -0,0 +1,29 @@ + + */ +class DefencerDecorator implements MatcherDecoratorInterface +{ + + public function decorate(MatcherInterface $matcher, &$value) + { + Fence::out($value); + } + +}