Legoktm has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/371090 )
Change subject: Revert "Wikibase: "data-values/interfaces": "0.2.5"" ...................................................................... Revert "Wikibase: "data-values/interfaces": "0.2.5"" This reverts commit 464d93b07414bff25df8c138bf86c191922c88ca. Change-Id: I811e4d028ce606f2917766d5e2e9da0d162daf7e --- M composer.json M composer.lock M composer/autoload_classmap.php M composer/autoload_files.php M composer/autoload_psr4.php M composer/autoload_static.php M composer/installed.json D data-values/interfaces/COPYING D data-values/interfaces/Interfaces.php D data-values/interfaces/README.md D data-values/interfaces/src/ValueFormatters/FormatterOptions.php D data-values/interfaces/src/ValueFormatters/FormattingException.php D data-values/interfaces/src/ValueFormatters/ValueFormatter.php D data-values/interfaces/src/ValueFormatters/ValueFormatterBase.php D data-values/interfaces/src/ValueParsers/ParseException.php D data-values/interfaces/src/ValueParsers/ParserOptions.php D data-values/interfaces/src/ValueParsers/ValueParser.php D data-values/interfaces/src/ValueValidators/Error.php D data-values/interfaces/src/ValueValidators/Result.php D data-values/interfaces/src/ValueValidators/ValueValidator.php D data-values/interfaces/src/ValueValidators/ValueValidatorObject.php D data-values/interfaces/tests/ValueFormatters/FormatterOptionsTest.php D data-values/interfaces/tests/ValueFormatters/ValueFormatterTestBase.php D data-values/interfaces/tests/ValueParsers/ParserOptionsTest.php D data-values/interfaces/tests/ValueValidators/ErrorTest.php D data-values/interfaces/tests/ValueValidators/ResultTest.php D data-values/interfaces/tests/bootstrap.php 27 files changed, 1 insertion(+), 2,185 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vendor refs/changes/90/371090/1 diff --git a/composer.json b/composer.json index 4fef5da..ec0ca59 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,6 @@ "require": { "composer/semver": "1.4.2", "cssjanus/cssjanus": "1.2.0", - "data-values/interfaces": "0.2.5", "diff/diff": "2.2.0", "firebase/php-jwt": "4.0.0", "james-heinrich/getid3": "1.9.14", diff --git a/composer.lock b/composer.lock index 5eca5be..4186276 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "776381472caad0924789a3f947d84b8f", + "content-hash": "8413b7a26368b44d5d2d0a9879691d22", "packages": [ { "name": "composer/semver", @@ -102,64 +102,6 @@ ], "description": "Convert CSS stylesheets between left-to-right and right-to-left.", "time": "2017-03-14T20:57:08+00:00" - }, - { - "name": "data-values/interfaces", - "version": "0.2.5", - "source": { - "type": "git", - "url": "https://github.com/DataValues/Interfaces.git", - "reference": "441a5c3c4d1ac8998ee95a0aafbf30e1064ae6f4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/DataValues/Interfaces/zipball/441a5c3c4d1ac8998ee95a0aafbf30e1064ae6f4", - "reference": "441a5c3c4d1ac8998ee95a0aafbf30e1064ae6f4", - "shasum": "" - }, - "require": { - "php": ">=5.5.9" - }, - "require-dev": { - "phpunit/phpunit": "~4.8", - "wikibase/wikibase-codesniffer": "^0.1.0" - }, - "type": "library", - "autoload": { - "files": [ - "Interfaces.php" - ], - "psr-4": { - "ValueFormatters\\": "src/ValueFormatters/", - "ValueParsers\\": "src/ValueParsers/", - "ValueValidators\\": "src/ValueValidators/" - }, - "classmap": [ - "tests/ValueFormatters/ValueFormatterTestBase.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0+" - ], - "authors": [ - { - "name": "Jeroen De Dauw", - "email": "jeroended...@gmail.com", - "homepage": "http://jeroendedauw.com", - "role": "Developer" - } - ], - "description": "Defines interfaces for ValueParsers, ValueFormatters and ValueValidators", - "homepage": "https://github.com/DataValues/Interfaces", - "keywords": [ - "datavalues", - "valueformatters", - "valueparsers", - "valuevalidators", - "wikidata" - ], - "time": "2017-08-09T15:18:46+00:00" }, { "name": "diff/diff", diff --git a/composer/autoload_classmap.php b/composer/autoload_classmap.php index 465a98c..d5a0e87 100644 --- a/composer/autoload_classmap.php +++ b/composer/autoload_classmap.php @@ -721,18 +721,6 @@ 'UtfNormal\\Constants' => $vendorDir . '/wikimedia/utfnormal/src/Constants.php', 'UtfNormal\\Utils' => $vendorDir . '/wikimedia/utfnormal/src/Util.php', 'UtfNormal\\Validator' => $vendorDir . '/wikimedia/utfnormal/src/Validator.php', - 'ValueFormatters\\FormatterOptions' => $vendorDir . '/data-values/interfaces/src/ValueFormatters/FormatterOptions.php', - 'ValueFormatters\\FormattingException' => $vendorDir . '/data-values/interfaces/src/ValueFormatters/FormattingException.php', - 'ValueFormatters\\Test\\ValueFormatterTestBase' => $vendorDir . '/data-values/interfaces/tests/ValueFormatters/ValueFormatterTestBase.php', - 'ValueFormatters\\ValueFormatter' => $vendorDir . '/data-values/interfaces/src/ValueFormatters/ValueFormatter.php', - 'ValueFormatters\\ValueFormatterBase' => $vendorDir . '/data-values/interfaces/src/ValueFormatters/ValueFormatterBase.php', - 'ValueParsers\\ParseException' => $vendorDir . '/data-values/interfaces/src/ValueParsers/ParseException.php', - 'ValueParsers\\ParserOptions' => $vendorDir . '/data-values/interfaces/src/ValueParsers/ParserOptions.php', - 'ValueParsers\\ValueParser' => $vendorDir . '/data-values/interfaces/src/ValueParsers/ValueParser.php', - 'ValueValidators\\Error' => $vendorDir . '/data-values/interfaces/src/ValueValidators/Error.php', - 'ValueValidators\\Result' => $vendorDir . '/data-values/interfaces/src/ValueValidators/Result.php', - 'ValueValidators\\ValueValidator' => $vendorDir . '/data-values/interfaces/src/ValueValidators/ValueValidator.php', - 'ValueValidators\\ValueValidatorObject' => $vendorDir . '/data-values/interfaces/src/ValueValidators/ValueValidatorObject.php', 'Wikimedia\\Assert\\Assert' => $vendorDir . '/wikimedia/assert/src/Assert.php', 'Wikimedia\\Assert\\AssertionException' => $vendorDir . '/wikimedia/assert/src/AssertionException.php', 'Wikimedia\\Assert\\InvariantException' => $vendorDir . '/wikimedia/assert/src/InvariantException.php', diff --git a/composer/autoload_files.php b/composer/autoload_files.php index 804fbdf..dd1cdd3 100644 --- a/composer/autoload_files.php +++ b/composer/autoload_files.php @@ -13,5 +13,4 @@ 'd55c27a601de788b19a09b7d057d07ae' => $vendorDir . '/wikimedia/relpath/src/RelPath.php', 'f4c767faab43077fd89ff7cf99ffb4b8' => $vendorDir . '/serialization/serialization/Serialization.php', '3ef87127dc6892a0a78f223558a0b940' => $vendorDir . '/diff/diff/Diff.php', - 'd1715cacc3c23b16a030645514266a76' => $vendorDir . '/data-values/interfaces/Interfaces.php', ); diff --git a/composer/autoload_psr4.php b/composer/autoload_psr4.php index ea23663..f376c88 100644 --- a/composer/autoload_psr4.php +++ b/composer/autoload_psr4.php @@ -12,9 +12,6 @@ 'Wikimedia\\Composer\\' => array($vendorDir . '/wikimedia/composer-merge-plugin/src'), 'Wikimedia\\Assert\\Test\\' => array($vendorDir . '/wikimedia/assert/tests/phpunit'), 'Wikimedia\\Assert\\' => array($vendorDir . '/wikimedia/assert/src'), - 'ValueValidators\\' => array($vendorDir . '/data-values/interfaces/src/ValueValidators'), - 'ValueParsers\\' => array($vendorDir . '/data-values/interfaces/src/ValueParsers'), - 'ValueFormatters\\' => array($vendorDir . '/data-values/interfaces/src/ValueFormatters'), 'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'), 'Serializers\\' => array($vendorDir . '/serialization/serialization/src/Serializers'), 'RemexHtml\\' => array($vendorDir . '/wikimedia/remex-html/RemexHtml'), diff --git a/composer/autoload_static.php b/composer/autoload_static.php index fa1ba32..b1fa3e8 100644 --- a/composer/autoload_static.php +++ b/composer/autoload_static.php @@ -14,7 +14,6 @@ 'd55c27a601de788b19a09b7d057d07ae' => __DIR__ . '/..' . '/wikimedia/relpath/src/RelPath.php', 'f4c767faab43077fd89ff7cf99ffb4b8' => __DIR__ . '/..' . '/serialization/serialization/Serialization.php', '3ef87127dc6892a0a78f223558a0b940' => __DIR__ . '/..' . '/diff/diff/Diff.php', - 'd1715cacc3c23b16a030645514266a76' => __DIR__ . '/..' . '/data-values/interfaces/Interfaces.php', ); public static $prefixLengthsPsr4 = array ( @@ -26,12 +25,6 @@ 'Wikimedia\\Composer\\' => 19, 'Wikimedia\\Assert\\Test\\' => 22, 'Wikimedia\\Assert\\' => 17, - ), - 'V' => - array ( - 'ValueValidators\\' => 16, - 'ValueParsers\\' => 13, - 'ValueFormatters\\' => 16, ), 'S' => array ( @@ -102,18 +95,6 @@ 'Wikimedia\\Assert\\' => array ( 0 => __DIR__ . '/..' . '/wikimedia/assert/src', - ), - 'ValueValidators\\' => - array ( - 0 => __DIR__ . '/..' . '/data-values/interfaces/src/ValueValidators', - ), - 'ValueParsers\\' => - array ( - 0 => __DIR__ . '/..' . '/data-values/interfaces/src/ValueParsers', - ), - 'ValueFormatters\\' => - array ( - 0 => __DIR__ . '/..' . '/data-values/interfaces/src/ValueFormatters', ), 'Symfony\\Component\\Process\\' => array ( @@ -956,18 +937,6 @@ 'UtfNormal\\Constants' => __DIR__ . '/..' . '/wikimedia/utfnormal/src/Constants.php', 'UtfNormal\\Utils' => __DIR__ . '/..' . '/wikimedia/utfnormal/src/Util.php', 'UtfNormal\\Validator' => __DIR__ . '/..' . '/wikimedia/utfnormal/src/Validator.php', - 'ValueFormatters\\FormatterOptions' => __DIR__ . '/..' . '/data-values/interfaces/src/ValueFormatters/FormatterOptions.php', - 'ValueFormatters\\FormattingException' => __DIR__ . '/..' . '/data-values/interfaces/src/ValueFormatters/FormattingException.php', - 'ValueFormatters\\Test\\ValueFormatterTestBase' => __DIR__ . '/..' . '/data-values/interfaces/tests/ValueFormatters/ValueFormatterTestBase.php', - 'ValueFormatters\\ValueFormatter' => __DIR__ . '/..' . '/data-values/interfaces/src/ValueFormatters/ValueFormatter.php', - 'ValueFormatters\\ValueFormatterBase' => __DIR__ . '/..' . '/data-values/interfaces/src/ValueFormatters/ValueFormatterBase.php', - 'ValueParsers\\ParseException' => __DIR__ . '/..' . '/data-values/interfaces/src/ValueParsers/ParseException.php', - 'ValueParsers\\ParserOptions' => __DIR__ . '/..' . '/data-values/interfaces/src/ValueParsers/ParserOptions.php', - 'ValueParsers\\ValueParser' => __DIR__ . '/..' . '/data-values/interfaces/src/ValueParsers/ValueParser.php', - 'ValueValidators\\Error' => __DIR__ . '/..' . '/data-values/interfaces/src/ValueValidators/Error.php', - 'ValueValidators\\Result' => __DIR__ . '/..' . '/data-values/interfaces/src/ValueValidators/Result.php', - 'ValueValidators\\ValueValidator' => __DIR__ . '/..' . '/data-values/interfaces/src/ValueValidators/ValueValidator.php', - 'ValueValidators\\ValueValidatorObject' => __DIR__ . '/..' . '/data-values/interfaces/src/ValueValidators/ValueValidatorObject.php', 'Wikimedia\\Assert\\Assert' => __DIR__ . '/..' . '/wikimedia/assert/src/Assert.php', 'Wikimedia\\Assert\\AssertionException' => __DIR__ . '/..' . '/wikimedia/assert/src/AssertionException.php', 'Wikimedia\\Assert\\InvariantException' => __DIR__ . '/..' . '/wikimedia/assert/src/InvariantException.php', diff --git a/composer/installed.json b/composer/installed.json index 8bcd686..56d0349 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -2523,65 +2523,5 @@ "patching", "wikidata" ] - }, - { - "name": "data-values/interfaces", - "version": "0.2.5", - "version_normalized": "0.2.5.0", - "source": { - "type": "git", - "url": "https://github.com/DataValues/Interfaces.git", - "reference": "441a5c3c4d1ac8998ee95a0aafbf30e1064ae6f4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/DataValues/Interfaces/zipball/441a5c3c4d1ac8998ee95a0aafbf30e1064ae6f4", - "reference": "441a5c3c4d1ac8998ee95a0aafbf30e1064ae6f4", - "shasum": "" - }, - "require": { - "php": ">=5.5.9" - }, - "require-dev": { - "phpunit/phpunit": "~4.8", - "wikibase/wikibase-codesniffer": "^0.1.0" - }, - "time": "2017-08-09T15:18:46+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "files": [ - "Interfaces.php" - ], - "psr-4": { - "ValueFormatters\\": "src/ValueFormatters/", - "ValueParsers\\": "src/ValueParsers/", - "ValueValidators\\": "src/ValueValidators/" - }, - "classmap": [ - "tests/ValueFormatters/ValueFormatterTestBase.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0+" - ], - "authors": [ - { - "name": "Jeroen De Dauw", - "email": "jeroended...@gmail.com", - "homepage": "http://jeroendedauw.com", - "role": "Developer" - } - ], - "description": "Defines interfaces for ValueParsers, ValueFormatters and ValueValidators", - "homepage": "https://github.com/DataValues/Interfaces", - "keywords": [ - "datavalues", - "valueformatters", - "valueparsers", - "valuevalidators", - "wikidata" - ] } ] diff --git a/data-values/interfaces/COPYING b/data-values/interfaces/COPYING deleted file mode 100644 index ebba08a..0000000 --- a/data-values/interfaces/COPYING +++ /dev/null @@ -1,347 +0,0 @@ -The license text below "----" applies to all files within this distribution, other -than those that are in a directory which contains files named "LICENSE" or -"COPYING", or a subdirectory thereof. For those files, the license text contained in -said file overrides any license information contained in directories of smaller depth. -Alternative licenses are typically used for software that is provided by external -parties, and merely packaged with this software for convenience. ----- - - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/data-values/interfaces/Interfaces.php b/data-values/interfaces/Interfaces.php deleted file mode 100644 index d349502..0000000 --- a/data-values/interfaces/Interfaces.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -/** - * Entry point of the DataValues Interfaces library. - * - * @since 0.1 - * @codeCoverageIgnore - * - * @license GPL-2.0+ - * @author Jeroen De Dauw < jeroended...@gmail.com > - */ - -if ( defined( 'DATAVALUES_INTERFACES_VERSION' ) ) { - // Do not initialize more than once. - return 1; -} - -define( 'DATAVALUES_INTERFACES_VERSION', '0.2.5' ); diff --git a/data-values/interfaces/README.md b/data-values/interfaces/README.md deleted file mode 100644 index 96d5789..0000000 --- a/data-values/interfaces/README.md +++ /dev/null @@ -1,119 +0,0 @@ -# DataValues Interfaces - -DataValues Interfaces is a small PHP library that defines a set of interfaces for parsers, -formatters and validators. - -It is part of the [DataValues set of libraries](https://github.com/DataValues). - -[![Build Status](https://secure.travis-ci.org/DataValues/Interfaces.png?branch=master)](http://travis-ci.org/DataValues/Interfaces) -[![Code Coverage](https://scrutinizer-ci.com/g/DataValues/Interfaces/badges/coverage.png?s=6432d29bf3fed068995e66093ad52e053099a916)](https://scrutinizer-ci.com/g/DataValues/Interfaces/) -[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/DataValues/Interfaces/badges/quality-score.png?s=da1bb6ea09762d9e3a143e473cdefa712db46804)](https://scrutinizer-ci.com/g/DataValues/Interfaces/) - -On [Packagist](https://packagist.org/packages/data-values/interfaces): -[![Latest Stable Version](https://poser.pugx.org/data-values/interfaces/version.png)](https://packagist.org/packages/data-values/interfaces) -[![Download count](https://poser.pugx.org/data-values/interfaces/d/total.png)](https://packagist.org/packages/data-values/interfaces) - -## Requirements - -* PHP 5.5 or later - -## Installation - -You can use [Composer](http://getcomposer.org/) to download and install -this package as well as its dependencies. Alternatively you can simply clone -the git repository and take care of loading yourself. - -### Composer - -To add this package as a local, per-project dependency to your project, simply add a -dependency on `data-values/interfaces` to your project's `composer.json` file. -Here is a minimal example of a `composer.json` file that just defines a dependency on -DataValues Interfaces 0.2: - - { - "require": { - "data-values/interfaces": "0.2.*" - } - } - -### Manual - -Get the DataValues Interfaces code, either via git, or some other means. Also get all dependencies. -You can find a list of the dependencies in the "require" section of the composer.json file. -Load all dependencies and the load the DataValues Interfaces library by including its entry point: -Interfaces.php. - -## Tests - -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. - -## Authors - -DataValues Interfaces has been written by [Jeroen De Dauw](https://www.mediawiki.org/wiki/User:Jeroen_De_Dauw), -as [Wikimedia Germany](https://wikimedia.de) employee for the [Wikidata project](https://wikidata.org/). - -## Release notes - -### 0.2.5 (2017-08-09) - -* Removed MediaWiki extension credits registration - -### 0.2.4 (2017-08-02) - -* Fixed `ValueFormatterTestBase` not being installable via Composer. - -### 0.2.3 (2017-08-02) - -* Updated minimal required PHP version from 5.3 to 5.5.9. -* Minor fixes to code documentation. -* Added PHPCS support. - -### 0.2.2 (2016-07-15) - -* Fixed `ValueFormatterTestBase` not doing strict string comparisons. - -### 0.2.1 (2016-01-13) - -* Fixed an issue when using this component with HHVM 1.11.0 (see #21). - -### 0.2.0 (2015-08-11) - -* Dropped deprecated `ErrorObject`, use `Error` instead -* Dropped deprecated `ResultObject`, use `Result` instead -* Dropped deprecated constant `DataValuesInterfaces_VERSION`, use `DATAVALUES_INTERFACES_VERSION` instead -* Dropped `ValueFormatterTestBase::getFormatterClass` -* Made `ValueFormatterTestBase::getInstance` abstract -* The options in `ValueFormatterTestBase::getInstance` are now optional - -### 0.1.5 (2015-02-14) - -* The options in the `ValueFormatterBase` constructor are now optional -* The MediaWiki extension registration now includes the license - -### 0.1.4 (2014-04-14) - -* Added rawValue and expectedFormat arguments to `ValueParsers\ParseException` - -### 0.1.3 (2014-03-31) - -* Added `ValueFormatters\FormattingException` - -### 0.1.2 (2013-11-22) - -* Improved autoloading code -* Fixed link in MediaWiki credits -* Renamed entry point from DataValuesInterfaces.php to Interfaces.php - -### 0.1.0 (2013-11-16) - -Initial release with these features: - -* `ValueFormatters\ValueFormatter` interface -* `ValueParsers\ValueParser` interface -* `ValueValidators\ValueValidator` interface - -## Links - -* [DataValues Interfaces on Packagist](https://packagist.org/packages/data-values/interfaces) diff --git a/data-values/interfaces/src/ValueFormatters/FormatterOptions.php b/data-values/interfaces/src/ValueFormatters/FormatterOptions.php deleted file mode 100644 index 133f01e..0000000 --- a/data-values/interfaces/src/ValueFormatters/FormatterOptions.php +++ /dev/null @@ -1,123 +0,0 @@ -<?php - -namespace ValueFormatters; - -use InvalidArgumentException; -use OutOfBoundsException; -use RuntimeException; - -/** - * Object holding options for a formatter. - * - * @since 0.1 - * - * @license GPL-2.0+ - * @author Jeroen De Dauw < jeroended...@gmail.com > - */ -final class FormatterOptions { - - /** - * @since 0.1 - * - * @var array - */ - protected $options; - - /** - * @since 0.1 - * - * @param array $options - * - * @throws InvalidArgumentException - */ - public function __construct( array $options = [] ) { - foreach ( array_keys( $options ) as $option ) { - if ( !is_string( $option ) ) { - throw new InvalidArgumentException( 'Option names need to be strings' ); - } - } - - $this->options = $options; - } - - /** - * Sets the value of the specified option. - * - * @since 0.1 - * - * @param string $option - * @param mixed $value - * - * @throws InvalidArgumentException - */ - public function setOption( $option, $value ) { - if ( !is_string( $option ) ) { - throw new InvalidArgumentException( 'Option name needs to be a string' ); - } - - $this->options[$option] = $value; - } - - /** - * Returns the value of the specified option. If the option is not set, - * an InvalidArgumentException is thrown. - * - * @since 0.1 - * - * @param string $option - * - * @throws OutOfBoundsException - * @return mixed - */ - public function getOption( $option ) { - if ( !array_key_exists( $option, $this->options ) ) { - throw new OutOfBoundsException( "Option '$option' has not been set so cannot be obtained" ); - } - - return $this->options[$option]; - } - - /** - * Returns if the specified option is set or not. - * - * @since 0.1 - * - * @param string $option - * - * @return bool - */ - public function hasOption( $option ) { - return array_key_exists( $option, $this->options ); - } - - /** - * Sets the value of an option to the provided default in case the option is not set yet. - * - * @since 0.1 - * - * @param string $option - * @param mixed $default - */ - public function defaultOption( $option, $default ) { - if ( !$this->hasOption( $option ) ) { - $this->setOption( $option, $default ); - } - } - - /** - * Requires an option to be set. - * If it's not set, a RuntimeException is thrown. - * - * @since 0.1 - * - * @param string $option - * - * @throws RuntimeException - */ - public function requireOption( $option ) { - if ( !$this->hasOption( $option ) ) { - throw new RuntimeException( 'Required option"' . $option . '" is not set' ); - } - } - -} diff --git a/data-values/interfaces/src/ValueFormatters/FormattingException.php b/data-values/interfaces/src/ValueFormatters/FormattingException.php deleted file mode 100644 index afda722..0000000 --- a/data-values/interfaces/src/ValueFormatters/FormattingException.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php - -namespace ValueFormatters; - -use RuntimeException; - -/** - * @since 0.1.3 - * - * @license GPL-2.0+ - * @author Jeroen De Dauw < jeroended...@gmail.com > - */ -class FormattingException extends RuntimeException { - -} diff --git a/data-values/interfaces/src/ValueFormatters/ValueFormatter.php b/data-values/interfaces/src/ValueFormatters/ValueFormatter.php deleted file mode 100644 index 909b314..0000000 --- a/data-values/interfaces/src/ValueFormatters/ValueFormatter.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php - -namespace ValueFormatters; - -/** - * Interface for value formatters, typically (but not limited to) expecting a DataValue object and - * returning a string. - * - * @since 0.1 - * - * @license GPL-2.0+ - * @author Jeroen De Dauw < jeroended...@gmail.com > - */ -interface ValueFormatter { - - /** - * Identifier for the option that holds the code of the language in which the formatter should - * operate. - * @since 0.1 - */ - const OPT_LANG = 'lang'; - - /** - * @since 0.1 - * - * @param mixed $value - * - * @return mixed - * @throws FormattingException - */ - public function format( $value ); - -} diff --git a/data-values/interfaces/src/ValueFormatters/ValueFormatterBase.php b/data-values/interfaces/src/ValueFormatters/ValueFormatterBase.php deleted file mode 100644 index 3fd7ca2..0000000 --- a/data-values/interfaces/src/ValueFormatters/ValueFormatterBase.php +++ /dev/null @@ -1,67 +0,0 @@ -<?php - -namespace ValueFormatters; - -/** - * Base class for ValueFormatters. - * - * @since 0.1 - * - * @license GPL-2.0+ - * @author Jeroen De Dauw < jeroended...@gmail.com > - */ -abstract class ValueFormatterBase implements ValueFormatter { - - /** - * @since 0.1 - * - * @var FormatterOptions - */ - protected $options; - - /** - * @since 0.1 - * - * @param FormatterOptions|null $options - */ - public function __construct( FormatterOptions $options = null ) { - $this->options = $options ?: new FormatterOptions(); - - $this->options->defaultOption( ValueFormatter::OPT_LANG, 'en' ); - } - - /** - * Shortcut to $this->options->getOption. - * - * @since 0.1 - * - * @param string $option - * - * @return mixed - */ - final protected function getOption( $option ) { - return $this->options->getOption( $option ); - } - - /** - * Shortcut to $this->options->requireOption. - * - * @param string $option - */ - final protected function requireOption( $option ) { - $this->options->requireOption( $option ); - } - - /** - * Shortcut to $this->options->defaultOption. - * - * @since 0.1 - * - * @param string $option - * @param mixed $default - */ - final protected function defaultOption( $option, $default ) { - $this->options->defaultOption( $option, $default ); - } - -} diff --git a/data-values/interfaces/src/ValueParsers/ParseException.php b/data-values/interfaces/src/ValueParsers/ParseException.php deleted file mode 100644 index 151d9a5..0000000 --- a/data-values/interfaces/src/ValueParsers/ParseException.php +++ /dev/null @@ -1,67 +0,0 @@ -<?php - -namespace ValueParsers; - -use RuntimeException; - -/** - * @since 0.1 - * - * @license GPL-2.0+ - * @author Jeroen De Dauw < jeroended...@gmail.com > - */ -class ParseException extends RuntimeException { - - /** - * @var string|null - */ - private $expectedFormat; - - /** - * @var string|null - */ - private $rawValue; - - /** - * @param string $message A plain english message describing the error - * @param string|null $rawValue The raw value that failed to be parsed. - * @param string|null $expectedFormat An identifier for the format the raw value - * did not match - * - * @since 0.1.4 - */ - public function __construct( $message, $rawValue = null, $expectedFormat = null ) { - parent::__construct( $message ); - $this->expectedFormat = $expectedFormat; - $this->rawValue = $rawValue; - } - - /** - * An identifier for the format the raw value did not match. - * - * This does not necessarily specify the exact format the throwing parser accepts. - * For example, a PositiveFloatParser might throw a ParseException with the - * expected format 'float' if the value does not even parse as a float, while - * in fact the parser would only accept positive floats. However, if the user - * enters a negative float, the parser must throw with a more specific format, - * i. e. 'positive-float'. - * - * @since 0.1.4 - */ - public function getExpectedFormat() { - return $this->expectedFormat; - } - - /** - * The raw value which was not parsable. - * - * This is not necessarily the value an user entered, but the rawest value - * that's available at the throwing site. - * - * @since 0.1.4 - */ - public function getRawValue() { - return $this->rawValue; - } - -} diff --git a/data-values/interfaces/src/ValueParsers/ParserOptions.php b/data-values/interfaces/src/ValueParsers/ParserOptions.php deleted file mode 100644 index d06413f..0000000 --- a/data-values/interfaces/src/ValueParsers/ParserOptions.php +++ /dev/null @@ -1,122 +0,0 @@ -<?php - -namespace ValueParsers; - -use InvalidArgumentException; -use RuntimeException; - -/** - * Object holding options for a parser. - * - * @since 0.1 - * - * @license GPL-2.0+ - * @author Jeroen De Dauw < jeroended...@gmail.com > - */ -final class ParserOptions { - - /** - * @since 0.1 - * - * @var array - */ - protected $options; - - /** - * @since 0.1 - * - * @param array $options - * - * @throws InvalidArgumentException - */ - public function __construct( array $options = [] ) { - foreach ( array_keys( $options ) as $option ) { - if ( !is_string( $option ) ) { - throw new InvalidArgumentException( 'Option names need to be strings.' ); - } - } - - $this->options = $options; - } - - /** - * Sets the value of the specified option. - * - * @since 0.1 - * - * @param string $option - * @param mixed $value - * - * @throws InvalidArgumentException - */ - public function setOption( $option, $value ) { - if ( !is_string( $option ) ) { - throw new InvalidArgumentException( 'Option name needs to be a string.' ); - } - - $this->options[$option] = $value; - } - - /** - * Returns the value of the specified option. If the option is not set, - * an InvalidArgumentException is thrown. - * - * @since 0.1 - * - * @param string $option - * - * @throws InvalidArgumentException - * @return mixed - */ - public function getOption( $option ) { - if ( !array_key_exists( $option, $this->options ) ) { - throw new InvalidArgumentException(); - } - - return $this->options[$option]; - } - - /** - * Returns if the specified option is set or not. - * - * @since 0.1 - * - * @param string $option - * - * @return bool - */ - public function hasOption( $option ) { - return array_key_exists( $option, $this->options ); - } - - /** - * Sets the value of an option to the provided default in case the option is not set yet. - * - * @since 0.1 - * - * @param string $option - * @param mixed $default - */ - public function defaultOption( $option, $default ) { - if ( !$this->hasOption( $option ) ) { - $this->setOption( $option, $default ); - } - } - - /** - * Requires an option to be set. - * If it's not set, a RuntimeException is thrown. - * - * @since 0.1 - * - * @param string $option - * - * @throws RuntimeException - */ - public function requireOption( $option ) { - if ( !$this->hasOption( $option ) ) { - throw new RuntimeException( 'Required option "' . $option . '" is not set.' ); - } - } - -} diff --git a/data-values/interfaces/src/ValueParsers/ValueParser.php b/data-values/interfaces/src/ValueParsers/ValueParser.php deleted file mode 100644 index c202746..0000000 --- a/data-values/interfaces/src/ValueParsers/ValueParser.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php - -namespace ValueParsers; - -/** - * Interface for value parsers, typically (but not limited to) expecting a string and returning a - * DataValue object. - * - * @since 0.1 - * - * @license GPL-2.0+ - * @author Jeroen De Dauw < jeroended...@gmail.com > - */ -interface ValueParser { - - /** - * Identifier for the option that holds the code of the language in which the parser should - * operate. - * @since 0.1 - */ - const OPT_LANG = 'lang'; - - /** - * @since 0.1 - * - * @param mixed $value - * - * @return mixed - */ - public function parse( $value ); - -} diff --git a/data-values/interfaces/src/ValueValidators/Error.php b/data-values/interfaces/src/ValueValidators/Error.php deleted file mode 100644 index a368e5e..0000000 --- a/data-values/interfaces/src/ValueValidators/Error.php +++ /dev/null @@ -1,97 +0,0 @@ -<?php - -namespace ValueValidators; - -/** - * @since 0.1 - * - * @license GPL-2.0+ - * @author Jeroen De Dauw < jeroended...@gmail.com > - */ -class Error { - - const SEVERITY_ERROR = 9; - const SEVERITY_WARNING = 4; - - protected $text; - protected $severity; - protected $property; - - protected $code; - protected $params; - - /** - * @since 0.1 - * - * @param string $text - * @param string|null $property - * @param string $code - * @param array $params - * - * @return self - */ - public static function newError( $text = '', $property = null, $code = 'invalid', array $params = [] ) { - return new static( $text, self::SEVERITY_ERROR, $property, $code, $params ); - } - - /** - * @since 0.1 - * - * @param string $text - * @param integer $severity - * @param string|null $property - * @param string $code - * @param array $params - */ - protected function __construct( $text, $severity, $property, $code, array $params ) { - $this->text = $text; - $this->severity = $severity; - $this->property = $property; - $this->code = $code; - $this->params = $params; - } - - /** - * @since 0.1 - * - * @return string - */ - public function getText() { - return $this->text; - } - - /** - * @since 0.1 - * - * @return integer, element of the ValueValidatorError::SEVERITY_ enum - */ - public function getSeverity() { - return $this->severity; - } - - /** - * Returns the property of the value for which the error occurred, or null if it occurred for the value itself. - * - * @since 0.1 - * - * @return string|null - */ - public function getProperty() { - return $this->property; - } - - /** - * @return array - */ - public function getParameters() { - return $this->params; - } - - /** - * @return string - */ - public function getCode() { - return $this->code; - } - -} diff --git a/data-values/interfaces/src/ValueValidators/Result.php b/data-values/interfaces/src/ValueValidators/Result.php deleted file mode 100644 index 3f7225b..0000000 --- a/data-values/interfaces/src/ValueValidators/Result.php +++ /dev/null @@ -1,114 +0,0 @@ -<?php - -namespace ValueValidators; - -/** - * @since 0.1 - * - * @license GPL-2.0+ - * @author Jeroen De Dauw < jeroended...@gmail.com > - */ -class Result { - - /** - * @since 0.1 - * - * @var bool - */ - protected $isValid; - - /** - * @since 0.1 - * - * @var Error[] - */ - protected $errors = []; - - /** - * @since 0.1 - * - * @return self - */ - public static function newSuccess() { - return new static( true ); - } - - /** - * @since 0.1 - * - * @param Error[] $errors - * - * @return self - */ - public static function newError( array $errors ) { - return new static( false, $errors ); - } - - /** - * Returns a result that represents the combination of the two given results. - * In particular, this means: - * - * If $a->getErrors() is empty and $a->isValid() is true, $b is returned. - * If $b->getErrors() is empty and $b->isValid() is true, $a is returned. - * - * Otherwise, a new Result is constructed that contains - * all errors from $a and $b, and is considered valid - * if both $a and $b were valid. - * - * @since 0.1 - * - * @param self $a - * @param self $b - * - * @return self - */ - public static function merge( self $a, self $b ) { - $aErrors = $a->getErrors(); - $bErrors = $b->getErrors(); - - if ( $a->isValid() && empty( $aErrors ) ) { - return $b; - } elseif ( $b->isValid() && empty( $bErrors ) ) { - return $a; - } else { - $errors = array_merge( $aErrors, $bErrors ); - $valid = ( $a->isValid() && $b->isValid() ); - - return new self( $valid, $errors ); - } - } - - /** - * @since 0.1 - * - * @param bool $isValid - * @param Error[] $errors - */ - protected function __construct( $isValid, array $errors = [] ) { - $this->isValid = $isValid; - $this->errors = $errors; - } - - /** - * Returns if the value was found to be valid or not. - * - * @since 0.1 - * - * @return bool - */ - public function isValid() { - return $this->isValid; - } - - /** - * Returns an array with the errors that occurred during validation. - * - * @since 0.1 - * - * @return Error[] - */ - public function getErrors() { - return $this->errors; - } - -} diff --git a/data-values/interfaces/src/ValueValidators/ValueValidator.php b/data-values/interfaces/src/ValueValidators/ValueValidator.php deleted file mode 100644 index ce0d1aa..0000000 --- a/data-values/interfaces/src/ValueValidators/ValueValidator.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php - -namespace ValueValidators; - -/** - * Interface for value validators. - * - * @since 0.1 - * - * @license GPL-2.0+ - * @author Jeroen De Dauw < jeroended...@gmail.com > - */ -interface ValueValidator { - - /** - * Parses a value. - * - * @since 0.1 - * - * @param mixed $value The value to validate - * - * @return Result - */ - public function validate( $value ); - - /** - * Takes an associative array with options and sets those known to the ValueValidator. - * - * @since 0.1 - * - * @param array $options - */ - public function setOptions( array $options ); - -} diff --git a/data-values/interfaces/src/ValueValidators/ValueValidatorObject.php b/data-values/interfaces/src/ValueValidators/ValueValidatorObject.php deleted file mode 100644 index e38bd5c..0000000 --- a/data-values/interfaces/src/ValueValidators/ValueValidatorObject.php +++ /dev/null @@ -1,215 +0,0 @@ -<?php - -namespace ValueValidators; - -/** - * ValueValidator that holds base validation functions for any type of object. - * - * @since 0.1 - * - * @license GPL-2.0+ - * @author Jeroen De Dauw < jeroended...@gmail.com > - */ -abstract class ValueValidatorObject implements ValueValidator { - - /** - * A list of allowed values. This means the parameters value(s) must be in the list - * during validation. False for no restriction. - * - * @since 0.1 - * - * @var array|false - */ - protected $allowedValues = false; - - /** - * A list of prohibited values. This means the parameters value(s) must - * not be in the list during validation. False for no restriction. - * - * @since 0.1 - * - * @var array|false - */ - protected $prohibitedValues = false; - - /** - * @since 0.1 - * - * @var array - */ - protected $options = []; - - /** - * @since 0.1 - * - * @var Error[] - */ - protected $errors = []; - - /** - * @see ValueValidator::validate - * - * @param mixed $value - * - * @return Result - */ - final public function validate( $value ) { - $this->errors = []; - - if ( $this->enableWhitelistRestrictions() ) { - $this->valueIsAllowed( $value ); - } - - $this->doValidation( $value ); - - if ( $this->errors === [] ) { - return Result::newSuccess(); - } else { - return Result::newError( $this->errors ); - } - } - - /** - * Checks the value against the allowed values and prohibited values lists in case they are set. - * - * @since 0.1 - * - * @param mixed $value - */ - protected function valueIsAllowed( $value ) { - if ( $this->allowedValues !== false && !in_array( $value, $this->allowedValues, true ) ) { - $this->addErrorMessage( 'Value not in whitelist' ); - } - - if ( $this->prohibitedValues !== false && in_array( $value, $this->prohibitedValues, true ) ) { - $this->addErrorMessage( 'Value in blacklist' ); - } - } - - /** - * @see ValueValidator::validate - * - * @since 0.1 - * - * @param mixed $value - */ - abstract public function doValidation( $value ); - - /** - * Sets the parameter definition values contained in the provided array. - * @see ParamDefinition::setArrayValues - * - * @param array $param - */ - public function setOptions( array $param ) { - if ( $this->enableWhitelistRestrictions() ) { - if ( array_key_exists( 'values', $param ) ) { - $this->allowedValues = $param['values']; - } - - if ( array_key_exists( 'excluding', $param ) ) { - $this->prohibitedValues = $param['excluding']; - } - } - - $this->options = $param; - } - - /** - * Registers an error message. - * - * @since 0.1 - * - * @param string $errorMessage - */ - protected function addErrorMessage( $errorMessage ) { - $this->addError( Error::newError( $errorMessage ) ); - } - - /** - * Registers an error. - * - * @since 0.1 - * - * @param Error $error - */ - protected function addError( Error $error ) { - $this->errors[] = $error; - } - - /** - * Registers a list of errors. - * - * @since 0.1 - * - * @param Error[] $errors - */ - protected function addErrors( array $errors ) { - $this->errors = array_merge( $this->errors, $errors ); - } - - /** - * Runs the value through the provided ValueValidator and registers the errors. - * Options of $this can be mapped to those of the passed ValueValidator using - * the $optionMap parameter in which keys are source names and values are target - * names. - * - * @since 0.1 - * - * @param mixed $value - * @param ValueValidator $validator - * @param string|null $property - * @param array $optionMap - */ - protected function runSubValidator( - $value, - ValueValidator $validator, - $property = null, - array $optionMap = [] - ) { - if ( $optionMap !== [] ) { - $options = []; - - foreach ( $optionMap as $source => $target ) { - if ( array_key_exists( $source, $this->options ) ) { - $options[$target] = $this->options[$source]; - } - } - - $validator->setOptions( $options ); - } - - /** - * @var Error $error - */ - foreach ( $validator->validate( $value )->getErrors() as $error ) { - $this->addError( Error::newError( $error->getText(), $property ) ); - } - } - - /** - * If the "values" and "excluding" arguments should be held into account. - * - * @since 0.1 - * - * @return bool - */ - protected function enableWhitelistRestrictions() { - return true; - } - - /** - * Returns the allowed values. - * - * TODO: think about how to access set options in general and if we want to have - * whitelist and baclklist values in the validator objects to begin with. - * - * @since 0.1 - * - * @return array|bool false - */ - public function getWhitelistedValues() { - return $this->allowedValues; - } - -} diff --git a/data-values/interfaces/tests/ValueFormatters/FormatterOptionsTest.php b/data-values/interfaces/tests/ValueFormatters/FormatterOptionsTest.php deleted file mode 100644 index f611149..0000000 --- a/data-values/interfaces/tests/ValueFormatters/FormatterOptionsTest.php +++ /dev/null @@ -1,191 +0,0 @@ -<?php - -namespace ValueFormatters\Test; - -use ValueFormatters\FormatterOptions; - -/** - * @covers ValueFormatters\FormatterOptions - * - * @group ValueFormatters - * @group DataValueExtensions - * - * @license GPL-2.0+ - * @author Jeroen De Dauw < jeroended...@gmail.com > - */ -class FormatterOptionsTest extends \PHPUnit_Framework_TestCase { - - public function testConstructor() { - $options = [ - 'foo' => 42, - 'bar' => 4.2, - 'baz' => [ 'o_O', false, null, '42' => 42, [] ] - ]; - - $formatterOptions = new FormatterOptions( $options ); - - foreach ( $options as $option => $value ) { - $this->assertSame( - serialize( $value ), - serialize( $formatterOptions->getOption( $option ) ), - 'Option should be set properly' - ); - } - - $this->assertFalse( $formatterOptions->hasOption( 'ohi' ) ); - } - - public function testConstructorFail() { - $options = [ - 'foo' => 42, - 'bar' => 4.2, - 42 => [ 'o_O', false, null, '42' => 42, [] ] - ]; - - $this->setExpectedException( 'Exception' ); - - new FormatterOptions( $options ); - } - - public function setOptionProvider() { - $argLists = []; - - $formatterOptions = new FormatterOptions(); - - $argLists[] = [ $formatterOptions, 'foo', 42 ]; - $argLists[] = [ $formatterOptions, 'bar', 42 ]; - $argLists[] = [ $formatterOptions, 'foo', 'foo' ]; - $argLists[] = [ $formatterOptions, 'foo', null ]; - - return $argLists; - } - - /** - * @dataProvider setOptionProvider - */ - public function testSetAndGetOption( FormatterOptions $options, $option, $value ) { - $options->setOption( $option, $value ); - - $this->assertEquals( - $value, - $options->getOption( $option ), - 'Setting an option should work' - ); - } - - public function testHashOption() { - $options = [ - 'foo' => 42, - 'bar' => 4.2, - 'baz' => [ 'o_O', false, null, '42' => 42, [] ] - ]; - - $formatterOptions = new FormatterOptions( $options ); - - foreach ( array_keys( $options ) as $option ) { - $this->assertTrue( $formatterOptions->hasOption( $option ) ); - } - - $this->assertFalse( $formatterOptions->hasOption( 'ohi' ) ); - $this->assertFalse( $formatterOptions->hasOption( 'Foo' ) ); - } - - public function testSetOption() { - $formatterOptions = new FormatterOptions( [ 'foo' => 'bar' ] ); - - $values = [ - [ 'foo', 'baz' ], - [ 'foo', 'bar' ], - [ 'onoez', '' ], - [ 'hax', 'zor' ], - [ 'nyan', 9001 ], - [ 'cat', 4.2 ], - [ 'spam', [ '~=[,,_,,]:3' ] ], - ]; - - foreach ( $values as $value ) { - $formatterOptions->setOption( $value[0], $value[1] ); - $this->assertSame( $value[1], $formatterOptions->getOption( $value[0] ) ); - } - } - - /** - * @dataProvider nonExistingOptionsProvider - */ - public function testGetOption( $nonExistingOption ) { - $this->assertTrue( true ); - $formatterOptions = new FormatterOptions( [ 'foo' => 'bar' ] ); - - $this->setExpectedException( 'OutOfBoundsException' ); - - $formatterOptions->getOption( $nonExistingOption ); - } - - public function nonExistingOptionsProvider() { - $argLists = []; - - $argLists[] = [ 'bar' ]; - $argLists[] = [ 'Foo' ]; - $argLists[] = [ 'FOO' ]; - $argLists[] = [ 'spam' ]; - $argLists[] = [ 'onoez' ]; - - return $argLists; - } - - public function testRequireOption() { - $options = [ - 'foo' => 42, - 'bar' => 4.2, - 'baz' => [ 'o_O', false, null, '42' => 42, [] ] - ]; - - $formatterOptions = new FormatterOptions( $options ); - - foreach ( array_keys( $options ) as $option ) { - $formatterOptions->requireOption( $option ); - } - - $this->setExpectedException( 'Exception' ); - - $formatterOptions->requireOption( 'Foo' ); - } - - public function testDefaultOption() { - $options = [ - 'foo' => 42, - 'bar' => 4.2, - 'baz' => [ 'o_O', false, null, '42' => 42, [] ] - ]; - - $formatterOptions = new FormatterOptions( $options ); - - foreach ( $options as $option => $value ) { - $formatterOptions->defaultOption( $option, 9001 ); - - $this->assertSame( - serialize( $value ), - serialize( $formatterOptions->getOption( $option ) ), - 'Defaulting a set option should not affect its value' - ); - } - - $defaults = [ - 'N' => 42, - 'y' => 4.2, - 'a' => false, - 'n' => [ '42' => 42, [ '' ] ] - ]; - - foreach ( $defaults as $option => $value ) { - $formatterOptions->defaultOption( $option, $value ); - - $this->assertSame( - serialize( $value ), - serialize( $formatterOptions->getOption( $option ) ), - 'Defaulting a not set option should affect its value' - ); - } - } - -} diff --git a/data-values/interfaces/tests/ValueFormatters/ValueFormatterTestBase.php b/data-values/interfaces/tests/ValueFormatters/ValueFormatterTestBase.php deleted file mode 100644 index 6252b7b..0000000 --- a/data-values/interfaces/tests/ValueFormatters/ValueFormatterTestBase.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php - -namespace ValueFormatters\Test; - -use ValueFormatters\FormatterOptions; -use ValueFormatters\ValueFormatter; - -/** - * Base for unit tests for ValueFormatter implementing classes. - * - * @since 0.1 - * - * @group ValueFormatters - * @group DataValueExtensions - * - * @license GPL-2.0+ - * @author Jeroen De Dauw < jeroended...@gmail.com > - */ -abstract class ValueFormatterTestBase extends \PHPUnit_Framework_TestCase { - - /** - * Returns a list with valid inputs and their associated formatting output. - * - * @since 0.1 - * - * @return array[] - */ - abstract public function validProvider(); - - /** - * @since 0.1 - * - * @param FormatterOptions|null $options - * - * @return ValueFormatter - */ - abstract protected function getInstance( FormatterOptions $options = null ); - - /** - * @dataProvider validProvider - * - * @since 0.1 - * - * @param mixed $value - * @param mixed $expected - * @param FormatterOptions|null $options - * @param ValueFormatter|null $formatter - */ - public function testValidFormat( - $value, - $expected, - FormatterOptions $options = null, - ValueFormatter $formatter = null - ) { - if ( $formatter === null ) { - $formatter = $this->getInstance( $options ); - } - - $this->assertSame( $expected, $formatter->format( $value ) ); - } - -} diff --git a/data-values/interfaces/tests/ValueParsers/ParserOptionsTest.php b/data-values/interfaces/tests/ValueParsers/ParserOptionsTest.php deleted file mode 100644 index 8a97ecb..0000000 --- a/data-values/interfaces/tests/ValueParsers/ParserOptionsTest.php +++ /dev/null @@ -1,191 +0,0 @@ -<?php - -namespace ValueParsers\Test; - -use ValueParsers\ParserOptions; - -/** - * @covers ValueParsers\ParserOptions - * - * @group ValueParsers - * @group DataValueExtensions - * - * @license GPL-2.0+ - * @author Jeroen De Dauw < jeroended...@gmail.com > - */ -class ParserOptionsTest extends \PHPUnit_Framework_TestCase { - - public function testConstructor() { - $options = [ - 'foo' => 42, - 'bar' => 4.2, - 'baz' => [ 'o_O', false, null, '42' => 42, [] ] - ]; - - $parserOptions = new ParserOptions( $options ); - - foreach ( $options as $option => $value ) { - $this->assertSame( - serialize( $value ), - serialize( $parserOptions->getOption( $option ) ), - 'Option should be set properly' - ); - } - - $this->assertFalse( $parserOptions->hasOption( 'ohi' ) ); - } - - public function testConstructorFail() { - $options = [ - 'foo' => 42, - 'bar' => 4.2, - 42 => [ 'o_O', false, null, '42' => 42, [] ] - ]; - - $this->setExpectedException( 'Exception' ); - - new ParserOptions( $options ); - } - - public function setOptionProvider() { - $argLists = []; - - $parserOptions = new ParserOptions(); - - $argLists[] = [ $parserOptions, 'foo', 42 ]; - $argLists[] = [ $parserOptions, 'bar', 42 ]; - $argLists[] = [ $parserOptions, 'foo', 'foo' ]; - $argLists[] = [ $parserOptions, 'foo', null ]; - - return $argLists; - } - - /** - * @dataProvider setOptionProvider - */ - public function testSetAndGetOption( ParserOptions $options, $option, $value ) { - $options->setOption( $option, $value ); - - $this->assertEquals( - $value, - $options->getOption( $option ), - 'Setting an option should work' - ); - } - - public function testHashOption() { - $options = [ - 'foo' => 42, - 'bar' => 4.2, - 'baz' => [ 'o_O', false, null, '42' => 42, [] ] - ]; - - $parserOptions = new ParserOptions( $options ); - - foreach ( array_keys( $options ) as $option ) { - $this->assertTrue( $parserOptions->hasOption( $option ) ); - } - - $this->assertFalse( $parserOptions->hasOption( 'ohi' ) ); - $this->assertFalse( $parserOptions->hasOption( 'Foo' ) ); - } - - public function testSetOption() { - $parserOptions = new ParserOptions( [ 'foo' => 'bar' ] ); - - $values = [ - [ 'foo', 'baz' ], - [ 'foo', 'bar' ], - [ 'onoez', '' ], - [ 'hax', 'zor' ], - [ 'nyan', 9001 ], - [ 'cat', 4.2 ], - [ 'spam', [ '~=[,,_,,]:3' ] ], - ]; - - foreach ( $values as $value ) { - $parserOptions->setOption( $value[0], $value[1] ); - $this->assertSame( $value[1], $parserOptions->getOption( $value[0] ) ); - } - } - - /** - * @dataProvider nonExistingOptionsProvider - */ - public function testGetOption( $nonExistingOption ) { - $this->assertTrue( true ); - $formatterOptions = new ParserOptions( [ 'foo' => 'bar' ] ); - - $this->setExpectedException( 'InvalidArgumentException' ); - - $formatterOptions->getOption( $nonExistingOption ); - } - - public function nonExistingOptionsProvider() { - $argLists = []; - - $argLists[] = [ 'bar' ]; - $argLists[] = [ 'Foo' ]; - $argLists[] = [ 'FOO' ]; - $argLists[] = [ 'spam' ]; - $argLists[] = [ 'onoez' ]; - - return $argLists; - } - - public function testRequireOption() { - $options = [ - 'foo' => 42, - 'bar' => 4.2, - 'baz' => [ 'o_O', false, null, '42' => 42, [] ] - ]; - - $parserOptions = new ParserOptions( $options ); - - foreach ( array_keys( $options ) as $option ) { - $parserOptions->requireOption( $option ); - } - - $this->setExpectedException( 'Exception' ); - - $parserOptions->requireOption( 'Foo' ); - } - - public function testDefaultOption() { - $options = [ - 'foo' => 42, - 'bar' => 4.2, - 'baz' => [ 'o_O', false, null, '42' => 42, [] ] - ]; - - $parserOptions = new ParserOptions( $options ); - - foreach ( $options as $option => $value ) { - $parserOptions->defaultOption( $option, 9001 ); - - $this->assertSame( - serialize( $value ), - serialize( $parserOptions->getOption( $option ) ), - 'Defaulting a set option should not affect its value' - ); - } - - $defaults = [ - 'N' => 42, - 'y' => 4.2, - 'a' => false, - 'n' => [ '42' => 42, [ '' ] ] - ]; - - foreach ( $defaults as $option => $value ) { - $parserOptions->defaultOption( $option, $value ); - - $this->assertSame( - serialize( $value ), - serialize( $parserOptions->getOption( $option ) ), - 'Defaulting a not set option should affect its value' - ); - } - } - -} diff --git a/data-values/interfaces/tests/ValueValidators/ErrorTest.php b/data-values/interfaces/tests/ValueValidators/ErrorTest.php deleted file mode 100644 index d5ba9fb..0000000 --- a/data-values/interfaces/tests/ValueValidators/ErrorTest.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php - -namespace ValueValidators\Test; - -use ValueValidators\Error; - -/** - * @covers ValueValidators\Error - * - * @group ValueValidators - * @group DataValueExtensions - * - * @license GPL-2.0+ - * @author Jeroen De Dauw < jeroended...@gmail.com > - */ -class ErrorTest extends \PHPUnit_Framework_TestCase { - - public function newErrorProvider() { - $argLists = []; - - $argLists[] = []; - - $argLists[] = [ '' ]; - $argLists[] = [ 'foo' ]; - $argLists[] = [ ' foo bar baz.' ]; - - $argLists[] = [ ' foo bar ', null ]; - $argLists[] = [ ' foo bar ', 'length' ]; - - $argLists[] = [ ' foo bar ', null, 'something-went-wrong' ]; - $argLists[] = [ ' foo bar ', null, 'something-went-wrong', [ 'foo', 'bar' ] ]; - - return $argLists; - } - - /** - * @dataProvider newErrorProvider - */ - public function testNewError() { - $args = func_get_args(); - - $error = call_user_func_array( [ Error::class, 'newError' ], $args ); - - /** - * @var Error $error - */ - $this->assertInstanceOf( 'ValueValidators\Error', $error ); - - $this->assertInternalType( 'string', $error->getText() ); - $this->assertInternalType( 'integer', $error->getSeverity() ); - $this->assertTrue( is_string( $error->getProperty() ) || is_null( $error->getProperty() ) ); - $this->assertInternalType( 'string', $error->getCode() ); - $this->assertInternalType( 'array', $error->getParameters() ); - - if ( count( $args ) > 0 ) { - $this->assertSame( $args[0], $error->getText() ); - } - - if ( count( $args ) > 1 ) { - $this->assertSame( $args[1], $error->getProperty() ); - } - - if ( count( $args ) > 2 ) { - $this->assertSame( $args[2], $error->getCode() ); - } - - if ( count( $args ) > 3 ) { - $this->assertSame( $args[3], $error->getParameters() ); - } - } - -} diff --git a/data-values/interfaces/tests/ValueValidators/ResultTest.php b/data-values/interfaces/tests/ValueValidators/ResultTest.php deleted file mode 100644 index 69e5a72..0000000 --- a/data-values/interfaces/tests/ValueValidators/ResultTest.php +++ /dev/null @@ -1,84 +0,0 @@ -<?php - -namespace ValueValidators\Test; - -use ValueValidators\Error; -use ValueValidators\Result; - -/** - * @covers ValueValidators\Result - * - * @group ValueValidators - * @group DataValueExtensions - * - * @license GPL-2.0+ - * @author Daniel Kinzler - */ -class ResultTest extends \PHPUnit_Framework_TestCase { - - public function testNewSuccess() { - $result = Result::newSuccess(); - - $this->assertTrue( $result->isValid() ); - $this->assertEmpty( $result->getErrors() ); - } - - public function testNewError() { - $result = Result::newError( [ - Error::newError( 'foo' ), - Error::newError( 'bar' ), - ] ); - - $this->assertFalse( $result->isValid() ); - $this->assertCount( 2, $result->getErrors() ); - } - - public static function provideMerge() { - $errors = [ - Error::newError( 'foo' ), - Error::newError( 'bar' ), - ]; - - return [ - [ - Result::newSuccess(), - Result::newSuccess(), - true, - 0, - 'success + success' - ], - [ - Result::newSuccess(), - Result::newError( $errors ), - false, - 2, - 'success + error' - ], - [ - Result::newSuccess(), - Result::newError( $errors ), - false, - 2, - 'error + success' - ], - [ - Result::newError( $errors ), - Result::newError( $errors ), - false, - 4, - 'error + error' - ], - ]; - } - - /** - * @dataProvider provideMerge - */ - public function testMerge( $a, $b, $expectedValid, $expectedErrorCount, $message ) { - $result = Result::merge( $a, $b ); - - $this->assertSame( $expectedValid, $result->isValid(), $message ); - $this->assertCount( $expectedErrorCount, $result->getErrors(), $message ); - } - -} diff --git a/data-values/interfaces/tests/bootstrap.php b/data-values/interfaces/tests/bootstrap.php deleted file mode 100644 index ac82d46..0000000 --- a/data-values/interfaces/tests/bootstrap.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php - -if ( PHP_SAPI !== 'cli' ) { - die( 'Not an entry point' ); -} - -error_reporting( E_ALL | E_STRICT ); -ini_set( 'display_errors', 1 ); - -if ( !is_readable( __DIR__ . '/../vendor/autoload.php' ) ) { - die( 'You need to install this package with Composer before you can run the tests' ); -} - -require_once __DIR__ . '/../vendor/autoload.php'; -- To view, visit https://gerrit.wikimedia.org/r/371090 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I811e4d028ce606f2917766d5e2e9da0d162daf7e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/vendor Gerrit-Branch: master Gerrit-Owner: Legoktm <lego...@member.fsf.org> Gerrit-Reviewer: Legoktm <lego...@member.fsf.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits