diff --git a/composer.json b/composer.json index 9dbc9e90..ee0ece7f 100755 --- a/composer.json +++ b/composer.json @@ -36,7 +36,7 @@ "require": { "pimcore/pimcore": "^11.0", "doctrine/orm": "^2.7", - "symfony/form": "^6.2" + "symfony/form": "^6.4" }, "require-dev": { "codeception/codeception": "^5.0", diff --git a/src/Controller/ResettingController.php b/src/Controller/ResettingController.php index 9161b57b..3d43831e 100644 --- a/src/Controller/ResettingController.php +++ b/src/Controller/ResettingController.php @@ -44,7 +44,7 @@ public function sendEmailAction(Request $request): Response { $username = $request->request->get('username'); - /** @var UserInterface $user */ + /** @var UserInterface|null $user */ $user = $this->userManager->findUserByUsernameOrEmail($username); /* Dispatch init event */ diff --git a/src/CoreExtension/GroupMultiselect.php b/src/CoreExtension/GroupMultiselect.php index d276c6c9..5781f5b2 100644 --- a/src/CoreExtension/GroupMultiselect.php +++ b/src/CoreExtension/GroupMultiselect.php @@ -252,7 +252,7 @@ protected function prepareDataForPersistence(array|Element\ElementInterface $dat return $return; } - if (is_array($data) && count($data) === 0) { + if (is_array($data)) { //give empty array if data was not null return []; } diff --git a/src/Document/Builder/BrickBuilder.php b/src/Document/Builder/BrickBuilder.php index 1a87dad0..8c7e9ca3 100644 --- a/src/Document/Builder/BrickBuilder.php +++ b/src/Document/Builder/BrickBuilder.php @@ -9,7 +9,7 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; -use Symfony\Bundle\SecurityBundle\Security; +use Symfony\Component\Security\Http\SecurityRequestAttributes; use Twig\Environment; class BrickBuilder @@ -122,13 +122,13 @@ public function getViewParams(): array //only show backend note $template = $this->getTemplate('area-not-available'); } elseif (!$this->tokenStorage->getToken()?->getUser() instanceof UserInterface) { - $authErrorKey = Security::AUTHENTICATION_ERROR; - $lastUsernameKey = Security::LAST_USERNAME; + $authErrorKey = SecurityRequestAttributes::AUTHENTICATION_ERROR; + $lastUsernameKey = SecurityRequestAttributes::LAST_USERNAME; // get the error if any (works with forward and redirect -- see below) if ($this->request->attributes->has($authErrorKey)) { $error = $this->request->attributes->get($authErrorKey); - } elseif (null !== $this->request->getSession() && $this->request->getSession()->has($authErrorKey)) { + } elseif ($this->request->getSession()->has($authErrorKey)) { $error = $this->request->getSession()->get($authErrorKey); $this->request->getSession()->remove($authErrorKey); } else { diff --git a/src/Manager/ClassManager.php b/src/Manager/ClassManager.php index ab887aa2..a3ca5e4a 100644 --- a/src/Manager/ClassManager.php +++ b/src/Manager/ClassManager.php @@ -15,10 +15,9 @@ public function __construct(protected Configuration $configuration) public function getGroupListing(): Listing { - /** @var AbstractObject $listingClass */ $listingClass = $this->getGroupClass(); - if (!Tool::classExists($listingClass)) { + if (!Tool::classExists($listingClass) || !method_exists($listingClass, 'getList')) { throw new \Exception(sprintf('Cannot create listing with class "%s"', $listingClass)); } @@ -27,10 +26,9 @@ public function getGroupListing(): Listing public function getUserListing(): Listing { - /** @var AbstractObject $listingClass */ $listingClass = $this->getUserClass(); - if (!Tool::classExists($listingClass)) { + if (!Tool::classExists($listingClass) || !method_exists($listingClass, 'getList')) { throw new \Exception(sprintf('Cannot create listing with class "%s"', $listingClass)); } @@ -39,10 +37,9 @@ public function getUserListing(): Listing public function getSsoIdentityListing(): Listing { - /** @var AbstractObject $listingClass */ $listingClass = $this->getSsoIdentityClass(); - if (!Tool::classExists($listingClass)) { + if (!Tool::classExists($listingClass) || !method_exists($listingClass, 'getList')) { throw new \Exception(sprintf('Cannot create listing with class "%s"', $listingClass)); } diff --git a/src/Manager/RestrictionManager.php b/src/Manager/RestrictionManager.php index 88884aef..e1cdb6f8 100644 --- a/src/Manager/RestrictionManager.php +++ b/src/Manager/RestrictionManager.php @@ -48,12 +48,7 @@ public function getElementRestrictedGroups(ElementInterface $element): array return $groups; } - $groups = []; - if (is_array($restriction->getRelatedGroups())) { - $groups = $restriction->getRelatedGroups(); - } - - return $groups; + return $restriction->getRelatedGroups(); } public function getElementRestrictionStatus(ElementInterface $element): ElementRestriction @@ -88,9 +83,7 @@ public function getElementRestrictionStatus(ElementInterface $element): ElementR return $elementRestriction; } - if (is_array($restriction->getRelatedGroups())) { - $elementRestriction->setRestrictionGroups($restriction->getRelatedGroups()); - } + $elementRestriction->setRestrictionGroups($restriction->getRelatedGroups()); //check if user is not logged in. if (!$user instanceof UserInterface) { diff --git a/src/Manager/SsoIdentityManager.php b/src/Manager/SsoIdentityManager.php index 785adc7d..f939c561 100644 --- a/src/Manager/SsoIdentityManager.php +++ b/src/Manager/SsoIdentityManager.php @@ -86,7 +86,7 @@ public function createSsoIdentity(UserInterface $user, string $provider, string $key = File::getValidFilename(sprintf('%s-%s', $provider, $identifier)); $path = sprintf('%s/%s', $user->getRealFullPath(), $key); - /** @var SsoIdentityInterface $ssoIdentity */ + /** @var SsoIdentityInterface|null $ssoIdentity */ $ssoIdentity = DataObject::getByPath($path); if (!$ssoIdentity instanceof SsoIdentityInterface) { @@ -158,7 +158,6 @@ protected function findSsoIdentity(string $provider, string $identifier): ?SsoId protected function findUserBySsoIdentity(SsoIdentityInterface $ssoIdentity): ?UserInterface { - /** @var DataObject\Concrete $userClass */ $userClass = $this->classManager->getUserClass(); $qb = $this->connection->createQueryBuilder(); diff --git a/src/Restriction/Dao.php b/src/Restriction/Dao.php index 5e2dae1f..ea048ecf 100644 --- a/src/Restriction/Dao.php +++ b/src/Restriction/Dao.php @@ -80,20 +80,12 @@ public function save() return true; } - /** - * @param array $data - * - * @return mixed - * @throws Exception - */ - private function addRelationData($data) + private function addRelationData(array $data): array { $relations = $this->db->fetchAllAssociative('SELECT * FROM ' . $this->tableRelationName . ' WHERE restrictionId = ?', [$data['id']]); - if ($relations !== false) { - foreach ($relations as $relation) { - $data['relatedGroups'][] = $relation['groupId']; - } + foreach ($relations as $relation) { + $data['relatedGroups'][] = $relation['groupId']; } return $data; diff --git a/src/Service/RequestPropertiesForUserExtractorService.php b/src/Service/RequestPropertiesForUserExtractorService.php index e3e5001d..e3fe559e 100644 --- a/src/Service/RequestPropertiesForUserExtractorService.php +++ b/src/Service/RequestPropertiesForUserExtractorService.php @@ -29,11 +29,11 @@ public function extractFromParameterBag(array $parameter): array { $userProperties = []; - if (isset($parameter['locale']) && $parameter['locale'] !== null) { + if (isset($parameter['locale'])) { $userProperties['_user_locale'] = $parameter['locale']; } - if (isset($parameter['site_id']) && $parameter['site_id'] !== null) { + if (isset($parameter['site_id'])) { $site = Site::getById($parameter['site_id']); if ($site instanceof Site) { $userProperties['_site_domain'] = $site->getMainDomain(); diff --git a/src/Service/ResourceMappingService.php b/src/Service/ResourceMappingService.php index a883deb5..2ec92ed9 100644 --- a/src/Service/ResourceMappingService.php +++ b/src/Service/ResourceMappingService.php @@ -64,10 +64,6 @@ public function addDefaults(UserInterface $user, ResourceOwnerInterface $resourc $ownerDetails = $resourceOwner->toArray(); $disallowedProperties = ['lastLogin', 'password', 'confirmationToken', 'passwordRequestedAt', 'groups', 'ssoIdentities']; - if (!is_array($ownerDetails)) { - return; - } - foreach ($ownerDetails as $property => $value) { if (in_array(strtolower($property), $disallowedProperties)) { continue; diff --git a/src/Service/SsoIdentityStatusService.php b/src/Service/SsoIdentityStatusService.php index 22ec37ce..cd9171b2 100644 --- a/src/Service/SsoIdentityStatusService.php +++ b/src/Service/SsoIdentityStatusService.php @@ -55,10 +55,7 @@ protected function determinateDeletionByDefaults(UserInterface $user): bool // don't touch a user if he has other identities $userSsoIdentities = $this->ssoIdentityManager->getSsoIdentities($user); - if (is_array($userSsoIdentities) && count($userSsoIdentities) > 0) { - return false; - } - return true; + return count($userSsoIdentities) <= 0; } } diff --git a/src/Twig/Extension/OAuthExtension.php b/src/Twig/Extension/OAuthExtension.php index 6c409869..3df42855 100644 --- a/src/Twig/Extension/OAuthExtension.php +++ b/src/Twig/Extension/OAuthExtension.php @@ -50,10 +50,6 @@ public function getSocialLinks(string $route = 'members_user_security_oauth_logi $ssoIdentityProviders = $this->getSsoIdentityProvider(); $resourceOwners = $this->oauthRegistry->getEnabledClientKeys(); - if (!is_array($resourceOwners)) { - return []; - } - $data = []; foreach ($resourceOwners as $resourceOwner) { diff --git a/src/Validator/Constraints/PimcoreUniqueEntityValidator.php b/src/Validator/Constraints/PimcoreUniqueEntityValidator.php index 513613d0..11a18fb3 100644 --- a/src/Validator/Constraints/PimcoreUniqueEntityValidator.php +++ b/src/Validator/Constraints/PimcoreUniqueEntityValidator.php @@ -20,10 +20,6 @@ public function validate($entity, Constraint $constraint): void throw new UnexpectedTypeException($constraint, __NAMESPACE__ . '\PimcoreUniqueEntity'); } - if (!is_array($constraint->fields)) { - throw new UnexpectedTypeException($constraint->fields, 'array'); - } - $fields = $constraint->fields; if (count($fields) === 0) {