DX: fix phpstan issues

This commit is contained in:
2023-03-28 22:32:08 +02:00
parent 331443ae12
commit 48772efd54
27 changed files with 76 additions and 1309 deletions

View File

@@ -31,9 +31,6 @@ class NativeDateIntervalType extends DateIntervalType
{
public const FORMAT = '%rP%YY%MM%DDT%HH%IM%SS';
/**
* @param DateInterval|null $value
*/
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
if (null === $value) {

View File

@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\Export;
use Doctrine\ORM\NativeQuery;
use Doctrine\ORM\QueryBuilder;
/**
@@ -23,6 +24,7 @@ use Doctrine\ORM\QueryBuilder;
* aggregation, use `ListInterface`.
*
* @example Chill\PersonBundle\Export\CountPerson an example of implementation
* @template Q of QueryBuilder|NativeQuery
*/
interface ExportInterface extends ExportElementInterface
{
@@ -84,7 +86,7 @@ interface ExportInterface extends ExportElementInterface
* @param mixed[] $values The values from the result. if there are duplicates, those might be given twice. Example: array('FR', 'BE', 'CZ', 'FR', 'BE', 'FR')
* @param mixed $data The data from the export's form (as defined in `buildForm`)
*
* @return pure-callable(null|string|int|float|'_header' $value):string|int|\DateTimeInterface where the first argument is the value, and the function should return the label to show in the formatted file. Example : `function($countryCode) use ($countries) { return $countries[$countryCode]->getName(); }`
* @return callable(null|string|int|float|'_header' $value): string|int|\DateTimeInterface where the first argument is the value, and the function should return the label to show in the formatted file. Example : `function($countryCode) use ($countries) { return $countries[$countryCode]->getName(); }`
*/
public function getLabels($key, array $values, $data);
@@ -102,7 +104,7 @@ interface ExportInterface extends ExportElementInterface
/**
* Return the results of the query builder.
*
* @param \Doctrine\ORM\NativeQuery|QueryBuilder $query
* @param Q $query
* @param mixed[] $data the data from the export's fomr (added by self::buildForm)
*
* @return mixed[] an array of results
@@ -132,7 +134,7 @@ interface ExportInterface extends ExportElementInterface
* @param array $acl an array where each row has a `center` key containing the Chill\MainBundle\Entity\Center, and `circles` keys containing the reachable circles. Example: `array( array('center' => $centerA, 'circles' => array($circleA, $circleB) ) )`
* @param array $data the data from the form, if any
*
* @return \Doctrine\ORM\NativeQuery|QueryBuilder the query to execute.
* @return Q the query to execute.
*/
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []);

View File

@@ -24,15 +24,7 @@ class ExportPickCenterDataMapper implements DataMapperInterface
{
protected RegroupmentRepository $regroupmentRepository;
/**
* @param array|Center[] $data
* @param $forms
*
* @throws Exception
*
* @return void
*/
public function mapDataToForms($data, $forms)
public function mapDataToForms($data, $forms): void
{
if (null === $data) {
return;
@@ -44,7 +36,9 @@ class ExportPickCenterDataMapper implements DataMapperInterface
$pickedRegroupment = [];
foreach ($this->regroupmentRepository->findAll() as $regroupment) {
[$contained, $notContained] = $regroupment->getCenters()->partition(static function (Center $center) {
/** @phpstan-ignore-next-line */
[$contained, $notContained] = $regroupment->getCenters()->partition(static function (Center $center): bool {
return false;
});
if (0 === count($notContained)) {
@@ -56,13 +50,7 @@ class ExportPickCenterDataMapper implements DataMapperInterface
$form['centers']->setData($data);
}
/**
* @param iterable $forms
* @param array $data
*
* @return void
*/
public function mapFormsToData($forms, &$data)
public function mapFormsToData($forms, &$data): void
{
/** @var array<string, FormInterface> $forms */
$forms = iterator_to_array($forms);
@@ -74,8 +62,8 @@ class ExportPickCenterDataMapper implements DataMapperInterface
}
if (array_key_exists('regroupment', $forms)) {
/** @var Regroupment $regroupment */
foreach ($forms['regroupment']->getData() as $regroupment) {
/** @var Regroupment $regroupment */
foreach ($regroupment->getCenters() as $center) {
$centers[spl_object_hash($center)] = $center;
}

View File

@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\Workflow;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
interface EntityWorkflowHandlerInterface