Skip to content

Commit e7774ff

Browse files
committed
Remove dead code that was useful for doctrine 2.2
1 parent ef1d6b0 commit e7774ff

File tree

3 files changed

+3
-58
lines changed

3 files changed

+3
-58
lines changed

phpstan.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ parameters:
88
ignoreErrors:
99
# Real problems, hard to fix
1010
- '#Parameter \#2 \$dqlPart of method Doctrine\\ORM\\QueryBuilder::add\(\) expects array\|object, string given\.#'
11-
- '#Call to function method_exists\(\) with .Doctrine.+ and .get(Join|Alias|Parts). will always evaluate to false\.#'
1211

1312
# False positives
1413
- '#Access to an undefined property Prophecy\\Prophecy\\ObjectProphecy::\$[a-zA-Z0-9_]+#'

src/Bridge/Doctrine/Orm/Util/QueryJoinParser.php

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -100,35 +100,15 @@ public static function getClassMetadataFromJoinAlias(string $alias, QueryBuilder
100100
*/
101101
public static function getJoinRelationship(Join $join): string
102102
{
103-
static $relationshipProperty = null;
104-
static $initialized = false;
105-
106-
if (!$initialized && !method_exists(Join::class, 'getJoin')) {
107-
$relationshipProperty = new \ReflectionProperty(Join::class, '_join');
108-
$relationshipProperty->setAccessible(true);
109-
110-
$initialized = true;
111-
}
112-
113-
return (null === $relationshipProperty) ? $join->getJoin() : $relationshipProperty->getValue($join);
103+
return $join->getJoin();
114104
}
115105

116106
/**
117107
* Gets the alias from a Join expression.
118108
*/
119109
public static function getJoinAlias(Join $join): string
120110
{
121-
static $aliasProperty = null;
122-
static $initialized = false;
123-
124-
if (!$initialized && !method_exists(Join::class, 'getAlias')) {
125-
$aliasProperty = new \ReflectionProperty(Join::class, '_alias');
126-
$aliasProperty->setAccessible(true);
127-
128-
$initialized = true;
129-
}
130-
131-
return (null === $aliasProperty) ? $join->getAlias() : $aliasProperty->getValue($join);
111+
return $join->getAlias();
132112
}
133113

134114
/**
@@ -139,16 +119,6 @@ public static function getJoinAlias(Join $join): string
139119
*/
140120
public static function getOrderByParts(OrderBy $orderBy): array
141121
{
142-
static $partsProperty = null;
143-
static $initialized = false;
144-
145-
if (!$initialized && !method_exists(OrderBy::class, 'getParts')) {
146-
$partsProperty = new \ReflectionProperty(OrderBy::class, '_parts');
147-
$partsProperty->setAccessible(true);
148-
149-
$initialized = true;
150-
}
151-
152-
return (null === $partsProperty) ? $orderBy->getParts() : $partsProperty->getValue($orderBy);
122+
return $orderBy->getParts();
153123
}
154124
}

tests/Bridge/Doctrine/Orm/Util/QueryJoinParserTest.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,6 @@ public function testGetJoinRelationshipWithClassJoin()
5555
$this->assertEquals(RelatedDummy::class, QueryJoinParser::getJoinRelationship($join));
5656
}
5757

58-
public function testGetJoinRelationshipWithReflection()
59-
{
60-
$methodExist = $this->getFunctionMock('ApiPlatform\Core\Bridge\Doctrine\Orm\Util', 'method_exists');
61-
$methodExist->expects($this->any())->with(Join::class, 'getJoin')->willReturn('false');
62-
$join = new Join('INNER_JOIN', 'a_1.relatedDummy', 'a_1', null, 'a_1.name = r.name');
63-
$this->assertEquals('a_1.relatedDummy', QueryJoinParser::getJoinRelationship($join));
64-
}
65-
6658
public function testGetJoinAliasWithJoin()
6759
{
6860
$join = new Join('INNER_JOIN', 'relatedDummy', 'a_1', null, 'a_1.name = r.name');
@@ -75,25 +67,9 @@ public function testGetJoinAliasWithClassJoin()
7567
$this->assertEquals('a_1', QueryJoinParser::getJoinAlias($join));
7668
}
7769

78-
public function testGetJoinAliasWithReflection()
79-
{
80-
$methodExist = $this->getFunctionMock('ApiPlatform\Core\Bridge\Doctrine\Orm\Util', 'method_exists');
81-
$methodExist->expects($this->any())->with(Join::class, 'getAlias')->willReturn('false');
82-
$join = new Join('INNER_JOIN', 'relatedDummy', 'a_1', null, 'a_1.name = r.name');
83-
$this->assertEquals('a_1', QueryJoinParser::getJoinAlias($join));
84-
}
85-
8670
public function testGetOrderByPartsWithOrderBy()
8771
{
8872
$orderBy = new OrderBy('name', 'asc');
8973
$this->assertEquals(['name asc'], QueryJoinParser::getOrderByParts($orderBy));
9074
}
91-
92-
public function testGetOrderByPartsWithReflection()
93-
{
94-
$methodExist = $this->getFunctionMock('ApiPlatform\Core\Bridge\Doctrine\Orm\Util', 'method_exists');
95-
$methodExist->expects($this->any())->with(OrderBy::class, 'getParts')->willReturn('false');
96-
$orderBy = new OrderBy('name', 'desc');
97-
$this->assertEquals(['name desc'], QueryJoinParser::getOrderByParts($orderBy));
98-
}
9975
}

0 commit comments

Comments
 (0)