From a5104531a9bc7ab87171beda808d4ebd36b932ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thiemo=20M=C3=A4ttig?= Date: Thu, 28 Sep 2017 11:25:44 +0200 Subject: [PATCH 01/51] Fix StringParser::parse not throwing expected ParseException --- src/ValueParsers/StringParser.php | 5 ++--- tests/ValueParsers/StringParserTest.php | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ValueParsers/StringParser.php b/src/ValueParsers/StringParser.php index d07f91f..f7b408b 100644 --- a/src/ValueParsers/StringParser.php +++ b/src/ValueParsers/StringParser.php @@ -3,7 +3,6 @@ namespace ValueParsers; use DataValues\StringValue; -use InvalidArgumentException; use ValueParsers\Normalizers\NullStringNormalizer; use ValueParsers\Normalizers\StringNormalizer; @@ -34,12 +33,12 @@ public function __construct( StringNormalizer $normalizer = null ) { * * @param string $value * - * @throws InvalidArgumentException if $value is not a string + * @throws ParseException if the provided value is not a string * @return StringValue */ public function parse( $value ) { if ( !is_string( $value ) ) { - throw new InvalidArgumentException( 'Parameter $value must be a string' ); + throw new ParseException( 'Parameter $value must be a string' ); } $value = $this->normalizer->normalize( $value ); diff --git a/tests/ValueParsers/StringParserTest.php b/tests/ValueParsers/StringParserTest.php index 42b90bc..2a67f0a 100644 --- a/tests/ValueParsers/StringParserTest.php +++ b/tests/ValueParsers/StringParserTest.php @@ -5,6 +5,7 @@ use DataValues\DataValue; use DataValues\StringValue; use ValueParsers\Normalizers\StringNormalizer; +use ValueParsers\ParseException; use ValueParsers\StringParser; /** @@ -56,7 +57,7 @@ public function nonStringProvider() { */ public function testGivenNonString_parseThrowsException( $input ) { $parser = new StringParser(); - $this->setExpectedException( 'InvalidArgumentException' ); + $this->setExpectedException( ParseException::class ); $parser->parse( $input ); } From a3c1c50784a804848f0988690b0ac554b0088cbb Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Thu, 16 Aug 2018 10:17:13 +0200 Subject: [PATCH 02/51] Update README.md [skip ci] --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 3503808..86d8361 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,10 @@ employees for the [Wikidata project](https://wikidata.org/). * Removed the `DATAVALUES_COMMON_VERSION` constant * The `StringFormatter` constructor does not accept options any more +### 0.4.2 (2018-08-16) + +* The component can now be installed together with DataValues 2.x + ### 0.4.1 (2017-08-09) * Fixed version number not updated before. From 76ad7573fe00304731c591bce9fe86c9ee0fcabd Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Thu, 16 Aug 2018 10:19:14 +0200 Subject: [PATCH 03/51] Also test against PHP 7.2 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 74748b6..b40890f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ php: - 5.6 - 7 - 7.1 + - 7.2 - hhvm sudo: false From 86a85597f7065da4a254badcc37f55219f6e80f7 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 17 May 2019 07:25:35 +0200 Subject: [PATCH 04/51] Update .scrutinizer.yml --- .scrutinizer.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index d3e813a..18ed129 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -3,7 +3,6 @@ inherit: true tools: external_code_coverage: true - php_code_coverage: true php_code_sniffer: true php_cpd: true php_cs_fixer: true From d2ee49bbc80e59d9180b2f44029f13635e060434 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 17 May 2019 07:25:47 +0200 Subject: [PATCH 05/51] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b40890f..63ee174 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ php: - 7 - 7.1 - 7.2 - - hhvm + - 7.3 sudo: false From 95a0b2428501b75fe89b18a38d3e58bffdceb83b Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Mon, 29 Jul 2019 20:45:39 +0200 Subject: [PATCH 06/51] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 86d8361..7a40a59 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,11 @@ The recommended way to use this library is via [Composer](http://getcomposer.org To add this package as a local, per-project dependency to your project, simply add a dependency on `data-values/common` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on -version 1.0 of this package: +version 0.4.2 of this package: { "require": { - "data-values/common": "^1.0.0" + "data-values/common": "^0.4.2" } } From 7ad3f02f2a2c6eb97fbc754784fedf9c50a3d4f2 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Mon, 29 Jul 2019 20:46:13 +0200 Subject: [PATCH 07/51] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 63ee174..e5104fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ install: travis_retry composer install script: composer ci after_success: - - if [[ "`phpenv version-name`" != "7.1" ]]; then exit 0; fi + - if [[ "`phpenv version-name`" != "7.3" ]]; then exit 0; fi - vendor/bin/phpunit --coverage-clover coverage.clover - wget https://scrutinizer-ci.com/ocular.phar - php ocular.phar code-coverage:upload --format=php-clover coverage.clover From 2edfb55e7047ddb036db59fa4e907590169ed4f4 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Thu, 19 Sep 2019 12:42:21 +0200 Subject: [PATCH 08/51] Do not exclude tests directory from releases Some of the code in there is package public See https://github.com/DataValues/Common/blob/master/composer.json#L47 --- .gitattributes | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index dcd303f..3f150e3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,4 +6,3 @@ composer.json export-ignore phpcs.xml export-ignore phpunit.xml.dist export-ignore -tests export-ignore From 00d7acad5d15f3815fb785905ef31658b3123c23 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 20 Sep 2019 14:30:32 +0200 Subject: [PATCH 09/51] Explicitly use local PHPUnit --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 755a727..b6cee92 100644 --- a/composer.json +++ b/composer.json @@ -54,7 +54,7 @@ "test": [ "composer validate --no-interaction", "covers-validator", - "phpunit" + "vendor/bin/phpunit" ], "ci": [ "@cs", From 9f3979f873e3b315f202f31bf80bb6c24ec564c5 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 20 Sep 2019 14:34:08 +0200 Subject: [PATCH 10/51] FQNs for @covers tags --- tests/DataValues/MonolingualTextValueTest.php | 2 +- tests/DataValues/MultilingualTextValueTest.php | 2 +- .../Exceptions/MismatchingDataValueTypeExceptionTest.php | 2 +- tests/ValueFormatters/StringFormatterTest.php | 2 +- tests/ValueParsers/BoolParserTest.php | 4 ++-- tests/ValueParsers/DispatchingValueParserTest.php | 2 +- tests/ValueParsers/FloatParserTest.php | 4 ++-- tests/ValueParsers/IntParserTest.php | 4 ++-- tests/ValueParsers/Normalizers/NullStringNormalizerTest.php | 2 +- .../ValueParsers/Normalizers/TrimmingStringNormalizerTest.php | 2 +- tests/ValueParsers/NullParserTest.php | 2 +- tests/ValueParsers/StringParserTest.php | 2 +- tests/ValueParsers/StringValueParserTest.php | 2 +- 13 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/DataValues/MonolingualTextValueTest.php b/tests/DataValues/MonolingualTextValueTest.php index 38e69fc..3891208 100644 --- a/tests/DataValues/MonolingualTextValueTest.php +++ b/tests/DataValues/MonolingualTextValueTest.php @@ -6,7 +6,7 @@ use DataValues\MonolingualTextValue; /** - * @covers DataValues\MonolingualTextValue + * @covers \DataValues\MonolingualTextValue * * @since 0.1 * diff --git a/tests/DataValues/MultilingualTextValueTest.php b/tests/DataValues/MultilingualTextValueTest.php index 89f3760..192caf7 100644 --- a/tests/DataValues/MultilingualTextValueTest.php +++ b/tests/DataValues/MultilingualTextValueTest.php @@ -7,7 +7,7 @@ use DataValues\MultilingualTextValue; /** - * @covers DataValues\MultilingualTextValue + * @covers \DataValues\MultilingualTextValue * * @since 0.1 * diff --git a/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php b/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php index 44af779..231fe5d 100644 --- a/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php +++ b/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php @@ -7,7 +7,7 @@ use ValueFormatters\Exceptions\MismatchingDataValueTypeException; /** - * @covers ValueFormatters\Exceptions\MismatchingDataValueTypeException + * @covers \ValueFormatters\Exceptions\MismatchingDataValueTypeException * * @group ValueFormatters * @group DataValueExtensions diff --git a/tests/ValueFormatters/StringFormatterTest.php b/tests/ValueFormatters/StringFormatterTest.php index bf90701..a227a52 100644 --- a/tests/ValueFormatters/StringFormatterTest.php +++ b/tests/ValueFormatters/StringFormatterTest.php @@ -8,7 +8,7 @@ use ValueFormatters\StringFormatter; /** - * @covers ValueFormatters\StringFormatter + * @covers \ValueFormatters\StringFormatter * * @group ValueFormatters * @group DataValueExtensions diff --git a/tests/ValueParsers/BoolParserTest.php b/tests/ValueParsers/BoolParserTest.php index e365c76..f53fce8 100644 --- a/tests/ValueParsers/BoolParserTest.php +++ b/tests/ValueParsers/BoolParserTest.php @@ -6,8 +6,8 @@ use ValueParsers\BoolParser; /** - * @covers ValueParsers\BoolParser - * @covers ValueParsers\StringValueParser + * @covers \ValueParsers\BoolParser + * @covers \ValueParsers\StringValueParser * * @group ValueParsers * @group DataValueExtensions diff --git a/tests/ValueParsers/DispatchingValueParserTest.php b/tests/ValueParsers/DispatchingValueParserTest.php index b328660..93c214d 100644 --- a/tests/ValueParsers/DispatchingValueParserTest.php +++ b/tests/ValueParsers/DispatchingValueParserTest.php @@ -10,7 +10,7 @@ use ValueParsers\ValueParser; /** - * @covers ValueParsers\DispatchingValueParser + * @covers \ValueParsers\DispatchingValueParser * * @group DataValue * @group DataValueExtensions diff --git a/tests/ValueParsers/FloatParserTest.php b/tests/ValueParsers/FloatParserTest.php index c89d906..2983aee 100644 --- a/tests/ValueParsers/FloatParserTest.php +++ b/tests/ValueParsers/FloatParserTest.php @@ -6,8 +6,8 @@ use ValueParsers\FloatParser; /** - * @covers ValueParsers\FloatParser - * @covers ValueParsers\StringValueParser + * @covers \ValueParsers\FloatParser + * @covers \ValueParsers\StringValueParser * * @group ValueParsers * @group DataValueExtensions diff --git a/tests/ValueParsers/IntParserTest.php b/tests/ValueParsers/IntParserTest.php index eab8d89..46cc94d 100644 --- a/tests/ValueParsers/IntParserTest.php +++ b/tests/ValueParsers/IntParserTest.php @@ -6,8 +6,8 @@ use ValueParsers\IntParser; /** - * @covers ValueParsers\IntParser - * @covers ValueParsers\StringValueParser + * @covers \ValueParsers\IntParser + * @covers \ValueParsers\StringValueParser * * @group ValueParsers * @group DataValueExtensions diff --git a/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php b/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php index 72b9956..c58fd2e 100644 --- a/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php +++ b/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php @@ -8,7 +8,7 @@ use ValueParsers\Normalizers\NullStringNormalizer; /** - * @covers ValueParsers\Normalizers\NullStringNormalizer + * @covers \ValueParsers\Normalizers\NullStringNormalizer * * @group ValueParsers * @group DataValueExtensions diff --git a/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php b/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php index 3d69681..dc13a09 100644 --- a/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php +++ b/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php @@ -7,7 +7,7 @@ use ValueParsers\Normalizers\TrimmingStringNormalizer; /** - * @covers ValueParsers\Normalizers\TrimmingStringNormalizer + * @covers \ValueParsers\Normalizers\TrimmingStringNormalizer * * @group ValueParsers * @group DataValueExtensions diff --git a/tests/ValueParsers/NullParserTest.php b/tests/ValueParsers/NullParserTest.php index fbea499..c17eb58 100644 --- a/tests/ValueParsers/NullParserTest.php +++ b/tests/ValueParsers/NullParserTest.php @@ -7,7 +7,7 @@ use ValueParsers\ValueParser; /** - * @covers ValueParsers\NullParser + * @covers \ValueParsers\NullParser * * @group ValueParsers * @group DataValueExtensions diff --git a/tests/ValueParsers/StringParserTest.php b/tests/ValueParsers/StringParserTest.php index 47f01be..b72d15b 100644 --- a/tests/ValueParsers/StringParserTest.php +++ b/tests/ValueParsers/StringParserTest.php @@ -8,7 +8,7 @@ use ValueParsers\StringParser; /** - * @covers ValueParsers\StringParser + * @covers \ValueParsers\StringParser * * @group ValueParsers * @group DataValueExtensions diff --git a/tests/ValueParsers/StringValueParserTest.php b/tests/ValueParsers/StringValueParserTest.php index 5fcd989..7e05608 100644 --- a/tests/ValueParsers/StringValueParserTest.php +++ b/tests/ValueParsers/StringValueParserTest.php @@ -6,7 +6,7 @@ use ValueParsers\StringValueParser; /** - * @covers ValueParsers\StringValueParser + * @covers \ValueParsers\StringValueParser * * @group ValueParsers * @group DataValueExtensions From b8c0412a85c67727684c55846c8e1417b628b5a5 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 20 Sep 2019 14:37:17 +0200 Subject: [PATCH 11/51] Make tests package private Allows for https://github.com/DataValues/Common/pull/84 Wikibase Repo has 3 usages of StringValueParserTest: https://github.com/wikimedia/mediawiki-extensions-Wikibase/search?q=StringValueParserTest These can easily be fixed by using a copy of the class (or better yet: refactoring away from this inheritance abuse pattern). --- README.md | 3 ++- composer.json | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7a40a59..e462a6c 100644 --- a/README.md +++ b/README.md @@ -57,9 +57,10 @@ employees for the [Wikidata project](https://wikidata.org/). ### 1.0.0 (dev) -* Added `TrimmingStringNormalizer` * Removed the `DATAVALUES_COMMON_VERSION` constant +* Classes in the `ValueParsers\Test` namespace are now package private. Notably `ValueParserTestBase` and `StringValueParserTest` * The `StringFormatter` constructor does not accept options any more +* Added `TrimmingStringNormalizer` ### 0.4.2 (2018-08-16) diff --git a/composer.json b/composer.json index 755a727..ac8cdb7 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,9 @@ "DataValues\\": "src/DataValues/", "ValueFormatters\\": "src/ValueFormatters/", "ValueParsers\\": "src/ValueParsers/" - }, + } + }, + "autoload-dev": { "classmap": [ "tests/ValueParsers" ] From 6702b0465d62716880efa7a6c59285b05f91bb71 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Fri, 25 Sep 2020 15:36:52 +0200 Subject: [PATCH 12/51] =?UTF-8?q?Don=E2=80=99t=20declare=20support=20for?= =?UTF-8?q?=20unsupported=20PHP=20versions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PHP upstream doesn’t support any versions older than 7.2. (In fact even 7.2 is barely supported anymore, but we still expect to use it in Wikimedia production for a while, so the library should stay compatible for the time being.) --- .travis.yml | 4 ---- README.md | 1 + composer.json | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index e5104fa..bd64dfb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,10 +3,6 @@ language: php dist: trusty php: - - 5.5 - - 5.6 - - 7 - - 7.1 - 7.2 - 7.3 diff --git a/README.md b/README.md index e462a6c..a5bde67 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ employees for the [Wikidata project](https://wikidata.org/). * Classes in the `ValueParsers\Test` namespace are now package private. Notably `ValueParserTestBase` and `StringValueParserTest` * The `StringFormatter` constructor does not accept options any more * Added `TrimmingStringNormalizer` +* Updated minimal required PHP version from 5.5.9 to 7.2 ### 0.4.2 (2018-08-16) diff --git a/composer.json b/composer.json index 6025a0c..cf5779f 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "irc": "irc://irc.freenode.net/wikidata" }, "require": { - "php": ">=5.5.9", + "php": ">=7.2.0", "data-values/data-values": "~2.0|~1.0|~0.1", "data-values/interfaces": "~0.2.0" }, From a9ef75f215fd077ee159b99c714a697ace185382 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Fri, 25 Sep 2020 15:38:04 +0200 Subject: [PATCH 13/51] Update PHPUnit, DataValues and Interfaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a lot of changes at once, but I don’t think they can be split. The most important changes are: * The DataValueTest class was removed from DataValues. The release notes advise to “refactor away the bad design”, so I tried to rewrite the tests in a way that makes sense to me: instead of having one test per method (where many tests will end up calling other methods anyways, e. g. most test methods will also effectively test the constructor), test scenarios of how methods might be used in conjunction, e. g. serialize+unserialize. * The ValueFormatterTestBase class was removed from Interfaces. Its use can be substituted in the individual test classes relatively easily. * PHPUnit_Framework_TestCase is now PHPUnit\Framework\TestCase. PHPUnit_Framework_MockObject_Matcher_Invocation seems to have no replacement that’s not marked @internal, so leave that parameter untyped. * getMock() is now createMock(). * @expectedException or setExpectedException() is now expectException(). --- composer.json | 8 +- tests/DataValues/MonolingualTextValueTest.php | 69 +++++------ .../DataValues/MultilingualTextValueTest.php | 117 +++++++----------- .../MismatchingDataValueTypeExceptionTest.php | 4 +- tests/ValueFormatters/StringFormatterTest.php | 22 ++-- .../DispatchingValueParserTest.php | 18 +-- .../Normalizers/NullStringNormalizerTest.php | 6 +- .../TrimmingStringNormalizerTest.php | 7 +- tests/ValueParsers/StringParserTest.php | 8 +- tests/ValueParsers/ValueParserTestBase.php | 6 +- 10 files changed, 110 insertions(+), 155 deletions(-) diff --git a/composer.json b/composer.json index cf5779f..7fa44a4 100644 --- a/composer.json +++ b/composer.json @@ -24,12 +24,12 @@ }, "require": { "php": ">=7.2.0", - "data-values/data-values": "~2.0|~1.0|~0.1", - "data-values/interfaces": "~0.2.0" + "data-values/data-values": "~3.0|~2.0|~1.0|~0.1", + "data-values/interfaces": "~1.0|~0.2.0" }, "require-dev": { - "ockcyp/covers-validator": "~0.4", - "phpunit/phpunit": "~4.8", + "ockcyp/covers-validator": "~1.2", + "phpunit/phpunit": "~8.0", "wikibase/wikibase-codesniffer": "^0.1.0" }, "extra": { diff --git a/tests/DataValues/MonolingualTextValueTest.php b/tests/DataValues/MonolingualTextValueTest.php index 3891208..73c4b7e 100644 --- a/tests/DataValues/MonolingualTextValueTest.php +++ b/tests/DataValues/MonolingualTextValueTest.php @@ -4,6 +4,8 @@ use DataValues\IllegalValueException; use DataValues\MonolingualTextValue; +use Exception; +use PHPUnit\Framework\TestCase; /** * @covers \DataValues\MonolingualTextValue @@ -16,22 +18,38 @@ * @license GPL-2.0+ * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ -class MonolingualTextValueTest extends DataValueTest { +class MonolingualTextValueTest extends TestCase { + + public function testGetters() { + $value = new MonolingualTextValue( 'en', 'foo' ); + $this->assertSame( 'monolingualtext', $value->getType() ); + $this->assertSame( 'enfoo', $value->getSortKey() ); + $this->assertSame( 'foo', $value->getText() ); + $this->assertSame( 'en', $value->getLanguageCode() ); + } + + public function testArrayAndEquals() { + $value = new MonolingualTextValue( 'en', 'foo' ); + $array = $value->getArrayValue(); + $value2 = MonolingualTextValue::newFromArray( $array ); + $this->assertTrue( $value->equals( $value2 ) ); + $this->assertEquals( $value, $value2 ); + } + + public function testSerialize() { + $value = new MonolingualTextValue( 'en', 'foo' ); + $serialization = serialize( $value ); + $value2 = unserialize( $serialization ); + $this->assertEquals( $value, $value2 ); + } /** - * @see DataValueTest::getClass - * - * @return string + * @dataProvider invalidConstructorArgumentsProvider */ - public function getClass() { - return MonolingualTextValue::class; - } + public function testConstructorWithInvalidArguments( $languageCode, $text ) { + $this->expectException( Exception::class ); - public function validConstructorArgumentsProvider() { - return [ - [ 'en', 'foo' ], - [ 'en', ' foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz ' ], - ]; + $dataItem = new MonolingualTextValue( $languageCode, $text ); } public function invalidConstructorArgumentsProvider() { @@ -49,17 +67,11 @@ public function invalidConstructorArgumentsProvider() { ]; } - public function testNewFromArray() { - $array = [ 'text' => 'foo', 'language' => 'en' ]; - $value = MonolingualTextValue::newFromArray( $array ); - $this->assertSame( $array, $value->getArrayValue() ); - } - /** * @dataProvider invalidArrayProvider */ public function testNewFromArrayWithInvalidArray( array $array ) { - $this->setExpectedException( IllegalValueException::class ); + $this->expectException( IllegalValueException::class ); MonolingualTextValue::newFromArray( $array ); } @@ -74,23 +86,4 @@ public function invalidArrayProvider() { ]; } - public function testGetSortKey() { - $value = new MonolingualTextValue( 'en', 'foo' ); - $this->assertSame( 'enfoo', $value->getSortKey() ); - } - - /** - * @dataProvider instanceProvider - */ - public function testGetText( MonolingualTextValue $text, array $arguments ) { - $this->assertEquals( $arguments[1], $text->getText() ); - } - - /** - * @dataProvider instanceProvider - */ - public function testGetLanguageCode( MonolingualTextValue $text, array $arguments ) { - $this->assertEquals( $arguments[0], $text->getLanguageCode() ); - } - } diff --git a/tests/DataValues/MultilingualTextValueTest.php b/tests/DataValues/MultilingualTextValueTest.php index 192caf7..f9ac1f0 100644 --- a/tests/DataValues/MultilingualTextValueTest.php +++ b/tests/DataValues/MultilingualTextValueTest.php @@ -5,6 +5,8 @@ use DataValues\IllegalValueException; use DataValues\MonolingualTextValue; use DataValues\MultilingualTextValue; +use Exception; +use PHPUnit\Framework\TestCase; /** * @covers \DataValues\MultilingualTextValue @@ -17,36 +19,52 @@ * @license GPL-2.0+ * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ -class MultilingualTextValueTest extends DataValueTest { +class MultilingualTextValueTest extends TestCase { + + public function testGetters() { + $monolingualTextValue1 = new MonolingualTextValue( 'en', 'foo' ); + $monolingualTextValue2 = new MonolingualTextValue( 'de', 'foo' ); + $value = new MultilingualTextValue( [ $monolingualTextValue1, $monolingualTextValue2 ] ); + $this->assertSame( 'multilingualtext', $value->getType() ); + $this->assertSame( 'enfoo', $value->getSortKey() ); + $this->assertSame( + [ 'en' => $monolingualTextValue1, 'de' => $monolingualTextValue2 ], + $value->getTexts() + ); + } + + public function testGetters_empty() { + $value = new MultilingualTextValue( [] ); + $this->assertSame( '', $value->getSortKey() ); + $this->assertSame( [], $value->getTexts() ); + } + + public function testArrayAndEquals() { + $monolingualTextValue1 = new MonolingualTextValue( 'en', 'foo' ); + $monolingualTextValue2 = new MonolingualTextValue( 'de', 'foo' ); + $value = new MultilingualTextValue( [ $monolingualTextValue1, $monolingualTextValue2 ] ); + $array = $value->getArrayValue(); + $value2 = MultilingualTextValue::newFromArray( $array ); + $this->assertTrue( $value->equals( $value2 ) ); + $this->assertEquals( $value, $value2 ); + } + + public function testSerialize() { + $monolingualTextValue1 = new MonolingualTextValue( 'en', 'foo' ); + $monolingualTextValue2 = new MonolingualTextValue( 'de', 'foo' ); + $value = new MultilingualTextValue( [ $monolingualTextValue1, $monolingualTextValue2 ] ); + $serialization = serialize( $value ); + $value2 = unserialize( $serialization ); + $this->assertEquals( $value, $value2 ); + } /** - * @see DataValueTest::getClass - * - * @return string + * @dataProvider invalidConstructorArgumentsProvider */ - public function getClass() { - return MultilingualTextValue::class; - } + public function testConstructorWithInvalidArguments( $monolingualValues ) { + $this->expectException( Exception::class ); - public function validConstructorArgumentsProvider() { - return [ - [ [] ], - [ [ - new MonolingualTextValue( 'en', 'foo' ), - ] ], - [ [ - new MonolingualTextValue( 'en', 'foo' ), - new MonolingualTextValue( 'de', 'foo' ), - ] ], - [ [ - new MonolingualTextValue( 'en', 'foo' ), - new MonolingualTextValue( 'de', 'bar' ), - ] ], - [ [ - new MonolingualTextValue( 'en', 'foo' ), - new MonolingualTextValue( 'de', ' foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz ' ), - ] ], - ]; + $dataItem = new MultilingualTextValue( $monolingualValues ); } public function invalidConstructorArgumentsProvider() { @@ -81,17 +99,11 @@ public function invalidConstructorArgumentsProvider() { ]; } - public function testNewFromArray() { - $array = [ [ 'text' => 'foo', 'language' => 'en' ] ]; - $value = MultilingualTextValue::newFromArray( $array ); - $this->assertSame( $array, $value->getArrayValue() ); - } - /** * @dataProvider invalidArrayProvider */ public function testNewFromArrayWithInvalidArray( array $array ) { - $this->setExpectedException( IllegalValueException::class ); + $this->expectException( IllegalValueException::class ); MultilingualTextValue::newFromArray( $array ); } @@ -104,43 +116,4 @@ public function invalidArrayProvider() { ]; } - /** - * @dataProvider getSortKeyProvider - */ - public function testGetSortKey( array $monolingualValues, $expected ) { - $value = new MultilingualTextValue( $monolingualValues ); - $this->assertSame( $expected, $value->getSortKey() ); - } - - public function getSortKeyProvider() { - return [ - [ [], '' ], - [ [ - new MonolingualTextValue( 'en', 'foo' ), - ], 'enfoo' ], - [ [ - new MonolingualTextValue( 'en', 'foo' ), - new MonolingualTextValue( 'de', 'bar' ), - ], 'enfoo' ], - ]; - } - - /** - * @dataProvider instanceProvider - */ - public function testGetTexts( MultilingualTextValue $texts, array $arguments ) { - $actual = $texts->getTexts(); - - $this->assertInternalType( 'array', $actual ); - $this->assertContainsOnlyInstancesOf( MonolingualTextValue::class, $actual ); - $this->assertEquals( $arguments[0], array_values( $actual ) ); - } - - /** - * @dataProvider instanceProvider - */ - public function testGetValue( MultilingualTextValue $texts, array $arguments ) { - $this->assertInstanceOf( $this->getClass(), $texts->getValue() ); - } - } diff --git a/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php b/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php index 231fe5d..e963d8e 100644 --- a/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php +++ b/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php @@ -3,7 +3,7 @@ namespace ValueFormatters\Tests\Exceptions; use Exception; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; use ValueFormatters\Exceptions\MismatchingDataValueTypeException; /** @@ -16,7 +16,7 @@ * @author Katie Filbert < aude.wiki@gmail.com > * @author Thiemo Kreuz */ -class MismatchingDataValueTypeExceptionTest extends PHPUnit_Framework_TestCase { +class MismatchingDataValueTypeExceptionTest extends TestCase { /** * @dataProvider constructorProvider diff --git a/tests/ValueFormatters/StringFormatterTest.php b/tests/ValueFormatters/StringFormatterTest.php index a227a52..9b664c4 100644 --- a/tests/ValueFormatters/StringFormatterTest.php +++ b/tests/ValueFormatters/StringFormatterTest.php @@ -4,7 +4,7 @@ use DataValues\StringValue; use InvalidArgumentException; -use ValueFormatters\FormatterOptions; +use PHPUnit\Framework\TestCase; use ValueFormatters\StringFormatter; /** @@ -16,22 +16,14 @@ * @license GPL-2.0+ * @author Katie Filbert < aude.wiki@gmail.com > */ -class StringFormatterTest extends ValueFormatterTestBase { +class StringFormatterTest extends TestCase { - /** - * @see ValueFormatterTestBase::getInstance - * - * @param FormatterOptions|null $options - * - * @return StringFormatter - */ - protected function getInstance( FormatterOptions $options = null ) { - return new StringFormatter( $options ); + /** @dataProvider validProvider */ + public function testValidFormat( StringValue $value, string $expected ) { + $formatter = new StringFormatter(); + $this->assertSame( $expected, $formatter->format( $value ) ); } - /** - * @see ValueFormatterTestBase::validProvider - */ public function validProvider() { return [ [ new StringValue( 'ice cream' ), 'ice cream' ], @@ -47,7 +39,7 @@ public function validProvider() { */ public function testInvalidFormat( $value ) { $formatter = new StringFormatter(); - $this->setExpectedException( InvalidArgumentException::class ); + $this->expectException( InvalidArgumentException::class ); $formatter->format( $value ); } diff --git a/tests/ValueParsers/DispatchingValueParserTest.php b/tests/ValueParsers/DispatchingValueParserTest.php index 93c214d..d4e8e6c 100644 --- a/tests/ValueParsers/DispatchingValueParserTest.php +++ b/tests/ValueParsers/DispatchingValueParserTest.php @@ -3,8 +3,7 @@ namespace ValueParsers\Test; use InvalidArgumentException; -use PHPUnit_Framework_MockObject_Matcher_Invocation; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; use ValueParsers\DispatchingValueParser; use ValueParsers\ParseException; use ValueParsers\ValueParser; @@ -19,15 +18,10 @@ * @license GPL-2.0+ * @author Thiemo Kreuz */ -class DispatchingValueParserTest extends PHPUnit_Framework_TestCase { +class DispatchingValueParserTest extends TestCase { - /** - * @param PHPUnit_Framework_MockObject_Matcher_Invocation $invocation - * - * @return ValueParser - */ - private function getParser( PHPUnit_Framework_MockObject_Matcher_Invocation $invocation ) { - $mock = $this->getMock( ValueParser::class ); + private function getParser( $invocation ) : ValueParser { + $mock = $this->createMock( ValueParser::class ); $mock->expects( $invocation ) ->method( 'parse' ) @@ -43,9 +37,9 @@ private function getParser( PHPUnit_Framework_MockObject_Matcher_Invocation $inv /** * @dataProvider invalidConstructorArgumentsProvider - * @expectedException InvalidArgumentException */ public function testGivenInvalidConstructorArguments_constructorThrowsException( $parsers, $format ) { + $this->expectException( InvalidArgumentException::class ); new DispatchingValueParser( $parsers, $format ); } @@ -81,7 +75,7 @@ public function testParseThrowsException() { 'format' ); - $this->setExpectedException( ParseException::class ); + $this->expectException( ParseException::class ); $parser->parse( 'invalid' ); } diff --git a/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php b/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php index c58fd2e..3462457 100644 --- a/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php +++ b/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php @@ -4,7 +4,7 @@ use DataValues\StringValue; use InvalidArgumentException; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; use ValueParsers\Normalizers\NullStringNormalizer; /** @@ -16,7 +16,7 @@ * @license GPL-2.0+ * @author Thiemo Kreuz */ -class NullStringNormalizerTest extends PHPUnit_Framework_TestCase { +class NullStringNormalizerTest extends TestCase { /** * @dataProvider stringProvider @@ -39,7 +39,7 @@ public function stringProvider() { */ public function testNormalizeException( $value ) { $normalizer = new NullStringNormalizer(); - $this->setExpectedException( InvalidArgumentException::class ); + $this->expectException( InvalidArgumentException::class ); $normalizer->normalize( $value ); } diff --git a/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php b/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php index dc13a09..3c1dcbe 100644 --- a/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php +++ b/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php @@ -3,7 +3,8 @@ namespace ValueParsers\Normalizers\Test; use DataValues\StringValue; -use PHPUnit_Framework_TestCase; +use InvalidArgumentException; +use PHPUnit\Framework\TestCase; use ValueParsers\Normalizers\TrimmingStringNormalizer; /** @@ -15,7 +16,7 @@ * @license GPL-2.0-or-later * @author Thiemo Kreuz */ -class TrimmingStringNormalizerTest extends PHPUnit_Framework_TestCase { +class TrimmingStringNormalizerTest extends TestCase { /** * @dataProvider stringProvider @@ -40,7 +41,7 @@ public function stringProvider() { */ public function testNormalizeException( $value ) { $normalizer = new TrimmingStringNormalizer(); - $this->setExpectedException( 'InvalidArgumentException' ); + $this->expectException( InvalidArgumentException::class ); $normalizer->normalize( $value ); } diff --git a/tests/ValueParsers/StringParserTest.php b/tests/ValueParsers/StringParserTest.php index b72d15b..fd44bd7 100644 --- a/tests/ValueParsers/StringParserTest.php +++ b/tests/ValueParsers/StringParserTest.php @@ -4,6 +4,8 @@ use DataValues\DataValue; use DataValues\StringValue; +use InvalidArgumentException; +use PHPUnit\Framework\TestCase; use ValueParsers\Normalizers\StringNormalizer; use ValueParsers\StringParser; @@ -16,10 +18,10 @@ * @license GPL-2.0+ * @author Daniel Kinzler */ -class StringParserTest extends \PHPUnit_Framework_TestCase { +class StringParserTest extends TestCase { public function provideParse() { - $normalizer = $this->getMock( StringNormalizer::class ); + $normalizer = $this->createMock( StringNormalizer::class ); $normalizer->expects( $this->once() ) ->method( 'normalize' ) ->will( $this->returnCallback( function( $value ) { @@ -56,7 +58,7 @@ public function nonStringProvider() { */ public function testGivenNonString_parseThrowsException( $input ) { $parser = new StringParser(); - $this->setExpectedException( 'InvalidArgumentException' ); + $this->expectException( InvalidArgumentException::class ); $parser->parse( $input ); } diff --git a/tests/ValueParsers/ValueParserTestBase.php b/tests/ValueParsers/ValueParserTestBase.php index e19addc..8cfd78f 100644 --- a/tests/ValueParsers/ValueParserTestBase.php +++ b/tests/ValueParsers/ValueParserTestBase.php @@ -4,7 +4,7 @@ use Comparable; use DataValues\DataValue; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; use ValueParsers\ParseException; use ValueParsers\ValueParser; @@ -19,7 +19,7 @@ * @license GPL-2.0+ * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ -abstract class ValueParserTestBase extends PHPUnit_Framework_TestCase { +abstract class ValueParserTestBase extends TestCase { /** * @return array[] @@ -80,7 +80,7 @@ public function testParseWithInvalidInputs( $value, ValueParser $parser = null ) $parser = $this->getInstance(); } - $this->setExpectedException( ParseException::class ); + $this->expectException( ParseException::class ); $parser->parse( $value ); } From c1f33d7c21316f6dc3272c85bc05bbef420601f1 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Fri, 25 Sep 2020 15:49:30 +0200 Subject: [PATCH 14/51] Remove getSortKey() and getCopy() Removed from DataValues in 3.0.0. --- README.md | 1 + src/DataValues/MonolingualTextValue.php | 10 ---------- src/DataValues/MultilingualTextValue.php | 9 --------- tests/DataValues/MonolingualTextValueTest.php | 1 - tests/DataValues/MultilingualTextValueTest.php | 2 -- 5 files changed, 1 insertion(+), 22 deletions(-) diff --git a/README.md b/README.md index a5bde67..123bdd8 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ employees for the [Wikidata project](https://wikidata.org/). ### 1.0.0 (dev) * Removed the `DATAVALUES_COMMON_VERSION` constant +* Removed `getCopy` and `getSortKey` methods from `DataValue` implementations * Classes in the `ValueParsers\Test` namespace are now package private. Notably `ValueParserTestBase` and `StringValueParserTest` * The `StringFormatter` constructor does not accept options any more * Added `TrimmingStringNormalizer` diff --git a/src/DataValues/MonolingualTextValue.php b/src/DataValues/MonolingualTextValue.php index 5cf35fc..369a14d 100644 --- a/src/DataValues/MonolingualTextValue.php +++ b/src/DataValues/MonolingualTextValue.php @@ -68,16 +68,6 @@ public static function getType() { return 'monolingualtext'; } - /** - * @see DataValue::getSortKey - * - * @return string - */ - public function getSortKey() { - // TODO: we might want to re-think this key. Perhaps the language should simply be omitted. - return $this->languageCode . $this->text; - } - /** * @see DataValue::getValue * diff --git a/src/DataValues/MultilingualTextValue.php b/src/DataValues/MultilingualTextValue.php index 0335f84..54b2cb9 100644 --- a/src/DataValues/MultilingualTextValue.php +++ b/src/DataValues/MultilingualTextValue.php @@ -67,15 +67,6 @@ public static function getType() { return 'multilingualtext'; } - /** - * @see DataValue::getSortKey - * - * @return string|float|int - */ - public function getSortKey() { - return empty( $this->texts ) ? '' : reset( $this->texts )->getSortKey(); - } - /** * Returns the texts as an array of monolingual text values, * with the language codes as array keys. diff --git a/tests/DataValues/MonolingualTextValueTest.php b/tests/DataValues/MonolingualTextValueTest.php index 73c4b7e..1c49e25 100644 --- a/tests/DataValues/MonolingualTextValueTest.php +++ b/tests/DataValues/MonolingualTextValueTest.php @@ -23,7 +23,6 @@ class MonolingualTextValueTest extends TestCase { public function testGetters() { $value = new MonolingualTextValue( 'en', 'foo' ); $this->assertSame( 'monolingualtext', $value->getType() ); - $this->assertSame( 'enfoo', $value->getSortKey() ); $this->assertSame( 'foo', $value->getText() ); $this->assertSame( 'en', $value->getLanguageCode() ); } diff --git a/tests/DataValues/MultilingualTextValueTest.php b/tests/DataValues/MultilingualTextValueTest.php index f9ac1f0..291d37b 100644 --- a/tests/DataValues/MultilingualTextValueTest.php +++ b/tests/DataValues/MultilingualTextValueTest.php @@ -26,7 +26,6 @@ public function testGetters() { $monolingualTextValue2 = new MonolingualTextValue( 'de', 'foo' ); $value = new MultilingualTextValue( [ $monolingualTextValue1, $monolingualTextValue2 ] ); $this->assertSame( 'multilingualtext', $value->getType() ); - $this->assertSame( 'enfoo', $value->getSortKey() ); $this->assertSame( [ 'en' => $monolingualTextValue1, 'de' => $monolingualTextValue2 ], $value->getTexts() @@ -35,7 +34,6 @@ public function testGetters() { public function testGetters_empty() { $value = new MultilingualTextValue( [] ); - $this->assertSame( '', $value->getSortKey() ); $this->assertSame( [], $value->getTexts() ); } From dd563dbeee39654cf5c6db499b76d6ce9e179017 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 25 Sep 2020 17:23:17 +0200 Subject: [PATCH 15/51] Update README.md [skip ci] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e462a6c..a680f86 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ employees for the [Wikidata project](https://wikidata.org/). * Removed the `DATAVALUES_COMMON_VERSION` constant * Classes in the `ValueParsers\Test` namespace are now package private. Notably `ValueParserTestBase` and `StringValueParserTest` * The `StringFormatter` constructor does not accept options any more +* `StringParser::parse` now throws a `ParseException` instead of an `InvalidArgumentException` * Added `TrimmingStringNormalizer` ### 0.4.2 (2018-08-16) From e9ecad4ba8dadddb74e22541705bd0641ddb9c1f Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Mon, 28 Sep 2020 13:32:18 +0200 Subject: [PATCH 16/51] Revert "Remove getSortKey() and getCopy()" If we want to declare compatibility with older DataValues versions, we need to keep them around. Mark them as deprecated instead. This reverts commit c1f33d7c21316f6dc3272c85bc05bbef420601f1. --- README.md | 2 +- src/DataValues/MonolingualTextValue.php | 11 +++++++++++ src/DataValues/MultilingualTextValue.php | 10 ++++++++++ tests/DataValues/MonolingualTextValueTest.php | 1 + tests/DataValues/MultilingualTextValueTest.php | 2 ++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 30c52f4..5ed34fd 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ employees for the [Wikidata project](https://wikidata.org/). ### 1.0.0 (dev) * Removed the `DATAVALUES_COMMON_VERSION` constant -* Removed `getCopy` and `getSortKey` methods from `DataValue` implementations +* Deprecated `getSortKey` methods from `DataValue` implementations * Classes in the `ValueParsers\Test` namespace are now package private. Notably `ValueParserTestBase` and `StringValueParserTest` * The `StringFormatter` constructor does not accept options any more * `StringParser::parse` now throws a `ParseException` instead of an `InvalidArgumentException` diff --git a/src/DataValues/MonolingualTextValue.php b/src/DataValues/MonolingualTextValue.php index 369a14d..f575c4c 100644 --- a/src/DataValues/MonolingualTextValue.php +++ b/src/DataValues/MonolingualTextValue.php @@ -68,6 +68,17 @@ public static function getType() { return 'monolingualtext'; } + /** + * @deprecated Kept for compatibility with older DataValues versions. + * Do not use. + * + * @return string + */ + public function getSortKey() { + // TODO: we might want to re-think this key. Perhaps the language should simply be omitted. + return $this->languageCode . $this->text; + } + /** * @see DataValue::getValue * diff --git a/src/DataValues/MultilingualTextValue.php b/src/DataValues/MultilingualTextValue.php index 54b2cb9..a6ee131 100644 --- a/src/DataValues/MultilingualTextValue.php +++ b/src/DataValues/MultilingualTextValue.php @@ -67,6 +67,16 @@ public static function getType() { return 'multilingualtext'; } + /** + * @deprecated Kept for compatibility with older DataValues versions. + * Do not use. + * + * @return string|float|int + */ + public function getSortKey() { + return empty( $this->texts ) ? '' : reset( $this->texts )->getSortKey(); + } + /** * Returns the texts as an array of monolingual text values, * with the language codes as array keys. diff --git a/tests/DataValues/MonolingualTextValueTest.php b/tests/DataValues/MonolingualTextValueTest.php index 1c49e25..73c4b7e 100644 --- a/tests/DataValues/MonolingualTextValueTest.php +++ b/tests/DataValues/MonolingualTextValueTest.php @@ -23,6 +23,7 @@ class MonolingualTextValueTest extends TestCase { public function testGetters() { $value = new MonolingualTextValue( 'en', 'foo' ); $this->assertSame( 'monolingualtext', $value->getType() ); + $this->assertSame( 'enfoo', $value->getSortKey() ); $this->assertSame( 'foo', $value->getText() ); $this->assertSame( 'en', $value->getLanguageCode() ); } diff --git a/tests/DataValues/MultilingualTextValueTest.php b/tests/DataValues/MultilingualTextValueTest.php index 291d37b..f9ac1f0 100644 --- a/tests/DataValues/MultilingualTextValueTest.php +++ b/tests/DataValues/MultilingualTextValueTest.php @@ -26,6 +26,7 @@ public function testGetters() { $monolingualTextValue2 = new MonolingualTextValue( 'de', 'foo' ); $value = new MultilingualTextValue( [ $monolingualTextValue1, $monolingualTextValue2 ] ); $this->assertSame( 'multilingualtext', $value->getType() ); + $this->assertSame( 'enfoo', $value->getSortKey() ); $this->assertSame( [ 'en' => $monolingualTextValue1, 'de' => $monolingualTextValue2 ], $value->getTexts() @@ -34,6 +35,7 @@ public function testGetters() { public function testGetters_empty() { $value = new MultilingualTextValue( [] ); + $this->assertSame( '', $value->getSortKey() ); $this->assertSame( [], $value->getTexts() ); } From 5858cb12282811fe1298258093fe24f16c206e2e Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Mon, 28 Sep 2020 15:33:27 +0200 Subject: [PATCH 17/51] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5ed34fd..68bf8ab 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ employees for the [Wikidata project](https://wikidata.org/). * The `StringFormatter` constructor does not accept options any more * `StringParser::parse` now throws a `ParseException` instead of an `InvalidArgumentException` * Added `TrimmingStringNormalizer` -* Updated minimal required PHP version from 5.5.9 to 7.2 +* Updated minimum required PHP version from 5.5.9 to 7.2 ### 0.4.2 (2018-08-16) From db0c7619d49f2c502af2d9198ef54878b1e489b8 Mon Sep 17 00:00:00 2001 From: Itamar Givon Date: Tue, 13 Oct 2020 16:01:33 +0000 Subject: [PATCH 18/51] Update wikibase-codesniffer to v1.2.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7fa44a4..5e3f65b 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "require-dev": { "ockcyp/covers-validator": "~1.2", "phpunit/phpunit": "~8.0", - "wikibase/wikibase-codesniffer": "^0.1.0" + "wikibase/wikibase-codesniffer": "^1.2.0" }, "extra": { "branch-alias": { From 02d57f0794b86494273a0bf95257736be4590706 Mon Sep 17 00:00:00 2001 From: Itamar Givon Date: Tue, 13 Oct 2020 16:03:17 +0000 Subject: [PATCH 19/51] Add fix script --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index 5e3f65b..e543513 100644 --- a/composer.json +++ b/composer.json @@ -50,6 +50,9 @@ ] }, "scripts": { + "fix": [ + "phpcbf" + ], "cs": [ "phpcs -p -s" ], From add25fdacc482066dae02e72cca45895cc70b215 Mon Sep 17 00:00:00 2001 From: Itamar Givon Date: Tue, 13 Oct 2020 16:03:38 +0000 Subject: [PATCH 20/51] Autofix cs violations --- tests/ValueParsers/StringParserTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/ValueParsers/StringParserTest.php b/tests/ValueParsers/StringParserTest.php index e7ee54d..153a3f5 100644 --- a/tests/ValueParsers/StringParserTest.php +++ b/tests/ValueParsers/StringParserTest.php @@ -4,7 +4,6 @@ use DataValues\DataValue; use DataValues\StringValue; -use InvalidArgumentException; use PHPUnit\Framework\TestCase; use ValueParsers\Normalizers\StringNormalizer; use ValueParsers\ParseException; From 4139b35af87793bad411ac23d7297ff03e51a32e Mon Sep 17 00:00:00 2001 From: Itamar Givon Date: Tue, 13 Oct 2020 16:20:36 +0000 Subject: [PATCH 21/51] Update license identifier --- src/DataValues/MonolingualTextValue.php | 2 +- src/DataValues/MultilingualTextValue.php | 2 +- .../Exceptions/MismatchingDataValueTypeException.php | 2 +- src/ValueFormatters/StringFormatter.php | 2 +- src/ValueParsers/BoolParser.php | 2 +- src/ValueParsers/DispatchingValueParser.php | 2 +- src/ValueParsers/FloatParser.php | 2 +- src/ValueParsers/IntParser.php | 2 +- src/ValueParsers/Normalizers/NullStringNormalizer.php | 2 +- src/ValueParsers/Normalizers/StringNormalizer.php | 2 +- src/ValueParsers/NullParser.php | 2 +- src/ValueParsers/StringParser.php | 2 +- src/ValueParsers/StringValueParser.php | 2 +- tests/DataValues/MonolingualTextValueTest.php | 2 +- tests/DataValues/MultilingualTextValueTest.php | 2 +- .../Exceptions/MismatchingDataValueTypeExceptionTest.php | 2 +- tests/ValueFormatters/StringFormatterTest.php | 2 +- tests/ValueParsers/BoolParserTest.php | 2 +- tests/ValueParsers/DispatchingValueParserTest.php | 2 +- tests/ValueParsers/FloatParserTest.php | 2 +- tests/ValueParsers/IntParserTest.php | 2 +- tests/ValueParsers/Normalizers/NullStringNormalizerTest.php | 2 +- tests/ValueParsers/NullParserTest.php | 2 +- tests/ValueParsers/StringParserTest.php | 2 +- tests/ValueParsers/StringValueParserTest.php | 2 +- tests/ValueParsers/ValueParserTestBase.php | 2 +- 26 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/DataValues/MonolingualTextValue.php b/src/DataValues/MonolingualTextValue.php index f575c4c..e65d408 100644 --- a/src/DataValues/MonolingualTextValue.php +++ b/src/DataValues/MonolingualTextValue.php @@ -7,7 +7,7 @@ * * @since 0.1 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class MonolingualTextValue extends DataValueObject { diff --git a/src/DataValues/MultilingualTextValue.php b/src/DataValues/MultilingualTextValue.php index a6ee131..ba3393e 100644 --- a/src/DataValues/MultilingualTextValue.php +++ b/src/DataValues/MultilingualTextValue.php @@ -7,7 +7,7 @@ * * @since 0.1 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class MultilingualTextValue extends DataValueObject { diff --git a/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php b/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php index f041e17..7595164 100644 --- a/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php +++ b/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php @@ -8,7 +8,7 @@ /** * @since 0.2.2 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Katie Filbert < aude.wiki@gmail.com > * @author Thiemo Kreuz */ diff --git a/src/ValueFormatters/StringFormatter.php b/src/ValueFormatters/StringFormatter.php index c5ebaf9..eeb947b 100644 --- a/src/ValueFormatters/StringFormatter.php +++ b/src/ValueFormatters/StringFormatter.php @@ -11,7 +11,7 @@ * * @since 0.1 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Katie Filbert < aude.wiki@gmail.com > */ class StringFormatter implements ValueFormatter { diff --git a/src/ValueParsers/BoolParser.php b/src/ValueParsers/BoolParser.php index 2835e66..b30f926 100644 --- a/src/ValueParsers/BoolParser.php +++ b/src/ValueParsers/BoolParser.php @@ -9,7 +9,7 @@ * * @since 0.1 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class BoolParser extends StringValueParser { diff --git a/src/ValueParsers/DispatchingValueParser.php b/src/ValueParsers/DispatchingValueParser.php index fb34287..2626d5c 100644 --- a/src/ValueParsers/DispatchingValueParser.php +++ b/src/ValueParsers/DispatchingValueParser.php @@ -10,7 +10,7 @@ * * @since 0.3 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Thiemo Kreuz */ class DispatchingValueParser implements ValueParser { diff --git a/src/ValueParsers/FloatParser.php b/src/ValueParsers/FloatParser.php index 5845cbb..c24999a 100644 --- a/src/ValueParsers/FloatParser.php +++ b/src/ValueParsers/FloatParser.php @@ -9,7 +9,7 @@ * * @since 0.1 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class FloatParser extends StringValueParser { diff --git a/src/ValueParsers/IntParser.php b/src/ValueParsers/IntParser.php index 93547b0..964b02c 100644 --- a/src/ValueParsers/IntParser.php +++ b/src/ValueParsers/IntParser.php @@ -9,7 +9,7 @@ * * @since 0.1 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class IntParser extends StringValueParser { diff --git a/src/ValueParsers/Normalizers/NullStringNormalizer.php b/src/ValueParsers/Normalizers/NullStringNormalizer.php index 3f14402..7fe57bb 100644 --- a/src/ValueParsers/Normalizers/NullStringNormalizer.php +++ b/src/ValueParsers/Normalizers/NullStringNormalizer.php @@ -9,7 +9,7 @@ * * @since 0.3 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Daniel Kinzler */ class NullStringNormalizer implements StringNormalizer { diff --git a/src/ValueParsers/Normalizers/StringNormalizer.php b/src/ValueParsers/Normalizers/StringNormalizer.php index 36a1755..9888a6f 100644 --- a/src/ValueParsers/Normalizers/StringNormalizer.php +++ b/src/ValueParsers/Normalizers/StringNormalizer.php @@ -9,7 +9,7 @@ * * @since 0.3 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Daniel Kinzler */ interface StringNormalizer { diff --git a/src/ValueParsers/NullParser.php b/src/ValueParsers/NullParser.php index b5d3ae9..56ce6c5 100644 --- a/src/ValueParsers/NullParser.php +++ b/src/ValueParsers/NullParser.php @@ -9,7 +9,7 @@ * * @since 0.1 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class NullParser implements ValueParser { diff --git a/src/ValueParsers/StringParser.php b/src/ValueParsers/StringParser.php index f7b408b..b074af7 100644 --- a/src/ValueParsers/StringParser.php +++ b/src/ValueParsers/StringParser.php @@ -11,7 +11,7 @@ * * @since 0.3 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Daniel Kinzler */ class StringParser implements ValueParser { diff --git a/src/ValueParsers/StringValueParser.php b/src/ValueParsers/StringValueParser.php index 6ea7f1d..2915177 100644 --- a/src/ValueParsers/StringValueParser.php +++ b/src/ValueParsers/StringValueParser.php @@ -13,7 +13,7 @@ * * @since 0.1 * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ abstract class StringValueParser implements ValueParser { diff --git a/tests/DataValues/MonolingualTextValueTest.php b/tests/DataValues/MonolingualTextValueTest.php index 73c4b7e..65d87de 100644 --- a/tests/DataValues/MonolingualTextValueTest.php +++ b/tests/DataValues/MonolingualTextValueTest.php @@ -15,7 +15,7 @@ * @group DataValue * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class MonolingualTextValueTest extends TestCase { diff --git a/tests/DataValues/MultilingualTextValueTest.php b/tests/DataValues/MultilingualTextValueTest.php index f9ac1f0..cf6c578 100644 --- a/tests/DataValues/MultilingualTextValueTest.php +++ b/tests/DataValues/MultilingualTextValueTest.php @@ -16,7 +16,7 @@ * @group DataValue * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class MultilingualTextValueTest extends TestCase { diff --git a/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php b/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php index e963d8e..1cd3824 100644 --- a/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php +++ b/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php @@ -12,7 +12,7 @@ * @group ValueFormatters * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Katie Filbert < aude.wiki@gmail.com > * @author Thiemo Kreuz */ diff --git a/tests/ValueFormatters/StringFormatterTest.php b/tests/ValueFormatters/StringFormatterTest.php index 9b664c4..57f4989 100644 --- a/tests/ValueFormatters/StringFormatterTest.php +++ b/tests/ValueFormatters/StringFormatterTest.php @@ -13,7 +13,7 @@ * @group ValueFormatters * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Katie Filbert < aude.wiki@gmail.com > */ class StringFormatterTest extends TestCase { diff --git a/tests/ValueParsers/BoolParserTest.php b/tests/ValueParsers/BoolParserTest.php index f53fce8..44eaf66 100644 --- a/tests/ValueParsers/BoolParserTest.php +++ b/tests/ValueParsers/BoolParserTest.php @@ -12,7 +12,7 @@ * @group ValueParsers * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class BoolParserTest extends StringValueParserTest { diff --git a/tests/ValueParsers/DispatchingValueParserTest.php b/tests/ValueParsers/DispatchingValueParserTest.php index d4e8e6c..4b21986 100644 --- a/tests/ValueParsers/DispatchingValueParserTest.php +++ b/tests/ValueParsers/DispatchingValueParserTest.php @@ -15,7 +15,7 @@ * @group DataValueExtensions * @group ValueParsers * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Thiemo Kreuz */ class DispatchingValueParserTest extends TestCase { diff --git a/tests/ValueParsers/FloatParserTest.php b/tests/ValueParsers/FloatParserTest.php index 2983aee..e5206a9 100644 --- a/tests/ValueParsers/FloatParserTest.php +++ b/tests/ValueParsers/FloatParserTest.php @@ -12,7 +12,7 @@ * @group ValueParsers * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class FloatParserTest extends StringValueParserTest { diff --git a/tests/ValueParsers/IntParserTest.php b/tests/ValueParsers/IntParserTest.php index 46cc94d..c859ea7 100644 --- a/tests/ValueParsers/IntParserTest.php +++ b/tests/ValueParsers/IntParserTest.php @@ -12,7 +12,7 @@ * @group ValueParsers * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class IntParserTest extends StringValueParserTest { diff --git a/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php b/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php index 3462457..e988748 100644 --- a/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php +++ b/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php @@ -13,7 +13,7 @@ * @group ValueParsers * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Thiemo Kreuz */ class NullStringNormalizerTest extends TestCase { diff --git a/tests/ValueParsers/NullParserTest.php b/tests/ValueParsers/NullParserTest.php index c17eb58..2c5afd0 100644 --- a/tests/ValueParsers/NullParserTest.php +++ b/tests/ValueParsers/NullParserTest.php @@ -12,7 +12,7 @@ * @group ValueParsers * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class NullParserTest extends ValueParserTestBase { diff --git a/tests/ValueParsers/StringParserTest.php b/tests/ValueParsers/StringParserTest.php index 153a3f5..724546f 100644 --- a/tests/ValueParsers/StringParserTest.php +++ b/tests/ValueParsers/StringParserTest.php @@ -15,7 +15,7 @@ * @group ValueParsers * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Daniel Kinzler */ class StringParserTest extends TestCase { diff --git a/tests/ValueParsers/StringValueParserTest.php b/tests/ValueParsers/StringValueParserTest.php index 7e05608..91c828e 100644 --- a/tests/ValueParsers/StringValueParserTest.php +++ b/tests/ValueParsers/StringValueParserTest.php @@ -11,7 +11,7 @@ * @group ValueParsers * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ abstract class StringValueParserTest extends ValueParserTestBase { diff --git a/tests/ValueParsers/ValueParserTestBase.php b/tests/ValueParsers/ValueParserTestBase.php index 8cfd78f..477eb1e 100644 --- a/tests/ValueParsers/ValueParserTestBase.php +++ b/tests/ValueParsers/ValueParserTestBase.php @@ -16,7 +16,7 @@ * @group ValueParsers * @group DataValueExtensions * - * @license GPL-2.0+ + * @license GPL-2.0-or-later * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ abstract class ValueParserTestBase extends TestCase { From 046eb994204aa3d375b0df5e92782cef096257eb Mon Sep 17 00:00:00 2001 From: Itamar Givon Date: Tue, 13 Oct 2020 16:23:08 +0000 Subject: [PATCH 22/51] Fix nullable paramater code style --- tests/ValueParsers/StringParserTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ValueParsers/StringParserTest.php b/tests/ValueParsers/StringParserTest.php index 724546f..66c7e36 100644 --- a/tests/ValueParsers/StringParserTest.php +++ b/tests/ValueParsers/StringParserTest.php @@ -37,7 +37,7 @@ public function provideParse() { /** * @dataProvider provideParse */ - public function testParse( $input, StringNormalizer $normalizer = null, DataValue $expected ) { + public function testParse( $input, ?StringNormalizer $normalizer, DataValue $expected ) { $parser = new StringParser( $normalizer ); $value = $parser->parse( $input ); From 3f4c744567b53f537ee27666978a6c2b6b3fac7f Mon Sep 17 00:00:00 2001 From: Itamar Givon Date: Tue, 13 Oct 2020 16:45:19 +0000 Subject: [PATCH 23/51] Fix line limit violations --- src/DataValues/MultilingualTextValue.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/DataValues/MultilingualTextValue.php b/src/DataValues/MultilingualTextValue.php index ba3393e..44d601f 100644 --- a/src/DataValues/MultilingualTextValue.php +++ b/src/DataValues/MultilingualTextValue.php @@ -27,13 +27,17 @@ class MultilingualTextValue extends DataValueObject { public function __construct( array $monolingualValues ) { foreach ( $monolingualValues as $monolingualValue ) { if ( !( $monolingualValue instanceof MonolingualTextValue ) ) { - throw new IllegalValueException( 'Can only construct MultilingualTextValue from MonolingualTextValue objects' ); + throw new IllegalValueException( + 'Can only construct MultilingualTextValue from MonolingualTextValue objects' + ); } $languageCode = $monolingualValue->getLanguageCode(); if ( array_key_exists( $languageCode, $this->texts ) ) { - throw new IllegalValueException( 'Can only add a single MonolingualTextValue per language to a MultilingualTextValue' ); + throw new IllegalValueException( + 'Can only add a single MonolingualTextValue per language to a MultilingualTextValue' + ); } $this->texts[$languageCode] = $monolingualValue; From 9994130462bf7bb65490912fe8bbb9ce74e41239 Mon Sep 17 00:00:00 2001 From: Itamar Givon Date: Tue, 13 Oct 2020 16:47:51 +0000 Subject: [PATCH 24/51] Decalre visibility on consts --- src/ValueParsers/BoolParser.php | 2 +- src/ValueParsers/FloatParser.php | 2 +- src/ValueParsers/IntParser.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ValueParsers/BoolParser.php b/src/ValueParsers/BoolParser.php index b30f926..d9321d5 100644 --- a/src/ValueParsers/BoolParser.php +++ b/src/ValueParsers/BoolParser.php @@ -14,7 +14,7 @@ */ class BoolParser extends StringValueParser { - const FORMAT_NAME = 'bool'; + private const FORMAT_NAME = 'bool'; private static $values = [ 'yes' => true, diff --git a/src/ValueParsers/FloatParser.php b/src/ValueParsers/FloatParser.php index c24999a..ae5b27a 100644 --- a/src/ValueParsers/FloatParser.php +++ b/src/ValueParsers/FloatParser.php @@ -14,7 +14,7 @@ */ class FloatParser extends StringValueParser { - const FORMAT_NAME = 'float'; + private const FORMAT_NAME = 'float'; /** * @see StringValueParser::stringParse diff --git a/src/ValueParsers/IntParser.php b/src/ValueParsers/IntParser.php index 964b02c..d69439f 100644 --- a/src/ValueParsers/IntParser.php +++ b/src/ValueParsers/IntParser.php @@ -14,7 +14,7 @@ */ class IntParser extends StringValueParser { - const FORMAT_NAME = 'int'; + private const FORMAT_NAME = 'int'; /** * @see StringValueParser::stringParse From a44c3b51fbbdb9bbdef89d081db12d30946a190e Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Thu, 15 Oct 2020 13:16:23 +0200 Subject: [PATCH 25/51] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 68bf8ab..115a8ce 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ employees for the [Wikidata project](https://wikidata.org/). * The `StringFormatter` constructor does not accept options any more * `StringParser::parse` now throws a `ParseException` instead of an `InvalidArgumentException` * Added `TrimmingStringNormalizer` +* Made `FORMAT_NAME` constants in the Parser classes private * Updated minimum required PHP version from 5.5.9 to 7.2 ### 0.4.2 (2018-08-16) From 95e498c4bb324723b310bfdeb6f8537f8766edd1 Mon Sep 17 00:00:00 2001 From: addshore Date: Mon, 18 Jan 2021 23:02:29 +0000 Subject: [PATCH 26/51] README, Re add 0.4.3 release notes These are copied from 844359d1e782884a2b79460a49624d9c08673666 which is merged. But these seemingly vanished at some point --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 115a8ce..eaf467f 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,10 @@ employees for the [Wikidata project](https://wikidata.org/). * Made `FORMAT_NAME` constants in the Parser classes private * Updated minimum required PHP version from 5.5.9 to 7.2 +### 0.4.3 (2019-06-28) + +* Fixed typo in error message in `DispatchingValueParser` + ### 0.4.2 (2018-08-16) * The component can now be installed together with DataValues 2.x From 059c3946c4b7c3e7130541bccc499df75aef8b60 Mon Sep 17 00:00:00 2001 From: addshore Date: Mon, 18 Jan 2021 23:22:02 +0000 Subject: [PATCH 27/51] Switch from Travis to Github Actions --- .github/workflows/php.yml | 64 +++++++++++++++++++++++++++++++++++++++ .travis.yml | 23 -------------- README.md | 4 +-- 3 files changed, 65 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/php.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..547cf6c --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,64 @@ +name: PHP Composer + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php-version: ['7.2', '7.3', '7.4'] + + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v2 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: Install dependencies + if: steps.composer-cache.outputs.cache-hit != 'true' + run: composer install --prefer-dist --no-progress --no-suggest + + - name: Run test suite + run: composer ci + + - name: Run test suite + run: composer ci + + - name: Setup PHP for coverage + if: matrix.php-version == '7.4' + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: xdebug + + - name: Generate coverage + if: matrix.php-version == '7.4' + run: vendor/bin/phpunit --coverage-clover coverage.clover + + - name: Upload Scrutinizer coverage + if: matrix.php-version == '7.4' + uses: sudo-bot/action-scrutinizer@latest + with: + cli-args: "--format=php-clover coverage.clover" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index bd64dfb..0000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: php - -dist: trusty - -php: - - 7.2 - - 7.3 - -sudo: false - -install: travis_retry composer install - -script: composer ci - -after_success: - - if [[ "`phpenv version-name`" != "7.3" ]]; then exit 0; fi - - vendor/bin/phpunit --coverage-clover coverage.clover - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover coverage.clover - -cache: - directories: - - $HOME/.composer/cache diff --git a/README.md b/README.md index eaf467f..b706f7e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ implementations of the DataValues, ValueParsers, ValueFormatters and ValueValida It is part of the [DataValues set of libraries](https://github.com/DataValues). -[![Build Status](https://secure.travis-ci.org/DataValues/Common.png?branch=master)](http://travis-ci.org/DataValues/Common) [![Code Coverage](https://scrutinizer-ci.com/g/DataValues/Common/badges/coverage.png?s=728b9287ebdd13fbe15255d4d55575c5b5d47b8f)](https://scrutinizer-ci.com/g/DataValues/Common/) [![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/DataValues/Common/badges/quality-score.png?s=3195539d2e929aafaefb4bc006fb0da6c09a4d2a)](https://scrutinizer-ci.com/g/DataValues/Common/) @@ -32,7 +31,7 @@ version 0.4.2 of this package: This library comes with a set up PHPUnit tests that cover all non-trivial code. You can run these tests using the PHPUnit configuration file found in the root directory. The tests can also be run -via TravisCI, as a TravisCI configuration file is also provided in the root directory. +via Github Actions. ### Running the tests @@ -143,4 +142,3 @@ Initial release with these features: ## Links * [DataValues Common on Packagist](https://packagist.org/packages/data-values/common) -* [DataValues Common on TravisCI](https://travis-ci.org/DataValues/Common) From 9150b482a19606e14c29926b1400f7f760c27e23 Mon Sep 17 00:00:00 2001 From: addshore Date: Tue, 19 Jan 2021 09:51:15 +0000 Subject: [PATCH 28/51] Update .github/workflows/php.yml Co-authored-by: Jakob Warkotsch --- .github/workflows/php.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 547cf6c..db57ade 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -43,9 +43,6 @@ jobs: - name: Run test suite run: composer ci - - name: Run test suite - run: composer ci - - name: Setup PHP for coverage if: matrix.php-version == '7.4' uses: shivammathur/setup-php@v2 From b17562d40032a45ae61d40781334e694e72ed966 Mon Sep 17 00:00:00 2001 From: addshore Date: Tue, 19 Jan 2021 13:04:30 +0000 Subject: [PATCH 29/51] Update .github/workflows/php.yml Co-authored-by: Lucas Werkmeister --- .github/workflows/php.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index db57ade..aef5ac6 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -2,9 +2,7 @@ name: PHP Composer on: push: - branches: [ master ] pull_request: - branches: [ master ] jobs: build: From 6d3f05d03fc4a5352aa53f8236f8e3e75ede6728 Mon Sep 17 00:00:00 2001 From: addshore Date: Tue, 19 Jan 2021 13:04:40 +0000 Subject: [PATCH 30/51] Update .github/workflows/php.yml Co-authored-by: Lucas Werkmeister --- .github/workflows/php.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index aef5ac6..05d48d5 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -12,7 +12,10 @@ jobs: strategy: fail-fast: false matrix: - php-version: ['7.2', '7.3', '7.4'] + php-version: + - '7.2', + - '7.3' + - '7.4' steps: - uses: actions/checkout@v2 From 3aa96662d5e68f4d5bc0e78e489739c5e711f142 Mon Sep 17 00:00:00 2001 From: addshore Date: Tue, 19 Jan 2021 14:02:03 +0000 Subject: [PATCH 31/51] rename composer validate step --- .github/workflows/php.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 05d48d5..eec9622 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -25,7 +25,7 @@ jobs: with: php-version: ${{ matrix.php-version }} - - name: Validate composer.json and composer.lock + - name: Composer validate run: composer validate - name: Cache Composer packages From 494f7740b204bceb5a52cb9c41e5344d5d60615a Mon Sep 17 00:00:00 2001 From: addshore Date: Tue, 19 Jan 2021 14:04:11 +0000 Subject: [PATCH 32/51] Alter composer caching --- .github/workflows/php.yml | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index eec9622..c68fb66 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -12,8 +12,8 @@ jobs: strategy: fail-fast: false matrix: - php-version: - - '7.2', + php: + - '7.2' - '7.3' - '7.4' @@ -23,40 +23,35 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-version }} + php-version: ${{ matrix.php }} - name: Composer validate run: composer validate - - name: Cache Composer packages - id: composer-cache + - name: Cache Composer cache uses: actions/cache@v2 with: - path: vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-php- - - - name: Install dependencies - if: steps.composer-cache.outputs.cache-hit != 'true' - run: composer install --prefer-dist --no-progress --no-suggest + path: ~/.composer/cache + key: composer-cache-php${{ matrix.php }} + - name: Composer install + run: composer install --no-progress --no-suggest --no-interaction --prefer-dist --optimize-autoloader - name: Run test suite run: composer ci - name: Setup PHP for coverage - if: matrix.php-version == '7.4' + if: matrix.php == '7.4' uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-version }} + php-version: ${{ matrix.php }} coverage: xdebug - name: Generate coverage - if: matrix.php-version == '7.4' + if: matrix.php == '7.4' run: vendor/bin/phpunit --coverage-clover coverage.clover - name: Upload Scrutinizer coverage - if: matrix.php-version == '7.4' + if: matrix.php == '7.4' uses: sudo-bot/action-scrutinizer@latest with: cli-args: "--format=php-clover coverage.clover" From 71f5783202e7549ae0da82272fbfdad5b7fddc40 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 22 Jan 2021 15:27:07 +0100 Subject: [PATCH 33/51] Update release notes for 1.0.0 --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b706f7e..44d7be6 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,11 @@ The recommended way to use this library is via [Composer](http://getcomposer.org To add this package as a local, per-project dependency to your project, simply add a dependency on `data-values/common` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on -version 0.4.2 of this package: +version 1.x of this package: { "require": { - "data-values/common": "^0.4.2" + "data-values/common": "^1.0.0" } } @@ -54,8 +54,9 @@ employees for the [Wikidata project](https://wikidata.org/). ## Release notes -### 1.0.0 (dev) +### 1.0.0 (2021-01-22) +* Updated minimum required PHP version from 5.5.9 to 7.2 * Removed the `DATAVALUES_COMMON_VERSION` constant * Deprecated `getSortKey` methods from `DataValue` implementations * Classes in the `ValueParsers\Test` namespace are now package private. Notably `ValueParserTestBase` and `StringValueParserTest` @@ -63,7 +64,6 @@ employees for the [Wikidata project](https://wikidata.org/). * `StringParser::parse` now throws a `ParseException` instead of an `InvalidArgumentException` * Added `TrimmingStringNormalizer` * Made `FORMAT_NAME` constants in the Parser classes private -* Updated minimum required PHP version from 5.5.9 to 7.2 ### 0.4.3 (2019-06-28) From 9726088771c2107f605f18f659e455c27ef2e65b Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 22 Jan 2021 15:29:14 +0100 Subject: [PATCH 34/51] Add strict_types --- .gitignore | 4 +++- src/DataValues/MonolingualTextValue.php | 2 ++ src/DataValues/MultilingualTextValue.php | 2 ++ .../Exceptions/MismatchingDataValueTypeException.php | 2 ++ src/ValueFormatters/StringFormatter.php | 2 ++ src/ValueParsers/BoolParser.php | 2 ++ src/ValueParsers/DispatchingValueParser.php | 2 ++ src/ValueParsers/FloatParser.php | 2 ++ src/ValueParsers/IntParser.php | 2 ++ src/ValueParsers/Normalizers/NullStringNormalizer.php | 2 ++ src/ValueParsers/Normalizers/StringNormalizer.php | 2 ++ src/ValueParsers/Normalizers/TrimmingStringNormalizer.php | 2 ++ src/ValueParsers/NullParser.php | 2 ++ src/ValueParsers/StringParser.php | 2 ++ src/ValueParsers/StringValueParser.php | 2 ++ tests/DataValues/MonolingualTextValueTest.php | 2 ++ tests/DataValues/MultilingualTextValueTest.php | 2 ++ .../Exceptions/MismatchingDataValueTypeExceptionTest.php | 2 ++ tests/ValueFormatters/StringFormatterTest.php | 2 ++ tests/ValueParsers/BoolParserTest.php | 2 ++ tests/ValueParsers/DispatchingValueParserTest.php | 2 ++ tests/ValueParsers/FloatParserTest.php | 2 ++ tests/ValueParsers/IntParserTest.php | 2 ++ tests/ValueParsers/Normalizers/NullStringNormalizerTest.php | 2 ++ .../ValueParsers/Normalizers/TrimmingStringNormalizerTest.php | 2 ++ tests/ValueParsers/NullParserTest.php | 2 ++ tests/ValueParsers/StringParserTest.php | 2 ++ tests/ValueParsers/StringValueParserTest.php | 2 ++ tests/ValueParsers/ValueParserTestBase.php | 2 ++ tests/bootstrap.php | 4 +++- 30 files changed, 62 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 577795c..da794e8 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,6 @@ build/ vendor/ composer.phar -composer.lock \ No newline at end of file +composer.lock + +.phpunit.result.cache diff --git a/src/DataValues/MonolingualTextValue.php b/src/DataValues/MonolingualTextValue.php index e65d408..4a969a2 100644 --- a/src/DataValues/MonolingualTextValue.php +++ b/src/DataValues/MonolingualTextValue.php @@ -1,5 +1,7 @@ Date: Fri, 22 Jan 2021 15:31:14 +0100 Subject: [PATCH 35/51] Use MW CS instead of WB CS --- composer.json | 4 ++-- phpcs.xml | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index e543513..45ceb34 100644 --- a/composer.json +++ b/composer.json @@ -28,9 +28,9 @@ "data-values/interfaces": "~1.0|~0.2.0" }, "require-dev": { - "ockcyp/covers-validator": "~1.2", "phpunit/phpunit": "~8.0", - "wikibase/wikibase-codesniffer": "^1.2.0" + "ockcyp/covers-validator": "^1.3.3", + "mediawiki/mediawiki-codesniffer": "^34" }, "extra": { "branch-alias": { diff --git a/phpcs.xml b/phpcs.xml index ac20681..8649f80 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,12 +1,10 @@ - + src/ + tests/ - - - + + - - . From 8e2435f130e6d11c04ee940eb6f390f6f2b73c1a Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 22 Jan 2021 15:33:57 +0100 Subject: [PATCH 36/51] Use consistent PSR-4 autoloading for tests --- composer.json | 8 +++++--- tests/ValueFormatters/StringFormatterTest.php | 2 +- tests/ValueParsers/BoolParserTest.php | 2 +- tests/ValueParsers/DispatchingValueParserTest.php | 2 +- tests/ValueParsers/FloatParserTest.php | 2 +- tests/ValueParsers/IntParserTest.php | 2 +- .../ValueParsers/Normalizers/NullStringNormalizerTest.php | 2 +- .../Normalizers/TrimmingStringNormalizerTest.php | 2 +- tests/ValueParsers/NullParserTest.php | 2 +- tests/ValueParsers/StringParserTest.php | 2 +- tests/ValueParsers/StringValueParserTest.php | 2 +- tests/ValueParsers/ValueParserTestBase.php | 2 +- 12 files changed, 16 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index 45ceb34..e7f7d6c 100644 --- a/composer.json +++ b/composer.json @@ -45,9 +45,11 @@ } }, "autoload-dev": { - "classmap": [ - "tests/ValueParsers" - ] + "psr-4": { + "DataValues\\Tests\\": "tests/DataValues/", + "ValueFormatters\\Tests\\": "tests/ValueFormatters/", + "ValueParsers\\Tests\\": "tests/ValueParsers/" + } }, "scripts": { "fix": [ diff --git a/tests/ValueFormatters/StringFormatterTest.php b/tests/ValueFormatters/StringFormatterTest.php index cfa9d61..5af2df0 100644 --- a/tests/ValueFormatters/StringFormatterTest.php +++ b/tests/ValueFormatters/StringFormatterTest.php @@ -2,7 +2,7 @@ declare( strict_types = 1 ); -namespace ValueFormatters\Test; +namespace ValueFormatters\Tests; use DataValues\StringValue; use InvalidArgumentException; diff --git a/tests/ValueParsers/BoolParserTest.php b/tests/ValueParsers/BoolParserTest.php index 85db4b5..2c2bfc5 100644 --- a/tests/ValueParsers/BoolParserTest.php +++ b/tests/ValueParsers/BoolParserTest.php @@ -2,7 +2,7 @@ declare( strict_types = 1 ); -namespace ValueParsers\Test; +namespace ValueParsers\Tests; use DataValues\BooleanValue; use ValueParsers\BoolParser; diff --git a/tests/ValueParsers/DispatchingValueParserTest.php b/tests/ValueParsers/DispatchingValueParserTest.php index 7f1937d..0a547a7 100644 --- a/tests/ValueParsers/DispatchingValueParserTest.php +++ b/tests/ValueParsers/DispatchingValueParserTest.php @@ -2,7 +2,7 @@ declare( strict_types = 1 ); -namespace ValueParsers\Test; +namespace ValueParsers\Tests; use InvalidArgumentException; use PHPUnit\Framework\TestCase; diff --git a/tests/ValueParsers/FloatParserTest.php b/tests/ValueParsers/FloatParserTest.php index a4e2667..c931ed2 100644 --- a/tests/ValueParsers/FloatParserTest.php +++ b/tests/ValueParsers/FloatParserTest.php @@ -2,7 +2,7 @@ declare( strict_types = 1 ); -namespace ValueParsers\Test; +namespace ValueParsers\Tests; use DataValues\NumberValue; use ValueParsers\FloatParser; diff --git a/tests/ValueParsers/IntParserTest.php b/tests/ValueParsers/IntParserTest.php index 2f8c0ed..05b442b 100644 --- a/tests/ValueParsers/IntParserTest.php +++ b/tests/ValueParsers/IntParserTest.php @@ -2,7 +2,7 @@ declare( strict_types = 1 ); -namespace ValueParsers\Test; +namespace ValueParsers\Tests; use DataValues\NumberValue; use ValueParsers\IntParser; diff --git a/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php b/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php index 9ceb6ef..b568bfa 100644 --- a/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php +++ b/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php @@ -2,7 +2,7 @@ declare( strict_types = 1 ); -namespace ValueParsers\Normalizers\Test; +namespace ValueParsers\Tests\Normalizers; use DataValues\StringValue; use InvalidArgumentException; diff --git a/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php b/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php index 3deb2db..23e267c 100644 --- a/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php +++ b/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php @@ -2,7 +2,7 @@ declare( strict_types = 1 ); -namespace ValueParsers\Normalizers\Test; +namespace ValueParsers\Tests\Normalizers; use DataValues\StringValue; use InvalidArgumentException; diff --git a/tests/ValueParsers/NullParserTest.php b/tests/ValueParsers/NullParserTest.php index 3028bfa..68a2af5 100644 --- a/tests/ValueParsers/NullParserTest.php +++ b/tests/ValueParsers/NullParserTest.php @@ -2,7 +2,7 @@ declare( strict_types = 1 ); -namespace ValueParsers\Test; +namespace ValueParsers\Tests; use DataValues\UnknownValue; use ValueParsers\NullParser; diff --git a/tests/ValueParsers/StringParserTest.php b/tests/ValueParsers/StringParserTest.php index ffd84f3..410f2d4 100644 --- a/tests/ValueParsers/StringParserTest.php +++ b/tests/ValueParsers/StringParserTest.php @@ -2,7 +2,7 @@ declare( strict_types = 1 ); -namespace ValueParsers\Test; +namespace ValueParsers\Tests; use DataValues\DataValue; use DataValues\StringValue; diff --git a/tests/ValueParsers/StringValueParserTest.php b/tests/ValueParsers/StringValueParserTest.php index 76d4d55..b312f4e 100644 --- a/tests/ValueParsers/StringValueParserTest.php +++ b/tests/ValueParsers/StringValueParserTest.php @@ -2,7 +2,7 @@ declare( strict_types = 1 ); -namespace ValueParsers\Test; +namespace ValueParsers\Tests; use ValueParsers\ParserOptions; use ValueParsers\StringValueParser; diff --git a/tests/ValueParsers/ValueParserTestBase.php b/tests/ValueParsers/ValueParserTestBase.php index 42fee08..6e57c32 100644 --- a/tests/ValueParsers/ValueParserTestBase.php +++ b/tests/ValueParsers/ValueParserTestBase.php @@ -2,7 +2,7 @@ declare( strict_types = 1 ); -namespace ValueParsers\Test; +namespace ValueParsers\Tests; use Comparable; use DataValues\DataValue; From 315bd95ef8e5c360ce8a1cf02c0eef35bbb92561 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 22 Jan 2021 15:36:48 +0100 Subject: [PATCH 37/51] Add added compat to release notes --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 44d7be6..991a1e9 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,8 @@ employees for the [Wikidata project](https://wikidata.org/). ### 1.0.0 (2021-01-22) * Updated minimum required PHP version from 5.5.9 to 7.2 +* Added compatibility with `data-values/data-values` 3.x +* Added compatibility with `data-values/interfaces` 1.x * Removed the `DATAVALUES_COMMON_VERSION` constant * Deprecated `getSortKey` methods from `DataValue` implementations * Classes in the `ValueParsers\Test` namespace are now package private. Notably `ValueParserTestBase` and `StringValueParserTest` From 85e4c1f927c826490cfdd1388eaa9b8ab6a37c7a Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Mon, 12 Apr 2021 22:54:18 +0100 Subject: [PATCH 38/51] .gitattributes: Add .github to export-ignore --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index 3f150e3..a0593aa 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,6 @@ .editorconfig export-ignore .gitattributes export-ignore +.github/ export-ignore .gitignore export-ignore .scrutinizer.yml export-ignore .travis.yml export-ignore From 1dfcc7155728376ce90f5f4306e9ef904c0bd3b8 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Fri, 14 Oct 2022 14:39:05 +0200 Subject: [PATCH 39/51] Bump actions/checkout fetch-depth to 2 The default of 1 (only HEAD, no parents) is not enough for Scrutinizer, it seems. Problem witnessed in #96. --- .github/workflows/php.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index c68fb66..3b16ee3 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -19,6 +19,8 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 2 - name: Setup PHP uses: shivammathur/setup-php@v2 From 6334c72cf17837732858bbe67cb9ecc1e657fca4 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Fri, 14 Oct 2022 13:08:25 +0200 Subject: [PATCH 40/51] Implement _serialize()/__unserialize() Bug: T301249 --- src/DataValues/MonolingualTextValue.php | 12 ++++++++++-- src/DataValues/MultilingualTextValue.php | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/DataValues/MonolingualTextValue.php b/src/DataValues/MonolingualTextValue.php index 4a969a2..03eb876 100644 --- a/src/DataValues/MonolingualTextValue.php +++ b/src/DataValues/MonolingualTextValue.php @@ -48,7 +48,11 @@ public function __construct( $languageCode, $text ) { * @return string */ public function serialize() { - return serialize( [ $this->languageCode, $this->text ] ); + return serialize( $this->__serialize() ); + } + + public function __serialize(): array { + return [ $this->languageCode, $this->text ]; } /** @@ -57,7 +61,11 @@ public function serialize() { * @param string $value */ public function unserialize( $value ) { - list( $languageCode, $text ) = unserialize( $value ); + $this->__unserialize( unserialize( $value ) ); + } + + public function __unserialize( array $data ): void { + list( $languageCode, $text ) = $data; $this->__construct( $languageCode, $text ); } diff --git a/src/DataValues/MultilingualTextValue.php b/src/DataValues/MultilingualTextValue.php index 5492f1e..32165cf 100644 --- a/src/DataValues/MultilingualTextValue.php +++ b/src/DataValues/MultilingualTextValue.php @@ -52,7 +52,11 @@ public function __construct( array $monolingualValues ) { * @return string */ public function serialize() { - return serialize( $this->texts ); + return serialize( $this->__serialize() ); + } + + public function __serialize(): array { + return $this->texts; } /** @@ -61,7 +65,11 @@ public function serialize() { * @param string $value */ public function unserialize( $value ) { - $this->__construct( unserialize( $value ) ); + $this->__unserialize( unserialize( $value ) ); + } + + public function __unserialize( array $data ): void { + $this->__construct( $data ); } /** From 3d43c4344dcd6d72ebdfd2a02d4c466b77e31c39 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Fri, 21 Oct 2022 12:51:01 +0200 Subject: [PATCH 41/51] Release 1.1.0 --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 991a1e9..41723d8 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ version 1.x of this package: { "require": { - "data-values/common": "^1.0.0" + "data-values/common": "^1.1.0" } } @@ -54,6 +54,13 @@ employees for the [Wikidata project](https://wikidata.org/). ## Release notes +### 1.1.0 (2022-10-21) + +* Improved compatibility with PHP 8.1; + in particular, the new `__serialize`/`__unserialize` methods are implemented now + (in addition to the still supported `Serializable` interface). + Make sure to also use `data-values/data-values` version 3.1.0 (or later) to keep hashes stable. + ### 1.0.0 (2021-01-22) * Updated minimum required PHP version from 5.5.9 to 7.2 From 16ebf7de2011a42f6b72f92439faaac432b3ee1d Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 21 Oct 2022 16:10:07 +0200 Subject: [PATCH 42/51] Update build badges --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 41723d8..c494d07 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ implementations of the DataValues, ValueParsers, ValueFormatters and ValueValida It is part of the [DataValues set of libraries](https://github.com/DataValues). +[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/DataValues/Common/PHP%20Composer)](https://github.com/DataValues/Common/actions?query=workflow%3APHP%20Composer) [![Code Coverage](https://scrutinizer-ci.com/g/DataValues/Common/badges/coverage.png?s=728b9287ebdd13fbe15255d4d55575c5b5d47b8f)](https://scrutinizer-ci.com/g/DataValues/Common/) -[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/DataValues/Common/badges/quality-score.png?s=3195539d2e929aafaefb4bc006fb0da6c09a4d2a)](https://scrutinizer-ci.com/g/DataValues/Common/) On [Packagist](https://packagist.org/packages/data-values/common): [![Latest Stable Version](https://poser.pugx.org/data-values/common/version.png)](https://packagist.org/packages/data-values/common) From 9f5e6216ec66ac8f2281351b110bad0eded43e65 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 21 Oct 2022 16:13:11 +0200 Subject: [PATCH 43/51] Fix CI badge URL --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c494d07..de4bb6d 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ implementations of the DataValues, ValueParsers, ValueFormatters and ValueValida It is part of the [DataValues set of libraries](https://github.com/DataValues). -[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/DataValues/Common/PHP%20Composer)](https://github.com/DataValues/Common/actions?query=workflow%3APHP%20Composer) +[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/DataValues/Common/PHP%20Composer)](https://github.com/DataValues/Common/actions?query=workflow%3A"PHP+Composer") [![Code Coverage](https://scrutinizer-ci.com/g/DataValues/Common/badges/coverage.png?s=728b9287ebdd13fbe15255d4d55575c5b5d47b8f)](https://scrutinizer-ci.com/g/DataValues/Common/) On [Packagist](https://packagist.org/packages/data-values/common): From 2243b64f0148251bcd36421258405fb7ccce21a2 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Thu, 10 Nov 2022 10:52:12 +1100 Subject: [PATCH 44/51] Add tests/ to export-ignore To reduce the composer package size. --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index a0593aa..cdba42e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,3 +7,4 @@ composer.json export-ignore phpcs.xml export-ignore phpunit.xml.dist export-ignore +tests/ export-ignore From 06415a03d13e35ea471630ec6fa0f1f44cd45053 Mon Sep 17 00:00:00 2001 From: Arthur Taylor Date: Fri, 6 Dec 2024 14:07:02 +0100 Subject: [PATCH 45/51] Upgrade mediawiki-codesniffer to latest version (45.0.0) This repository is currently using version 34 of the Mediawiki coding style phpcs rules. If the code aims to comply with Mediawiki style guidelines, it makes sense that it continues to comply at current versions of the rules. Besides being simply different, the newer versions of the rules introduce, for example, MediaWiki.Usage.NullableType.ExplicitNullableTypes, which enforces compliance with coming deprecation rules in PHP 8.4 concerning nullable types. If the code does not remove the soon-to-be-deprecated form of nullable type declarations, the library will no longer be usable in Mediawiki for PHP 8.4 deployments. Resolves #100 Bug: T379481 --- .github/workflows/php.yml | 2 -- composer.json | 9 +++++++-- phpcs.xml | 1 + src/DataValues/MonolingualTextValue.php | 2 +- .../Exceptions/MismatchingDataValueTypeException.php | 2 +- src/ValueParsers/BoolParser.php | 4 ++++ src/ValueParsers/StringParser.php | 2 +- src/ValueParsers/StringValueParser.php | 2 +- tests/ValueParsers/DispatchingValueParserTest.php | 6 +++--- tests/ValueParsers/NullParserTest.php | 2 +- tests/ValueParsers/StringParserTest.php | 4 ++-- tests/ValueParsers/ValueParserTestBase.php | 4 ++-- 12 files changed, 24 insertions(+), 16 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 3b16ee3..641f7c7 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -13,8 +13,6 @@ jobs: fail-fast: false matrix: php: - - '7.2' - - '7.3' - '7.4' steps: diff --git a/composer.json b/composer.json index e7f7d6c..6e51d8f 100644 --- a/composer.json +++ b/composer.json @@ -23,14 +23,14 @@ "irc": "irc://irc.freenode.net/wikidata" }, "require": { - "php": ">=7.2.0", + "php": ">=7.4", "data-values/data-values": "~3.0|~2.0|~1.0|~0.1", "data-values/interfaces": "~1.0|~0.2.0" }, "require-dev": { "phpunit/phpunit": "~8.0", "ockcyp/covers-validator": "^1.3.3", - "mediawiki/mediawiki-codesniffer": "^34" + "mediawiki/mediawiki-codesniffer": "^45" }, "extra": { "branch-alias": { @@ -67,5 +67,10 @@ "@cs", "@test" ] + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } } } diff --git a/phpcs.xml b/phpcs.xml index 8649f80..52b4a07 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -7,4 +7,5 @@ + diff --git a/src/DataValues/MonolingualTextValue.php b/src/DataValues/MonolingualTextValue.php index 03eb876..e331064 100644 --- a/src/DataValues/MonolingualTextValue.php +++ b/src/DataValues/MonolingualTextValue.php @@ -65,7 +65,7 @@ public function unserialize( $value ) { } public function __unserialize( array $data ): void { - list( $languageCode, $text ) = $data; + [ $languageCode, $text ] = $data; $this->__construct( $languageCode, $text ); } diff --git a/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php b/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php index 549c79d..1c25dec 100644 --- a/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php +++ b/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php @@ -36,7 +36,7 @@ public function __construct( $expectedValueType, $dataValueType, $message = '', - Exception $previous = null + ?Exception $previous = null ) { $this->expectedValueType = $expectedValueType; $this->dataValueType = $dataValueType; diff --git a/src/ValueParsers/BoolParser.php b/src/ValueParsers/BoolParser.php index 5583073..99faf7f 100644 --- a/src/ValueParsers/BoolParser.php +++ b/src/ValueParsers/BoolParser.php @@ -18,6 +18,10 @@ class BoolParser extends StringValueParser { private const FORMAT_NAME = 'bool'; + /** + * @var Mapping from possible string values to their + * boolean equivalents + */ private static $values = [ 'yes' => true, 'on' => true, diff --git a/src/ValueParsers/StringParser.php b/src/ValueParsers/StringParser.php index 3efb4bf..4827694 100644 --- a/src/ValueParsers/StringParser.php +++ b/src/ValueParsers/StringParser.php @@ -26,7 +26,7 @@ class StringParser implements ValueParser { /** * @param StringNormalizer|null $normalizer */ - public function __construct( StringNormalizer $normalizer = null ) { + public function __construct( ?StringNormalizer $normalizer = null ) { $this->normalizer = $normalizer ?: new NullStringNormalizer(); } diff --git a/src/ValueParsers/StringValueParser.php b/src/ValueParsers/StringValueParser.php index c80e3c3..ac638c0 100644 --- a/src/ValueParsers/StringValueParser.php +++ b/src/ValueParsers/StringValueParser.php @@ -28,7 +28,7 @@ abstract class StringValueParser implements ValueParser { /** * @param ParserOptions|null $options */ - public function __construct( ParserOptions $options = null ) { + public function __construct( ?ParserOptions $options = null ) { $this->options = $options ?: new ParserOptions(); $this->defaultOption( ValueParser::OPT_LANG, 'en' ); diff --git a/tests/ValueParsers/DispatchingValueParserTest.php b/tests/ValueParsers/DispatchingValueParserTest.php index 0a547a7..7d42056 100644 --- a/tests/ValueParsers/DispatchingValueParserTest.php +++ b/tests/ValueParsers/DispatchingValueParserTest.php @@ -22,17 +22,17 @@ */ class DispatchingValueParserTest extends TestCase { - private function getParser( $invocation ) : ValueParser { + private function getParser( $invocation ): ValueParser { $mock = $this->createMock( ValueParser::class ); $mock->expects( $invocation ) ->method( 'parse' ) - ->will( $this->returnCallback( function( $value ) { + ->willReturnCallback( static function ( $value ) { if ( $value === 'invalid' ) { throw new ParseException( 'failed' ); } return $value; - } ) ); + } ); return $mock; } diff --git a/tests/ValueParsers/NullParserTest.php b/tests/ValueParsers/NullParserTest.php index 68a2af5..1f1573e 100644 --- a/tests/ValueParsers/NullParserTest.php +++ b/tests/ValueParsers/NullParserTest.php @@ -55,7 +55,7 @@ public function invalidInputProvider() { * * @dataProvider invalidInputProvider */ - public function testParseWithInvalidInputs( $value, ValueParser $parser = null ) { + public function testParseWithInvalidInputs( $value, ?ValueParser $parser = null ) { $this->markTestSkipped( 'NullParser has no invalid inputs' ); } diff --git a/tests/ValueParsers/StringParserTest.php b/tests/ValueParsers/StringParserTest.php index 410f2d4..c707846 100644 --- a/tests/ValueParsers/StringParserTest.php +++ b/tests/ValueParsers/StringParserTest.php @@ -26,9 +26,9 @@ public function provideParse() { $normalizer = $this->createMock( StringNormalizer::class ); $normalizer->expects( $this->once() ) ->method( 'normalize' ) - ->will( $this->returnCallback( function( $value ) { + ->willReturnCallback( static function ( $value ) { return strtolower( trim( $value ) ); - } ) ); + } ); return [ 'simple' => [ 'hello world', null, new StringValue( 'hello world' ) ], diff --git a/tests/ValueParsers/ValueParserTestBase.php b/tests/ValueParsers/ValueParserTestBase.php index 6e57c32..cf5fdd9 100644 --- a/tests/ValueParsers/ValueParserTestBase.php +++ b/tests/ValueParsers/ValueParserTestBase.php @@ -44,7 +44,7 @@ abstract protected function getInstance(); * @param mixed $expected * @param ValueParser|null $parser */ - public function testParseWithValidInputs( $value, $expected, ValueParser $parser = null ) { + public function testParseWithValidInputs( $value, $expected, ?ValueParser $parser = null ) { if ( $parser === null ) { $parser = $this->getInstance(); } @@ -77,7 +77,7 @@ private function assertSmartEquals( $expected, $actual ) { * @param mixed $value * @param ValueParser|null $parser */ - public function testParseWithInvalidInputs( $value, ValueParser $parser = null ) { + public function testParseWithInvalidInputs( $value, ?ValueParser $parser = null ) { if ( $parser === null ) { $parser = $this->getInstance(); } From b3114dcc9da1bc37cc6b0cd66137f951d17c0ee7 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Fri, 6 Dec 2024 17:11:44 +0100 Subject: [PATCH 46/51] Test with modern PHP --- .github/workflows/php.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 641f7c7..41cef68 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -14,6 +14,11 @@ jobs: matrix: php: - '7.4' + - '8.0' + - '8.1' + - '8.2' + - '8.3' + - '8.4' steps: - uses: actions/checkout@v2 From 9799074609af63d76b29f582d8f34e6f24b51bf1 Mon Sep 17 00:00:00 2001 From: Arthur Taylor Date: Mon, 9 Dec 2024 11:18:27 +0100 Subject: [PATCH 47/51] Bump version to 1.2.0 * Drop support for PHP 7.2, 7.3 * Upgrade codesniffer rules to current `mediawiki/mediawiki-codesniffer` version (45.0.0) * Make nullable type parameter declarations explicit for compatibility with PHP 8.4 * Start testing with modern versions of PHP (8.1-8.4) --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index de4bb6d..dc2ce75 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,13 @@ employees for the [Wikidata project](https://wikidata.org/). ## Release notes +### 1.2.0 (2024-12-10) + +* Drop support for PHP 7.2, 7.3 +* Upgrade codesniffer rules to current `mediawiki/mediawiki-codesniffer` version (45.0.0) +* Make nullable type parameter declarations explicit for compatibility with PHP 8.4 +* Start testing with modern versions of PHP (8.1-8.4) + ### 1.1.0 (2022-10-21) * Improved compatibility with PHP 8.1; From b21c2bd3b213d6233a645003df4f88956afc52f4 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Mon, 9 Dec 2024 23:42:56 +0100 Subject: [PATCH 48/51] Improve release notes --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dc2ce75..0e9172e 100644 --- a/README.md +++ b/README.md @@ -56,10 +56,10 @@ employees for the [Wikidata project](https://wikidata.org/). ### 1.2.0 (2024-12-10) -* Drop support for PHP 7.2, 7.3 -* Upgrade codesniffer rules to current `mediawiki/mediawiki-codesniffer` version (45.0.0) -* Make nullable type parameter declarations explicit for compatibility with PHP 8.4 -* Start testing with modern versions of PHP (8.1-8.4) +* Dropped support for PHP 7.2 and PHP 7.3 +* Improved support for PHP 8.4 by explicitly declaring nullable types +* Upgraded codesniffer rules to current `mediawiki/mediawiki-codesniffer` version (45.0.0) +* Added testing with PHP 8.1 up to 8.4 ### 1.1.0 (2022-10-21) From 7a1c1037729462cd536eaed1236eb31cff4c5820 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Tue, 10 Dec 2024 00:16:25 +0100 Subject: [PATCH 49/51] Fix badges --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0e9172e..f0d5acd 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ # DataValues Common -DataValues Common is a small library build on top of DataValues that provides common -implementations of the DataValues, ValueParsers, ValueFormatters and ValueValidators interfaces. +DataValues Common is a small library built on top of DataValues that provides common +implementations of the DataValues, ValueParsers, ValueFormatters, and ValueValidators interfaces. It is part of the [DataValues set of libraries](https://github.com/DataValues). -[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/DataValues/Common/PHP%20Composer)](https://github.com/DataValues/Common/actions?query=workflow%3A"PHP+Composer") -[![Code Coverage](https://scrutinizer-ci.com/g/DataValues/Common/badges/coverage.png?s=728b9287ebdd13fbe15255d4d55575c5b5d47b8f)](https://scrutinizer-ci.com/g/DataValues/Common/) +[![Build Status](https://img.shields.io/github/actions/workflow/status/DataValues/Common/php.yml?branch=master)](https://github.com/DataValues/Common/actions/workflows/php.yml?query=workflow%3APHP) +[![Code Coverage](https://scrutinizer-ci.com/g/DataValues/Common/badges/coverage.png?s=6432d29bf3fed068995e66093ad52e053099a916)](https://scrutinizer-ci.com/g/DataValues/Common/) On [Packagist](https://packagist.org/packages/data-values/common): -[![Latest Stable Version](https://poser.pugx.org/data-values/common/version.png)](https://packagist.org/packages/data-values/common) -[![Download count](https://poser.pugx.org/data-values/common/d/total.png)](https://packagist.org/packages/data-values/common) +[![Latest Stable Version](https://poser.pugx.org/data-values/common/v/stable)](https://packagist.org/packages/data-values/common) +[![Download count](https://poser.pugx.org/data-values/common/downloads)](https://packagist.org/packages/data-values/common) ## Installation From c586bd6e6c7e6488f7d8332c70d1ad0c497975a9 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Thu, 12 Dec 2024 16:41:53 +0000 Subject: [PATCH 50/51] php.yml: Update to actions/cache@v4 --- .github/workflows/php.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 41cef68..70485e9 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -34,7 +34,7 @@ jobs: run: composer validate - name: Cache Composer cache - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.composer/cache key: composer-cache-php${{ matrix.php }} From 043f5e0ab9c034ee2a91366ea55d404d57df0549 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Thu, 8 Jan 2026 01:21:36 +0000 Subject: [PATCH 51/51] php.yml: Test on PHP 8.5 --- .github/workflows/php.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 70485e9..de76a8d 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -19,6 +19,7 @@ jobs: - '8.2' - '8.3' - '8.4' + - '8.5' steps: - uses: actions/checkout@v2