Skip to content

Commit

Permalink
Bump phpstan to level 5 (#547)
Browse files Browse the repository at this point in the history
* Github workflow changes (#527)

* GitHub workflows

Aligned to pimcore/pimcore

* Do not run static-analysis on docs

* ignore /Resources/public/ content for codeception checks

* Ignore src/Resources/public/ for static analysis

* Corrected path for Resources

* Corrected path for Resources

* Bump phpstan to level 5

* Revert "Github workflow changes (#527)"

This reverts commit 147d203.

* Apply php-cs-fixer changes

Co-authored-by: Niklas <[email protected]>
Co-authored-by: mcop1 <[email protected]>
  • Loading branch information
3 people authored Jun 28, 2022
1 parent c5966fc commit 284b728
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 37 deletions.
7 changes: 1 addition & 6 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ parameters:
ignoreErrors:
-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#"
count: 1
path: src/DependencyInjection/Configuration.php

-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeParentInterface\\:\\:end\\(\\)\\.$#"
count: 1
count: 2
path: src/DependencyInjection/Configuration.php

-
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 4
level: 5
paths:
- src
bootstrapFiles:
Expand Down
6 changes: 3 additions & 3 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class Configuration extends AbstractModel
protected $modificationDate;

/**
* @param string $type
* @param string $path
* @param string|null $type
* @param string|null $path
* @param string|null $name
* @param array|null $configuration
*/
Expand Down Expand Up @@ -231,7 +231,7 @@ public function skipPermisssionCheck()
}

/**
* @param string $path
* @param string|null $path
*/
public function setPath($path): void
{
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/WebserviceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public function webonyxAction(
$debug = DebugFlag::INCLUDE_DEBUG_MESSAGE | DebugFlag::INCLUDE_TRACE;
$output = $result->toArray($debug);
} else {
$output = $result->toArray(false);
$output = $result->toArray();
}
} catch (\Exception $e) {
$output = [
Expand Down
5 changes: 3 additions & 2 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
namespace Pimcore\Bundle\DataHubBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

Expand Down Expand Up @@ -48,9 +49,9 @@ public function getConfigTreeBuilder()
}

/**
* @param ArrayNodeDefinition $rootNode
* @param ArrayNodeDefinition|NodeDefinition $rootNode
*/
private function addConfigurationsNode(ArrayNodeDefinition $rootNode)
private function addConfigurationsNode(ArrayNodeDefinition | NodeDefinition $rootNode)
{
$rootNode
->children()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public function process($object, $newValue, $args, $context, ResolveInfo $info)
$data[$metaDataValue['name']] = $metaDataValue['value'];
}
}
$item = new ObjectMetadata($attribute, $columns ?? [], $element);
$concrete = Concrete::getById($element->getId());
$item = new ObjectMetadata($attribute, $columns ?? [], $concrete);
if (isset($data) === true) {
$item->setData($data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public function getFieldType(Data $fieldDefinition, $class = null, $container =

public function getResolver($attribute, $fieldDefinition, $class)
{

/** @var Data\Hotspotimage $fieldDefinition */
$resolver = new Helper\Hotspotimage($this->getGraphQlService(), $attribute, $fieldDefinition, $class);

return [$resolver, 'resolve'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public function getFieldType(Data $fieldDefinition, $class = null, $container =

public function getResolver($attribute, $fieldDefinition, $class)
{
/** @var Data\ImageGallery $fieldDefinition */
$resolver = new Helper\ImageGallery($this->getGraphQlService(), $attribute, $fieldDefinition, $class);

return [$resolver, 'resolve'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Pimcore\Bundle\DataHubBundle\GraphQL\DataObjectType\ObjectMetadataType;
use Pimcore\Model\DataObject\ClassDefinition;
use Pimcore\Model\DataObject\ClassDefinition\Data;
use Pimcore\Model\DataObject\ClassDefinition\Data\AdvancedManyToManyObjectRelation;

class ObjectsMetadata extends Base
{
Expand All @@ -32,6 +33,7 @@ class ObjectsMetadata extends Base
*/
public function getGraphQlFieldConfig($attribute, Data $fieldDefinition, $class = null, $container = null)
{
/** @var AdvancedManyToManyObjectRelation $fieldDefinition */
return $this->enrichConfig($fieldDefinition, $class, $attribute,
[
'name' => $fieldDefinition->getName(),
Expand All @@ -43,7 +45,7 @@ public function getGraphQlFieldConfig($attribute, Data $fieldDefinition, $class
}

/**
* @param Data\AdvancedManyToManyObjectRelation $fieldDefinition
* @param AdvancedManyToManyObjectRelation $fieldDefinition
* @param ClassDefinition|null $class
* @param object|null $container
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ReverseManyToManyObjectRelation extends Base
*/
public function getGraphQlFieldConfig($attribute, Data $fieldDefinition, $class = null, $container = null)
{
/** @var Data\ReverseManyToManyObjectRelation $fieldDefinition */
return $this->enrichConfig(
$fieldDefinition,
$class,
Expand Down
31 changes: 16 additions & 15 deletions src/GraphQL/DataObjectType/PimcoreObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,22 +203,23 @@ public function addFieldCollectionDefs($column, ClassDefinition $class, &$fields
} else {
$fcDef = Definition::getByKey($allowedFcName);
$fcFields = [];
if ($fcDef != null) {
$fcFieldDefs = $fcDef->getFieldDefinitions();

$fcFieldDefs = $fcDef->getFieldDefinitions();

foreach ($fcFieldDefs as $key => $fieldDef) {
$attrName = $fieldDef->getName();
$columnDesc = [
'isOperator' => false,
'attributes' => [
'attribute' => $attrName,
'label' => $fieldDef->getName(),
'dataType' => $fieldDef->getFieldtype()
]
];
$fcResult = $fieldHelper->getQueryFieldConfigFromConfig($columnDesc, $fcDef);
if ($fcResult) {
$fcFields[$fcResult['key']] = $fcResult['config'];
foreach ($fcFieldDefs as $key => $fieldDef) {
$attrName = $fieldDef->getName();
$columnDesc = [
'isOperator' => false,
'attributes' => [
'attribute' => $attrName,
'label' => $fieldDef->getName(),
'dataType' => $fieldDef->getFieldtype()
]
];
$fcResult = $fieldHelper->getQueryFieldConfigFromConfig($columnDesc, $fcDef);
if ($fcResult) {
$fcFields[$fcResult['key']] = $fcResult['config'];
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/GraphQL/FieldHelper/DataObjectFieldHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class DataObjectFieldHelper extends AbstractFieldHelper
{
/**
* @param array $nodeDef
* @param ClassDefinition $class
* @param ClassDefinition|\Pimcore\Model\DataObject\Fieldcollection\Definition $class
* @param object|null $container
*
* @return array|bool|null
Expand Down Expand Up @@ -123,7 +123,7 @@ public function getQueryFieldConfigFromConfig($nodeDef, $class, $container = nul
* @param string $mode
* @param array $nodeDef
* @param ClassDefinition $class
* @param object $container
* @param object|null $container
* @param array $params
*
* @return mixed
Expand Down Expand Up @@ -336,7 +336,7 @@ public function getGraphQlTypeFromNodeConf($nodeConf, $class, $container = null)

if ($nodeConf['isOperator']) {
$operatorTypeName = $attributes['class'];
$type = $this->getGraphQlService()->buildDataObjectOperatorQueryType($operatorTypeName, $nodeConf, $class, $container);
$type = $this->getGraphQlService()->buildDataObjectOperatorQueryType('mutation', $operatorTypeName, $nodeConf, $class, $container);
} else {
$key = $attributes['attribute'];
$fieldDefinition = $this->getFieldDefinitionFromKey($class, $key);
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static function addJoins(&$list, $filter, $columns, &$mappingTable = [])

/**
* @param string $defaultTable
* @param string|array $q
* @param string|array|\stdClass $q
* @param string|null $op
* @param string|null $subject
* @param array $fieldMappingTable
Expand Down
2 changes: 2 additions & 0 deletions src/GraphQL/Mutation/MutationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public function buildUpdateDocumentMutation(&$config, $context, $mutationType, $
'type' => $updateResultType,
'args' => $args, 'resolve' => static function ($value, $args, $context, ResolveInfo $info) use ($documentType, $inputProcessorFn, $processors, $mutationType, $me) {
if ($mutationType == 'update') {
/** @var Document $element */
$element = $me->getElementByTypeAndIdOrPath($args, 'document');

if (!WorkspaceHelper::checkPermission($element, 'update')) {
Expand Down Expand Up @@ -1042,6 +1043,7 @@ public function buildUpdateAssetMutation(&$config, $context)
'userId' => ['type' => Type::int()],
'input' => $this->getGraphQlService()->getAssetTypeDefinition('asset_input')
], 'resolve' => static function ($value, $args, $context, ResolveInfo $info) use ($me) {
/** @var Asset $element */
$element = $me->getElementByTypeAndIdOrPath($args, 'asset');
$tags = [];

Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL/Query/Value/DefaultValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function getLabeledValue($element, ResolveInfo $resolveInfo = null)
$valueParams = new ElementDescriptor($element);

$resolveFn = $this->getGraphQlService()->buildDataObjectDataQueryResolver($this->attribute, $fieldDefinition, $class);
$args = null;
$args = [];

$value = $resolveFn($valueParams, $args, $this->context, $resolveInfo);
if ($value) {
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL/Resolver/QueryType.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public function resolveObjectGetter($value = null, $args = [], $context = [], Re

$objectList->setObjectTypes([AbstractObject::OBJECT_TYPE_OBJECT, AbstractObject::OBJECT_TYPE_FOLDER, AbstractObject::OBJECT_TYPE_VARIANT]);
$objectList->setLimit(1);
$objectList->setUnpublished(1);
$objectList->setUnpublished(true);
$objectList = $objectList->load();
if (!$objectList) {
$errorMessage = $this->createArgumentErrorMessage($isFullpathSet, $isIdSet, $args);
Expand Down
3 changes: 2 additions & 1 deletion src/GraphQL/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
use Pimcore\Bundle\DataHubBundle\GraphQL\Query\Value\DefaultValue;
use Pimcore\Bundle\DataHubBundle\PimcoreDataHubBundle;
use Pimcore\Cache\Runtime;
use Pimcore\DataObject\GridColumnConfig\ConfigElementInterface;
use Pimcore\Localization\LocaleServiceInterface;
use Pimcore\Model\Asset;
use Pimcore\Model\DataObject\AbstractObject;
Expand Down Expand Up @@ -485,7 +486,7 @@ public function buildQueryOperator($typeName, $attributes = null, ClassDefinitio
}

/**
* @param array $nodeConfig
* @param ConfigElementInterface $nodeConfig
*
* @return mixed|DefaultValue
*
Expand Down

0 comments on commit 284b728

Please sign in to comment.