Skip to content

Commit e8dcf01

Browse files
committed
minor #27609 Remove direct dependencies on doctrine/common (Majkl578)
This PR was merged into the 4.2-dev branch. Discussion ---------- Remove direct dependencies on doctrine/common | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | none | License | MIT | Doc PR | ? Doctrine has recently separated multiple components from doctrine/common: * [doctrine/event-manager](https://github.com/doctrine/event-manager) [[release notes](https://github.com/doctrine/event-manager/releases/tag/v1.0.0) | [split PR](doctrine/common#842)] * [doctrine/persistence](https://github.com/doctrine/persistence) [[release notes](https://github.com/doctrine/persistence/releases/tag/v1.0.0) | [split PR](doctrine/common#845)] * [doctrine/reflection](https://github.com/doctrine/reflection) [[release notes](https://github.com/doctrine/reflection/releases/tag/v1.0.0) | [split PR](doctrine/common#845)] All of the packages are 100% backward compatible with their counterparts in Common 2.8. This is a major step to slowly start with [phasing out doctrine/common package](doctrine/common#826) before ORM 3.0 / DBAL 3.0 / ODM 3.0. Common 2.9.0 will also be composed from these new packages. Most of the remaining parts in doctrine/common are likely to be deprecated (or already are), please see & discuss in [the PR over in doctrine/common repository](doctrine/common#845). This PR therefore aims to remove the direct doctrine/common dependency from Symfony, replacing it by specific Doctrine components. Commits ------- b0fa398187 Remove direct dependencies on doctrine/common
2 parents bb65c4d + 58e7b2c commit e8dcf01

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

Form/DoctrineOrmTypeGuesser.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313

1414
use Doctrine\Common\Persistence\ManagerRegistry;
1515
use Doctrine\Common\Persistence\Mapping\MappingException;
16+
use Doctrine\Common\Persistence\Proxy;
1617
use Doctrine\DBAL\Types\Type;
1718
use Doctrine\ORM\Mapping\ClassMetadataInfo;
1819
use Doctrine\ORM\Mapping\MappingException as LegacyMappingException;
1920
use Symfony\Component\Form\FormTypeGuesserInterface;
2021
use Symfony\Component\Form\Guess\Guess;
2122
use Symfony\Component\Form\Guess\TypeGuess;
2223
use Symfony\Component\Form\Guess\ValueGuess;
23-
use Doctrine\Common\Util\ClassUtils;
2424

2525
class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
2626
{
@@ -162,7 +162,7 @@ public function guessPattern($class, $property)
162162
protected function getMetadata($class)
163163
{
164164
// normalize class name
165-
$class = ClassUtils::getRealClass(ltrim($class, '\\'));
165+
$class = self::getRealClass(ltrim($class, '\\'));
166166

167167
if (array_key_exists($class, $this->cache)) {
168168
return $this->cache[$class];
@@ -179,4 +179,13 @@ protected function getMetadata($class)
179179
}
180180
}
181181
}
182+
183+
private static function getRealClass(string $class): string
184+
{
185+
if (false === $pos = strrpos($class, '\\'.Proxy::MARKER.'\\')) {
186+
return $class;
187+
}
188+
189+
return substr($class, $pos + Proxy::MARKER_LENGTH + 2);
190+
}
182191
}

composer.json

+7-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
],
1818
"require": {
1919
"php": "^7.1.3",
20-
"doctrine/common": "~2.4",
20+
"doctrine/collections": "~1.0",
21+
"doctrine/event-manager": "~1.0",
22+
"doctrine/persistence": "~1.0",
2123
"symfony/polyfill-ctype": "~1.8",
2224
"symfony/polyfill-mbstring": "~1.0"
2325
},
@@ -33,9 +35,12 @@
3335
"symfony/expression-language": "~3.4|~4.0",
3436
"symfony/validator": "~3.4|~4.0",
3537
"symfony/translation": "~3.4|~4.0",
38+
"doctrine/annotations": "~1.0",
39+
"doctrine/cache": "~1.6",
3640
"doctrine/data-fixtures": "1.0.*",
3741
"doctrine/dbal": "~2.4",
38-
"doctrine/orm": "^2.4.5"
42+
"doctrine/orm": "^2.4.5",
43+
"doctrine/reflection": "~1.0"
3944
},
4045
"conflict": {
4146
"phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0",

0 commit comments

Comments
 (0)