mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
DX: fix phpstan errors
This commit is contained in:
parent
856eea37ee
commit
584ac05b53
@ -1,76 +1,6 @@
|
|||||||
parameters:
|
parameters:
|
||||||
ignoreErrors:
|
ignoreErrors:
|
||||||
-
|
|
||||||
message: "#^Implicit array creation is not allowed \\- variable \\$centers might not exist\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Entity\\\\AccompanyingPeriod\\:\\:\\$work\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Undefined variable\\: \\$person$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Variable variables are not allowed\\.$#"
|
|
||||||
count: 4
|
|
||||||
path: src/Bundle/ChillPersonBundle/Search/PersonSearch.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Function Chill\\\\PersonBundle\\\\Serializer\\\\Normalizer\\\\·\\\\is_array not found\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Undefined variable\\: \\$choiceSlug$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillReportBundle/Export/Export/ReportList.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Undefined variable\\: \\$type$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillTaskBundle/Controller/TaskController.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Call to an undefined method Chill\\\\MainBundle\\\\CRUD\\\\Controller\\\\AbstractCRUDController\\:\\:getRoleFor\\(\\)\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Controller\\\\UserController\\:\\:createEditForm\\(\\)\\.$#"
|
message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Controller\\\\UserController\\:\\:createEditForm\\(\\)\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
path: src/Bundle/ChillMainBundle/Controller/UserController.php
|
path: src/Bundle/ChillMainBundle/Controller/UserController.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Undefined variable\\: \\$current$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillMainBundle/Pagination/PageGenerator.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AbstractChillVoter\\:\\:getSupportedAttributes\\(\\)\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AbstractChillVoter\\:\\:getSupportedClasses\\(\\)\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Call to an undefined method Chill\\\\MainBundle\\\\Security\\\\Authorization\\\\AbstractChillVoter\\:\\:isGranted\\(\\)\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillMainBundle/Security/Authorization/AbstractChillVoter.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Access to an undefined property Chill\\\\PersonBundle\\\\Controller\\\\PersonController\\:\\:\\$security\\.$#"
|
|
||||||
count: 3
|
|
||||||
path: src/Bundle/ChillPersonBundle/Controller/PersonController.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Call to an undefined method Chill\\\\ThirdPartyBundle\\\\Form\\\\Type\\\\PickThirdPartyTypeCategoryType\\:\\:transform\\(\\)\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: src/Bundle/ChillThirdPartyBundle/Form/Type/PickThirdPartyTypeCategoryType.php
|
|
||||||
|
@ -225,10 +225,9 @@ final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInte
|
|||||||
$personToCenter = $metadataPerson->getAssociationMapping('center')['joinColumns'][0]['name'];
|
$personToCenter = $metadataPerson->getAssociationMapping('center')['joinColumns'][0]['name'];
|
||||||
|
|
||||||
// acls:
|
// acls:
|
||||||
$role = new Role(ActivityVoter::SEE);
|
|
||||||
$reachableCenters = $this->authorizationHelper->getReachableCenters(
|
$reachableCenters = $this->authorizationHelper->getReachableCenters(
|
||||||
$this->tokenStorage->getToken()->getUser(),
|
$this->tokenStorage->getToken()->getUser(),
|
||||||
$role
|
ActivityVoter::SEE
|
||||||
);
|
);
|
||||||
|
|
||||||
if (count($reachableCenters) === 0) {
|
if (count($reachableCenters) === 0) {
|
||||||
@ -239,7 +238,7 @@ final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInte
|
|||||||
if ('person' === $context) {
|
if ('person' === $context) {
|
||||||
// we start with activities having the person_id linked to person
|
// we start with activities having the person_id linked to person
|
||||||
$where .= sprintf('%s = ? AND ', $activityToPerson);
|
$where .= sprintf('%s = ? AND ', $activityToPerson);
|
||||||
$parameters[] = $person->getId();
|
$parameters[] = $args['context']->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
// we add acl (reachable center and scopes)
|
// we add acl (reachable center and scopes)
|
||||||
@ -252,7 +251,7 @@ final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInte
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// we get all the reachable scopes for this center
|
// we get all the reachable scopes for this center
|
||||||
$reachableScopes = $this->authorizationHelper->getReachableScopes($this->tokenStorage->getToken()->getUser(), $role, $center);
|
$reachableScopes = $this->authorizationHelper->getReachableScopes($this->tokenStorage->getToken()->getUser(), ActivityVoter::SEE, $center);
|
||||||
// we get the ids for those scopes
|
// we get the ids for those scopes
|
||||||
$reachablesScopesId = array_map(
|
$reachablesScopesId = array_map(
|
||||||
static function (Scope $scope) {
|
static function (Scope $scope) {
|
||||||
|
@ -34,6 +34,29 @@ abstract class AbstractCRUDController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
protected array $crudConfig = [];
|
protected array $crudConfig = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the role given from the config.
|
||||||
|
*
|
||||||
|
* @param mixed $entity
|
||||||
|
* @param mixed $_format
|
||||||
|
*/
|
||||||
|
protected function getRoleFor(string $action, Request $request, $entity, $_format): string
|
||||||
|
{
|
||||||
|
$actionConfig = $this->getActionConfig($action);
|
||||||
|
|
||||||
|
if (null !== $actionConfig['roles'][$request->getMethod()]) {
|
||||||
|
return $actionConfig['roles'][$request->getMethod()];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->crudConfig['base_role']) {
|
||||||
|
return $this->crudConfig['base_role'];
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \RuntimeException(sprintf('the config does not have any role for the ' .
|
||||||
|
'method %s nor a global role for the whole action. Add those to your ' .
|
||||||
|
'configuration or override the required method', $request->getMethod()));
|
||||||
|
}
|
||||||
|
|
||||||
public static function getSubscribedServices(): array
|
public static function getSubscribedServices(): array
|
||||||
{
|
{
|
||||||
return array_merge(
|
return array_merge(
|
||||||
|
@ -499,28 +499,6 @@ class ApiController extends AbstractCRUDController
|
|||||||
return ['groups' => ['read']];
|
return ['groups' => ['read']];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* get the role given from the config.
|
|
||||||
*
|
|
||||||
* @param mixed $entity
|
|
||||||
* @param mixed $_format
|
|
||||||
*/
|
|
||||||
protected function getRoleFor(string $action, Request $request, $entity, $_format): string
|
|
||||||
{
|
|
||||||
$actionConfig = $this->getActionConfig($action);
|
|
||||||
|
|
||||||
if (null !== $actionConfig['roles'][$request->getMethod()]) {
|
|
||||||
return $actionConfig['roles'][$request->getMethod()];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->crudConfig['base_role']) {
|
|
||||||
return $this->crudConfig['base_role'];
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new RuntimeException(sprintf('the config does not have any role for the ' .
|
|
||||||
'method %s nor a global role for the whole action. Add those to your ' .
|
|
||||||
'configuration or override the required method', $request->getMethod()));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getSerializer(): SerializerInterface
|
protected function getSerializer(): SerializerInterface
|
||||||
{
|
{
|
||||||
|
@ -183,7 +183,7 @@ final class PhonenumberHelper implements PhoneNumberHelperInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// filter only number
|
// filter only number
|
||||||
$filtered = preg_replace('/[^0-9]/', '', $phonenumber);
|
$filtered = preg_replace('/[^0-9]/', '', (string) $phonenumber);
|
||||||
|
|
||||||
$item = $this->cachePool->getItem('pnum_' . $filtered);
|
$item = $this->cachePool->getItem('pnum_' . $filtered);
|
||||||
|
|
||||||
|
@ -26,28 +26,4 @@ use const E_USER_DEPRECATED;
|
|||||||
*/
|
*/
|
||||||
abstract class AbstractChillVoter extends Voter implements ChillVoterInterface
|
abstract class AbstractChillVoter extends Voter implements ChillVoterInterface
|
||||||
{
|
{
|
||||||
protected function supports($attribute, $subject)
|
|
||||||
{
|
|
||||||
@trigger_error(
|
|
||||||
'This voter should implements the new `supports` '
|
|
||||||
. 'methods introduced by Symfony 3.0, and do not rely on '
|
|
||||||
. 'getSupportedAttributes and getSupportedClasses methods.',
|
|
||||||
E_USER_DEPRECATED
|
|
||||||
);
|
|
||||||
|
|
||||||
// @TODO: getSupportedAttributes() should be created in here and made abstract or in ChillVoterInterface.
|
|
||||||
// @TODO: getSupportedClasses() should be created in here and made abstract or in ChillVoterInterface.
|
|
||||||
return in_array($attribute, $this->getSupportedAttributes($attribute), true)
|
|
||||||
&& in_array(get_class($subject), $this->getSupportedClasses(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
|
|
||||||
{
|
|
||||||
@trigger_error('This voter should implements the new `voteOnAttribute` '
|
|
||||||
. 'methods introduced by Symfony 3.0, and do not rely on '
|
|
||||||
. 'isGranted method', E_USER_DEPRECATED);
|
|
||||||
|
|
||||||
// @TODO: isGranted() should be created in here and made abstract or in ChillVoterInterface.
|
|
||||||
return $this->isGranted($attribute, $subject, $token->getUser());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,8 @@ final class PersonController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
protected $personRepository;
|
protected $personRepository;
|
||||||
|
|
||||||
|
private Security $security;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var SimilarPersonMatcher
|
* @var SimilarPersonMatcher
|
||||||
*/
|
*/
|
||||||
|
@ -1155,7 +1155,7 @@ class AccompanyingPeriod implements
|
|||||||
|
|
||||||
public function removeWork(AccompanyingPeriodWork $work): self
|
public function removeWork(AccompanyingPeriodWork $work): self
|
||||||
{
|
{
|
||||||
$this->work->removeElement($work);
|
$this->works->removeElement($work);
|
||||||
$work->setAccompanyingPeriod(null);
|
$work->setAccompanyingPeriod(null);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -181,7 +181,7 @@ class MembersEditorNormalizer implements DenormalizerAwareInterface, Denormalize
|
|||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
null === $data['concerned'] ?? null
|
null === $data['concerned'] ?? null
|
||||||
&& false === ·\is_array('concerned')
|
&& false === \is_array('concerned')
|
||||||
) {
|
) {
|
||||||
throw new Exception\UnexpectedValueException("The schema does not have any key 'concerned'");
|
throw new Exception\UnexpectedValueException("The schema does not have any key 'concerned'");
|
||||||
}
|
}
|
||||||
|
@ -541,7 +541,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface
|
|||||||
. ' | ' . $label;
|
. ' | ' . $label;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('_other' === $slugChoice && $cfType->isChecked($cf, $choiceSlug, $decoded)) {
|
if ('_other' === $slugChoice && $cfType->isChecked($cf, $slugChoice, $decoded)) {
|
||||||
return $cfType->extractOtherValue($cf, $decoded);
|
return $cfType->extractOtherValue($cf, $decoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ class TaskController extends AbstractController
|
|||||||
|
|
||||||
if (null === $task) {
|
if (null === $task) {
|
||||||
throw $this->createNotFoundException("task with id '{$taskId}' and type "
|
throw $this->createNotFoundException("task with id '{$taskId}' and type "
|
||||||
. "'{$type}' does not exists");
|
. "'{$kind}' does not exists");
|
||||||
}
|
}
|
||||||
|
|
||||||
$workflow = $registry->get($task);
|
$workflow = $registry->get($task);
|
||||||
|
@ -88,22 +88,12 @@ class PickThirdPartyTypeCategoryType extends \Symfony\Component\Form\AbstractTyp
|
|||||||
return ChoiceType::class;
|
return ChoiceType::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reverseTransform($value)
|
private function reverseTransform($value)
|
||||||
{
|
{
|
||||||
if (null === $value) {
|
if (null === $value) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($value)) {
|
|
||||||
$r = [];
|
|
||||||
|
|
||||||
foreach ($value as $v) {
|
|
||||||
$r[] = $this->transform($v);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $r;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($value instanceof ThirdPartyCategory) {
|
if ($value instanceof ThirdPartyCategory) {
|
||||||
return 'category:' . $value->getId();
|
return 'category:' . $value->getId();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user