Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -2587,12 +2587,6 @@
'count' => 1,
'path' => __DIR__ . '/src/Event/Listener/ContentFillListener.php',
];
$ignoreErrors[] = [
'message' => '#^Call to an undefined method object\\:\\:getType\\(\\)\\.$#',
'identifier' => 'method.notFound',
'count' => 1,
'path' => __DIR__ . '/src/Event/Listener/FieldDiscriminatorListener.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$objectOrClass of class ReflectionClass constructor expects class\\-string\\<T of object\\>\\|T of object, string given\\.$#',
'identifier' => 'argument.type',
Expand Down Expand Up @@ -3229,36 +3223,6 @@
'count' => 1,
'path' => __DIR__ . '/src/Repository/ContentRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Call to an undefined method object\\:\\:setDefaultLocale\\(\\)\\.$#',
'identifier' => 'method.notFound',
'count' => 1,
'path' => __DIR__ . '/src/Repository/FieldRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Call to an undefined method object\\:\\:setDefinition\\(\\)\\.$#',
'identifier' => 'method.notFound',
'count' => 1,
'path' => __DIR__ . '/src/Repository/FieldRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Call to an undefined method object\\:\\:setLabel\\(\\)\\.$#',
'identifier' => 'method.notFound',
'count' => 1,
'path' => __DIR__ . '/src/Repository/FieldRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Call to an undefined method object\\:\\:setLocale\\(\\)\\.$#',
'identifier' => 'method.notFound',
'count' => 1,
'path' => __DIR__ . '/src/Repository/FieldRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Call to an undefined method object\\:\\:setName\\(\\)\\.$#',
'identifier' => 'method.notFound',
'count' => 1,
'path' => __DIR__ . '/src/Repository/FieldRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getMetadataFactory\\(\\) on Doctrine\\\\ORM\\\\EntityManagerInterface\\|null\\.$#',
'identifier' => 'method.nonObject',
Expand All @@ -3277,12 +3241,6 @@
'count' => 1,
'path' => __DIR__ . '/src/Repository/FieldRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method Bolt\\\\Repository\\\\FieldRepository\\:\\:factory\\(\\) should return Bolt\\\\Entity\\\\Field but returns object\\.$#',
'identifier' => 'return.type',
'count' => 1,
'path' => __DIR__ . '/src/Repository/FieldRepository.php',
];
$ignoreErrors[] = [
'message' => '#^Method Bolt\\\\Repository\\\\FieldRepository\\:\\:findAllByParent\\(\\) return type has no value type specified in iterable type array\\.$#',
'identifier' => 'missingType.iterableValue',
Expand Down Expand Up @@ -3985,12 +3943,6 @@
'count' => 4,
'path' => __DIR__ . '/src/Storage/SelectQuery.php',
];
$ignoreErrors[] = [
'message' => '#^Possibly invalid array key type array\\|string\\.$#',
'identifier' => 'offsetAccess.invalidOffset',
'count' => 3,
'path' => __DIR__ . '/src/Storage/SelectQuery.php',
];
$ignoreErrors[] = [
'message' => '#^Property Bolt\\\\Storage\\\\SelectQuery\\:\\:\\$coreDateFields type has no value type specified in iterable type array\\.$#',
'identifier' => 'missingType.iterableValue',
Expand Down
4 changes: 3 additions & 1 deletion src/Event/Listener/FieldDiscriminatorListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ private function isField(string $class): bool

private function extractFieldType(string $class): string
{
$fieldType = (new $class())->getType();
/** @var FieldInterface $field */
$field = new $class();
$fieldType = $field->getType();
if (in_array($fieldType, $this->tempMap, true) === true) {
throw new LogicException("Found duplicate discriminator map entry '" . $fieldType . "' in " . $class);
}
Expand Down
1 change: 1 addition & 0 deletions src/Repository/FieldRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public static function factory(Collection $definition, string $name = '', string
$classname = self::getFieldClassname($type);

if ($classname && class_exists($classname)) {
/** @var Field $field */
$field = new $classname();
} else {
$field = new Field();
Expand Down
16 changes: 11 additions & 5 deletions src/Storage/SelectQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,10 @@ private function getCoreFieldExpression(Filter $filter): string

private function getReferenceFieldExpression(Filter $filter): string
{
if ($filter->getKey() !== $this->anything) {
$this->referenceJoins[$filter->getKey()] = $filter;
/** @var string $key */
$key = $filter->getKey();
if ($key !== $this->anything) {
$this->referenceJoins[$key] = $filter;

return $filter->getExpression();
}
Expand All @@ -518,7 +520,9 @@ private function getReferenceFieldExpression(Filter $filter): string

private function getTaxonomyFieldExpression(Filter $filter): string
{
$this->taxonomyJoins[$filter->getKey()] = $filter;
/** @var string $key */
$key = $filter->getKey();
$this->taxonomyJoins[$key] = $filter;

$originalExpression = $filter->getExpression();
$originalLeftExpression = '/content\.([^\s])*/';
Expand All @@ -542,14 +546,16 @@ private function getCheckboxFieldExpression(Filter $filter): string
$value = $isSqlite ? true : 'true';
}

$filter->setParameters([key($filter->getParameters()) => $value]);
$filter->setParameters([(string) key($filter->getParameters()) => $value]);

return $this->getRegularFieldExpression($filter);
}

private function getRegularFieldExpression(Filter $filter): string
{
$this->fieldJoins[$filter->getKey()] = $filter;
/** @var string $key */
$key = $filter->getKey();
$this->fieldJoins[$key] = $filter;
$expr = $this->qb->expr()->andX();

// where clause for the value of the field
Expand Down
2 changes: 1 addition & 1 deletion src/Twig/FieldExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function getSelected(SelectField $field, $returnsingle = false, $returnar

// Sort the results in the order of the $ids.
$order = array_flip($ids);
$records = $records->sortBy(fn (Content $record) => $order[$record->getId()])->values()->toArray();
$records = $records->sortBy(fn (Content $record) => $order[(int) $record->getId()])->values()->toArray();

if ($returnsingle || (! $returnarray && $definition->get('multiple') === false)) {
return current($records);
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/TranslationsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private function getFieldChildrenTranslations(array &$translations, FieldParentI
$this->getFieldChildrenTranslations($translations, $child);
}

$translations[$child->getId()] = $child->getTranslations();
$translations[(int) $child->getId()] = $child->getTranslations();
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/Validator/ContentValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ private function relationsToMap(Collection $relations): array
foreach ($relations as $relation) {
$to = $relation->getToContent();
$typeName = $to->getContentType();
if ($typeName === null) {
continue;
}
if (! isset($result[$typeName])) {
$result[$typeName] = [];
}
Expand Down
Loading