/** * @since 3.0.0 * @group issue_58 * @test */ public function stoppingAnnotationPersistenceDoesNotWriteCacheFileOnShutdown() { AnnotationCache::put(new Annotations('someTarget')); AnnotationCache::stop(); AnnotationCache::__shutdown(); assertFalse(file_exists(vfsStream::url('root/annotations.cache'))); }
/** * returns annotations for given reflected * * @param \Reflector|string|object $reflected class name, function name of or object instance to reflect * @param string $methodName optional specific method to reflect * @return \stubbles\reflect\annotation\Annotations * @since 5.3.0 */ function annotationsOf($reflected, string $methodName = null) : Annotations { $reflector = $reflected instanceof \Reflector ? $reflected : reflect($reflected, $methodName); $target = _annotationTarget($reflector); if (AnnotationCache::has($target)) { return AnnotationCache::get($target); } list($sourceTarget) = explode('#', $target); $return = null; foreach (Annotations::parse(docComment($reflector), $sourceTarget) as $annotations) { AnnotationCache::put($annotations); if ($annotations->target() === $target) { $return = $annotations; } } if (null === $return) { $return = new Annotations($target); AnnotationCache::put($return); } return $return; }