Skip to content

Commit c5ec462

Browse files
VincentLangletondrejmirtes
authored andcommitted
Fix phpstan build
1 parent a6edbb0 commit c5ec462

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/Type/Doctrine/Query/QueryResultTypeWalker.php

+11-13
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
use function get_class;
4343
use function gettype;
4444
use function intval;
45-
use function is_array;
4645
use function is_numeric;
4746
use function is_object;
4847
use function is_string;
@@ -249,24 +248,21 @@ public function walkPathExpression($pathExpr)
249248
case AST\PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION:
250249
if (isset($class->associationMappings[$fieldName]['inherited'])) {
251250
$newClassName = $class->associationMappings[$fieldName]['inherited'];
252-
assert(is_string($newClassName));
253-
/** @var class-string $newClassName */
254251
$class = $this->em->getClassMetadata($newClassName);
255252
}
256253

257254
$assoc = $class->associationMappings[$fieldName];
258255

259-
assert(is_array($assoc['joinColumns']));
260-
261-
if (!((bool) $assoc['isOwningSide']) || count($assoc['joinColumns']) !== 1) {
256+
if (
257+
!$assoc['isOwningSide']
258+
|| !isset($assoc['joinColumns'])
259+
|| count($assoc['joinColumns']) !== 1
260+
) {
262261
throw new ShouldNotHappenException();
263262
}
264263

265264
$joinColumn = $assoc['joinColumns'][0];
266-
assert(is_array($joinColumn));
267265
$assocClassName = $assoc['targetEntity'];
268-
assert(is_string($assocClassName));
269-
/** @var class-string $assocClassName */
270266

271267
$targetClass = $this->em->getClassMetadata($assocClassName);
272268
$identifierFieldNames = $targetClass->getIdentifierFieldNames();
@@ -278,7 +274,7 @@ public function walkPathExpression($pathExpr)
278274
$targetFieldName = $identifierFieldNames[0];
279275
[$typeName, $enumType] = $this->getTypeOfField($targetClass, $targetFieldName);
280276

281-
$nullable = (bool) ($joinColumn['nullable'] ?? true)
277+
$nullable = ($joinColumn['nullable'] ?? true)
282278
|| $this->hasAggregateWithoutGroupBy();
283279

284280
$fieldType = $this->resolveDatabaseInternalType($typeName, $enumType, $nullable);
@@ -516,7 +512,6 @@ public function walkFunction($function)
516512
$queryComp = $this->queryComponents[$dqlAlias];
517513
$class = $queryComp['metadata'];
518514
$assoc = $class->associationMappings[$assocField];
519-
/** @var class-string $assocClassName */
520515
$assocClassName = $assoc['targetEntity'];
521516
$targetClass = $this->em->getClassMetadata($assocClassName);
522517

@@ -538,6 +533,10 @@ public function walkFunction($function)
538533

539534
[$typeName, $enumType] = $this->getTypeOfField($targetClass, $targetFieldName);
540535

536+
if (!isset($assoc['joinColumns'])) {
537+
return $this->marshalType(new MixedType());
538+
}
539+
541540
$joinColumn = null;
542541

543542
foreach ($assoc['joinColumns'] as $item) {
@@ -551,7 +550,7 @@ public function walkFunction($function)
551550
return $this->marshalType(new MixedType());
552551
}
553552

554-
$nullable = (bool) ($joinColumn['nullable'] ?? true)
553+
$nullable = ($joinColumn['nullable'] ?? true)
555554
|| $this->hasAggregateWithoutGroupBy();
556555

557556
$fieldType = $this->resolveDatabaseInternalType($typeName, $enumType, $nullable);
@@ -1296,7 +1295,6 @@ private function getTypeOfField(ClassMetadataInfo $class, string $fieldName): ar
12961295
{
12971296
assert(isset($class->fieldMappings[$fieldName]));
12981297

1299-
/** @var array{type: string, enumType?: ?string} $metadata */
13001298
$metadata = $class->fieldMappings[$fieldName];
13011299

13021300
$type = $metadata['type'];

0 commit comments

Comments
 (0)