Skip to content

Commit 8f2d7be

Browse files
Upgrade doctrine/annotations to 2.0 and refactor code to fit it
1 parent 6e117e9 commit 8f2d7be

File tree

4 files changed

+9
-16
lines changed

4 files changed

+9
-16
lines changed

GearmanBundle.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace Mmoreram\GearmanBundle;
44

55
use Doctrine\Common\Annotations\AnnotationRegistry;
6+
use Mmoreram\GearmanBundle\Driver\Gearman\Work;
7+
use Mmoreram\GearmanBundle\Driver\Gearman\Job;
68
use Symfony\Component\HttpKernel\Bundle\Bundle;
79

810
class GearmanBundle extends Bundle
@@ -12,16 +14,7 @@ class GearmanBundle extends Bundle
1214
*/
1315
public function boot()
1416
{
15-
$kernel = $this->container->get('kernel');
16-
17-
AnnotationRegistry::registerFile(
18-
$kernel
19-
->locateResource("@GearmanBundle/Driver/Gearman/Work.php")
20-
);
21-
22-
AnnotationRegistry::registerFile(
23-
$kernel
24-
->locateResource("@GearmanBundle/Driver/Gearman/Job.php")
25-
);
17+
AnnotationRegistry::loadAnnotationClass(Work::class);
18+
AnnotationRegistry::loadAnnotationClass(Job::class);
2619
}
2720
}

Tests/Module/WorkerClassTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace Mmoreram\GearmanBundle\Tests\Module;
1515

16-
use Doctrine\Common\Annotations\SimpleAnnotationReader;
16+
use Doctrine\Common\Annotations\AnnotationReader;
1717

1818
use Mmoreram\GearmanBundle\Driver\Gearman\Work as WorkAnnotation;
1919
use Mmoreram\GearmanBundle\Module\WorkerClass;
@@ -38,7 +38,7 @@ class WorkerClassTest extends \PHPUnit\Framework\TestCase
3838
private $reflectionClass;
3939

4040
/**
41-
* @var SimpleAnnotationReader
41+
* @var AnnotationReader
4242
*
4343
* Reader
4444
*/
@@ -115,7 +115,7 @@ public function setUp(): void
115115
->getMock();
116116

117117
$this->reader = $this
118-
->getMockBuilder('Doctrine\Common\Annotations\SimpleAnnotationReader')
118+
->getMockBuilder('Doctrine\Common\Annotations\AnnotationReader')
119119
->disableOriginalConstructor()
120120
->setMethods([
121121
'getMethodAnnotations',

Tests/Service/GearmanParserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public function testParseNamespaceMapSomePaths()
188188
$excludedPaths = [];
189189

190190
$reader = $this
191-
->getMockBuilder('\Doctrine\Common\Annotations\SimpleAnnotationReader')
191+
->getMockBuilder('\Doctrine\Common\Annotations\AnnotationReader')
192192
->setMethods(null)
193193
->getMock();
194194

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"require": {
2626
"php": "^7.4 || ^8.0",
2727
"ext-gearman": "*",
28-
"doctrine/annotations": "^1.5",
28+
"doctrine/annotations": "^2.0",
2929
"symfony/dependency-injection": "^4.0 || ^5.0 || ^6.0",
3030
"symfony/yaml": "^4.4 || ^5.0 || ^6.0",
3131
"symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0",

0 commit comments

Comments
 (0)