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 19 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
@@ -1,5 +1,4 @@
<?php
declare(strict_types=1);

/**
* Pimcore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public function doGetGridColumnConfig(Request $request, bool $isDelete = false):

if (empty($gridConfig)) {
$availableFields = $this->getDefaultGridFields(
$request->get('no_system_columns'),
$request->get('no_system_columns', false),
[], //maybe required for types other than metadata
$context,
$types);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
declare(strict_types=1);

/**
* Pimcore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,10 @@ public function doGetGridColumnConfig(Request $request, Config $config, bool $is

if (empty($gridConfig)) {
$availableFields = $this->getDefaultGridFields(
$request->get('no_system_columns'),
$request->get('no_system_columns', false),
$class,
$gridType,
$request->get('no_brick_columns'),
$request->get('no_brick_columns', false),
$fields,
$context,
$objectId,
Expand Down 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
@@ -1,5 +1,4 @@
<?php
declare(strict_types=1);

/**
* Pimcore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
declare(strict_types=1);

/**
* Pimcore
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
2 changes: 0 additions & 2 deletions bundles/AdminBundle/src/Helper/GridHelperService.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

declare(strict_types=1);

/**
* Pimcore
*
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
declare(strict_types=1);

/**
* Pimcore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@

class IndexFieldSelection
{
public string $tenant;
public ?string $tenant = null;

public string $field;

/**
* @var string|string[]
* @var string|string[]|null
*/
public string|array $preSelect;
public string|array|null $preSelect;

/**
* @param string $tenant
* @param string|null $tenant
* @param string $field
* @param string|string[] $preSelect
*/
public function __construct(string $tenant, string $field, array|string $preSelect)
public function __construct(?string $tenant, string $field, array|string|null $preSelect)
{
$this->field = $field;
$this->preSelect = $preSelect;
Expand All @@ -58,9 +58,9 @@ public function setPreSelect(array|string $preSelect): void
}

/**
* @return string|string[]
* @return string|string[]|null
*/
public function getPreSelect(): array|string
public function getPreSelect(): array|string|null
{
return $this->preSelect;
}
Expand All @@ -70,7 +70,7 @@ public function setTenant(string $tenant): void
$this->tenant = $tenant;
}

public function getTenant(): string
public function getTenant(): ?string
{
return $this->tenant;
}
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
1 change: 0 additions & 1 deletion bundles/EcommerceFrameworkBundle/src/Model/Currency.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
declare(strict_types=1);

/**
* Pimcore
Expand Down
6 changes: 3 additions & 3 deletions bundles/EcommerceFrameworkBundle/src/PriceSystem/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Price implements PriceInterface

private Decimal $netAmount;

private string $taxEntryCombinationMode = TaxEntry::CALCULATION_MODE_COMBINE;
private ?string $taxEntryCombinationMode = TaxEntry::CALCULATION_MODE_COMBINE;

private bool $minPrice;

Expand Down Expand Up @@ -122,7 +122,7 @@ public function getTaxEntries(): array
/**
* {@inheritdoc}
*/
public function getTaxEntryCombinationMode(): string
public function getTaxEntryCombinationMode(): ?string
{
return $this->taxEntryCombinationMode;
}
Expand Down Expand Up @@ -162,7 +162,7 @@ public function setTaxEntries(array $taxEntries): void
/**
* {@inheritdoc}
*/
public function setTaxEntryCombinationMode(string $taxEntryCombinationMode): void
public function setTaxEntryCombinationMode(?string $taxEntryCombinationMode = null): void
{
$this->taxEntryCombinationMode = $taxEntryCombinationMode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ public function getTaxEntries(): array;
/**
* Returns tax entry combination mode needed for tax calculation
*
* @return string
* @return string|null
*/
public function getTaxEntryCombinationMode(): string;
public function getTaxEntryCombinationMode(): ?string;

/**
* Sets gross amount of price. If $recalc is set to true, corresponding net price
Expand Down Expand Up @@ -113,9 +113,9 @@ public function setTaxEntries(array $taxEntries): void;
/**
* Sets $taxEntryCombinationMode for price.
*
* @param string $taxEntryCombinationMode
* @param string|null $taxEntryCombinationMode
*
* @return void
*/
public function setTaxEntryCombinationMode(string $taxEntryCombinationMode): void;
public function setTaxEntryCombinationMode(?string $taxEntryCombinationMode = null): void;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
declare(strict_types=1);

/**
* Pimcore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ abstract class AbstractProductData extends AbstractData

protected string $name;

protected string $brand;
protected ?string $brand = null;

protected array $categories;

protected string $variant;
protected ?string $variant = null;

protected int $position;
protected int $position = 0;

protected float $price;

Expand Down Expand Up @@ -56,12 +56,15 @@ public function setName(string $name): static
return $this;
}

public function getBrand(): string
public function getBrand(): ?string
{
return $this->brand;
}

public function setBrand(string $brand): static
/**
* @return $this
*/
public function setBrand(?string $brand = null): static
mcop1 marked this conversation as resolved.
Show resolved Hide resolved
{
$this->brand = $brand;

Expand Down Expand Up @@ -89,7 +92,7 @@ public function setCategories(array $categories): static
return $this;
}

public function getVariant(): string
public function getVariant(): ?string
{
return $this->variant;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ProductAction extends AbstractProductData
{
protected int $quantity = 1;

protected string $coupon;
protected string $coupon = '';

public function getQuantity(): float|int
{
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"require-dev": {
"codeception/codeception": "^5.0.3",
"codeception/phpunit-wrapper": "^9",
"phpstan/phpstan": "^1.9",
"phpstan/phpstan": "1.9.x-dev",
"phpstan/phpstan-symfony": "^1.2.14",
"phpunit/phpunit": "^9.3",
"spiritix/php-chrome-html2pdf": "^1.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public function buildProperties(ClassDefinition $classDefinition): string
{
$cd = '';

$cd .= 'protected $o_classId = "' . $classDefinition->getId(). "\";\n";
$cd .= 'protected $o_className = "'.$classDefinition->getName().'"'.";\n";
$cd .= 'protected ?string $o_classId = "' . $classDefinition->getId(). "\";\n";
$cd .= 'protected ?string $o_className = "'.$classDefinition->getName().'"'.";\n";

if (is_array($classDefinition->getFieldDefinitions()) && count($classDefinition->getFieldDefinitions())) {
foreach ($classDefinition->getFieldDefinitions() as $key => $def) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Event/Traits/ResponseAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ public function setResponse(Response $response): void
*/
public function hasResponse(): bool
{
return null !== $this->response;
return isset($this->response);
}
}
1 change: 0 additions & 1 deletion lib/Image/Adapter/Imagick.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ private function hasAlphaChannel(): bool
for ($i = 0; $i < $width; $i++) {
for ($j = 0; $j < $height; $j++) {
$pixel = $this->resource->getImagePixelColor($i, $j);
// @phpstan-ignore-next-line - phpstan expects bool, but actually doc says int
mcop1 marked this conversation as resolved.
Show resolved Hide resolved
$color = $pixel->getColor(1); // get the real alpha not just 1/0
if ($color['a'] < 1) { // if there's an alpha pixel, return true
return true;
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
11 changes: 7 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,15 @@ 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
/**
* @return $this
*/
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