Laravel 5.6 updates

Travis config update

Removed HHVM script as Laravel no longer support HHVM after releasing 5.3
This commit is contained in:
Manish Verma
2018-08-06 20:08:55 +05:30
parent 126fbb0255
commit 1ac0f42a58
2464 changed files with 65239 additions and 46734 deletions

View File

@@ -22,7 +22,7 @@ This Code of Conduct applies both within project spaces and in public spaces whe
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project maintainer at sebastian@phpunit.de. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. Maintainers are obligated to maintain confidentiality with regard to the reporter of an incident.
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.3.0, available at [http://contributor-covenant.org/version/1/3/0/][version]
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.3.0, available at [https://contributor-covenant.org/version/1/3/0/][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/3/0/
[homepage]: https://contributor-covenant.org
[version]: https://contributor-covenant.org/version/1/3/0/

View File

@@ -11,7 +11,7 @@ Please note that this project is released with a [Contributor Code of Conduct](C
* Add tests for it. This is important so we don't break it in a future version unintentionally.
* Send a pull request. Bonus points for topic branches.
Please make sure that you have [set up your user name and email address](http://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup) for use with Git. Strings such as `silly nick name <root@localhost>` look really stupid in the commit history of a project.
Please make sure that you have [set up your user name and email address](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup) for use with Git. Strings such as `silly nick name <root@localhost>` look really stupid in the commit history of a project.
Pull requests for bug fixes must be based on the current stable branch whereas pull requests for new features must be based on the `master` branch.
@@ -21,7 +21,7 @@ Due to time constraints, we are not always able to respond as quickly as we woul
## Coding Guidelines
This project comes with a configuration file and an executable for [php-cs-fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) (`.php_cs`) that you can use to (re)format your sourcecode for compliance with this project's coding guidelines:
This project comes with a configuration file and an executable for [php-cs-fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) (`.php_cs`) that you can use to (re)format your source code for compliance with this project's coding guidelines:
```bash
$ ./build/tools/php-cs-fixer fix
@@ -63,7 +63,6 @@ Please use the most specific issue tracker to search for existing tickets and to
* [General problems](https://github.com/sebastianbergmann/phpunit/issues)
* [Code Coverage](https://github.com/sebastianbergmann/php-code-coverage/issues)
* [Stub and Mock Objects](https://github.com/sebastianbergmann/phpunit-mock-objects/issues)
* [Documentation](https://github.com/sebastianbergmann/phpunit-documentation/issues)
* [Documentation](https://github.com/sebastianbergmann/phpunit-documentation-english/issues)
* [Website](https://github.com/sebastianbergmann/phpunit-website/issues)

View File

@@ -0,0 +1,47 @@
# Configuration for probot-stale - https://github.com/probot/stale
# Number of days of inactivity before an Issue or Pull Request becomes stale
daysUntilStale: 60
# Number of days of inactivity before a stale Issue or Pull Request is closed.
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
daysUntilClose: 7
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
exemptLabels:
- blocked
- enhancement
- backward-compatibility-break
- feature-removal
- php-support-removal
- process
- rfc
- refactoring
# Set to true to ignore issues in a project (defaults to false)
exemptProjects: false
# Set to true to ignore issues in a milestone (defaults to false)
exemptMilestones: false
# Label to use when marking as stale
staleLabel: stale
# Comment to post when marking as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had activity within the last 60 days. It will be closed after 7 days if no further activity occurs. Thank you for your contributions.
# Comment to post when removing the stale label.
# unmarkComment: >
# Your comment here.
# Comment to post when closing a stale Issue or Pull Request.
closeComment: >
This issue has been automatically closed because it has not had activity since it was marked as stale. Thank you for your contributions.
# Limit the number of actions per hour, from 1-30. Default is 30
limitPerRun: 30
# Limit to only `issues` or `pulls`
only: issues

View File

@@ -18,4 +18,3 @@
/tests/TextUI/*.out
/tests/TextUI/*.php
/vendor

View File

@@ -12,71 +12,173 @@ return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules(
[
'align_multiline_comment' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'align_double_arrow' => true,
'align_equals' => true
'operators' => [
'=' => 'align',
'=>' => 'align',
],
],
'blank_line_after_namespace' => true,
'blank_line_before_statement' => [
'statements' => [
'break',
'continue',
'declare',
'do',
'for',
'foreach',
'if',
'include',
'include_once',
'require',
'require_once',
'return',
'switch',
'throw',
'try',
'while',
'yield',
],
],
'braces' => true,
'cast_spaces' => true,
'class_attributes_separation' => ['elements' => ['const', 'method', 'property']],
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'compact_nullable_typehint' => true,
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => ['space' => 'none'],
'dir_constant' => true,
'elseif' => true,
'encoding' => true,
'full_opening_tag' => true,
'function_declaration' => true,
'header_comment' => ['header' => $header, 'separate' => 'none'],
'indentation_type' => true,
'is_null' => true,
'line_ending' => true,
'list_syntax' => ['syntax' => 'short'],
'logical_operators' => true,
'lowercase_cast' => true,
'lowercase_constants' => true,
'lowercase_keywords' => true,
'method_argument_space' => true,
'lowercase_static_reference' => true,
'magic_constant_casing' => true,
'method_argument_space' => ['ensure_fully_multiline' => true],
'modernize_types_casting' => true,
'multiline_comment_opening_closing' => true,
'multiline_whitespace_before_semicolons' => true,
'native_constant_invocation' => true,
'native_function_casing' => true,
'native_function_invocation' => true,
'new_with_braces' => false,
'no_alias_functions' => true,
'no_alternative_syntax' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_blank_lines_before_namespace' => true,
'no_closing_tag' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => true,
'no_extra_blank_lines' => true,
'no_homoglyph_names' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => ['use' => 'print'],
'no_multiline_whitespace_around_double_arrow' => true,
'no_null_property_initialization' => true,
'no_php4_constructor' => true,
'no_short_bool_cast' => true,
'no_short_echo_tag' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_after_function_name' => true,
'no_spaces_inside_parenthesis' => true,
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => true,
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_unneeded_control_parentheses' => true,
'no_unneeded_curly_braces' => true,
'no_unneeded_final_method' => true,
'no_unreachable_default_argument_value' => true,
'no_unset_on_property' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'non_printable_character' => true,
'normalize_index_brace' => true,
'object_operator_without_whitespace' => true,
'ordered_class_elements' => [
'order' => [
'use_trait',
'constant_public',
'constant_protected',
'constant_private',
'property_public_static',
'property_protected_static',
'property_private_static',
'property_public',
'property_protected',
'property_private',
'method_public_static',
'construct',
'destruct',
'magic',
'phpunit',
'method_public',
'method_protected',
'method_private',
'method_protected_static',
'method_private_static',
],
],
'ordered_imports' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_align' => true,
'phpdoc_annotation_without_dot' => true,
'phpdoc_indent' => true,
'phpdoc_no_access' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_no_package' => true,
'phpdoc_order' => true,
'phpdoc_return_self_reference' => true,
'phpdoc_scalar' => true,
'phpdoc_separation' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_to_comment' => true,
'phpdoc_trim' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_types' => true,
'phpdoc_types_order' => true,
'phpdoc_var_without_name' => true,
'pow_to_exponentiation' => true,
'protected_to_private' => true,
'return_assignment' => true,
'return_type_declaration' => ['space_before' => 'none'],
'self_accessor' => true,
'semicolon_after_instruction' => true,
'set_type_to_cast' => true,
'short_scalar_cast' => true,
'simplified_null_return' => true,
'single_blank_line_at_eof' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_quote' => true,
'ternary_operator_spaces' => true,
'standardize_not_equals' => true,
'ternary_to_null_coalescing' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => true,
//'void_return' => true,
'whitespace_after_comma_in_array' => true,
]
)
->setFinder(
@@ -84,8 +186,6 @@ return PhpCsFixer\Config::create()
->files()
->in(__DIR__ . '/build')
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests/Framework')
->in(__DIR__ . '/tests/Runner')
->in(__DIR__ . '/tests/Util')
->name('*.php')
->in(__DIR__ . '/tests')
->notName('*.phpt')
);

View File

@@ -8,7 +8,6 @@ addons:
- libxml2-utils
php:
- 7.0
- 7.1
- 7.2
- master
@@ -26,12 +25,11 @@ env:
- DEFAULT_COMPOSER_FLAGS="--no-interaction --no-ansi --no-progress --no-suggest"
before_install:
- composer self-update
- composer clear-cache
- ./build/tools/composer clear-cache
install:
- if [[ "$DEPENDENCIES" = 'high' ]]; then travis_retry composer update $DEFAULT_COMPOSER_FLAGS; fi
- if [[ "$DEPENDENCIES" = 'low' ]]; then travis_retry composer update $DEFAULT_COMPOSER_FLAGS --prefer-lowest; fi
- if [[ "$DEPENDENCIES" = 'high' ]]; then travis_retry ./build/tools/composer update $DEFAULT_COMPOSER_FLAGS; fi
- if [[ "$DEPENDENCIES" = 'low' ]]; then travis_retry ./build/tools/composer update $DEFAULT_COMPOSER_FLAGS --prefer-lowest; fi
before_script:
- echo 'zend.assertions=1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
@@ -51,3 +49,21 @@ after_success:
notifications:
email: false
jobs:
include:
- stage: Static Code Analysis
php: 7.2
env: PHPStan
before_install:
- travis_retry ./build/tools/composer require --no-update phpunit/php-invoker:^2.0
install: travis_retry ./build/tools/composer update --prefer-dist --prefer-stable
script:
- ./build/tools/phpstan analyse --level=0 -c phpstan.neon src
- ./build/tools/phpstan analyse --level=2 -c phpstan-tests.neon tests
- stage: Static Code Analysis
php: 7.2
env: php-cs-fixer
install:
- phpenv config-rm xdebug.ini
script:
- ./build/tools/php-cs-fixer fix --dry-run -v --show-progress=dots --diff-format=udiff

View File

@@ -1,242 +0,0 @@
# Changes in PHPUnit 5.7
All notable changes of the PHPUnit 5.7 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
## [5.7.27] - 2018-02-01
### Fixed
* Fixed [#2236](https://github.com/sebastianbergmann/phpunit/issues/2236): Exceptions in `tearDown()` do not affect `getStatus()`
* Fixed [#2950](https://github.com/sebastianbergmann/phpunit/issues/2950): Class extending `PHPUnit\Framework\TestSuite` does not extend `PHPUnit\FrameworkTestCase`
* Fixed [#2972](https://github.com/sebastianbergmann/phpunit/issues/2972): PHPUnit crashes when test suite contains both `.phpt` files and unconventionally named tests
## [5.7.26] - 2017-12-17
### Fixed
* Fixed [#2472](https://github.com/sebastianbergmann/phpunit/issues/2472): `PHPUnit\Util\Getopt` uses deprecated `each()` function
* Fixed [#2833](https://github.com/sebastianbergmann/phpunit/issues/2833): Test class loaded during data provider execution is not discovered
* Fixed [#2922](https://github.com/sebastianbergmann/phpunit/issues/2922): Test class is not discovered when there is a test class with `@group` and provider throwing exception in it, tests are run with `--exclude-group` for that group, there is another class called later (after the class from above), and the name of that another class does not match its filename
## [5.7.25] - 2017-11-14
### Fixed
* Fixed [#2859](https://github.com/sebastianbergmann/phpunit/issues/2859): Regression caused by fix for [#2833](https://github.com/sebastianbergmann/phpunit/issues/2833)
## [5.7.24] - 2017-11-14
### Fixed
* Fixed [#2833](https://github.com/sebastianbergmann/phpunit/issues/2833): Test class loaded during data provider execution is not discovered
## [5.7.23] - 2017-10-15
### Fixed
* Fixed [#2731](https://github.com/sebastianbergmann/phpunit/issues/2731): Empty exception message cannot be expected
## [5.7.22] - 2017-09-24
### Fixed
* Fixed [#2769](https://github.com/sebastianbergmann/phpunit/issues/2769): Usage of `setUseErrorHandler()` produces `Undefined variable` error
## [5.7.21] - 2017-06-21
### Added
* Added `PHPUnit\Framework\AssertionFailedError`, `PHPUnit\Framework\Test`, and `PHPUnit\Framework\TestSuite` to the forward compatibility layer for PHPUnit 6
### Fixed
* Fixed [#2705](https://github.com/sebastianbergmann/phpunit/issues/2705): `stderr` parameter in `phpunit.xml` always considered `true`
## [5.7.20] - 2017-05-22
### Fixed
* Fixed [#2563](https://github.com/sebastianbergmann/phpunit/pull/2563): `phpunit --version` does not display version when running unsupported PHP
## [5.7.19] - 2017-04-03
### Fixed
* Fixed [#2638](https://github.com/sebastianbergmann/phpunit/pull/2638): Regression in `PHPUnit\Framework\TestCase:registerMockObjectsFromTestArguments()`
## [5.7.18] - 2017-04-02
### Fixed
* Fixed [#2145](https://github.com/sebastianbergmann/phpunit/issues/2145): `--stop-on-failure` fails to stop on PHP 7
* Fixed [#2572](https://github.com/sebastianbergmann/phpunit/issues/2572): `PHPUnit\Framework\TestCase:registerMockObjectsFromTestArguments()` does not correctly handle arrays that reference themselves
## [5.7.17] - 2017-03-19
### Fixed
* Fixed [#2016](https://github.com/sebastianbergmann/phpunit/issues/2016): `prophesize()` does not work when static attributes are backed up
* Fixed [#2568](https://github.com/sebastianbergmann/phpunit/issues/2568): `ArraySubsetConstraint` uses invalid cast to array
* Fixed [#2573](https://github.com/sebastianbergmann/phpunit/issues/2573): `getMockFromWsdl()` does not handle URLs with query parameters
* `PHPUnit\Util\Test::getDataFromTestWithAnnotation()` raises notice when docblock contains Windows line endings
## [5.7.16] - 2017-03-15
### Fixed
* Fixed [#2547](https://github.com/sebastianbergmann/phpunit/issues/2547): Code Coverage data is collected for test annotated with `@coversNothing`
* Fixed [#2558](https://github.com/sebastianbergmann/phpunit/issues/2558): `countOf()` function is missing
## [5.7.15] - 2017-03-02
### Fixed
* Fixed [#1999](https://github.com/sebastianbergmann/phpunit/issues/1999): Handler is inherited from previous custom option with handler
* Fixed [#2149](https://github.com/sebastianbergmann/phpunit/issues/2149): `assertCount()` does not handle generators properly
* Fixed [#2478](https://github.com/sebastianbergmann/phpunit/issues/2478): Tests that take too long are not reported as risky test
## [5.7.14] - 2017-02-19
### Fixed
* Fixed [#2489](https://github.com/sebastianbergmann/phpunit/issues/2489): `processUncoveredFilesFromWhitelist` is not handled correctly
* Fixed default values for `addUncoveredFilesFromWhitelist` and `processUncoveredFilesFromWhitelist` in `phpunit.xsd`
## [5.7.13] - 2017-02-10
### Fixed
* Fixed [#2493](https://github.com/sebastianbergmann/phpunit/issues/2493): Fix for [#2475](https://github.com/sebastianbergmann/phpunit/pull/2475) does not apply to PHPUnit 5.7
## [5.7.12] - 2017-02-08
### Fixed
* Fixed [#2475](https://github.com/sebastianbergmann/phpunit/pull/2475): Defining a test suite with only one file does not work
## [5.7.11] - 2017-02-05
### Fixed
* Deprecation errors when used with PHP 7.2
## [5.7.10] - 2017-02-04
### Fixed
* Fixed [#2462](https://github.com/sebastianbergmann/phpunit/issues/2462): Code Coverage whitelist is filled even if no code coverage data is to be collected
## [5.7.9] - 2017-01-28
### Fixed
* Fixed [#2447](https://github.com/sebastianbergmann/phpunit/issues/2447): Reverted backwards incompatible change to handling of boolean environment variable values specified in XML
## [5.7.8] - 2017-01-26
### Fixed
* Fixed [#2446](https://github.com/sebastianbergmann/phpunit/issues/2446): Reverted backwards incompatible change to exit code in case of warnings
## [5.7.7] - 2017-01-25
### Fixed
* Fixed [#1896](https://github.com/sebastianbergmann/phpunit/issues/1896): Wrong test location when `@depends` and `@dataProvider` are combined
* Fixed [#1983](https://github.com/sebastianbergmann/phpunit/pull/1983): Tests with `@expectedException` annotation cannot be skipped
* Fixed [#2137](https://github.com/sebastianbergmann/phpunit/issues/2137): Warnings for invalid data providers are suppressed when test execution is filtered
* Fixed [#2275](https://github.com/sebastianbergmann/phpunit/pull/2275): Invalid UTF-8 characters can lead to missing output
* Fixed [#2299](https://github.com/sebastianbergmann/phpunit/issues/2299): `expectExceptionMessage()` and `expectExceptionCode()` do not work without `expectException()`
* Fixed [#2328](https://github.com/sebastianbergmann/phpunit/issues/2328): `TestListener` callbacks `startTest()` and `endTest()` are not called when test is skipped due to `@depends`
* Fixed [#2331](https://github.com/sebastianbergmann/phpunit/issues/2331): Boolean environment variable values specified in XML get mangled
* Fixed [#2333](https://github.com/sebastianbergmann/phpunit/issues/2333): `assertContains()` and `assertNotContains()` do not handle UTF-8 strings correctly
* Fixed [#2340](https://github.com/sebastianbergmann/phpunit/pull/2340): Data providers that use `yield` or implement `Iterator` cannot be combined
* Fixed [#2349](https://github.com/sebastianbergmann/phpunit/pull/2349): `PHPUnit_TextUI_Command` does not `exit()` when it should
* Fixed [#2392](https://github.com/sebastianbergmann/phpunit/issues/2392): Empty (but valid) data provider should skip the test
* Fixed [#2431](https://github.com/sebastianbergmann/phpunit/issues/2431): `assertArraySubset()` does not support `ArrayAccess`
* Fixed [#2435](https://github.com/sebastianbergmann/phpunit/issues/2435): Empty `@group` annotation causes error on PHP 7.2+
## [5.7.6] - 2017-01-22
### Fixed
* Fixed [#2424](https://github.com/sebastianbergmann/phpunit/issues/2424): `TestCase::getStatus()` returns `STATUS_PASSED` instead of `STATUS_RISKY` for risky test
* Fixed [#2427](https://github.com/sebastianbergmann/phpunit/issues/2427): TestDox group configuration is not handled
* Fixed [#2428](https://github.com/sebastianbergmann/phpunit/pull/2428): Nested arrays specificied in XML configuration file are not handled correctly
## [5.7.5] - 2016-12-28
### Fixed
* Fixed [#2404](https://github.com/sebastianbergmann/phpunit/pull/2404): `assertDirectoryNotIsWriteable()` calls itself
## [5.7.4] - 2016-12-13
### Fixed
* Fixed [#2394](https://github.com/sebastianbergmann/phpunit/issues/2394): Do not treat `AssertionError` as assertion failure on PHP 5
## [5.7.3] - 2016-12-09
### Fixed
* Fixed [#2384](https://github.com/sebastianbergmann/phpunit/pull/2384): Handle `PHPUnit_Framework_Exception` correctly when expecting exceptions
## [5.7.2] - 2016-12-03
### Fixed
* Fixed [#2382](https://github.com/sebastianbergmann/phpunit/issues/2382): Uncloneable test doubles passed via data provider do not work
## [5.7.1] - 2016-12-02
### Fixed
* Fixed [#2380](https://github.com/sebastianbergmann/phpunit/issues/2380): Data Providers cannot be generators anymore
## [5.7.0] - 2016-12-02
### Added
* Merged [#2223](https://github.com/sebastianbergmann/phpunit/pull/2223): Add support for multiple data providers
* Added `extensionsDirectory` configuration directive to configure a directory from which all `.phar` files are loaded as PHPUnit extensions
* Added `--no-extensions` commandline option to suppress loading of extensions (from configured extension directory)
* Added `PHPUnit\Framework\Assert` as an alias for `PHPUnit_Framework_Assert` for forward compatibility
* Added `PHPUnit\Framework\BaseTestListener` as an alias for `PHPUnit_Framework_BaseTestListener` for forward compatibility
* Added `PHPUnit\Framework\TestListener` as an alias for `PHPUnit_Framework_TestListener` for forward compatibility
### Changed
* The `--log-json` commandline option has been deprecated
* The `--tap` and `--log-tap` commandline options have been deprecated
* The `--self-update` and `--self-upgrade` commandline options have been deprecated (PHAR binary only)
[5.7.27]: https://github.com/sebastianbergmann/phpunit/compare/5.7.26...5.7.27
[5.7.26]: https://github.com/sebastianbergmann/phpunit/compare/5.7.25...5.7.26
[5.7.25]: https://github.com/sebastianbergmann/phpunit/compare/5.7.24...5.7.25
[5.7.24]: https://github.com/sebastianbergmann/phpunit/compare/5.7.23...5.7.24
[5.7.23]: https://github.com/sebastianbergmann/phpunit/compare/5.7.22...5.7.23
[5.7.22]: https://github.com/sebastianbergmann/phpunit/compare/5.7.21...5.7.22
[5.7.21]: https://github.com/sebastianbergmann/phpunit/compare/5.7.20...5.7.21
[5.7.20]: https://github.com/sebastianbergmann/phpunit/compare/5.7.19...5.7.20
[5.7.19]: https://github.com/sebastianbergmann/phpunit/compare/5.7.18...5.7.19
[5.7.18]: https://github.com/sebastianbergmann/phpunit/compare/5.7.17...5.7.18
[5.7.17]: https://github.com/sebastianbergmann/phpunit/compare/5.7.16...5.7.17
[5.7.16]: https://github.com/sebastianbergmann/phpunit/compare/5.7.15...5.7.16
[5.7.15]: https://github.com/sebastianbergmann/phpunit/compare/5.7.14...5.7.15
[5.7.14]: https://github.com/sebastianbergmann/phpunit/compare/5.7.13...5.7.14
[5.7.13]: https://github.com/sebastianbergmann/phpunit/compare/5.7.12...5.7.13
[5.7.12]: https://github.com/sebastianbergmann/phpunit/compare/5.7.11...5.7.12
[5.7.11]: https://github.com/sebastianbergmann/phpunit/compare/5.7.10...5.7.11
[5.7.10]: https://github.com/sebastianbergmann/phpunit/compare/5.7.9...5.7.10
[5.7.9]: https://github.com/sebastianbergmann/phpunit/compare/5.7.8...5.7.9
[5.7.8]: https://github.com/sebastianbergmann/phpunit/compare/5.7.7...5.7.8
[5.7.7]: https://github.com/sebastianbergmann/phpunit/compare/5.7.6...5.7.7
[5.7.6]: https://github.com/sebastianbergmann/phpunit/compare/5.7.5...5.7.6
[5.7.5]: https://github.com/sebastianbergmann/phpunit/compare/5.7.4...5.7.5
[5.7.4]: https://github.com/sebastianbergmann/phpunit/compare/5.7.3...5.7.4
[5.7.3]: https://github.com/sebastianbergmann/phpunit/compare/5.7.2...5.7.3
[5.7.2]: https://github.com/sebastianbergmann/phpunit/compare/5.7.1...5.7.2
[5.7.1]: https://github.com/sebastianbergmann/phpunit/compare/5.7.0...5.7.1
[5.7.0]: https://github.com/sebastianbergmann/phpunit/compare/5.6...5.7.0

View File

@@ -2,7 +2,7 @@
All notable changes of the PHPUnit 6.5 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
## [6.5.10] - 2018-08-03
## [6.5.10] - 2018-MM-DD
### Fixed

56
vendor/phpunit/phpunit/ChangeLog-7.0.md vendored Normal file
View File

@@ -0,0 +1,56 @@
# Changes in PHPUnit 7.0
All notable changes of the PHPUnit 7.0 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
## [7.0.3] - 2018-03-26
* Fixed [#3028](https://github.com/sebastianbergmann/phpunit/pull/3028): TestDox name prettifier does not handle test case classes correctly that are in a `Tests\*` namespace
## [7.0.2] - 2018-02-26
### Fixed
* Fixed [#2974](https://github.com/sebastianbergmann/phpunit/issues/2974): JUnit XML logfile contains invalid characters when test output contains binary data
* Fixed [#3014](https://github.com/sebastianbergmann/phpunit/issues/3014): `TypeError` in `PHPUnit\Framework\TestCase::getActualOutput()` when callback registered using `setOutputCallback()` does not return a string
* Removed more superfluous `@throws \Exception` annotations
## [7.0.1] - 2018-02-13
### Fixed
* Fixed [#3000](https://github.com/sebastianbergmann/phpunit/issues/3000): Directories are not created recursively
* Removed superfluous `@throws \Exception` annotations from assertion methods
## [7.0.0] - 2018-02-02
### Added
* Implemented [#2967](https://github.com/sebastianbergmann/phpunit/pull/2967): Added support for PHP configuration settings to `@requires` annotation
### Changed
* Implemented [#2566](https://github.com/sebastianbergmann/phpunit/issues/2566): Use `Throwable` instead of `Exception` in `PHPUnit\Framework\TestListener` method signatures
* Implemented [#2920](https://github.com/sebastianbergmann/phpunit/pull/2920): Replace CLI TestDox printer with `rpkamp/fancy-testdox-printer`
* Scalar Type Declarations and Return Type Declarations are now used where possible (as a result, the API of `PHPUnit\Framework\TestListener`, for instance, has changed)
* Some classes are now `final`
* The visibility of some methods has been changed from `protected` to `private`
### Removed
* Implemented [#2473](https://github.com/sebastianbergmann/phpunit/issues/2473): Drop support for PHP 7.0
* `@scenario` is no longer an alias for `@test`
* The `PHPUnit\Framework\BaseTestListener` class has been removed (deprecated in PHPUnit 6.4)
* The `PHPUnit\Framework\TestCase::prepareTemplate` template method has been removed
### Fixed
* Fixed [#2169](https://github.com/sebastianbergmann/phpunit/issues/2169): `assertSame()` does not show differences when used on two arrays that are not identical
* Fixed [#2902](https://github.com/sebastianbergmann/phpunit/issues/2902): `@test` annotation gets accepted no matter what
* Fixed [#2907](https://github.com/sebastianbergmann/phpunit/issues/2907): `StringMatchesFormatDescription` constraint does not handle escaped `%` correctly
* Fixed [#2919](https://github.com/sebastianbergmann/phpunit/issues/2919): `assertJsonStringEqualsJsonString()` matches empty object as empty array
[7.0.3]: https://github.com/sebastianbergmann/phpunit/compare/7.0.2...7.0.3
[7.0.2]: https://github.com/sebastianbergmann/phpunit/compare/7.0.1...7.0.2
[7.0.1]: https://github.com/sebastianbergmann/phpunit/compare/7.0.0...7.0.1
[7.0.0]: https://github.com/sebastianbergmann/phpunit/compare/6.5...7.0.0

63
vendor/phpunit/phpunit/ChangeLog-7.1.md vendored Normal file
View File

@@ -0,0 +1,63 @@
# Changes in PHPUnit 7.1
All notable changes of the PHPUnit 7.1 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
## [7.1.6] - 2018-MM-DD
### Fixed
* Fixed [#3107](https://github.com/sebastianbergmann/phpunit/issues/3107): `CliTestDoxPrinter::addError()` cannot handle errors in `setUpBeforeClass()`
* Fixed [#3142](https://github.com/sebastianbergmann/phpunit/issues/3142): Method-level annotations (`@backupGlobals`, `@backupStaticAttributes`, `@errorHandler`, `@preserveGlobalState`) do not override class-level annotations
## [7.1.5] - 2018-04-29
### Fixed
* Fixed [#3105](https://github.com/sebastianbergmann/phpunit/pull/3105): Name is prettified inconsistently when snake_case notation is used
## [7.1.4] - 2018-04-18
### Fixed
* Fixed [#3034](https://github.com/sebastianbergmann/phpunit/pull/3034): `$this->getStatus()` returns `STATUS_PASSED` in `tearDown()` after unexpected exception
## [7.1.3] - 2018-04-13
### Fixed
* Fixed [#3094](https://github.com/sebastianbergmann/phpunit/issues/3094): Faulty dependency constraint affecting `getObjectForTrait()` (failure using `--prefer-lowest`)
## [7.1.2] - 2018-04-10
### Fixed
* Fixed [#2830](https://github.com/sebastianbergmann/phpunit/issues/2830): `@runClassInSeparateProcess` does not work for tests that use `@dataProvider`
* Fixed [#3059](https://github.com/sebastianbergmann/phpunit/pull/3059): `StringMatchesFormatDescription` constraint fails when matching multiline with `\r\n`
* Fixed [#3087](https://github.com/sebastianbergmann/phpunit/pull/3087): `TestCase::getTestResultObject()` can return `null`
## [7.1.1] - 2018-04-06
### Fixed
* `CliTestDoxPrinter::writeProgress()` and `TeamCity::writeProgress()` are not compatible with `ResultPrinter::writeProgress()` (on PHP 7.1)
## [7.1.0] - 2018-04-06
### Added
* Implemented [#3002](https://github.com/sebastianbergmann/phpunit/issues/3002): Support for test runner extensions
* Implemented [#3035](https://github.com/sebastianbergmann/phpunit/pull/3035): Add support for `iterable` in `assertInternalType()`
### Changed
* `PHPUnit\Framework\Assert` is no longer searched for test methods
* `ReflectionMethod::invokeArgs()` is no longer used to invoke test methods
[7.1.6]: https://github.com/sebastianbergmann/phpunit/compare/7.1.5...7.1.6
[7.1.5]: https://github.com/sebastianbergmann/phpunit/compare/7.1.4...7.1.5
[7.1.4]: https://github.com/sebastianbergmann/phpunit/compare/7.1.3...7.1.4
[7.1.3]: https://github.com/sebastianbergmann/phpunit/compare/7.1.2...7.1.3
[7.1.2]: https://github.com/sebastianbergmann/phpunit/compare/7.1.1...7.1.2
[7.1.1]: https://github.com/sebastianbergmann/phpunit/compare/7.1.0...7.1.1
[7.1.0]: https://github.com/sebastianbergmann/phpunit/compare/7.0...7.1.0

78
vendor/phpunit/phpunit/ChangeLog-7.2.md vendored Normal file
View File

@@ -0,0 +1,78 @@
# Changes in PHPUnit 7.2
All notable changes of the PHPUnit 7.2 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
## [7.2.7] - 2018-07-15
### Fixed
* Fixed [#3154](https://github.com/sebastianbergmann/phpunit/issues/3154): Global constants as default parameter values are not handled correctly in namespace
* Fixed [#3189](https://github.com/sebastianbergmann/phpunit/issues/3189): PHPUnit 7.2 potentially leaves a messy libxmlerror state
* Fixed [#3199](https://github.com/sebastianbergmann/phpunit/pull/3199): Code Coverage for PHPT tests does not work when PHPDBG is used
## [7.2.6] - 2018-06-21
### Fixed
* Fixed [#3176](https://github.com/sebastianbergmann/phpunit/issues/3176): PHPUnit 7.2.5 breaks backward compatibility
## [7.2.5] - 2018-06-21
### Fixed
* Fixed [#3093](https://github.com/sebastianbergmann/phpunit/issues/3093): Unable to chain a `@dataProvider` in method `a` with a `@depends` in method `b`
* Fixed [#3174](https://github.com/sebastianbergmann/phpunit/issues/3174): Code generator for test doubles does not handle proxied methods with variadic parameters correctly
## [7.2.4] - 2018-06-05
### Fixed
* Fixed [#3160](https://github.com/sebastianbergmann/phpunit/issues/3160): TeamCity logfile writer broken on Windows
## [7.2.3] - 2018-06-03
### Fixed
* Fixed [#3156](https://github.com/sebastianbergmann/phpunit/issues/3156): Combined use of `@depends` and `@dataProvider` is not handled correctly
## [7.2.2] - 2018-06-01
### Changed
* Ensure that `phpunit/php-code-coverage` is used in version `^6.0.7`
## [7.2.1] - 2018-06-01
### Fixed
* Fixed [#3155](https://github.com/sebastianbergmann/phpunit/issues/3155): Calling `getStatus()` on a `TestCase` object before the respective test has been executed results in type error
## [7.2.0] - 2018-06-01
### Added
* Implemented [#3042](https://github.com/sebastianbergmann/phpunit/pull/3042): Add `TestCase::expectNotToPerformAssertions()` method as alternative to `@doesNotPerformAssertions` annotation
* Implemented [#3064](https://github.com/sebastianbergmann/phpunit/issues/3064): Mark tests as risky when they claim not to perform assertions but do
* Implemented [#3066](https://github.com/sebastianbergmann/phpunit/issues/3066): Validate XML configuration against XSD
* Implemented [#3076](https://github.com/sebastianbergmann/phpunit/issues/3076): Extensions can be configured via PHPUnit's XML configuration
* Implemented [#3080](https://github.com/sebastianbergmann/phpunit/issues/3080): The XML configuration arguments can have boolean elements
* Implemented [#3092](https://github.com/sebastianbergmann/phpunit/pull/3092): Ability to run tests in random order, reverse order, ordered using dependency resolution
### Changed
* Implemented [#3103](https://github.com/sebastianbergmann/phpunit/issues/3103): Merge `phpunit-mock-objects` back into PHPUnit's Git repository
* Implemented [#3115](https://github.com/sebastianbergmann/phpunit/pull/3115): Method-level `@covers` annotation overrides class-level `@coversNothing` annotation
### Removed
* Fixed [#3069](https://github.com/sebastianbergmann/phpunit/issues/3069): Method `ResultPrinter::printWaitPrompt()` seems to be unused
[7.2.7]: https://github.com/sebastianbergmann/phpunit/compare/7.2.6...7.2.7
[7.2.6]: https://github.com/sebastianbergmann/phpunit/compare/7.2.5...7.2.6
[7.2.5]: https://github.com/sebastianbergmann/phpunit/compare/7.2.4...7.2.5
[7.2.4]: https://github.com/sebastianbergmann/phpunit/compare/7.2.3...7.2.4
[7.2.3]: https://github.com/sebastianbergmann/phpunit/compare/7.2.2...7.2.3
[7.2.2]: https://github.com/sebastianbergmann/phpunit/compare/7.2.1...7.2.2
[7.2.1]: https://github.com/sebastianbergmann/phpunit/compare/7.2.0...7.2.1
[7.2.0]: https://github.com/sebastianbergmann/phpunit/compare/7.1...7.2.0

30
vendor/phpunit/phpunit/ChangeLog-7.3.md vendored Normal file
View File

@@ -0,0 +1,30 @@
# Changes in PHPUnit 7.3
All notable changes of the PHPUnit 7.3 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
## [7.3.0] - 2018-08-03
### Added
* Implemented [#3147](https://github.com/sebastianbergmann/phpunit/pull/3147): Support for running tests first that failed in a previous run
* Implemented `cacheResult` configuration directive and `--cache-result` CLI option to control test result cache required for "run defects first" functionality (disabled by default)
* Implemented `cacheResultFile` configuration directive and `--cache-result-file` CLI option to configure test result cache file (default: `.phpunit.result.cache`)
* Implemented `stopOnDefect` configuration directive and `--stop-on-defect` CLI option for aborting test suite execution upon first defective test
* Implemented `executionOrder` configuration directive and `--order-by` CLI option for sorting the test suite before execution
* The `--order-by=random` CLI option should now be used instead of `--random-order`
* The `--order-by=depends` CLI option should now be used instead of `--resolve-dependencies`
* The `--order-by=reverse` CLI option should now be used instead of `--reverse-order`
* Implemented [#3161](https://github.com/sebastianbergmann/phpunit/pull/3161): Support for indexed arrays in `PHPUnit\Framework\Constraint\ArraySubset`
* Implemented [#3194](https://github.com/sebastianbergmann/phpunit/issues/3194): `@covers class` (and `@uses class`) should include traits used by class
* Implemented [#3196](https://github.com/sebastianbergmann/phpunit/issues/3196): Support for replacing placeholders in `@testdox` text with data provider values
* Implemented [#3198](https://github.com/sebastianbergmann/phpunit/pull/3198): Provide source location for useless tests
### Fixed
* Fixed [#3154](https://github.com/sebastianbergmann/phpunit/issues/3154): Global constants as default parameter values are not handled correctly in namespace
* Fixed [#3218](https://github.com/sebastianbergmann/phpunit/issues/3218): `prefix` attribute for `directory` node missing from `phpunit.xml` XSD
* Fixed [#3222](https://github.com/sebastianbergmann/phpunit/pull/3222): Priority of `@covers` and `@coversNothing` is wrong
* Fixed [#3225](https://github.com/sebastianbergmann/phpunit/issues/3225): `coverage-php` missing from `phpunit.xsd`
[7.3.0]: https://github.com/sebastianbergmann/phpunit/compare/7.2...7.3.0

View File

@@ -3,17 +3,17 @@
PHPUnit is a programmer-oriented testing framework for PHP. It is an instance of the xUnit architecture for unit testing frameworks.
[![Latest Stable Version](https://img.shields.io/packagist/v/phpunit/phpunit.svg?style=flat-square)](https://packagist.org/packages/phpunit/phpunit)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.0-8892BF.svg?style=flat-square)](https://php.net/)
[![Build Status](https://img.shields.io/travis/sebastianbergmann/phpunit/6.5.svg?style=flat-square)](https://phpunit.de/build-status.html)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.1-8892BF.svg?style=flat-square)](https://php.net/)
[![Build Status](https://img.shields.io/travis/sebastianbergmann/7.2/master.svg?style=flat-square)](https://phpunit.de/build-status.html)
## Installation
We distribute a [PHP Archive (PHAR)](https://php.net/phar) that has all required (as well as some optional) dependencies of PHPUnit 6.5 bundled in a single file:
We distribute a [PHP Archive (PHAR)](https://php.net/phar) that has all required (as well as some optional) dependencies of PHPUnit 7.3 bundled in a single file:
```bash
$ wget https://phar.phpunit.de/phpunit-6.5.phar
$ wget https://phar.phpunit.de/phpunit-7.2.phar
$ php phpunit-6.5.phar --version
$ php phpunit-7.2.phar --version
```
Alternatively, you may use [Composer](https://getcomposer.org/) to download and install PHPUnit as well as its dependencies. Please refer to the "[Getting Started](https://phpunit.de/getting-started-with-phpunit.html)" guide for details on how to install PHPUnit.
@@ -28,7 +28,6 @@ Thanks to everyone who has contributed to PHPUnit! You can find a detailed list
* [PHPUnit](https://github.com/sebastianbergmann/phpunit/graphs/contributors)
* [php-code-coverage](https://github.com/sebastianbergmann/php-code-coverage/graphs/contributors)
* [phpunit-mock-objects](https://github.com/sebastianbergmann/phpunit-mock-objects/graphs/contributors)
A very special thanks to everyone who has contributed to the documentation and helps maintain the translations:

View File

@@ -7,15 +7,9 @@ pull_requests:
version: '{build}.{branch}'
environment:
COMPOSER_ROOT_VERSION: '6.5.x-dev'
COMPOSER_ROOT_VERSION: '7.0-dev'
matrix:
- PHP_VERSION: '7.0.25'
XDEBUG_VERSION: '2.5.5-7.0'
DEPENDENCIES: '--prefer-lowest'
- PHP_VERSION: '7.0.25'
XDEBUG_VERSION: '2.5.5-7.0'
DEPENDENCIES: ''
- PHP_VERSION: '7.1.11'
XDEBUG_VERSION: '2.5.5-7.1'
DEPENDENCIES: '--prefer-lowest'

View File

@@ -42,6 +42,14 @@
</target>
<target name="install-dependencies" unless="dependencies-installed" depends="-dependencies-installed,validate-composer-json" description="Install dependencies with Composer">
<copy file="${basedir}/composer.json" tofile="${basedir}/composer.json.bak"/>
<exec executable="${basedir}/build/tools/composer" taskname="composer">
<arg value="require"/>
<arg value="--no-update"/>
<arg value="phpunit/php-invoker:^2.0"/>
</exec>
<exec executable="${basedir}/build/tools/composer" taskname="composer">
<arg value="update"/>
<arg value="--no-interaction"/>
@@ -49,6 +57,8 @@
<arg value="--no-ansi"/>
<arg value="--no-suggest"/>
</exec>
<move file="${basedir}/composer.json.bak" tofile="${basedir}/composer.json"/>
</target>
<target name="php-syntax-check" unless="php-syntax-check.done" description="Perform syntax check on PHP files">
@@ -114,14 +124,8 @@
<target name="-phar-prepare" depends="clean,install-dependencies">
<mkdir dir="${basedir}/build/phar"/>
<copy file="${basedir}/composer.json" tofile="${basedir}/composer.json.bak"/>
<exec executable="${basedir}/build/tools/composer">
<arg value="require"/>
<arg value="phpunit/php-invoker:~1.1"/>
</exec>
<move file="${basedir}/composer.json.bak" tofile="${basedir}/composer.json"/>
<copy file="${basedir}/phpunit.xsd" tofile="${basedir}/build/phar/phpunit.xsd"/>
<exec executable="${basedir}/build/phar-manifest.php" output="${basedir}/build/phar/manifest.txt"/>
@@ -160,13 +164,6 @@
</fileset>
</copy>
<copy file="${basedir}/vendor/phpunit/phpunit-mock-objects/LICENSE" tofile="${basedir}/build/phar/phpunit-mock-objects/LICENSE"/>
<copy todir="${basedir}/build/phar/phpunit-mock-objects">
<fileset dir="${basedir}/vendor/phpunit/phpunit-mock-objects/src">
<include name="**/*" />
</fileset>
</copy>
<copy file="${basedir}/vendor/sebastian/code-unit-reverse-lookup/LICENSE" tofile="${basedir}/build/phar/sebastian-code-unit-reverse-lookup/LICENSE"/>
<copy todir="${basedir}/build/phar/sebastian-code-unit-reverse-lookup">
<fileset dir="${basedir}/vendor/sebastian/code-unit-reverse-lookup/src">

View File

@@ -21,23 +21,23 @@
},
"prefer-stable": true,
"require": {
"php": "^7.0",
"php": "^7.1",
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-xml": "*",
"myclabs/deep-copy": "^1.6.1",
"phar-io/manifest": "^1.0.1",
"phar-io/version": "^1.0",
"doctrine/instantiator": "^1.1",
"myclabs/deep-copy": "^1.7",
"phar-io/manifest": "^1.0.2",
"phar-io/version": "^2.0",
"phpspec/prophecy": "^1.7",
"phpunit/php-code-coverage": "^5.3",
"phpunit/php-file-iterator": "^1.4.3",
"phpunit/php-code-coverage": "^6.0.7",
"phpunit/php-file-iterator": "^2.0.1",
"phpunit/php-text-template": "^1.2.1",
"phpunit/php-timer": "^1.0.9",
"phpunit/phpunit-mock-objects": "^5.0.8",
"sebastian/comparator": "^2.1",
"sebastian/diff": "^2.0",
"phpunit/php-timer": "^2.0",
"sebastian/comparator": "^3.0",
"sebastian/diff": "^3.0",
"sebastian/environment": "^3.1",
"sebastian/exporter": "^3.1",
"sebastian/global-state": "^2.0",
@@ -49,18 +49,18 @@
"ext-PDO": "*"
},
"conflict": {
"phpunit/dbunit": "<3.0",
"phpdocumentor/reflection-docblock": "3.0.2"
"phpunit/phpunit-mock-objects": "*"
},
"config": {
"platform": {
"php": "7.0.0"
"php": "7.1.0"
},
"optimize-autoloader": true,
"sort-packages": true
},
"suggest": {
"phpunit/php-invoker": "^1.1",
"phpunit/php-invoker": "^2.0",
"ext-soap": "*",
"ext-xdebug": "*"
},
"bin": [
@@ -77,12 +77,14 @@
],
"files": [
"src/Framework/Assert/Functions.php",
"tests/_files/CoveredFunction.php"
"tests/_files/CoverageNamespacedFunctionTest.php",
"tests/_files/CoveredFunction.php",
"tests/_files/NamespaceCoveredFunction.php"
]
},
"extra": {
"branch-alias": {
"dev-master": "6.5.x-dev"
"dev-master": "7.3-dev"
}
}
}

View File

@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpab" version="^1.24.1" installed="1.25.0" location="./build/tools/phpab" copy="true"/>
<phar name="php-cs-fixer" version="^2.12.0" installed="2.12.1" location="./build/tools/php-cs-fixer" copy="true"/>
<phar name="php-cs-fixer" version="^2.12.0" installed="2.12.2" location="./build/tools/php-cs-fixer" copy="true"/>
<phar name="phpdox" version="^0.11.2" installed="0.11.2" location="./build/tools/phpdox" copy="true"/>
<phar name="phploc" version="^4.0.1" installed="4.0.1" location="./build/tools/phploc" copy="true"/>
<phar name="phpstan" version="^0.10.1" installed="0.10.1" location="./build/tools/phpstan" copy="true"/>
</phive>

View File

@@ -0,0 +1,50 @@
parameters:
ignoreErrors:
# https://github.com/phpstan/phpstan/issues/1185
- '#Function xdebug_disable not found.#'
# parent calls are intentionally omitted
- '#Issue244Exception::__construct\(\) does not call parent constructor from Exception.#'
- '#Issue244ExceptionIntCode::__construct\(\) does not call parent constructor from Exception.#'
# these constants are defined in PHPUnit configuration XML, so they can't be detected in PHPStan
- '#Constant PHPUNIT_1330 not found.#'
- '#Constant FOO not found.#'
- '#Constant BAR not found.#'
# global constants does not work properly in PHPStan yet https://github.com/phpstan/phpstan/issues/768
- '#Constant TEST_FILES_PATH not found.#'
- '#Constant GITHUB_ISSUE not found.#'
# This access to undefined property is legit
- '#Access to an undefined property SplObjectStorage::\$foo#'
# intentionally non existent function in tests/Regression/GitHub/3107/Issue3107Test.php
- '#Function does_not_exist not found#'
# https://github.com/sebastianbergmann/phpunit/issues/3129
- '#Access to an undefined property PHPUnit\\Framework\\MockObject\\MockObject::\$constructorArgs#'
- '#Access to an undefined property PHPUnit\\Framework\\MockObject\\MockObject::\$constructorCalled#'
- '#Access to an undefined property PHPUnit\\Framework\\MockObject\\MockObject::\$cloned#'
- '#Call to an undefined method PHPUnit\\Framework\\MockObject\\MockObject::foo()#'
- '#Call to an undefined method PHPUnit\\Framework\\MockObject\\MockObject::bar()#'
- '#Call to an undefined method PHPUnit\\Framework\\MockObject\\MockObject::doSomething()#'
- '#Call to an undefined method PHPUnit\\Framework\\MockObject\\MockObject::wrong()#'
- '#Call to an undefined method PHPUnit\\Framework\\MockObject\\MockObject::right()#'
- '#Call to an undefined method PHPUnit\\Framework\\MockObject\\MockObject::staticMethod()#'
- '#Call to an undefined method PHPUnit\\Framework\\MockObject\\MockObject::returnAnything()#'
- '#Call to an undefined method PHPUnit\\Framework\\MockObject\\MockObject::mockableMethod()#'
- '#Call to an undefined method PHPUnit\\Framework\\MockObject\\MockObject::anotherMockableMethod()#'
- '#Call to an undefined method PHPUnit\\Framework\\MockObject\\MockObject::someMethod()#'
- '#Call to an undefined method PHPUnit\\Framework\\MockObject\\MockObject::callback()#'
- '#Call to an undefined method object::ohHai#'
- '#Call to static method bar\(\) on an unknown class Legacy#'
- '#Class ACustomClassName not found#'
- '#Function functionCallback not found while trying to analyse it - autoloading is probably not configured properly#'
- '#Result of method ClassWithAllPossibleReturnTypes::methodWithVoidReturnTypeDeclaration\(\) \(void\) is used#'
excludes_analyse:
- tests/_files/phpunit-example-extension/tests/OneTest.php
- tests/Regression/Trac/783/OneTest.php
- tests/_files/3194.php
- tests/_files/RouterTest.php

7
vendor/phpunit/phpunit/phpstan.neon vendored Normal file
View File

@@ -0,0 +1,7 @@
parameters:
ignoreErrors:
# https://github.com/phpstan/phpstan/issues/1185
- '#Function xdebug_start_function_monitor not found.#'
- '#Function xdebug_get_monitored_functions not found.#'
- '#Function xdebug_stop_function_monitor not found.#'

View File

@@ -9,11 +9,11 @@
* file that was distributed with this source code.
*/
if (version_compare('7.0.0', PHP_VERSION, '>')) {
if (version_compare('7.1.0', PHP_VERSION, '>')) {
fwrite(
STDERR,
sprintf(
'This version of PHPUnit is supported on PHP 7.0 and PHP 7.1.' . PHP_EOL .
'This version of PHPUnit is supported on PHP 7.1 and PHP 7.2.' . PHP_EOL .
'You are using PHP %s (%s).' . PHP_EOL,
PHP_VERSION,
PHP_BINARY

View File

@@ -2,15 +2,17 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="phpunit.xsd"
bootstrap="tests/bootstrap.php"
cacheResult="true"
verbose="true">
<testsuites>
<testsuite name="small">
<directory suffix="Test.php">tests/Framework</directory>
<directory suffix="Test.php">tests/Runner</directory>
<directory suffix="Test.php">tests/Util</directory>
<directory>tests/Framework</directory>
<directory>tests/Runner</directory>
<directory>tests/Util</directory>
</testsuite>
<testsuite name="large">
<directory suffix=".phpt">tests/Framework/MockObject/Generator</directory>
<directory suffix=".phpt">tests/TextUI</directory>
<directory suffix=".phpt">tests/Regression</directory>
</testsuite>

View File

@@ -1,272 +1,298 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:documentation source="https://phpunit.de/manual/6.5/en/appendixes.configuration.html">
This Schema file defines the rules by which the XML configuration file of PHPUnit 6.5 may be structured.
</xs:documentation>
<xs:appinfo source="https://phpunit.de/manual/6.5/en/appendixes.configuration.html"/>
</xs:annotation>
<xs:element name="phpunit" type="phpUnitType">
<xs:annotation>
<xs:documentation>Root Element</xs:documentation>
<xs:documentation source="https://phpunit.de/documentation.html">
This Schema file defines the rules by which the XML configuration file of PHPUnit 7.3 may be structured.
</xs:documentation>
<xs:appinfo source="https://phpunit.de/documentation.html"/>
</xs:annotation>
</xs:element>
<xs:complexType name="filtersType">
<xs:sequence>
<xs:element name="whitelist" type="whiteListType" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="filterType">
<xs:sequence>
<xs:group ref="pathGroup"/>
<xs:element name="exclude" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:group ref="pathGroup"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="whiteListType">
<xs:complexContent>
<xs:extension base="filterType">
<xs:attribute name="addUncoveredFilesFromWhitelist" default="true" type="xs:boolean"/>
<xs:attribute name="processUncoveredFilesFromWhitelist" default="false" type="xs:boolean"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="groupsType">
<xs:choice>
<xs:sequence>
<xs:element name="include" type="groupType"/>
<xs:element name="exclude" type="groupType" minOccurs="0"/>
</xs:sequence>
<xs:sequence>
<xs:element name="exclude" type="groupType"/>
</xs:sequence>
</xs:choice>
</xs:complexType>
<xs:complexType name="groupType">
<xs:sequence>
<xs:element name="group" type="xs:string" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="listenersType">
<xs:sequence>
<xs:element name="listener" type="objectType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="objectType">
<xs:sequence>
<xs:element name="arguments" minOccurs="0">
<xs:complexType>
<xs:group ref="argumentsGroup"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="class" type="xs:string" use="required"/>
<xs:attribute name="file" type="xs:anyURI"/>
</xs:complexType>
<xs:complexType name="arrayType">
<xs:sequence>
<xs:element name="element" type="argumentType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="argumentType">
<xs:group ref="argumentChoice"/>
<xs:attribute name="key" use="required"/>
</xs:complexType>
<xs:group name="argumentsGroup">
<xs:sequence>
<xs:element name="array" type="arrayType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="integer" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="string" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="double" type="xs:double" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="null" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="object" type="objectType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="file" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="directory" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:group>
<xs:group name="argumentChoice">
<xs:choice>
<xs:element name="array" type="arrayType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="integer" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="string" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="double" type="xs:double" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="null" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="object" type="objectType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="file" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="directory" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
</xs:group>
<xs:simpleType name="columnsType">
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:integer"/>
</xs:simpleType>
<xs:simpleType>
<xs:element name="phpunit" type="phpUnitType">
<xs:annotation>
<xs:documentation>Root Element</xs:documentation>
</xs:annotation>
</xs:element>
<xs:complexType name="filtersType">
<xs:sequence>
<xs:element name="whitelist" type="whiteListType" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="filterType">
<xs:sequence>
<xs:group ref="pathGroup"/>
<xs:element name="exclude" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:group ref="pathGroup"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="whiteListType">
<xs:complexContent>
<xs:extension base="filterType">
<xs:attribute name="addUncoveredFilesFromWhitelist" default="true" type="xs:boolean"/>
<xs:attribute name="processUncoveredFilesFromWhitelist" default="false" type="xs:boolean"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="groupsType">
<xs:choice>
<xs:sequence>
<xs:element name="include" type="groupType"/>
<xs:element name="exclude" type="groupType" minOccurs="0"/>
</xs:sequence>
<xs:sequence>
<xs:element name="exclude" type="groupType"/>
</xs:sequence>
</xs:choice>
</xs:complexType>
<xs:complexType name="groupType">
<xs:sequence>
<xs:element name="group" type="xs:string" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="extensionsType">
<xs:sequence>
<xs:element name="extension" type="objectType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="listenersType">
<xs:sequence>
<xs:element name="listener" type="objectType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="objectType">
<xs:sequence>
<xs:element name="arguments" minOccurs="0">
<xs:complexType>
<xs:group ref="argumentsGroup"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="class" type="xs:string" use="required"/>
<xs:attribute name="file" type="xs:anyURI"/>
</xs:complexType>
<xs:complexType name="arrayType">
<xs:sequence>
<xs:element name="element" type="argumentType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="argumentType">
<xs:group ref="argumentChoice"/>
<xs:attribute name="key" use="required"/>
</xs:complexType>
<xs:group name="argumentsGroup">
<xs:sequence>
<xs:element name="array" type="arrayType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="integer" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="string" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="double" type="xs:double" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="null" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="object" type="objectType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="file" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="directory" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="boolean" type="xs:boolean" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:group>
<xs:group name="argumentChoice">
<xs:choice>
<xs:element name="array" type="arrayType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="integer" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="string" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="double" type="xs:double" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="null" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="object" type="objectType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="file" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="directory" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="boolean" type="xs:boolean" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
</xs:group>
<xs:simpleType name="columnsType">
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:integer"/>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="max"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:complexType name="loggersType">
<xs:sequence>
<xs:element name="log" type="loggerType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="loggerType">
<xs:attribute name="type">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="coverage-html"/>
<xs:enumeration value="coverage-text"/>
<xs:enumeration value="coverage-clover"/>
<xs:enumeration value="coverage-crap4j"/>
<xs:enumeration value="coverage-xml"/>
<xs:enumeration value="coverage-php"/>
<xs:enumeration value="json"/>
<xs:enumeration value="plain"/>
<xs:enumeration value="tap"/>
<xs:enumeration value="teamcity"/>
<xs:enumeration value="junit"/>
<xs:enumeration value="testdox-html"/>
<xs:enumeration value="testdox-text"/>
<xs:enumeration value="testdox-xml"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="target" type="xs:anyURI"/>
<xs:attribute name="lowUpperBound" type="xs:nonNegativeInteger" default="35"/>
<xs:attribute name="highLowerBound" type="xs:nonNegativeInteger" default="70"/>
<xs:attribute name="showUncoveredFiles" type="xs:boolean" default="false"/>
<xs:attribute name="showOnlySummary" type="xs:boolean" default="false"/>
<xs:attribute name="threshold" type="xs:nonNegativeInteger" default="30"/>
</xs:complexType>
<xs:group name="pathGroup">
<xs:sequence>
<xs:element name="directory" type="directoryFilterType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="file" type="fileFilterType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:group>
<xs:complexType name="directoryFilterType">
<xs:simpleContent>
<xs:extension base="xs:anyURI">
<xs:attribute type="xs:string" name="prefix" default=""/>
<xs:attribute type="xs:string" name="suffix" default="Test.php"/>
<xs:attributeGroup ref="phpVersionGroup"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:simpleType name="executionOrderType">
<xs:restriction base="xs:string">
<xs:enumeration value="max"/>
<xs:enumeration value="default"/>
<xs:enumeration value="defects"/>
<xs:enumeration value="depends"/>
<xs:enumeration value="depends,defects"/>
<xs:enumeration value="random"/>
<xs:enumeration value="reverse"/>
<xs:enumeration value="depends,random"/>
<xs:enumeration value="depends,reverse"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:complexType name="loggersType">
<xs:sequence>
<xs:element name="log" type="loggerType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="loggerType">
<xs:attribute name="type">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="coverage-html"/>
<xs:enumeration value="coverage-text"/>
<xs:enumeration value="coverage-clover"/>
<xs:enumeration value="coverage-crap4j"/>
<xs:enumeration value="coverage-xml"/>
<xs:enumeration value="coverage-php"/>
<xs:enumeration value="json"/>
<xs:enumeration value="plain"/>
<xs:enumeration value="tap"/>
<xs:enumeration value="teamcity"/>
<xs:enumeration value="junit"/>
<xs:enumeration value="testdox-html"/>
<xs:enumeration value="testdox-text"/>
<xs:enumeration value="testdox-xml"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="target" type="xs:anyURI"/>
<xs:attribute name="lowUpperBound" type="xs:nonNegativeInteger" default="35"/>
<xs:attribute name="highLowerBound" type="xs:nonNegativeInteger" default="70"/>
<xs:attribute name="showUncoveredFiles" type="xs:boolean" default="false"/>
<xs:attribute name="showOnlySummary" type="xs:boolean" default="false"/>
<xs:attribute name="threshold" type="xs:nonNegativeInteger" default="30"/>
</xs:complexType>
<xs:group name="pathGroup">
<xs:sequence>
<xs:element name="directory" type="directoryFilterType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="file" type="fileFilterType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:group>
<xs:complexType name="directoryFilterType">
<xs:simpleContent>
<xs:extension base="xs:anyURI">
<xs:attribute type="xs:string" name="prefix" default=""/>
<xs:attribute type="xs:string" name="suffix" default="Test.php"/>
<xs:attributeGroup ref="phpVersionGroup"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="fileFilterType">
<xs:simpleContent>
<xs:extension base="xs:anyURI">
<xs:attributeGroup ref="phpVersionGroup"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:attributeGroup name="phpVersionGroup">
<xs:attribute name="phpVersion" type="xs:string" default="5.3.0"/>
<xs:attribute name="phpVersionOperator" type="xs:string" default="&gt;="/>
</xs:attributeGroup>
<xs:complexType name="phpType">
<xs:sequence>
<xs:choice maxOccurs="unbounded">
<xs:element name="includePath" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="ini" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="const" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="var" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="env" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="post" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="get" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="cookie" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="server" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="files" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="request" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
<xs:complexType name="namedValueType">
<xs:attribute name="name" use="required" type="xs:string"/>
<xs:attribute name="value" use="required" type="xs:anySimpleType"/>
<xs:attribute name="verbatim" use="optional" type="xs:boolean"/>
<xs:attribute name="force" use="optional" type="xs:boolean"/>
</xs:complexType>
<xs:complexType name="phpUnitType">
<xs:annotation>
<xs:documentation>The main type specifying the document structure</xs:documentation>
</xs:annotation>
<xs:group ref="configGroup"/>
<xs:attributeGroup ref="configAttributeGroup"/>
</xs:complexType>
<xs:attributeGroup name="configAttributeGroup">
<xs:attribute name="backupGlobals" type="xs:boolean" default="false"/>
<xs:attribute name="backupStaticAttributes" type="xs:boolean" default="false"/>
<xs:attribute name="bootstrap" type="xs:anyURI"/>
<xs:attribute name="cacheTokens" type="xs:boolean"/>
<xs:attribute name="colors" type="xs:boolean" default="false"/>
<xs:attribute name="columns" type="columnsType" default="80"/>
<xs:attribute name="convertDeprecationsToExceptions" type="xs:boolean" default="true"/>
<xs:attribute name="convertErrorsToExceptions" type="xs:boolean" default="true"/>
<xs:attribute name="convertNoticesToExceptions" type="xs:boolean" default="true"/>
<xs:attribute name="convertWarningsToExceptions" type="xs:boolean" default="true"/>
<xs:attribute name="forceCoversAnnotation" type="xs:boolean" default="false"/>
<xs:attribute name="printerClass" type="xs:string" default="PHPUnit_TextUI_ResultPrinter"/>
<xs:attribute name="printerFile" type="xs:anyURI"/>
<xs:attribute name="processIsolation" type="xs:boolean" default="false"/>
<xs:attribute name="stopOnError" type="xs:boolean" default="false"/>
<xs:attribute name="stopOnFailure" type="xs:boolean" default="false"/>
<xs:attribute name="stopOnWarning" type="xs:boolean" default="false"/>
<xs:attribute name="stopOnIncomplete" type="xs:boolean" default="false"/>
<xs:attribute name="stopOnRisky" type="xs:boolean" default="false"/>
<xs:attribute name="stopOnSkipped" type="xs:boolean" default="false"/>
<xs:attribute name="failOnRisky" type="xs:boolean" default="false"/>
<xs:attribute name="failOnWarning" type="xs:boolean" default="false"/>
<xs:attribute name="beStrictAboutChangesToGlobalState" type="xs:boolean" default="false"/>
<xs:attribute name="beStrictAboutOutputDuringTests" type="xs:boolean" default="false"/>
<xs:attribute name="beStrictAboutResourceUsageDuringSmallTests" type="xs:boolean" default="false"/>
<xs:attribute name="beStrictAboutTestsThatDoNotTestAnything" type="xs:boolean" default="true"/>
<xs:attribute name="beStrictAboutTodoAnnotatedTests" type="xs:boolean" default="false"/>
<xs:attribute name="beStrictAboutCoversAnnotation" type="xs:boolean" default="false"/>
<xs:attribute name="enforceTimeLimit" type="xs:boolean" default="false"/>
<xs:attribute name="ignoreDeprecatedCodeUnitsFromCodeCoverage" type="xs:boolean" default="false"/>
<xs:attribute name="timeoutForSmallTests" type="xs:integer" default="1"/>
<xs:attribute name="timeoutForMediumTests" type="xs:integer" default="10"/>
<xs:attribute name="timeoutForLargeTests" type="xs:integer" default="60"/>
<xs:attribute name="testSuiteLoaderClass" type="xs:string" default="PHPUnit_Runner_StandardTestSuiteLoader"/>
<xs:attribute name="testSuiteLoaderFile" type="xs:anyURI"/>
<xs:attribute name="defaultTestSuite" type="xs:string" default=""/>
<xs:attribute name="verbose" type="xs:boolean" default="false"/>
<xs:attribute name="stderr" type="xs:boolean" default="false"/>
<xs:attribute name="reverseDefectList" type="xs:boolean" default="false"/>
<xs:attribute name="registerMockObjectsFromTestArgumentsRecursively" type="xs:boolean" default="false"/>
<xs:attribute name="extensionsDirectory" type="xs:string"/>
</xs:attributeGroup>
<xs:group name="configGroup">
<xs:all>
<xs:element ref="testSuiteFacet" minOccurs="0"/>
<xs:element name="groups" type="groupsType" minOccurs="0"/>
<xs:element name="testdoxGroups" type="groupsType" minOccurs="0"/>
<xs:element name="filter" type="filtersType" minOccurs="0"/>
<xs:element name="logging" type="loggersType" minOccurs="0"/>
<xs:element name="listeners" type="listenersType" minOccurs="0"/>
<xs:element name="php" type="phpType" minOccurs="0"/>
</xs:all>
</xs:group>
<xs:element name="testSuiteFacet" abstract="true"/>
<xs:element name="testsuite" type="testSuiteType" substitutionGroup="testSuiteFacet"/>
<xs:element name="testsuites" type="testSuitesType" substitutionGroup="testSuiteFacet"/>
<xs:complexType name="testSuitesType">
<xs:sequence>
<xs:element name="testsuite" type="testSuiteType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="testSuiteType">
<xs:sequence>
<xs:group ref="pathGroup"/>
<xs:element name="exclude" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:complexType>
</xs:simpleType>
<xs:complexType name="fileFilterType">
<xs:simpleContent>
<xs:extension base="xs:anyURI">
<xs:attributeGroup ref="phpVersionGroup"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:attributeGroup name="phpVersionGroup">
<xs:attribute name="phpVersion" type="xs:string" default="5.3.0"/>
<xs:attribute name="phpVersionOperator" type="xs:string" default="&gt;="/>
</xs:attributeGroup>
<xs:complexType name="phpType">
<xs:sequence>
<xs:choice maxOccurs="unbounded">
<xs:element name="includePath" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="ini" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="const" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="var" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="env" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="post" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="get" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="cookie" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="server" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="files" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="request" type="namedValueType" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
<xs:complexType name="namedValueType">
<xs:attribute name="name" use="required" type="xs:string"/>
<xs:attribute name="value" use="required" type="xs:anySimpleType"/>
<xs:attribute name="verbatim" use="optional" type="xs:boolean"/>
<xs:attribute name="force" use="optional" type="xs:boolean"/>
</xs:complexType>
<xs:complexType name="phpUnitType">
<xs:annotation>
<xs:documentation>The main type specifying the document structure</xs:documentation>
</xs:annotation>
<xs:group ref="configGroup"/>
<xs:attributeGroup ref="configAttributeGroup"/>
</xs:complexType>
<xs:attributeGroup name="configAttributeGroup">
<xs:attribute name="backupGlobals" type="xs:boolean" default="false"/>
<xs:attribute name="backupStaticAttributes" type="xs:boolean" default="false"/>
<xs:attribute name="bootstrap" type="xs:anyURI"/>
<xs:attribute name="cacheResult" type="xs:boolean"/>
<xs:attribute name="cacheResultFile" type="xs:anyURI"/>
<xs:attribute name="cacheTokens" type="xs:boolean"/>
<xs:attribute name="colors" type="xs:boolean" default="false"/>
<xs:attribute name="columns" type="columnsType" default="80"/>
<xs:attribute name="convertDeprecationsToExceptions" type="xs:boolean" default="true"/>
<xs:attribute name="convertErrorsToExceptions" type="xs:boolean" default="true"/>
<xs:attribute name="convertNoticesToExceptions" type="xs:boolean" default="true"/>
<xs:attribute name="convertWarningsToExceptions" type="xs:boolean" default="true"/>
<xs:attribute name="disableCodeCoverageIgnore" type="xs:boolean" default="false"/>
<xs:attribute name="forceCoversAnnotation" type="xs:boolean" default="false"/>
<xs:attribute name="printerClass" type="xs:string" default="PHPUnit\TextUI\ResultPrinter"/>
<xs:attribute name="printerFile" type="xs:anyURI"/>
<xs:attribute name="processIsolation" type="xs:boolean" default="false"/>
<xs:attribute name="stopOnDefect" type="xs:boolean" default="false"/>
<xs:attribute name="stopOnError" type="xs:boolean" default="false"/>
<xs:attribute name="stopOnFailure" type="xs:boolean" default="false"/>
<xs:attribute name="stopOnWarning" type="xs:boolean" default="false"/>
<xs:attribute name="stopOnIncomplete" type="xs:boolean" default="false"/>
<xs:attribute name="stopOnRisky" type="xs:boolean" default="false"/>
<xs:attribute name="stopOnSkipped" type="xs:boolean" default="false"/>
<xs:attribute name="failOnRisky" type="xs:boolean" default="false"/>
<xs:attribute name="failOnWarning" type="xs:boolean" default="false"/>
<xs:attribute name="beStrictAboutChangesToGlobalState" type="xs:boolean" default="false"/>
<xs:attribute name="beStrictAboutOutputDuringTests" type="xs:boolean" default="false"/>
<xs:attribute name="beStrictAboutResourceUsageDuringSmallTests" type="xs:boolean" default="false"/>
<xs:attribute name="beStrictAboutTestsThatDoNotTestAnything" type="xs:boolean" default="true"/>
<xs:attribute name="beStrictAboutTodoAnnotatedTests" type="xs:boolean" default="false"/>
<xs:attribute name="beStrictAboutCoversAnnotation" type="xs:boolean" default="false"/>
<xs:attribute name="enforceTimeLimit" type="xs:boolean" default="false"/>
<xs:attribute name="ignoreDeprecatedCodeUnitsFromCodeCoverage" type="xs:boolean" default="false"/>
<xs:attribute name="timeoutForSmallTests" type="xs:integer" default="1"/>
<xs:attribute name="timeoutForMediumTests" type="xs:integer" default="10"/>
<xs:attribute name="timeoutForLargeTests" type="xs:integer" default="60"/>
<xs:attribute name="testSuiteLoaderClass" type="xs:string" default="PHPUnit\Runner\StandardTestSuiteLoader"/>
<xs:attribute name="testSuiteLoaderFile" type="xs:anyURI"/>
<xs:attribute name="defaultTestSuite" type="xs:string" default=""/>
<xs:attribute name="verbose" type="xs:boolean" default="false"/>
<xs:attribute name="stderr" type="xs:boolean" default="false"/>
<xs:attribute name="reverseDefectList" type="xs:boolean" default="false"/>
<xs:attribute name="registerMockObjectsFromTestArgumentsRecursively" type="xs:boolean" default="false"/>
<xs:attribute name="extensionsDirectory" type="xs:string"/>
<xs:attribute name="executionOrder" type="executionOrderType" default="default"/>
<xs:attribute name="resolveDependencies" type="xs:boolean" default="false"/>
</xs:attributeGroup>
<xs:group name="configGroup">
<xs:all>
<xs:element ref="testSuiteFacet" minOccurs="0"/>
<xs:element name="groups" type="groupsType" minOccurs="0"/>
<xs:element name="testdoxGroups" type="groupsType" minOccurs="0"/>
<xs:element name="filter" type="filtersType" minOccurs="0"/>
<xs:element name="logging" type="loggersType" minOccurs="0"/>
<xs:element name="extensions" type="extensionsType" minOccurs="0"/>
<xs:element name="listeners" type="listenersType" minOccurs="0"/>
<xs:element name="php" type="phpType" minOccurs="0"/>
</xs:all>
</xs:group>
<xs:element name="testSuiteFacet" abstract="true"/>
<xs:element name="testsuite" type="testSuiteType" substitutionGroup="testSuiteFacet"/>
<xs:element name="testsuites" type="testSuitesType" substitutionGroup="testSuiteFacet"/>
<xs:complexType name="testSuitesType">
<xs:sequence>
<xs:element name="testsuite" type="testSuiteType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="testSuiteType">
<xs:sequence>
<xs:group ref="pathGroup"/>
<xs:element name="exclude" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:complexType>
</xs:schema>

View File

@@ -7,7 +7,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit;
/**

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -7,7 +7,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework;
/**
@@ -17,10 +16,8 @@ class AssertionFailedError extends Exception implements SelfDescribing
{
/**
* Wrapper for getMessage() which is declared as final.
*
* @return string
*/
public function toString()
public function toString(): string
{
return $this->getMessage();
}

View File

@@ -7,7 +7,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework;
class CodeCoverageException extends Exception

View File

@@ -24,7 +24,7 @@ class ArrayHasKey extends Constraint
/**
* @var int|string
*/
protected $key;
private $key;
/**
* @param int|string $key
@@ -35,15 +35,23 @@ class ArrayHasKey extends Constraint
$this->key = $key;
}
/**
* Returns a string representation of the constraint.
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function toString(): string
{
return 'has the key ' . $this->exporter->export($this->key);
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
* @param mixed $other value or object to evaluate
*/
protected function matches($other)
protected function matches($other): bool
{
if (\is_array($other)) {
return \array_key_exists($this->key, $other);
@@ -56,27 +64,17 @@ class ArrayHasKey extends Constraint
return false;
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
return 'has the key ' . $this->exporter->export($this->key);
}
/**
* Returns the description of the failure
*
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other Evaluated value or object.
* @param mixed $other evaluated value or object
*
* @return string
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
protected function failureDescription($other)
protected function failureDescription($other): string
{
return 'an array ' . $this->toString();
}

View File

@@ -21,20 +21,16 @@ use SebastianBergmann\Comparator\ComparisonFailure;
class ArraySubset extends Constraint
{
/**
* @var array|\Traversable
* @var iterable
*/
protected $subset;
private $subset;
/**
* @var bool
*/
protected $strict;
private $strict;
/**
* @param array|\Traversable $subset
* @param bool $strict Check for object identity
*/
public function __construct($subset, $strict = false)
public function __construct(iterable $subset, bool $strict = false)
{
parent::__construct();
@@ -52,13 +48,12 @@ class ArraySubset extends Constraint
* a boolean value instead: true in case of success, false in case of a
* failure.
*
* @param mixed $other Value or object to evaluate.
* @param mixed $other value or object to evaluate
* @param string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @return mixed
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function evaluate($other, $description = '', $returnResult = false)
{
@@ -67,13 +62,12 @@ class ArraySubset extends Constraint
$other = $this->toArray($other);
$this->subset = $this->toArray($this->subset);
$patched = \array_replace_recursive($other, $this->subset);
$intersect = $this->arrayIntersectRecursive($other, $this->subset);
if ($this->strict) {
$result = $other === $patched;
} else {
$result = $other == $patched;
}
$this->deepSort($intersect);
$this->deepSort($this->subset);
$result = $this->compare($intersect, $this->subset);
if ($returnResult) {
return $result;
@@ -81,9 +75,9 @@ class ArraySubset extends Constraint
if (!$result) {
$f = new ComparisonFailure(
$patched,
$this->subset,
$other,
\print_r($patched, true),
\print_r($this->subset, true),
\print_r($other, true)
);
@@ -94,9 +88,9 @@ class ArraySubset extends Constraint
/**
* Returns a string representation of the constraint.
*
* @return string
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function toString()
public function toString(): string
{
return 'has the subset ' . $this->exporter->export($this->subset);
}
@@ -107,21 +101,16 @@ class ArraySubset extends Constraint
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other Evaluated value or object.
* @param mixed $other evaluated value or object
*
* @return string
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
protected function failureDescription($other)
protected function failureDescription($other): string
{
return 'an array ' . $this->toString();
}
/**
* @param array|\Traversable $other
*
* @return array
*/
private function toArray($other)
private function toArray(iterable $other): array
{
if (\is_array($other)) {
return $other;
@@ -138,4 +127,86 @@ class ArraySubset extends Constraint
// Keep BC even if we know that array would not be the expected one
return (array) $other;
}
private function isAssociative(array $array): bool
{
return \array_reduce(
\array_keys($array),
function (bool $carry, $key): bool {
return $carry || \is_string($key);
},
false
);
}
private function compare($first, $second): bool
{
return $this->strict ? $first === $second : $first == $second;
}
private function deepSort(array &$array): void
{
foreach ($array as &$value) {
if (\is_array($value)) {
$this->deepSort($value);
}
}
unset($value);
if ($this->isAssociative($array)) {
\ksort($array);
} else {
\sort($array);
}
}
private function arrayIntersectRecursive(array $array, array $subset): array
{
$intersect = [];
if ($this->isAssociative($subset)) {
// If the subset is an associative array, get the intersection while
// preserving the keys.
foreach ($subset as $key => $subset_value) {
if (\array_key_exists($key, $array)) {
$array_value = $array[$key];
if (\is_array($subset_value) && \is_array($array_value)) {
$intersect[$key] = $this->arrayIntersectRecursive($array_value, $subset_value);
} elseif ($this->compare($subset_value, $array_value)) {
$intersect[$key] = $array_value;
}
}
}
} else {
// If the subset is an indexed array, loop over all entries in the
// haystack and check if they match the ones in the subset.
foreach ($array as $array_value) {
if (\is_array($array_value)) {
foreach ($subset as $key => $subset_value) {
if (\is_array($subset_value)) {
$recursed = $this->arrayIntersectRecursive($array_value, $subset_value);
if (!empty($recursed)) {
$intersect[$key] = $recursed;
break;
}
}
}
} else {
foreach ($subset as $key => $subset_value) {
if (!\is_array($subset_value) && $this->compare($subset_value, $array_value)) {
$intersect[$key] = $array_value;
break;
}
}
}
}
}
return $intersect;
}
}

View File

@@ -17,13 +17,9 @@ class Attribute extends Composite
/**
* @var string
*/
protected $attributeName;
private $attributeName;
/**
* @param Constraint $constraint
* @param string $attributeName
*/
public function __construct(Constraint $constraint, $attributeName)
public function __construct(Constraint $constraint, string $attributeName)
{
parent::__construct($constraint);
@@ -40,13 +36,13 @@ class Attribute extends Composite
* a boolean value instead: true in case of success, false in case of a
* failure.
*
* @param mixed $other Value or object to evaluate.
* @param mixed $other value or object to evaluate
* @param string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @return mixed
*
* @throws ExpectationFailedException
* @throws \PHPUnit\Framework\Exception
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function evaluate($other, $description = '', $returnResult = false)
{
@@ -62,13 +58,10 @@ class Attribute extends Composite
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
public function toString(): string
{
return 'attribute "' . $this->attributeName . '" ' .
$this->innerConstraint->toString();
return 'attribute "' . $this->attributeName . '" ' . $this->innerConstraint()->toString();
}
/**
@@ -77,11 +70,9 @@ class Attribute extends Composite
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other Evaluated value or object.
*
* @return string
* @param mixed $other evaluated value or object
*/
protected function failureDescription($other)
protected function failureDescription($other): string
{
return $this->toString();
}

View File

@@ -9,54 +9,39 @@
*/
namespace PHPUnit\Framework\Constraint;
use PHPUnit\Util\InvalidArgumentHelper;
/**
* Constraint that evaluates against a specified closure.
*/
class Callback extends Constraint
{
/**
* @var callable
*/
private $callback;
/**
* @param callable $callback
*
* @throws \PHPUnit\Framework\Exception
*/
public function __construct($callback)
public function __construct(callable $callback)
{
if (!\is_callable($callback)) {
throw InvalidArgumentHelper::factory(
1,
'callable'
);
}
parent::__construct();
$this->callback = $callback;
}
/**
* Evaluates the constraint for parameter $value. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
*/
protected function matches($other)
{
return \call_user_func($this->callback, $other);
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
public function toString(): string
{
return 'is accepted by specified callback';
}
/**
* Evaluates the constraint for parameter $value. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other value or object to evaluate
*/
protected function matches($other): bool
{
return \call_user_func($this->callback, $other);
}
}

View File

@@ -22,38 +22,19 @@ class ClassHasAttribute extends Constraint
/**
* @var string
*/
protected $attributeName;
private $attributeName;
/**
* @param string $attributeName
*/
public function __construct($attributeName)
public function __construct(string $attributeName)
{
parent::__construct();
$this->attributeName = $attributeName;
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
*/
protected function matches($other)
{
$class = new ReflectionClass($other);
return $class->hasProperty($this->attributeName);
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
public function toString(): string
{
return \sprintf(
'has attribute "%s"',
@@ -61,17 +42,28 @@ class ClassHasAttribute extends Constraint
);
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other value or object to evaluate
*/
protected function matches($other): bool
{
$class = new ReflectionClass($other);
return $class->hasProperty($this->attributeName);
}
/**
* Returns the description of the failure
*
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other Evaluated value or object.
*
* @return string
* @param mixed $other evaluated value or object
*/
protected function failureDescription($other)
protected function failureDescription($other): string
{
return \sprintf(
'%sclass "%s" %s',
@@ -80,4 +72,9 @@ class ClassHasAttribute extends Constraint
$this->toString()
);
}
protected function attributeName(): string
{
return $this->attributeName;
}
}

View File

@@ -19,37 +19,33 @@ use ReflectionClass;
*/
class ClassHasStaticAttribute extends ClassHasAttribute
{
/**
* Returns a string representation of the constraint.
*/
public function toString(): string
{
return \sprintf(
'has static attribute "%s"',
$this->attributeName()
);
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
* @param mixed $other value or object to evaluate
*/
protected function matches($other)
protected function matches($other): bool
{
$class = new ReflectionClass($other);
if ($class->hasProperty($this->attributeName)) {
$attribute = $class->getProperty($this->attributeName);
if ($class->hasProperty($this->attributeName())) {
$attribute = $class->getProperty($this->attributeName());
return $attribute->isStatic();
}
return false;
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
return \sprintf(
'has static attribute "%s"',
$this->attributeName
);
}
}

View File

@@ -16,14 +16,12 @@ abstract class Composite extends Constraint
/**
* @var Constraint
*/
protected $innerConstraint;
private $innerConstraint;
/**
* @param Constraint $innerConstraint
*/
public function __construct(Constraint $innerConstraint)
{
parent::__construct();
$this->innerConstraint = $innerConstraint;
}
@@ -37,13 +35,12 @@ abstract class Composite extends Constraint
* a boolean value instead: true in case of success, false in case of a
* failure.
*
* @param mixed $other Value or object to evaluate.
* @param mixed $other value or object to evaluate
* @param string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @return mixed
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function evaluate($other, $description = '', $returnResult = false)
{
@@ -60,11 +57,14 @@ abstract class Composite extends Constraint
/**
* Counts the number of constraint elements.
*
* @return int
*/
public function count()
public function count(): int
{
return \count($this->innerConstraint);
}
protected function innerConstraint(): Constraint
{
return $this->innerConstraint;
}
}

View File

@@ -7,7 +7,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework\Constraint;
use Countable;
@@ -38,13 +37,12 @@ abstract class Constraint implements Countable, SelfDescribing
* a boolean value instead: true in case of success, false in case of a
* failure.
*
* @param mixed $other Value or object to evaluate.
* @param mixed $other value or object to evaluate
* @param string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @return mixed
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function evaluate($other, $description = '', $returnResult = false)
{
@@ -63,41 +61,38 @@ abstract class Constraint implements Countable, SelfDescribing
}
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* This method can be overridden to implement the evaluation algorithm.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
*/
protected function matches($other)
{
return false;
}
/**
* Counts the number of constraint elements.
*
* @return int
*/
public function count()
public function count(): int
{
return 1;
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* This method can be overridden to implement the evaluation algorithm.
*
* @param mixed $other value or object to evaluate
*/
protected function matches($other): bool
{
return false;
}
/**
* Throws an exception for the given compared value and test description
*
* @param mixed $other Evaluated value or object.
* @param mixed $other evaluated value or object
* @param string $description Additional information about the test
* @param ComparisonFailure $comparisonFailure
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
protected function fail($other, $description, ComparisonFailure $comparisonFailure = null)
protected function fail($other, $description, ComparisonFailure $comparisonFailure = null): void
{
$failureDescription = \sprintf(
'Failed asserting that %s.',
@@ -126,11 +121,9 @@ abstract class Constraint implements Countable, SelfDescribing
* The function can be overridden to provide additional failure
* information like a diff
*
* @param mixed $other Evaluated value or object.
*
* @return string
* @param mixed $other evaluated value or object
*/
protected function additionalFailureDescription($other)
protected function additionalFailureDescription($other): string
{
return '';
}
@@ -144,11 +137,11 @@ abstract class Constraint implements Countable, SelfDescribing
* To provide additional failure information additionalFailureDescription
* can be used.
*
* @param mixed $other Evaluated value or object.
* @param mixed $other evaluated value or object
*
* @return string
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
protected function failureDescription($other)
protected function failureDescription($other): string
{
return $this->exporter->export($other) . ' ' . $this->toString();
}

View File

@@ -20,36 +20,36 @@ class Count extends Constraint
/**
* @var int
*/
protected $expectedCount = 0;
private $expectedCount;
/**
* @param int $expected
*/
public function __construct($expected)
public function __construct(int $expected)
{
parent::__construct();
$this->expectedCount = $expected;
}
public function toString(): string
{
return \sprintf(
'count matches %d',
$this->expectedCount
);
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other
*
* @return bool
*/
protected function matches($other)
protected function matches($other): bool
{
return $this->expectedCount === $this->getCountOf($other);
}
/**
* @param \Countable|\Traversable|array $other
*
* @return int|null
* @param iterable $other
*/
protected function getCountOf($other)
protected function getCountOf($other): ?int
{
if ($other instanceof Countable || \is_array($other)) {
return \count($other);
@@ -77,6 +77,7 @@ class Count extends Constraint
// moves pointer.
if ($key !== null) {
$iterator->rewind();
while ($iterator->valid() && $key !== $iterator->key()) {
$iterator->next();
}
@@ -89,12 +90,8 @@ class Count extends Constraint
/**
* Returns the total number of iterations from a generator.
* This will fully exhaust the generator.
*
* @param Generator $generator
*
* @return int
*/
protected function getCountOfGenerator(Generator $generator)
protected function getCountOfGenerator(Generator $generator): int
{
for ($count = 0; $generator->valid(); $generator->next()) {
++$count;
@@ -109,11 +106,9 @@ class Count extends Constraint
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other Evaluated value or object.
*
* @return string
* @param mixed $other evaluated value or object
*/
protected function failureDescription($other)
protected function failureDescription($other): string
{
return \sprintf(
'actual size %d matches expected size %d',
@@ -121,15 +116,4 @@ class Count extends Constraint
$this->expectedCount
);
}
/**
* @return string
*/
public function toString()
{
return \sprintf(
'count matches %d',
$this->expectedCount
);
}
}

View File

@@ -16,15 +16,21 @@ namespace PHPUnit\Framework\Constraint;
*/
class DirectoryExists extends Constraint
{
/**
* Returns a string representation of the constraint.
*/
public function toString(): string
{
return 'directory exists';
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
* @param mixed $other value or object to evaluate
*/
protected function matches($other)
protected function matches($other): bool
{
return \is_dir($other);
}
@@ -35,25 +41,13 @@ class DirectoryExists extends Constraint
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other Evaluated value or object.
*
* @return string
* @param mixed $other evaluated value or object
*/
protected function failureDescription($other)
protected function failureDescription($other): string
{
return \sprintf(
'directory "%s" exists',
$other
);
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
return 'directory exists';
}
}

View File

@@ -17,26 +17,33 @@ class Exception extends Constraint
/**
* @var string
*/
protected $className;
private $className;
/**
* @param string $className
*/
public function __construct($className)
public function __construct(string $className)
{
parent::__construct();
$this->className = $className;
}
/**
* Returns a string representation of the constraint.
*/
public function toString(): string
{
return \sprintf(
'exception of type "%s"',
$this->className
);
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
* @param mixed $other value or object to evaluate
*/
protected function matches($other)
protected function matches($other): bool
{
return $other instanceof $this->className;
}
@@ -47,14 +54,13 @@ class Exception extends Constraint
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other Evaluated value or object.
*
* @return string
* @param mixed $other evaluated value or object
*/
protected function failureDescription($other)
protected function failureDescription($other): string
{
if ($other !== null) {
$message = '';
if ($other instanceof Throwable) {
$message = '. Message was: "' . $other->getMessage() . '" at'
. "\n" . Filter::getFilteredStacktrace($other);
@@ -73,17 +79,4 @@ class Exception extends Constraint
$this->className
);
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
return \sprintf(
'exception of type "%s"',
$this->className
);
}
}

View File

@@ -12,12 +12,12 @@ namespace PHPUnit\Framework\Constraint;
class ExceptionCode extends Constraint
{
/**
* @var int
* @var int|string
*/
protected $expectedCode;
private $expectedCode;
/**
* @param int $expected
* @param int|string $expected
*/
public function __construct($expected)
{
@@ -26,17 +26,20 @@ class ExceptionCode extends Constraint
$this->expectedCode = $expected;
}
public function toString(): string
{
return 'exception code is ';
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param \Throwable $other
*
* @return bool
*/
protected function matches($other)
protected function matches($other): bool
{
return (string) $other->getCode() == (string) $this->expectedCode;
return (string) $other->getCode() === (string) $this->expectedCode;
}
/**
@@ -45,11 +48,11 @@ class ExceptionCode extends Constraint
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other Evaluated value or object.
* @param mixed $other evaluated value or object
*
* @return string
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
protected function failureDescription($other)
protected function failureDescription($other): string
{
return \sprintf(
'%s is equal to expected exception code %s',
@@ -57,12 +60,4 @@ class ExceptionCode extends Constraint
$this->exporter->export($this->expectedCode)
);
}
/**
* @return string
*/
public function toString()
{
return 'exception code is ';
}
}

View File

@@ -12,29 +12,33 @@ namespace PHPUnit\Framework\Constraint;
class ExceptionMessage extends Constraint
{
/**
* @var int
* @var string
*/
protected $expectedMessage;
private $expectedMessage;
/**
* @param string $expected
*/
public function __construct($expected)
public function __construct(string $expected)
{
parent::__construct();
$this->expectedMessage = $expected;
}
public function toString(): string
{
if ($this->expectedMessage === '') {
return 'exception message is empty';
}
return 'exception message contains ';
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param \Throwable $other
*
* @return bool
*/
protected function matches($other)
protected function matches($other): bool
{
if ($this->expectedMessage === '') {
return $other->getMessage() === '';
@@ -49,11 +53,9 @@ class ExceptionMessage extends Constraint
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other Evaluated value or object.
*
* @return string
* @param mixed $other evaluated value or object
*/
protected function failureDescription($other)
protected function failureDescription($other): string
{
if ($this->expectedMessage === '') {
return \sprintf(
@@ -68,16 +70,4 @@ class ExceptionMessage extends Constraint
$this->expectedMessage
);
}
/**
* @return string
*/
public function toString()
{
if ($this->expectedMessage === '') {
return 'exception message is empty';
}
return 'exception message contains ';
}
}

View File

@@ -16,36 +16,40 @@ class ExceptionMessageRegularExpression extends Constraint
/**
* @var string
*/
protected $expectedMessageRegExp;
private $expectedMessageRegExp;
/**
* @param string $expected
*/
public function __construct($expected)
public function __construct(string $expected)
{
parent::__construct();
$this->expectedMessageRegExp = $expected;
}
public function toString(): string
{
return 'exception message matches ';
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param \PHPUnit\Framework\Exception $other
*
* @return bool
* @throws \Exception
* @throws \PHPUnit\Framework\Exception
*/
protected function matches($other)
protected function matches($other): bool
{
$match = RegularExpressionUtil::safeMatch($this->expectedMessageRegExp, $other->getMessage());
if (false === $match) {
if ($match === false) {
throw new \PHPUnit\Framework\Exception(
"Invalid expected exception message regex given: '{$this->expectedMessageRegExp}'"
);
}
return 1 === $match;
return $match === 1;
}
/**
@@ -54,11 +58,9 @@ class ExceptionMessageRegularExpression extends Constraint
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other Evaluated value or object.
*
* @return string
* @param mixed $other evaluated value or object
*/
protected function failureDescription($other)
protected function failureDescription($other): string
{
return \sprintf(
"exception message '%s' matches '%s'",
@@ -66,12 +68,4 @@ class ExceptionMessageRegularExpression extends Constraint
$this->expectedMessageRegExp
);
}
/**
* @return string
*/
public function toString()
{
return 'exception message matches ';
}
}

View File

@@ -16,15 +16,21 @@ namespace PHPUnit\Framework\Constraint;
*/
class FileExists extends Constraint
{
/**
* Returns a string representation of the constraint.
*/
public function toString(): string
{
return 'file exists';
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
* @param mixed $other value or object to evaluate
*/
protected function matches($other)
protected function matches($other): bool
{
return \file_exists($other);
}
@@ -35,25 +41,13 @@ class FileExists extends Constraint
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other Evaluated value or object.
*
* @return string
* @param mixed $other evaluated value or object
*/
protected function failureDescription($other)
protected function failureDescription($other): string
{
return \sprintf(
'file "%s" exists',
$other
);
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
return 'file exists';
}
}

View File

@@ -16,12 +16,12 @@ namespace PHPUnit\Framework\Constraint;
class GreaterThan extends Constraint
{
/**
* @var int|float
* @var float|int
*/
protected $value;
private $value;
/**
* @param int|float $value
* @param float|int $value
*/
public function __construct($value)
{
@@ -30,26 +30,24 @@ class GreaterThan extends Constraint
$this->value = $value;
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
*/
protected function matches($other)
{
return $this->value < $other;
}
/**
* Returns a string representation of the constraint.
*
* @return string
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function toString()
public function toString(): string
{
return 'is greater than ' . $this->exporter->export($this->value);
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other value or object to evaluate
*/
protected function matches($other): bool
{
return $this->value < $other;
}
}

View File

@@ -26,12 +26,10 @@ class IsAnything extends Constraint
* a boolean value instead: true in case of success, false in case of a
* failure.
*
* @param mixed $other Value or object to evaluate.
* @param mixed $other value or object to evaluate
* @param string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @return mixed
*
* @throws ExpectationFailedException
*/
public function evaluate($other, $description = '', $returnResult = false)
@@ -41,20 +39,16 @@ class IsAnything extends Constraint
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
public function toString(): string
{
return 'is anything';
}
/**
* Counts the number of constraint elements.
*
* @return int
*/
public function count()
public function count(): int
{
return 0;
}

View File

@@ -16,15 +16,21 @@ use Countable;
*/
class IsEmpty extends Constraint
{
/**
* Returns a string representation of the constraint.
*/
public function toString(): string
{
return 'is empty';
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
* @param mixed $other value or object to evaluate
*/
protected function matches($other)
protected function matches($other): bool
{
if ($other instanceof Countable) {
return \count($other) === 0;
@@ -33,27 +39,15 @@ class IsEmpty extends Constraint
return empty($other);
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
return 'is empty';
}
/**
* Returns the description of the failure
*
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other Evaluated value or object.
*
* @return string
* @param mixed $other evaluated value or object
*/
protected function failureDescription($other)
protected function failureDescription($other): string
{
$type = \gettype($other);

View File

@@ -10,7 +10,6 @@
namespace PHPUnit\Framework\Constraint;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Util\InvalidArgumentHelper;
use SebastianBergmann\Comparator\ComparisonFailure;
use SebastianBergmann\Comparator\Factory as ComparatorFactory;
@@ -18,7 +17,7 @@ use SebastianBergmann\Comparator\Factory as ComparatorFactory;
* Constraint that checks if one value is equal to another.
*
* Equality is checked with PHP's == operator, the operator is explained in
* detail at {@url http://www.php.net/manual/en/types.comparisons.php}.
* detail at {@url https://php.net/manual/en/types.comparisons.php}.
* Two values are equal if they have the same value disregarding type.
*
* The expected value is passed in the constructor.
@@ -28,57 +27,32 @@ class IsEqual extends Constraint
/**
* @var mixed
*/
protected $value;
private $value;
/**
* @var float
*/
protected $delta = 0.0;
private $delta;
/**
* @var int
*/
protected $maxDepth = 10;
private $maxDepth;
/**
* @var bool
*/
protected $canonicalize = false;
private $canonicalize;
/**
* @var bool
*/
protected $ignoreCase = false;
private $ignoreCase;
/**
* @param mixed $value
* @param float $delta
* @param int $maxDepth
* @param bool $canonicalize
* @param bool $ignoreCase
*
* @throws \PHPUnit\Framework\Exception
*/
public function __construct($value, $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false)
public function __construct($value, float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)
{
parent::__construct();
if (!\is_numeric($delta)) {
throw InvalidArgumentHelper::factory(2, 'numeric');
}
if (!\is_int($maxDepth)) {
throw InvalidArgumentHelper::factory(3, 'integer');
}
if (!\is_bool($canonicalize)) {
throw InvalidArgumentHelper::factory(4, 'boolean');
}
if (!\is_bool($ignoreCase)) {
throw InvalidArgumentHelper::factory(5, 'boolean');
}
$this->value = $value;
$this->delta = $delta;
$this->maxDepth = $maxDepth;
@@ -96,12 +70,10 @@ class IsEqual extends Constraint
* a boolean value instead: true in case of success, false in case of a
* failure.
*
* @param mixed $other Value or object to evaluate.
* @param mixed $other value or object to evaluate
* @param string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @return mixed
*
* @throws ExpectationFailedException
*/
public function evaluate($other, $description = '', $returnResult = false)
@@ -145,9 +117,9 @@ class IsEqual extends Constraint
/**
* Returns a string representation of the constraint.
*
* @return string
* @throws SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function toString()
public function toString(): string
{
$delta = '';

View File

@@ -14,26 +14,22 @@ namespace PHPUnit\Framework\Constraint;
*/
class IsFalse extends Constraint
{
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
*/
protected function matches($other)
{
return $other === false;
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
public function toString(): string
{
return 'is false';
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other value or object to evaluate
*/
protected function matches($other): bool
{
return $other === false;
}
}

View File

@@ -14,26 +14,22 @@ namespace PHPUnit\Framework\Constraint;
*/
class IsFinite extends Constraint
{
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
*/
protected function matches($other)
{
return \is_finite($other);
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
public function toString(): string
{
return 'is finite';
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other value or object to evaluate
*/
protected function matches($other): bool
{
return \is_finite($other);
}
}

View File

@@ -17,7 +17,7 @@ use SebastianBergmann\Comparator\ComparisonFailure;
*
* Identical check is performed with PHP's === operator, the operator is
* explained in detail at
* {@url http://www.php.net/manual/en/types.comparisons.php}.
* {@url https://php.net/manual/en/types.comparisons.php}.
* Two values are identical if they have the same value and are of the same
* type.
*
@@ -28,19 +28,17 @@ class IsIdentical extends Constraint
/**
* @var float
*/
const EPSILON = 0.0000000001;
private const EPSILON = 0.0000000001;
/**
* @var mixed
*/
protected $value;
private $value;
/**
* @param mixed $value
*/
public function __construct($value)
{
parent::__construct();
$this->value = $value;
}
@@ -54,13 +52,12 @@ class IsIdentical extends Constraint
* a boolean value instead: true in case of success, false in case of a
* failure.
*
* @param mixed $other Value or object to evaluate.
* @param mixed $other value or object to evaluate
* @param string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @return mixed
*
* @throws ExpectationFailedException
* @throws SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function evaluate($other, $description = '', $returnResult = false)
{
@@ -89,21 +86,46 @@ class IsIdentical extends Constraint
);
}
// if both values are array, make sure a diff is generated
if (\is_array($this->value) && \is_array($other)) {
$f = new ComparisonFailure(
$this->value,
$other,
$this->exporter->export($this->value),
$this->exporter->export($other)
);
}
$this->fail($other, $description, $f);
}
}
/**
* Returns a string representation of the constraint.
*
* @throws SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function toString(): string
{
if (\is_object($this->value)) {
return 'is identical to an object of class "' .
\get_class($this->value) . '"';
}
return 'is identical to ' . $this->exporter->export($this->value);
}
/**
* Returns the description of the failure
*
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other Evaluated value or object.
* @param mixed $other evaluated value or object
*
* @return string
* @throws SebastianBergmann\RecursionContext\InvalidArgumentException
*/
protected function failureDescription($other)
protected function failureDescription($other): string
{
if (\is_object($this->value) && \is_object($other)) {
return 'two variables reference the same object';
@@ -113,21 +135,10 @@ class IsIdentical extends Constraint
return 'two strings are identical';
}
return parent::failureDescription($other);
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
if (\is_object($this->value)) {
return 'is identical to an object of class "' .
\get_class($this->value) . '"';
if (\is_array($this->value) && \is_array($other)) {
return 'two arrays are identical';
}
return 'is identical to ' . $this->exporter->export($this->value);
return parent::failureDescription($other);
}
}

View File

@@ -14,26 +14,22 @@ namespace PHPUnit\Framework\Constraint;
*/
class IsInfinite extends Constraint
{
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
*/
protected function matches($other)
{
return \is_infinite($other);
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
public function toString(): string
{
return 'is infinite';
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other value or object to evaluate
*/
protected function matches($other): bool
{
return \is_infinite($other);
}
}

View File

@@ -23,28 +23,36 @@ class IsInstanceOf extends Constraint
/**
* @var string
*/
protected $className;
private $className;
/**
* @param string $className
*/
public function __construct($className)
public function __construct(string $className)
{
parent::__construct();
$this->className = $className;
}
/**
* Returns a string representation of the constraint.
*/
public function toString(): string
{
return \sprintf(
'is instance of %s "%s"',
$this->getType(),
$this->className
);
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
* @param mixed $other value or object to evaluate
*/
protected function matches($other)
protected function matches($other): bool
{
return ($other instanceof $this->className);
return $other instanceof $this->className;
}
/**
@@ -53,11 +61,11 @@ class IsInstanceOf extends Constraint
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other Evaluated value or object.
* @param mixed $other evaluated value or object
*
* @return string
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
protected function failureDescription($other)
protected function failureDescription($other): string
{
return \sprintf(
'%s is an instance of %s "%s"',
@@ -67,24 +75,11 @@ class IsInstanceOf extends Constraint
);
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
return \sprintf(
'is instance of %s "%s"',
$this->getType(),
$this->className
);
}
private function getType()
private function getType(): string
{
try {
$reflection = new ReflectionClass($this->className);
if ($reflection->isInterface()) {
return 'interface';
}

View File

@@ -14,21 +14,28 @@ namespace PHPUnit\Framework\Constraint;
*/
class IsJson extends Constraint
{
/**
* Returns a string representation of the constraint.
*/
public function toString(): string
{
return 'is valid JSON';
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
* @param mixed $other value or object to evaluate
*/
protected function matches($other)
protected function matches($other): bool
{
if ($other === '') {
return false;
}
\json_decode($other);
if (\json_last_error()) {
return false;
}
@@ -42,11 +49,11 @@ class IsJson extends Constraint
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other Evaluated value or object.
* @param mixed $other evaluated value or object
*
* @return string
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
protected function failureDescription($other)
protected function failureDescription($other): string
{
if ($other === '') {
return 'an empty string is valid JSON';
@@ -63,14 +70,4 @@ class IsJson extends Constraint
$error
);
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
return 'is valid JSON';
}
}

View File

@@ -14,26 +14,22 @@ namespace PHPUnit\Framework\Constraint;
*/
class IsNan extends Constraint
{
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
*/
protected function matches($other)
{
return \is_nan($other);
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
public function toString(): string
{
return 'is nan';
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other value or object to evaluate
*/
protected function matches($other): bool
{
return \is_nan($other);
}
}

View File

@@ -14,26 +14,22 @@ namespace PHPUnit\Framework\Constraint;
*/
class IsNull extends Constraint
{
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
*/
protected function matches($other)
{
return $other === null;
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
public function toString(): string
{
return 'is null';
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other value or object to evaluate
*/
protected function matches($other): bool
{
return $other === null;
}
}

View File

@@ -16,15 +16,21 @@ namespace PHPUnit\Framework\Constraint;
*/
class IsReadable extends Constraint
{
/**
* Returns a string representation of the constraint.
*/
public function toString(): string
{
return 'is readable';
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
* @param mixed $other value or object to evaluate
*/
protected function matches($other)
protected function matches($other): bool
{
return \is_readable($other);
}
@@ -35,25 +41,13 @@ class IsReadable extends Constraint
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other Evaluated value or object.
*
* @return string
* @param mixed $other evaluated value or object
*/
protected function failureDescription($other)
protected function failureDescription($other): string
{
return \sprintf(
'"%s" is readable',
$other
);
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
return 'is readable';
}
}

View File

@@ -14,26 +14,22 @@ namespace PHPUnit\Framework\Constraint;
*/
class IsTrue extends Constraint
{
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
*/
protected function matches($other)
{
return $other === true;
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
public function toString(): string
{
return 'is true';
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other value or object to evaluate
*/
protected function matches($other): bool
{
return $other === true;
}
}

View File

@@ -17,22 +17,34 @@ namespace PHPUnit\Framework\Constraint;
*/
class IsType extends Constraint
{
const TYPE_ARRAY = 'array';
const TYPE_BOOL = 'bool';
const TYPE_FLOAT = 'float';
const TYPE_INT = 'int';
const TYPE_NULL = 'null';
const TYPE_NUMERIC = 'numeric';
const TYPE_OBJECT = 'object';
const TYPE_RESOURCE = 'resource';
const TYPE_STRING = 'string';
const TYPE_SCALAR = 'scalar';
const TYPE_CALLABLE = 'callable';
public const TYPE_ARRAY = 'array';
public const TYPE_BOOL = 'bool';
public const TYPE_FLOAT = 'float';
public const TYPE_INT = 'int';
public const TYPE_NULL = 'null';
public const TYPE_NUMERIC = 'numeric';
public const TYPE_OBJECT = 'object';
public const TYPE_RESOURCE = 'resource';
public const TYPE_STRING = 'string';
public const TYPE_SCALAR = 'scalar';
public const TYPE_CALLABLE = 'callable';
public const TYPE_ITERABLE = 'iterable';
/**
* @var array
*/
protected $types = [
private const KNOWN_TYPES = [
'array' => true,
'boolean' => true,
'bool' => true,
@@ -47,24 +59,23 @@ class IsType extends Constraint
'resource' => true,
'string' => true,
'scalar' => true,
'callable' => true
'callable' => true,
'iterable' => true
];
/**
* @var string
*/
protected $type;
private $type;
/**
* @param string $type
*
* @throws \PHPUnit\Framework\Exception
*/
public function __construct($type)
public function __construct(string $type)
{
parent::__construct();
if (!isset($this->types[$type])) {
if (!isset(self::KNOWN_TYPES[$type])) {
throw new \PHPUnit\Framework\Exception(
\sprintf(
'Type specified for PHPUnit\Framework\Constraint\IsType <%s> ' .
@@ -77,15 +88,24 @@ class IsType extends Constraint
$this->type = $type;
}
/**
* Returns a string representation of the constraint.
*/
public function toString(): string
{
return \sprintf(
'is of type "%s"',
$this->type
);
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
* @param mixed $other value or object to evaluate
*/
protected function matches($other)
protected function matches($other): bool
{
switch ($this->type) {
case 'numeric':
@@ -124,19 +144,9 @@ class IsType extends Constraint
case 'callable':
return \is_callable($other);
case 'iterable':
return \is_iterable($other);
}
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
return \sprintf(
'is of type "%s"',
$this->type
);
}
}

View File

@@ -16,15 +16,21 @@ namespace PHPUnit\Framework\Constraint;
*/
class IsWritable extends Constraint
{
/**
* Returns a string representation of the constraint.
*/
public function toString(): string
{
return 'is writable';
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
* @param mixed $other value or object to evaluate
*/
protected function matches($other)
protected function matches($other): bool
{
return \is_writable($other);
}
@@ -35,25 +41,13 @@ class IsWritable extends Constraint
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other Evaluated value or object.
*
* @return string
* @param mixed $other evaluated value or object
*/
protected function failureDescription($other)
protected function failureDescription($other): string
{
return \sprintf(
'"%s" is writable',
$other
);
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
return 'is writable';
}
}

View File

@@ -21,37 +21,44 @@ class JsonMatches extends Constraint
/**
* @var string
*/
protected $value;
private $value;
/**
* Creates a new constraint.
*
* @param string $value
*/
public function __construct($value)
public function __construct(string $value)
{
parent::__construct();
$this->value = $value;
}
/**
* Returns a string representation of the object.
*/
public function toString(): string
{
return \sprintf(
'matches JSON string "%s"',
$this->value
);
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* This method can be overridden to implement the evaluation algorithm.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
* @param mixed $other value or object to evaluate
*/
protected function matches($other)
protected function matches($other): bool
{
list($error, $recodedOther) = Json::canonicalize($other);
[$error, $recodedOther] = Json::canonicalize($other);
if ($error) {
return false;
}
list($error, $recodedValue) = Json::canonicalize($this->value);
[$error, $recodedValue] = Json::canonicalize($this->value);
if ($error) {
return false;
}
@@ -62,23 +69,27 @@ class JsonMatches extends Constraint
/**
* Throws an exception for the given compared value and test description
*
* @param mixed $other Evaluated value or object.
* @param mixed $other evaluated value or object
* @param string $description Additional information about the test
* @param ComparisonFailure $comparisonFailure
*
* @throws ExpectationFailedException
* @throws \PHPUnit\Framework\Exception
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
protected function fail($other, $description, ComparisonFailure $comparisonFailure = null)
protected function fail($other, $description, ComparisonFailure $comparisonFailure = null): void
{
if ($comparisonFailure === null) {
list($error) = Json::canonicalize($other);
[$error] = Json::canonicalize($other);
if ($error) {
parent::fail($other, $description);
return;
}
list($error) = Json::canonicalize($this->value);
[$error] = Json::canonicalize($this->value);
if ($error) {
parent::fail($other, $description);
@@ -97,17 +108,4 @@ class JsonMatches extends Constraint
parent::fail($other, $description, $comparisonFailure);
}
/**
* Returns a string representation of the object.
*
* @return string
*/
public function toString()
{
return \sprintf(
'matches JSON string "%s"',
$this->value
);
}
}

View File

@@ -7,7 +7,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework\Constraint;
/**
@@ -17,26 +16,21 @@ class JsonMatchesErrorMessageProvider
{
/**
* Translates JSON error to a human readable string.
*
* @param string $error
* @param string $prefix
*
* @return string
*/
public static function determineJsonError($error, $prefix = '')
public static function determineJsonError(string $error, string $prefix = ''): ?string
{
switch ($error) {
case JSON_ERROR_NONE:
return;
case JSON_ERROR_DEPTH:
case \JSON_ERROR_NONE:
return null;
case \JSON_ERROR_DEPTH:
return $prefix . 'Maximum stack depth exceeded';
case JSON_ERROR_STATE_MISMATCH:
case \JSON_ERROR_STATE_MISMATCH:
return $prefix . 'Underflow or the modes mismatch';
case JSON_ERROR_CTRL_CHAR:
case \JSON_ERROR_CTRL_CHAR:
return $prefix . 'Unexpected control character found';
case JSON_ERROR_SYNTAX:
case \JSON_ERROR_SYNTAX:
return $prefix . 'Syntax error, malformed JSON';
case JSON_ERROR_UTF8:
case \JSON_ERROR_UTF8:
return $prefix . 'Malformed UTF-8 characters, possibly incorrectly encoded';
default:
return $prefix . 'Unknown error';
@@ -45,12 +39,8 @@ class JsonMatchesErrorMessageProvider
/**
* Translates a given type to a human readable message prefix.
*
* @param string $type
*
* @return string
*/
public static function translateTypeToPrefix($type)
public static function translateTypeToPrefix(string $type): string
{
switch (\strtolower($type)) {
case 'expected':

View File

@@ -16,12 +16,12 @@ namespace PHPUnit\Framework\Constraint;
class LessThan extends Constraint
{
/**
* @var int|float
* @var float|int
*/
protected $value;
private $value;
/**
* @param int|float $value
* @param float|int $value
*/
public function __construct($value)
{
@@ -30,26 +30,24 @@ class LessThan extends Constraint
$this->value = $value;
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
*/
protected function matches($other)
{
return $this->value > $other;
}
/**
* Returns a string representation of the constraint.
*
* @return string
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function toString()
public function toString(): string
{
return 'is less than ' . $this->exporter->export($this->value);
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other value or object to evaluate
*/
protected function matches($other): bool
{
return $this->value > $other;
}
}

View File

@@ -19,12 +19,7 @@ class LogicalAnd extends Constraint
/**
* @var Constraint[]
*/
protected $constraints = [];
/**
* @var Constraint
*/
protected $lastConstraint;
private $constraints = [];
public static function fromConstraints(Constraint ...$constraints): self
{
@@ -40,7 +35,7 @@ class LogicalAnd extends Constraint
*
* @throws \PHPUnit\Framework\Exception
*/
public function setConstraints(array $constraints)
public function setConstraints(array $constraints): void
{
$this->constraints = [];
@@ -66,18 +61,16 @@ class LogicalAnd extends Constraint
* a boolean value instead: true in case of success, false in case of a
* failure.
*
* @param mixed $other Value or object to evaluate.
* @param mixed $other value or object to evaluate
* @param string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @return mixed
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function evaluate($other, $description = '', $returnResult = false)
{
$success = true;
$constraint = null;
$success = true;
foreach ($this->constraints as $constraint) {
if (!$constraint->evaluate($other, $description, true)) {
@@ -98,10 +91,8 @@ class LogicalAnd extends Constraint
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
public function toString(): string
{
$text = '';
@@ -118,10 +109,8 @@ class LogicalAnd extends Constraint
/**
* Counts the number of constraint elements.
*
* @return int
*/
public function count()
public function count(): int
{
$count = 0;

View File

@@ -19,28 +19,9 @@ class LogicalNot extends Constraint
/**
* @var Constraint
*/
protected $constraint;
private $constraint;
/**
* @param Constraint $constraint
*/
public function __construct($constraint)
{
parent::__construct();
if (!($constraint instanceof Constraint)) {
$constraint = new IsEqual($constraint);
}
$this->constraint = $constraint;
}
/**
* @param string $string
*
* @return string
*/
public static function negate($string)
public static function negate(string $string): string
{
$positives = [
'contains ',
@@ -93,6 +74,20 @@ class LogicalNot extends Constraint
return $negatedString;
}
/**
* @param Constraint|mixed $constraint
*/
public function __construct($constraint)
{
parent::__construct();
if (!($constraint instanceof Constraint)) {
$constraint = new IsEqual($constraint);
}
$this->constraint = $constraint;
}
/**
* Evaluates the constraint for parameter $other
*
@@ -103,13 +98,12 @@ class LogicalNot extends Constraint
* a boolean value instead: true in case of success, false in case of a
* failure.
*
* @param mixed $other Value or object to evaluate.
* @param mixed $other value or object to evaluate
* @param string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @return mixed
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function evaluate($other, $description = '', $returnResult = false)
{
@@ -124,37 +118,10 @@ class LogicalNot extends Constraint
}
}
/**
* Returns the description of the failure
*
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other Evaluated value or object.
*
* @return string
*/
protected function failureDescription($other)
{
switch (\get_class($this->constraint)) {
case LogicalAnd::class:
case self::class:
case LogicalOr::class:
return 'not( ' . $this->constraint->failureDescription($other) . ' )';
default:
return self::negate(
$this->constraint->failureDescription($other)
);
}
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
public function toString(): string
{
switch (\get_class($this->constraint)) {
case LogicalAnd::class:
@@ -171,11 +138,34 @@ class LogicalNot extends Constraint
/**
* Counts the number of constraint elements.
*
* @return int
*/
public function count()
public function count(): int
{
return \count($this->constraint);
}
/**
* Returns the description of the failure
*
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other evaluated value or object
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
protected function failureDescription($other): string
{
switch (\get_class($this->constraint)) {
case LogicalAnd::class:
case self::class:
case LogicalOr::class:
return 'not( ' . $this->constraint->failureDescription($other) . ' )';
default:
return self::negate(
$this->constraint->failureDescription($other)
);
}
}
}

View File

@@ -19,7 +19,7 @@ class LogicalOr extends Constraint
/**
* @var Constraint[]
*/
protected $constraints = [];
private $constraints = [];
public static function fromConstraints(Constraint ...$constraints): self
{
@@ -33,7 +33,7 @@ class LogicalOr extends Constraint
/**
* @param Constraint[] $constraints
*/
public function setConstraints(array $constraints)
public function setConstraints(array $constraints): void
{
$this->constraints = [];
@@ -58,18 +58,16 @@ class LogicalOr extends Constraint
* a boolean value instead: true in case of success, false in case of a
* failure.
*
* @param mixed $other Value or object to evaluate.
* @param mixed $other value or object to evaluate
* @param string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @return mixed
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function evaluate($other, $description = '', $returnResult = false)
{
$success = false;
$constraint = null;
$success = false;
foreach ($this->constraints as $constraint) {
if ($constraint->evaluate($other, $description, true)) {
@@ -90,10 +88,8 @@ class LogicalOr extends Constraint
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
public function toString(): string
{
$text = '';
@@ -110,10 +106,8 @@ class LogicalOr extends Constraint
/**
* Counts the number of constraint elements.
*
* @return int
*/
public function count()
public function count(): int
{
$count = 0;

View File

@@ -19,7 +19,7 @@ class LogicalXor extends Constraint
/**
* @var Constraint[]
*/
protected $constraints = [];
private $constraints = [];
public static function fromConstraints(Constraint ...$constraints): self
{
@@ -33,7 +33,7 @@ class LogicalXor extends Constraint
/**
* @param Constraint[] $constraints
*/
public function setConstraints(array $constraints)
public function setConstraints(array $constraints): void
{
$this->constraints = [];
@@ -58,19 +58,17 @@ class LogicalXor extends Constraint
* a boolean value instead: true in case of success, false in case of a
* failure.
*
* @param mixed $other Value or object to evaluate.
* @param mixed $other value or object to evaluate
* @param string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @return mixed
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function evaluate($other, $description = '', $returnResult = false)
{
$success = true;
$lastResult = null;
$constraint = null;
foreach ($this->constraints as $constraint) {
$result = $constraint->evaluate($other, $description, true);
@@ -95,10 +93,8 @@ class LogicalXor extends Constraint
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
public function toString(): string
{
$text = '';
@@ -115,10 +111,8 @@ class LogicalXor extends Constraint
/**
* Counts the number of constraint elements.
*
* @return int
*/
public function count()
public function count(): int
{
$count = 0;

View File

@@ -23,14 +23,12 @@ class ObjectHasAttribute extends ClassHasAttribute
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
* @param mixed $other value or object to evaluate
*/
protected function matches($other)
protected function matches($other): bool
{
$object = new ReflectionObject($other);
return $object->hasProperty($this->attributeName);
return $object->hasProperty($this->attributeName());
}
}

View File

@@ -23,40 +23,34 @@ class RegularExpression extends Constraint
/**
* @var string
*/
protected $pattern;
private $pattern;
/**
* @param string $pattern
*/
public function __construct($pattern)
public function __construct(string $pattern)
{
parent::__construct();
$this->pattern = $pattern;
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
*/
protected function matches($other)
{
return \preg_match($this->pattern, $other) > 0;
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
public function toString(): string
{
return \sprintf(
'matches PCRE pattern "%s"',
$this->pattern
);
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other value or object to evaluate
*/
protected function matches($other): bool
{
return \preg_match($this->pattern, $other) > 0;
}
}

View File

@@ -11,15 +11,7 @@ namespace PHPUnit\Framework\Constraint;
class SameSize extends Count
{
/**
* @var int
*/
protected $expectedCount;
/**
* @param \Countable|\Traversable|array $expected
*/
public function __construct($expected)
public function __construct(iterable $expected)
{
parent::__construct($this->getCountOf($expected));
}

View File

@@ -23,18 +23,14 @@ class StringContains extends Constraint
/**
* @var string
*/
protected $string;
private $string;
/**
* @var bool
*/
protected $ignoreCase;
private $ignoreCase;
/**
* @param string $string
* @param bool $ignoreCase
*/
public function __construct($string, $ignoreCase = false)
public function __construct(string $string, bool $ignoreCase = false)
{
parent::__construct();
@@ -42,33 +38,10 @@ class StringContains extends Constraint
$this->ignoreCase = $ignoreCase;
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
*/
protected function matches($other)
{
if ('' === $this->string) {
return true;
}
if ($this->ignoreCase) {
return \mb_stripos($other, $this->string) !== false;
}
return \mb_strpos($other, $this->string) !== false;
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
public function toString(): string
{
if ($this->ignoreCase) {
$string = \mb_strtolower($this->string);
@@ -81,4 +54,23 @@ class StringContains extends Constraint
$string
);
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other value or object to evaluate
*/
protected function matches($other): bool
{
if ('' === $this->string) {
return true;
}
if ($this->ignoreCase) {
return \mb_stripos($other, $this->string) !== false;
}
return \mb_strpos($other, $this->string) !== false;
}
}

View File

@@ -18,37 +18,31 @@ class StringEndsWith extends Constraint
/**
* @var string
*/
protected $suffix;
private $suffix;
/**
* @param string $suffix
*/
public function __construct($suffix)
public function __construct(string $suffix)
{
parent::__construct();
$this->suffix = $suffix;
}
/**
* Returns a string representation of the constraint.
*/
public function toString(): string
{
return 'ends with "' . $this->suffix . '"';
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
* @param mixed $other value or object to evaluate
*/
protected function matches($other)
protected function matches($other): bool
{
return \substr($other, 0 - \strlen($this->suffix)) == $this->suffix;
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
return 'ends with "' . $this->suffix . '"';
}
}

View File

@@ -7,7 +7,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework\Constraint;
use SebastianBergmann\Diff\Differ;
@@ -20,31 +19,41 @@ class StringMatchesFormatDescription extends RegularExpression
/**
* @var string
*/
protected $string;
private $string;
/**
* @param string $string
*/
public function __construct($string)
public function __construct(string $string)
{
parent::__construct($string);
$this->pattern = $this->createPatternFromFormat(
\preg_replace('/\r\n/', "\n", $string)
parent::__construct(
$this->createPatternFromFormat(
$this->convertNewlines($string)
)
);
$this->string = $string;
}
protected function failureDescription($other)
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other value or object to evaluate
*/
protected function matches($other): bool
{
return parent::matches(
$this->convertNewlines($other)
);
}
protected function failureDescription($other): string
{
return 'string matches format description';
}
protected function additionalFailureDescription($other)
protected function additionalFailureDescription($other): string
{
$from = \preg_split('(\r\n|\r|\n)', $this->string);
$to = \preg_split('(\r\n|\r|\n)', $other);
$from = \explode("\n", $this->string);
$to = \explode("\n", $this->convertNewlines($other));
foreach ($from as $index => $line) {
if (isset($to[$index]) && $line !== $to[$index]) {
@@ -64,24 +73,24 @@ class StringMatchesFormatDescription extends RegularExpression
return $differ->diff($this->string, $other);
}
protected function createPatternFromFormat($string)
private function createPatternFromFormat(string $string): string
{
$string = \str_replace(
$string = \preg_replace(
[
'%e',
'%s',
'%S',
'%a',
'%A',
'%w',
'%i',
'%d',
'%x',
'%f',
'%c'
'/(?<!%)%e/',
'/(?<!%)%s/',
'/(?<!%)%S/',
'/(?<!%)%a/',
'/(?<!%)%A/',
'/(?<!%)%w/',
'/(?<!%)%i/',
'/(?<!%)%d/',
'/(?<!%)%x/',
'/(?<!%)%f/',
'/(?<!%)%c/'
],
[
'\\' . DIRECTORY_SEPARATOR,
\str_replace('\\', '\\\\', '\\' . \DIRECTORY_SEPARATOR),
'[^\r\n]+',
'[^\r\n]*',
'.+',
@@ -96,6 +105,13 @@ class StringMatchesFormatDescription extends RegularExpression
\preg_quote($string, '/')
);
$string = \str_replace('%%', '%', $string);
return '/^' . $string . '$/s';
}
private function convertNewlines($text): string
{
return \preg_replace('/\r\n/', "\n", $text);
}
}

View File

@@ -18,37 +18,31 @@ class StringStartsWith extends Constraint
/**
* @var string
*/
protected $prefix;
private $prefix;
/**
* @param string $prefix
*/
public function __construct($prefix)
public function __construct(string $prefix)
{
parent::__construct();
$this->prefix = $prefix;
}
/**
* Returns a string representation of the constraint.
*/
public function toString(): string
{
return 'starts with "' . $this->prefix . '"';
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
* @param mixed $other value or object to evaluate
*/
protected function matches($other)
protected function matches($other): bool
{
return \strpos($other, $this->prefix) === 0;
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
return 'starts with "' . $this->prefix . '"';
}
}

View File

@@ -9,7 +9,6 @@
*/
namespace PHPUnit\Framework\Constraint;
use PHPUnit\Util\InvalidArgumentHelper;
use SplObjectStorage;
/**
@@ -21,51 +20,51 @@ class TraversableContains extends Constraint
/**
* @var bool
*/
protected $checkForObjectIdentity;
private $checkForObjectIdentity;
/**
* @var bool
*/
protected $checkForNonObjectIdentity;
private $checkForNonObjectIdentity;
/**
* @var mixed
*/
protected $value;
private $value;
/**
* @param mixed $value
* @param bool $checkForObjectIdentity
* @param bool $checkForNonObjectIdentity
*
* @throws \PHPUnit\Framework\Exception
*/
public function __construct($value, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
public function __construct($value, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false)
{
parent::__construct();
if (!\is_bool($checkForObjectIdentity)) {
throw InvalidArgumentHelper::factory(2, 'boolean');
}
if (!\is_bool($checkForNonObjectIdentity)) {
throw InvalidArgumentHelper::factory(3, 'boolean');
}
$this->checkForObjectIdentity = $checkForObjectIdentity;
$this->checkForNonObjectIdentity = $checkForNonObjectIdentity;
$this->value = $value;
}
/**
* Returns a string representation of the constraint.
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function toString(): string
{
if (\is_string($this->value) && \strpos($this->value, "\n") !== false) {
return 'contains "' . $this->value . '"';
}
return 'contains ' . $this->exporter->export($this->value);
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
* @param mixed $other value or object to evaluate
*/
protected function matches($other)
protected function matches($other): bool
{
if ($other instanceof SplObjectStorage) {
return $other->contains($this->value);
@@ -96,31 +95,17 @@ class TraversableContains extends Constraint
return false;
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
if (\is_string($this->value) && \strpos($this->value, "\n") !== false) {
return 'contains "' . $this->value . '"';
}
return 'contains ' . $this->exporter->export($this->value);
}
/**
* Returns the description of the failure
*
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other Evaluated value or object.
* @param mixed $other evaluated value or object
*
* @return string
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
protected function failureDescription($other)
protected function failureDescription($other): string
{
return \sprintf(
'%s %s',

View File

@@ -20,18 +20,17 @@ class TraversableContainsOnly extends Constraint
/**
* @var Constraint
*/
protected $constraint;
private $constraint;
/**
* @var string
*/
protected $type;
private $type;
/**
* @param string $type
* @param bool $isNativeType
* @throws \PHPUnit\Framework\Exception
*/
public function __construct($type, $isNativeType = true)
public function __construct(string $type, bool $isNativeType = true)
{
parent::__construct();
@@ -56,13 +55,12 @@ class TraversableContainsOnly extends Constraint
* a boolean value instead: true in case of success, false in case of a
* failure.
*
* @param mixed $other Value or object to evaluate.
* @param mixed $other value or object to evaluate
* @param string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @return mixed
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function evaluate($other, $description = '', $returnResult = false)
{
@@ -87,10 +85,8 @@ class TraversableContainsOnly extends Constraint
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
public function toString(): string
{
return 'contains only values of type "' . $this->type . '"';
}

View File

@@ -7,7 +7,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework;
class CoveredCodeNotExecutedException extends RiskyTestError

View File

@@ -12,14 +12,29 @@ namespace PHPUnit\Framework;
class DataProviderTestSuite extends TestSuite
{
/**
* Sets the dependencies of a TestCase.
*
* @var string[]
*/
private $dependencies = [];
/**
* @param string[] $dependencies
*/
public function setDependencies(array $dependencies)
public function setDependencies(array $dependencies): void
{
$this->dependencies = $dependencies;
foreach ($this->tests as $test) {
$test->setDependencies($dependencies);
}
}
public function getDependencies(): array
{
return $this->dependencies;
}
public function hasDependencies(): bool
{
return \count($this->dependencies) > 0;
}
}

View File

@@ -7,7 +7,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework\Error;
use PHPUnit\Framework\Exception;
@@ -17,16 +16,7 @@ use PHPUnit\Framework\Exception;
*/
class Error extends Exception
{
/**
* Constructor.
*
* @param string $message
* @param int $code
* @param string $file
* @param int $line
* @param \Exception $previous
*/
public function __construct($message, $code, $file, $line, \Exception $previous = null)
public function __construct(string $message, int $code, string $file, int $line, \Exception $previous = null)
{
parent::__construct($message, $code, $previous);

View File

@@ -50,19 +50,9 @@ class Exception extends \RuntimeException implements \PHPUnit\Exception
}
/**
* Returns the serializable trace (without 'args').
*
* @return array
* @throws \InvalidArgumentException
*/
public function getSerializableTrace()
{
return $this->serializableTrace;
}
/**
* @return string
*/
public function __toString()
public function __toString(): string
{
$string = TestFailure::exceptionToString($this);
@@ -73,8 +63,16 @@ class Exception extends \RuntimeException implements \PHPUnit\Exception
return $string;
}
public function __sleep()
public function __sleep(): array
{
return \array_keys(\get_object_vars($this));
}
/**
* Returns the serializable trace (without 'args').
*/
public function getSerializableTrace(): array
{
return $this->serializableTrace;
}
}

View File

@@ -29,18 +29,54 @@ class ExceptionWrapper extends Exception
protected $className;
/**
* @var ExceptionWrapper|null
* @var null|ExceptionWrapper
*/
protected $previous;
/**
* @param Throwable $t
*/
public function __construct(Throwable $t)
{
// PDOException::getCode() is a string.
// @see http://php.net/manual/en/class.pdoexception.php#95812
// @see https://php.net/manual/en/class.pdoexception.php#95812
parent::__construct($t->getMessage(), (int) $t->getCode());
$this->setOriginalException($t);
}
/**
* @throws \InvalidArgumentException
*/
public function __toString(): string
{
$string = TestFailure::exceptionToString($this);
if ($trace = Filter::getFilteredStacktrace($this)) {
$string .= "\n" . $trace;
}
if ($this->previous) {
$string .= "\nCaused by\n" . $this->previous;
}
return $string;
}
public function getClassName(): string
{
return $this->className;
}
public function getPreviousWrapped(): ?self
{
return $this->previous;
}
public function setClassName(string $className): void
{
$this->className = $className;
}
public function setOriginalException(\Throwable $t): void
{
$this->originalException($t);
$this->className = \get_class($t);
$this->file = $t->getFile();
@@ -57,37 +93,28 @@ class ExceptionWrapper extends Exception
}
}
/**
* @return string
*/
public function getClassName()
public function getOriginalException(): ?Throwable
{
return $this->className;
return $this->originalException();
}
/**
* @return ExceptionWrapper
* Method to contain static originalException to exclude it from stacktrace to prevent the stacktrace contents,
* which can be quite big, from being garbage-collected, thus blocking memory until shutdown.
* Approach works both for var_dump() and var_export() and print_r()
*
* @param null|Throwable $exceptionToStore
*/
public function getPreviousWrapped()
private function originalException(Throwable $exceptionToStore = null): ?Throwable
{
return $this->previous;
}
static $originalExceptions;
/**
* @return string
*/
public function __toString()
{
$string = TestFailure::exceptionToString($this);
$instanceId = \spl_object_hash($this);
if ($trace = Filter::getFilteredStacktrace($this)) {
$string .= "\n" . $trace;
if ($exceptionToStore) {
$originalExceptions[$instanceId] = $exceptionToStore;
}
if ($this->previous) {
$string .= "\nCaused by\n" . $this->previous;
}
return $string;
return $originalExceptions[$instanceId] ?? null;
}
}

View File

@@ -20,24 +20,19 @@ use SebastianBergmann\Comparator\ComparisonFailure;
*/
class ExpectationFailedException extends AssertionFailedError
{
/**
* @var ComparisonFailure
*/
protected $comparisonFailure;
/**
* @param string $message
* @param ComparisonFailure|null $comparisonFailure
* @param \Exception|null $previous
*/
public function __construct($message, ComparisonFailure $comparisonFailure = null, \Exception $previous = null)
public function __construct(string $message, ComparisonFailure $comparisonFailure = null, \Exception $previous = null)
{
$this->comparisonFailure = $comparisonFailure;
parent::__construct($message, 0, $previous);
}
/**
* @return null|ComparisonFailure
*/
public function getComparisonFailure()
public function getComparisonFailure(): ?ComparisonFailure
{
return $this->comparisonFailure;
}

View File

@@ -7,7 +7,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework;
/**

View File

@@ -44,29 +44,14 @@ class IncompleteTestCase extends TestCase
*/
protected $useOutputBuffering = false;
/**
* @param string $className
* @param string $methodName
* @param string $message
*/
public function __construct($className, $methodName, $message = '')
public function __construct(string $className, string $methodName, string $message = '')
{
$this->message = $message;
parent::__construct($className . '::' . $methodName);
$this->message = $message;
}
/**
* @throws Exception
*/
protected function runTest()
{
$this->markTestIncomplete($this->message);
}
/**
* @return string
*/
public function getMessage()
public function getMessage(): string
{
return $this->message;
}
@@ -74,10 +59,18 @@ class IncompleteTestCase extends TestCase
/**
* Returns a string representation of the test case.
*
* @return string
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function toString()
public function toString(): string
{
return $this->getName();
}
/**
* @throws Exception
*/
protected function runTest(): void
{
$this->markTestIncomplete($this->message);
}
}

View File

@@ -7,7 +7,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework;
class MissingCoversAnnotationException extends RiskyTestError

View File

@@ -0,0 +1,30 @@
<?php
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework\MockObject\Builder;
/**
* Builder interface for unique identifiers.
*
* Defines the interface for recording unique identifiers. The identifiers
* can be used to define the invocation order of expectations. The expectation
* is recorded using id() and then defined in order using
* PHPUnit\Framework\MockObject\Builder\Match::after().
*/
interface Identity
{
/**
* Sets the identification of the expectation to $id.
*
* @note The identifier is unique per mock object.
*
* @param string $id unique identification of expectation
*/
public function id($id);
}

View File

@@ -0,0 +1,277 @@
<?php
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework\MockObject\Builder;
use PHPUnit\Framework\Constraint\Constraint;
use PHPUnit\Framework\MockObject\Matcher;
use PHPUnit\Framework\MockObject\Matcher\Invocation;
use PHPUnit\Framework\MockObject\RuntimeException;
use PHPUnit\Framework\MockObject\Stub;
use PHPUnit\Framework\MockObject\Stub\MatcherCollection;
/**
* Builder for mocked or stubbed invocations.
*
* Provides methods for building expectations without having to resort to
* instantiating the various matchers manually. These methods also form a
* more natural way of reading the expectation. This class should be together
* with the test case PHPUnit\Framework\MockObject\TestCase.
*/
class InvocationMocker implements MethodNameMatch
{
/**
* @var MatcherCollection
*/
private $collection;
/**
* @var Matcher
*/
private $matcher;
/**
* @var string[]
*/
private $configurableMethods;
public function __construct(MatcherCollection $collection, Invocation $invocationMatcher, array $configurableMethods)
{
$this->collection = $collection;
$this->matcher = new Matcher($invocationMatcher);
$this->collection->addMatcher($this->matcher);
$this->configurableMethods = $configurableMethods;
}
/**
* @return Matcher
*/
public function getMatcher()
{
return $this->matcher;
}
/**
* @return InvocationMocker
*/
public function id($id)
{
$this->collection->registerId($id, $this);
return $this;
}
/**
* @return InvocationMocker
*/
public function will(Stub $stub)
{
$this->matcher->setStub($stub);
return $this;
}
/**
* @return InvocationMocker
*/
public function willReturn($value, ...$nextValues)
{
if (\count($nextValues) === 0) {
$stub = new Stub\ReturnStub($value);
} else {
$stub = new Stub\ConsecutiveCalls(
\array_merge([$value], $nextValues)
);
}
return $this->will($stub);
}
/**
* @param mixed $reference
*
* @return InvocationMocker
*/
public function willReturnReference(&$reference)
{
$stub = new Stub\ReturnReference($reference);
return $this->will($stub);
}
/**
* @return InvocationMocker
*/
public function willReturnMap(array $valueMap)
{
$stub = new Stub\ReturnValueMap($valueMap);
return $this->will($stub);
}
/**
* @return InvocationMocker
*/
public function willReturnArgument($argumentIndex)
{
$stub = new Stub\ReturnArgument($argumentIndex);
return $this->will($stub);
}
/**
* @param callable $callback
*
* @return InvocationMocker
*/
public function willReturnCallback($callback)
{
$stub = new Stub\ReturnCallback($callback);
return $this->will($stub);
}
/**
* @return InvocationMocker
*/
public function willReturnSelf()
{
$stub = new Stub\ReturnSelf;
return $this->will($stub);
}
/**
* @return InvocationMocker
*/
public function willReturnOnConsecutiveCalls(...$values)
{
$stub = new Stub\ConsecutiveCalls($values);
return $this->will($stub);
}
/**
* @return InvocationMocker
*/
public function willThrowException(\Exception $exception)
{
$stub = new Stub\Exception($exception);
return $this->will($stub);
}
/**
* @return InvocationMocker
*/
public function after($id)
{
$this->matcher->setAfterMatchBuilderId($id);
return $this;
}
/**
* @param array ...$arguments
*
* @throws RuntimeException
*
* @return InvocationMocker
*/
public function with(...$arguments)
{
$this->canDefineParameters();
$this->matcher->setParametersMatcher(new Matcher\Parameters($arguments));
return $this;
}
/**
* @param array ...$arguments
*
* @throws RuntimeException
*
* @return InvocationMocker
*/
public function withConsecutive(...$arguments)
{
$this->canDefineParameters();
$this->matcher->setParametersMatcher(new Matcher\ConsecutiveParameters($arguments));
return $this;
}
/**
* @throws RuntimeException
*
* @return InvocationMocker
*/
public function withAnyParameters()
{
$this->canDefineParameters();
$this->matcher->setParametersMatcher(new Matcher\AnyParameters);
return $this;
}
/**
* @param Constraint|string $constraint
*
* @throws RuntimeException
*
* @return InvocationMocker
*/
public function method($constraint)
{
if ($this->matcher->hasMethodNameMatcher()) {
throw new RuntimeException(
'Method name matcher is already defined, cannot redefine'
);
}
if (\is_string($constraint) && !\in_array(\strtolower($constraint), $this->configurableMethods, true)) {
throw new RuntimeException(
\sprintf(
'Trying to configure method "%s" which cannot be configured because it does not exist, has not been specified, is final, or is static',
$constraint
)
);
}
$this->matcher->setMethodNameMatcher(new Matcher\MethodName($constraint));
return $this;
}
/**
* Validate that a parameters matcher can be defined, throw exceptions otherwise.
*
* @throws RuntimeException
*/
private function canDefineParameters(): void
{
if (!$this->matcher->hasMethodNameMatcher()) {
throw new RuntimeException(
'Method name matcher is not defined, cannot define parameter ' .
'matcher without one'
);
}
if ($this->matcher->hasParametersMatcher()) {
throw new RuntimeException(
'Parameter matcher is already defined, cannot redefine'
);
}
}
}

View File

@@ -0,0 +1,26 @@
<?php
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework\MockObject\Builder;
/**
* Builder interface for invocation order matches.
*/
interface Match extends Stub
{
/**
* Defines the expectation which must occur before the current is valid.
*
* @param string $id the identification of the expectation that should
* occur before this one
*
* @return Stub
*/
public function after($id);
}

View File

@@ -0,0 +1,26 @@
<?php
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework\MockObject\Builder;
/**
* Builder interface for matcher of method names.
*/
interface MethodNameMatch extends ParametersMatch
{
/**
* Adds a new method name match and returns the parameter match object for
* further matching possibilities.
*
* @param \PHPUnit\Framework\Constraint\Constraint $name Constraint for matching method, if a string is passed it will use the PHPUnit_Framework_Constraint_IsEqual
*
* @return ParametersMatch
*/
public function method($name);
}

View File

@@ -0,0 +1,37 @@
<?php
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework\MockObject\Builder;
/**
* Interface for builders which can register builders with a given identification.
*
* This interface relates to Identity.
*/
interface NamespaceMatch
{
/**
* Looks up the match builder with identification $id and returns it.
*
* @param string $id The identification of the match builder
*
* @return Match
*/
public function lookupId($id);
/**
* Registers the match builder $builder with the identification $id. The
* builder can later be looked up using lookupId() to figure out if it
* has been invoked.
*
* @param string $id The identification of the match builder
* @param Match $builder The builder which is being registered
*/
public function registerId($id, Match $builder);
}

View File

@@ -0,0 +1,50 @@
<?php
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework\MockObject\Builder;
use PHPUnit\Framework\MockObject\Matcher\AnyParameters;
/**
* Builder interface for parameter matchers.
*/
interface ParametersMatch extends Match
{
/**
* Sets the parameters to match for, each parameter to this function will
* be part of match. To perform specific matches or constraints create a
* new PHPUnit\Framework\Constraint\Constraint and use it for the parameter.
* If the parameter value is not a constraint it will use the
* PHPUnit\Framework\Constraint\IsEqual for the value.
*
* Some examples:
* <code>
* // match first parameter with value 2
* $b->with(2);
* // match first parameter with value 'smock' and second identical to 42
* $b->with('smock', new PHPUnit\Framework\Constraint\IsEqual(42));
* </code>
*
* @return ParametersMatch
*/
public function with(...$arguments);
/**
* Sets a matcher which allows any kind of parameters.
*
* Some examples:
* <code>
* // match any number of parameters
* $b->withAnyParameters();
* </code>
*
* @return AnyParameters
*/
public function withAnyParameters();
}

View File

@@ -0,0 +1,26 @@
<?php
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework\MockObject\Builder;
use PHPUnit\Framework\MockObject\Stub as BaseStub;
/**
* Builder interface for stubs which are actions replacing an invocation.
*/
interface Stub extends Identity
{
/**
* Stubs the matching method with the stub object $stub. Any invocations of
* the matched method will now be handled by the stub instead.
*
* @return Identity
*/
public function will(BaseStub $stub);
}

View File

@@ -0,0 +1,14 @@
<?php
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework\MockObject;
class BadMethodCallException extends \BadMethodCallException implements Exception
{
}

View File

@@ -0,0 +1,17 @@
<?php
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework\MockObject;
/**
* Interface for exceptions used by PHPUnit_MockObject.
*/
interface Exception
{
}

View File

@@ -0,0 +1,14 @@
<?php
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework\MockObject;
class RuntimeException extends \RuntimeException implements Exception
{
}

View File

@@ -0,0 +1,16 @@
<?php
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework\MockObject;
use PHPUnit_Framework_MockObject_MockObject;
interface MockObject extends PHPUnit_Framework_MockObject_MockObject
{
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
@trigger_error({deprecation}, E_USER_DEPRECATED);

View File

@@ -0,0 +1,46 @@
{prologue}{class_declaration}
{
private $__phpunit_invocationMocker;
private $__phpunit_originalObject;
private $__phpunit_configurable = {configurable};
private $__phpunit_returnValueGeneration = true;
{clone}{mocked_methods}
public function expects(\PHPUnit\Framework\MockObject\Matcher\Invocation $matcher)
{
return $this->__phpunit_getInvocationMocker()->expects($matcher);
}
{method}
public function __phpunit_setOriginalObject($originalObject)
{
$this->__phpunit_originalObject = $originalObject;
}
public function __phpunit_setReturnValueGeneration(bool $returnValueGeneration)
{
$this->__phpunit_returnValueGeneration = $returnValueGeneration;
}
public function __phpunit_getInvocationMocker()
{
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new \PHPUnit\Framework\MockObject\InvocationMocker($this->__phpunit_configurable, $this->__phpunit_returnValueGeneration);
}
return $this->__phpunit_invocationMocker;
}
public function __phpunit_hasMatchers()
{
return $this->__phpunit_getInvocationMocker()->hasMatchers();
}
public function __phpunit_verify($unsetInvocationMocker = true)
{
$this->__phpunit_getInvocationMocker()->verify();
if ($unsetInvocationMocker) {
$this->__phpunit_invocationMocker = null;
}
}
}{epilogue}

View File

@@ -0,0 +1,8 @@
public function method()
{
$any = new \PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
$expects = $this->expects($any);
return call_user_func_array([$expects, 'method'], func_get_args());
}

View File

@@ -0,0 +1,4 @@
public function __clone()
{
$this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
}

View File

@@ -0,0 +1,22 @@
{modifier} function {reference}{method_name}({arguments_decl}){return_delim}{return_type}
{{deprecation}
$__phpunit_arguments = [{arguments_call}];
$__phpunit_count = func_num_args();
if ($__phpunit_count > {arguments_count}) {
$__phpunit_arguments_tmp = func_get_args();
for ($__phpunit_i = {arguments_count}; $__phpunit_i < $__phpunit_count; $__phpunit_i++) {
$__phpunit_arguments[] = $__phpunit_arguments_tmp[$__phpunit_i];
}
}
$__phpunit_result = $this->__phpunit_getInvocationMocker()->invoke(
new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
'{class_name}', '{method_name}', $__phpunit_arguments, '{return_type}', $this, {clone_arguments}
)
);
return $__phpunit_result;
}

Some files were not shown because too many files have changed in this diff Show More