diff:
@@ -16,9 +16,7 @@ use PHPUnit\Framework\TestCase;
*/
class DigitsTest extends TestCase
{
- /**
- * @var Digits
- */
+ /** @var Digits */
protected $validator;
protected function setUp() : void
@@ -29,24 +27,30 @@ class DigitsTest extends TestCase
/**
* Ensures that the validator follows expected behavior for basic input values
*
+ * @dataProvider basicDataProvider
* @return void
*/
- public function testExpectedResultsWithBasicInputValues()
+ public function testExpectedResultsWithBasicInputValues(string $input, bool $expected)
{
- $valuesExpected = [
- 'abc123' => false,
- 'abc 123' => false,
- 'abcxyz' => false,
- 'AZ@#4.3' => false,
- '1.23' => false,
- '0x9f' => false,
- '123' => true,
- '09' => true,
- '' => false,
- ];
- foreach ($valuesExpected as $input => $result) {
- $this->assertEquals($result, $this->validator->isValid($input));
+ $this->assertSame($expected, $this->validator->isValid($input));
}
+
+ public function basicDataProvider()
+ {
+ return [
+ // phpcs:disable
+ 'invalid; starts with alphabetic chars' => ['abc123', false],
+ 'invalid; contains alphabetic chars and one whitespace' => ['abc 123', false],
+ 'invalid; contains only alphabetic chars' => ['abcxyz', false],
+ 'invalid; contains alphabetic and special chars' => ['AZ@#4.3', false],
+ 'invalid; is a float' => ['1.23', false],
+ 'invalid; is a hexa notation' => ['0x9f', false],
+ 'invalid; is empty' => ['', false],
+
+ 'valid; is a normal integer' => ['123', true],
+ 'valid; starts with a zero' => ['09', true],
+ // phpcs:enable
+ ];
}
/**

diff:
@@ -21,41 +21,42 @@ class CountTest extends TestCase
/**
* Ensures that the validator follows expected behavior
*
+ * @dataProvider basicDataProvider
+ * @param array|int $options
* @return void
*/
- public function testBasic()
- {
- $valuesExpected = [
- [5, true, true, true, true],
- [['min' => 0, 'max' => 3], true, true, true, false],
- [['min' => 2, 'max' => 3], false, true, true, false],
- [['min' => 2], false, true, true, true],
- [['max' => 5], true, true, true, true],
- ];
-
- foreach ($valuesExpected as $element) {
- $validator = new File\Count($element[0]);
- $this->assertEquals(
- $element[1],
- $validator->isValid(__DIR__ . '/_files/testsize.mo'),
- 'Tested with ' . var_export($element, 1)
+ public function testBasic($options, bool $expected1, bool $expected2, bool $expected3, bool $expected4)
+ {
+ $validator = new File\Count($options);
+ $this->assertSame(
+ $expected1,
+ $validator->isValid(__DIR__ . '/_files/testsize.mo')
);
- $this->assertEquals(
- $element[2],
- $validator->isValid(__DIR__ . '/_files/testsize2.mo'),
- 'Tested with ' . var_export($element, 1)
+ $this->assertSame(
+ $expected2,
+ $validator->isValid(__DIR__ . '/_files/testsize2.mo')
);
- $this->assertEquals(
- $element[3],
- $validator->isValid(__DIR__ . '/_files/testsize3.mo'),
- 'Tested with ' . var_export($element, 1)
+ $this->assertSame(
+ $expected3,
+ $validator->isValid(__DIR__ . '/_files/testsize3.mo')
);
- $this->assertEquals(
- $element[4],
- $validator->isValid(__DIR__ . '/_files/testsize4.mo'),
- 'Tested with ' . var_export($element, 1)
+ $this->assertSame(
+ $expected4,
+ $validator->isValid(__DIR__ . '/_files/testsize4.mo')
);
}
+
+ public function basicDataProvider()
+ {
+ return [
+ // phpcs:disable
+ 'no minimum; maximum: 5; integer' => [5, true, true, true, true],
+ 'no minimum; maximum: 5; array' => [['max' => 5], true, true, true, true],
+ 'minimum: 0; maximum: 3' => [['min' => 0, 'max' => 3], true, true, true, false],
+ 'minimum: 2; maximum: 3' => [['min' => 2, 'max' => 3], false, true, true, false],
+ 'minimum: 2; no maximum' => [['min' => 2], false, true, true, true],
+ // phpcs:enable
+ ];
}
/**

diff:
@@ -28,50 +28,58 @@ class FilesSizeTest extends TestCase
/**
* Ensures that the validator follows expected behavior
*
+ * @dataProvider basicDataProvider
+ * @param array|int $options
* @return void
*/
- public function testBasic()
+ public function testBasic($options, bool $expected1, bool $expected2, bool $expected3)
{
- $valuesExpected = [
- [['min' => 0, 'max' => 2000], true, true, false],
- [['min' => 0, 'max' => '2 MB'], true, true, true],
- [['min' => 0, 'max' => '2MB'], true, true, true],
- [['min' => 0, 'max' => '2 MB'], true, true, true],
- [2000, true, true, false],
- [['min' => 0, 'max' => 500], false, false, false],
- [500, false, false, false],
- ];
-
- foreach ($valuesExpected as $element) {
- $validator = new File\FilesSize($element[0]);
- $this->assertEquals(
- $element[1],
- $validator->isValid(__DIR__ . '/_files/testsize.mo'),
- 'Tested with ' . var_export($element, 1)
+ $validator = new File\FilesSize(...$options);
+ $this->assertSame(
+ $expected1,
+ $validator->isValid(__DIR__ . '/_files/testsize.mo')
);
- $this->assertEquals(
- $element[2],
- $validator->isValid(__DIR__ . '/_files/testsize2.mo'),
- 'Tested with ' . var_export($element, 1)
+ $this->assertSame(
+ $expected2,
+ $validator->isValid(__DIR__ . '/_files/testsize2.mo')
);
- $this->assertEquals(
- $element[3],
- $validator->isValid(__DIR__ . '/_files/testsize3.mo'),
- 'Tested with ' . var_export($element, 1)
+ $this->assertSame(
+ $expected3,
+ $validator->isValid(__DIR__ . '/_files/testsize3.mo')
);
}
- $validator = new File\FilesSize(['min' => 0, 'max' => 200]);
- $this->assertEquals(false, $validator->isValid(__DIR__ . '/_files/nofile.mo'));
- $this->assertArrayHasKey('fileFilesSizeNotReadable', $validator->getMessages());
+ public function basicDataProvider()
+ {
+ return [
+ // phpcs:disable
+ 'minimum: 0 byte; maximum: 500 bytes; integer' => [[500], false, false, false],
+ 'minimum: 0 byte; maximum: 500 bytes; array' => [[['min' => 0, 'max' => 500]], false, false, false],
+ 'minimum: 0 byte; maximum: 2000 bytes; integer' => [[2000], true, true, false],
+ 'minimum: 0 byte; maximum: 2000 bytes; array' => [[['min' => 0, 'max' => 2000]], true, true, false],
+ 'minimum: 0 byte; maximum: 500 kilobytes' => [[['min' => 0, 'max' => 500000]], true, true, true],
+ 'minimum: 0 byte; maximum: 2 megabytes; 2 MB' => [[['min' => 0, 'max' => '2 MB']], true, true, true],
+ 'minimum: 0 byte; maximum: 2 megabytes; 2MB' => [[['min' => 0, 'max' => '2MB']], true, true, true],
+ 'minimum: 0 byte; maximum: 2 megabytes; 2 MB' => [[['min' => 0, 'max' => '2 MB']], true, true, true],
+ // phpcs:enable
+ ];
+ }
+ public function testMultipleFiles()
+ {
$validator = new File\FilesSize(['min' => 0, 'max' => 500000]);
$this->assertEquals(true, $validator->isValid([
__DIR__ . '/_files/testsize.mo',
__DIR__ . '/_files/testsize.mo',
__DIR__ . '/_files/testsize2.mo',
]));
- $this->assertEquals(true, $validator->isValid(__DIR__ . '/_files/testsize.mo'));
+ }
+
+ public function testFileDoNotExist()
+ {
+ $validator = new File\FilesSize(['min' => 0, 'max' => 200]);
+ $this->assertEquals(false, $validator->isValid(__DIR__ . '/_files/nofile.mo'));
+ $this->assertArrayHasKey('fileFilesSizeNotReadable', $validator->getMessages());
}
/**

diff:
@@ -19,33 +19,79 @@ class GreaterThanTest extends TestCase
/**
* Ensures that the validator follows expected behavior
*
+ * @dataProvider basicDataProvider
+ * @param int|string $input
* @return void
*/
- public function testBasic()
+ public function testBasic(array $options, $input, bool $expected)
{
- /**
- * The elements of each array are, in order:
- * - minimum
- * - expected validation result
- * - array of test input values
- */
- $valuesExpected = [
- [0, true, [0.01, 1, 100]],
- [0, false, [0, 0.00, -0.01, -1, -100]],
- ['a', true, ['b', 'c', 'd']],
- ['z', false, ['x', 'y', 'z']],
- [['min' => 0, 'inclusive' => true], true, [0, 0.00, 0.01, 1, 100]],
- [['min' => 0, 'inclusive' => true], false, [-0.01, -1, -100]],
- [['min' => 0, 'inclusive' => false], true, [0.01, 1, 100]],
- [['min' => 0, 'inclusive' => false], false, [0, 0.00, -0.01, -1, -100]],
- ];
-
- foreach ($valuesExpected as $element) {
- $validator = new GreaterThan($element[0]);
- foreach ($element[2] as $input) {
- $this->assertEquals($element[1], $validator->isValid($input));
- }
+ $validator = new GreaterThan(...$options);
+ $this->assertSame($expected, $validator->isValid($input));
}
+
+ public function basicDataProvider()
+ {
+ return [
+ // phpcs:disable
+ 'valid; non inclusive; 0 < 0.01' => [[0], 0.01, true],
+ 'valid; non inclusive; 0 < 1' => [[0], 1, true],
+ 'valid; non inclusive; 0 < 100' => [[0], 100, true],
+
+ 'invalid; non inclusive; 0 >= 0' => [[0], 0, false],
+ 'invalid; non inclusive; 0 >= 0.00' => [[0], 0.00, false],
+ 'invalid; non inclusive; 0 >= -0.01' => [[0], -0.01, false],
+ 'invalid; non inclusive; 0 >= -1' => [[0], -1, false],
+ 'invalid; non inclusive; 0 >= -100' => [[0], -100, false],
+
+ 'valid; inclusive; 0 <= 0' => [[0, true], 0, true],
+ 'valid; inclusive; 0 <= 0.00' => [[0, true], 0.00, true],
+ 'valid; inclusive; 0 <= 0.01' => [[0, true], 0.01, true],
+ 'valid; inclusive; 0 <= 1' => [[0, true], 1, true],
+ 'valid; inclusive; 0 <= 100' => [[0, true], 100, true],
+
+ 'invalid; inclusive; 0 >= -0.01' => [[0, true], -0.01, false],
+ 'invalid; inclusive; 0 >= -1' => [[0, true], -1, false],
+ 'invalid; inclusive; 0 >= -100' => [[0, true], -100, false],
+
+ 'valid; non inclusive; a < b' => [['a'], 'b', true],
+ 'valid; non inclusive; a < c' => [['a'], 'c', true],
+ 'valid; non inclusive; a < d' => [['a'], 'd', true],
+
+ 'valid; inclusive; a <= a' => [['a', true], 'a', true],
+ 'valid; inclusive; a <= b' => [['a', true], 'b', true],
+ 'valid; inclusive; a <= c' => [['a', true], 'c', true],
+ 'valid; inclusive; a <= d' => [['a', true], 'd', true],
+
+ 'invalid; non-inclusive; a >= a' => [['a', false], 'a', false],
+
+ 'invalid; non inclusive; z >= x' => [['z'], 'x', false],
+ 'invalid; non inclusive; z >= y' => [['z'], 'y', false],
+ 'invalid; non inclusive; z >= z' => [['z'], 'z', false],
+
+ 'invalid; inclusive; z > x' => [['z', true], 'x', false],
+ 'invalid; inclusive; z > y' => [['z', true], 'y', false],
+
+ 'valid; inclusive; 0 <= 0; array' => [[['min' => 0, 'inclusive' => true]], 0, true],
+ 'valid; inclusive; 0 <= 0.00; array' => [[['min' => 0, 'inclusive' => true]], 0.00, true],
+ 'valid; inclusive; 0 <= 0.01; array' => [[['min' => 0, 'inclusive' => true]], 0.01, true],
+ 'valid; inclusive; 0 <= 1; array' => [[['min' => 0, 'inclusive' => true]], 1, true],
+ 'valid; inclusive; 0 <= 100; array' => [[['min' => 0, 'inclusive' => true]], 100, true],
+
+ 'invalid; inclusive; 0 >= -0.01; array' => [[['min' => 0, 'inclusive' => true]], -0.01, false],
+ 'invalid; inclusive; 0 >= -1; array' => [[['min' => 0, 'inclusive' => true]], -1, false],
+ 'invalid; inclusive; 0 >= -100; array' => [[['min' => 0, 'inclusive' => true]], -100, false],
+
+ 'valid; non inclusive; 0 < 0.01; array' => [[['min' => 0, 'inclusive' => false]], 0.01, true],
+ 'valid; non inclusive; 0 < 1; array' => [[['min' => 0, 'inclusive' => false]], 1, true],
+ 'valid; non inclusive; 0 < 100; array' => [[['min' => 0, 'inclusive' => false]], 100, true],
+
+ 'invalid; non inclusive; 0 >= 0; array' => [[['min' => 0, 'inclusive' => false]], 0, false],
+ 'invalid; non inclusive; 0 >= 0.00; array' => [[['min' => 0, 'inclusive' => false]], 0.00, false],
+ 'invalid; non inclusive; 0 >= -0.01; array' => [[['min' => 0, 'inclusive' => false]], -0.01, false],
+ 'invalid; non inclusive; 0 >= -1; array' => [[['min' => 0, 'inclusive' => false]], -1, false],
+ 'invalid; non inclusive; 0 >= -100; array' => [[['min' => 0, 'inclusive' => false]], -100, false],
+ // phpcs:enable
+ ];
}
/**
@@ -101,32 +147,50 @@ class GreaterThanTest extends TestCase
);
}
- public function testCorrectInclusiveMessageReturn()
+ /**
+ * @dataProvider correctInclusiveMessageDataProvider
+ */
+ public function testCorrectInclusiveMessageReturn(float $input)
{
- $valuesToValidate = [0, 0.5, 5, 10];
-
- foreach ($valuesToValidate as $value) {
$validator = new GreaterThan(10);
- $validator->isValid($value);
+ $validator->isValid($input);
$message = $validator->getMessages();
$this->assertArrayHaskey('notGreaterThan', $message);
$this->assertEquals($message['notGreaterThan'], "The input is not greater than '10'");
}
- }
- public function testCorrectNotInclusiveMessageReturn()
+ public function correctInclusiveMessageDataProvider()
{
- $valuesToValidate = [0, 0.5, 5, 9];
+ return [
+ '0' => [0],
+ '0.5' => [0.5],
+ '5' => [5],
+ '10' => [10],
+ ];
+ }
- foreach ($valuesToValidate as $value) {
+ /**
+ * @dataProvider correctNotInclusiveMessageDataProvider
+ */
+ public function testCorrectNotInclusiveMessageReturn(float $input)
+ {
$validator = new GreaterThan(['min' => 10, 'inclusive' => true]);
- $validator->isValid($value);
+ $validator->isValid($input);
$message = $validator->getMessages();
$this->assertArrayHaskey('notGreaterThanInclusive', $message);
$this->assertEquals($message['notGreaterThanInclusive'], "The input is not greater than or equal to '10'");
}
+
+ public function correctNotInclusiveMessageDataProvider()
+ {
+ return [
+ '0' => [0],
+ '0.5' => [0.5],
+ '5' => [5],
+ '9' => [9],
+ ];
}
public function testConstructorCanAcceptInclusiveFlagAsAnArgument()

diff:
@@ -29,25 +29,31 @@ class HexTest extends TestCase
/**
* Ensures that the validator follows expected behavior
*
+ * @dataProvider basicDataProvider
+ * @param int|string $input
* @return void
*/
- public function testBasic()
+ public function testBasic($input, bool $expected)
{
- $valuesExpected = [
- [1, true],
- [0x1, true],
- [0x123, true],
- ['1', true],
- ['abc123', true],
- ['ABC123', true],
- ['1234567890abcdef', true],
- ['g', false],
- ['1.2', false],
- ];
-
- foreach ($valuesExpected as $element) {
- $this->assertEquals($element[1], $this->validator->isValid($element[0]), $element[0]);
+ $this->assertSame($expected, $this->validator->isValid($input));
}
+
+ public function basicDataProvider()
+ {
+ return [
+ // phpcs:disable
+ 'valid; int; 1' => [1, true],
+ 'valid; hex; 0x1' => [0x1, true],
+ 'valid; hex; 0x123' => [0x123, true],
+ 'valid; string; 1' => ['1', true],
+ 'valid; string; abc123' => ['abc123', true],
+ 'valid; string; ABC123' => ['ABC123', true],
+ 'valid; string; 1234567890abcdef' => ['1234567890abcdef', true],
+
+ 'invalid; string; g' => ['g', false],
+ 'invalid; string; 1.2' => ['1.2', false],
+ // phpcs:enable
+ ];
}
/**

diff:
@@ -19,33 +19,75 @@ class LessThanTest extends TestCase
/**
* Ensures that the validator follows expected behavior
*
+ * @dataProvider basicDataProvider
+ * @param int|string $input
* @return void
*/
- public function testBasic()
+ public function testBasic(array $options, $input, bool $expected)
{
- /**
- * The elements of each array are, in order:
- * - maximum
- * - expected validation result
- * - array of test input values
- */
- $valuesExpected = [
- [100, true, [-1, 0, 0.01, 1, 99.999]],
- [100, false, [100, 100.0, 100.01]],
- ['a', false, ['a', 'b', 'c', 'd']],
- ['z', true, ['x', 'y']],
- [['max' => 100, 'inclusive' => true], true, [-1, 0, 0.01, 1, 99.999, 100, 100.0]],
- [['max' => 100, 'inclusive' => true], false, [100.01]],
- [['max' => 100, 'inclusive' => false], true, [-1, 0, 0.01, 1, 99.999]],
- [['max' => 100, 'inclusive' => false], false, [100, 100.0, 100.01]],
- ];
-
- foreach ($valuesExpected as $element) {
- $validator = new LessThan($element[0]);
- foreach ($element[2] as $input) {
- $this->assertEquals($element[1], $validator->isValid($input));
- }
+ $validator = new LessThan(...$options);
+ $this->assertSame($expected, $validator->isValid($input));
}
+
+ public function basicDataProvider()
+ {
+ return [
+ // phpcs:disable
+ 'valid; non inclusive; 100 > -1' => [[100], -1, true],
+ 'valid; non inclusive; 100 > 0' => [[100], 0, true],
+ 'valid; non inclusive; 100 > 0.01' => [[100], 0.01, true],
+ 'valid; non inclusive; 100 > 1' => [[100], 1, true],
+ 'valid; non inclusive; 100 > 99.999' => [[100], 99.999, true],
+
+ 'invalid; non inclusive; 100 <= 100' => [[100], 100, false],
+ 'invalid; non inclusive; 100 <= 100.0' => [[100], 100.0, false],
+ 'invalid; non inclusive; 100 <= 100.01' => [[100], 100.01, false],
+
+ 'valid; inclusive; 100 >= -1' => [[100, true], -1, true],
+ 'valid; inclusive; 100 >= 0' => [[100, true], 0, true],
+ 'valid; inclusive; 100 >= 0.01' => [[100, true], 0.01, true],
+ 'valid; inclusive; 100 >= 1' => [[100, true], 1, true],
+ 'valid; inclusive; 100 >= 99.999' => [[100, true], 99.999, true],
+ 'valid; inclusive; 100 >= 100' => [[100, true], 100, true],
+ 'valid; inclusive; 100 >= 100.0' => [[100, true], 100.0, true],
+
+ 'invalid; inclusive; 100 < 100.01' => [[100, true], 100.01, false],
+
+ 'invalid; non inclusive; a >= a' => [['a'], 'a', false],
+ 'invalid; non inclusive; a >= b' => [['a'], 'b', false],
+ 'invalid; non inclusive; a >= c' => [['a'], 'c', false],
+ 'invalid; non inclusive; a >= d' => [['a'], 'd', false],
+
+ 'valid; inclusive; a <= a' => [['a', true], 'a', true],
+
+ 'valid; non inclusive; z > x' => [['z'], 'x', true],
+ 'valid; non inclusive; z > y' => [['z'], 'y', true],
+
+ 'valid; inclusive; z >= x' => [['z', true], 'x', true],
+ 'valid; inclusive; z >= y' => [['z', true], 'y', true],
+ 'valid; inclusive; z >= z' => [['z', true], 'z', true],
+
+ 'valid; inclusive; 100 >= -1; array' => [[['max' => 100, 'inclusive' => true]], -1, true],
+ 'valid; inclusive; 100 >= 0; array' => [[['max' => 100, 'inclusive' => true]], 0, true],
+ 'valid; inclusive; 100 >= 0.01; array' => [[['max' => 100, 'inclusive' => true]], 0.01, true],
+ 'valid; inclusive; 100 >= 1; array' => [[['max' => 100, 'inclusive' => true]], 1, true],
+ 'valid; inclusive; 100 >= 99.999; array' => [[['max' => 100, 'inclusive' => true]], 99.999, true],
+ 'valid; inclusive; 100 >= 100; array' => [[['max' => 100, 'inclusive' => true]], 100, true],
+ 'valid; inclusive; 100 >= 100.0; array' => [[['max' => 100, 'inclusive' => true]], 100.0, true],
+
+ 'invalid; inclusive; 100 < 100.01; array' => [[['max' => 100, 'inclusive' => true]], 100.01, false],
+
+ 'valid; non inclusive; 100 > -1; array' => [[['max' => 100, 'inclusive' => false]], -1, true],
+ 'valid; non inclusive; 100 > 0; array' => [[['max' => 100, 'inclusive' => false]], 0, true],
+ 'valid; non inclusive; 100 > 0.01; array' => [[['max' => 100, 'inclusive' => false]], 0.01, true],
+ 'valid; non inclusive; 100 > 1; array' => [[['max' => 100, 'inclusive' => false]], 1, true],
+ 'valid; non inclusive; 100 > 99.999; array' => [[['max' => 100, 'inclusive' => false]], 99.999, true],
+
+ 'invalid; non inclusive; 100 <= 100; array' => [[['max' => 100, 'inclusive' => false]], 100, false],
+ 'invalid; non inclusive; 100 <= 100.0; array' => [[['max' => 100, 'inclusive' => false]], 100.0, false],
+ 'invalid; non inclusive; 100 <= 100.01; array' => [[['max' => 100, 'inclusive' => false]], 100.01, false],
+ // phpcs:enable
+ ];
}
/**

diff:
@@ -21,27 +21,36 @@ class RegexTest extends TestCase
/**
* Ensures that the validator follows expected behavior
*
+ * @dataProvider basicDataProvider
* @return void
*/
- public function testBasic()
+ public function testBasic(array $options, string $input, bool $expected)
{
- /**
- * The elements of each array are, in order:
- * - pattern
- * - expected validation result
- * - array of test input values
- */
- $valuesExpected = [
- ['/[a-z]/', true, ['abc123', 'foo', 'a', 'z']],
- ['/[a-z]/', false, ['123', 'A']],
- ];
-
- foreach ($valuesExpected as $element) {
- $validator = new Regex($element[0]);
- foreach ($element[2] as $input) {
- $this->assertEquals($element[1], $validator->isValid($input));
- }
+ $validator = new Regex(...$options);
+ $this->assertSame($expected, $validator->isValid($input));
}
+
+ public function basicDataProvider()
+ {
+ return [
+ // phpcs:disable
+ 'valid; abc123' => [['/[a-z]/'], 'abc123', true],
+ 'valid; foo' => [['/[a-z]/'], 'foo', true],
+ 'valid; a' => [['/[a-z]/'], 'a', true],
+ 'valid; z' => [['/[a-z]/'], 'z', true],
+
+ 'valid; 123' => [['/[a-z]/'], '123', false],
+ 'valid; A' => [['/[a-z]/'], 'A', false],
+
+ 'valid; abc123; array' => [[['pattern' => '/[a-z]/']], 'abc123', true],
+ 'valid; foo; array' => [[['pattern' => '/[a-z]/']], 'foo', true],
+ 'valid; a; array' => [[['pattern' => '/[a-z]/']], 'a', true],
+ 'valid; z; array' => [[['pattern' => '/[a-z]/']], 'z', true],
+
+ 'valid; 123; array' => [[['pattern' => '/[a-z]/']], '123', false],
+ 'valid; A; array' => [[['pattern' => '/[a-z]/']], 'A', false],
+ // phpcs:enable
+ ];
}
/**

original_message:
qa: Replace array by data providers in unit tests

Signed-off-by: codisart <louis.celier@gmail.com>


change_type: ADD

diff:
+# BIC Validator
+
+`Laminas\Validator\BusinessIdentifierCode` validates if a given value
+**could be a ["Business Identifier Code" (BIC)](https://www.swift.com/standards/data-standards/bic)**
+as defined by [ISO 9362](https://wikipedia.org/wiki/ISO_9362).
+A BIC is a unique identification code for financial and non-financial institutions.
+
+## Supported options
+
+There are no additional supported options for the `BusinessIdentifierCode` validator.
+
+## BIC validation
+
+BICs should be a string which length should be equal to 8 or 11.
+* The 4 first characters can only be letters and it is used to identify a bank or an institution.
+* The following 2 characters can only be letters too and it should be a country code assigned within ISO 3166-1 alpha-2.
+The only exception is the code 'XK' used for the Republic of Kosovo.
+* The following 2 characters can be letters or digits. It is used to represent a location (like a city)
+* The last 3 characters are optional and can be letters or digits. It can represent a branche office. The code 'XXX' is
+often used to represent the ain office when the 11 characters code is used.
+
+## Basic usage
+```php
+$validator = new Laminas\Validator\BusinessIdentifierCode();
+
+if ($validator->isValid('DEUTDEFF')) {
+ // bic appears to be valid
+} else {
+ // bic is invalid; print the reasons
+}
+```

diff:
+<?php
+
+/**
+ * @see https://github.com/laminas/laminas-validator for the canonical source repository
+ * @copyright https://github.com/laminas/laminas-validator/blob/master/COPYRIGHT.md
+ * @license https://github.com/laminas/laminas-validator/blob/master/LICENSE.md New BSD License
+ */
+
+namespace Laminas\Validator;
+
+use Laminas\Stdlib\ArrayUtils;
+use Traversable;
+
+class BusinessIdentifierCode extends AbstractValidator
+{
+ public const INVALID = 'valueNotBic';
+ public const NOT_STRING = 'valueNotString';
+ public const NOT_VALID_COUNTRY = 'valueNotCountry';
+
+ /**
+ * @var string[]
+ */
+ protected $messageTemplates = [
+ self::NOT_STRING => 'Invalid type given; string expected',
+ self::INVALID => 'Invalid BIC format',
+ self::NOT_VALID_COUNTRY => 'Invalid country code',
+ ];
+
+ private const REGEX_BIC = '/^[a-z]{4}(?<country>[a-z]{2})[0-9a-z]{2}([0-9a-z]{3})?$/i';
+
+ /**
+ * List of all country codes defined by ISO 3166-1 alpha-2
+ * @see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Current_codes
+ *
+ * @var array<ISO 3166-1 alpha-2>
+ */
+ private const ISO_COUNTRIES = [
+ 'AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AO', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB',
+ 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BQ', 'BR', 'BS', 'BT', 'BV', 'BW',
+ 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW',
+ 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ',
+ 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GG', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR',
+ 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IO', 'IQ',
+ 'IR', 'IS', 'IT', 'JE', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW', 'KY', 'KZ',
+ 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH',
+ 'MK', 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC',
+ 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL',
+ 'PM', 'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE',
+ 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'SS', 'ST', 'SV', 'SX', 'SY', 'SZ', 'TC', 'TD',
+ 'TF', 'TG', 'TH', 'TJ', 'TK', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'UM', 'US',
+ 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', 'VI', 'VN', 'VU', 'WF', 'WS', 'YE', 'YT', 'ZA', 'ZM', 'ZW',
+ ];
+
+ /**
+ * This code is the only one used by SWIFT that is not defined by ISO 3166-1 alpha-2
+ * @see https://en.wikipedia.org/wiki/ISO_9362
+ *
+ * @var string
+ */
+ private const KOSOVO_EXCEPTION = 'XK';
+
+ /**
+ * @inheritDoc
+ */
+ public function isValid($value) : bool
+ {
+ if (! is_string($value)) {
+ $this->error(self::NOT_STRING);
+ return false;
+ }
+
+ if (empty($value)
+ || ! preg_match(self::REGEX_BIC, $value, $matches)
+ ) {
+ $this->error(self::INVALID);
+ return false;
+ }
+
+ if (! $this->isSwiftValidCountry($matches['country'])) {
+ $this->error(self::NOT_VALID_COUNTRY);
+ return false;
+ }
+
+ return true;
+ }
+
+ private function isSwiftValidCountry(string $countryCode) : bool
+ {
+ $countryCode = strtoupper($countryCode);
+ return in_array($countryCode, self::ISO_COUNTRIES, true)
+ || $countryCode === self::KOSOVO_EXCEPTION;
+ }
+}

diff:
+<?php
+
+/**
+ * @see https://github.com/laminas/laminas-validator for the canonical source repository
+ * @copyright https://github.com/laminas/laminas-validator/blob/master/COPYRIGHT.md
+ * @license https://github.com/laminas/laminas-validator/blob/master/LICENSE.md New BSD License
+ */
+
+namespace LaminasTest\Validator;
+
+use PHPUnit\Framework\TestCase;
+use Laminas\Validator\BusinessIdentifierCode;
+
+class BusinessIdentifierCodeTest extends TestCase
+{
+ public function successProvider() : array
+ {
+ return [
+ // UPPERCASE
+ 'BANQUE ATLANTIQUE COTE D\'IVOIRE, ABIDJAN, Cote d\'Ivoire' => ['ATCICIAB'],
+ 'BANQUE NATIONALE DU CANADA, MONTREAL, Canada' => ['BNDCCAMMINT'],
+ 'BDO UNIBANK, INC., MANILA, Philippines' => ['BNORPHMM'],
+ 'FEDERATION DES CAISSES DESJARDINS DU QUEBEC, LEVIS, Canada' => ['CCDQCAMM'],
+ 'COMMERZBANK AG, FRANKFURT AM MAIN, Germany' => ['COBADEFF'],
+ 'DANSKE BANK A/S, COPENHAGEN, Denmark' => ['DABADKKK'],
+ 'DEUTSCHE BANK AG, FRANKFURT AM MAIN, Germany' => ['DEUTDEFF'],
+ 'DB PRIVAT-UND FIRMENKUNDENBANK, DUSSELDORF, Germany' => ['DEUTDEDBDUE'],
+ 'DAH SING BANK (CHINA) LIMITED, SHANGHAI, China' => ['DSBACNBXSHA'],
+ 'FINANCIERE DES PAIEMENTS ELECTRONIQUES, CHARENTON LE PONT, France' => ['FPELFR21XXX'],
+ 'BNP PARIBAS FORTIS, BRUSSELS, Belgium' => ['GEBABEBB'],
+ 'PROCREDIT BANK SH.A KOSOVO, HEAD QUARTER, PRISTINA, Kosovo' => ['MBKOXKPRXXX'],
+ 'NEDBANK LIMITED, JOHANNESBURG, South Africa' => ['NEDSZAJJ'],
+ 'LA BANQUE POSTALE, MONTPELLIER, France' => ['PSSTFRPPMON'],
+
+ // lowercase
+ 'DEUTSCHE BANK AG, BAD HOMBURG, Germany' => ['deutdeff500'],
+ 'NEDBANK LIMITED, JOHANNESBURG, South Africa (primary office)' => ['nedszajjxxx'],
+ 'LA BANQUE POSTALE, NANTES, France' => ['psstfrppnte'],
+ 'UNICREDIT S.P.A., MILANO, Italy' => ['uncritmm'],
+ ];
+ }
+
+ /**
+ * @dataProvider successProvider
+ */
+ public function testValidateSuccess(string $code)
+ {
+ $validator = new BusinessIdentifierCode();
+ self::assertTrue($validator->isValid($code));
+ }
+
+ public function notAStringProvider() : array
+ {
+ return [
+ 'number' => [123],
+ 'array' => [['DEUTDEFF']],
+ 'object' => [new \stdClass()],
+ ];
+ }
+
+ /**
+ * @dataProvider notAStringProvider
+ */
+ public function testNotAStringFailure($code)
+ {
+ $validator = new BusinessIdentifierCode();
+ self::assertFalse($validator->isValid($code));
+ self::assertCount(1, $validator->getMessages());
+ self::assertSame(
+ 'Invalid type given; string expected',
+ $validator->getMessages()[BusinessIdentifierCode::NOT_STRING]
+ );
+ }
+
+ public function notBicFormatProvider() : array
+ {
+ return [
+ 'too short' => ['SHORT'],
+ 'too long' => ['SOLOOOOOOOOOOOOOOOOOOONG'],
+ 'use numbers for country code' => ['DEUT12AA'],
+ ];
+ }
+
+ /**
+ * @dataProvider notBicFormatProvider
+ */
+ public function testNotBicFormatFailure(string $code)
+ {
+ $validator = new BusinessIdentifierCode();
+ self::assertFalse($validator->isValid($code));
+ self::assertCount(1, $validator->getMessages());
+ self::assertSame('Invalid BIC format', $validator->getMessages()[BusinessIdentifierCode::INVALID]);
+ }
+
+ public function notSwiftCountryCodeProvider() : array
+ {
+ return [
+ 'AA is not a assigned code' => ['DEUTAAFF'],
+ 'UK is not the iso code for the united kingdom' => ['ABCDUKFF'],
+ ];
+ }
+
+ /**
+ * @dataProvider notSwiftCountryCodeProvider
+ */
+ public function testNotSwiftCountryCodeFailure(string $code)
+ {
+ $validator = new BusinessIdentifierCode();
+ self::assertFalse($validator->isValid($code));
+ self::assertCount(1, $validator->getMessages());
+ self::assertSame('Invalid country code', $validator->getMessages()[BusinessIdentifierCode::NOT_VALID_COUNTRY]);
+ }
+}

license: BSD 3-Clause New or Revised License

repo: laminas/laminas-validator

original_message:
feat: Add the support for SWIFT Business Identifier Code (BIC) format

Signed-off-by: codisart <louis.celier@gmail.com>


message: Move suppression to offending method

change_type: MODIFY

diff:
@@ -8,9 +8,6 @@ use stdClass;
use function current;
-/**
- * @psalm-suppress UnevaluatedCode
- */
class LocTest extends TestCase
{
/** @var Loc */
@@ -60,6 +57,7 @@ class LocTest extends TestCase
*
* @todo A change in the URI API has led to most of these now validating
* @dataProvider invalidLocs
+ * @psalm-suppress UnevaluatedCode
*/
public function testInvalidLocs(string $url): void
{

original_message:
Move suppression to offending method

Signed-off-by: George Steel <george@net-glue.co.uk>


diff:
@@ -8,7 +8,6 @@ use Traversable;
use function array_key_exists;
use function array_keys;
use function array_unique;
-use function assert;
use function current;
use function get_class;
use function implode;
@@ -377,8 +376,6 @@ abstract class AbstractValidator implements
$messageKey = current($keys);
}
- assert(is_string($messageKey));
-
if ($value === null) {
/** @psalm-var string|array|object $value */
$value = $this->value;

original_message:
Drop the added assertion that affects the mime-type test

Signed-off-by: George Steel <george@net-glue.co.uk>


diff:
"require": {
"php": "^7.3 || ~8.0.0 || ~8.1.0",
"container-interop/container-interop": "^1.1",
- "laminas/laminas-stdlib": "^3.6"
+ "laminas/laminas-stdlib": "^3.10"
},
"require-dev": {
"laminas/laminas-cache": "^2.6.1",

diff:
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "0ab16e4f22b3ddb83ac4802a1f9b03ea",
+ "content-hash": "9cfab05d9913bbc9e4ac25184c989da7",
"packages": [
{
"name": "container-interop/container-interop",
},
{
"name": "laminas/laminas-stdlib",
- "version": "3.9.1",
+ "version": "3.10.0",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-stdlib.git",
- "reference": "1df1cc0b9c2b8c7d1e322da1669a576386b5da46"
+ "reference": "449c0405e182bfe77702604a474668fbb63e9907"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/1df1cc0b9c2b8c7d1e322da1669a576386b5da46",
- "reference": "1df1cc0b9c2b8c7d1e322da1669a576386b5da46",
+ "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/449c0405e182bfe77702604a474668fbb63e9907",
+ "reference": "449c0405e182bfe77702604a474668fbb63e9907",
"shasum": ""
},
"require": {
"type": "community_bridge"
}
],
- "time": "2022-06-08T11:33:13+00:00"
+ "time": "2022-06-09T08:43:49+00:00"
},
{
"name": "psr/container",

diff:
<MixedReturnStatement occurrences="1">
$this->options['inclusive']
</MixedReturnStatement>
- <PossiblyInvalidArgument occurrences="1">
- $options
- </PossiblyInvalidArgument>
</file>
<file src="src/Bitwise.php">
<DocblockTypeContradiction occurrences="4">

diff:
@@ -96,7 +96,6 @@ abstract class AbstractValidator implements
{
// The abstract constructor allows no scalar values
if ($options instanceof Traversable) {
- /** @psalm-var array<string, mixed> $options */
$options = ArrayUtils::iteratorToArray($options);
}

original_message:
Update stdlib to 3.10 and remove unnecessary annotation

Signed-off-by: George Steel <george@net-glue.co.uk>


message:
Re-organize dot-files
Rename Psr\Container stub to avoid detection as a duplicate interface
Update export-ignores in .gitattributes to avoid shipping unnecessary files
Remove coveralls badge and assets as they are no longer in use

change_type: DELETE

diff:
-coverage_clover: clover.xml
-json_path: coveralls-upload.json

old_path: .gitattributes

new_path: .gitattributes

diff:
-/.coveralls.yml export-ignore
-/.gitattributes export-ignore
/.github/ export-ignore
-/.gitignore export-ignore
/docs/ export-ignore
+/test/ export-ignore
+/.gitattributes export-ignore
+/.gitignore export-ignore
+/.laminas-ci.json export-ignore
+/.psr-container.php.stub export-ignore
/mkdocs.yml export-ignore
-/phpcs.xml export-ignore
+/phpcs.xml.dist export-ignore
/phpunit.xml.dist export-ignore
-/test/ export-ignore
+/psalm-baseline.xml export-ignore
+/psalm.xml.dist export-ignore

old_path: .gitignore

new_path: .gitignore

diff:
/.phpcs-cache
/.phpunit.result.cache
/clover.xml
-/coveralls-upload.json
/docs/html/
/laminas-mkdoc-theme.tgz
/laminas-mkdoc-theme/

change_type: RENAME

diff:
<?php
-
+/**
+ * File named as .stub to avoid duplicate declaration of the interface in consuming projects
+ */
declare(strict_types=1);
namespace Psr\Container {

diff:
</plugins>
<stubs>
- <file name=".psr-container-stub.php" preloadClasses="true" />
+ <file name=".psr-container.php.stub" preloadClasses="true" />
</stubs>
</psalm>

original_message:
Re-organize dot-files

- Rename Psr\Container stub to avoid detection as a duplicate interface
- Update export-ignores in .gitattributes to avoid shipping unnecessary files
- Remove coveralls badge and assets as they are no longer in use

Signed-off-by: George Steel <george@net-glue.co.uk>


diff:
<MixedPropertyTypeCoercion occurrences="1">
new PriorityQueue()
</MixedPropertyTypeCoercion>
- <RedundantCastGivenDocblockType occurrences="2">
- (bool) $breakChainOnFailure
- (bool) $breakChainOnFailure
- </RedundantCastGivenDocblockType>
<TooManyArguments occurrences="1">
isValid
</TooManyArguments>

diff:
@@ -92,9 +92,13 @@ class ValidatorChain implements
/**
* Retrieve a validator by name
*
- * @param string $name Name of validator to return
- * @param null|array $options Options to pass to validator constructor (if not already instantiated)
+ * @param string|class-string<ValidatorInterface> $name Name of validator to return
+ * @param null|array $options Options to pass to validator constructor
+ * (if not already instantiated)
* @return ValidatorInterface
+ * @template T of ValidatorInterface
+ * @psalm-param string|class-string<T> $name
+ * @psalm-return ($name is class-string ? T : ValidatorInterface)
*/
public function plugin($name, ?array $options = null)
{
@@ -118,6 +122,7 @@ class ValidatorChain implements
$breakChainOnFailure = false,
$priority = self::DEFAULT_PRIORITY
) {
+ /** @psalm-suppress RedundantCastGivenDocblockType */
$this->validators->insert(
[
'instance' => $validator,
@@ -165,6 +170,7 @@ class ValidatorChain implements
$priority = $extractedNodes[0] + 1;
}
+ /** @psalm-suppress RedundantCastGivenDocblockType */
$this->validators->insert(
[
'instance' => $validator,
@@ -178,7 +184,7 @@ class ValidatorChain implements
/**
* Use the plugin manager to add a validator by name
*
- * @param string $name
+ * @param string|class-string<ValidatorInterface> $name
* @param array $options
* @param bool $breakChainOnFailure
* @param int $priority
@@ -217,7 +223,7 @@ class ValidatorChain implements
/**
* Use the plugin manager to prepend a validator by name
*
- * @param string $name
+ * @param string|class-string<ValidatorInterface> $name
* @param array $options
* @param bool $breakChainOnFailure
* @return $this

original_message:
Adds type inference for `plugin()` when given a class-string

Signed-off-by: George Steel <george@net-glue.co.uk>


diff:
},
"require": {
"php": "^7.4 || ~8.0.0 || ~8.1.0",
- "container-interop/container-interop": "^1.1",
+ "laminas/laminas-servicemanager": "^3.12.0",
"laminas/laminas-stdlib": "^3.10"
},
"require-dev": {
"laminas/laminas-http": "^2.14.2",
"laminas/laminas-i18n": "^2.15.0",
"laminas/laminas-math": "^2.7.1",
- "laminas/laminas-servicemanager": "^3.12.0",
"laminas/laminas-session": "^2.12.1",
"laminas/laminas-uri": "^2.9.1",
"phpspec/prophecy-phpunit": "^2.0",

diff:
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "9c648cb7391ef85eac6ec4b3dfc37651",
+ "content-hash": "0eb1f1c3bae821da3c13e1e504414c93",
"packages": [
{
"name": "laminas/laminas-servicemanager",

diff:
<MixedAssignment occurrences="1">
$validator
</MixedAssignment>
- <MixedMethodCall occurrences="5">
- get
- get
+ <MixedMethodCall occurrences="1">
getValidatorPluginManager
- setInvokableClass
- setService
</MixedMethodCall>
- <UndefinedThisPropertyAssignment occurrences="1">
- $this->validators
- </UndefinedThisPropertyAssignment>
- <UndefinedThisPropertyFetch occurrences="3">
- $this->validators
- $this->validators
- $this->validators
- </UndefinedThisPropertyFetch>
</file>
<file src="test/_files/MyBarcode1.php">
<UndefinedFunction occurrences="1">

diff:
namespace Laminas\Validator;
-use Interop\Container\ContainerInterface; // phpcs:ignore
use Laminas\I18n\Validator as I18nValidator;
use Laminas\ServiceManager\AbstractPluginManager;
use Laminas\ServiceManager\ConfigInterface;
use Laminas\ServiceManager\Exception\InvalidServiceException;
use Laminas\ServiceManager\Factory\InvokableFactory;
use Laminas\ServiceManager\ServiceManager;
+use Psr\Container\ContainerInterface;
use Zend\I18n\Validator\Alnum;
use Zend\I18n\Validator\Alpha;
use Zend\I18n\Validator\DateTime;

diff:
namespace Laminas\Validator;
-use Interop\Container\ContainerInterface; // phpcs:ignore
use Laminas\ServiceManager\Config;
use Laminas\ServiceManager\FactoryInterface;
use Laminas\ServiceManager\ServiceLocatorInterface;
use Laminas\ServiceManager\ServiceManager;
+use Psr\Container\ContainerInterface;
use function is_array;

diff:
namespace LaminasTest\Validator;
-use Interop\Container\ContainerInterface; // phpcs:ignore
use Laminas\ServiceManager\ServiceLocatorInterface;
use Laminas\Validator\Digits;
use Laminas\Validator\ValidatorInterface;
@@ -10,6 +9,7 @@ use Laminas\Validator\ValidatorPluginManager;
use Laminas\Validator\ValidatorPluginManagerFactory;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
+use Psr\Container\ContainerInterface;
class ValidatorPluginManagerFactoryTest extends TestCase
{

diff:
namespace LaminasTest\Validator;
use Exception;
-use Interop\Container\ContainerInterface; // phpcs:ignore
use Laminas\ServiceManager\Exception\InvalidServiceException;
use Laminas\ServiceManager\ServiceManager;
use Laminas\Validator\AbstractValidator;
@@ -13,6 +12,7 @@ use Laminas\Validator\ValidatorInterface;
use Laminas\Validator\ValidatorPluginManager;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
+use Psr\Container\ContainerInterface;
use function get_class;
use function sprintf;
@@ -24,6 +24,8 @@ class ValidatorPluginManagerTest extends TestCase
{
use ProphecyTrait;
+ private ValidatorPluginManager $validators;
+
protected function setUp(): void
{
$this->validators = new ValidatorPluginManager(new ServiceManager());
@@ -59,6 +61,7 @@ class ValidatorPluginManagerTest extends TestCase
public function testRegisteringInvalidValidatorRaisesException(): void
{
try {
+ /** @psalm-suppress InvalidArgument */
$this->validators->setService('test', $this);
} catch (InvalidServiceException $e) {
$this->assertStringContainsString(ValidatorInterface::class, $e->getMessage());

original_message:
Drop Interop container and move service manager from dev to require

Signed-off-by: George Steel <george@net-glue.co.uk>


message: Fix psalm errors

diff:
$container
</UnusedClosureParam>
</file>
- <file src="test/ValidatorPluginManagerTest.php">
- <MixedAssignment occurrences="1">
- $validator
- </MixedAssignment>
- <MixedMethodCall occurrences="1">
- getValidatorPluginManager
- </MixedMethodCall>
- </file>
<file src="test/_files/MyBarcode1.php">
<UndefinedFunction occurrences="1">
'invalid'

diff:
@@ -7,6 +7,7 @@ use Laminas\ServiceManager\Exception\InvalidServiceException;
use Laminas\ServiceManager\ServiceManager;
use Laminas\Validator\AbstractValidator;
use Laminas\Validator\Exception\RuntimeException;
+use Laminas\Validator\Explode;
use Laminas\Validator\NotEmpty;
use Laminas\Validator\ValidatorInterface;
use Laminas\Validator\ValidatorPluginManager;
@@ -14,6 +15,7 @@ use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Psr\Container\ContainerInterface;
+use function assert;
use function get_class;
use function sprintf;
@@ -94,7 +96,8 @@ class ValidatorPluginManagerTest extends TestCase
public function testInjectedValidatorPluginManager(): void
{
- $validator = $this->validators->get('explode');
+ $validator = $this->validators->get(Explode::class);
+ assert($validator instanceof Explode);
$this->assertSame($this->validators, $validator->getValidatorPluginManager());
}
}

original_message:
Fix psalm errors

Signed-off-by: George Steel <george@net-glue.co.uk>


diff:
"laminas/laminas-filter": "^2.14.0",
"laminas/laminas-http": "^2.14.2",
"laminas/laminas-i18n": "^2.15.0",
- "laminas/laminas-math": "^2.7.1",
"laminas/laminas-session": "^2.12.1",
"laminas/laminas-uri": "^2.9.1",
"phpspec/prophecy-phpunit": "^2.0",
"laminas/laminas-filter": "Laminas\\Filter component, required by the Digits validator",
"laminas/laminas-i18n": "Laminas\\I18n component to allow translation of validation error messages",
"laminas/laminas-i18n-resources": "Translations of validator messages",
- "laminas/laminas-math": "Laminas\\Math component, required by the Csrf validator",
"laminas/laminas-servicemanager": "Laminas\\ServiceManager component to allow using the ValidatorPluginManager and validator chains",
"laminas/laminas-session": "Laminas\\Session component, ^2.8; required by the Csrf validator",
"laminas/laminas-uri": "Laminas\\Uri component, required by the Uri and Sitemap\\Loc validators",

diff:
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "0eb1f1c3bae821da3c13e1e504414c93",
+ "content-hash": "f8bcfbe52ea67b5c0a12788e142c00bf",
"packages": [
{
"name": "laminas/laminas-servicemanager",
],
"time": "2021-09-02T18:30:53+00:00"
},
- {
- "name": "laminas/laminas-math",
- "version": "2.7.1",
- "source": {
- "type": "git",
- "url": "https://github.com/laminas/laminas-math.git",
- "reference": "8027b37e00accc43f28605c7d8fd081baed1f475"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/laminas/laminas-math/zipball/8027b37e00accc43f28605c7d8fd081baed1f475",
- "reference": "8027b37e00accc43f28605c7d8fd081baed1f475",
- "shasum": ""
- },
- "require": {
- "laminas/laminas-zendframework-bridge": "^1.0",
- "php": "^5.5 || ^7.0"
- },
- "replace": {
- "zendframework/zend-math": "self.version"
- },
- "require-dev": {
- "fabpot/php-cs-fixer": "1.7.*",
- "ircmaxell/random-lib": "~1.1",
- "phpunit/phpunit": "~4.0"
- },
- "suggest": {
- "ext-bcmath": "If using the bcmath functionality",
- "ext-gmp": "If using the gmp functionality",
- "ircmaxell/random-lib": "Fallback random byte generator for Laminas\\Math\\Rand if Mcrypt extensions is unavailable"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.7-dev",
- "dev-develop": "2.8-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "Laminas\\Math\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "homepage": "https://laminas.dev",
- "keywords": [
- "laminas",
- "math"
- ],
- "support": {
- "chat": "https://laminas.dev/chat",
- "docs": "https://docs.laminas.dev/laminas-math/",
- "forum": "https://discourse.laminas.dev",
- "issues": "https://github.com/laminas/laminas-math/issues",
- "rss": "https://github.com/laminas/laminas-math/releases.atom",
- "source": "https://github.com/laminas/laminas-math"
- },
- "time": "2019-12-31T17:24:15+00:00"
- },
{
"name": "laminas/laminas-session",
"version": "2.12.1",

diff:
namespace Laminas\Validator;
-use Laminas\Math\Rand;
use Laminas\Session\Container as SessionContainer;
use Laminas\Stdlib\ArrayUtils;
use Traversable;
@@ -11,6 +10,7 @@ use function explode;
use function is_array;
use function is_string;
use function md5;
+use function random_bytes;
use function sprintf;
use function str_replace;
use function strtolower;
@@ -301,7 +301,7 @@ class Csrf extends AbstractValidator
*/
protected function generateHash()
{
- $token = md5($this->getSalt() . Rand::getBytes(32) . $this->getName());
+ $token = md5($this->getSalt() . random_bytes(32) . $this->getName());
$this->hash = $this->formatHash($token, $this->generateTokenId());
@@ -314,7 +314,7 @@ class Csrf extends AbstractValidator
*/
protected function generateTokenId()
{
- return md5(Rand::getBytes(32));
+ return md5(random_bytes(32));
}
/**

original_message:
Removes Dependency on Laminas\Math

Closes #132

Signed-off-by: George Steel <george@net-glue.co.uk>


diff:
@@ -9,17 +9,6 @@ The typical mitigation is to create a one-time token that is transmitted as part
This token expires after first submission or after a short amount of time, preventing replays or further submissions.
If the token provided does not match what was originally sent, an error should be returned.
-<!-- markdownlint-disable-next-line MD001 -->
-> ### Installation Requirements
->
-> The CSRF validator depends on [laminas-math](https://docs.laminas.dev/laminas-math/) to generate the hash and on [laminas-session](https://docs.laminas.dev/laminas-session/) to persist the generated token between requests.
-> Consequently, both components must be installed before the validator can be used.
-> To install both components, run the following command.
->
-> ```bash
-> composer require laminas/laminas-math laminas/laminas-session
-> ```
-
## Supported Options
The following options are supported for `Laminas\Validator\Csrf`.

original_message:
Remove documented requirement for `Laminas\Math`

Signed-off-by: George Steel <george@net-glue.co.uk>


diff:
<?xml version="1.0" encoding="UTF-8"?>
-<files psalm-version="4.23.0@f1fe6ff483bf325c803df9f510d09a03fd796f88">
+<files psalm-version="4.24.0@06dd975cb55d36af80f242561738f16c5f58264f">
<file src="bin/update_hostname_validator.php">
<MissingClosureParamType occurrences="2">
$domain
$this->type
$this->type
</MixedArgument>
- <MixedAssignment occurrences="2">
- $mime
+ <MixedAssignment occurrences="1">
$this->type
</MixedAssignment>
<MoreSpecificImplementedParamType occurrences="1">
$value
</MoreSpecificImplementedParamType>
- <PossiblyInvalidArgument occurrences="1">
- $mimetype
- </PossiblyInvalidArgument>
- <PossiblyInvalidIterator occurrences="1">
- $mimetype
- </PossiblyInvalidIterator>
<PossiblyNullPropertyAssignmentValue occurrences="1">
null
</PossiblyNullPropertyAssignmentValue>
static::NOT_DETECTED
static::NOT_READABLE
</MixedArgument>
- <MixedArgumentTypeCoercion occurrences="1">
- $mimetypes
- </MixedArgumentTypeCoercion>
- <MixedAssignment occurrences="4">
+ <MixedAssignment occurrences="2">
$file
- $mime
- $mt
$this->type
</MixedAssignment>
<MixedInferredReturnType occurrences="3">
<MoreSpecificImplementedParamType occurrences="1">
$value
</MoreSpecificImplementedParamType>
- <PossiblyInvalidArgument occurrences="3">
- $mimetype
- $mimetypes
+ <PossiblyInvalidArgument occurrences="1">
$options
</PossiblyInvalidArgument>
- <PossiblyInvalidIterator occurrences="1">
- $mimetype
- </PossiblyInvalidIterator>
<PossiblyNullPropertyAssignmentValue occurrences="2">
null
null
$finfo
$type
</PropertyNotSetInConstructor>
- <RedundantCastGivenDocblockType occurrences="3">
- (bool) $asArray
+ <RedundantCastGivenDocblockType occurrences="2">
(bool) $disable
(bool) $headerCheck
</RedundantCastGivenDocblockType>
<InvalidArgument occurrences="1">
1
</InvalidArgument>
- <InvalidScalarArgument occurrences="1">
- 123
- </InvalidScalarArgument>
<NullArgument occurrences="1">
null
</NullArgument>
<ArgumentTypeCoercion occurrences="1">
$classOrInstance
</ArgumentTypeCoercion>
- <InvalidArgument occurrences="2">
- $this->httpClient
- $this->httpRequest
- </InvalidArgument>
- <InvalidPropertyAssignmentValue occurrences="3"/>
+ <InvalidPropertyAssignmentValue occurrences="1"/>
<MixedArgument occurrences="2"/>
<MixedInferredReturnType occurrences="2">
array

diff:
@@ -28,7 +28,7 @@ class ConfigProvider
'ValidatorManager' => ValidatorPluginManager::class,
// Legacy Zend Framework aliases
- \Zend\Validator\ValidatorPluginManager::class => ValidatorPluginManager::class,
+ 'Zend\Validator\ValidatorPluginManager' => ValidatorPluginManager::class,
],
'factories' => [
ValidatorPluginManager::class => ValidatorPluginManagerFactory::class,

diff:
@@ -276,6 +276,7 @@ class MimeType extends AbstractValidator
*
* @param bool $asArray Returns the values as array, when false a concatenated string is returned
* @return string|array
+ * @psalm-return ($asArray is true ? list<string> : string)
*/
public function getMimeType($asArray = false)
{

original_message:
Solve newly detected psalm issues, updating baseline

Signed-off-by: George Steel <george@net-glue.co.uk>


diff:
@@ -31,7 +31,10 @@ class NoRecordExistsTest extends TestCase
$mockConnection = $this->createMock(ConnectionInterface::class);
// Mock has result
- $mockHasResultRow = new ArrayObject();
+ $mockHasResultRow = new class extends ArrayObject {
+ public ?string $one = null;
+ };
+
$mockHasResultRow->one = 'one';
$mockHasResult = $this->createMock(ResultInterface::class);

diff:
@@ -35,7 +35,10 @@ class RecordExistsTest extends TestCase
$mockConnection = $this->createMock(ConnectionInterface::class);
// Mock has result
- $mockHasResultRow = new ArrayObject();
+ $mockHasResultRow = new class extends ArrayObject {
+ public ?string $one = null;
+ };
+
$mockHasResultRow->one = 'one';
$mockHasResult = $this->createMock(ResultInterface::class);

diff:
@@ -104,6 +104,8 @@ class Crc32Test extends TestCase
if (! $expected) {
$this->assertArrayHasKey($messageKey, $validator->getMessages());
}
+ } else {
+ $this->expectNotToPerformAssertions();
}
}

diff:
@@ -100,6 +100,8 @@ class ExcludeExtensionTest extends TestCase
if (! $expected) {
$this->assertArrayHasKey($messageKey, $validator->getMessages());
}
+ } else {
+ $this->expectNotToPerformAssertions();
}
}

diff:
@@ -78,6 +78,8 @@ class ExistsTest extends TestCase
if (is_array($isValidParam)) {
$validator = new File\Exists($options);
$this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
+ } else {
+ $this->expectNotToPerformAssertions();
}
}

diff:
@@ -101,6 +101,8 @@ class ExtensionTest extends TestCase
if (! $expected) {
$this->assertArrayHasKey($messageKey, $validator->getMessages());
}
+ } else {
+ $this->expectNotToPerformAssertions();
}
}

diff:
@@ -132,6 +132,8 @@ class HashTest extends TestCase
if (! $expected) {
$this->assertArrayHasKey($messageKey, $validator->getMessages());
}
+ } else {
+ $this->expectNotToPerformAssertions();
}
}

diff:
@@ -168,6 +168,8 @@ class ImageSizeTest extends TestCase
$this->assertArrayHasKey($messageKey, $validator->getMessages());
}
}
+ } else {
+ $this->expectNotToPerformAssertions();
}
}

diff:
@@ -126,6 +126,8 @@ class Md5Test extends TestCase
if (! $expected) {
$this->assertArrayHasKey($messageKey, $validator->getMessages());
}
+ } else {
+ $this->expectNotToPerformAssertions();
}
}

diff:
@@ -79,6 +79,8 @@ class NotExistsTest extends TestCase
if (is_array($isValidParam)) {
$validator = new File\NotExists($options);
$this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
+ } else {
+ $this->expectNotToPerformAssertions();
}
}

diff:
@@ -109,6 +109,8 @@ class Sha1Test extends TestCase
if (! $expected) {
$this->assertArrayHasKey($messageKey, $validator->getMessages());
}
+ } else {
+ $this->expectNotToPerformAssertions();
}
}

diff:
@@ -87,6 +87,8 @@ class SizeTest extends TestCase
if (is_array($isValidParam)) {
$validator = new File\Size($options);
$this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
+ } else {
+ $this->expectNotToPerformAssertions();
}
}

diff:
@@ -82,6 +82,8 @@ class WordCountTest extends TestCase
if (is_array($isValidParam)) {
$validator = new File\WordCount($options);
$this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
+ } else {
+ $this->expectNotToPerformAssertions();
}
}

original_message:
Forward compatibility for PHP 8.2

Add anonymous classes in tests to avoid setting dynamic properties.
Also, inform PHPUnit that some tests will not perform assertions making the output of PHPUnit less verbose.

Signed-off-by: George Steel <george@net-glue.co.uk>


diff:
@@ -207,6 +207,10 @@ class Date extends AbstractValidator
// Invalid dates can show up as warnings (ie. "2007-02-99")
// and still return a DateTime object.
$errors = DateTime::getLastErrors();
+ if ($errors === false) {
+ return $date;
+ }
+
if ($errors['warning_count'] > 0) {
if ($addErrors) {
$this->error(self::FALSEFORMAT);

original_message:
`DateTime::getLastErrors()` can be false

Signed-off-by: George Steel <george@net-glue.co.uk>


diff:
<?xml version="1.0" encoding="UTF-8"?>
-<files psalm-version="4.24.0@06dd975cb55d36af80f242561738f16c5f58264f">
+<files psalm-version="4.26.0@6998fabb2bf528b65777bf9941920888d23c03ac">
<file src="bin/update_hostname_validator.php">
<MissingClosureParamType occurrences="2">
$domain
<PossiblyUndefinedVariable occurrences="1">
$temp
</PossiblyUndefinedVariable>
+ <TypeDoesNotContainType occurrences="1">
+ $errors === false
+ </TypeDoesNotContainType>
</file>
<file src="src/DateStep.php">
<ArgumentTypeCoercion occurrences="1">
</PossiblyNullArgument>
<RedundantConditionGivenDocblockType occurrences="3">
$file !== null
- is_array($files)
+ is_countable($files)
</RedundantConditionGivenDocblockType>
</file>
<file src="src/File/UploadFile.php">
[$this, 'errorHandlerIgnore']
[$this, 'errorHandlerIgnore']
</InvalidArgument>
- <InvalidScalarArgument occurrences="1">
- 1
- </InvalidScalarArgument>
<MixedArgument occurrences="2">
$message
$options
null
null
</NullArgument>
- <PossiblyNullArgument occurrences="1">
- var_export($messages, 1)
- </PossiblyNullArgument>
</file>
<file src="test/BarcodeTest.php">
<ArgumentTypeCoercion occurrences="1">
'users'
'users'
</InvalidArgument>
- <UndefinedPropertyAssignment occurrences="1">
- $mockHasResultRow->one
- </UndefinedPropertyAssignment>
</file>
<file src="test/Db/RecordExistsTest.php">
<DeprecatedMethod occurrences="2">
<PossiblyNullReference occurrences="1">
$parameters
</PossiblyNullReference>
- <UndefinedPropertyAssignment occurrences="1">
- $mockHasResultRow->one
- </UndefinedPropertyAssignment>
</file>
<file src="test/Db/TestAsset/ConcreteDbValidator.php">
<PropertyNotSetInConstructor occurrences="2">
<ArgumentTypeCoercion occurrences="1">
$classOrInstance
</ArgumentTypeCoercion>
- <InvalidPropertyAssignmentValue occurrences="1"/>
<MixedArgument occurrences="2"/>
<MixedInferredReturnType occurrences="2">
array
array
</MixedInferredReturnType>
- <MixedMethodCall occurrences="6">
- will
- will
- willReturn
- willReturn
- willReturnCallback
- willReturnCallback
- </MixedMethodCall>
- <PossiblyNullPropertyAssignmentValue occurrences="1">
- null
- </PossiblyNullPropertyAssignmentValue>
- <UndefinedInterfaceMethod occurrences="6">
- method
- method
- method
- method
- method
- method
- </UndefinedInterfaceMethod>
</file>
<file src="test/UriTest.php">
<InvalidArgument occurrences="4">

original_message:
Add `TypeDoesNotContainType` issue to the baseline. Psalm is wrong here?

Signed-off-by: George Steel <george@net-glue.co.uk>


diff:
@@ -39,7 +39,7 @@ class DateTest extends TestCase
/**
* @return array[]
* @psalm-return array<array{
- * 0: string|numeric|DateTime|object|array,
+ * 0: string|numeric|DateTime|object|array|null,
* 1: null|string,
* 2: bool,
* 3: bool
@@ -97,6 +97,10 @@ class DateTest extends TestCase
[new DateTime(), null, true, false],
// invalid obj
[new stdClass(), null, false, false],
+ // Empty Values
+ [[], null, false, false],
+ ['', null, false, false],
+ [null, null, false, false],
];
}
@@ -104,24 +108,24 @@ class DateTest extends TestCase
* Ensures that the validator follows expected behavior
*
* @dataProvider datesDataProvider
- * @param string|numeric|DateTime|object|array $input
+ * @param string|numeric|DateTime|object|array|null $input
*/
public function testBasic($input, ?string $format, bool $result, bool $resultStrict): void
{
$this->validator->setFormat($format);
- /** @psalm-suppress ArgumentTypeCoercion */
+ /** @psalm-suppress ArgumentTypeCoercion, PossiblyNullArgument */
$this->assertEquals($result, $this->validator->isValid($input));
}
/**
* @dataProvider datesDataProvider
- * @param string|numeric|DateTime|object|array $input
+ * @param string|numeric|DateTime|object|array|null $input
*/
public function testBasicStrictMode($input, ?string $format, bool $result, bool $resultStrict): void
{
$this->validator->setStrict(true);
$this->validator->setFormat($format);
- /** @psalm-suppress ArgumentTypeCoercion */
+ /** @psalm-suppress ArgumentTypeCoercion, PossiblyNullArgument */
$this->assertSame($resultStrict, $this->validator->isValid($input));
}

original_message:
Add empty values to the date validator data provider

Signed-off-by: George Steel <george@net-glue.co.uk>


diff:
@@ -98,15 +98,15 @@ class Crc32Test extends TestCase
*/
public function testLegacy($options, $isValidParam, bool $expected, string $messageKey): void
{
- if (is_array($isValidParam)) {
+ if (! is_array($isValidParam)) {
+ $this->markTestSkipped('An array is expected for legacy compat tests');
+ }
+
$validator = new File\Crc32($options);
$this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
if (! $expected) {
$this->assertArrayHasKey($messageKey, $validator->getMessages());
}
- } else {
- $this->expectNotToPerformAssertions();
- }
}
/**

diff:
@@ -94,15 +94,15 @@ class ExcludeExtensionTest extends TestCase
*/
public function testLegacy($options, $isValidParam, bool $expected, string $messageKey): void
{
- if (is_array($isValidParam)) {
+ if (! is_array($isValidParam)) {
+ $this->markTestSkipped('An array is expected for legacy compat tests');
+ }
+
$validator = new File\ExcludeExtension($options);
$this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
if (! $expected) {
$this->assertArrayHasKey($messageKey, $validator->getMessages());
}
- } else {
- $this->expectNotToPerformAssertions();
- }
}
public function testCaseTesting(): void

diff:
@@ -75,12 +75,12 @@ class ExistsTest extends TestCase
*/
public function testLegacy(string $options, $isValidParam, bool $expected): void
{
- if (is_array($isValidParam)) {
+ if (! is_array($isValidParam)) {
+ $this->markTestSkipped('An array is expected for legacy compat tests');
+ }
+
$validator = new File\Exists($options);
$this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
- } else {
- $this->expectNotToPerformAssertions();
- }
}
/**

diff:
@@ -95,15 +95,15 @@ class ExtensionTest extends TestCase
*/
public function testLegacy($options, $isValidParam, bool $expected, string $messageKey): void
{
- if (is_array($isValidParam)) {
+ if (! is_array($isValidParam)) {
+ $this->markTestSkipped('An array is expected for legacy compat tests');
+ }
+
$validator = new File\Extension($options);
$this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
if (! $expected) {
$this->assertArrayHasKey($messageKey, $validator->getMessages());
}
- } else {
- $this->expectNotToPerformAssertions();
- }
}
/**

diff:
@@ -126,15 +126,15 @@ class HashTest extends TestCase
*/
public function testLegacy($options, $isValidParam, bool $expected, string $messageKey): void
{
- if (is_array($isValidParam)) {
+ if (! is_array($isValidParam)) {
+ $this->markTestSkipped('An array is expected for legacy compat tests');
+ }
+
$validator = new File\Hash($options);
$this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
if (! $expected) {
$this->assertArrayHasKey($messageKey, $validator->getMessages());
}
- } else {
- $this->expectNotToPerformAssertions();
- }
}
/**

diff:
@@ -156,8 +156,10 @@ class ImageSizeTest extends TestCase
*/
public function testLegacy(array $options, $isValidParam, bool $expected, $messageKeys): void
{
- // Test legacy Laminas\Transfer API
- if (is_array($isValidParam)) {
+ if (! is_array($isValidParam)) {
+ $this->markTestSkipped('An array is expected for legacy compat tests');
+ }
+
$validator = new File\ImageSize($options);
$this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
if (! $expected) {
@@ -168,9 +170,6 @@ class ImageSizeTest extends TestCase
$this->assertArrayHasKey($messageKey, $validator->getMessages());
}
}
- } else {
- $this->expectNotToPerformAssertions();
- }
}
/**

diff:
@@ -120,15 +120,15 @@ class Md5Test extends TestCase
*/
public function testLegacy($options, $isValidParam, bool $expected, string $messageKey): void
{
- if (is_array($isValidParam)) {
+ if (! is_array($isValidParam)) {
+ $this->markTestSkipped('An array is expected for legacy compat tests');
+ }
+
$validator = new File\Md5($options);
$this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
if (! $expected) {
$this->assertArrayHasKey($messageKey, $validator->getMessages());
}
- } else {
- $this->expectNotToPerformAssertions();
- }
}
/**

diff:
@@ -76,12 +76,12 @@ class NotExistsTest extends TestCase
*/
public function testLegacy(string $options, $isValidParam, bool $expected): void
{
- if (is_array($isValidParam)) {
+ if (! is_array($isValidParam)) {
+ $this->markTestSkipped('An array is expected for legacy compat tests');
+ }
+
$validator = new File\NotExists($options);
$this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
- } else {
- $this->expectNotToPerformAssertions();
- }
}
/**

diff:
@@ -103,15 +103,15 @@ class Sha1Test extends TestCase
*/
public function testLegacy($options, $isValidParam, bool $expected, string $messageKey): void
{
- if (is_array($isValidParam)) {
+ if (! is_array($isValidParam)) {
+ $this->markTestSkipped('An array is expected for legacy compat tests');
+ }
+
$validator = new File\Sha1($options);
$this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
if (! $expected) {
$this->assertArrayHasKey($messageKey, $validator->getMessages());
}
- } else {
- $this->expectNotToPerformAssertions();
- }
}
/**

diff:
@@ -84,12 +84,12 @@ class SizeTest extends TestCase
*/
public function testLegacy($options, $isValidParam, bool $expected): void
{
- if (is_array($isValidParam)) {
+ if (! is_array($isValidParam)) {
+ $this->markTestSkipped('An array is expected for legacy compat tests');
+ }
+
$validator = new File\Size($options);
$this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
- } else {
- $this->expectNotToPerformAssertions();
- }
}
/**

diff:
@@ -79,12 +79,12 @@ class WordCountTest extends TestCase
*/
public function testLegacy($options, $isValidParam, bool $expected): void
{
- if (is_array($isValidParam)) {
+ if (! is_array($isValidParam)) {
+ $this->markTestSkipped('An array is expected for legacy compat tests');
+ }
+
$validator = new File\WordCount($options);
$this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
- } else {
- $this->expectNotToPerformAssertions();
- }
}
/**

original_message:
Skip redundant tests rather than expecting zero assertions

Signed-off-by: George Steel <george@net-glue.co.uk>


diff:
},
"require-dev": {
"laminas/laminas-coding-standard": "^2.4.0",
- "laminas/laminas-db": "^2.7",
- "laminas/laminas-filter": "^2.14.0",
- "laminas/laminas-http": "^2.14.2",
- "laminas/laminas-i18n": "^2.15.0",
- "laminas/laminas-session": "^2.12.1",
+ "laminas/laminas-db": "^2.15.0",
+ "laminas/laminas-filter": "^2.18.0",
+ "laminas/laminas-http": "^2.16.0",
+ "laminas/laminas-i18n": "^2.17.0",
+ "laminas/laminas-session": "^2.13.0",
"laminas/laminas-uri": "^2.9.1",
"phpspec/prophecy-phpunit": "^2.0",
- "phpunit/phpunit": "^9.5.21",
+ "phpunit/phpunit": "^9.5.24",
"psalm/plugin-phpunit": "^0.17.0",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0",
- "vimeo/psalm": "^4.24.0"
+ "vimeo/psalm": "^4.27.0"
},
"suggest": {
"laminas/laminas-db": "Laminas\\Db component, required by the (No)RecordExists validator",

diff:
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "b99de6e42a0689e2cc05c918c3bd2b66",
+ "content-hash": "692419bd211c070dc48def1f401530d0",
"packages": [
{
"name": "laminas/laminas-servicemanager",
},
{
"name": "laminas/laminas-filter",
- "version": "2.17.0",
+ "version": "2.18.0",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-filter.git",
- "reference": "7c78483f22e118fbc98be41dc24b39e8c17cdcae"
+ "reference": "8d352d8d031af69a366ba5eb5b812a5d33e97c3c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laminas/laminas-filter/zipball/7c78483f22e118fbc98be41dc24b39e8c17cdcae",
- "reference": "7c78483f22e118fbc98be41dc24b39e8c17cdcae",
+ "url": "https://api.github.com/repos/laminas/laminas-filter/zipball/8d352d8d031af69a366ba5eb5b812a5d33e97c3c",
+ "reference": "8d352d8d031af69a366ba5eb5b812a5d33e97c3c",
"shasum": ""
},
"require": {
"type": "community_bridge"
}
],
- "time": "2022-07-17T11:58:06+00:00"
+ "time": "2022-09-09T05:08:45+00:00"
},
{
"name": "laminas/laminas-http",
},
{
"name": "nikic/php-parser",
- "version": "v4.14.0",
+ "version": "v4.15.1",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
- "reference": "34bea19b6e03d8153165d8f30bba4c3be86184c1"
+ "reference": "0ef6c55a3f47f89d7a374e6f835197a0b5fcf900"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/34bea19b6e03d8153165d8f30bba4c3be86184c1",
- "reference": "34bea19b6e03d8153165d8f30bba4c3be86184c1",
+ "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/0ef6c55a3f47f89d7a374e6f835197a0b5fcf900",
+ "reference": "0ef6c55a3f47f89d7a374e6f835197a0b5fcf900",
"shasum": ""
},
"require": {
],
"support": {
"issues": "https://github.com/nikic/PHP-Parser/issues",
- "source": "https://github.com/nikic/PHP-Parser/tree/v4.14.0"
+ "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.1"
},
- "time": "2022-05-31T20:59:12+00:00"
+ "time": "2022-09-04T07:30:47+00:00"
},
{
"name": "openlss/lib-array2xml",
},
{
"name": "phpunit/php-code-coverage",
- "version": "9.2.16",
+ "version": "9.2.17",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
- "reference": "2593003befdcc10db5e213f9f28814f5aa8ac073"
+ "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2593003befdcc10db5e213f9f28814f5aa8ac073",
- "reference": "2593003befdcc10db5e213f9f28814f5aa8ac073",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/aa94dc41e8661fe90c7316849907cba3007b10d8",
+ "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8",
"shasum": ""
},
"require": {
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
- "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.16"
+ "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.17"
},
"funding": [
{
"type": "github"
}
],
- "time": "2022-08-20T05:26:47+00:00"
+ "time": "2022-08-30T12:24:04+00:00"
},
{
"name": "phpunit/php-file-iterator",
},
{
"name": "phpunit/phpunit",
- "version": "9.5.23",
+ "version": "9.5.24",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "888556852e7e9bbeeedb9656afe46118765ade34"
+ "reference": "d0aa6097bef9fd42458a9b3c49da32c6ce6129c5"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/888556852e7e9bbeeedb9656afe46118765ade34",
- "reference": "888556852e7e9bbeeedb9656afe46118765ade34",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d0aa6097bef9fd42458a9b3c49da32c6ce6129c5",
+ "reference": "d0aa6097bef9fd42458a9b3c49da32c6ce6129c5",
"shasum": ""
},
"require": {
"sebastian/global-state": "^5.0.1",
"sebastian/object-enumerator": "^4.0.3",
"sebastian/resource-operations": "^3.0.3",
- "sebastian/type": "^3.0",
+ "sebastian/type": "^3.1",
"sebastian/version": "^3.0.2"
},
"suggest": {
],
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
- "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.23"
+ "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.24"
},
"funding": [
{
"type": "github"
}
],
- "time": "2022-08-22T14:01:36+00:00"
+ "time": "2022-08-30T07:42:16+00:00"
},
{
"name": "psalm/plugin-phpunit",
},
{
"name": "sebastian/type",
- "version": "3.0.0",
+ "version": "3.2.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/type.git",
- "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad"
+ "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b233b84bc4465aff7b57cf1c4bc75c86d00d6dad",
- "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad",
+ "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e",
+ "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e",
"shasum": ""
},
"require": {
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "3.0-dev"
+ "dev-master": "3.2-dev"
}
},
"autoload": {
"homepage": "https://github.com/sebastianbergmann/type",
"support": {
"issues": "https://github.com/sebastianbergmann/type/issues",
- "source": "https://github.com/sebastianbergmann/type/tree/3.0.0"
+ "source": "https://github.com/sebastianbergmann/type/tree/3.2.0"
},
"funding": [
{
"type": "github"
}
],
- "time": "2022-03-15T09:54:48+00:00"
+ "time": "2022-09-12T14:47:03+00:00"
},
{
"name": "sebastian/version",
},
{
"name": "symfony/console",
- "version": "v5.4.11",
+ "version": "v5.4.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
- "reference": "535846c7ee6bc4dd027ca0d93220601456734b10"
+ "reference": "c072aa8f724c3af64e2c7a96b796a4863d24dba1"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/console/zipball/535846c7ee6bc4dd027ca0d93220601456734b10",
- "reference": "535846c7ee6bc4dd027ca0d93220601456734b10",
+ "url": "https://api.github.com/repos/symfony/console/zipball/c072aa8f724c3af64e2c7a96b796a4863d24dba1",
+ "reference": "c072aa8f724c3af64e2c7a96b796a4863d24dba1",
"shasum": ""
},
"require": {
"terminal"
],
"support": {
- "source": "https://github.com/symfony/console/tree/v5.4.11"
+ "source": "https://github.com/symfony/console/tree/v5.4.12"
},
"funding": [
{
"type": "tidelift"
}
],
- "time": "2022-07-22T10:42:43+00:00"
+ "time": "2022-08-17T13:18:05+00:00"
},
{
"name": "symfony/deprecation-contracts",
},
{
"name": "symfony/string",
- "version": "v5.4.11",
+ "version": "v5.4.12",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
- "reference": "5eb661e49ad389e4ae2b6e4df8d783a8a6548322"
+ "reference": "2fc515e512d721bf31ea76bd02fe23ada4640058"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/string/zipball/5eb661e49ad389e4ae2b6e4df8d783a8a6548322",
- "reference": "5eb661e49ad389e4ae2b6e4df8d783a8a6548322",
+ "url": "https://api.github.com/repos/symfony/string/zipball/2fc515e512d721bf31ea76bd02fe23ada4640058",
+ "reference": "2fc515e512d721bf31ea76bd02fe23ada4640058",
"shasum": ""
},
"require": {
"utf8"
],
"support": {
- "source": "https://github.com/symfony/string/tree/v5.4.11"
+ "source": "https://github.com/symfony/string/tree/v5.4.12"
},
"funding": [
{
"type": "tidelift"
}
],
- "time": "2022-07-24T16:15:25+00:00"
+ "time": "2022-08-12T17:03:11+00:00"
},
{
"name": "theseer/tokenizer",
},
{
"name": "vimeo/psalm",
- "version": "4.26.0",
+ "version": "4.27.0",
"source": {
"type": "git",
"url": "https://github.com/vimeo/psalm.git",
- "reference": "6998fabb2bf528b65777bf9941920888d23c03ac"
+ "reference": "faf106e717c37b8c81721845dba9de3d8deed8ff"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/vimeo/psalm/zipball/6998fabb2bf528b65777bf9941920888d23c03ac",
- "reference": "6998fabb2bf528b65777bf9941920888d23c03ac",
+ "url": "https://api.github.com/repos/vimeo/psalm/zipball/faf106e717c37b8c81721845dba9de3d8deed8ff",
+ "reference": "faf106e717c37b8c81721845dba9de3d8deed8ff",
"shasum": ""
},
"require": {
],
"support": {
"issues": "https://github.com/vimeo/psalm/issues",
- "source": "https://github.com/vimeo/psalm/tree/4.26.0"
+ "source": "https://github.com/vimeo/psalm/tree/4.27.0"
},
- "time": "2022-07-31T13:10:26+00:00"
+ "time": "2022-08-31T13:47:09+00:00"
},
{
"name": "webimpress/coding-standard",

diff:
@@ -16,6 +16,7 @@ use function array_combine;
use function array_count_values;
use function array_map;
use function array_shift;
+use function assert;
use function ceil;
use function date_default_timezone_get;
use function explode;
@@ -408,6 +409,7 @@ class DateStep extends Date
} else {
$baseDate = $baseDate->sub($minimumInterval);
}
+ assert($baseDate !== false);
}
while (
@@ -420,6 +422,8 @@ class DateStep extends Date
$baseDate = $baseDate->sub($step);
}
+ assert($baseDate !== false);
+
// phpcs:ignore SlevomatCodingStandard.Operators.DisallowEqualOperators.DisallowedEqualOperator
if ($baseDate == $valueDate) {
return true;

original_message:
Update psalm to 4.27 fixing newly discovered issues

Signed-off-by: George Steel <george@net-glue.co.uk>


diff:
"require": {
"php": "^7.4 || ~8.0.0 || ~8.1.0",
"laminas/laminas-servicemanager": "^3.12.0",
- "laminas/laminas-stdlib": "^3.10"
+ "laminas/laminas-stdlib": "^3.13"
},
"require-dev": {
"laminas/laminas-coding-standard": "^2.4.0",

diff:
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "692419bd211c070dc48def1f401530d0",
+ "content-hash": "85c2b13ee36a9a4429eca67b43f03d0a",
"packages": [
{
"name": "laminas/laminas-servicemanager",
},
{
"name": "laminas/laminas-filter",
- "version": "2.18.0",
+ "version": "2.19.0",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-filter.git",
- "reference": "8d352d8d031af69a366ba5eb5b812a5d33e97c3c"
+ "reference": "06322d90fad3c18dc4646f26d92c8b5557ee195e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laminas/laminas-filter/zipball/8d352d8d031af69a366ba5eb5b812a5d33e97c3c",
- "reference": "8d352d8d031af69a366ba5eb5b812a5d33e97c3c",
+ "url": "https://api.github.com/repos/laminas/laminas-filter/zipball/06322d90fad3c18dc4646f26d92c8b5557ee195e",
+ "reference": "06322d90fad3c18dc4646f26d92c8b5557ee195e",
"shasum": ""
},
"require": {
"laminas/laminas-servicemanager": "^3.14.0",
- "laminas/laminas-stdlib": "^3.6.1",
+ "laminas/laminas-stdlib": "^3.13.0",
"php": "^7.4 || ~8.0.0 || ~8.1.0"
},
"conflict": {
"zendframework/zend-filter": "*"
},
"require-dev": {
- "laminas/laminas-coding-standard": "^2.3.0",
+ "laminas/laminas-coding-standard": "~2.4.0",
"laminas/laminas-crypt": "^3.5.1",
"laminas/laminas-uri": "^2.9.1",
"pear/archive_tar": "^1.4.14",
"phpspec/prophecy-phpunit": "^2.0.1",
- "phpunit/phpunit": "^9.5.10",
+ "phpunit/phpunit": "^9.5.24",
"psalm/plugin-phpunit": "^0.17.0",
"psr/http-factory": "^1.0.1",
- "vimeo/psalm": "^4.24.0"
+ "vimeo/psalm": "^4.27.0"
},
"suggest": {
"laminas/laminas-crypt": "Laminas\\Crypt component, for encryption filters",
"type": "community_bridge"
}
],
- "time": "2022-09-09T05:08:45+00:00"
+ "time": "2022-09-20T11:05:37+00:00"
},
{
"name": "laminas/laminas-http",

diff:
namespace Laminas\Validator;
use Countable;
+use IteratorAggregate;
use Laminas\ServiceManager\ServiceManager;
use Laminas\Stdlib\PriorityQueue;
use ReturnTypeWillChange;
+use Traversable;
use function array_replace;
use function assert;
@@ -16,10 +18,10 @@ use const SORT_NUMERIC;
/**
* @psalm-type QueueElement = array{instance: ValidatorInterface, breakChainOnFailure: bool}
+ * @implements IteratorAggregate<array-key, QueueElement>
+ * @final
*/
-class ValidatorChain implements
- Countable,
- ValidatorInterface
+class ValidatorChain implements Countable, IteratorAggregate, ValidatorInterface
{
/**
* Default priority at which validators are added
@@ -248,7 +250,7 @@ class ValidatorChain implements
{
$this->messages = [];
$result = true;
- foreach ($this->validators as $element) {
+ foreach ($this as $element) {
$validator = $element['instance'];
assert($validator instanceof ValidatorInterface);
if ($validator->isValid($value, $context)) {
@@ -331,4 +333,10 @@ class ValidatorChain implements
{
return ['validators', 'messages'];
}
+
+ /** @return Traversable<array-key, QueueElement> */
+ public function getIterator(): Traversable
+ {
+ return clone $this->validators;
+ }
}

original_message:
Mark the ValidatorChain as iterable and final

Signed-off-by: George Steel <george@net-glue.co.uk>


diff:
"config": {
"sort-packages": true,
"platform": {
- "php": "7.4.99"
+ "php": "8.0.99"
},
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"require": {
- "php": "^7.4 || ~8.0.0 || ~8.1.0",
+ "php": "~8.0.0 || ~8.1.0 || ~8.2.0",
"laminas/laminas-servicemanager": "^3.12.0",
"laminas/laminas-stdlib": "^3.13"
},
"require-dev": {
"laminas/laminas-coding-standard": "^2.4.0",
"laminas/laminas-db": "^2.15.0",
- "laminas/laminas-filter": "^2.18.0",
+ "laminas/laminas-filter": "^2.22",
"laminas/laminas-http": "^2.16.0",
- "laminas/laminas-i18n": "^2.17.0",
+ "laminas/laminas-i18n": "^2.19",
"laminas/laminas-session": "^2.13.0",
"laminas/laminas-uri": "^2.9.1",
- "phpunit/phpunit": "^9.5.24",
+ "phpunit/phpunit": "^9.5.25",
"psalm/plugin-phpunit": "^0.17.0",
- "psr/http-client": "^1.0",
- "psr/http-factory": "^1.0",
- "psr/http-message": "^1.0",
- "vimeo/psalm": "^4.27.0"
+ "psr/http-client": "^1.0.1",
+ "psr/http-factory": "^1.0.1",
+ "psr/http-message": "^1.0.1",
+ "vimeo/psalm": "^4.28"
},
"suggest": {
"laminas/laminas-db": "Laminas\\Db component, required by the (No)RecordExists validator",

diff:
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "ab099ed9db9523c09d59ebce8d5610a0",
+ "content-hash": "520516b15499e7e76ac4e8b0ff7fbd7b",
"packages": [
{
"name": "laminas/laminas-servicemanager",
- "version": "3.17.0",
+ "version": "3.19.0",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-servicemanager.git",
- "reference": "360be5f16955dd1edbcce1cfaa98ed82a17f02ec"
+ "reference": "ed160729bb8721127efdaac799f9a298963345b1"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laminas/laminas-servicemanager/zipball/360be5f16955dd1edbcce1cfaa98ed82a17f02ec",
- "reference": "360be5f16955dd1edbcce1cfaa98ed82a17f02ec",
+ "url": "https://api.github.com/repos/laminas/laminas-servicemanager/zipball/ed160729bb8721127efdaac799f9a298963345b1",
+ "reference": "ed160729bb8721127efdaac799f9a298963345b1",
"shasum": ""
},
"require": {
"laminas/laminas-stdlib": "^3.2.1",
- "php": "~7.4.0 || ~8.0.0 || ~8.1.0",
+ "php": "~8.0.0 || ~8.1.0 || ~8.2.0",
"psr/container": "^1.0"
},
"conflict": {
"container-interop/container-interop": "^1.2.0"
},
"require-dev": {
- "composer/package-versions-deprecated": "^1.0",
+ "composer/package-versions-deprecated": "^1.11.99.5",
"laminas/laminas-coding-standard": "~2.4.0",
"laminas/laminas-container-config-test": "^0.7",
- "laminas/laminas-dependency-plugin": "^2.1.2",
- "mikey179/vfsstream": "^1.6.10@alpha",
- "ocramius/proxy-manager": "^2.11",
- "phpbench/phpbench": "^1.1",
- "phpspec/prophecy-phpunit": "^2.0",
- "phpunit/phpunit": "^9.5.5",
+ "laminas/laminas-dependency-plugin": "^2.2",
+ "mikey179/vfsstream": "^1.6.11@alpha",
+ "ocramius/proxy-manager": "^2.14.1",
+ "phpbench/phpbench": "^1.2.6",
+ "phpunit/phpunit": "^9.5.25",
"psalm/plugin-phpunit": "^0.17.0",
- "vimeo/psalm": "^4.8"
+ "vimeo/psalm": "^4.28"
},
"suggest": {
"ocramius/proxy-manager": "ProxyManager ^2.1.1 to handle lazy initialization of services"
"type": "community_bridge"
}
],
- "time": "2022-09-22T11:33:46+00:00"
+ "time": "2022-10-10T20:59:22+00:00"
},
{
"name": "laminas/laminas-stdlib",
- "version": "3.13.0",
+ "version": "3.15.0",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-stdlib.git",
- "reference": "66a6d03c381f6c9f1dd988bf8244f9afb9380d76"
+ "reference": "63b66bd4b696f024f42616b9d95cdb10e5109c27"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/66a6d03c381f6c9f1dd988bf8244f9afb9380d76",
- "reference": "66a6d03c381f6c9f1dd988bf8244f9afb9380d76",
+ "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/63b66bd4b696f024f42616b9d95cdb10e5109c27",
+ "reference": "63b66bd4b696f024f42616b9d95cdb10e5109c27",
"shasum": ""
},
"require": {
- "php": "^7.4 || ~8.0.0 || ~8.1.0"
+ "php": "~8.0.0 || ~8.1.0 || ~8.2.0"
},
"conflict": {
"zendframework/zend-stdlib": "*"
},
"require-dev": {
- "laminas/laminas-coding-standard": "~2.3.0",
+ "laminas/laminas-coding-standard": "^2.4.0",
"phpbench/phpbench": "^1.2.6",
- "phpstan/phpdoc-parser": "^0.5.4",
- "phpunit/phpunit": "^9.5.23",
+ "phpunit/phpunit": "^9.5.25",
"psalm/plugin-phpunit": "^0.17.0",
- "vimeo/psalm": "^4.26"
+ "vimeo/psalm": "^4.28"
},
"type": "library",
"autoload": {
"type": "community_bridge"
}
],
- "time": "2022-08-24T13:56:50+00:00"
+ "time": "2022-10-10T19:10:24+00:00"
},
{
"name": "psr/container",
},
{
"name": "laminas/laminas-escaper",
- "version": "2.10.0",
+ "version": "2.12.0",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-escaper.git",
- "reference": "58af67282db37d24e584a837a94ee55b9c7552be"
+ "reference": "ee7a4c37bf3d0e8c03635d5bddb5bb3184ead490"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laminas/laminas-escaper/zipball/58af67282db37d24e584a837a94ee55b9c7552be",
- "reference": "58af67282db37d24e584a837a94ee55b9c7552be",
+ "url": "https://api.github.com/repos/laminas/laminas-escaper/zipball/ee7a4c37bf3d0e8c03635d5bddb5bb3184ead490",
+ "reference": "ee7a4c37bf3d0e8c03635d5bddb5bb3184ead490",
"shasum": ""
},
"require": {
"ext-ctype": "*",
"ext-mbstring": "*",
- "php": "^7.4 || ~8.0.0 || ~8.1.0"
+ "php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0"
},
"conflict": {
"zendframework/zend-escaper": "*"
},
"require-dev": {
"infection/infection": "^0.26.6",
- "laminas/laminas-coding-standard": "~2.3.0",
+ "laminas/laminas-coding-standard": "~2.4.0",
"maglnet/composer-require-checker": "^3.8.0",
"phpunit/phpunit": "^9.5.18",
- "psalm/plugin-phpunit": "^0.16.1",
+ "psalm/plugin-phpunit": "^0.17.0",
"vimeo/psalm": "^4.22.0"
},
"type": "library",
"type": "community_bridge"
}
],
- "time": "2022-03-08T20:15:36+00:00"
+ "time": "2022-10-10T10:11:09+00:00"
},
{
"name": "laminas/laminas-eventmanager",
},
{
"name": "laminas/laminas-filter",
- "version": "2.21.0",
+ "version": "2.22.0",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-filter.git",
- "reference": "7835f3f3227b1892676cb7366fbed0e521cac845"
+ "reference": "c48e8a392a81de7d211026c078dce0e8bc57e2e3"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laminas/laminas-filter/zipball/7835f3f3227b1892676cb7366fbed0e521cac845",
- "reference": "7835f3f3227b1892676cb7366fbed0e521cac845",
+ "url": "https://api.github.com/repos/laminas/laminas-filter/zipball/c48e8a392a81de7d211026c078dce0e8bc57e2e3",
+ "reference": "c48e8a392a81de7d211026c078dce0e8bc57e2e3",
"shasum": ""
},
"require": {
+ "ext-mbstring": "*",
"laminas/laminas-servicemanager": "^3.14.0",
"laminas/laminas-stdlib": "^3.13.0",
"php": "^7.4 || ~8.0.0 || ~8.1.0"
"type": "community_bridge"
}
],
- "time": "2022-09-30T09:15:24+00:00"
+ "time": "2022-10-11T08:14:46+00:00"
},
{
"name": "laminas/laminas-http",
},
{
"name": "laminas/laminas-i18n",
- "version": "2.17.0",
+ "version": "2.19.0",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-i18n.git",
- "reference": "7e8e63353b38792f2f360dc57cfa7187be20f182"
+ "reference": "ebabca3a6398fc872127bc69a51bda5afc720d67"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laminas/laminas-i18n/zipball/7e8e63353b38792f2f360dc57cfa7187be20f182",
- "reference": "7e8e63353b38792f2f360dc57cfa7187be20f182",
+ "url": "https://api.github.com/repos/laminas/laminas-i18n/zipball/ebabca3a6398fc872127bc69a51bda5afc720d67",
+ "reference": "ebabca3a6398fc872127bc69a51bda5afc720d67",
"shasum": ""
},
"require": {
"ext-intl": "*",
"laminas/laminas-servicemanager": "^3.14.0",
"laminas/laminas-stdlib": "^2.7 || ^3.0",
- "php": "^7.4 || ~8.0.0 || ~8.1.0"
+ "php": "~8.0.0 || ~8.1.0 || ~8.2.0"
},
"conflict": {
"laminas/laminas-view": "<2.20.0",
"zendframework/zend-i18n": "*"
},
"require-dev": {
- "laminas/laminas-cache": "^3.1.2",
- "laminas/laminas-cache-storage-adapter-memory": "^2.0.0",
- "laminas/laminas-cache-storage-deprecated-factory": "^1.0.0",
- "laminas/laminas-coding-standard": "~2.3.0",
- "laminas/laminas-config": "^3.4.0",
+ "laminas/laminas-cache": "^3.6",
+ "laminas/laminas-cache-storage-adapter-memory": "^2.1",
+ "laminas/laminas-cache-storage-deprecated-factory": "^1.0.1",
+ "laminas/laminas-coding-standard": "~2.4.0",
+ "laminas/laminas-config": "^3.7",
"laminas/laminas-eventmanager": "^3.5.0",
- "laminas/laminas-filter": "^2.16.0",
- "laminas/laminas-validator": "^2.17.0",
- "laminas/laminas-view": "^2.21.0",
- "phpspec/prophecy-phpunit": "^2.0",
- "phpunit/phpunit": "^9.5.21",
+ "laminas/laminas-filter": "^2.21",
+ "laminas/laminas-validator": "^2.25",
+ "laminas/laminas-view": "^2.23",
+ "phpunit/phpunit": "^9.5.25",
"psalm/plugin-phpunit": "^0.17.0",
- "vimeo/psalm": "^4.24.0"
+ "vimeo/psalm": "^4.28"
},
"suggest": {
"laminas/laminas-cache": "You should install this package to cache the translations",
"type": "community_bridge"
}
],
- "time": "2022-07-27T11:23:29+00:00"
+ "time": "2022-10-10T15:48:56+00:00"
},
{
"name": "laminas/laminas-loader",
},
{
"name": "psr/log",
- "version": "1.1.4",
+ "version": "3.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
- "reference": "d49695b909c3b7628b6289db5479a1c204601f11"
+ "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
- "reference": "d49695b909c3b7628b6289db5479a1c204601f11",
+ "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001",
+ "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001",
"shasum": ""
},
"require": {
- "php": ">=5.3.0"
+ "php": ">=8.0.0"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.1.x-dev"
+ "dev-master": "3.x-dev"
}
},
"autoload": {
"psr-4": {
- "Psr\\Log\\": "Psr/Log/"
+ "Psr\\Log\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"psr-3"
],
"support": {
- "source": "https://github.com/php-fig/log/tree/1.1.4"
+ "source": "https://github.com/php-fig/log/tree/3.0.0"
},
- "time": "2021-05-03T11:20:27+00:00"
+ "time": "2021-07-14T16:46:02+00:00"
},
{
"name": "sebastian/cli-parser",
},
{
"name": "symfony/console",
- "version": "v5.4.13",
+ "version": "v6.0.13",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
- "reference": "3f97f6c7b7e26848a90c0c0cfb91eeb2bb8618be"
+ "reference": "8f14753b865651c2aad107ef97475740a9b0730f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/console/zipball/3f97f6c7b7e26848a90c0c0cfb91eeb2bb8618be",
- "reference": "3f97f6c7b7e26848a90c0c0cfb91eeb2bb8618be",
+ "url": "https://api.github.com/repos/symfony/console/zipball/8f14753b865651c2aad107ef97475740a9b0730f",
+ "reference": "8f14753b865651c2aad107ef97475740a9b0730f",
"shasum": ""
},
"require": {
- "php": ">=7.2.5",
- "symfony/deprecation-contracts": "^2.1|^3",
+ "php": ">=8.0.2",
"symfony/polyfill-mbstring": "~1.0",
- "symfony/polyfill-php73": "^1.9",
- "symfony/polyfill-php80": "^1.16",
"symfony/service-contracts": "^1.1|^2|^3",
- "symfony/string": "^5.1|^6.0"
+ "symfony/string": "^5.4|^6.0"
},
"conflict": {
- "psr/log": ">=3",
- "symfony/dependency-injection": "<4.4",
- "symfony/dotenv": "<5.1",
- "symfony/event-dispatcher": "<4.4",
- "symfony/lock": "<4.4",
- "symfony/process": "<4.4"
+ "symfony/dependency-injection": "<5.4",
+ "symfony/dotenv": "<5.4",
+ "symfony/event-dispatcher": "<5.4",
+ "symfony/lock": "<5.4",
+ "symfony/process": "<5.4"
},
"provide": {
- "psr/log-implementation": "1.0|2.0"
+ "psr/log-implementation": "1.0|2.0|3.0"
},
"require-dev": {
- "psr/log": "^1|^2",
- "symfony/config": "^4.4|^5.0|^6.0",
- "symfony/dependency-injection": "^4.4|^5.0|^6.0",
- "symfony/event-dispatcher": "^4.4|^5.0|^6.0",
- "symfony/lock": "^4.4|^5.0|^6.0",
- "symfony/process": "^4.4|^5.0|^6.0",
- "symfony/var-dumper": "^4.4|^5.0|^6.0"
+ "psr/log": "^1|^2|^3",
+ "symfony/config": "^5.4|^6.0",
+ "symfony/dependency-injection": "^5.4|^6.0",
+ "symfony/event-dispatcher": "^5.4|^6.0",
+ "symfony/lock": "^5.4|^6.0",
+ "symfony/process": "^5.4|^6.0",
+ "symfony/var-dumper": "^5.4|^6.0"
},
"suggest": {
"psr/log": "For using the console logger",
"terminal"
],
"support": {
- "source": "https://github.com/symfony/console/tree/v5.4.13"
+ "source": "https://github.com/symfony/console/tree/v6.0.13"
},
"funding": [
{
"type": "tidelift"
}
],
- "time": "2022-08-26T13:50:20+00:00"
+ "time": "2022-09-03T14:23:25+00:00"
},
{
"name": "symfony/deprecation-contracts",
- "version": "v2.5.2",
+ "version": "v3.0.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
- "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66"
+ "reference": "26954b3d62a6c5fd0ea8a2a00c0353a14978d05c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66",
- "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66",
+ "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/26954b3d62a6c5fd0ea8a2a00c0353a14978d05c",
+ "reference": "26954b3d62a6c5fd0ea8a2a00c0353a14978d05c",
"shasum": ""
},
"require": {
- "php": ">=7.1"
+ "php": ">=8.0.2"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "2.5-dev"
+ "dev-main": "3.0-dev"
},
"thanks": {
"name": "symfony/contracts",
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
- "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.2"
+ "source": "https://github.com/symfony/deprecation-contracts/tree/v3.0.2"
},
"funding": [
{
"type": "tidelift"
}
],
- "time": "2022-01-02T09:53:40+00:00"
+ "time": "2022-01-02T09:55:41+00:00"
},
{
"name": "symfony/polyfill-ctype",
],
"time": "2022-05-24T11:49:31+00:00"
},
- {
- "name": "symfony/polyfill-php73",
- "version": "v1.26.0",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/polyfill-php73.git",
- "reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/e440d35fa0286f77fb45b79a03fedbeda9307e85",
- "reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85",
- "shasum": ""
- },
- "require": {
- "php": ">=7.1"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-main": "1.26-dev"
- },
- "thanks": {
- "name": "symfony/polyfill",
- "url": "https://github.com/symfony/polyfill"
- }
- },
- "autoload": {
- "files": [
- "bootstrap.php"
- ],
- "psr-4": {
- "Symfony\\Polyfill\\Php73\\": ""
- },
- "classmap": [
- "Resources/stubs"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions",
- "homepage": "https://symfony.com",
- "keywords": [
- "compatibility",
- "polyfill",
- "portable",
- "shim"
- ],
- "support": {
- "source": "https://github.com/symfony/polyfill-php73/tree/v1.26.0"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2022-05-24T11:49:31+00:00"
- },
{
"name": "symfony/polyfill-php80",
"version": "v1.26.0",
},
{
"name": "symfony/string",
- "version": "v5.4.13",
+ "version": "v6.0.13",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
- "reference": "2900c668a32138a34118740de3e4d5a701801f53"
+ "reference": "65e99fb179e7241606377e4042cd2161f3dd1c05"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/string/zipball/2900c668a32138a34118740de3e4d5a701801f53",
- "reference": "2900c668a32138a34118740de3e4d5a701801f53",
+ "url": "https://api.github.com/repos/symfony/string/zipball/65e99fb179e7241606377e4042cd2161f3dd1c05",
+ "reference": "65e99fb179e7241606377e4042cd2161f3dd1c05",
"shasum": ""
},
"require": {
- "php": ">=7.2.5",
+ "php": ">=8.0.2",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-intl-grapheme": "~1.0",
"symfony/polyfill-intl-normalizer": "~1.0",
- "symfony/polyfill-mbstring": "~1.0",
- "symfony/polyfill-php80": "~1.15"
+ "symfony/polyfill-mbstring": "~1.0"
},
"conflict": {
- "symfony/translation-contracts": ">=3.0"
+ "symfony/translation-contracts": "<2.0"
},
"require-dev": {
- "symfony/error-handler": "^4.4|^5.0|^6.0",
- "symfony/http-client": "^4.4|^5.0|^6.0",
- "symfony/translation-contracts": "^1.1|^2",
- "symfony/var-exporter": "^4.4|^5.0|^6.0"
+ "symfony/error-handler": "^5.4|^6.0",
+ "symfony/http-client": "^5.4|^6.0",
+ "symfony/translation-contracts": "^2.0|^3.0",
+ "symfony/var-exporter": "^5.4|^6.0"
},
"type": "library",
"autoload": {
"utf8"
],
"support": {
- "source": "https://github.com/symfony/string/tree/v5.4.13"
+ "source": "https://github.com/symfony/string/tree/v6.0.13"
},
"funding": [
{
"type": "tidelift"
}
],
- "time": "2022-09-01T01:52:16+00:00"
+ "time": "2022-09-02T08:05:03+00:00"
},
{
"name": "theseer/tokenizer",
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
- "php": "^7.4 || ~8.0.0 || ~8.1.0"
+ "php": "~8.0.0 || ~8.1.0 || ~8.2.0"
},
"platform-dev": [],
"platform-overrides": {
- "php": "7.4.99"
+ "php": "8.0.99"
},
"plugin-api-version": "2.3.0"
}

original_message:
Add support for PHP 8.2, remove support for PHP 7.4

Signed-off-by: George Steel <george@net-glue.co.uk>


diff:
@@ -204,7 +204,7 @@ class DateStep extends Date
// Invalid dates can show up as warnings (ie. "2007-02-99")
// and still return a DateTime object.
$errors = DateTime::getLastErrors();
- if ($errors['warning_count'] > 0) {
+ if (is_array($errors) && $errors['warning_count'] > 0) {
if ($addErrors) {
$this->error(self::FALSEFORMAT);
}

original_message:
8.2 compat: `DateTime::getLastErrors()` can be false

Signed-off-by: George Steel <george@net-glue.co.uk>


diff:
@@ -11,11 +11,7 @@ use PHPUnit\Framework\TestCase;
use function basename;
use function current;
use function filesize;
-use function restore_error_handler;
-use function set_error_handler;
-use function strstr;
-use const E_USER_NOTICE;
use const UPLOAD_ERR_NO_FILE;
/**
@@ -171,13 +167,6 @@ final class FilesSizeTest extends TestCase
self::assertSame('976.56kB', $validator->getMax());
}
- public function testConstructorShouldRaiseErrorWhenPassedMultipleOptions(): void
- {
- set_error_handler([$this, 'errorHandler'], E_USER_NOTICE);
- new FilesSize(1000, 10000);
- restore_error_handler();
- }
-
/**
* Ensures that the validator returns size infos
*/
@@ -210,13 +199,6 @@ final class FilesSizeTest extends TestCase
self::assertStringContainsString('1588', current($messages));
}
- public function errorHandler(int $errno, string $errstr): void
- {
- if (strstr($errstr, 'deprecated')) {
- $this->multipleOptionsDetected = true;
- }
- }
-
public function testEmptyFileShouldReturnFalseAndDisplayNotFoundMessage(): void
{
$validator = new FilesSize(0);

original_message:
Remove outdated, redundant test that doesn't test anything

Signed-off-by: George Steel <george@net-glue.co.uk>