Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Task] Follow up native params and return type hints #13653

Merged
merged 21 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
371123c
Fix: pdfreactor buildPdf declaration not compatible with Abstract
kingjia90 Nov 22, 2022
5962727
Update Environment.php
kingjia90 Nov 22, 2022
0228e99
Fix: clearEnv a nullable property should set it to `null`
kingjia90 Nov 22, 2022
32cee53
[Task]: Apply native parameter and return type hints
mcop1 Nov 23, 2022
8f14261
[Task]: Apply native parameter and return type hints
mcop1 Nov 23, 2022
b777d77
[Task]: Apply native parameter and return type hints
mcop1 Nov 24, 2022
eb4bcf6
Update lib/Navigation/Renderer/Breadcrumbs.php
mcop1 Nov 24, 2022
11ecb76
Update bundles/EcommerceFrameworkBundle/src/Tracking/AbstractProductD…
mcop1 Nov 24, 2022
fa3a909
[Task]: Apply native parameter and return type hints
mcop1 Nov 24, 2022
49512f8
Merge remote-tracking branch 'origin/followup-13474' into followup-13474
mcop1 Nov 24, 2022
37d2120
[Task]: Apply native parameter and return type hints
mcop1 Nov 24, 2022
2a82235
Merge branch '11.x' into followup-13474
mcop1 Nov 25, 2022
643b8ae
[Task]: Apply native parameter and return type hints
mcop1 Nov 25, 2022
14a8ab5
[Task]: Apply native parameter and return type hints
mcop1 Nov 28, 2022
9651827
Task: remove getColor phpstan ignore it got fixed
kingjia90 Nov 28, 2022
a107bd3
[Task]: Apply native parameter and return type hints
mcop1 Nov 28, 2022
5f415a9
Revert "Task: remove getColor phpstan ignore it got fixed"
mcop1 Nov 28, 2022
cbb696c
Revert "Revert "Task: remove getColor phpstan ignore it got fixed""
mcop1 Nov 28, 2022
561bd0c
[Task]: Apply native parameter and return type hints
mcop1 Nov 28, 2022
b21f5e4
[Task]: Apply native parameter and return type hints
mcop1 Nov 28, 2022
4f91af7
[Task]: Apply native parameter and return type hints
mcop1 Nov 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ public function doGetGridColumnConfig(Request $request, Config $config, bool $is
$keyFieldDef = json_decode($keyDef->getDefinition(), true);
if ($keyFieldDef) {
$keyFieldDef = \Pimcore\Model\DataObject\Classificationstore\Service::getFieldDefinitionFromJson($keyFieldDef, $keyDef->getType());
$fieldConfig = $this->getFieldGridConfig($keyFieldDef, $gridType, $sc['position'], true, null, $class, $objectId);
$fieldConfig = $this->getFieldGridConfig($keyFieldDef, $gridType, (string)$sc['position'], true, null, $class, $objectId);
if ($fieldConfig) {
$fieldConfig['key'] = $key;
$fieldConfig['label'] = '#' . $keyFieldDef->getTitle();
Expand Down Expand Up @@ -452,7 +452,7 @@ public function doGetGridColumnConfig(Request $request, Config $config, bool $is
}

if ($fd !== null) {
$fieldConfig = $this->getFieldGridConfig($fd, $gridType, $sc['position'], true, $keyPrefix, $class, $objectId);
$fieldConfig = $this->getFieldGridConfig($fd, $gridType, (string)$sc['position'], true, $keyPrefix, $class, $objectId);
if (!empty($fieldConfig)) {
if (isset($sc['width'])) {
$fieldConfig['width'] = $sc['width'];
Expand Down Expand Up @@ -482,7 +482,7 @@ public function doGetGridColumnConfig(Request $request, Config $config, bool $is
}

if (!empty($fd)) {
$fieldConfig = $this->getFieldGridConfig($fd, $gridType, $sc['position'], true, null, $class, $objectId);
$fieldConfig = $this->getFieldGridConfig($fd, $gridType, (string)$sc['position'], true, null, $class, $objectId);
if (!empty($fieldConfig)) {
if (isset($sc['width'])) {
$fieldConfig['width'] = $sc['width'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function lockElementAction(Request $request): Response
*/
public function unlockElementAction(Request $request): Response
{
Element\Editlock::unlock($request->get('id'), $request->get('type'));
Element\Editlock::unlock((int)$request->get('id'), $request->get('type'));

return $this->adminJson(['success' => true]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected function getParams(Request $request): array
$value = json_decode($value);
if (is_array($value)) {
array_walk_recursive($value, function (&$item, $key) {
if (strpos($key, 'pass') !== false) {
if (strpos((string)$key, 'pass') !== false) {
$item = '*************';
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function start(Request $request, AuthenticationException $authException =
return $response;
}

$event = new LoginRedirectEvent(self::PIMCORE_ADMIN_LOGIN, ['perspective' => strip_tags($request->get('perspective'))]);
$event = new LoginRedirectEvent(self::PIMCORE_ADMIN_LOGIN, ['perspective' => strip_tags($request->get('perspective', '') )]);
$this->dispatcher->dispatch($event, AdminEvents::LOGIN_REDIRECT);

$url = $this->router->generate($event->getRouteName(), $event->getRouteParams());
Expand Down
2 changes: 1 addition & 1 deletion bundles/EcommerceFrameworkBundle/src/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function clearEnvironment()
$this->currentAssortmentSubTenant = null;
$this->currentCheckoutTenant = null;
$this->currentTransientCheckoutTenant = null;
$this->useGuestCart = false;
$this->useGuestCart = null;
}

public function setDefaultCurrency(Currency $currency)
Expand Down
5 changes: 4 additions & 1 deletion lib/Navigation/Renderer/AbstractRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,17 @@ public function setRenderInvisible(bool $renderInvisible = true): static
*
* @return array
*/
public function findActive(Container $container, int $minDepth = null, int $maxDepth = -1): array
public function findActive(Container $container, int $minDepth = null, int $maxDepth = null): array
{
if (!is_int($minDepth)) {
$minDepth = $this->getMinDepth();
}
if ((!is_int($maxDepth) || $maxDepth < 0) && null !== $maxDepth) {
$maxDepth = $this->getMaxDepth();
}
if(is_null($maxDepth)) {
$maxDepth = -1;
}

$found = null;
$foundDepth = -1;
Expand Down
8 changes: 4 additions & 4 deletions lib/Navigation/Renderer/Breadcrumbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ class Breadcrumbs extends AbstractRenderer
/**
* Partial view script to use for rendering menu
*
* @var string|array
* @var string|array|null
*/
protected string|array $_template;
protected string|array|null $_template = null;

// Accessors:

Expand Down Expand Up @@ -110,12 +110,12 @@ public function getLinkLast(): bool
return $this->_linkLast;
}

public function getTemplate(): array|string
public function getTemplate(): array|string|null
{
return $this->_template;
}

public function setTemplate(array|string $template): static
public function setTemplate(array|string|null $template): static
mcop1 marked this conversation as resolved.
Show resolved Hide resolved
{
$this->_template = $template;

Expand Down
8 changes: 6 additions & 2 deletions lib/Routing/RedirectHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,16 @@ private function getRegexRedirects(): array
}

$cacheKey = 'system_route_redirect';
if (($this->redirects = Cache::load($cacheKey)) === false) {
$valueFromCache = Cache::load($cacheKey);
$this->redirects = $valueFromCache === false ? null : $valueFromCache;
if (!isset($this->redirects)) {
// acquire lock to avoid concurrent redirect cache warm-up
$this->lock->acquire(true);

//check again if redirects are cached to avoid re-warming cache
if (($this->redirects = Cache::load($cacheKey)) === false) {
$valueFromCache = Cache::load($cacheKey);
$this->redirects = $valueFromCache === false ? null : $valueFromCache;
if (!isset($this->redirects)) {
try {
$list = new Redirect\Listing();
$list->setCondition('active = 1 AND regex = 1');
Expand Down
4 changes: 2 additions & 2 deletions lib/Web2Print/Processor/PdfReactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected function getClient(): \com\realobjects\pdfreactor\webservice\client\PD
/**
* @internal
*/
public function getPdfFromString(string $html, array $params = [], bool $returnFilePath = false): bool|string
public function getPdfFromString(string $html, array $params = [], bool $returnFilePath = false): string
{
$pdfreactor = $this->getClient();

Expand Down Expand Up @@ -117,7 +117,7 @@ public function getPdfFromString(string $html, array $params = [], bool $returnF
/**
* @internal
*/
protected function buildPdf(Document\PrintAbstract $document, object $config): bool|string
protected function buildPdf(Document\PrintAbstract $document, object $config): string
{
$this->includeApi();

Expand Down
8 changes: 6 additions & 2 deletions models/DataObject/ClassDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -1142,8 +1142,12 @@ public function setPreviewGeneratorReference(?string $previewGeneratorReference)

public function getPreviewGenerator(): ?ClassDefinition\PreviewGeneratorInterface
{
/** @var ClassDefinition\PreviewGeneratorInterface $interface */
$interface = DataObject\ClassDefinition\Helper\PreviewGeneratorResolver::resolveGenerator($this->getPreviewGeneratorReference());
$interface = null;

if($this->getPreviewGeneratorReference()) {
/** @var ClassDefinition\PreviewGeneratorInterface $interface */
$interface = DataObject\ClassDefinition\Helper\PreviewGeneratorResolver::resolveGenerator($this->getPreviewGeneratorReference());
}

return $interface;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class AdvancedManyToManyObjectRelation extends ManyToManyObjectRelation implemen
/**
* @internal
*
* @var string|null
* @var array|string|null
*/
public ?string $visibleFields = null;
public array|string|null $visibleFields = null;

/**
* @internal
Expand Down Expand Up @@ -645,7 +645,7 @@ public function setVisibleFields(array|string|null $visibleFields): static
return $this;
}

public function getVisibleFields(): ?string
public function getVisibleFields(): array|string|null
{
return $this->visibleFields;
}
Expand Down
10 changes: 5 additions & 5 deletions models/DataObject/ClassDefinition/Data/Localizedfields.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class Localizedfields extends Data implements CustomResourcePersistingInterface,
public ?array $permissionEdit = null;

/**
* @param mixed $data
* @param mixed $localizedField
* @param null|DataObject\Concrete $object
* @param array $params
*
Expand All @@ -162,16 +162,16 @@ class Localizedfields extends Data implements CustomResourcePersistingInterface,
* @see Data::getDataForEditmode
*
*/
public function getDataForEditmode(mixed $data, DataObject\Concrete $object = null, array $params = []): array
public function getDataForEditmode(mixed $localizedField, DataObject\Concrete $object = null, array $params = []): array
{
$fieldData = [];
$metaData = [];

if (!$data instanceof DataObject\Localizedfield) {
if (!$localizedField instanceof DataObject\Localizedfield) {
return [];
}

$result = $this->doGetDataForEditMode($data, $object, $fieldData, $metaData, 1, $params);
$result = $this->doGetDataForEditMode($localizedField, $object, $fieldData, $metaData, 1, $params);

// replace the real data with the data for the editmode
foreach ($result['data'] as $language => &$data) {
Expand All @@ -185,7 +185,7 @@ public function getDataForEditmode(mixed $data, DataObject\Concrete $object = nu
$childData->setContextualData($ownerType, $ownerName, $index, $language, null, null, $fieldDefinition);
$value = $fieldDefinition->getDataForEditmode($childData, $object, $params);
} else {
$value = $fieldDefinition->getDataForEditmode($value, $object, array_merge($params, $data->getDao()->getFieldDefinitionParams($fieldDefinition->getName(), $language)));
$value = $fieldDefinition->getDataForEditmode($value, $object, array_merge($params, $localizedField->getDao()->getFieldDefinitionParams($fieldDefinition->getName(), $language)));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ class ManyToManyObjectRelation extends AbstractRelations implements QueryResourc
/**
* @internal
*
* @var string|null
* @var array|string|null
*/
public ?string $visibleFields = null;
public array|string|null $visibleFields = null;

/**
* @internal
Expand Down Expand Up @@ -782,7 +782,7 @@ public function setVisibleFields(array|string|null $visibleFields): static
return $this;
}

public function getVisibleFields(): ?string
public function getVisibleFields(): array|null|string
{
return $this->visibleFields;
}
Expand Down
4 changes: 2 additions & 2 deletions models/DataObject/Concrete.php
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,11 @@ public function getClosestParentOfClass(string $classId): ?self
*
* @param string $fieldName
* @param bool $forOwner
* @param string $remoteClassId
* @param string|null $remoteClassId
*
* @return array
*/
public function getRelationData(string $fieldName, bool $forOwner, string $remoteClassId): array
public function getRelationData(string $fieldName, bool $forOwner, ?string $remoteClassId = null): array
{
$relationData = $this->getDao()->getRelationData($fieldName, $forOwner, $remoteClassId);

Expand Down
2 changes: 1 addition & 1 deletion models/DataObject/Concrete/Dao.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function getRelationIds(string $fieldName): array
return $relations;
}

public function getRelationData(string $field, bool $forOwner, string $remoteClassId): array
public function getRelationData(string $field, bool $forOwner, ?string $remoteClassId = null): array
{
$id = $this->model->getId();
if ($remoteClassId) {
Expand Down
6 changes: 4 additions & 2 deletions models/DataObject/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ public static function getLanguagePermissions(Fieldcollection\Data\AbstractData|
return $languageAllowed;
}

public static function getLayoutPermissions(string $classId, array $permissionSet): ?array
public static function getLayoutPermissions(string $classId, ?array $permissionSet = null): ?array
{
$layoutPermissions = null;

Expand Down Expand Up @@ -1645,7 +1645,9 @@ public static function recursiveResetDirtyMap(AbstractObject $object)
}

if ($object instanceof Concrete) {
self::doResetDirtyMap($object, $object->getClass());
if(($class = $object->getClass()) !== null) {
self::doResetDirtyMap($object, $class);
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion models/Document/Editable/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ public function frontend()
*/
public function setDataFromResource(mixed $data): static
{
$this->text = $data;
if(is_string($data)) {
mcop1 marked this conversation as resolved.
Show resolved Hide resolved
$this->text = $data;
}

return $this;
}
Expand Down
4 changes: 2 additions & 2 deletions models/Element/AdminStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class AdminStyle
{
protected string|bool|null $elementCssClass = '';

protected string|bool|null $elementIcon;
protected string|bool|null $elementIcon = null;

protected string|bool|null $elementIconClass;
protected string|bool|null $elementIconClass = null;

protected ?array $elementQtipConfig = null;

Expand Down
8 changes: 4 additions & 4 deletions models/Element/Editlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*/
final class Editlock extends Model\AbstractModel
{
protected int $id;
protected ?int $id = null;

protected int $cid;

Expand Down Expand Up @@ -114,7 +114,7 @@ public function getCid(): int
return $this->cid;
}

public function getId(): int
public function getId(): ?int
{
return $this->id;
}
Expand All @@ -131,9 +131,9 @@ public function setCid(int $cid): static
return $this;
}

public function setId(int $id): static
public function setId(?int $id): static
{
$this->id = (int) $id;
$this->id = $id;

return $this;
}
Expand Down
6 changes: 3 additions & 3 deletions models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ final class User extends User\UserRole

protected bool $allowDirtyClose = false;

protected ?string $contentLanguages = null;
protected ?string $contentLanguages = '';

protected ?string $activePerspective = null;

Expand All @@ -66,9 +66,9 @@ final class User extends User\UserRole

protected int $lastLogin;

protected string $keyBindings;
protected ?string $keyBindings = null;

protected array $twoFactorAuthentication;
protected array $twoFactorAuthentication = [];

public function getPassword(): ?string
{
Expand Down