Skip to content

Commit

Permalink
update dev dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikzogg committed Oct 3, 2021
1 parent 4baf80e commit 58eed4d
Show file tree
Hide file tree
Showing 64 changed files with 187 additions and 195 deletions.
11 changes: 9 additions & 2 deletions .php_cs → .php-cs-fixer.php
Expand Up @@ -12,9 +12,16 @@
/** @var array $config */
$config = require __DIR__ . '/vendor/chubbyphp/chubbyphp-dev-helper/phpcs.php';

unset ($config['rules']['final_class']);
unset($config['rules']['final_class']);

return PhpCsFixer\Config::create()
$config['rules']['final_public_method_for_abstract_class'] = false;

// drop onces code is >= 8.0
unset($config['rules']['phpdoc_to_return_type']);

$config['rules']['phpdoc_to_param_type'] = false;

return (new PhpCsFixer\Config)
->setIndent($config['indent'])
->setLineEnding($config['lineEnding'])
->setRules($config['rules'])
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Expand Up @@ -21,12 +21,12 @@
"chubbyphp/chubbyphp-laminas-config-factory": "^1.0",
"chubbyphp/chubbyphp-mock": "^1.6",
"doctrine/persistence": "^1.3|^2.0",
"infection/infection": "^0.20.2",
"infection/infection": "^0.25.2",
"php-coveralls/php-coveralls": "^2.4.3",
"phploc/phploc": "^7.0.2",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^0.12.64",
"phpunit/phpunit": "^9.5",
"phpstan/phpstan": "^0.12.99",
"phpunit/phpunit": "^9.5.10",
"pimple/pimple": "^3.3",
"psr/container": "^1.0|^2.0",
"symfony/validator": "^3.4|^4.2|^5.0"
Expand Down
6 changes: 6 additions & 0 deletions phpstan.neon
Expand Up @@ -6,3 +6,9 @@ parameters:
-
message: '/PHPDoc tag @var for variable \$parentReflectionClass contains generic class ReflectionClass but does not specify its types\: T/'
path: %currentWorkingDirectory%/src/Mapping/ValidationMappingProviderRegistry.php
-
message: '/Method Chubbyphp\\Validation\\Constraint\\Symfony\\ExecutionContext\:\:getObject\(\) should return object\|null but return statement is missing\./'
path: %currentWorkingDirectory%/src/Constraint/Symfony/ExecutionContext.php
-
message: '/Method Chubbyphp\\Validation\\Constraint\\Symfony\\ExecutionContext\:\:getClassName\(\) should return string\|null but return statement is missing\./'
path: %currentWorkingDirectory%/src/Constraint/Symfony/ExecutionContext.php
15 changes: 8 additions & 7 deletions phpunit.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
Expand All @@ -8,7 +9,12 @@
executionOrder="random"
processIsolation="false"
stopOnFailure="false"
>
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Integration">
<directory>./tests/Integration</directory>
Expand All @@ -17,9 +23,4 @@
<directory>./tests/Unit</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src</directory>
</whitelist>
</filter>
</phpunit>
4 changes: 1 addition & 3 deletions src/Accessor/AccessorInterface.php
Expand Up @@ -9,11 +9,9 @@
interface AccessorInterface
{
/**
* @param object $object
*
* @throws ValidatorLogicException
*
* @return mixed
*/
public function getValue($object);
public function getValue(object $object);
}
7 changes: 3 additions & 4 deletions src/Accessor/MethodAccessor.php
Expand Up @@ -16,13 +16,11 @@ public function __construct(string $property)
}

/**
* @param object $object
*
* @throws ValidatorLogicException
*
* @return mixed
*/
public function getValue($object)
public function getValue(object $object)
{
$getMethodName = 'get'.ucfirst($this->property);
$hasMethodName = 'has'.ucfirst($this->property);
Expand All @@ -41,7 +39,8 @@ public function getValue($object)
}

throw ValidatorLogicException::createMissingMethod(
get_class($object), [$getMethodName, $hasMethodName, $isMethodName]
\get_class($object),
[$getMethodName, $hasMethodName, $isMethodName]
);
}
}
11 changes: 3 additions & 8 deletions src/Accessor/PropertyAccessor.php
Expand Up @@ -17,11 +17,9 @@ public function __construct(string $property)
}

/**
* @param object $object
*
* @return mixed
*/
public function getValue($object)
public function getValue(object $object)
{
$class = $this->getClass($object);

Expand All @@ -38,10 +36,7 @@ public function getValue($object)
return $getter($this->property);
}

/**
* @param object $object
*/
private function getClass($object): string
private function getClass(object $object): string
{
if (interface_exists('Doctrine\Persistence\Proxy') && $object instanceof Proxy) {
if (!$object->__isInitialized()) {
Expand All @@ -54,6 +49,6 @@ private function getClass($object): string
}
}

return get_class($object);
return \get_class($object);
}
}
4 changes: 2 additions & 2 deletions src/Constraint/AllConstraint.php
Expand Up @@ -45,11 +45,11 @@ public function validate(
return [];
}

if (!is_array($value) && !$value instanceof \Traversable) {
if (!\is_array($value) && !$value instanceof \Traversable) {
return [new Error(
$path.'[_all]',
'constraint.all.invalidtype',
['type' => is_object($value) ? get_class($value) : gettype($value)]
['type' => \is_object($value) ? \get_class($value) : \gettype($value)]
)];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Constraint/ChoiceConstraint.php
Expand Up @@ -39,7 +39,7 @@ public function validate(
return [];
}

if (!in_array($value, $this->choices, true)) {
if (!\in_array($value, $this->choices, true)) {
return [
new Error(
$path,
Expand Down
4 changes: 2 additions & 2 deletions src/Constraint/CoordinateArrayConstraint.php
Expand Up @@ -26,11 +26,11 @@ public function validate(
return [];
}

if (!is_array($value)) {
if (!\is_array($value)) {
return [new Error(
$path,
'constraint.coordinatearray.invalidtype',
['type' => is_object($value) ? get_class($value) : gettype($value)]
['type' => \is_object($value) ? \get_class($value) : \gettype($value)]
)];
}

Expand Down
4 changes: 2 additions & 2 deletions src/Constraint/CoordinateConstraint.php
Expand Up @@ -28,11 +28,11 @@ public function validate(
return [];
}

if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
return [new Error(
$path,
'constraint.coordinate.invalidtype',
['type' => is_object($value) ? get_class($value) : gettype($value)]
['type' => \is_object($value) ? \get_class($value) : \gettype($value)]
)];
}

Expand Down
6 changes: 3 additions & 3 deletions src/Constraint/CountConstraint.php
Expand Up @@ -36,15 +36,15 @@ public function validate(
return [];
}

if (!is_array($value) && !$value instanceof \Countable) {
if (!\is_array($value) && !$value instanceof \Countable) {
return [new Error(
$path,
'constraint.count.invalidtype',
['type' => is_object($value) ? get_class($value) : gettype($value)]
['type' => \is_object($value) ? \get_class($value) : \gettype($value)]
)];
}

$count = count($value);
$count = \count($value);

if (null !== $this->min && $count < $this->min || null !== $this->max && $count > $this->max) {
return [
Expand Down
10 changes: 5 additions & 5 deletions src/Constraint/DateTimeConstraint.php
Expand Up @@ -37,19 +37,19 @@ public function validate(
return $this->validateDateTime($path, $value);
}

if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
return [new Error(
$path,
'constraint.datetime.invalidtype',
['type' => is_object($value) ? get_class($value) : gettype($value)]
['type' => \is_object($value) ? \get_class($value) : \gettype($value)]
)];
}

$value = trim((string) $value);

\DateTime::createFromFormat('!'.$this->format, $value);
\DateTimeImmutable::createFromFormat('!'.$this->format, $value);

$dateTimeErrors = \DateTime::getLastErrors();
$dateTimeErrors = \DateTimeImmutable::getLastErrors();

return [...$this->errorsByDateTimeLastErrors(
$path,
Expand All @@ -72,7 +72,7 @@ public function validate(
private function validateDateTime(string $path, \DateTimeInterface $value): array
{
/** @var \DateTime $expectedValue */
$expectedValue = \DateTime::createFromFormat(
$expectedValue = \DateTimeImmutable::createFromFormat(
'!'.$this->format,
$value->format($this->format),
$value->getTimezone()
Expand Down
2 changes: 1 addition & 1 deletion src/Constraint/Doctrine/UniqueConstraint.php
Expand Up @@ -47,7 +47,7 @@ public function validate(

$criteria = $this->getCriteria($model);

$modelClass = get_class($model);
$modelClass = \get_class($model);

if (null === $persistedModel = $this->objectManager->getRepository($modelClass)->findOneBy($criteria)) {
return [];
Expand Down
4 changes: 2 additions & 2 deletions src/Constraint/EmailConstraint.php
Expand Up @@ -31,11 +31,11 @@ public function validate(
return [];
}

if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
return [new Error(
$path,
'constraint.email.invalidtype',
['type' => is_object($value) ? get_class($value) : gettype($value)]
['type' => \is_object($value) ? \get_class($value) : \gettype($value)]
)];
}

Expand Down
6 changes: 3 additions & 3 deletions src/Constraint/MapConstraint.php
Expand Up @@ -18,7 +18,7 @@ final class MapConstraint implements ConstraintInterface
private array $constraintsByFields;

/**
* @param array<string, ConstraintInterface|array<ConstraintInterface>> $constraintsByFields
* @param array<string, array<ConstraintInterface>|ConstraintInterface> $constraintsByFields
*/
public function __construct(array $constraintsByFields = [])
{
Expand Down Expand Up @@ -58,11 +58,11 @@ public function validate(
return [];
}

if (!is_array($value) && !$value instanceof \Traversable) {
if (!\is_array($value) && !$value instanceof \Traversable) {
return [new Error(
$path,
'constraint.map.invalidtype',
['type' => is_object($value) ? get_class($value) : gettype($value)]
['type' => \is_object($value) ? \get_class($value) : \gettype($value)]
)];
}

Expand Down
4 changes: 2 additions & 2 deletions src/Constraint/NumericConstraint.php
Expand Up @@ -26,11 +26,11 @@ public function validate(
return [];
}

if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
return [new Error(
$path,
'constraint.numeric.invalidtype',
['type' => is_object($value) ? get_class($value) : gettype($value)]
['type' => \is_object($value) ? \get_class($value) : \gettype($value)]
)];
}

Expand Down
12 changes: 6 additions & 6 deletions src/Constraint/SortConstraint.php
Expand Up @@ -40,11 +40,11 @@ public function validate(
ValidatorContextInterface $context,
?ValidatorInterface $validator = null
): array {
if (!is_array($sort)) {
if (!\is_array($sort)) {
return [new Error(
$path,
'constraint.sort.invalidtype',
['type' => is_object($sort) ? get_class($sort) : gettype($sort)]
['type' => \is_object($sort) ? \get_class($sort) : \gettype($sort)]
)];
}

Expand All @@ -66,25 +66,25 @@ private function validateFieldAndOrder(string $path, string $field, $order): arr
{
$errors = [];

if (!in_array($field, $this->allowedFields, true)) {
if (!\in_array($field, $this->allowedFields, true)) {
$errors[] = new Error(
$path.'.'.$field,
'constraint.sort.field.notallowed',
['field' => $field, 'allowedFields' => $this->allowedFields]
);
}

if (!is_string($order)) {
if (!\is_string($order)) {
$errors[] = new Error(
$path.'.'.$field,
'constraint.sort.order.invalidtype',
['field' => $field, 'type' => is_object($order) ? get_class($order) : gettype($order)]
['field' => $field, 'type' => \is_object($order) ? \get_class($order) : \gettype($order)]
);

return $errors;
}

if (!in_array($order, self::ALLOWED_ORDERS, true)) {
if (!\in_array($order, self::ALLOWED_ORDERS, true)) {
$errors[] = new Error(
$path.'.'.$field,
'constraint.sort.order.notallowed',
Expand Down
4 changes: 2 additions & 2 deletions src/Constraint/Symfony/ConstraintViolationBuilder.php
Expand Up @@ -14,7 +14,7 @@ final class ConstraintViolationBuilder implements ConstraintViolationBuilderInte
/**
* @var ConstraintViolationListInterface<int, ConstraintViolationInterface>
*/
private $violations;
private ConstraintViolationListInterface $violations;

private string $path;

Expand Down Expand Up @@ -128,7 +128,7 @@ public function setPlural($number): self
}

/**
* @param string|null $code
* @param null|string $code
*
* @return ConstraintViolationBuilder
*/
Expand Down

0 comments on commit 58eed4d

Please sign in to comment.