mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-04 07:56:12 +00:00
fix phpstan, cs, and rector rules
This commit is contained in:
parent
059e4a0acd
commit
56d173046d
@ -76,7 +76,7 @@
|
||||
"phpunit/phpunit": ">= 7.5",
|
||||
"psalm/plugin-phpunit": "^0.18.4",
|
||||
"psalm/plugin-symfony": "^4.0.2",
|
||||
"rector/rector": "^0.17.7",
|
||||
"rector/rector": "^1.1.0",
|
||||
"symfony/debug-bundle": "^5.1",
|
||||
"symfony/dotenv": "^4.4",
|
||||
"symfony/maker-bundle": "^1.20",
|
||||
|
6
phpstan-baseline-2024-05.neon
Normal file
6
phpstan-baseline-2024-05.neon
Normal file
@ -0,0 +1,6 @@
|
||||
parameters:
|
||||
ignoreErrors:
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$records of method League\\\\Csv\\\\Writer\\:\\:insertAll\\(\\) expects iterable\\<array\\<float\\|int\\|string\\|Stringable\\|null\\>\\>, iterable\\<array\\<string, bool\\|int\\|string\\>\\> given\\.$#"
|
||||
count: 1
|
||||
path: src/Bundle/ChillMainBundle/Controller/UserExportController.php
|
@ -31,4 +31,5 @@ includes:
|
||||
- phpstan-baseline-level-3.neon
|
||||
- phpstan-baseline-level-4.neon
|
||||
- phpstan-baseline-level-5.neon
|
||||
- phpstan-baseline-2024-05.neon
|
||||
|
||||
|
@ -45,9 +45,6 @@ return static function (RectorConfig $rectorConfig): void {
|
||||
|
||||
// skip some path...
|
||||
$rectorConfig->skip([
|
||||
// we need to discuss this: are we going to have FALSE in tests instead of an error ?
|
||||
\Rector\Php71\Rector\FuncCall\CountOnNullRector::class,
|
||||
|
||||
// we must adapt service definition
|
||||
\Rector\Symfony\Symfony28\Rector\MethodCall\GetToConstructorInjectionRector::class,
|
||||
\Rector\Symfony\Symfony34\Rector\Closure\ContainerGetNameToTypeInTestsRector::class,
|
||||
|
@ -49,20 +49,17 @@ interface CustomFieldInterface
|
||||
|
||||
/**
|
||||
* Return if the value can be considered as empty.
|
||||
*
|
||||
* @param mixed $value the value passed throug the deserialize function
|
||||
*/
|
||||
public function isEmptyValue($value, CustomField $customField);
|
||||
public function isEmptyValue(mixed $value, CustomField $customField);
|
||||
|
||||
/**
|
||||
* Return a repsentation of the value of the CustomField.
|
||||
*
|
||||
* @param mixed $value the raw value, **not deserialized** (= as stored in the db)
|
||||
* @param \Chill\CustomFieldsBundle\CustomField\CustomField $customField
|
||||
*
|
||||
* @return string an html representation of the value
|
||||
*/
|
||||
public function render($value, CustomField $customField, $documentType = 'html');
|
||||
public function render(mixed $value, CustomField $customField, $documentType = 'html');
|
||||
|
||||
/**
|
||||
* Transform the value into a format that can be stored in DB.
|
||||
|
@ -399,8 +399,6 @@ final class CustomFieldsChoiceTest extends KernelTestCase
|
||||
|
||||
/**
|
||||
* @dataProvider emptyDataProvider
|
||||
*
|
||||
* @param mixed $data deserialized data
|
||||
*/
|
||||
public function testIsEmptyValueEmpty(mixed $data)
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ class JWTOnDavUrlAuthenticator extends JWTTokenAuthenticator
|
||||
TokenExtractorInterface $tokenExtractor,
|
||||
private readonly DavOnUrlTokenExtractor $davOnUrlTokenExtractor,
|
||||
TokenStorageInterface $preAuthenticationTokenStorage,
|
||||
TranslatorInterface $translator = null,
|
||||
?TranslatorInterface $translator = null,
|
||||
) {
|
||||
parent::__construct($jwtManager, $dispatcher, $tokenExtractor, $preAuthenticationTokenStorage, $translator);
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ final readonly class WopiEditTwigExtensionRuntime implements RuntimeExtensionInt
|
||||
* @throws \Twig\Error\RuntimeError
|
||||
* @throws \Twig\Error\SyntaxError
|
||||
*/
|
||||
public function renderButtonGroup(Environment $environment, StoredObject $document, string $title = null, bool $canEdit = true, array $options = []): string
|
||||
public function renderButtonGroup(Environment $environment, StoredObject $document, ?string $title = null, bool $canEdit = true, array $options = []): string
|
||||
{
|
||||
$accessToken = $this->davTokenProvider->createToken(
|
||||
$document,
|
||||
@ -174,7 +174,7 @@ final readonly class WopiEditTwigExtensionRuntime implements RuntimeExtensionInt
|
||||
]);
|
||||
}
|
||||
|
||||
public function renderEditButton(Environment $environment, StoredObject $document, array $options = null): string
|
||||
public function renderEditButton(Environment $environment, StoredObject $document, ?array $options = null): string
|
||||
{
|
||||
return $environment->render(self::TEMPLATE, [
|
||||
'document' => $document,
|
||||
|
@ -32,7 +32,7 @@ class StoredObjectVoterTest extends TestCase
|
||||
/**
|
||||
* @dataProvider provideDataVote
|
||||
*/
|
||||
public function testVote(TokenInterface $token, null|object $subject, string $attribute, mixed $expected): void
|
||||
public function testVote(TokenInterface $token, ?object $subject, string $attribute, mixed $expected): void
|
||||
{
|
||||
$voter = new StoredObjectVoter();
|
||||
|
||||
@ -98,7 +98,7 @@ class StoredObjectVoterTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
private function buildToken(StoredObjectRoleEnum $storedObjectRoleEnum = null, StoredObject $storedObject = null): TokenInterface
|
||||
private function buildToken(?StoredObjectRoleEnum $storedObjectRoleEnum = null, ?StoredObject $storedObject = null): TokenInterface
|
||||
{
|
||||
$token = $this->prophesize(TokenInterface::class);
|
||||
|
||||
|
@ -206,8 +206,6 @@ class EventTypeController extends AbstractController
|
||||
/**
|
||||
* Creates a form to delete a EventType entity by id.
|
||||
*
|
||||
* @param mixed $id The entity id
|
||||
*
|
||||
* @return \Symfony\Component\Form\Form The form
|
||||
*/
|
||||
private function createDeleteForm(mixed $id)
|
||||
|
@ -206,8 +206,6 @@ class RoleController extends AbstractController
|
||||
/**
|
||||
* Creates a form to delete a Role entity by id.
|
||||
*
|
||||
* @param mixed $id The entity id
|
||||
*
|
||||
* @return \Symfony\Component\Form\Form The form
|
||||
*/
|
||||
private function createDeleteForm(mixed $id)
|
||||
|
@ -206,8 +206,6 @@ class StatusController extends AbstractController
|
||||
/**
|
||||
* Creates a form to delete a Status entity by id.
|
||||
*
|
||||
* @param mixed $id The entity id
|
||||
*
|
||||
* @return \Symfony\Component\Form\Form The form
|
||||
*/
|
||||
private function createDeleteForm(mixed $id)
|
||||
|
@ -700,7 +700,6 @@ class CRUDController extends AbstractController
|
||||
* and view.
|
||||
*
|
||||
* @param string $action
|
||||
* @param mixed $entity the entity for the current request, or an array of entities
|
||||
*
|
||||
* @return string the path to the template
|
||||
*
|
||||
|
@ -317,8 +317,8 @@ final class PermissionsGroupController extends AbstractController
|
||||
}
|
||||
|
||||
return strcmp(
|
||||
$translatableStringHelper->localize($a->getScope()->getName()),
|
||||
$translatableStringHelper->localize($b->getScope()->getName())
|
||||
(string) $translatableStringHelper->localize($a->getScope()->getName()),
|
||||
(string) $translatableStringHelper->localize($b->getScope()->getName())
|
||||
);
|
||||
}
|
||||
);
|
||||
@ -451,8 +451,6 @@ final class PermissionsGroupController extends AbstractController
|
||||
|
||||
/**
|
||||
* Creates a form to delete a link to roleScope.
|
||||
*
|
||||
* @param mixed $permissionsGroup The entity id
|
||||
*/
|
||||
private function createDeleteRoleScopeForm(
|
||||
PermissionsGroup $permissionsGroup,
|
||||
|
@ -73,6 +73,7 @@ final readonly class UserExportController
|
||||
)
|
||||
);
|
||||
$csv->addFormatter(fn (array $row) => null !== ($row['absenceStart'] ?? null) ? array_merge($row, ['absenceStart' => $row['absenceStart']->format('Y-m-d')]) : $row);
|
||||
/* @phpstan-ignore-next-line as phpstan seem to ignore that we transform datetime into string */
|
||||
$csv->insertAll($users);
|
||||
|
||||
return new StreamedResponse(
|
||||
|
@ -344,11 +344,11 @@ class LoadPostalCodes extends AbstractFixture implements OrderedFixtureInterface
|
||||
->findOneBy(['countryCode' => $countryCode]);
|
||||
|
||||
foreach ($lines as $line) {
|
||||
$code = str_getcsv($line);
|
||||
$code = str_getcsv((string) $line);
|
||||
$c = new PostalCode();
|
||||
$c->setCountry($country)
|
||||
->setCode($code[0])
|
||||
->setName(\ucwords(\strtolower($code[1])));
|
||||
->setName(\ucwords(\strtolower((string) $code[1])));
|
||||
|
||||
if (null !== ($code[3] ?? null)) {
|
||||
$c->setRefPostalCodeId($code[3]);
|
||||
|
@ -73,7 +73,6 @@ interface AggregatorInterface extends ModifierInterface
|
||||
*
|
||||
* @param string $key The column key, as added in the query
|
||||
* @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 \Closure 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(); }`
|
||||
*/
|
||||
|
@ -30,8 +30,6 @@ interface ExportElementValidatedInterface
|
||||
/**
|
||||
* validate the form's data and, if required, build a contraint
|
||||
* violation on the data.
|
||||
*
|
||||
* @param mixed $data the data, as returned by the user
|
||||
*/
|
||||
public function validateForm(mixed $data, ExecutionContextInterface $context);
|
||||
}
|
||||
|
@ -96,7 +96,6 @@ interface ExportInterface extends ExportElementInterface
|
||||
*
|
||||
* @param string $key The column key, as added in the query
|
||||
* @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 (callable(string|int|float|'_header'|null $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(); }`
|
||||
*/
|
||||
|
@ -552,7 +552,6 @@ class ExportManager
|
||||
*
|
||||
* This function check the acl.
|
||||
*
|
||||
* @param mixed $data the data under the initial 'filters' data
|
||||
* @param \Chill\MainBundle\Entity\Center[] $centers the picked centers
|
||||
*
|
||||
* @throw UnauthorizedHttpException if the user is not authorized
|
||||
@ -615,9 +614,6 @@ class ExportManager
|
||||
return $usedTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $data the data from the filter key of the ExportType
|
||||
*/
|
||||
private function retrieveUsedFilters(mixed $data): iterable
|
||||
{
|
||||
if (null === $data) {
|
||||
@ -634,8 +630,6 @@ class ExportManager
|
||||
/**
|
||||
* Retrieve the filter used in this export.
|
||||
*
|
||||
* @param mixed $data the data from the `filters` key of the ExportType
|
||||
*
|
||||
* @return array an array with types
|
||||
*/
|
||||
private function retrieveUsedFiltersType(mixed $data): iterable
|
||||
|
@ -257,10 +257,10 @@ class SearchProvider
|
||||
$this->mustBeExtracted[] = $matches[0][$key];
|
||||
// strip parenthesis
|
||||
if (
|
||||
'"' === mb_substr((string) $match, 0, 1)
|
||||
&& '"' === mb_substr((string) $match, mb_strlen((string) $match) - 1)
|
||||
'"' === mb_substr($match, 0, 1)
|
||||
&& '"' === mb_substr($match, mb_strlen($match) - 1)
|
||||
) {
|
||||
$match = trim(mb_substr((string) $match, 1, mb_strlen((string) $match) - 2));
|
||||
$match = trim(mb_substr($match, 1, mb_strlen($match) - 2));
|
||||
}
|
||||
$terms[$matches[1][$key]] = $match;
|
||||
}
|
||||
|
@ -199,8 +199,6 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
||||
* if the entity implements Chill\MainBundle\Entity\HasScopeInterface,
|
||||
* the scope is taken into account.
|
||||
*
|
||||
* @param mixed $entity the entity may also implement HasScopeInterface
|
||||
*
|
||||
* @return bool true if the user has access
|
||||
*/
|
||||
public function userHasAccess(User $user, mixed $entity, string $attribute)
|
||||
|
@ -788,7 +788,7 @@ class AccompanyingPeriod implements
|
||||
if (self::STEP_DRAFT === $this->getStep()) {
|
||||
return [[self::STEP_DRAFT]];
|
||||
}
|
||||
if (str_starts_with($this->getStep(), 'CONFIRM')) {
|
||||
if (str_starts_with((string) $this->getStep(), 'CONFIRM')) {
|
||||
return [[self::STEP_DRAFT, self::STEP_CONFIRMED]];
|
||||
}
|
||||
if (self::STEP_CLOSED === $this->getStep()) {
|
||||
|
@ -1787,10 +1787,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $spokenLanguages
|
||||
*/
|
||||
public function setSpokenLanguages($spokenLanguages): self
|
||||
public function setSpokenLanguages(mixed $spokenLanguages): self
|
||||
{
|
||||
$this->spokenLanguages = $spokenLanguages;
|
||||
|
||||
|
@ -112,8 +112,8 @@ final readonly class PersonACLAwareRepository implements PersonACLAwareRepositor
|
||||
$andWhereSearchClause = [];
|
||||
$andWhereSearchClauseArgs = [];
|
||||
|
||||
if ('' !== trim($default)) {
|
||||
foreach (\explode(' ', $default) as $str) {
|
||||
if ('' !== trim((string) $default)) {
|
||||
foreach (\explode(' ', (string) $default) as $str) {
|
||||
if ('' === trim($str)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -686,20 +686,9 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface, \Strin
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setCenters(Collection $centers)
|
||||
public function setCenters(Collection $centers): self
|
||||
{
|
||||
foreach ($centers as $center) {
|
||||
$this->addCenter($center);
|
||||
}
|
||||
|
||||
foreach ($this->centers as $center) {
|
||||
if (false === $centers->contains($center)) {
|
||||
$this->removeCenter($center);
|
||||
}
|
||||
}
|
||||
$this->centers = $centers;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ use Chill\MainBundle\Export\ExportInterface;
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\MainBundle\Export\ListInterface;
|
||||
use PhpParser\Node;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Rector\AbstractRector;
|
||||
use Rector\Symfony\NodeAnalyzer\ClassAnalyzer;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user