Skip to content

Commit e064b6f

Browse files
committed
add StaticReflectionService backport for doctrine/persistence
1 parent 2b80d6b commit e064b6f

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

src/Doctrine/DoctrineHelper.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
use Doctrine\Persistence\Mapping\Driver\MappingDriver;
2525
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;
2626
use Doctrine\Persistence\Mapping\MappingException as PersistenceMappingException;
27-
use Doctrine\Persistence\Mapping\StaticReflectionService;
2827
use Symfony\Bundle\MakerBundle\Util\ClassNameDetails;
2928
use Symfony\Component\Uid\Ulid;
3029
use Symfony\Component\Uid\Uuid;
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony MakerBundle package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\MakerBundle\Doctrine;
13+
14+
use Doctrine\Persistence\Mapping\ReflectionService;
15+
16+
/**
17+
* @internal replacing removed Doctrine\Persistence\Mapping\StaticReflectionService
18+
*/
19+
final class StaticReflectionService implements ReflectionService
20+
{
21+
public function getParentClasses(string $class): array
22+
{
23+
return [];
24+
}
25+
26+
public function getClassShortName(string $class): string
27+
{
28+
$nsSeparatorLastPosition = strrpos($class, '\\');
29+
30+
if ($nsSeparatorLastPosition !== false) {
31+
$class = substr($class, $nsSeparatorLastPosition + 1);
32+
}
33+
34+
return $class;
35+
}
36+
37+
public function getClassNamespace(string $class): string
38+
{
39+
$namespace = '';
40+
41+
if (strpos($class, '\\') !== false) {
42+
$namespace = strrev(substr(strrev($class), (int) strpos(strrev($class), '\\') + 1));
43+
}
44+
45+
return $namespace;
46+
}
47+
48+
public function getClass(string $class): \ReflectionClass
49+
{
50+
return new \ReflectionClass($class);
51+
}
52+
53+
public function getAccessibleProperty(string $class, string $property): ?\ReflectionProperty
54+
{
55+
return null;
56+
}
57+
58+
public function hasPublicMethod(string $class, string $method): bool
59+
{
60+
return true;
61+
}
62+
}

0 commit comments

Comments
 (0)