Skip to content

Commit

Permalink
Merge pull request #804 from TomHAnderson/feat/merge-drop-php74
Browse files Browse the repository at this point in the history
Feat/merge drop php74
  • Loading branch information
TomHAnderson committed May 10, 2023
2 parents 7c1ed51 + d3ea2f9 commit 38e4c4a
Show file tree
Hide file tree
Showing 46 changed files with 346 additions and 345 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ jobs:
name: "PHPUnit"
uses: "doctrine/.github/.github/workflows/continuous-integration.yml@2.1.0"
with:
php-versions: '["7.4", "8.0", "8.1", "8.2"]'
php-versions: '["8.0", "8.1", "8.2"]'
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"homepage": "http://www.doctrine-project.org/",
"require": {
"php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0",
"php": "~8.0.0 || ~8.1.0 || ~8.2.0",
"composer-runtime-api": "^2.0",
"doctrine/annotations": "^1.13.3 || ^2",
"doctrine/cache": "^1.13.0 || ^2.1.0",
Expand Down
4 changes: 2 additions & 2 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<arg name="cache" value=".phpcs.cache"/>
<arg name="colors"/>

<!-- set minimal required PHP version (7.4) -->
<config name="php_version" value="70400"/>
<!-- set minimal required PHP version (8.0) -->
<config name="php_version" value="80000"/>

<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>
Expand Down
1 change: 0 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ parameters:
-
message: '#mock an undefined method save\(\) on class Doctrine\\Common\\Cache\\ArrayCache#'
path: tests/Cache/DoctrineCacheStorageTest.php

includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon
Expand Down
2 changes: 2 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0"?>
<psalm
errorLevel="4"
findUnusedCode="false"
findUnusedBaselineEntry="true"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
Expand Down
9 changes: 4 additions & 5 deletions src/Authentication/Adapter/ObjectRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Laminas\Authentication\Result as AuthenticationResult;

use function call_user_func;
use function get_class;
use function method_exists;
use function property_exists;
use function sprintf;
Expand All @@ -38,7 +37,7 @@ class ObjectRepository extends AbstractAdapter
*
* @param mixed[]|AuthenticationOptions $options
*/
public function __construct($options = [], ?Inflector $inflector = null)
public function __construct(array|AuthenticationOptions $options = [], ?Inflector $inflector = null)
{
$this->setOptions($options);
$this->inflector = $inflector ?? InflectorFactory::create()->build();
Expand All @@ -47,7 +46,7 @@ public function __construct($options = [], ?Inflector $inflector = null)
/**
* @param mixed[]|AuthenticationOptions $options
*/
public function setOptions($options): self
public function setOptions(array|AuthenticationOptions $options): self
{
if (! $options instanceof AuthenticationOptions) {
$options = new AuthenticationOptions($options);
Expand Down Expand Up @@ -102,8 +101,8 @@ protected function validateIdentity(object $identity): AuthenticationResult
sprintf(
'Property (%s) in (%s) is not accessible. You should implement %s::%s()',
$credentialProperty,
get_class($identity),
get_class($identity),
$identity::class,
$identity::class,
$getter
)
);
Expand Down
13 changes: 4 additions & 9 deletions src/Authentication/Storage/ObjectRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ObjectRepository implements StorageInterface
/**
* @param mixed[]|AuthenticationOptions $options
*/
public function setOptions($options): ObjectRepository
public function setOptions(array|AuthenticationOptions $options): ObjectRepository
{
if (! $options instanceof AuthenticationOptions) {
$options = new AuthenticationOptions($options);
Expand All @@ -33,7 +33,7 @@ public function setOptions($options): ObjectRepository
*
* @param mixed[]|AuthenticationOptions $options
*/
public function __construct($options = [])
public function __construct(array|AuthenticationOptions $options = [])
{
$this->setOptions($options);
}
Expand All @@ -60,18 +60,13 @@ public function read(): ?object
/**
* Will return the key of the identity. If only the key is needed, this avoids an
* unnecessary db call
*
* @return mixed
*/
public function readKeyOnly()
public function readKeyOnly(): mixed
{
return $identity = $this->options->getStorage()->read();
}

/**
* @param mixed $contents
*/
public function write($contents): void
public function write(mixed $contents): void
{
$metadataInfo = $this->options->getClassMetadata();
$identifierValues = $metadataInfo->getIdentifierValues($contents);
Expand Down
6 changes: 1 addition & 5 deletions src/Cache/DoctrineCacheStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,15 @@
*/
class DoctrineCacheStorage extends AbstractAdapter
{
protected Cache $cache;

/**
* {@inheritDoc}
*
* @param iterable<mixed>|AdapterOptions $options
* @param Cache $cache
*/
public function __construct($options, Cache $cache)
public function __construct($options, protected Cache $cache)
{
parent::__construct($options);

$this->cache = $cache;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Cache/LaminasStorageCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@
*/
class LaminasStorageCache extends CacheProvider
{
protected StorageInterface $storage;

public function __construct(StorageInterface $storage)
public function __construct(protected StorageInterface $storage)
{
$this->storage = $storage;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Form/Element/ObjectMultiCheckbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ public function setOptions(iterable $options): self
}

/**
* @param mixed $value
* @param mixed $key
*
* @return $this
*/
public function setOption($key, $value): self
public function setOption(mixed $key, mixed $value): self
{
$this->getProxy()->setOptions([$key => $value]);

Expand Down
5 changes: 1 addition & 4 deletions src/Form/Element/ObjectRadio.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@ public function setOptions(iterable $options): self
}

/**
* @param mixed $value
* @param mixed $key
*
* @return $this
*/
public function setOption($key, $value): self
public function setOption(mixed $key, mixed $value): self
{
$this->getProxy()->setOptions([$key => $value]);

Expand Down
5 changes: 1 addition & 4 deletions src/Form/Element/ObjectSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ public function setOptions(iterable $options): self
}

/**
* @param mixed $value
* @param mixed $key
*
* @return $this
*/
public function setOption($key, $value): self
public function setOption(mixed $key, mixed $value): self
{
$this->getProxy()->setOptions([$key => $value]);

Expand Down
41 changes: 12 additions & 29 deletions src/Form/Element/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Doctrine\Inflector\Inflector;
use Doctrine\Inflector\InflectorFactory;
use Doctrine\Persistence\ObjectManager;
use DoctrineModule\Form\Element\Exception\InvalidRepositoryResultException;
use DoctrineModule\Persistence\ObjectManagerAwareInterface;
use Laminas\Stdlib\ArrayUtils;
use Laminas\Stdlib\Guard\ArrayOrTraversableGuardTrait;
Expand All @@ -22,7 +23,6 @@
use function call_user_func;
use function count;
use function current;
use function get_class;
use function gettype;
use function is_callable;
use function is_object;
Expand All @@ -47,8 +47,7 @@ class Proxy implements ObjectManagerAwareInterface
/** @var mixed[] */
protected array $findMethod = [];

/** @var mixed */
protected $property;
protected mixed $property;

/** @var mixed[] */
protected array $optionAttributes = [];
Expand Down Expand Up @@ -131,10 +130,7 @@ public function setOptions(iterable $options): void
$this->setOptgroupDefault($options['optgroup_default']);
}

/**
* @return mixed
*/
public function getValueOptions()
public function getValueOptions(): mixed
{
if (empty($this->valueOptions)) {
$this->loadValueOptions();
Expand All @@ -143,10 +139,7 @@ public function getValueOptions()
return $this->valueOptions;
}

/**
* @return mixed
*/
public function getObjects()
public function getObjects(): mixed
{
$this->loadObjects();

Expand Down Expand Up @@ -253,10 +246,7 @@ public function setProperty(string $property): Proxy
return $this;
}

/**
* @return mixed
*/
public function getProperty()
public function getProperty(): mixed
{
return $this->property;
}
Expand Down Expand Up @@ -332,10 +322,7 @@ public function getFindMethod(): array
return $this->findMethod;
}

/**
* @param mixed $targetEntity
*/
protected function generateLabel($targetEntity): ?string
protected function generateLabel(mixed $targetEntity): ?string
{
if ($this->getLabelGenerator() === null) {
return null;
Expand All @@ -345,13 +332,9 @@ protected function generateLabel($targetEntity): ?string
}

/**
* @param mixed $value
*
* @return mixed[]|mixed|object
*
* @throws RuntimeException
*/
public function getValue($value)
public function getValue(mixed $value): mixed
{
$metadata = $this->getObjectManager()->getClassMetadata($this->getTargetClass());

Expand All @@ -366,7 +349,7 @@ public function getValue($value)

$value = $data;
} else {
$metadata = $this->getObjectManager()->getClassMetadata(get_class($value));
$metadata = $this->getObjectManager()->getClassMetadata($value::class);
$identifier = $metadata->getIdentifierFieldNames();

if ($identifier !== null && count($identifier) > 1) {
Expand Down Expand Up @@ -416,7 +399,7 @@ protected function loadObjects(): void
sprintf(
'Method "%s" could not be found in repository "%s"',
$findMethodName,
get_class($repository)
$repository::class
)
);
}
Expand All @@ -436,7 +419,7 @@ protected function loadObjects(): void
. ' was not provided',
$param->getName(),
$findMethodName,
get_class($repository)
$repository::class
)
);
}
Expand All @@ -447,8 +430,8 @@ protected function loadObjects(): void

$this->guardForArrayOrTraversable(
$objects,
sprintf('%s::%s() return value', get_class($repository), $findMethodName),
'DoctrineModule\Form\Element\Exception\InvalidRepositoryResultException'
sprintf('%s::%s() return value', $repository::class, $findMethodName),
InvalidRepositoryResultException::class
);

$this->objects = $objects;
Expand Down

0 comments on commit 38e4c4a

Please sign in to comment.