From cff8bc581f62908028e44eebbdac667fc15c15a9 Mon Sep 17 00:00:00 2001 From: s3b4stian Date: Tue, 23 Mar 2021 15:01:57 +0000 Subject: [PATCH 1/2] align master to b3.0.0 --- .scrutinizer.yml | 2 +- CHANGELOG.md | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 74ce2ea..6ead1df 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -14,7 +14,7 @@ tools: build: environment: - php: 7.1 + php: 8.0 tests: override: - diff --git a/CHANGELOG.md b/CHANGELOG.md index 7066af0..4e035d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,15 +6,19 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [v2.0.1](https://github.com/linna/typed-array/compare/v2.0.0...v2.0.1) - 2019-03-XX +## [v2.0.1](https://github.com/linna/typed-array/compare/v2.0.0...v2.0.1) - 2020-03-23 ### Added - php 7.3 support +- php 7.4 support ### Changed - `.scrutinizer.yml` updated for use phpunit from `vendor` directory - Merge pull request #14 from peter279k/enhance_stuffs with code enhancements +### Removed +- Travis CI usage for test build. + ## [v2.0.0](https://github.com/linna/typed-array/compare/v1.0.5...v2.0.0) - 2018-08-13 ### Changed From 42898a6c81853c1d0052a1b9549fed975baa1cd6 Mon Sep 17 00:00:00 2001 From: s3b4stian Date: Tue, 23 Mar 2021 15:06:04 +0000 Subject: [PATCH 2/2] style fixed, .travis.yml removed --- .travis.yml | 13 ------- README.md | 2 +- .../TypedArrayObject/ClassArrayObject.php | 2 +- tests/ArrayArrayObjectTest.php | 27 +++++++------- tests/BoolArrayObjectTest.php | 27 +++++++------- tests/CallableArrayObjectTest.php | 36 +++++++++++-------- tests/ClassArrayObjectTest.php | 33 +++++++++-------- tests/FloatArrayObjectTest.php | 27 +++++++------- tests/IntArrayObjectTest.php | 27 +++++++------- tests/ObjectArrayObject.php | 29 ++++++++------- tests/StringArrayObjectTest.php | 27 +++++++------- 11 files changed, 132 insertions(+), 118 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 89c464a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: php -php: -- 7.1 -- 7.2 -- 7.3 - -before_script: -- composer install - -script: -- ./vendor/bin/phpstan analyse --level 7 src -- ./vendor/bin/phpunit -- ./vendor/bin/infection --min-msi=75 --min-covered-msi=75 diff --git a/README.md b/README.md index 75c36a1..6681b3d 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@
-[![Build Status](https://travis-ci.org/linna/typed-array.svg?branch=master)](https://travis-ci.org/linna/typed-array) +[![Tests](https://github.com/linna/typed-array/actions/workflows/tests.yml/badge.svg)](https://github.com/linna/typed-array/actions/workflows/tests.yml) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/linna/typed-array/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/linna/typed-array/?branch=master) [![Code Coverage](https://scrutinizer-ci.com/g/linna/typed-array/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/linna/typed-array/?branch=master) [![StyleCI](https://styleci.io/repos/93407083/shield?branch=master&style=flat)](https://styleci.io/repos/93407083) diff --git a/src/Linna/TypedArrayObject/ClassArrayObject.php b/src/Linna/TypedArrayObject/ClassArrayObject.php index 133a1b8..47a5768 100644 --- a/src/Linna/TypedArrayObject/ClassArrayObject.php +++ b/src/Linna/TypedArrayObject/ClassArrayObject.php @@ -37,7 +37,7 @@ class ClassArrayObject extends ArrayObject public function __construct(string $class, array $input = [], int $flags = 0, string $iterator_class = "ArrayIterator") { $this->type = $class; - + if (!\class_exists($class)) { throw new InvalidArgumentException("Type <{$this->type}> provided isn't a class."); } diff --git a/tests/ArrayArrayObjectTest.php b/tests/ArrayArrayObjectTest.php index b3e0a93..5bddd4e 100644 --- a/tests/ArrayArrayObjectTest.php +++ b/tests/ArrayArrayObjectTest.php @@ -43,11 +43,11 @@ public function testSetValueWithValidArgument(): void { $arrayArray = new ArrayArrayObject(); $arrayArray[] = [1,2,3]; - + $this->assertSame(1, $this->count($arrayArray)); $this->assertSame([1,2,3], $arrayArray[0]); } - + /** * Test append value with valid argument. */ @@ -55,11 +55,11 @@ public function testAppendValueWithValidArgument(): void { $arrayArray = new ArrayArrayObject(); $arrayArray->append([1,2,3]); - + $this->assertSame(1, $this->count($arrayArray)); $this->assertSame([1,2,3], $arrayArray[0]); } - + /** * Provide invalid typed arrays. * @@ -70,7 +70,9 @@ public function invalidArrayProvider(): array return [ //[[[1], [2]]], //array [[true, false]], //bool - [[function () {}, function () {}]], //callable + [[function () { + }, function () { + }]], //callable [[1.1, 2.2]], //float [[1, 2]], //int [[(object) ['name' => 'foo'], (object) ['name' => 'bar']]], //object @@ -80,13 +82,13 @@ public function invalidArrayProvider(): array /** * Test new instance with invalid argument. - * + * * @dataProvider invalidArrayProvider */ public function testNewInstanceWithInvalidArgument(array $array): void { $this->expectException(InvalidArgumentException::class); - + $arrayArray = new ArrayArrayObject($array); } @@ -100,7 +102,8 @@ public function invalidValueProvider(): array return [ //[[1]], //array [true], //bool - [function () {}], //callable + [function () { + }], //callable [1.1], //float [1], //int [(object) ['name' => 'foo']], //object @@ -110,26 +113,26 @@ public function invalidValueProvider(): array /** * Test set value with invalid argument. - * + * * @dataProvider invalidValueProvider */ public function testSetValueWithInvalidArgument($value): void { $this->expectException(InvalidArgumentException::class); - + $arrayArray = new ArrayArrayObject(); $arrayArray[] = $value; } /** * Test append value with invalid argument. - * + * * @dataProvider invalidValueProvider */ public function testAppendValueWithInvalidArgument($value): void { $this->expectException(InvalidArgumentException::class); - + $arrayArray = new ArrayArrayObject(); $arrayArray->append($value); } diff --git a/tests/BoolArrayObjectTest.php b/tests/BoolArrayObjectTest.php index ee8c48c..040131e 100644 --- a/tests/BoolArrayObjectTest.php +++ b/tests/BoolArrayObjectTest.php @@ -43,11 +43,11 @@ public function testSetValueWithValidArgument(): void { $boolArray = new BoolArrayObject(); $boolArray[] = false; - + $this->assertSame(1, $this->count($boolArray)); $this->assertSame(false, $boolArray[0]); } - + /** * Test append value with valid argument. */ @@ -55,11 +55,11 @@ public function testAppendValueWithValidArgument(): void { $boolArray = new BoolArrayObject(); $boolArray->append(false); - + $this->assertSame(1, $this->count($boolArray)); $this->assertSame(false, $boolArray[0]); } - + /** * Provide invalid typed arrays. * @@ -70,7 +70,9 @@ public function invalidArrayProvider(): array return [ [[[1], [2]]], //array //[[true, false]], //bool - [[function () {}, function () {}]], //callable + [[function () { + }, function () { + }]], //callable [[1.1, 2.2]], //float [[1, 2]], //int [[(object) ['name' => 'foo'], (object) ['name' => 'bar']]], //object @@ -80,13 +82,13 @@ public function invalidArrayProvider(): array /** * Test new instance with invalid argument. - * + * * @dataProvider invalidArrayProvider */ public function testNewInstanceWithInvalidArgument(array $array): void { $this->expectException(InvalidArgumentException::class); - + $boolArray = new BoolArrayObject($array); } @@ -100,7 +102,8 @@ public function invalidValueProvider(): array return [ [[1]], //array //[true], //bool - [function () {}], //callable + [function () { + }], //callable [1.1], //float [1], //int [(object) ['name' => 'foo']], //object @@ -110,26 +113,26 @@ public function invalidValueProvider(): array /** * Test set value with invalid argument. - * + * * @dataProvider invalidValueProvider */ public function testSetValueWithInvalidArgument($value): void { $this->expectException(InvalidArgumentException::class); - + $boolArray = new BoolArrayObject(); $boolArray[] = $value; } /** * Test append value with invalid argument. - * + * * @dataProvider invalidValueProvider */ public function testAppendValueWithInvalidArgument($value): void { $this->expectException(InvalidArgumentException::class); - + $boolArray = new BoolArrayObject(); $boolArray->append($value); } diff --git a/tests/CallableArrayObjectTest.php b/tests/CallableArrayObjectTest.php index 455de31..bb8102b 100644 --- a/tests/CallableArrayObjectTest.php +++ b/tests/CallableArrayObjectTest.php @@ -33,7 +33,9 @@ public function testNewInstance(): void */ public function testNewInstanceWithValidArgument(): void { - $this->assertInstanceOf(CallableArrayObject::class, (new CallableArrayObject([function($e){return $e+1;}]))); + $this->assertInstanceOf(CallableArrayObject::class, (new CallableArrayObject([function ($e) { + return $e+1; + }]))); } /** @@ -42,24 +44,28 @@ public function testNewInstanceWithValidArgument(): void public function testSetValueWithValidArgument(): void { $callableArray = new CallableArrayObject(); - $callableArray[] = function($e){return $e+1;}; - + $callableArray[] = function ($e) { + return $e+1; + }; + $this->assertSame(1, $this->count($callableArray)); - $this->assertSame(true, is_callable($callableArray[0])); + $this->assertSame(true, \is_callable($callableArray[0])); } - + /** * Test append value with valid argument. */ public function testAppendValueWithValidArgument(): void { $callableArray = new CallableArrayObject(); - $callableArray->append(function($e){return $e+1;}); - + $callableArray->append(function ($e) { + return $e+1; + }); + $this->assertSame(1, $this->count($callableArray)); - $this->assertSame(true, is_callable($callableArray[0])); + $this->assertSame(true, \is_callable($callableArray[0])); } - + /** * Provide invalid typed arrays. * @@ -80,13 +86,13 @@ public function invalidArrayProvider(): array /** * Test new instance with invalid argument. - * + * * @dataProvider invalidArrayProvider */ public function testNewInstanceWithInvalidArgument(array $array): void { $this->expectException(InvalidArgumentException::class); - + $callableArray = new CallableArrayObject($array); } @@ -110,26 +116,26 @@ public function invalidValueProvider(): array /** * Test set value with invalid argument. - * + * * @dataProvider invalidValueProvider */ public function testSetValueWithInvalidArgument($value): void { $this->expectException(InvalidArgumentException::class); - + $callableArray = new CallableArrayObject(); $callableArray[] = $value; } /** * Test append value with invalid argument. - * + * * @dataProvider invalidValueProvider */ public function testAppendValueWithInvalidArgument($value): void { $this->expectException(InvalidArgumentException::class); - + $callableArray = new CallableArrayObject(); $callableArray->append($value); } diff --git a/tests/ClassArrayObjectTest.php b/tests/ClassArrayObjectTest.php index 3b20a4f..650d110 100644 --- a/tests/ClassArrayObjectTest.php +++ b/tests/ClassArrayObjectTest.php @@ -39,7 +39,7 @@ public function testNewInstanceWithValidArgument(): void (new ArrayObject), (new ArrayObject) ]; - + $this->assertInstanceOf(ClassArrayObject::class, (new ClassArrayObject(ArrayObject::class, $array))); } @@ -49,28 +49,28 @@ public function testNewInstanceWithValidArgument(): void public function testSetValueWithValidArgument(): void { $object = new ArrayObject(); - + $classArray = new ClassArrayObject(ArrayObject::class); $classArray[] = $object; - + $this->assertSame(1, $this->count($classArray)); $this->assertSame($object, $classArray[0]); } - + /** * Test append value with valid argument. */ public function testAppendValueWithValidArgument(): void { $object = new ArrayObject(); - + $classArray = new ClassArrayObject(ArrayObject::class); $classArray->append($object); - + $this->assertSame(1, $this->count($classArray)); $this->assertSame($object, $classArray[0]); } - + /** * Provide invalid typed arrays. * @@ -81,7 +81,9 @@ public function invalidArrayProvider(): array return [ [[[1], [2]]], //array [[true, false]], //bool - [[function () {}, function () {}]], //callable + [[function () { + }, function () { + }]], //callable [[1.1, 2.2]], //float [[1, 2]], //int [[(object) ['name' => 'foo'], (object) ['name' => 'bar']]], //object @@ -91,13 +93,13 @@ public function invalidArrayProvider(): array /** * Test new instance with invalid argument. - * + * * @dataProvider invalidArrayProvider */ public function testNewInstanceWithInvalidArgument(array $array): void { $this->expectException(InvalidArgumentException::class); - + $classArray = new ClassArrayObject(ArrayObject::class, $array); } @@ -111,7 +113,8 @@ public function invalidValueProvider(): array return [ [[1]], //array [true], //bool - [function () {}], //callable + [function () { + }], //callable [1.1], //float [1], //int [(object) ['name' => 'foo']], //object @@ -121,26 +124,26 @@ public function invalidValueProvider(): array /** * Test set value with invalid argument. - * + * * @dataProvider invalidValueProvider */ public function testSetValueWithInvalidArgument($value): void { $this->expectException(InvalidArgumentException::class); - + $classArray = new ClassArrayObject(ArrayObject::class); $classArray[] = $value; } /** * Test append value with invalid argument. - * + * * @dataProvider invalidValueProvider */ public function testAppendValueWithInvalidArgument($value): void { $this->expectException(InvalidArgumentException::class); - + $classArray = new ClassArrayObject(ArrayObject::class); $classArray->append($value); } diff --git a/tests/FloatArrayObjectTest.php b/tests/FloatArrayObjectTest.php index af2d4cb..5485250 100644 --- a/tests/FloatArrayObjectTest.php +++ b/tests/FloatArrayObjectTest.php @@ -43,11 +43,11 @@ public function testSetValueWithValidArgument(): void { $floatArray = new FloatArrayObject(); $floatArray[] = 1.1; - + $this->assertSame(1, $this->count($floatArray)); $this->assertSame(1.1, $floatArray[0]); } - + /** * Test append value with valid argument. */ @@ -55,11 +55,11 @@ public function testAppendValueWithValidArgument(): void { $floatArray = new FloatArrayObject(); $floatArray->append(1.1); - + $this->assertSame(1, $this->count($floatArray)); $this->assertSame(1.1, $floatArray[0]); } - + /** * Provide invalid typed arrays. * @@ -70,7 +70,9 @@ public function invalidArrayProvider(): array return [ [[[1], [2]]], //array [[true, false]], //bool - [[function () {}, function () {}]], //callable + [[function () { + }, function () { + }]], //callable //[[1.1, 2.2]], //float [[1, 2]], //int [[(object) ['name' => 'foo'], (object) ['name' => 'bar']]], //object @@ -80,13 +82,13 @@ public function invalidArrayProvider(): array /** * Test new instance with invalid argument. - * + * * @dataProvider invalidArrayProvider */ public function testNewInstanceWithInvalidArgument(array $array): void { $this->expectException(InvalidArgumentException::class); - + $floatArray = new FloatArrayObject($array); } @@ -100,7 +102,8 @@ public function invalidValueProvider(): array return [ [[1]], //array [true], //bool - [function () {}], //callable + [function () { + }], //callable //[1.1], //float [1], //int [(object) ['name' => 'foo']], //object @@ -110,26 +113,26 @@ public function invalidValueProvider(): array /** * Test set value with invalid argument. - * + * * @dataProvider invalidValueProvider */ public function testSetValueWithInvalidArgument($value): void { $this->expectException(InvalidArgumentException::class); - + $floatArray = new FloatArrayObject(); $floatArray[] = $value; } /** * Test append value with invalid argument. - * + * * @dataProvider invalidValueProvider */ public function testAppendValueWithInvalidArgument($value): void { $this->expectException(InvalidArgumentException::class); - + $floatArray = new FloatArrayObject(); $floatArray->append($value); } diff --git a/tests/IntArrayObjectTest.php b/tests/IntArrayObjectTest.php index 6eda2af..9a70881 100644 --- a/tests/IntArrayObjectTest.php +++ b/tests/IntArrayObjectTest.php @@ -43,11 +43,11 @@ public function testSetValueWithValidArgument(): void { $intArray = new IntArrayObject(); $intArray[] = 1; - + $this->assertSame(1, $this->count($intArray)); $this->assertSame(1, $intArray[0]); } - + /** * Test append value with valid argument. */ @@ -55,11 +55,11 @@ public function testAppendValueWithValidArgument(): void { $intArray = new IntArrayObject(); $intArray->append(1); - + $this->assertSame(1, $this->count($intArray)); $this->assertSame(1, $intArray[0]); } - + /** * Provide invalid typed arrays. * @@ -70,7 +70,9 @@ public function invalidArrayProvider(): array return [ [[[1], [2]]], //array [[true, false]], //bool - [[function () {}, function () {}]], //callable + [[function () { + }, function () { + }]], //callable [[1.1, 2.2]], //float //[[1, 2]], //int [[(object) ['name' => 'foo'], (object) ['name' => 'bar']]], //object @@ -80,13 +82,13 @@ public function invalidArrayProvider(): array /** * Test new instance with invalid argument. - * + * * @dataProvider invalidArrayProvider */ public function testNewInstanceWithInvalidArgument(array $array): void { $this->expectException(InvalidArgumentException::class); - + $intArray = new IntArrayObject($array); } @@ -100,7 +102,8 @@ public function invalidValueProvider(): array return [ [[1]], //array [true], //bool - [function () {}], //callable + [function () { + }], //callable [1.1], //float //[1], //int [(object) ['name' => 'foo']], //object @@ -110,26 +113,26 @@ public function invalidValueProvider(): array /** * Test set value with invalid argument. - * + * * @dataProvider invalidValueProvider */ public function testSetValueWithInvalidArgument($value): void { $this->expectException(InvalidArgumentException::class); - + $intArray = new IntArrayObject(); $intArray[] = $value; } /** * Test append value with invalid argument. - * + * * @dataProvider invalidValueProvider */ public function testAppendValueWithInvalidArgument($value): void { $this->expectException(InvalidArgumentException::class); - + $intArray = new IntArrayObject(); $intArray->append($value); } diff --git a/tests/ObjectArrayObject.php b/tests/ObjectArrayObject.php index 44271de..3e56607 100644 --- a/tests/ObjectArrayObject.php +++ b/tests/ObjectArrayObject.php @@ -42,14 +42,14 @@ public function testNewInstanceWithValidArgument(): void public function testSetValueWithValidArgument(): void { $object = (object)["name" => "test"]; - + $objectArray = new ObjectArrayObject(); $objectArray[] = $object; - + $this->assertSame(1, $this->count($objectArray)); $this->assertSame($object, $objectArray[0]); } - + /** * Test append value with valid argument. */ @@ -57,11 +57,11 @@ public function testAppendValueWithValidArgument(): void { $objectArray = new ObjectArrayObject(); $objectArray->append($object); - + $this->assertSame(1, $this->count($objectArray)); $this->assertSame($object, $objectArray[0]); } - + /** * Provide invalid typed arrays. * @@ -72,7 +72,9 @@ public function invalidArrayProvider(): array return [ [[[1], [2]]], //array [[true, false]], //bool - [[function () {}, function () {}]], //callable + [[function () { + }, function () { + }]], //callable [[1.1, 2.2]], //float [[1, 2]], //int //[[(object) ['name' => 'foo'], (object) ['name' => 'bar']]], //object @@ -82,13 +84,13 @@ public function invalidArrayProvider(): array /** * Test new instance with invalid argument. - * + * * @dataProvider invalidArrayProvider */ public function testNewInstanceWithInvalidArgument(array $array): void { $this->expectException(InvalidArgumentException::class); - + $objectArray = new ObjectArrayObject($array); } @@ -102,7 +104,8 @@ public function invalidValueProvider(): array return [ [[1]], //array [true], //bool - [function () {}], //callable + [function () { + }], //callable [1.1], //float [1], //int //[(object) ['name' => 'foo']], //object @@ -112,26 +115,26 @@ public function invalidValueProvider(): array /** * Test set value with invalid argument. - * + * * @dataProvider invalidValueProvider */ public function testSetValueWithInvalidArgument($value): void { $this->expectException(InvalidArgumentException::class); - + $objectArray = new ObjectArrayObject(); $objectArray[] = $value; } /** * Test append value with invalid argument. - * + * * @dataProvider invalidValueProvider */ public function testAppendValueWithInvalidArgument($value): void { $this->expectException(InvalidArgumentException::class); - + $objectArray = new ObjectArrayObject(); $objectArray->append($value); } diff --git a/tests/StringArrayObjectTest.php b/tests/StringArrayObjectTest.php index 33f5c0d..0a78372 100644 --- a/tests/StringArrayObjectTest.php +++ b/tests/StringArrayObjectTest.php @@ -43,11 +43,11 @@ public function testSetValueWithValidArgument(): void { $stringArray = new StringArrayObject(); $stringArray[] = 'a'; - + $this->assertSame(1, $this->count($stringArray)); $this->assertSame('a', $stringArray[0]); } - + /** * Test append value with valid argument. */ @@ -55,11 +55,11 @@ public function testAppendValueWithValidArgument(): void { $stringArray = new StringArrayObject(); $stringArray->append('a'); - + $this->assertSame(1, $this->count($stringArray)); $this->assertSame('a', $stringArray[0]); } - + /** * Provide invalid typed arrays. * @@ -70,7 +70,9 @@ public function invalidArrayProvider(): array return [ [[[1], [2]]], //array [[true, false]], //bool - [[function () {}, function () {}]], //callable + [[function () { + }, function () { + }]], //callable [[1.1, 2.2]], //float [[1, 2]], //int [[(object) ['name' => 'foo'], (object) ['name' => 'bar']]], //object @@ -80,13 +82,13 @@ public function invalidArrayProvider(): array /** * Test new instance with invalid argument. - * + * * @dataProvider invalidArrayProvider */ public function testNewInstanceWithInvalidArgument(array $array): void { $this->expectException(InvalidArgumentException::class); - + $stringArray = new StringArrayObject($array); } @@ -100,7 +102,8 @@ public function invalidValueProvider(): array return [ [[1]], //array [true], //bool - [function () {}], //callable + [function () { + }], //callable [1.1], //float [1], //int [(object) ['name' => 'foo']], //object @@ -110,26 +113,26 @@ public function invalidValueProvider(): array /** * Test set value with invalid argument. - * + * * @dataProvider invalidValueProvider */ public function testSetValueWithInvalidArgument($value): void { $this->expectException(InvalidArgumentException::class); - + $stringArray = new StringArrayObject(); $stringArray[] = $value; } /** * Test append value with invalid argument. - * + * * @dataProvider invalidValueProvider */ public function testAppendValueWithInvalidArgument($value): void { $this->expectException(InvalidArgumentException::class); - + $stringArray = new StringArrayObject(); $stringArray->append($value); }