Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate runtime mutation of validator options #132

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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