Skip to content

Commit

Permalink
Merge pull request #489 from pirate-ship-software/annotations2
Browse files Browse the repository at this point in the history
Migrate to doctrine/annotations 2.x
  • Loading branch information
lisachenko authored Feb 7, 2024
2 parents b10821b + 32b897b commit 2801484
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

"require": {
"php": "^7.4.0",
"doctrine/annotations": "^1.11.1",
"doctrine/annotations": "^2.0",
"doctrine/cache": "^1.10",
"goaop/parser-reflection": "^3.0.1",
"jakubledl/dissect": "~1.0",
Expand Down
7 changes: 4 additions & 3 deletions src/Core/GoAspectContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace Go\Core;

use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\CachedReader;
use Doctrine\Common\Annotations\PsrCachedReader;
use Doctrine\Common\Cache as DoctrineCache;
use Go\Aop\Advisor;
use Go\Aop\Aspect;
Expand Down Expand Up @@ -104,10 +104,11 @@ public function __construct()

$this->share('aspect.annotation.reader', function (Container $container) {
$options = $container->get('kernel.options');
$annotationCache = $container->get('aspect.annotation.cache');

return new CachedReader(
return new PsrCachedReader(
new AnnotationReader(),
$container->get('aspect.annotation.cache'),
new DoctrineCache\Psr6\CacheAdapter($annotationCache),

Check failure on line 111 in src/Core/GoAspectContainer.php

View workflow job for this annotation

GitHub Actions / build

Cannot instantiate class Doctrine\Common\Cache\Psr6\CacheAdapter via private constructor Doctrine\Common\Cache\Psr6\CacheAdapter::__construct().
$options['debug'] ?? false
);
});
Expand Down
8 changes: 0 additions & 8 deletions src/Instrument/ClassLoading/AopComposerLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Go\Instrument\PathResolver;
use Go\Instrument\Transformer\FilterInjectorTransformer;
use Composer\Autoload\ClassLoader;
use Doctrine\Common\Annotations\AnnotationRegistry;

/**
* AopComposerLoader class is responsible to use a weaver for classes instead of original one
Expand Down Expand Up @@ -92,13 +91,6 @@ public static function init(array $options, AspectContainer $container): bool
foreach ($loaders as &$loader) {
$loaderToUnregister = $loader;
if (is_array($loader) && ($loader[0] instanceof ClassLoader)) {
$originalLoader = $loader[0];
// Configure library loader for doctrine annotation loader
AnnotationRegistry::registerLoader(function($class) use ($originalLoader) {
$originalLoader->loadClass($class);

return class_exists($class, false);
});
$loader[0] = new AopComposerLoader($loader[0], $container, $options);
self::$wasInitialized = true;
}
Expand Down

0 comments on commit 2801484

Please sign in to comment.