Skip to content

Commit

Permalink
Merge pull request #132 from gsteel/validator-update
Browse files Browse the repository at this point in the history
Deprecate runtime mutation of validator options
  • Loading branch information
gsteel authored Jul 15, 2024
2 parents d61fdd8 + 5990e03 commit e1e3126
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 45 deletions.
72 changes: 36 additions & 36 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -484,21 +484,41 @@
</MixedAssignment>
</file>
<file src="src/Validator/Alnum.php">
<DeprecatedMethod>
<code><![CDATA[getAllowWhiteSpace]]></code>
</DeprecatedMethod>
<RedundantCastGivenDocblockType>
<code><![CDATA[(bool) $allowWhiteSpace]]></code>
<code><![CDATA[(bool) $allowWhiteSpace]]></code>
</RedundantCastGivenDocblockType>
</file>
<file src="src/Validator/Alpha.php">
<DeprecatedMethod>
<code><![CDATA[getAllowWhiteSpace]]></code>
</DeprecatedMethod>
<InvalidClassConstantType>
<code><![CDATA[INVALID]]></code>
<code><![CDATA[STRING_EMPTY]]></code>
</InvalidClassConstantType>
<InvalidExtendClass>
<code><![CDATA[Alnum]]></code>
</InvalidExtendClass>
<MethodSignatureMismatch>
<code><![CDATA[public function isValid($value)]]></code>
</MethodSignatureMismatch>
<NonInvariantDocblockPropertyType>
<code><![CDATA[$filter]]></code>
</NonInvariantDocblockPropertyType>
</file>
<file src="src/Validator/DateTime.php">
<DeprecatedMethod>
<code><![CDATA[getDateType]]></code>
<code><![CDATA[getLocale]]></code>
<code><![CDATA[getTimeType]]></code>
<code><![CDATA[setCalendar]]></code>
<code><![CDATA[setPattern]]></code>
<code><![CDATA[setTimezone]]></code>
</DeprecatedMethod>
<DocblockTypeContradiction>
<code><![CDATA[is_string($value)]]></code>
</DocblockTypeContradiction>
Expand All @@ -517,11 +537,21 @@
</PossiblyUnusedMethod>
</file>
<file src="src/Validator/IsFloat.php">
<DeprecatedMethod>
<code><![CDATA[getLocale]]></code>
<code><![CDATA[getLocale]]></code>
<code><![CDATA[setLocale]]></code>
</DeprecatedMethod>
<MixedArgument>
<code><![CDATA[$options['locale']]]></code>
</MixedArgument>
</file>
<file src="src/Validator/IsInt.php">
<DeprecatedMethod>
<code><![CDATA[getLocale]]></code>
<code><![CDATA[setLocale]]></code>
<code><![CDATA[setStrict]]></code>
</DeprecatedMethod>
<DocblockTypeContradiction>
<code><![CDATA[is_bool($strict)]]></code>
</DocblockTypeContradiction>
Expand Down Expand Up @@ -563,7 +593,13 @@
</file>
<file src="src/Validator/PostCode.php">
<DeprecatedMethod>
<code><![CDATA[getFormat]]></code>
<code><![CDATA[getLocale]]></code>
<code><![CDATA[getService]]></code>
<code><![CDATA[setFormat]]></code>
<code><![CDATA[setLocale]]></code>
<code><![CDATA[setLocale]]></code>
<code><![CDATA[setOptions]]></code>
<code><![CDATA[setService]]></code>
</DeprecatedMethod>
<MixedArgument>
Expand Down
9 changes: 7 additions & 2 deletions src/Validator/Alnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use function is_scalar;
use function is_string;

/** @final */
class Alnum extends AbstractValidator
{
public const INVALID = 'alnumInvalid';
Expand All @@ -28,7 +29,7 @@ class Alnum extends AbstractValidator
/**
* Validation failure message template definitions
*
* @var string[]
* @var array<string, string>
*/
protected $messageTemplates = [
self::INVALID => 'Invalid type given. String, integer or float expected',
Expand Down Expand Up @@ -63,6 +64,8 @@ public function __construct($allowWhiteSpace = false)
/**
* Returns the allowWhiteSpace option
*
* @deprecated Since 2.28.0 - This method will be removed in 3.0
*
* @return bool
*/
public function getAllowWhiteSpace()
Expand All @@ -73,7 +76,9 @@ public function getAllowWhiteSpace()
/**
* Sets the allowWhiteSpace option
*
* @param bool $allowWhiteSpace
* @deprecated Since 2.28.0 - This method will be removed in 3.0. Provide options to the constructor instead.
*
* @param bool $allowWhiteSpace
* @return $this
*/
public function setAllowWhiteSpace($allowWhiteSpace)
Expand Down
3 changes: 2 additions & 1 deletion src/Validator/Alpha.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use function is_string;

/** @final */
class Alpha extends Alnum
{
public const INVALID = 'alphaInvalid';
Expand All @@ -22,7 +23,7 @@ class Alpha extends Alnum
/**
* Validation failure message template definitions
*
* @var string[]
* @var array<string, string>
*/
protected $messageTemplates = [
self::INVALID => 'Invalid type given. String expected',
Expand Down
Loading

0 comments on commit e1e3126

Please sign in to comment.