Skip to content

Commit

Permalink
Fix for phpstan error messages (#554)
Browse files Browse the repository at this point in the history
* Fix for phpstan error messages

* Apply php-cs-fixer changes

* Removed unnecessary ignored error message patterns

Co-authored-by: mcop1 <[email protected]>
  • Loading branch information
mcop1 and mcop1 committed Jun 29, 2022
1 parent 284b728 commit 7f2fce5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,6 @@ parameters:
count: 1
path: src/GraphQL/ClassificationstoreType/Group.php

-
message: "#^Call to an undefined method Pimcore\\\\Model\\\\AbstractModel\\:\\:getType\\(\\)\\.$#"
count: 1
path: src/GraphQL/DataObjectInputProcessor/Fieldcollections.php

-
message: "#^Call to an undefined method Pimcore\\\\Model\\\\AbstractModel\\:\\:setIndex\\(\\)\\.$#"
count: 1
path: src/GraphQL/DataObjectInputProcessor/Fieldcollections.php

-
message: "#^Expression on left side of \\?\\? is not nullable\\.$#"
count: 2
Expand Down
6 changes: 4 additions & 2 deletions src/GraphQL/DataObjectInputProcessor/Fieldcollections.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use GraphQL\Type\Definition\ResolveInfo;
use Pimcore\Model\DataObject\Concrete;
use Pimcore\Model\DataObject\Fieldcollection;
use Pimcore\Model\DataObject\Fieldcollection\Data\AbstractData;

class Fieldcollections extends Base
{
Expand All @@ -37,7 +38,7 @@ public function __construct(array $nodeDef, array $processors)
}

/**
* @param Concrete|Fieldcollection\Data\AbstractData $object
* @param Concrete|AbstractData $object
* @param mixed $newValue
* @param array $args
* @param array $context
Expand Down Expand Up @@ -83,7 +84,8 @@ public function process($object, $newValue, $args, $context, ResolveInfo $info)
if (!$fc || $fc->getType() != $fcKey) {
// either index does not exist or type does not match
$modelFactory = $this->getGraphQlService()->getModelFactory();
$className = 'Pimcore\\Model\\DataObject\\Fieldcollection\Data\\' . ucfirst($fcKey);
$className = 'Pimcore\\Model\\DataObject\\Fieldcollection\\Data\\' . ucfirst($fcKey);
/** @var AbstractData $fc */
$fc = $modelFactory->build($className);
}
$fc->setIndex($index);
Expand Down
4 changes: 4 additions & 0 deletions src/GraphQL/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,10 @@ public static function getValueForObject($object, $key, $brickType = null, $bric
if ($fieldDefinition->isEmpty($value)) {
$parent = \Pimcore\Model\DataObject\Service::hasInheritableParentObject($object);
if (!empty($parent)) {
if (!($parent instanceof Concrete)) {
$parent = Concrete::getById($parent->getId());
}

return self::getValueForObject($parent, $key, $brickType, $brickKey, $fieldDefinition, $context, $brickDescriptor);
}
}
Expand Down

0 comments on commit 7f2fce5

Please sign in to comment.