mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 02:38:50 +02:00
Applied rector suggestions
This commit is contained in:
parent
4106bcef5f
commit
20f32c7f12
170 changed files with 808 additions and 761 deletions
|
@ -30,6 +30,7 @@ use Symfony\Component\Validator\Exception\UnexpectedValueException;
|
|||
|
||||
/**
|
||||
* The validator for the NoneOfItsChildren annotation.
|
||||
* @see \App\Tests\Validator\Constraints\NoneOfItsChildrenValidatorTest
|
||||
*/
|
||||
class NoneOfItsChildrenValidator extends ConstraintValidator
|
||||
{
|
||||
|
|
|
@ -30,6 +30,7 @@ use Symfony\Component\Validator\Exception\UnexpectedValueException;
|
|||
|
||||
/**
|
||||
* The validator for the Selectable constraint.
|
||||
* @see \App\Tests\Validator\Constraints\SelectableValidatorTest
|
||||
*/
|
||||
class SelectableValidator extends ConstraintValidator
|
||||
{
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Validator\Constraints;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
@ -59,4 +61,4 @@ class UniqueObjectCollection extends Constraint
|
|||
throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', get_debug_type($this->normalizer)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Validator\Constraints;
|
||||
|
||||
use App\Validator\UniqueValidatableInterface;
|
||||
|
@ -26,6 +28,9 @@ use Symfony\Component\Validator\ConstraintValidator;
|
|||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedValueException;
|
||||
|
||||
/**
|
||||
* @see \App\Tests\Validator\Constraints\UniqueObjectCollectionValidatorTest
|
||||
*/
|
||||
class UniqueObjectCollectionValidator extends ConstraintValidator
|
||||
{
|
||||
|
||||
|
@ -106,4 +111,4 @@ class UniqueObjectCollectionValidator extends ConstraintValidator
|
|||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ use function is_object;
|
|||
* The validator for UrlOrBuiltin.
|
||||
* It checks if the value is either a builtin ressource or a valid url.
|
||||
* In both cases it is not checked, if the ressource is really existing.
|
||||
* @see \App\Tests\Validator\Constraints\UrlOrBuiltinValidatorTest
|
||||
*/
|
||||
class UrlOrBuiltinValidator extends UrlValidator
|
||||
{
|
||||
|
|
|
@ -33,6 +33,9 @@ use Symfony\Component\Validator\Exception\UnexpectedValueException;
|
|||
use function is_string;
|
||||
use function strlen;
|
||||
|
||||
/**
|
||||
* @see \App\Tests\Validator\Constraints\ValidGoogleAuthCodeValidatorTest
|
||||
*/
|
||||
class ValidGoogleAuthCodeValidator extends ConstraintValidator
|
||||
{
|
||||
public function __construct(private readonly GoogleAuthenticatorInterface $googleAuthenticator, private readonly Security $security)
|
||||
|
|
|
@ -63,11 +63,11 @@ class ValidPermissionValidator extends ConstraintValidator
|
|||
if ($changed) {
|
||||
//Check if this was called in context of UserController
|
||||
$request = $this->requestStack->getMainRequest();
|
||||
if (!$request) {
|
||||
if ($request === null) {
|
||||
return;
|
||||
}
|
||||
//Determine the controller class (the part before the ::)
|
||||
$controller_class = explode('::', $request->attributes->get('_controller'))[0];
|
||||
$controller_class = explode('::', (string) $request->attributes->get('_controller'))[0];
|
||||
|
||||
if (in_array($controller_class, [UserController::class, GroupController::class], true)) {
|
||||
/** @var Session $session */
|
||||
|
|
|
@ -26,6 +26,9 @@ use Symfony\Component\Validator\Constraint;
|
|||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
|
||||
/**
|
||||
* @see \App\Tests\Validator\Constraints\ValidThemeValidatorTest
|
||||
*/
|
||||
class ValidThemeValidator extends ConstraintValidator
|
||||
{
|
||||
public function __construct(private readonly array $available_themes)
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Validator;
|
||||
|
||||
interface UniqueValidatableInterface
|
||||
|
@ -29,4 +31,4 @@ interface UniqueValidatableInterface
|
|||
* @return array An array of the form ['field1' => 'value1', 'field2' => 'value2', ...]
|
||||
*/
|
||||
public function getComparableFields(): array;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue