diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..db9cba3 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +# http://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = tab +indent_size = 4 +end_of_line = lf +trim_trailing_whitespace = true +insert_final_newline = true + +[*.php] +quote_type = single +spaces_around_operators = true +spaces_around_brackets = inside +indent_brace_style = K&R diff --git a/.gitattributes b/.gitattributes index e8ad548..cdba42e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,8 +1,10 @@ +.editorconfig export-ignore .gitattributes export-ignore +.github/ export-ignore .gitignore export-ignore .scrutinizer.yml export-ignore .travis.yml export-ignore composer.json export-ignore phpcs.xml export-ignore phpunit.xml.dist export-ignore -tests export-ignore +tests/ export-ignore diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..de76a8d --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,63 @@ +name: PHP Composer + +on: + push: + pull_request: + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php: + - '7.4' + - '8.0' + - '8.1' + - '8.2' + - '8.3' + - '8.4' + - '8.5' + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + + - name: Composer validate + run: composer validate + + - name: Cache Composer cache + uses: actions/cache@v4 + with: + 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 == '7.4' + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: xdebug + + - name: Generate coverage + if: matrix.php == '7.4' + run: vendor/bin/phpunit --coverage-clover coverage.clover + + - name: Upload Scrutinizer coverage + if: matrix.php == '7.4' + uses: sudo-bot/action-scrutinizer@latest + with: + cli-args: "--format=php-clover coverage.clover" 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/.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 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 74748b6..0000000 --- a/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: php - -dist: trusty - -php: - - 5.5 - - 5.6 - - 7 - - 7.1 - - hhvm - -sudo: false - -install: travis_retry composer install - -script: composer ci - -after_success: - - if [[ "`phpenv version-name`" != "7.1" ]]; 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/Common.php b/Common.php deleted file mode 100644 index 4302be8..0000000 --- a/Common.php +++ /dev/null @@ -1,22 +0,0 @@ - - */ - -if ( defined( 'DATAVALUES_COMMON_VERSION' ) ) { - // Do not initialize more than once. - return 1; -} - -define( 'DATAVALUES_COMMON_VERSION', '0.3.1' ); - -if ( defined( 'MEDIAWIKI' ) && function_exists( 'wfLoadExtension' ) ) { - wfLoadExtension( 'DataValuesCommon', __DIR__ . '/mediawiki-extension.json' ); -} diff --git a/README.md b/README.md index c130d5b..f0d5acd 100644 --- a/README.md +++ b/README.md @@ -1,17 +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). -[![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/) +[![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 @@ -20,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.3 of this package: +version 1.x of this package: { "require": { - "data-values/common": "0.3.*" + "data-values/common": "^1.1.0" } } @@ -32,7 +31,7 @@ version 0.3 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 @@ -55,6 +54,52 @@ employees for the [Wikidata project](https://wikidata.org/). ## Release notes +### 1.2.0 (2024-12-10) + +* 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) + +* 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 +* 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` +* 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 + +### 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 + +### 0.4.1 (2017-08-09) + +* Fixed version number not updated before. + +### 0.4.0 (2017-08-09) + +* Deprecated `MonolingualTextValue::newFromArray` and `MultilingualTextValue::newFromArray` +* `MismatchingDataValueTypeException` no longer modifies custom error messages in its constructor +* Updated minimal required PHP version from 5.3 to 5.5.9 +* Updated the MediaWiki entry point to use the extension.json format + ### 0.3.1 (2015-08-14) * The component can now be installed together with DataValues Interfaces 0.1.5 @@ -113,4 +158,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) diff --git a/composer.json b/composer.json index 302e06f..6e51d8f 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "wikidata" ], "homepage": "https://github.com/DataValues/Common", - "license": "GPL-2.0+", + "license": "GPL-2.0-or-later", "authors": [ { "name": "Jeroen De Dauw", @@ -23,45 +23,54 @@ "irc": "irc://irc.freenode.net/wikidata" }, "require": { - "php": ">=5.5.9", - "data-values/data-values": "~1.0|~0.1", - "data-values/interfaces": "~0.2.0|~0.1.5" + "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": "~4.8", - "ockcyp/covers-validator": "~0.4", - "wikibase/wikibase-codesniffer": "^0.1.0" + "phpunit/phpunit": "~8.0", + "ockcyp/covers-validator": "^1.3.3", + "mediawiki/mediawiki-codesniffer": "^45" }, "extra": { "branch-alias": { - "dev-master": "0.3.x-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { - "files" : [ - "Common.php" - ], "psr-4": { "DataValues\\": "src/DataValues/", "ValueFormatters\\": "src/ValueFormatters/", "ValueParsers\\": "src/ValueParsers/" - }, - "classmap": [ - "tests/ValueParsers" - ] + } + }, + "autoload-dev": { + "psr-4": { + "DataValues\\Tests\\": "tests/DataValues/", + "ValueFormatters\\Tests\\": "tests/ValueFormatters/", + "ValueParsers\\Tests\\": "tests/ValueParsers/" + } }, "scripts": { + "fix": [ + "phpcbf" + ], "cs": [ - "phpcs src/* tests/* --standard=phpcs.xml -sp" + "phpcs -p -s" ], "test": [ - "@validate --no-interaction", + "composer validate --no-interaction", "covers-validator", - "phpunit" + "vendor/bin/phpunit" ], "ci": [ - "@test", - "@cs" + "@cs", + "@test" ] + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } } } diff --git a/mediawiki-extension.json b/mediawiki-extension.json deleted file mode 100644 index 8e5099a..0000000 --- a/mediawiki-extension.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "DataValues Common", - "version": "0.3.1", - "author": [ - "[https://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw]" - ], - "url": "https://github.com/DataValues/Common", - "description": "Contains common implementations of the interfaces defined by DataValuesInterfaces", - "license-name": "GPL-2.0+", - "type": "datavalues", - "load_composer_autoloader": true, - "manifest_version": 1 -} diff --git a/phpcs.xml b/phpcs.xml index 033a4eb..52b4a07 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,12 +1,11 @@ - - - + src/ + tests/ - - - + + + diff --git a/src/DataValues/MonolingualTextValue.php b/src/DataValues/MonolingualTextValue.php index e5a280e..e331064 100644 --- a/src/DataValues/MonolingualTextValue.php +++ b/src/DataValues/MonolingualTextValue.php @@ -1,5 +1,7 @@ */ class MonolingualTextValue extends DataValueObject { @@ -46,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 ]; } /** @@ -55,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 { + [ $languageCode, $text ] = $data; $this->__construct( $languageCode, $text ); } @@ -69,7 +79,8 @@ public static function getType() { } /** - * @see DataValue::getSortKey + * @deprecated Kept for compatibility with older DataValues versions. + * Do not use. * * @return string */ @@ -117,7 +128,7 @@ public function getArrayValue() { * Constructs a new instance from the provided data. Required for @see DataValueDeserializer. * This is expected to round-trip with @see getArrayValue. * - * @deprecated since 0.3.2. Static DataValue::newFromArray constructors like this are + * @deprecated since 1.0.0. Static DataValue::newFromArray constructors like this are * underspecified (not in the DataValue interface), and misleadingly named (should be named * newFromArrayValue). Instead, use DataValue builder callbacks in @see DataValueDeserializer. * diff --git a/src/DataValues/MultilingualTextValue.php b/src/DataValues/MultilingualTextValue.php index 46bcc54..32165cf 100644 --- a/src/DataValues/MultilingualTextValue.php +++ b/src/DataValues/MultilingualTextValue.php @@ -1,5 +1,7 @@ */ class MultilingualTextValue extends DataValueObject { @@ -27,13 +29,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; @@ -46,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; } /** @@ -55,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 ); } /** @@ -68,7 +82,8 @@ public static function getType() { } /** - * @see DataValue::getSortKey + * @deprecated Kept for compatibility with older DataValues versions. + * Do not use. * * @return string|float|int */ @@ -77,7 +92,8 @@ public function getSortKey() { } /** - * Returns the texts as an array of monolingual text values. + * Returns the texts as an array of monolingual text values, + * with the language codes as array keys. * * @return MonolingualTextValue[] */ @@ -117,7 +133,7 @@ public function getArrayValue() { * Constructs a new instance from the provided data. Required for @see DataValueDeserializer. * This is expected to round-trip with @see getArrayValue. * - * @deprecated since 0.3.2. Static DataValue::newFromArray constructors like this are + * @deprecated since 1.0.0. Static DataValue::newFromArray constructors like this are * underspecified (not in the DataValue interface), and misleadingly named (should be named * newFromArrayValue). Instead, use DataValue builder callbacks in @see DataValueDeserializer. * diff --git a/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php b/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php index 147eb9f..1c25dec 100644 --- a/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php +++ b/src/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php @@ -1,5 +1,7 @@ - * @author Thiemo Mättig + * @author Thiemo Kreuz */ class MismatchingDataValueTypeException extends FormattingException { @@ -34,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/ValueFormatters/StringFormatter.php b/src/ValueFormatters/StringFormatter.php index 5581df6..077e86b 100644 --- a/src/ValueFormatters/StringFormatter.php +++ b/src/ValueFormatters/StringFormatter.php @@ -1,19 +1,22 @@ */ -class StringFormatter extends ValueFormatterBase { +class StringFormatter implements ValueFormatter { /** * @see ValueFormatter::format diff --git a/src/ValueParsers/BoolParser.php b/src/ValueParsers/BoolParser.php index 2835e66..99faf7f 100644 --- a/src/ValueParsers/BoolParser.php +++ b/src/ValueParsers/BoolParser.php @@ -1,5 +1,7 @@ */ class BoolParser extends StringValueParser { - const FORMAT_NAME = 'bool'; + 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/DispatchingValueParser.php b/src/ValueParsers/DispatchingValueParser.php index 235da84..0ad0fce 100644 --- a/src/ValueParsers/DispatchingValueParser.php +++ b/src/ValueParsers/DispatchingValueParser.php @@ -1,5 +1,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 93547b0..ffd1650 100644 --- a/src/ValueParsers/IntParser.php +++ b/src/ValueParsers/IntParser.php @@ -1,5 +1,7 @@ */ class IntParser extends StringValueParser { - const FORMAT_NAME = 'int'; + private const FORMAT_NAME = 'int'; /** * @see StringValueParser::stringParse diff --git a/src/ValueParsers/Normalizers/NullStringNormalizer.php b/src/ValueParsers/Normalizers/NullStringNormalizer.php index 3f14402..a16730f 100644 --- a/src/ValueParsers/Normalizers/NullStringNormalizer.php +++ b/src/ValueParsers/Normalizers/NullStringNormalizer.php @@ -1,5 +1,7 @@ */ class NullParser implements ValueParser { diff --git a/src/ValueParsers/StringParser.php b/src/ValueParsers/StringParser.php index d07f91f..4827694 100644 --- a/src/ValueParsers/StringParser.php +++ b/src/ValueParsers/StringParser.php @@ -1,9 +1,10 @@ normalizer = $normalizer ?: new NullStringNormalizer(); } @@ -34,12 +35,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/src/ValueParsers/StringValueParser.php b/src/ValueParsers/StringValueParser.php index 7176a74..ac638c0 100644 --- a/src/ValueParsers/StringValueParser.php +++ b/src/ValueParsers/StringValueParser.php @@ -1,33 +1,34 @@ */ abstract class StringValueParser implements ValueParser { /** - * @since 0.1 - * * @var ParserOptions */ protected $options; /** - * @since 0.1 - * * @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' ); @@ -36,10 +37,10 @@ public function __construct( ParserOptions $options = null ) { /** * @see ValueParser::parse * - * @param mixed $value + * @param string $value * * @return mixed - * @throws ParseException + * @throws ParseException if the provided value is not a string */ public function parse( $value ) { if ( is_string( $value ) ) { @@ -52,26 +53,17 @@ public function parse( $value ) { /** * Parses the provided string and returns the result. * - * @since 0.1 - * * @param string $value * * @return mixed */ - protected abstract function stringParse( $value ); + abstract protected function stringParse( $value ); - /** - * @since 0.1 - * - * @param ParserOptions $options - */ public function setOptions( ParserOptions $options ) { $this->options = $options; } /** - * @since 0.1 - * * @return ParserOptions */ public function getOptions() { @@ -81,39 +73,33 @@ public function getOptions() { /** * Shortcut to $this->options->getOption. * - * @since 0.1 - * * @param string $option * * @throws InvalidArgumentException * @return mixed */ - protected final function getOption( $option ) { + final protected function getOption( $option ) { return $this->options->getOption( $option ); } /** * Shortcut to $this->options->requireOption. * - * @since 0.1 - * * @param string $option * * @throws RuntimeException */ - protected final function requireOption( $option ) { + final protected function requireOption( $option ) { $this->options->requireOption( $option ); } /** * Shortcut to $this->options->defaultOption. * - * @since 0.1 - * * @param string $option * @param mixed $default */ - protected final function defaultOption( $option, $default ) { + final protected function defaultOption( $option, $default ) { $this->options->defaultOption( $option, $default ); } diff --git a/tests/DataValues/MonolingualTextValueTest.php b/tests/DataValues/MonolingualTextValueTest.php index 6687e47..2ead346 100644 --- a/tests/DataValues/MonolingualTextValueTest.php +++ b/tests/DataValues/MonolingualTextValueTest.php @@ -1,73 +1,91 @@ */ -class MonolingualTextValueTest extends DataValueTest { +class MonolingualTextValueTest extends TestCase { - /** - * @see DataValueTest::getClass - * - * @return string - */ - public function getClass() { - return 'DataValues\MonolingualTextValue'; + 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 validConstructorArgumentsProvider() { - $argLists = []; - - $argLists[] = [ 'en', 'foo' ]; - $argLists[] = [ 'en', ' foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz ' ]; + public function testArrayAndEquals() { + $value = new MonolingualTextValue( 'en', 'foo' ); + $array = $value->getArrayValue(); + $value2 = MonolingualTextValue::newFromArray( $array ); + $this->assertTrue( $value->equals( $value2 ) ); + $this->assertEquals( $value, $value2 ); + } - return $argLists; + public function testSerialize() { + $value = new MonolingualTextValue( 'en', 'foo' ); + $serialization = serialize( $value ); + $value2 = unserialize( $serialization ); + $this->assertEquals( $value, $value2 ); } - public function invalidConstructorArgumentsProvider() { - $argLists = []; + /** + * @dataProvider invalidConstructorArgumentsProvider + */ + public function testConstructorWithInvalidArguments( $languageCode, $text ) { + $this->expectException( Exception::class ); - $argLists[] = [ 42, null ]; - $argLists[] = [ [], null ]; - $argLists[] = [ false, null ]; - $argLists[] = [ true, null ]; - $argLists[] = [ null, null ]; - $argLists[] = [ 'en', 42 ]; - $argLists[] = [ 'en', false ]; - $argLists[] = [ 'en', [] ]; - $argLists[] = [ 'en', null ]; - $argLists[] = [ '', 'foo' ]; + $dataItem = new MonolingualTextValue( $languageCode, $text ); + } - return $argLists; + public function invalidConstructorArgumentsProvider() { + return [ + [ 42, null ], + [ [], null ], + [ false, null ], + [ true, null ], + [ null, null ], + [ 'en', 42 ], + [ 'en', false ], + [ 'en', [] ], + [ 'en', null ], + [ '', 'foo' ], + ]; } /** - * @dataProvider instanceProvider - * @param MonolingualTextValue $text - * @param array $arguments + * @dataProvider invalidArrayProvider */ - public function testGetText( MonolingualTextValue $text, array $arguments ) { - $this->assertEquals( $arguments[1], $text->getText() ); + public function testNewFromArrayWithInvalidArray( array $array ) { + $this->expectException( IllegalValueException::class ); + MonolingualTextValue::newFromArray( $array ); } - /** - * @dataProvider instanceProvider - * @param MonolingualTextValue $text - * @param array $arguments - */ - public function testGetLanguageCode( MonolingualTextValue $text, array $arguments ) { - $this->assertEquals( $arguments[0], $text->getLanguageCode() ); + public function invalidArrayProvider() { + return [ + [ [] ], + [ [ null ] ], + [ [ '' ] ], + [ [ 'en', 'foo' ] ], + [ [ 'language' => 'en' ] ], + [ [ 'text' => 'foo' ] ], + ]; } } diff --git a/tests/DataValues/MultilingualTextValueTest.php b/tests/DataValues/MultilingualTextValueTest.php index de19748..1d5b2fe 100644 --- a/tests/DataValues/MultilingualTextValueTest.php +++ b/tests/DataValues/MultilingualTextValueTest.php @@ -1,87 +1,121 @@ */ -class MultilingualTextValueTest extends DataValueTest { - - /** - * @see DataValueTest::getClass - * - * @return string - */ - public function getClass() { - return 'DataValues\MultilingualTextValue'; +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 validConstructorArgumentsProvider() { - $argLists = []; - - $argLists[] = [ [] ]; - $argLists[] = [ [ new MonolingualTextValue( 'en', 'foo' ) ] ]; - $argLists[] = [ [ new MonolingualTextValue( 'en', 'foo' ), new MonolingualTextValue( 'de', 'foo' ) ] ]; - $argLists[] = [ [ new MonolingualTextValue( 'en', 'foo' ), new MonolingualTextValue( 'de', 'bar' ) ] ]; - $argLists[] = [ [ - 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 ' ) - ] ]; + public function testGetters_empty() { + $value = new MultilingualTextValue( [] ); + $this->assertSame( '', $value->getSortKey() ); + $this->assertSame( [], $value->getTexts() ); + } - return $argLists; + 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 invalidConstructorArgumentsProvider() { - $argLists = []; - - $argLists[] = [ [ 42 ] ]; - $argLists[] = [ [ false ] ]; - $argLists[] = [ [ true ] ]; - $argLists[] = [ [ null ] ]; - $argLists[] = [ [ [] ] ]; - $argLists[] = [ [ 'foo' ] ]; - - $argLists[] = [ [ 42 => 'foo' ] ]; - $argLists[] = [ [ '' => 'foo' ] ]; - $argLists[] = [ [ 'en' => 42 ] ]; - $argLists[] = [ [ 'en' => null ] ]; - $argLists[] = [ [ 'en' => true ] ]; - $argLists[] = [ [ 'en' => [] ] ]; - $argLists[] = [ [ 'en' => 4.2 ] ]; - - $argLists[] = [ [ new MonolingualTextValue( 'en', 'foo' ), false ] ]; - $argLists[] = [ [ new MonolingualTextValue( 'en', 'foo' ), 'foobar' ] ]; - - return $argLists; + 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 ); } /** - * @dataProvider instanceProvider + * @dataProvider invalidConstructorArgumentsProvider */ - public function testGetTexts( MultilingualTextValue $texts, array $arguments ) { - $actual = $texts->getTexts(); + public function testConstructorWithInvalidArguments( $monolingualValues ) { + $this->expectException( Exception::class ); + + $dataItem = new MultilingualTextValue( $monolingualValues ); + } - $this->assertInternalType( 'array', $actual ); - $this->assertContainsOnlyInstancesOf( '\DataValues\MonolingualTextValue', $actual ); - $this->assertEquals( $arguments[0], array_values( $actual ) ); + public function invalidConstructorArgumentsProvider() { + return [ + [ [ 42 ] ], + [ [ false ] ], + [ [ true ] ], + [ [ null ] ], + [ [ [] ] ], + [ [ 'foo' ] ], + + [ [ 42 => 'foo' ] ], + [ [ '' => 'foo' ] ], + [ [ 'en' => 42 ] ], + [ [ 'en' => null ] ], + [ [ 'en' => true ] ], + [ [ 'en' => [] ] ], + [ [ 'en' => 4.2 ] ], + + [ [ + new MonolingualTextValue( 'en', 'foo' ), + false, + ] ], + [ [ + new MonolingualTextValue( 'en', 'foo' ), + 'foobar', + ] ], + [ [ + new MonolingualTextValue( 'en', 'foo' ), + new MonolingualTextValue( 'en', 'bar' ), + ] ], + ]; } /** - * @dataProvider instanceProvider + * @dataProvider invalidArrayProvider */ - public function testGetValue( MultilingualTextValue $texts, array $arguments ) { - $this->assertInstanceOf( $this->getClass(), $texts->getValue() ); + public function testNewFromArrayWithInvalidArray( array $array ) { + $this->expectException( IllegalValueException::class ); + MultilingualTextValue::newFromArray( $array ); + } + + public function invalidArrayProvider() { + return [ + [ [ null ] ], + [ [ '' ] ], + [ [ [] ] ], + [ [ [ 'en', 'foo' ] ] ], + ]; } } diff --git a/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php b/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php index 5c8d45b..38f5263 100644 --- a/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php +++ b/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeExceptionTest.php @@ -1,22 +1,24 @@ - * @author Thiemo Mättig + * @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 d66d710..5af2df0 100644 --- a/tests/ValueFormatters/StringFormatterTest.php +++ b/tests/ValueFormatters/StringFormatterTest.php @@ -1,59 +1,56 @@ */ -class StringFormatterTest extends ValueFormatterTestBase { +class StringFormatterTest extends TestCase { - /** - * @deprecated since DataValues Interfaces 0.2, just use getInstance. - */ - protected function getFormatterClass() { - throw new \LogicException( 'Should not be called, use getInstance' ); + /** @dataProvider validProvider */ + public function testValidFormat( StringValue $value, string $expected ) { + $formatter = new StringFormatter(); + $this->assertSame( $expected, $formatter->format( $value ) ); } - /** - * @see ValueFormatterTestBase::getInstance - * - * @param FormatterOptions|null $options - * - * @return StringFormatter - */ - protected function getInstance( FormatterOptions $options = null ) { - return new StringFormatter( $options ); + public function validProvider() { + return [ + [ new StringValue( 'ice cream' ), 'ice cream' ], + [ new StringValue( 'cake' ), 'cake' ], + [ new StringValue( '' ), '' ], + [ new StringValue( ' a ' ), ' a ' ], + [ new StringValue( ' ' ), ' ' ], + ]; } /** - * @see ValueFormatterTestBase::validProvider + * @dataProvider invalidProvider */ - public function validProvider() { - $strings = [ - 'ice cream', - 'cake', - '', - ' a ', - ' ', - ]; - - $argLists = []; - - foreach ( $strings as $string ) { - $argLists[] = [ new StringValue( $string ), $string ]; - } + public function testInvalidFormat( $value ) { + $formatter = new StringFormatter(); + $this->expectException( InvalidArgumentException::class ); + $formatter->format( $value ); + } - return $argLists; + public function invalidProvider() { + return [ + [ null ], + [ 0 ], + [ '' ], + ]; } } diff --git a/tests/ValueParsers/BoolParserTest.php b/tests/ValueParsers/BoolParserTest.php index ea06387..2c2bfc5 100644 --- a/tests/ValueParsers/BoolParserTest.php +++ b/tests/ValueParsers/BoolParserTest.php @@ -1,17 +1,20 @@ */ class BoolParserTest extends StringValueParserTest { @@ -29,30 +32,21 @@ protected function getInstance() { * @see ValueParserTestBase::validInputProvider */ public function validInputProvider() { - $argLists = []; - - $valid = [ - 'yes' => true, - 'on' => true, - '1' => true, - 'true' => true, - 'no' => false, - 'off' => false, - '0' => false, - 'false' => false, + return [ + [ 'yes', new BooleanValue( true ) ], + [ 'on', new BooleanValue( true ) ], + [ '1', new BooleanValue( true ) ], + [ 'true', new BooleanValue( true ) ], + [ 'no', new BooleanValue( false ) ], + [ 'off', new BooleanValue( false ) ], + [ '0', new BooleanValue( false ) ], + [ 'false', new BooleanValue( false ) ], - 'YeS' => true, - 'ON' => true, - 'No' => false, - 'OfF' => false, + [ 'YeS', new BooleanValue( true ) ], + [ 'ON', new BooleanValue( true ) ], + [ 'No', new BooleanValue( false ) ], + [ 'OfF', new BooleanValue( false ) ], ]; - - foreach ( $valid as $value => $expected ) { - $expected = new BooleanValue( $expected ); - $argLists[] = [ (string)$value, $expected ]; - } - - return $argLists; } /** diff --git a/tests/ValueParsers/DispatchingValueParserTest.php b/tests/ValueParsers/DispatchingValueParserTest.php index 964e5ac..7d42056 100644 --- a/tests/ValueParsers/DispatchingValueParserTest.php +++ b/tests/ValueParsers/DispatchingValueParserTest.php @@ -1,51 +1,47 @@ getMock( 'ValueParsers\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; } /** * @dataProvider invalidConstructorArgumentsProvider - * @expectedException InvalidArgumentException */ public function testGivenInvalidConstructorArguments_constructorThrowsException( $parsers, $format ) { + $this->expectException( InvalidArgumentException::class ); new DispatchingValueParser( $parsers, $format ); } @@ -81,7 +77,7 @@ public function testParseThrowsException() { 'format' ); - $this->setExpectedException( 'ValueParsers\ParseException' ); + $this->expectException( ParseException::class ); $parser->parse( 'invalid' ); } diff --git a/tests/ValueParsers/FloatParserTest.php b/tests/ValueParsers/FloatParserTest.php index b3ef453..c931ed2 100644 --- a/tests/ValueParsers/FloatParserTest.php +++ b/tests/ValueParsers/FloatParserTest.php @@ -1,17 +1,20 @@ */ class FloatParserTest extends StringValueParserTest { @@ -29,41 +32,26 @@ protected function getInstance() { * @see ValueParserTestBase::validInputProvider */ public function validInputProvider() { - $argLists = []; - - $valid = [ + return [ // Ignoring a single trailing newline is an intended PCRE feature - "0\n" => 0, - - '0' => 0, - '1' => 1, - '42' => 42, - '01' => 01, - '9001' => 9001, - '-1' => -1, - '-42' => -42, - - '0.0' => 0, - '1.0' => 1, - '4.2' => 4.2, - '0.1' => 0.1, - '90.01' => 90.01, - '-1.0' => -1, - '-4.2' => -4.2, + [ "0\n", new NumberValue( 0.0 ) ], + + [ '0', new NumberValue( 0.0 ) ], + [ '1', new NumberValue( 1.0 ) ], + [ '42', new NumberValue( 42.0 ) ], + [ '01', new NumberValue( 1.0 ) ], + [ '9001', new NumberValue( 9001.0 ) ], + [ '-1', new NumberValue( -1.0 ) ], + [ '-42', new NumberValue( -42.0 ) ], + + [ '0.0', new NumberValue( 0.0 ) ], + [ '1.0', new NumberValue( 1.0 ) ], + [ '4.2', new NumberValue( 4.2 ) ], + [ '0.1', new NumberValue( 0.1 ) ], + [ '90.01', new NumberValue( 90.01 ) ], + [ '-1.0', new NumberValue( -1.0 ) ], + [ '-4.2', new NumberValue( -4.2 ) ], ]; - - foreach ( $valid as $value => $expected ) { - // Because PHP turns them into ints/floats using black magic - $value = (string)$value; - - // Because 1 is an int but will come out as a float - $expected = (float)$expected; - - $expected = new NumberValue( $expected ); - $argLists[] = [ $value, $expected ]; - } - - return $argLists; } /** diff --git a/tests/ValueParsers/IntParserTest.php b/tests/ValueParsers/IntParserTest.php index 3b6c608..05b442b 100644 --- a/tests/ValueParsers/IntParserTest.php +++ b/tests/ValueParsers/IntParserTest.php @@ -1,17 +1,20 @@ */ class IntParserTest extends StringValueParserTest { @@ -29,27 +32,15 @@ protected function getInstance() { * @see ValueParserTestBase::validInputProvider */ public function validInputProvider() { - $argLists = []; - - $valid = [ - '0' => 0, - '1' => 1, - '42' => 42, - '01' => 01, - '9001' => 9001, - '-1' => -1, - '-42' => -42, + return [ + [ '0', new NumberValue( 0 ) ], + [ '1', new NumberValue( 1 ) ], + [ '42', new NumberValue( 42 ) ], + [ '01', new NumberValue( 01 ) ], + [ '9001', new NumberValue( 9001 ) ], + [ '-1', new NumberValue( -1 ) ], + [ '-42', new NumberValue( -42 ) ], ]; - - foreach ( $valid as $value => $expected ) { - // Because PHP turns them into ints using black magic - $value = (string)$value; - - $expected = new NumberValue( $expected ); - $argLists[] = [ $value, $expected ]; - } - - return $argLists; } /** diff --git a/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php b/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php index 7d244b4..b568bfa 100644 --- a/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php +++ b/tests/ValueParsers/Normalizers/NullStringNormalizerTest.php @@ -1,21 +1,24 @@ setExpectedException( 'InvalidArgumentException' ); + $this->expectException( InvalidArgumentException::class ); $normalizer->normalize( $value ); } diff --git a/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php b/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php new file mode 100644 index 0000000..23e267c --- /dev/null +++ b/tests/ValueParsers/Normalizers/TrimmingStringNormalizerTest.php @@ -0,0 +1,59 @@ +assertSame( $expected, $normalizer->normalize( $value ) ); + } + + public function stringProvider() { + return [ + 'Empty' => [ '', '' ], + 'Trimmed' => [ 'a', 'a' ], + 'Spaces' => [ ' a ', 'a' ], + 'Controls' => [ "\n\r\ta\n\r\t", 'a' ], + 'Paragraph separator' => [ "\xE2\x80\xA9a\xE2\x80\xA9", 'a' ], + ]; + } + + /** + * @dataProvider invalidValueProvider + */ + public function testNormalizeException( $value ) { + $normalizer = new TrimmingStringNormalizer(); + $this->expectException( InvalidArgumentException::class ); + $normalizer->normalize( $value ); + } + + public function invalidValueProvider() { + return [ + [ null ], + [ true ], + [ 1 ], + [ new StringValue( '' ) ], + ]; + } + +} diff --git a/tests/ValueParsers/NullParserTest.php b/tests/ValueParsers/NullParserTest.php index ed1372a..1f1573e 100644 --- a/tests/ValueParsers/NullParserTest.php +++ b/tests/ValueParsers/NullParserTest.php @@ -1,18 +1,20 @@ */ class NullParserTest extends ValueParserTestBase { @@ -30,45 +32,30 @@ protected function getInstance() { * @see ValueParserTestBase::validInputProvider */ public function validInputProvider() { - $argLists = []; - - $values = [ - '42', - 42, - false, - [], - 'ohi there!', - null, - 4.2, + return [ + [ '42', new UnknownValue( '42' ) ], + [ 42, new UnknownValue( 42 ) ], + [ false, new UnknownValue( false ) ], + [ [], new UnknownValue( [] ) ], + [ 'ohi there!', new UnknownValue( 'ohi there!' ) ], + [ null, new UnknownValue( null ) ], + [ 4.2, new UnknownValue( 4.2 ) ], ]; - - foreach ( $values as $value ) { - $argLists[] = [ - $value, - new UnknownValue( $value ) - ]; - } - - return $argLists; } /** * @see ValueParserTestBase::invalidInputProvider */ public function invalidInputProvider() { - return [ - [ null ] - ]; + return [ [ null ] ]; } /** * @see ValueParserTestBase::testParseWithInvalidInputs * * @dataProvider invalidInputProvider - * @param mixed $value - * @param ValueParser|null $parser */ - 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 42b90bc..c707846 100644 --- a/tests/ValueParsers/StringParserTest.php +++ b/tests/ValueParsers/StringParserTest.php @@ -1,30 +1,34 @@ getMock( 'ValueParsers\Normalizers\StringNormalizer' ); + $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' ) ], @@ -35,11 +39,11 @@ 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 ); - $this->assertInstanceOf( 'DataValues\StringValue', $value ); + $this->assertInstanceOf( StringValue::class, $value ); $this->assertEquals( $expected->toArray(), $value->toArray() ); } @@ -56,7 +60,9 @@ public function nonStringProvider() { */ public function testGivenNonString_parseThrowsException( $input ) { $parser = new StringParser(); - $this->setExpectedException( 'InvalidArgumentException' ); + + $this->expectException( ParseException::class ); + $parser->parse( $input ); } diff --git a/tests/ValueParsers/StringValueParserTest.php b/tests/ValueParsers/StringValueParserTest.php index 331250a..b312f4e 100644 --- a/tests/ValueParsers/StringValueParserTest.php +++ b/tests/ValueParsers/StringValueParserTest.php @@ -1,19 +1,19 @@ */ abstract class StringValueParserTest extends ValueParserTestBase { @@ -33,21 +33,11 @@ public function invalidInputProvider() { } public function testSetAndGetOptions() { - /** - * @var StringValueParser $parser - */ + /** @var StringValueParser $parser */ $parser = $this->getInstance(); - - $parser->setOptions( new ParserOptions() ); - - $this->assertEquals( new ParserOptions(), $parser->getOptions() ); - $options = new ParserOptions(); - $options->setOption( '~=[,,_,,]:3', '~=[,,_,,]:3' ); - $parser->setOptions( $options ); - - $this->assertEquals( $options, $parser->getOptions() ); + $this->assertSame( $options, $parser->getOptions() ); } } diff --git a/tests/ValueParsers/ValueParserTestBase.php b/tests/ValueParsers/ValueParserTestBase.php index 3646899..cf5fdd9 100644 --- a/tests/ValueParsers/ValueParserTestBase.php +++ b/tests/ValueParsers/ValueParserTestBase.php @@ -1,10 +1,13 @@ */ -abstract class ValueParserTestBase extends PHPUnit_Framework_TestCase { +abstract class ValueParserTestBase extends TestCase { /** - * @since 0.1 - * * @return array[] */ - public abstract function validInputProvider(); + abstract public function validInputProvider(); /** - * @since 0.1 - * * @return array[] */ - public abstract function invalidInputProvider(); + abstract public function invalidInputProvider(); /** - * @since 0.1 - * * @return ValueParser */ - protected abstract function getInstance(); + abstract protected function getInstance(); /** - * @since 0.1 - * * @dataProvider validInputProvider * @param mixed $value * @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(); } @@ -78,26 +73,22 @@ private function assertSmartEquals( $expected, $actual ) { } /** - * @since 0.1 - * * @dataProvider invalidInputProvider * @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(); } - $this->setExpectedException( 'ValueParsers\ParseException' ); + $this->expectException( ParseException::class ); $parser->parse( $value ); } /** * Returns if the result of the parsing process should be checked to be a DataValue. * - * @since 0.1 - * * @return bool */ protected function requireDataValue() { diff --git a/tests/bootstrap.php b/tests/bootstrap.php index ac82d46..f3efb2a 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,11 +1,13 @@