laravel-6 support

This commit is contained in:
RafficMohammed
2023-01-08 01:17:22 +05:30
parent 1a5c16ae4b
commit 774eed8b0e
4962 changed files with 279380 additions and 297961 deletions

View File

@@ -1,14 +0,0 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
charset = utf-8
[*.yml]
indent_size = 2
[tests/_files/*_result_cache.txt]
insert_final_newline = false

View File

@@ -1,7 +0,0 @@
/.docker export-ignore
/build export-ignore
/tools export-ignore
/tools/* binary
*.php diff=php

View File

@@ -1,28 +0,0 @@
# Contributor Code of Conduct
As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* Public or private harassment
* Publishing other's private information, such as physical or electronic
addresses, without explicit permission
* Other unethical or unprofessional conduct
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
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 [https://contributor-covenant.org/version/1/3/0/][version]
[homepage]: https://contributor-covenant.org
[version]: https://contributor-covenant.org/version/1/3/0/

View File

@@ -1,68 +0,0 @@
# Contributing to PHPUnit
## Contributor Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
## Workflow
* Fork the project.
* Make your bug fix or feature addition.
* 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](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 made for the oldest branch that is [supported](https://phpunit.de/supported-versions.html). Pull requests for new features must be based on the `master` branch.
We are trying to keep backwards compatibility breaks in PHPUnit to an absolute minimum. Please take this into account when proposing changes.
Due to time constraints, we are not always able to respond as quickly as we would like. Please do not take delays personal and feel free to remind us if you feel that we forgot to respond.
## 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
$ ./tools/php-cs-fixer fix
```
## Using PHPUnit from a Git checkout
The following commands can be used to perform the initial checkout of PHPUnit:
```bash
$ git clone git://github.com/sebastianbergmann/phpunit.git
$ cd phpunit
```
Retrieve PHPUnit's dependencies using [Composer](https://getcomposer.org/):
```bash
$ ./tools/composer install
```
The `phpunit` script can be used to invoke the PHPUnit test runner:
```bash
$ ./phpunit --version
```
## Running PHPUnit's own test suite
After following the steps shown above, PHPUnit's own test suite is run like this:
```bash
$ ./phpunit
```
## Reporting issues
Please use the most specific issue tracker to search for existing tickets and to open new tickets:
* [General problems](https://github.com/sebastianbergmann/phpunit/issues)
* [Code Coverage](https://github.com/sebastianbergmann/php-code-coverage/issues)
* [Documentation](https://github.com/sebastianbergmann/phpunit-documentation-english/issues)
* [Website](https://github.com/sebastianbergmann/phpunit-website/issues)

View File

@@ -1,15 +0,0 @@
| Q | A
| --------------------| ---------------
| PHPUnit version | x.y.z
| PHP version | x.y.z
| Installation Method | Composer / PHAR
<!--
- Please fill in this template according to your issue.
- Please keep the table shown above at the top of your issue.
- Please include the output of "composer info | sort" if you installed PHPUnit using Composer.
- Please post code as text (using proper markup). Do not post screenshots of code.
- Visit https://phpunit.de/support.html if you are looking for support.
- Otherwise, replace this comment by the description of your issue.
-->

View File

@@ -1,84 +0,0 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
on:
- pull_request
- push
name: CI
jobs:
coding-guidelines:
name: Coding Guidelines
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run friendsofphp/php-cs-fixer
run: php7.3 ./tools/php-cs-fixer fix --diff-format=udiff --dry-run --show-progress=dots --using-cache=no --verbose
lint-xml-configuration:
name: Lint XML Configuration
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build Docker image
uses: ./.docker/lint-xml-configuration
- name: Lint XML configuration files
uses: ./.docker/lint-xml-configuration
with:
args: bash ./build/lint-xml-configuration
tests:
name: Tests
runs-on: ubuntu-latest
strategy:
matrix:
php-binary:
- php7.1
- php7.2
- php7.3
dependencies:
- lowest
- highest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: "Cache dependencies installed with composer"
uses: actions/cache@v1
with:
path: ~/.composer/cache
key: ${{ matrix.php-binary }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ matrix.php-binary }}-composer-${{ matrix.dependencies }}-
- name: Install lowest dependencies with composer
if: matrix.dependencies == 'lowest'
run: ${{ matrix.php-binary }} ./tools/composer update --no-ansi --no-interaction --no-progress --no-suggest --prefer-lowest
- name: Install highest dependencies with composer
if: matrix.dependencies == 'highest'
run: ${{ matrix.php-binary }} ./tools/composer update --no-ansi --no-interaction --no-progress --no-suggest
- name: Run sanity check
run: PHP_BINARY=${{ matrix.php-binary }} bash ./build/sanity-check
- name: Run tests with phpunit
run: ${{ matrix.php-binary }} -d assert.exception=1 -d zend.assertions=1 ./phpunit --coverage-clover=coverage.xml
- name: Send code coverage report to Codecov.io
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: bash <(curl -s https://codecov.io/bash) || true

View File

@@ -1,21 +0,0 @@
/.ant_targets
/.idea
/.php_cs
/.php_cs.cache
/build/documentation
/build/logfiles
/build/phar
/build/phpdox
/build/*.phar
/build/*.phar.asc
/build/binary-phar-autoload.php
/cache.properties
/composer.lock
/tests/end-to-end/*.diff
/tests/end-to-end/*.exp
/tests/end-to-end/*.log
/tests/end-to-end/*.out
/tests/end-to-end/*.php
/vendor
.phpunit.result.cache
.psalm

View File

@@ -1,201 +0,0 @@
<?php
$header = <<<'EOF'
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.
EOF;
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules(
[
'align_multiline_comment' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'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,
'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_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,
'ordered_interfaces' => [
'direction' => 'ascend',
'order' => 'alpha',
],
'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' => ['groups' => ['simple', 'meta']],
'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' => false,
'single_blank_line_at_eof' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_quote' => true,
'standardize_not_equals' => true,
'ternary_to_null_coalescing' => true,
'trailing_comma_in_multiline_array' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => [
'elements' => [
'const',
'method',
'property',
],
],
//'void_return' => true,
'whitespace_after_comma_in_array' => true,
]
)
->setFinder(
PhpCsFixer\Finder::create()
->files()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
->notName('*.phpt')
);

View File

@@ -0,0 +1,33 @@
<?php
namespace PHPSTORM_META {
override(
\PHPUnit\Framework\TestCase::createMock(0),
map([""=>"$0"])
);
override(
\PHPUnit\Framework\TestCase::createStub(0),
map([""=>"$0"])
);
override(
\PHPUnit\Framework\TestCase::createConfiguredMock(0),
map([""=>"$0"])
);
override(
\PHPUnit\Framework\TestCase::createPartialMock(0),
map([""=>"$0"])
);
override(
\PHPUnit\Framework\TestCase::createTestProxy(0),
map([""=>"$0"])
);
override(
\PHPUnit\Framework\TestCase::getMockForAbstractClass(0),
map([""=>"$0"])
);
}

View File

@@ -1,38 +0,0 @@
language: php
jobs:
include:
- &COLLECT_CODE_COVERAGE
stage: Collect Code Coverage
php: 7.1
if: type = pull_request
before_install:
- ./tools/composer clear-cache
install:
- travis_retry ./tools/composer update --no-ansi --no-interaction --no-progress --no-suggest
before_script:
- echo 'zend.assertions=1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- echo 'assert.exception=On' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
script:
- ./phpunit --coverage-clover=coverage.xml
after_success:
- bash <(curl -s https://codecov.io/bash)
- <<: *COLLECT_CODE_COVERAGE
php: 7.2
- <<: *COLLECT_CODE_COVERAGE
php: 7.3
notifications:
email: false

View File

@@ -1,195 +0,0 @@
# Changes in PHPUnit 7.5
All notable changes of the PHPUnit 7.5 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
## [7.5.20] - 2020-01-08
### Removed
* `eval-stdin.php` has been removed, it was not used anymore since PHPUnit 7.2.7
## [7.5.19] - 2020-01-06
### Changed
* `eval-stdin.php` can now only be executed with `cli` and `phpdbg`
## [7.5.18] - 2019-12-06
### Fixed
* Fixed [#3967](https://github.com/sebastianbergmann/phpunit/issues/3967): Cannot double interface that extends interface that extends `\Throwable`
* Fixed [#3968](https://github.com/sebastianbergmann/phpunit/pull/3968): Test class run in a separate PHP process are passing when `exit` called inside
## [7.5.17] - 2019-10-28
### Fixed
* Fixed [#3727](https://github.com/sebastianbergmann/phpunit/issues/3727): Problem hidden by PHPUnit's error handler
* Fixed [#3863](https://github.com/sebastianbergmann/phpunit/pull/3863): `\Countable` needs to be checked before `\EmptyIterator`
## [7.5.16] - 2019-09-14
### Fixed
* Fixed [#3801](https://github.com/sebastianbergmann/phpunit/issues/3801): Class constant as default parameter is undefined
* Fixed [#3834](https://github.com/sebastianbergmann/phpunit/issues/3834): Trailing slash breaks code coverage on Windows
## [7.5.15] - 2019-08-21
### Changed
* Implemented [#3765](https://github.com/sebastianbergmann/phpunit/pull/3765): Use `ReflectionType::getName()` instead of `ReflectionType::__toString()` (which is deprecated in PHP 7.4)
## [7.5.14] - 2019-07-15
### Fixed
* Fixed [#3743](https://github.com/sebastianbergmann/phpunit/issues/3743): `EmptyIterator` instances are not handled correctly by `Count` and `IsEmpty` constraints
## [7.5.13] - 2019-06-19
### Fixed
* Fixed [#3722](https://github.com/sebastianbergmann/phpunit/issues/3722): `getObjectForTrait()` does not work for traits that declare a constructor
* Fixed [#3723](https://github.com/sebastianbergmann/phpunit/pull/3723): Unescaped dash in character group in regular expression
## [7.5.12] - 2019-05-28
### Changed
* After each test, `libxml_clear_errors()` is now called to clear the libxml error buffer
### Fixed
* Fixed [#3694](https://github.com/sebastianbergmann/phpunit/pull/3694): Constructor arguments for `Throwable` and `Exception` are ignored
* Fixed [#3709](https://github.com/sebastianbergmann/phpunit/pull/3709): Method-level `@coversNothing` annotation does not prevent code coverage data collection
## [7.5.11] - 2019-05-14
### Fixed
* Fixed [#3683](https://github.com/sebastianbergmann/phpunit/issues/3683): Regression in PHPUnit 7.5.10 with regard to Exception stubbing/mocking
## [7.5.10] - 2019-05-09
### Fixed
* Fixed [#3414](https://github.com/sebastianbergmann/phpunit/pull/3414): `willThrowException()` only accepts `Exception`, not `Throwable`
* Fixed [#3587](https://github.com/sebastianbergmann/phpunit/issues/3587): `.phpunit.result.cache` file is all over the place
* Fixed [#3596](https://github.com/sebastianbergmann/phpunit/issues/3596): Mocking an interface that extends another interface forgets to mock its own methods
* Fixed [#3674](https://github.com/sebastianbergmann/phpunit/issues/3674): `TypeError` when an incorrect file path is given
## [7.5.9] - 2019-04-19
### Fixed
* Fixed [#3607](https://github.com/sebastianbergmann/phpunit/issues/3607): Return value generation interferes with proxying to original method
## [7.5.8] - 2019-03-26
### Fixed
* Fixed [#3564](https://github.com/sebastianbergmann/phpunit/issues/3564): Production code uses class from test suite's fixture
## [7.5.7] - 2019-03-16
### Fixed
* Fixed [#3480](https://github.com/sebastianbergmann/phpunit/issues/3480): Wrong return type declaration for `TestCase::getExpectedExceptionMessage()` and `TestCase::getExpectedExceptionMessageRegExp()`
* Fixed [#3550](https://github.com/sebastianbergmann/phpunit/issues/3550): Check for valid attribute names in `assertObjectHasAttribute()` is too strict
## [7.5.6] - 2019-02-18
### Fixed
* Fixed [#3530](https://github.com/sebastianbergmann/phpunit/issues/3530): `generateClassFromWsdl()` does not handle methods with multiple output values
* Fixed [#3531](https://github.com/sebastianbergmann/phpunit/issues/3531): Test suite fails on warning
* Fixed [#3534](https://github.com/sebastianbergmann/phpunit/pull/3534): Wrong message in `ConstraintTestCase`
## [7.5.5] - 2019-02-15
### Fixed
* Fixed [#3011](https://github.com/sebastianbergmann/phpunit/issues/3011): Unsupported PHPT `--SECTION--` throws unhandled exception
* Fixed [#3461](https://github.com/sebastianbergmann/phpunit/issues/3461): `StringEndsWith` matches too loosely
* Fixed [#3515](https://github.com/sebastianbergmann/phpunit/issues/3515): Random order seed is only printed in verbose mode
* Fixed [#3517](https://github.com/sebastianbergmann/phpunit/issues/3517): Useless error message when depending on test that does not exist
## [7.5.4] - 2019-02-07
### Fixed
* Fixed [#3352](https://github.com/sebastianbergmann/phpunit/issues/3352): Using `phpunit.phar` with PHPDBG does not work with `auto_globals_jit=On`
* Fixed [#3502](https://github.com/sebastianbergmann/phpunit/issues/3502): Numeric `@ticket` or `@group` annotations no longer work
## [7.5.3] - 2019-02-01
### Fixed
* Fixed [#3490](https://github.com/sebastianbergmann/phpunit/pull/3490): Exceptions in `tearDownAfterClass()` kill PHPUnit
### Deprecated
* The method `assertArraySubset()` is now deprecated. There is no behavioral change in this version of PHPUnit. Using this method will trigger a deprecation warning in PHPUnit 8 and in PHPUnit 9 this method will be removed.
## [7.5.2] - 2019-01-15
### Fixed
* Fixed [#3456](https://github.com/sebastianbergmann/phpunit/pull/3456): Generator for Xdebug filter script does not handle directories with leading `.` correctly
* Fixed [#3459](https://github.com/sebastianbergmann/phpunit/issues/3459): `@requires` function swallows digits at the end of function name
## [7.5.1] - 2018-12-12
### Fixed
* Fixed [#3441](https://github.com/sebastianbergmann/phpunit/issues/3441): Call to undefined method `DataProviderTestSuite::usesDataProvider()`
## [7.5.0] - 2018-12-07
### Added
* Implemented [#3340](https://github.com/sebastianbergmann/phpunit/issues/3340): Added `assertEqualsCanonicalizing()`, `assertEqualsIgnoringCase()`, `assertEqualsWithDelta()`, `assertNotEqualsCanonicalizing()`, `assertNotEqualsIgnoringCase()`, and `assertNotEqualsWithDelta()` as alternatives to using `assertEquals()` and `assertNotEquals()` with the `$delta`, `$canonicalize`, or `$ignoreCase` parameters
* Implemented [#3368](https://github.com/sebastianbergmann/phpunit/issues/3368): Added `assertIsArray()`, `assertIsBool()`, `assertIsFloat()`, `assertIsInt()`, `assertIsNumeric()`, `assertIsObject()`, `assertIsResource()`, `assertIsString()`, `assertIsScalar()`, `assertIsCallable()`, `assertIsIterable()`, `assertIsNotArray()`, `assertIsNotBool()`, `assertIsNotFloat()`, `assertIsNotInt()`, `assertIsNotNumeric()`, `assertIsNotObject()`, `assertIsNotResource()`, `assertIsNotString()`, `assertIsNotScalar()`, `assertIsNotCallable()`, `assertIsNotIterable()` as alternatives to `assertInternalType()` and `assertNotInternalType()`
* Implemented [#3391](https://github.com/sebastianbergmann/phpunit/issues/3391): Added a `TestHook` that fires after each test, regardless of result
* Implemented [#3417](https://github.com/sebastianbergmann/phpunit/pull/3417): Refinements related to test suite sorting and TestDox result printer
* Implemented [#3422](https://github.com/sebastianbergmann/phpunit/issues/3422): Added `assertStringContainsString()`, `assertStringContainsStringIgnoringCase()`, `assertStringNotContainsString()`, and `assertStringNotContainsStringIgnoringCase()`
### Deprecated
* The methods `assertInternalType()` and `assertNotInternalType()` are now deprecated. There is no behavioral change in this version of PHPUnit. Using these methods will trigger a deprecation warning in PHPUnit 8 and in PHPUnit 9 these methods will be removed.
* The methods `assertAttributeContains()`, `assertAttributeNotContains()`, `assertAttributeContainsOnly()`, `assertAttributeNotContainsOnly()`, `assertAttributeCount()`, `assertAttributeNotCount()`, `assertAttributeEquals()`, `assertAttributeNotEquals()`, `assertAttributeEmpty()`, `assertAttributeNotEmpty()`, `assertAttributeGreaterThan()`, `assertAttributeGreaterThanOrEqual()`, `assertAttributeLessThan()`, `assertAttributeLessThanOrEqual()`, `assertAttributeSame()`, `assertAttributeNotSame()`, `assertAttributeInstanceOf()`, `assertAttributeNotInstanceOf()`, `assertAttributeInternalType()`, `assertAttributeNotInternalType()`, `attributeEqualTo()`, `readAttribute()`, `getStaticAttribute()`, and `getObjectAttribute()` are now deprecated. There is no behavioral change in this version of PHPUnit. Using these methods will trigger a deprecation warning in PHPUnit 8 and in PHPUnit 9 these methods will be removed.
* The optional parameters `$delta`, `$maxDepth`, `$canonicalize`, and `$ignoreCase` of `assertEquals()` and `assertNotEquals()` are now deprecated. There is no behavioral change in this version of PHPUnit. Using these parameters will trigger a deprecation warning in PHPUnit 8 and in PHPUnit 9 these parameters will be removed.
* The annotations `@expectedException`, `@expectedExceptionCode`, `@expectedExceptionMessage`, and `@expectedExceptionMessageRegExp` are now deprecated. There is no behavioral change in this version of PHPUnit. Using these annotations will trigger a deprecation warning in PHPUnit 8 and in PHPUnit 9 these annotations will be removed.
* Using the methods `assertContains()` and `assertNotContains()` on `string` haystacks is now deprecated. There is no behavioral change in this version of PHPUnit. Using these methods on `string` haystacks will trigger a deprecation warning in PHPUnit 8 and in PHPUnit 9 these methods cannot be used on on `string` haystacks anymore.
* The optional parameters `$ignoreCase`, `$checkForObjectIdentity`, and `$checkForNonObjectIdentity` of `assertContains()` and `assertNotContains()` are now deprecated. There is no behavioral change in this version of PHPUnit. Using these parameters will trigger a deprecation warning in PHPUnit 8 and in PHPUnit 9 these parameters will be removed.
### Fixed
* Fixed [#3428](https://github.com/sebastianbergmann/phpunit/pull/3428): `TestSuite` setup failures are not logged correctly
* Fixed [#3429](https://github.com/sebastianbergmann/phpunit/pull/3429): Inefficient loop in `getHookMethods()`
* Fixed [#3437](https://github.com/sebastianbergmann/phpunit/pull/3437): JUnit logger skips PHPT tests
[7.5.20]: https://github.com/sebastianbergmann/phpunit/compare/7.5.19...7.5.20
[7.5.19]: https://github.com/sebastianbergmann/phpunit/compare/7.5.18...7.5.19
[7.5.18]: https://github.com/sebastianbergmann/phpunit/compare/7.5.17...7.5.18
[7.5.17]: https://github.com/sebastianbergmann/phpunit/compare/7.5.16...7.5.17
[7.5.16]: https://github.com/sebastianbergmann/phpunit/compare/7.5.15...7.5.16
[7.5.15]: https://github.com/sebastianbergmann/phpunit/compare/7.5.14...7.5.15
[7.5.14]: https://github.com/sebastianbergmann/phpunit/compare/7.5.13...7.5.14
[7.5.13]: https://github.com/sebastianbergmann/phpunit/compare/7.5.12...7.5.13
[7.5.12]: https://github.com/sebastianbergmann/phpunit/compare/7.5.11...7.5.12
[7.5.11]: https://github.com/sebastianbergmann/phpunit/compare/7.5.10...7.5.11
[7.5.10]: https://github.com/sebastianbergmann/phpunit/compare/7.5.9...7.5.10
[7.5.9]: https://github.com/sebastianbergmann/phpunit/compare/7.5.8...7.5.9
[7.5.8]: https://github.com/sebastianbergmann/phpunit/compare/7.5.7...7.5.8
[7.5.7]: https://github.com/sebastianbergmann/phpunit/compare/7.5.6...7.5.7
[7.5.6]: https://github.com/sebastianbergmann/phpunit/compare/7.5.5...7.5.6
[7.5.5]: https://github.com/sebastianbergmann/phpunit/compare/7.5.4...7.5.5
[7.5.4]: https://github.com/sebastianbergmann/phpunit/compare/7.5.3...7.5.4
[7.5.3]: https://github.com/sebastianbergmann/phpunit/compare/7.5.2...7.5.3
[7.5.2]: https://github.com/sebastianbergmann/phpunit/compare/7.5.1...7.5.2
[7.5.1]: https://github.com/sebastianbergmann/phpunit/compare/7.5.0...7.5.1
[7.5.0]: https://github.com/sebastianbergmann/phpunit/compare/7.4.5...7.5.0

290
vendor/phpunit/phpunit/ChangeLog-8.5.md vendored Normal file
View File

@@ -0,0 +1,290 @@
# Changes in PHPUnit 8.5
All notable changes of the PHPUnit 8.5 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
## [8.5.31] - 2022-10-28
### Fixed
* [#5076](https://github.com/sebastianbergmann/phpunit/issues/5076): Test Runner does not warn about conflicting options
## [8.5.30] - 2022-09-25
### Changed
* The configuration generator now asks for a cache directory
### Fixed
* [#4913](https://github.com/sebastianbergmann/phpunit/issues/4913): Failed `assert()` should show a backtrace
* [#4966](https://github.com/sebastianbergmann/phpunit/issues/4966): `TestCase::assertSame()` (and related exact comparisons) must compare `float` exactly
## [8.5.29] - 2022-08-22
### Changed
* [#5033](https://github.com/sebastianbergmann/phpunit/issues/5033): Do not depend on phpspec/prophecy
## [8.5.28] - 2022-07-29
### Fixed
* [#5015](https://github.com/sebastianbergmann/phpunit/pull/5015): Ukraine banner unreadable on black background
* [#5016](https://github.com/sebastianbergmann/phpunit/issues/5016): PHPUnit 8.5.27 does not work on PHP 7.2.0-7.2.18 and PHP 7.3.0-7.3.5
## [8.5.27] - 2022-06-19
### Fixed
* [#4950](https://github.com/sebastianbergmann/phpunit/issues/4950): False error on `atMost()` invocation rule without call
* [#4962](https://github.com/sebastianbergmann/phpunit/issues/4962): Ukraine banner unreadable on white background
## [8.5.26] - 2022-04-01
### Fixed
* [#4938](https://github.com/sebastianbergmann/phpunit/issues/4938): Test Double code generator does not handle `void` return type declaration on `__clone()` methods
## [8.5.25] - 2022-03-16
### Fixed
* [#4934](https://github.com/sebastianbergmann/phpunit/issues/4934): Code Coverage does not work with PHPUnit 8.5.24 PHAR on PHP 7
## [8.5.24] - 2022-03-05 - #StandWithUkraine
### Changed
* [#4874](https://github.com/sebastianbergmann/phpunit/pull/4874): `PHP_FLOAT_EPSILON` is now used instead of hardcoded `0.0000000001` in `PHPUnit\Framework\Constraint\IsIdentical`
### Fixed
* When the HTML code coverage report's configured low upper bound is larger than the high lower bound then the default values are used instead
## [8.5.23] - 2022-01-21
### Fixed
* [#4799](https://github.com/sebastianbergmann/phpunit/pull/4799): Memory leaks in `PHPUnit\Framework\TestSuite` class
* [#4857](https://github.com/sebastianbergmann/phpunit/pull/4857): Result of `debug_backtrace()` is not used correctly
## [8.5.22] - 2021-12-25
### Changed
* [#4812](https://github.com/sebastianbergmann/phpunit/issues/4812): Do not enforce time limits when a debugging session through DBGp is active
* [#4835](https://github.com/sebastianbergmann/phpunit/issues/4835): Support for `$GLOBALS['_composer_autoload_path']` introduced in Composer 2.2
### Fixed
* [#4840](https://github.com/sebastianbergmann/phpunit/pull/4840): TestDox prettifying for class names does not correctly handle diacritics
* [#4846](https://github.com/sebastianbergmann/phpunit/pull/4846): Composer proxy script is not ignored
## [8.5.21] - 2021-09-25
### Changed
* PHPUnit no longer converts PHP deprecations to exceptions by default (configure `convertDeprecationsToExceptions="true"` to enable this)
* The PHPUnit XML configuration file generator now configures `convertDeprecationsToExceptions="true"`
### Fixed
* [#4772](https://github.com/sebastianbergmann/phpunit/pull/4772): TestDox HTML report not displayed correctly when browser has custom colour settings
## [8.5.20] - 2021-08-31
### Fixed
* [#4751](https://github.com/sebastianbergmann/phpunit/issues/4751): Configuration validation fails when using brackets in glob pattern
## [8.5.19] - 2021-07-31
### Fixed
* [#4740](https://github.com/sebastianbergmann/phpunit/issues/4740): `phpunit.phar` does not work with PHP 8.1
## [8.5.18] - 2021-07-19
### Fixed
* [#4720](https://github.com/sebastianbergmann/phpunit/issues/4720): PHPUnit does not verify its own PHP extension requirements
## [8.5.17] - 2021-06-23
### Changed
* PHPUnit now errors out on startup when `PHP_VERSION` contains a value that is not compatible with `version_compare()`, for instance `X.Y.Z-(to be removed in future macOS)`
## [8.5.16] - 2021-06-05
### Changed
* The test result cache (the storage for which is implemented in `PHPUnit\Runner\DefaultTestResultCache`) no longer uses PHP's `serialize()` and `unserialize()` functions for persistence. It now uses a versioned JSON format instead that is independent of PHP implementation details (see [#3581](https://github.com/sebastianbergmann/phpunit/issues/3581) and [#4662](https://github.com/sebastianbergmann/phpunit/pull/4662) for examples why this is a problem). When PHPUnit tries to load the test result cache from a file that does not exist, or from a file that does not contain data in JSON format, or from a file that contains data in a JSON format version other than the one used by the currently running PHPUnit version, then this is considered to be a "cache miss". An empty `DefaultTestResultCache` object is created in this case. This should also prevent PHPUnit from crashing when trying to load a test result cache file created by a different version of PHPUnit (see [#4580](https://github.com/sebastianbergmann/phpunit/issues/4580) for example).
### Fixed
* [#4663](https://github.com/sebastianbergmann/phpunit/issues/4663): `TestCase::expectError()` works on PHP 7.3, but not on PHP >= 7.4
* [#4678](https://github.com/sebastianbergmann/phpunit/pull/4678): Stubbed methods with `iterable` return types should return empty array by default
* [#4692](https://github.com/sebastianbergmann/phpunit/issues/4692): Annotations in single-line doc-comments are not handled correctly
* [#4694](https://github.com/sebastianbergmann/phpunit/issues/4694): `TestCase::getMockFromWsdl()` does not work with PHP 8.1-dev
## [8.5.15] - 2021-03-17
### Fixed
* [#4591](https://github.com/sebastianbergmann/phpunit/issues/4591): TeamCity logger logs warnings as test failures
## [8.5.14] - 2021-01-17
### Fixed
* [#4535](https://github.com/sebastianbergmann/phpunit/issues/4535): `getMockFromWsdl()` does not handle methods that do not have parameters correctly
* [#4572](https://github.com/sebastianbergmann/phpunit/issues/4572): Schema validation does not work with `%xx` sequences in path to `phpunit.xsd`
* [#4575](https://github.com/sebastianbergmann/phpunit/issues/4575): PHPUnit 8.5 incompatibility with PHP 8.1
## [8.5.13] - 2020-12-01
### Fixed
* Running tests in isolated processes did not work with PHP 8 on Windows
## [8.5.12] - 2020-11-30
### Changed
* Changed PHP version constraint in `composer.json` from `^7.2` to `>=7.2` to allow the installation of PHPUnit 8.5 on PHP 8. Please note that the code coverage functionality is not available for PHPUnit 8.5 on PHP 8.
### Fixed
* [#4529](https://github.com/sebastianbergmann/phpunit/issues/4529): Debug mode of Xdebug 2 is not disabled for PHPT tests
## [8.5.11] - 2020-11-27
### Changed
* Bumped required version of `phpunit/php-code-coverage`
## [8.5.10] - 2020-11-27
### Added
* Support for Xdebug 3
### Fixed
* [#4516](https://github.com/sebastianbergmann/phpunit/issues/4516): `phpunit/phpunit-selenium` does not work with PHPUnit 8.5.9
## [8.5.9] - 2020-11-10
### Fixed
* [#3965](https://github.com/sebastianbergmann/phpunit/issues/3965): Process Isolation throws exceptions when PHPDBG is used
* [#4470](https://github.com/sebastianbergmann/phpunit/pull/4470): Infinite recursion when `--static-backup --strict-global-state` is used
## [8.5.8] - 2020-06-22
### Fixed
* [#4312](https://github.com/sebastianbergmann/phpunit/issues/4312): Fix for [#4299](https://github.com/sebastianbergmann/phpunit/issues/4299) breaks backward compatibility
## [8.5.7] - 2020-06-21
### Fixed
* [#4299](https://github.com/sebastianbergmann/phpunit/issues/4299): "No tests executed" does not always result in exit code `1`
* [#4306](https://github.com/sebastianbergmann/phpunit/issues/4306): Exceptions during code coverage driver initialization are not handled correctly
## [8.5.6] - 2020-06-15
### Fixed
* [#4211](https://github.com/sebastianbergmann/phpunit/issues/4211): `phpdbg_*()` functions are scoped to `PHPUnit\phpdbg_*()`
## [8.5.5] - 2020-05-22
### Fixed
* [#4033](https://github.com/sebastianbergmann/phpunit/issues/4033): Unexpected behaviour when `$GLOBALS` is deleted
## [8.5.4] - 2020-04-23
### Changed
* Changed how `PHPUnit\TextUI\Command` passes warnings to `PHPUnit\TextUI\TestRunner`
## [8.5.3] - 2020-03-31
### Fixed
* [#4017](https://github.com/sebastianbergmann/phpunit/issues/4017): Do not suggest refactoring to something that is also deprecated
* [#4133](https://github.com/sebastianbergmann/phpunit/issues/4133): `expectExceptionMessageRegExp()` has been removed in PHPUnit 9 without a deprecation warning being given in PHPUnit 8
* [#4139](https://github.com/sebastianbergmann/phpunit/issues/4139): Cannot double interfaces that declare a constructor with PHP 8
* [#4144](https://github.com/sebastianbergmann/phpunit/issues/4144): Empty objects are converted to empty arrays in JSON comparison failure diff
## [8.5.2] - 2020-01-08
### Removed
* `eval-stdin.php` has been removed, it was not used anymore since PHPUnit 7.2.7
## [8.5.1] - 2019-12-25
### Changed
* `eval-stdin.php` can now only be executed with `cli` and `phpdbg`
### Fixed
* [#3983](https://github.com/sebastianbergmann/phpunit/issues/3983): Deprecation warning given too eagerly
## [8.5.0] - 2019-12-06
### Added
* [#3911](https://github.com/sebastianbergmann/phpunit/issues/3911): Support combined use of `addMethods()` and `onlyMethods()`
* [#3949](https://github.com/sebastianbergmann/phpunit/issues/3949): Introduce specialized assertions `assertFileEqualsCanonicalizing()`, `assertFileEqualsIgnoringCase()`, `assertStringEqualsFileCanonicalizing()`, `assertStringEqualsFileIgnoringCase()`, `assertFileNotEqualsCanonicalizing()`, `assertFileNotEqualsIgnoringCase()`, `assertStringNotEqualsFileCanonicalizing()`, and `assertStringNotEqualsFileIgnoringCase()` as alternative to using `assertFileEquals()` etc. with optional parameters
### Changed
* [#3860](https://github.com/sebastianbergmann/phpunit/pull/3860): Deprecate invoking PHPUnit commandline test runner with just a class name
* [#3950](https://github.com/sebastianbergmann/phpunit/issues/3950): Deprecate optional parameters of `assertFileEquals()` etc.
* [#3955](https://github.com/sebastianbergmann/phpunit/issues/3955): Deprecate support for doubling multiple interfaces
### Fixed
* [#3953](https://github.com/sebastianbergmann/phpunit/issues/3953): Code Coverage for test executed in isolation does not work when the PHAR is used
* [#3967](https://github.com/sebastianbergmann/phpunit/issues/3967): Cannot double interface that extends interface that extends `\Throwable`
* [#3968](https://github.com/sebastianbergmann/phpunit/pull/3968): Test class run in a separate PHP process are passing when `exit` called inside
[8.5.31]: https://github.com/sebastianbergmann/phpunit/compare/8.5.30...8.5.31
[8.5.30]: https://github.com/sebastianbergmann/phpunit/compare/8.5.29...8.5.30
[8.5.29]: https://github.com/sebastianbergmann/phpunit/compare/8.5.28...8.5.29
[8.5.28]: https://github.com/sebastianbergmann/phpunit/compare/8.5.27...8.5.28
[8.5.27]: https://github.com/sebastianbergmann/phpunit/compare/8.5.26...8.5.27
[8.5.26]: https://github.com/sebastianbergmann/phpunit/compare/8.5.25...8.5.26
[8.5.25]: https://github.com/sebastianbergmann/phpunit/compare/8.5.24...8.5.25
[8.5.24]: https://github.com/sebastianbergmann/phpunit/compare/8.5.23...8.5.24
[8.5.23]: https://github.com/sebastianbergmann/phpunit/compare/8.5.22...8.5.23
[8.5.22]: https://github.com/sebastianbergmann/phpunit/compare/8.5.21...8.5.22
[8.5.21]: https://github.com/sebastianbergmann/phpunit/compare/8.5.20...8.5.21
[8.5.20]: https://github.com/sebastianbergmann/phpunit/compare/8.5.19...8.5.20
[8.5.19]: https://github.com/sebastianbergmann/phpunit/compare/8.5.18...8.5.19
[8.5.18]: https://github.com/sebastianbergmann/phpunit/compare/8.5.17...8.5.18
[8.5.17]: https://github.com/sebastianbergmann/phpunit/compare/8.5.16...8.5.17
[8.5.16]: https://github.com/sebastianbergmann/phpunit/compare/8.5.15...8.5.16
[8.5.15]: https://github.com/sebastianbergmann/phpunit/compare/8.5.14...8.5.15
[8.5.14]: https://github.com/sebastianbergmann/phpunit/compare/8.5.13...8.5.14
[8.5.13]: https://github.com/sebastianbergmann/phpunit/compare/8.5.12...8.5.13
[8.5.12]: https://github.com/sebastianbergmann/phpunit/compare/8.5.11...8.5.12
[8.5.11]: https://github.com/sebastianbergmann/phpunit/compare/8.5.10...8.5.11
[8.5.10]: https://github.com/sebastianbergmann/phpunit/compare/8.5.9...8.5.10
[8.5.9]: https://github.com/sebastianbergmann/phpunit/compare/8.5.8...8.5.9
[8.5.8]: https://github.com/sebastianbergmann/phpunit/compare/8.5.7...8.5.8
[8.5.7]: https://github.com/sebastianbergmann/phpunit/compare/8.5.6...8.5.7
[8.5.6]: https://github.com/sebastianbergmann/phpunit/compare/8.5.5...8.5.6
[8.5.5]: https://github.com/sebastianbergmann/phpunit/compare/8.5.4...8.5.5
[8.5.4]: https://github.com/sebastianbergmann/phpunit/compare/8.5.3...8.5.4
[8.5.3]: https://github.com/sebastianbergmann/phpunit/compare/8.5.2...8.5.3
[8.5.2]: https://github.com/sebastianbergmann/phpunit/compare/8.5.1...8.5.2
[8.5.1]: https://github.com/sebastianbergmann/phpunit/compare/8.5.0...8.5.1
[8.5.0]: https://github.com/sebastianbergmann/phpunit/compare/8.4.3...8.5.0

View File

@@ -1,33 +1,29 @@
PHPUnit
BSD 3-Clause License
Copyright (c) 2001-2019, Sebastian Bergmann <sebastian@phpunit.de>.
Copyright (c) 2001-2022, Sebastian Bergmann
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Sebastian Bergmann nor the names of his
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -1,21 +1,26 @@
<h1 align="center">🇺🇦 <a href="https://phpunit.de/stand-with-ukraine.html">UKRAINE NEEDS YOUR HELP NOW!</a></h1>
# PHPUnit
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.1-8892BF.svg?style=flat-square)](https://php.net/)
[![CI Status](https://github.com/sebastianbergmann/phpunit/workflows/CI/badge.svg)](https://github.com/sebastianbergmann/phpunit/actions)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.2-8892BF.svg?style=flat-square)](https://php.net/)
[![CI Status](https://github.com/sebastianbergmann/phpunit/workflows/CI/badge.svg?branch=8.5&event=push)](https://phpunit.de/build-status.html)
[![Type Coverage](https://shepherd.dev/github/sebastianbergmann/phpunit/coverage.svg)](https://shepherd.dev/github/sebastianbergmann/phpunit)
## Installation
We distribute a [PHP Archive (PHAR)](https://php.net/phar) that has all required (as well as some optional) dependencies of PHPUnit 7.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 bundled in a single file:
```bash
$ wget https://phar.phpunit.de/phpunit-7.5.phar
$ wget https://phar.phpunit.de/phpunit-X.Y.phar
$ php phpunit-7.5.phar --version
$ php phpunit-X.Y.phar --version
```
Please replace `X.Y` with the version of PHPUnit you are interested in.
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.
## Contribute

11
vendor/phpunit/phpunit/SECURITY.md vendored Normal file
View File

@@ -0,0 +1,11 @@
# Security Policy
PHPUnit is a framework for writing as well as a commandline tool for running tests. Writing and running tests is a development-time activity. There is no reason why PHPUnit should be installed on a webserver.
**If you upload PHPUnit to a webserver then your deployment process is broken. On a more general note, if your `vendor` directory is publicly accessible on your webserver then your deployment process is also broken.**
Please note that if you upload PHPUnit to a webserver "bad things" may happen. [You have been warned.](https://thephp.cc/articles/phpunit-a-security-risk)
## Security Contact Information
After the above, if you still would like to report a security vulnerability, please email `sebastian@phpunit.de`.

View File

@@ -1,428 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="phpunit" default="setup">
<target name="setup" depends="clean,install-dependencies"/>
<target name="validate" depends="php-syntax-check,validate-composer-json,validate-phpunit-xsd"/>
<target name="clean" unless="clean.done" description="Cleanup build artifacts">
<delete dir="${basedir}/bin"/>
<delete dir="${basedir}/vendor"/>
<delete file="${basedir}/composer.lock"/>
<delete dir="${basedir}/build/documentation"/>
<delete dir="${basedir}/build/logfiles"/>
<delete dir="${basedir}/build/phar"/>
<delete>
<fileset dir="${basedir}/build">
<include name="**/phpunit*.phar"/>
<include name="**/phpunit*.phar.asc"/>
</fileset>
</delete>
<property name="clean.done" value="true"/>
</target>
<target name="prepare" unless="prepare.done" depends="clean" description="Prepare for build">
<mkdir dir="${basedir}/build/documentation"/>
<mkdir dir="${basedir}/build/logfiles"/>
<property name="prepare.done" value="true"/>
</target>
<target name="validate-composer-json" depends="clean" unless="validate-composer-json.done" description="Validate composer.json">
<exec executable="${basedir}/tools/composer" failonerror="true" taskname="composer">
<arg value="validate"/>
<arg value="--strict"/>
<arg value="${basedir}/composer.json"/>
</exec>
<property name="validate-composer-json.done" value="true"/>
</target>
<target name="-dependencies-installed">
<available file="${basedir}/composer.lock" property="dependencies-installed"/>
</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}/tools/composer" taskname="composer">
<arg value="require"/>
<arg value="--no-update"/>
<arg value="phpunit/php-invoker:^2.0"/>
</exec>
<exec executable="${basedir}/tools/composer" taskname="composer">
<arg value="update"/>
<arg value="--no-interaction"/>
<arg value="--no-progress"/>
<arg value="--no-ansi"/>
<arg value="--no-suggest"/>
</exec>
<move file="${basedir}/composer.json.bak" tofile="${basedir}/composer.json"/>
</target>
<target name="check-dependencies" description="Performs check for outdated dependencies">
<exec executable="${basedir}/tools/composer" taskname="composer">
<arg value="show"/>
<arg value="--minor-only"/>
<arg value="--latest"/>
<arg value="--direct"/>
<arg value="--outdated"/>
<arg value="--strict"/>
</exec>
</target>
<target name="php-syntax-check" unless="php-syntax-check.done" description="Perform syntax check on PHP files">
<apply executable="php" failonerror="true" taskname="lint">
<arg value="-l"/>
<fileset dir="${basedir}/src">
<include name="**/*.php"/>
<modified/>
</fileset>
<fileset dir="${basedir}/tests">
<include name="**/*.php"/>
<modified/>
</fileset>
</apply>
<property name="php-syntax-check.done" value="true"/>
</target>
<target name="validate-phpunit-xsd" unless="validate-phpunit-xsd.done" description="Validate phpunit.xsd">
<exec executable="xmllint" failonerror="true" taskname="xmllint">
<arg value="--noout"/>
<arg path="${basedir}/phpunit.xsd"/>
</exec>
<property name="validate-phpunit-xsd.done" value="true"/>
</target>
<target name="test" depends="validate,install-dependencies" description="Run tests">
<exec executable="${basedir}/phpunit" taskname="phpunit"/>
</target>
<target name="signed-phar" depends="phar" description="Create signed PHAR archive of PHPUnit and all its dependencies">
<exec executable="gpg" failonerror="true">
<arg value="--local-user"/>
<arg value="sb@sebastian-bergmann.de"/>
<arg value="--armor"/>
<arg value="--detach-sign"/>
<arg path="${basedir}/build/phpunit-library-${version}.phar"/>
</exec>
<exec executable="gpg" failonerror="true">
<arg value="--local-user"/>
<arg value="sb@sebastian-bergmann.de"/>
<arg value="--armor"/>
<arg value="--detach-sign"/>
<arg path="${basedir}/build/phpunit-${version}.phar"/>
</exec>
</target>
<target name="phar" depends="-phar-prepare,-phar-determine-version" description="Create PHAR archive of PHPUnit and all its dependencies">
<antcall target="-phar-build">
<param name="type" value="release"/>
</antcall>
</target>
<target name="phar-nightly" depends="-phar-prepare" description="Create PHAR archive of PHPUnit and all its dependencies (nightly)">
<antcall target="-phar-build">
<param name="type" value="nightly"/>
</antcall>
</target>
<target name="-phar-prepare" depends="clean,install-dependencies">
<mkdir dir="${basedir}/build/phar"/>
<copy file="${basedir}/phpunit.xsd" tofile="${basedir}/build/phar/phpunit.xsd"/>
<exec executable="${basedir}/build/phar-manifest.php" output="${basedir}/build/phar/manifest.txt" failonerror="true"/>
<copy file="${basedir}/vendor/phpunit/php-code-coverage/LICENSE" tofile="${basedir}/build/phar/php-code-coverage/LICENSE"/>
<copy todir="${basedir}/build/phar/php-code-coverage">
<fileset dir="${basedir}/vendor/phpunit/php-code-coverage/src">
<include name="**/*" />
</fileset>
</copy>
<copy file="${basedir}/vendor/phpunit/php-file-iterator/LICENSE" tofile="${basedir}/build/phar/php-file-iterator/LICENSE"/>
<copy todir="${basedir}/build/phar/php-file-iterator">
<fileset dir="${basedir}/vendor/phpunit/php-file-iterator/src">
<include name="**/*.php" />
</fileset>
</copy>
<copy todir="${basedir}/build/phar/php-invoker">
<fileset dir="${basedir}/vendor/phpunit/php-invoker/src">
<include name="**/*.php" />
</fileset>
</copy>
<copy file="${basedir}/vendor/phpunit/php-text-template/LICENSE" tofile="${basedir}/build/phar/php-text-template/LICENSE"/>
<copy todir="${basedir}/build/phar/php-text-template">
<fileset dir="${basedir}/vendor/phpunit/php-text-template/src">
<include name="**/*.php" />
</fileset>
</copy>
<copy file="${basedir}/vendor/phpunit/php-timer/LICENSE" tofile="${basedir}/build/phar/php-timer/LICENSE"/>
<copy todir="${basedir}/build/phar/php-timer">
<fileset dir="${basedir}/vendor/phpunit/php-timer/src">
<include name="**/*.php" />
</fileset>
</copy>
<copy file="${basedir}/vendor/phpunit/php-token-stream/LICENSE" tofile="${basedir}/build/phar/php-token-stream/LICENSE"/>
<copy todir="${basedir}/build/phar/php-token-stream">
<fileset dir="${basedir}/vendor/phpunit/php-token-stream/src">
<include name="**/*.php" />
</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">
<include name="**/*.php" />
</fileset>
</copy>
<copy file="${basedir}/vendor/sebastian/comparator/LICENSE" tofile="${basedir}/build/phar/sebastian-comparator/LICENSE"/>
<copy todir="${basedir}/build/phar/sebastian-comparator">
<fileset dir="${basedir}/vendor/sebastian/comparator/src">
<include name="**/*.php" />
</fileset>
</copy>
<copy file="${basedir}/vendor/sebastian/diff/LICENSE" tofile="${basedir}/build/phar/sebastian-diff/LICENSE"/>
<copy todir="${basedir}/build/phar/sebastian-diff">
<fileset dir="${basedir}/vendor/sebastian/diff/src">
<include name="**/*.php" />
</fileset>
</copy>
<copy file="${basedir}/vendor/sebastian/environment/LICENSE" tofile="${basedir}/build/phar/sebastian-environment/LICENSE"/>
<copy todir="${basedir}/build/phar/sebastian-environment">
<fileset dir="${basedir}/vendor/sebastian/environment/src">
<include name="**/*.php" />
</fileset>
</copy>
<copy file="${basedir}/vendor/sebastian/exporter/LICENSE" tofile="${basedir}/build/phar/sebastian-exporter/LICENSE"/>
<copy todir="${basedir}/build/phar/sebastian-exporter">
<fileset dir="${basedir}/vendor/sebastian/exporter/src">
<include name="**/*.php" />
</fileset>
</copy>
<copy file="${basedir}/vendor/sebastian/global-state/LICENSE" tofile="${basedir}/build/phar/sebastian-global-state/LICENSE"/>
<copy todir="${basedir}/build/phar/sebastian-global-state">
<fileset dir="${basedir}/vendor/sebastian/global-state/src">
<include name="**/*.php" />
</fileset>
</copy>
<copy file="${basedir}/vendor/sebastian/object-enumerator/LICENSE" tofile="${basedir}/build/phar/object-enumerator/LICENSE"/>
<copy todir="${basedir}/build/phar/sebastian-object-enumerator">
<fileset dir="${basedir}/vendor/sebastian/object-enumerator/src">
<include name="**/*.php" />
</fileset>
</copy>
<copy file="${basedir}/vendor/sebastian/object-reflector/LICENSE" tofile="${basedir}/build/phar/object-reflector/LICENSE"/>
<copy todir="${basedir}/build/phar/sebastian-object-reflector">
<fileset dir="${basedir}/vendor/sebastian/object-reflector/src">
<include name="**/*.php" />
</fileset>
</copy>
<copy file="${basedir}/vendor/sebastian/recursion-context/LICENSE" tofile="${basedir}/build/phar/sebastian-recursion-context/LICENSE"/>
<copy todir="${basedir}/build/phar/sebastian-recursion-context">
<fileset dir="${basedir}/vendor/sebastian/recursion-context/src">
<include name="**/*.php" />
</fileset>
</copy>
<copy file="${basedir}/vendor/sebastian/resource-operations/LICENSE" tofile="${basedir}/build/phar/sebastian-resource-operations/LICENSE"/>
<copy todir="${basedir}/build/phar/sebastian-resource-operations">
<fileset dir="${basedir}/vendor/sebastian/resource-operations/src">
<include name="**/*.php" />
</fileset>
</copy>
<copy file="${basedir}/vendor/sebastian/version/LICENSE" tofile="${basedir}/build/phar/sebastian-version/LICENSE"/>
<copy todir="${basedir}/build/phar/sebastian-version">
<fileset dir="${basedir}/vendor/sebastian/version/src">
<include name="**/*.php" />
</fileset>
</copy>
<copy file="${basedir}/vendor/doctrine/instantiator/LICENSE" tofile="${basedir}/build/phar/doctrine-instantiator/LICENSE"/>
<copy todir="${basedir}/build/phar/doctrine-instantiator">
<fileset dir="${basedir}/vendor/doctrine/instantiator/src">
<include name="**/*.php" />
</fileset>
</copy>
<copy file="${basedir}/vendor/myclabs/deep-copy/LICENSE" tofile="${basedir}/build/phar/myclabs-deep-copy/LICENSE"/>
<copy todir="${basedir}/build/phar/myclabs-deep-copy">
<fileset dir="${basedir}/vendor/myclabs/deep-copy/src">
<include name="**/*.php" />
</fileset>
</copy>
<copy file="${basedir}/vendor/phar-io/manifest/LICENSE" tofile="${basedir}/build/phar/phar-io-manifest/LICENSE"/>
<copy todir="${basedir}/build/phar/phar-io-manifest">
<fileset dir="${basedir}/vendor/phar-io/manifest/src">
<include name="**/*.php" />
</fileset>
</copy>
<copy file="${basedir}/vendor/phar-io/version/LICENSE" tofile="${basedir}/build/phar/phar-io-version/LICENSE"/>
<copy todir="${basedir}/build/phar/phar-io-version">
<fileset dir="${basedir}/vendor/phar-io/version/src">
<include name="**/*.php" />
</fileset>
</copy>
<copy file="${basedir}/vendor/phpdocumentor/reflection-common/LICENSE" tofile="${basedir}/build/phar/phpdocumentor-reflection-common/LICENSE"/>
<copy todir="${basedir}/build/phar/phpdocumentor-reflection-common">
<fileset dir="${basedir}/vendor/phpdocumentor/reflection-common/src">
<include name="**/*.php" />
</fileset>
</copy>
<copy file="${basedir}/vendor/phpdocumentor/reflection-docblock/LICENSE" tofile="${basedir}/build/phar/phpdocumentor-reflection-docblock/LICENSE"/>
<copy todir="${basedir}/build/phar/phpdocumentor-reflection-docblock">
<fileset dir="${basedir}/vendor/phpdocumentor/reflection-docblock/src">
<include name="**/*.php" />
</fileset>
</copy>
<copy file="${basedir}/vendor/phpdocumentor/type-resolver/LICENSE" tofile="${basedir}/build/phar/phpdocumentor-type-resolver/LICENSE"/>
<copy todir="${basedir}/build/phar/phpdocumentor-type-resolver">
<fileset dir="${basedir}/vendor/phpdocumentor/type-resolver/src">
<include name="**/*.php" />
</fileset>
</copy>
<copy file="${basedir}/vendor/phpspec/prophecy/LICENSE" tofile="${basedir}/build/phar/phpspec-prophecy/LICENSE"/>
<copy todir="${basedir}/build/phar/phpspec-prophecy">
<fileset dir="${basedir}/vendor/phpspec/prophecy/src">
<include name="**/*.php" />
</fileset>
</copy>
<copy file="${basedir}/vendor/theseer/tokenizer/LICENSE" tofile="${basedir}/build/phar/theseer-tokenizer/LICENSE"/>
<copy todir="${basedir}/build/phar/theseer-tokenizer">
<fileset dir="${basedir}/vendor/theseer/tokenizer/src">
<include name="**/*.php" />
</fileset>
</copy>
<copy file="${basedir}/vendor/webmozart/assert/LICENSE" tofile="${basedir}/build/phar/webmozart-assert/LICENSE"/>
<copy todir="${basedir}/build/phar/webmozart-assert">
<fileset dir="${basedir}/vendor/webmozart/assert/src">
<include name="**/*.php" />
</fileset>
</copy>
</target>
<target name="-phar-build" depends="-phar-determine-version">
<copy todir="${basedir}/build/phar/phpunit">
<fileset dir="${basedir}/src">
<include name="**/*.php"/>
<include name="**/*.tpl*"/>
</fileset>
</copy>
<exec executable="${basedir}/build/phar-version.php" outputproperty="_version" failonerror="true">
<arg value="${version}"/>
<arg value="${type}"/>
</exec>
<exec executable="${basedir}/tools/phpab" taskname="phpab" failonerror="true">
<arg value="--all" />
<arg value="--static" />
<arg value="--once" />
<arg value="--phar" />
<arg value="--hash" />
<arg value="SHA-1" />
<arg value="--output" />
<arg path="${basedir}/build/phpunit-library-${_version}.phar" />
<arg value="--template" />
<arg path="${basedir}/build/library-phar-autoload.php.in" />
<arg path="${basedir}/build/phar" />
</exec>
<copy file="${basedir}/build/binary-phar-autoload.php.in" tofile="${basedir}/build/binary-phar-autoload.php"/>
<replace file="${basedir}/build/binary-phar-autoload.php" token="X.Y.Z" value="${_version}"/>
<exec executable="${basedir}/tools/phpab" taskname="phpab" failonerror="true">
<arg value="--all" />
<arg value="--nolower" />
<arg value="--static" />
<arg value="--phar" />
<arg value="--hash" />
<arg value="SHA-1" />
<arg value="--output" />
<arg path="${basedir}/build/phpunit-${_version}.phar" />
<arg value="--template" />
<arg path="${basedir}/build/binary-phar-autoload.php" />
<arg path="${basedir}/build/phar" />
</exec>
<chmod file="${basedir}/build/phpunit-${_version}.phar" perm="ugo+rx"/>
<delete dir="${basedir}/build/phar"/>
<delete file="${basedir}/build/binary-phar-autoload.php"/>
</target>
<target name="-phar-determine-version">
<exec executable="${basedir}/build/version.php" outputproperty="version" failonerror="true" />
</target>
<target name="generate-project-documentation" depends="-phploc,-checkstyle,-phpunit">
<exec executable="${basedir}/tools/phpdox" dir="${basedir}/build" taskname="phpdox"/>
</target>
<target name="update-tools">
<exec executable="phive">
<arg value="--no-progress"/>
<arg value="update"/>
</exec>
<exec executable="${basedir}/tools/composer">
<arg value="self-update"/>
</exec>
</target>
<target name="-phploc" depends="prepare">
<exec executable="${basedir}/tools/phploc" output="/dev/null" taskname="phploc">
<arg value="--count-tests"/>
<arg value="--log-xml"/>
<arg path="${basedir}/build/logfiles/phploc.xml"/>
<arg path="${basedir}/src"/>
<arg path="${basedir}/tests"/>
</exec>
</target>
<target name="-checkstyle" depends="prepare">
<exec executable="${basedir}/tools/php-cs-fixer" output="${basedir}/build/logfiles/checkstyle.xml" error="/dev/null" taskname="php-cs-fixer">
<arg value="--diff"/>
<arg value="--dry-run"/>
<arg value="fix"/>
<arg value="--format=checkstyle"/>
</exec>
</target>
<target name="-phpunit" depends="setup">
<exec executable="${basedir}/phpunit" taskname="phpunit">
<arg value="--coverage-xml"/>
<arg path="${basedir}/build/logfiles/coverage"/>
<arg value="--log-junit"/>
<arg path="${basedir}/build/logfiles/junit.xml"/>
</exec>
</target>
</project>

View File

@@ -21,45 +21,40 @@
},
"prefer-stable": true,
"require": {
"php": "^7.1",
"php": ">=7.2",
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-xml": "*",
"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": "^6.0.7",
"phpunit/php-file-iterator": "^2.0.1",
"ext-xmlwriter": "*",
"doctrine/instantiator": "^1.3.1",
"myclabs/deep-copy": "^1.10.0",
"phar-io/manifest": "^2.0.3",
"phar-io/version": "^3.0.2",
"phpunit/php-code-coverage": "^7.0.12",
"phpunit/php-file-iterator": "^2.0.4",
"phpunit/php-text-template": "^1.2.1",
"phpunit/php-timer": "^2.1",
"sebastian/comparator": "^3.0",
"sebastian/diff": "^3.0",
"sebastian/environment": "^4.0",
"sebastian/exporter": "^3.1",
"sebastian/global-state": "^2.0",
"phpunit/php-timer": "^2.1.2",
"sebastian/comparator": "^3.0.5",
"sebastian/diff": "^3.0.2",
"sebastian/environment": "^4.2.3",
"sebastian/exporter": "^3.1.5",
"sebastian/global-state": "^3.0.0",
"sebastian/object-enumerator": "^3.0.3",
"sebastian/resource-operations": "^2.0",
"sebastian/resource-operations": "^2.0.1",
"sebastian/type": "^1.1.3",
"sebastian/version": "^2.0.1"
},
"require-dev": {
"ext-PDO": "*"
},
"conflict": {
"phpunit/phpunit-mock-objects": "*"
},
"config": {
"platform": {
"php": "7.1.0"
"php": "7.2.0"
},
"optimize-autoloader": true,
"sort-packages": true
},
"suggest": {
"phpunit/php-invoker": "^2.0",
"phpunit/php-invoker": "^2.0.0",
"ext-soap": "*",
"ext-xdebug": "*"
},
@@ -84,7 +79,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "7.5-dev"
"dev-master": "8.5-dev"
}
}
}

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpab" version="^1.25" installed="1.25.8" location="./tools/phpab" copy="true"/>
<phar name="php-cs-fixer" version="^2.16" installed="2.16.1" location="./tools/php-cs-fixer" copy="true"/>
<phar name="phpdox" version="^0.11" installed="0.12.0" location="./tools/phpdox" copy="true"/>
<phar name="phploc" version="^4.0" installed="4.0.1" location="./tools/phploc" copy="true"/>
</phive>

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env php
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,11 +9,26 @@
* file that was distributed with this source code.
*/
if (version_compare('7.1.0', PHP_VERSION, '>')) {
if (!version_compare(PHP_VERSION, PHP_VERSION, '=')) {
fwrite(
STDERR,
sprintf(
'This version of PHPUnit is supported on PHP 7.1, PHP 7.2, and PHP 7.3.' . PHP_EOL .
'%s declares an invalid value for PHP_VERSION.' . PHP_EOL .
'This breaks fundamental functionality such as version_compare().' . PHP_EOL .
'Please use a different PHP interpreter.' . PHP_EOL,
PHP_BINARY
)
);
die(1);
}
if (version_compare('7.2.0', PHP_VERSION, '>')) {
fwrite(
STDERR,
sprintf(
'This version of PHPUnit requires PHP >= 7.2.' . PHP_EOL .
'You are using PHP %s (%s).' . PHP_EOL,
PHP_VERSION,
PHP_BINARY
@@ -23,19 +38,41 @@ if (version_compare('7.1.0', PHP_VERSION, '>')) {
die(1);
}
foreach (['dom', 'json', 'libxml', 'mbstring', 'tokenizer', 'xml', 'xmlwriter'] as $extension) {
if (extension_loaded($extension)) {
continue;
}
fwrite(
STDERR,
sprintf(
'PHPUnit requires the "%s" extension.' . PHP_EOL,
$extension
)
);
die(1);
}
if (!ini_get('date.timezone')) {
ini_set('date.timezone', 'UTC');
}
foreach (array(__DIR__ . '/../../autoload.php', __DIR__ . '/../vendor/autoload.php', __DIR__ . '/vendor/autoload.php') as $file) {
if (file_exists($file)) {
define('PHPUNIT_COMPOSER_INSTALL', $file);
if (isset($GLOBALS['_composer_autoload_path'])) {
define('PHPUNIT_COMPOSER_INSTALL', $GLOBALS['_composer_autoload_path']);
break;
unset($GLOBALS['_composer_autoload_path']);
} else {
foreach (array(__DIR__ . '/../../autoload.php', __DIR__ . '/../vendor/autoload.php', __DIR__ . '/vendor/autoload.php') as $file) {
if (file_exists($file)) {
define('PHPUNIT_COMPOSER_INSTALL', $file);
break;
}
}
}
unset($file);
unset($file);
}
if (!defined('PHPUNIT_COMPOSER_INSTALL')) {
fwrite(

View File

@@ -1,32 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="phpunit.xsd"
bootstrap="tests/bootstrap.php"
cacheResult="true"
colors="true"
verbose="true">
<testsuites>
<testsuite name="unit">
<directory suffix="Test.php">tests/unit</directory>
</testsuite>
<testsuite name="end-to-end">
<directory suffix=".phpt">tests/end-to-end</directory>
<exclude>tests/end-to-end/_files</exclude>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
<exclude>
<file>src/Framework/Assert/Functions.php</file>
<file>src/Util/PHP/eval-stdin.php</file>
</exclude>
</whitelist>
</filter>
<php>
<const name="PHPUNIT_TESTSUITE" value="true"/>
</php>
</phpunit>

View File

@@ -2,7 +2,7 @@
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:documentation source="https://phpunit.de/documentation.html">
This Schema file defines the rules by which the XML configuration file of PHPUnit 7.5 may be structured.
This Schema file defines the rules by which the XML configuration file of PHPUnit 8.5 may be structured.
</xs:documentation>
<xs:appinfo source="https://phpunit.de/documentation.html"/>
</xs:annotation>
@@ -149,8 +149,8 @@
</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="lowUpperBound" type="xs:nonNegativeInteger" default="50"/>
<xs:attribute name="highLowerBound" type="xs:nonNegativeInteger" default="90"/>
<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"/>
@@ -165,7 +165,7 @@
</xs:group>
<xs:complexType name="directoryFilterType">
<xs:simpleContent>
<xs:extension base="xs:anyURI">
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="prefix" default=""/>
<xs:attribute type="xs:string" name="suffix" default="Test.php"/>
<xs:attributeGroup ref="phpVersionGroup"/>
@@ -176,14 +176,22 @@
<xs:restriction base="xs:string">
<xs:enumeration value="default"/>
<xs:enumeration value="defects"/>
<xs:enumeration value="duration"/>
<xs:enumeration value="depends"/>
<xs:enumeration value="depends,defects"/>
<xs:enumeration value="random"/>
<xs:enumeration value="reverse"/>
<xs:enumeration value="depends,duration"/>
<xs:enumeration value="depends,random"/>
<xs:enumeration value="depends,reverse"/>
<xs:enumeration value="depends,duration"/>
<xs:enumeration value="depends,size"/>
<xs:enumeration value="duration"/>
<xs:enumeration value="no-depends"/>
<xs:enumeration value="no-depends,defects"/>
<xs:enumeration value="no-depends,duration"/>
<xs:enumeration value="no-depends,random"/>
<xs:enumeration value="no-depends,reverse"/>
<xs:enumeration value="no-depends,size"/>
<xs:enumeration value="random"/>
<xs:enumeration value="reverse"/>
<xs:enumeration value="size"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="fileFilterType">
@@ -231,12 +239,12 @@
<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" default="false"/>
<xs:attribute name="cacheResult" type="xs:boolean" default="true"/>
<xs:attribute name="cacheResultFile" type="xs:anyURI"/>
<xs:attribute name="cacheTokens" type="xs:boolean" default="false"/>
<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="convertDeprecationsToExceptions" type="xs:boolean" default="false"/>
<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"/>
@@ -270,12 +278,14 @@
<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="testdox" 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="extensionsDirectory" type="xs:anyURI"/>
<xs:attribute name="executionOrder" type="executionOrderType" default="default"/>
<xs:attribute name="resolveDependencies" type="xs:boolean" default="false"/>
<xs:attribute name="resolveDependencies" type="xs:boolean" default="true"/>
<xs:attribute name="noInteraction" type="xs:boolean" default="false"/>
</xs:attributeGroup>
<xs:group name="configGroup">
<xs:all>
@@ -299,8 +309,10 @@
</xs:complexType>
<xs:complexType name="testSuiteType">
<xs:sequence>
<xs:group ref="pathGroup"/>
<xs:element name="exclude" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="pathGroup"/>
<xs:element name="exclude" type="xs:string"/>
</xs:choice>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:complexType>

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,9 +9,11 @@
*/
namespace PHPUnit;
use Throwable;
/**
* Marker interface for PHPUnit exceptions.
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
interface Exception extends \Throwable
interface Exception extends Throwable
{
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,6 +9,8 @@
*/
namespace PHPUnit\Framework\Constraint;
use function array_key_exists;
use function is_array;
use ArrayAccess;
/**
@@ -19,7 +21,7 @@ use ArrayAccess;
*
* The array key is passed in the constructor.
*/
class ArrayHasKey extends Constraint
final class ArrayHasKey extends Constraint
{
/**
* @var int|string
@@ -31,7 +33,6 @@ class ArrayHasKey extends Constraint
*/
public function __construct($key)
{
parent::__construct();
$this->key = $key;
}
@@ -42,7 +43,7 @@ class ArrayHasKey extends Constraint
*/
public function toString(): string
{
return 'has the key ' . $this->exporter->export($this->key);
return 'has the key ' . $this->exporter()->export($this->key);
}
/**
@@ -53,8 +54,8 @@ class ArrayHasKey extends Constraint
*/
protected function matches($other): bool
{
if (\is_array($other)) {
return \array_key_exists($this->key, $other);
if (is_array($other)) {
return array_key_exists($this->key, $other);
}
if ($other instanceof ArrayAccess) {
@@ -65,7 +66,7 @@ class ArrayHasKey extends Constraint
}
/**
* Returns the description of the failure
* 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.

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,8 +9,14 @@
*/
namespace PHPUnit\Framework\Constraint;
use function array_replace_recursive;
use function is_array;
use function iterator_to_array;
use function var_export;
use ArrayObject;
use PHPUnit\Framework\ExpectationFailedException;
use SebastianBergmann\Comparator\ComparisonFailure;
use Traversable;
/**
* Constraint that asserts that the array it is evaluated for has a specified subset.
@@ -18,9 +24,11 @@ use SebastianBergmann\Comparator\ComparisonFailure;
* Uses array_replace_recursive() to check if a key value subset is part of the
* subject array.
*
* @codeCoverageIgnore
*
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/3494
*/
class ArraySubset extends Constraint
final class ArraySubset extends Constraint
{
/**
* @var iterable
@@ -34,14 +42,12 @@ class ArraySubset extends Constraint
public function __construct(iterable $subset, bool $strict = false)
{
parent::__construct();
$this->strict = $strict;
$this->subset = $subset;
}
/**
* Evaluates the constraint for parameter $other
* Evaluates the constraint for parameter $other.
*
* If $returnResult is set to false (the default), an exception is thrown
* in case of a failure. null is returned otherwise.
@@ -50,21 +56,17 @@ 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 string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws ExpectationFailedException
*/
public function evaluate($other, $description = '', $returnResult = false)
public function evaluate($other, string $description = '', bool $returnResult = false)
{
//type cast $other & $this->subset as an array to allow
//support in standard array functions.
$other = $this->toArray($other);
$this->subset = $this->toArray($this->subset);
$patched = \array_replace_recursive($other, $this->subset);
$patched = array_replace_recursive($other, $this->subset);
if ($this->strict) {
$result = $other === $patched;
@@ -80,8 +82,8 @@ class ArraySubset extends Constraint
$f = new ComparisonFailure(
$patched,
$other,
\var_export($patched, true),
\var_export($other, true)
var_export($patched, true),
var_export($other, true)
);
$this->fail($other, $description, $f);
@@ -95,11 +97,11 @@ class ArraySubset extends Constraint
*/
public function toString(): string
{
return 'has the subset ' . $this->exporter->export($this->subset);
return 'has the subset ' . $this->exporter()->export($this->subset);
}
/**
* Returns the description of the failure
* 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.
@@ -115,16 +117,16 @@ class ArraySubset extends Constraint
private function toArray(iterable $other): array
{
if (\is_array($other)) {
if (is_array($other)) {
return $other;
}
if ($other instanceof \ArrayObject) {
if ($other instanceof ArrayObject) {
return $other->getArrayCopy();
}
if ($other instanceof \Traversable) {
return \iterator_to_array($other);
if ($other instanceof Traversable) {
return iterator_to_array($other);
}
// Keep BC even if we know that array would not be the expected one

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -12,7 +12,12 @@ namespace PHPUnit\Framework\Constraint;
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\ExpectationFailedException;
class Attribute extends Composite
/**
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338
*
* @codeCoverageIgnore
*/
final class Attribute extends Composite
{
/**
* @var string
@@ -27,7 +32,7 @@ class Attribute extends Composite
}
/**
* Evaluates the constraint for parameter $other
* Evaluates the constraint for parameter $other.
*
* If $returnResult is set to false (the default), an exception is thrown
* in case of a failure. null is returned otherwise.
@@ -36,15 +41,11 @@ 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 string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @throws ExpectationFailedException
* @throws \PHPUnit\Framework\Exception
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws ExpectationFailedException
*/
public function evaluate($other, $description = '', $returnResult = false)
public function evaluate($other, string $description = '', bool $returnResult = false)
{
return parent::evaluate(
Assert::readAttribute(
@@ -65,7 +66,7 @@ class Attribute extends Composite
}
/**
* Returns the description of the failure
* 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.

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -11,18 +11,21 @@ namespace PHPUnit\Framework\Constraint;
/**
* Constraint that evaluates against a specified closure.
*
* @psalm-template CallbackInput of mixed
*/
class Callback extends Constraint
final class Callback extends Constraint
{
/**
* @var callable
*
* @psalm-var callable(CallbackInput $input): bool
*/
private $callback;
/** @psalm-param callable(CallbackInput $input): bool $callback */
public function __construct(callable $callback)
{
parent::__construct();
$this->callback = $callback;
}
@@ -39,9 +42,11 @@ class Callback extends Constraint
* constraint is met, false otherwise.
*
* @param mixed $other value or object to evaluate
*
* @psalm-param CallbackInput $other
*/
protected function matches($other): bool
{
return \call_user_func($this->callback, $other);
return ($this->callback)($other);
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,7 +9,12 @@
*/
namespace PHPUnit\Framework\Constraint;
use function get_class;
use function is_object;
use function sprintf;
use PHPUnit\Framework\Exception;
use ReflectionClass;
use ReflectionException;
/**
* Constraint that asserts that the class it is evaluated for has a given
@@ -26,8 +31,6 @@ class ClassHasAttribute extends Constraint
public function __construct(string $attributeName)
{
parent::__construct();
$this->attributeName = $attributeName;
}
@@ -36,7 +39,7 @@ class ClassHasAttribute extends Constraint
*/
public function toString(): string
{
return \sprintf(
return sprintf(
'has attribute "%s"',
$this->attributeName
);
@@ -50,13 +53,21 @@ class ClassHasAttribute extends Constraint
*/
protected function matches($other): bool
{
$class = new ReflectionClass($other);
return $class->hasProperty($this->attributeName);
try {
return (new ReflectionClass($other))->hasProperty($this->attributeName);
// @codeCoverageIgnoreStart
} catch (ReflectionException $e) {
throw new Exception(
$e->getMessage(),
(int) $e->getCode(),
$e
);
}
// @codeCoverageIgnoreEnd
}
/**
* Returns the description of the failure
* 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.
@@ -65,10 +76,10 @@ class ClassHasAttribute extends Constraint
*/
protected function failureDescription($other): string
{
return \sprintf(
return sprintf(
'%sclass "%s" %s',
\is_object($other) ? 'object of ' : '',
\is_object($other) ? \get_class($other) : $other,
is_object($other) ? 'object of ' : '',
is_object($other) ? get_class($other) : $other,
$this->toString()
);
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,7 +9,10 @@
*/
namespace PHPUnit\Framework\Constraint;
use function sprintf;
use PHPUnit\Framework\Exception;
use ReflectionClass;
use ReflectionException;
/**
* Constraint that asserts that the class it is evaluated for has a given
@@ -17,14 +20,14 @@ use ReflectionClass;
*
* The attribute name is passed in the constructor.
*/
class ClassHasStaticAttribute extends ClassHasAttribute
final class ClassHasStaticAttribute extends ClassHasAttribute
{
/**
* Returns a string representation of the constraint.
*/
public function toString(): string
{
return \sprintf(
return sprintf(
'has static attribute "%s"',
$this->attributeName()
);
@@ -38,13 +41,21 @@ class ClassHasStaticAttribute extends ClassHasAttribute
*/
protected function matches($other): bool
{
$class = new ReflectionClass($other);
try {
$class = new ReflectionClass($other);
if ($class->hasProperty($this->attributeName())) {
$attribute = $class->getProperty($this->attributeName());
return $attribute->isStatic();
if ($class->hasProperty($this->attributeName())) {
return $class->getProperty($this->attributeName())->isStatic();
}
// @codeCoverageIgnoreStart
} catch (ReflectionException $e) {
throw new Exception(
$e->getMessage(),
(int) $e->getCode(),
$e
);
}
// @codeCoverageIgnoreEnd
return false;
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,8 +9,14 @@
*/
namespace PHPUnit\Framework\Constraint;
use function count;
use PHPUnit\Framework\ExpectationFailedException;
/**
* @deprecated https://github.com/sebastianbergmann/phpunit/issues/3338
*
* @codeCoverageIgnore
*/
abstract class Composite extends Constraint
{
/**
@@ -20,13 +26,11 @@ abstract class Composite extends Constraint
public function __construct(Constraint $innerConstraint)
{
parent::__construct();
$this->innerConstraint = $innerConstraint;
}
/**
* Evaluates the constraint for parameter $other
* Evaluates the constraint for parameter $other.
*
* If $returnResult is set to false (the default), an exception is thrown
* in case of a failure. null is returned otherwise.
@@ -35,14 +39,10 @@ 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 string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws ExpectationFailedException
*/
public function evaluate($other, $description = '', $returnResult = false)
public function evaluate($other, string $description = '', bool $returnResult = false)
{
try {
return $this->innerConstraint->evaluate(
@@ -60,7 +60,7 @@ abstract class Composite extends Constraint
*/
public function count(): int
{
return \count($this->innerConstraint);
return count($this->innerConstraint);
}
protected function innerConstraint(): Constraint

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,6 +9,7 @@
*/
namespace PHPUnit\Framework\Constraint;
use function sprintf;
use Countable;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Framework\SelfDescribing;
@@ -20,15 +21,13 @@ use SebastianBergmann\Exporter\Exporter;
*/
abstract class Constraint implements Countable, SelfDescribing
{
protected $exporter;
public function __construct()
{
$this->exporter = new Exporter;
}
/**
* @var Exporter
*/
private $exporter;
/**
* Evaluates the constraint for parameter $other
* Evaluates the constraint for parameter $other.
*
* If $returnResult is set to false (the default), an exception is thrown
* in case of a failure. null is returned otherwise.
@@ -37,14 +36,10 @@ 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 string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws ExpectationFailedException
*/
public function evaluate($other, $description = '', $returnResult = false)
public function evaluate($other, string $description = '', bool $returnResult = false)
{
$success = false;
@@ -69,6 +64,15 @@ abstract class Constraint implements Countable, SelfDescribing
return 1;
}
protected function exporter(): Exporter
{
if ($this->exporter === null) {
$this->exporter = new Exporter;
}
return $this->exporter;
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
@@ -76,6 +80,8 @@ abstract class Constraint implements Countable, SelfDescribing
* This method can be overridden to implement the evaluation algorithm.
*
* @param mixed $other value or object to evaluate
*
* @codeCoverageIgnore
*/
protected function matches($other): bool
{
@@ -83,18 +89,20 @@ abstract class Constraint implements Countable, SelfDescribing
}
/**
* Throws an exception for the given compared value and test description
* Throws an exception for the given compared value and test description.
*
* @param mixed $other evaluated value or object
* @param string $description Additional information about the test
* @param ComparisonFailure $comparisonFailure
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws ExpectationFailedException
*
* @psalm-return never-return
*/
protected function fail($other, $description, ComparisonFailure $comparisonFailure = null): void
{
$failureDescription = \sprintf(
$failureDescription = sprintf(
'Failed asserting that %s.',
$this->failureDescription($other)
);
@@ -116,7 +124,7 @@ abstract class Constraint implements Countable, SelfDescribing
}
/**
* Return additional failure description where needed
* Return additional failure description where needed.
*
* The function can be overridden to provide additional failure
* information like a diff
@@ -129,7 +137,7 @@ abstract class Constraint implements Countable, SelfDescribing
}
/**
* Returns the description of the failure
* 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.
@@ -143,6 +151,6 @@ abstract class Constraint implements Countable, SelfDescribing
*/
protected function failureDescription($other): string
{
return $this->exporter->export($other) . ' ' . $this->toString();
return $this->exporter()->export($other) . ' ' . $this->toString();
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,7 +9,12 @@
*/
namespace PHPUnit\Framework\Constraint;
use function count;
use function is_array;
use function iterator_count;
use function sprintf;
use Countable;
use EmptyIterator;
use Generator;
use Iterator;
use IteratorAggregate;
@@ -24,14 +29,12 @@ class Count extends Constraint
public function __construct(int $expected)
{
parent::__construct();
$this->expectedCount = $expected;
}
public function toString(): string
{
return \sprintf(
return sprintf(
'count matches %d',
$this->expectedCount
);
@@ -51,11 +54,11 @@ class Count extends Constraint
*/
protected function getCountOf($other): ?int
{
if ($other instanceof Countable || \is_array($other)) {
return \count($other);
if ($other instanceof Countable || is_array($other)) {
return count($other);
}
if ($other instanceof \EmptyIterator) {
if ($other instanceof EmptyIterator) {
return 0;
}
@@ -71,11 +74,11 @@ class Count extends Constraint
}
if (!$iterator instanceof Iterator) {
return \iterator_count($iterator);
return iterator_count($iterator);
}
$key = $iterator->key();
$count = \iterator_count($iterator);
$count = iterator_count($iterator);
// Manually rewind $iterator to previous key, since iterator_count
// moves pointer.
@@ -89,6 +92,8 @@ class Count extends Constraint
return $count;
}
return null;
}
/**
@@ -98,7 +103,7 @@ class Count extends Constraint
protected function getCountOfGenerator(Generator $generator): int
{
for ($count = 0; $generator->valid(); $generator->next()) {
++$count;
$count++;
}
return $count;
@@ -114,7 +119,7 @@ class Count extends Constraint
*/
protected function failureDescription($other): string
{
return \sprintf(
return sprintf(
'actual size %d matches expected size %d',
$this->getCountOf($other),
$this->expectedCount

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,12 +9,15 @@
*/
namespace PHPUnit\Framework\Constraint;
use function is_dir;
use function sprintf;
/**
* Constraint that checks if the directory(name) that it is evaluated for exists.
*
* The file path to check is passed as $other in evaluate().
*/
class DirectoryExists extends Constraint
final class DirectoryExists extends Constraint
{
/**
* Returns a string representation of the constraint.
@@ -32,11 +35,11 @@ class DirectoryExists extends Constraint
*/
protected function matches($other): bool
{
return \is_dir($other);
return is_dir($other);
}
/**
* Returns the description of the failure
* 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.
@@ -45,7 +48,7 @@ class DirectoryExists extends Constraint
*/
protected function failureDescription($other): string
{
return \sprintf(
return sprintf(
'directory "%s" exists',
$other
);

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,10 +9,12 @@
*/
namespace PHPUnit\Framework\Constraint;
use function get_class;
use function sprintf;
use PHPUnit\Util\Filter;
use Throwable;
class Exception extends Constraint
final class Exception extends Constraint
{
/**
* @var string
@@ -21,8 +23,6 @@ class Exception extends Constraint
public function __construct(string $className)
{
parent::__construct();
$this->className = $className;
}
@@ -31,7 +31,7 @@ class Exception extends Constraint
*/
public function toString(): string
{
return \sprintf(
return sprintf(
'exception of type "%s"',
$this->className
);
@@ -49,7 +49,7 @@ class Exception extends Constraint
}
/**
* Returns the description of the failure
* 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.
@@ -66,15 +66,15 @@ class Exception extends Constraint
. "\n" . Filter::getFilteredStacktrace($other);
}
return \sprintf(
return sprintf(
'exception of type "%s" matches expected exception "%s"%s',
\get_class($other),
get_class($other),
$this->className,
$message
);
}
return \sprintf(
return sprintf(
'exception of type "%s" is thrown',
$this->className
);

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,7 +9,10 @@
*/
namespace PHPUnit\Framework\Constraint;
class ExceptionCode extends Constraint
use function sprintf;
use Throwable;
final class ExceptionCode extends Constraint
{
/**
* @var int|string
@@ -21,8 +24,6 @@ class ExceptionCode extends Constraint
*/
public function __construct($expected)
{
parent::__construct();
$this->expectedCode = $expected;
}
@@ -35,7 +36,7 @@ class ExceptionCode extends Constraint
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param \Throwable $other
* @param Throwable $other
*/
protected function matches($other): bool
{
@@ -43,7 +44,7 @@ class ExceptionCode extends Constraint
}
/**
* Returns the description of the failure
* 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.
@@ -54,10 +55,10 @@ class ExceptionCode extends Constraint
*/
protected function failureDescription($other): string
{
return \sprintf(
return sprintf(
'%s is equal to expected exception code %s',
$this->exporter->export($other->getCode()),
$this->exporter->export($this->expectedCode)
$this->exporter()->export($other->getCode()),
$this->exporter()->export($this->expectedCode)
);
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,7 +9,11 @@
*/
namespace PHPUnit\Framework\Constraint;
class ExceptionMessage extends Constraint
use function sprintf;
use function strpos;
use Throwable;
final class ExceptionMessage extends Constraint
{
/**
* @var string
@@ -18,8 +22,6 @@ class ExceptionMessage extends Constraint
public function __construct(string $expected)
{
parent::__construct();
$this->expectedMessage = $expected;
}
@@ -36,7 +38,7 @@ class ExceptionMessage extends Constraint
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param \Throwable $other
* @param Throwable $other
*/
protected function matches($other): bool
{
@@ -44,11 +46,11 @@ class ExceptionMessage extends Constraint
return $other->getMessage() === '';
}
return \strpos($other->getMessage(), $this->expectedMessage) !== false;
return strpos((string) $other->getMessage(), $this->expectedMessage) !== false;
}
/**
* Returns the description of the failure
* 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.
@@ -58,13 +60,13 @@ class ExceptionMessage extends Constraint
protected function failureDescription($other): string
{
if ($this->expectedMessage === '') {
return \sprintf(
return sprintf(
"exception message is empty but is '%s'",
$other->getMessage()
);
}
return \sprintf(
return sprintf(
"exception message '%s' contains '%s'",
$other->getMessage(),
$this->expectedMessage

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,9 +9,11 @@
*/
namespace PHPUnit\Framework\Constraint;
use function sprintf;
use Exception;
use PHPUnit\Util\RegularExpression as RegularExpressionUtil;
class ExceptionMessageRegularExpression extends Constraint
final class ExceptionMessageRegularExpression extends Constraint
{
/**
* @var string
@@ -20,8 +22,6 @@ class ExceptionMessageRegularExpression extends Constraint
public function __construct(string $expected)
{
parent::__construct();
$this->expectedMessageRegExp = $expected;
}
@@ -36,8 +36,8 @@ class ExceptionMessageRegularExpression extends Constraint
*
* @param \PHPUnit\Framework\Exception $other
*
* @throws \Exception
* @throws \PHPUnit\Framework\Exception
* @throws Exception
*/
protected function matches($other): bool
{
@@ -53,7 +53,7 @@ class ExceptionMessageRegularExpression extends Constraint
}
/**
* Returns the description of the failure
* 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.
@@ -62,7 +62,7 @@ class ExceptionMessageRegularExpression extends Constraint
*/
protected function failureDescription($other): string
{
return \sprintf(
return sprintf(
"exception message '%s' matches '%s'",
$other->getMessage(),
$this->expectedMessageRegExp

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,12 +9,15 @@
*/
namespace PHPUnit\Framework\Constraint;
use function file_exists;
use function sprintf;
/**
* Constraint that checks if the file(name) that it is evaluated for exists.
*
* The file path to check is passed as $other in evaluate().
*/
class FileExists extends Constraint
final class FileExists extends Constraint
{
/**
* Returns a string representation of the constraint.
@@ -32,11 +35,11 @@ class FileExists extends Constraint
*/
protected function matches($other): bool
{
return \file_exists($other);
return file_exists($other);
}
/**
* Returns the description of the failure
* 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.
@@ -45,7 +48,7 @@ class FileExists extends Constraint
*/
protected function failureDescription($other): string
{
return \sprintf(
return sprintf(
'file "%s" exists',
$other
);

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -13,7 +13,7 @@ namespace PHPUnit\Framework\Constraint;
* Constraint that asserts that the value it is evaluated for is greater
* than a given value.
*/
class GreaterThan extends Constraint
final class GreaterThan extends Constraint
{
/**
* @var float|int
@@ -25,8 +25,6 @@ class GreaterThan extends Constraint
*/
public function __construct($value)
{
parent::__construct();
$this->value = $value;
}
@@ -37,7 +35,7 @@ class GreaterThan extends Constraint
*/
public function toString(): string
{
return 'is greater than ' . $this->exporter->export($this->value);
return 'is greater than ' . $this->exporter()->export($this->value);
}
/**

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -14,10 +14,10 @@ use PHPUnit\Framework\ExpectationFailedException;
/**
* Constraint that accepts any input value.
*/
class IsAnything extends Constraint
final class IsAnything extends Constraint
{
/**
* Evaluates the constraint for parameter $other
* Evaluates the constraint for parameter $other.
*
* If $returnResult is set to false (the default), an exception is thrown
* in case of a failure. null is returned otherwise.
@@ -26,13 +26,9 @@ 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 string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @throws ExpectationFailedException
*/
public function evaluate($other, $description = '', $returnResult = false)
public function evaluate($other, string $description = '', bool $returnResult = false)
{
return $returnResult ? true : null;
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,12 +9,17 @@
*/
namespace PHPUnit\Framework\Constraint;
use function count;
use function gettype;
use function sprintf;
use function strpos;
use Countable;
use EmptyIterator;
/**
* Constraint that checks whether a variable is empty().
*/
class IsEmpty extends Constraint
final class IsEmpty extends Constraint
{
/**
* Returns a string representation of the constraint.
@@ -32,19 +37,19 @@ class IsEmpty extends Constraint
*/
protected function matches($other): bool
{
if ($other instanceof \EmptyIterator) {
if ($other instanceof EmptyIterator) {
return true;
}
if ($other instanceof Countable) {
return \count($other) === 0;
return count($other) === 0;
}
return empty($other);
}
/**
* Returns the description of the failure
* 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.
@@ -53,11 +58,11 @@ class IsEmpty extends Constraint
*/
protected function failureDescription($other): string
{
$type = \gettype($other);
$type = gettype($other);
return \sprintf(
return sprintf(
'%s %s %s',
$type[0] == 'a' || $type[0] == 'o' ? 'an' : 'a',
strpos($type, 'a') === 0 || strpos($type, 'o') === 0 ? 'an' : 'a',
$type,
$this->toString()
);

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,6 +9,10 @@
*/
namespace PHPUnit\Framework\Constraint;
use function is_string;
use function sprintf;
use function strpos;
use function trim;
use PHPUnit\Framework\ExpectationFailedException;
use SebastianBergmann\Comparator\ComparisonFailure;
use SebastianBergmann\Comparator\Factory as ComparatorFactory;
@@ -22,7 +26,7 @@ use SebastianBergmann\Comparator\Factory as ComparatorFactory;
*
* The expected value is passed in the constructor.
*/
class IsEqual extends Constraint
final class IsEqual extends Constraint
{
/**
* @var mixed
@@ -34,11 +38,6 @@ class IsEqual extends Constraint
*/
private $delta;
/**
* @var int
*/
private $maxDepth;
/**
* @var bool
*/
@@ -51,17 +50,14 @@ class IsEqual extends Constraint
public function __construct($value, float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)
{
parent::__construct();
$this->value = $value;
$this->delta = $delta;
$this->maxDepth = $maxDepth;
$this->canonicalize = $canonicalize;
$this->ignoreCase = $ignoreCase;
}
/**
* Evaluates the constraint for parameter $other
* Evaluates the constraint for parameter $other.
*
* If $returnResult is set to false (the default), an exception is thrown
* in case of a failure. null is returned otherwise.
@@ -70,13 +66,9 @@ 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 string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @throws ExpectationFailedException
*/
public function evaluate($other, $description = '', $returnResult = false)
public function evaluate($other, string $description = '', bool $returnResult = false)
{
// If $this->value and $other are identical, they are also equal.
// This is the most common path and will allow us to skip
@@ -106,7 +98,7 @@ class IsEqual extends Constraint
}
throw new ExpectationFailedException(
\trim($description . "\n" . $f->getMessage()),
trim($description . "\n" . $f->getMessage()),
$f
);
}
@@ -123,27 +115,27 @@ class IsEqual extends Constraint
{
$delta = '';
if (\is_string($this->value)) {
if (\strpos($this->value, "\n") !== false) {
if (is_string($this->value)) {
if (strpos($this->value, "\n") !== false) {
return 'is equal to <text>';
}
return \sprintf(
return sprintf(
"is equal to '%s'",
$this->value
);
}
if ($this->delta != 0) {
$delta = \sprintf(
$delta = sprintf(
' with delta <%F>',
$this->delta
);
}
return \sprintf(
return sprintf(
'is equal to %s%s',
$this->exporter->export($this->value),
$this->exporter()->export($this->value),
$delta
);
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -12,7 +12,7 @@ namespace PHPUnit\Framework\Constraint;
/**
* Constraint that accepts false.
*/
class IsFalse extends Constraint
final class IsFalse extends Constraint
{
/**
* Returns a string representation of the constraint.

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,10 +9,12 @@
*/
namespace PHPUnit\Framework\Constraint;
use function is_finite;
/**
* Constraint that accepts finite.
*/
class IsFinite extends Constraint
final class IsFinite extends Constraint
{
/**
* Returns a string representation of the constraint.
@@ -30,6 +32,6 @@ class IsFinite extends Constraint
*/
protected function matches($other): bool
{
return \is_finite($other);
return is_finite($other);
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,6 +9,11 @@
*/
namespace PHPUnit\Framework\Constraint;
use function get_class;
use function is_array;
use function is_object;
use function is_string;
use function sprintf;
use PHPUnit\Framework\ExpectationFailedException;
use SebastianBergmann\Comparator\ComparisonFailure;
@@ -23,13 +28,8 @@ use SebastianBergmann\Comparator\ComparisonFailure;
*
* The expected value is passed in the constructor.
*/
class IsIdentical extends Constraint
final class IsIdentical extends Constraint
{
/**
* @var float
*/
private const EPSILON = 0.0000000001;
/**
* @var mixed
*/
@@ -37,13 +37,11 @@ class IsIdentical extends Constraint
public function __construct($value)
{
parent::__construct();
$this->value = $value;
}
/**
* Evaluates the constraint for parameter $other
* Evaluates the constraint for parameter $other.
*
* If $returnResult is set to false (the default), an exception is thrown
* in case of a failure. null is returned otherwise.
@@ -52,22 +50,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 string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws ExpectationFailedException
*/
public function evaluate($other, $description = '', $returnResult = false)
public function evaluate($other, string $description = '', bool $returnResult = false)
{
if (\is_float($this->value) && \is_float($other) &&
!\is_infinite($this->value) && !\is_infinite($other) &&
!\is_nan($this->value) && !\is_nan($other)) {
$success = \abs($this->value - $other) < self::EPSILON;
} else {
$success = $this->value === $other;
}
$success = $this->value === $other;
if ($returnResult) {
return $success;
@@ -77,22 +65,22 @@ class IsIdentical extends Constraint
$f = null;
// if both values are strings, make sure a diff is generated
if (\is_string($this->value) && \is_string($other)) {
if (is_string($this->value) && is_string($other)) {
$f = new ComparisonFailure(
$this->value,
$other,
\sprintf("'%s'", $this->value),
\sprintf("'%s'", $other)
sprintf("'%s'", $this->value),
sprintf("'%s'", $other)
);
}
// if both values are array, make sure a diff is generated
if (\is_array($this->value) && \is_array($other)) {
if (is_array($this->value) && is_array($other)) {
$f = new ComparisonFailure(
$this->value,
$other,
$this->exporter->export($this->value),
$this->exporter->export($other)
$this->exporter()->export($this->value),
$this->exporter()->export($other)
);
}
@@ -107,16 +95,16 @@ class IsIdentical extends Constraint
*/
public function toString(): string
{
if (\is_object($this->value)) {
if (is_object($this->value)) {
return 'is identical to an object of class "' .
\get_class($this->value) . '"';
get_class($this->value) . '"';
}
return 'is identical to ' . $this->exporter->export($this->value);
return 'is identical to ' . $this->exporter()->export($this->value);
}
/**
* Returns the description of the failure
* 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.
@@ -127,15 +115,15 @@ class IsIdentical extends Constraint
*/
protected function failureDescription($other): string
{
if (\is_object($this->value) && \is_object($other)) {
if (is_object($this->value) && is_object($other)) {
return 'two variables reference the same object';
}
if (\is_string($this->value) && \is_string($other)) {
if (is_string($this->value) && is_string($other)) {
return 'two strings are identical';
}
if (\is_array($this->value) && \is_array($other)) {
if (is_array($this->value) && is_array($other)) {
return 'two arrays are identical';
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,10 +9,12 @@
*/
namespace PHPUnit\Framework\Constraint;
use function is_infinite;
/**
* Constraint that accepts infinite.
*/
class IsInfinite extends Constraint
final class IsInfinite extends Constraint
{
/**
* Returns a string representation of the constraint.
@@ -30,6 +32,6 @@ class IsInfinite extends Constraint
*/
protected function matches($other): bool
{
return \is_infinite($other);
return is_infinite($other);
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,6 +9,7 @@
*/
namespace PHPUnit\Framework\Constraint;
use function sprintf;
use ReflectionClass;
use ReflectionException;
@@ -18,7 +19,7 @@ use ReflectionException;
*
* The expected class name is passed in the constructor.
*/
class IsInstanceOf extends Constraint
final class IsInstanceOf extends Constraint
{
/**
* @var string
@@ -27,8 +28,6 @@ class IsInstanceOf extends Constraint
public function __construct(string $className)
{
parent::__construct();
$this->className = $className;
}
@@ -37,7 +36,7 @@ class IsInstanceOf extends Constraint
*/
public function toString(): string
{
return \sprintf(
return sprintf(
'is instance of %s "%s"',
$this->getType(),
$this->className
@@ -56,7 +55,7 @@ class IsInstanceOf extends Constraint
}
/**
* Returns the description of the failure
* 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.
@@ -67,9 +66,9 @@ class IsInstanceOf extends Constraint
*/
protected function failureDescription($other): string
{
return \sprintf(
return sprintf(
'%s is an instance of %s "%s"',
$this->exporter->shortenedExport($other),
$this->exporter()->shortenedExport($other),
$this->getType(),
$this->className
);

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,10 +9,14 @@
*/
namespace PHPUnit\Framework\Constraint;
use function json_decode;
use function json_last_error;
use function sprintf;
/**
* Constraint that asserts that a string is valid JSON.
*/
class IsJson extends Constraint
final class IsJson extends Constraint
{
/**
* Returns a string representation of the constraint.
@@ -34,9 +38,9 @@ class IsJson extends Constraint
return false;
}
\json_decode($other);
json_decode($other);
if (\json_last_error()) {
if (json_last_error()) {
return false;
}
@@ -44,7 +48,7 @@ class IsJson extends Constraint
}
/**
* Returns the description of the failure
* 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.
@@ -59,14 +63,14 @@ class IsJson extends Constraint
return 'an empty string is valid JSON';
}
\json_decode($other);
json_decode($other);
$error = JsonMatchesErrorMessageProvider::determineJsonError(
\json_last_error()
(string) json_last_error()
);
return \sprintf(
return sprintf(
'%s is valid JSON (%s)',
$this->exporter->shortenedExport($other),
$this->exporter()->shortenedExport($other),
$error
);
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,10 +9,12 @@
*/
namespace PHPUnit\Framework\Constraint;
use function is_nan;
/**
* Constraint that accepts nan.
*/
class IsNan extends Constraint
final class IsNan extends Constraint
{
/**
* Returns a string representation of the constraint.
@@ -30,6 +32,6 @@ class IsNan extends Constraint
*/
protected function matches($other): bool
{
return \is_nan($other);
return is_nan($other);
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -12,7 +12,7 @@ namespace PHPUnit\Framework\Constraint;
/**
* Constraint that accepts null.
*/
class IsNull extends Constraint
final class IsNull extends Constraint
{
/**
* Returns a string representation of the constraint.

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,12 +9,15 @@
*/
namespace PHPUnit\Framework\Constraint;
use function is_readable;
use function sprintf;
/**
* Constraint that checks if the file/dir(name) that it is evaluated for is readable.
*
* The file path to check is passed as $other in evaluate().
*/
class IsReadable extends Constraint
final class IsReadable extends Constraint
{
/**
* Returns a string representation of the constraint.
@@ -32,11 +35,11 @@ class IsReadable extends Constraint
*/
protected function matches($other): bool
{
return \is_readable($other);
return is_readable($other);
}
/**
* Returns the description of the failure
* 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.
@@ -45,7 +48,7 @@ class IsReadable extends Constraint
*/
protected function failureDescription($other): string
{
return \sprintf(
return sprintf(
'"%s" is readable',
$other
);

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -12,7 +12,7 @@ namespace PHPUnit\Framework\Constraint;
/**
* Constraint that accepts true.
*/
class IsTrue extends Constraint
final class IsTrue extends Constraint
{
/**
* Returns a string representation of the constraint.

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,40 +9,91 @@
*/
namespace PHPUnit\Framework\Constraint;
use function get_resource_type;
use function is_array;
use function is_bool;
use function is_callable;
use function is_float;
use function is_int;
use function is_iterable;
use function is_numeric;
use function is_object;
use function is_resource;
use function is_scalar;
use function is_string;
use function sprintf;
use TypeError;
/**
* Constraint that asserts that the value it is evaluated for is of a
* specified type.
*
* The expected value is passed in the constructor.
*/
class IsType extends Constraint
final class IsType extends Constraint
{
public const TYPE_ARRAY = 'array';
/**
* @var string
*/
public const TYPE_ARRAY = 'array';
public const TYPE_BOOL = 'bool';
/**
* @var string
*/
public const TYPE_BOOL = 'bool';
public const TYPE_FLOAT = 'float';
/**
* @var string
*/
public const TYPE_FLOAT = 'float';
public const TYPE_INT = 'int';
/**
* @var string
*/
public const TYPE_INT = 'int';
public const TYPE_NULL = 'null';
/**
* @var string
*/
public const TYPE_NULL = 'null';
public const TYPE_NUMERIC = 'numeric';
/**
* @var string
*/
public const TYPE_NUMERIC = 'numeric';
public const TYPE_OBJECT = 'object';
/**
* @var string
*/
public const TYPE_OBJECT = 'object';
/**
* @var string
*/
public const TYPE_RESOURCE = 'resource';
public const TYPE_STRING = 'string';
/**
* @var string
*/
public const TYPE_STRING = 'string';
public const TYPE_SCALAR = 'scalar';
/**
* @var string
*/
public const TYPE_SCALAR = 'scalar';
/**
* @var string
*/
public const TYPE_CALLABLE = 'callable';
/**
* @var string
*/
public const TYPE_ITERABLE = 'iterable';
/**
* @var array
* @var array<string,bool>
*/
private const KNOWN_TYPES = [
'array' => true,
@@ -73,11 +124,9 @@ class IsType extends Constraint
*/
public function __construct(string $type)
{
parent::__construct();
if (!isset(self::KNOWN_TYPES[$type])) {
throw new \PHPUnit\Framework\Exception(
\sprintf(
sprintf(
'Type specified for PHPUnit\Framework\Constraint\IsType <%s> ' .
'is not a valid type.',
$type
@@ -93,7 +142,7 @@ class IsType extends Constraint
*/
public function toString(): string
{
return \sprintf(
return sprintf(
'is of type "%s"',
$this->type
);
@@ -109,44 +158,57 @@ class IsType extends Constraint
{
switch ($this->type) {
case 'numeric':
return \is_numeric($other);
return is_numeric($other);
case 'integer':
case 'int':
return \is_int($other);
return is_int($other);
case 'double':
case 'float':
case 'real':
return \is_float($other);
return is_float($other);
case 'string':
return \is_string($other);
return is_string($other);
case 'boolean':
case 'bool':
return \is_bool($other);
return is_bool($other);
case 'null':
return null === $other;
case 'array':
return \is_array($other);
return is_array($other);
case 'object':
return \is_object($other);
return is_object($other);
case 'resource':
return \is_resource($other) || \is_string(@\get_resource_type($other));
if (is_resource($other)) {
return true;
}
try {
$resource = @get_resource_type($other);
if (is_string($resource)) {
return true;
}
} catch (TypeError $e) {
}
return false;
case 'scalar':
return \is_scalar($other);
return is_scalar($other);
case 'callable':
return \is_callable($other);
return is_callable($other);
case 'iterable':
return \is_iterable($other);
return is_iterable($other);
}
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,12 +9,15 @@
*/
namespace PHPUnit\Framework\Constraint;
use function is_writable;
use function sprintf;
/**
* Constraint that checks if the file/dir(name) that it is evaluated for is writable.
*
* The file path to check is passed as $other in evaluate().
*/
class IsWritable extends Constraint
final class IsWritable extends Constraint
{
/**
* Returns a string representation of the constraint.
@@ -32,11 +35,11 @@ class IsWritable extends Constraint
*/
protected function matches($other): bool
{
return \is_writable($other);
return is_writable($other);
}
/**
* Returns the description of the failure
* 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.
@@ -45,7 +48,7 @@ class IsWritable extends Constraint
*/
protected function failureDescription($other): string
{
return \sprintf(
return sprintf(
'"%s" is writable',
$other
);

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,6 +9,8 @@
*/
namespace PHPUnit\Framework\Constraint;
use function json_decode;
use function sprintf;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Util\Json;
use SebastianBergmann\Comparator\ComparisonFailure;
@@ -16,7 +18,7 @@ use SebastianBergmann\Comparator\ComparisonFailure;
/**
* Asserts whether or not two JSON objects are equal.
*/
class JsonMatches extends Constraint
final class JsonMatches extends Constraint
{
/**
* @var string
@@ -25,8 +27,6 @@ class JsonMatches extends Constraint
public function __construct(string $value)
{
parent::__construct();
$this->value = $value;
}
@@ -35,7 +35,7 @@ class JsonMatches extends Constraint
*/
public function toString(): string
{
return \sprintf(
return sprintf(
'matches JSON string "%s"',
$this->value
);
@@ -67,40 +67,38 @@ class JsonMatches extends Constraint
}
/**
* Throws an exception for the given compared value and test description
* Throws an exception for the given compared value and test description.
*
* @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
* @throws ExpectationFailedException
*
* @psalm-return never-return
*/
protected function fail($other, $description, ComparisonFailure $comparisonFailure = null): void
{
if ($comparisonFailure === null) {
[$error] = Json::canonicalize($other);
[$error, $recodedOther] = Json::canonicalize($other);
if ($error) {
parent::fail($other, $description);
return;
}
[$error] = Json::canonicalize($this->value);
[$error, $recodedValue] = Json::canonicalize($this->value);
if ($error) {
parent::fail($other, $description);
return;
}
$comparisonFailure = new ComparisonFailure(
\json_decode($this->value),
\json_decode($other),
Json::prettify($this->value),
Json::prettify($other),
json_decode($this->value),
json_decode($other),
Json::prettify($recodedValue),
Json::prettify($recodedOther),
false,
'Failed asserting that two json values are equal.'
);

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,10 +9,18 @@
*/
namespace PHPUnit\Framework\Constraint;
use const JSON_ERROR_CTRL_CHAR;
use const JSON_ERROR_DEPTH;
use const JSON_ERROR_NONE;
use const JSON_ERROR_STATE_MISMATCH;
use const JSON_ERROR_SYNTAX;
use const JSON_ERROR_UTF8;
use function strtolower;
/**
* Provides human readable messages for each JSON error.
*/
class JsonMatchesErrorMessageProvider
final class JsonMatchesErrorMessageProvider
{
/**
* Translates JSON error to a human readable string.
@@ -20,18 +28,19 @@ class JsonMatchesErrorMessageProvider
public static function determineJsonError(string $error, string $prefix = ''): ?string
{
switch ($error) {
case \JSON_ERROR_NONE:
case JSON_ERROR_NONE:
return null;
case \JSON_ERROR_DEPTH:
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';
}
@@ -42,7 +51,7 @@ class JsonMatchesErrorMessageProvider
*/
public static function translateTypeToPrefix(string $type): string
{
switch (\strtolower($type)) {
switch (strtolower($type)) {
case 'expected':
$prefix = 'Expected value JSON decode error - ';
@@ -51,6 +60,7 @@ class JsonMatchesErrorMessageProvider
$prefix = 'Actual value JSON decode error - ';
break;
default:
$prefix = '';

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -13,7 +13,7 @@ namespace PHPUnit\Framework\Constraint;
* Constraint that asserts that the value it is evaluated for is less than
* a given value.
*/
class LessThan extends Constraint
final class LessThan extends Constraint
{
/**
* @var float|int
@@ -25,8 +25,6 @@ class LessThan extends Constraint
*/
public function __construct($value)
{
parent::__construct();
$this->value = $value;
}
@@ -37,7 +35,7 @@ class LessThan extends Constraint
*/
public function toString(): string
{
return 'is less than ' . $this->exporter->export($this->value);
return 'is less than ' . $this->exporter()->export($this->value);
}
/**

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,12 +9,14 @@
*/
namespace PHPUnit\Framework\Constraint;
use function array_values;
use function count;
use PHPUnit\Framework\ExpectationFailedException;
/**
* Logical AND.
*/
class LogicalAnd extends Constraint
final class LogicalAnd extends Constraint
{
/**
* @var Constraint[]
@@ -25,7 +27,7 @@ class LogicalAnd extends Constraint
{
$constraint = new self;
$constraint->constraints = \array_values($constraints);
$constraint->constraints = array_values($constraints);
return $constraint;
}
@@ -52,7 +54,7 @@ class LogicalAnd extends Constraint
}
/**
* Evaluates the constraint for parameter $other
* Evaluates the constraint for parameter $other.
*
* If $returnResult is set to false (the default), an exception is thrown
* in case of a failure. null is returned otherwise.
@@ -61,14 +63,10 @@ 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 string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws ExpectationFailedException
*/
public function evaluate($other, $description = '', $returnResult = false)
public function evaluate($other, string $description = '', bool $returnResult = false)
{
$success = true;
@@ -115,7 +113,7 @@ class LogicalAnd extends Constraint
$count = 0;
foreach ($this->constraints as $constraint) {
$count += \count($constraint);
$count += count($constraint);
}
return $count;

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,12 +9,16 @@
*/
namespace PHPUnit\Framework\Constraint;
use function count;
use function get_class;
use function preg_match;
use function str_replace;
use PHPUnit\Framework\ExpectationFailedException;
/**
* Logical NOT.
*/
class LogicalNot extends Constraint
final class LogicalNot extends Constraint
{
/**
* @var Constraint
@@ -49,14 +53,14 @@ class LogicalNot extends Constraint
'not ',
];
\preg_match('/(\'[\w\W]*\')([\w\W]*)("[\w\W]*")/i', $string, $matches);
preg_match('/(\'[\w\W]*\')([\w\W]*)("[\w\W]*")/i', $string, $matches);
if (\count($matches) > 0) {
if (count($matches) > 0) {
$nonInput = $matches[2];
$negatedString = \str_replace(
$negatedString = str_replace(
$nonInput,
\str_replace(
str_replace(
$positives,
$negatives,
$nonInput
@@ -64,7 +68,7 @@ class LogicalNot extends Constraint
$string
);
} else {
$negatedString = \str_replace(
$negatedString = str_replace(
$positives,
$negatives,
$string
@@ -79,8 +83,6 @@ class LogicalNot extends Constraint
*/
public function __construct($constraint)
{
parent::__construct();
if (!($constraint instanceof Constraint)) {
$constraint = new IsEqual($constraint);
}
@@ -89,7 +91,7 @@ class LogicalNot extends Constraint
}
/**
* Evaluates the constraint for parameter $other
* Evaluates the constraint for parameter $other.
*
* If $returnResult is set to false (the default), an exception is thrown
* in case of a failure. null is returned otherwise.
@@ -98,14 +100,10 @@ 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 string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws ExpectationFailedException
*/
public function evaluate($other, $description = '', $returnResult = false)
public function evaluate($other, string $description = '', bool $returnResult = false)
{
$success = !$this->constraint->evaluate($other, $description, true);
@@ -123,7 +121,7 @@ class LogicalNot extends Constraint
*/
public function toString(): string
{
switch (\get_class($this->constraint)) {
switch (get_class($this->constraint)) {
case LogicalAnd::class:
case self::class:
case LogicalOr::class:
@@ -141,11 +139,11 @@ class LogicalNot extends Constraint
*/
public function count(): int
{
return \count($this->constraint);
return count($this->constraint);
}
/**
* Returns the description of the failure
* 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.
@@ -156,7 +154,7 @@ class LogicalNot extends Constraint
*/
protected function failureDescription($other): string
{
switch (\get_class($this->constraint)) {
switch (get_class($this->constraint)) {
case LogicalAnd::class:
case self::class:
case LogicalOr::class:

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,12 +9,14 @@
*/
namespace PHPUnit\Framework\Constraint;
use function array_values;
use function count;
use PHPUnit\Framework\ExpectationFailedException;
/**
* Logical OR.
*/
class LogicalOr extends Constraint
final class LogicalOr extends Constraint
{
/**
* @var Constraint[]
@@ -25,7 +27,7 @@ class LogicalOr extends Constraint
{
$constraint = new self;
$constraint->constraints = \array_values($constraints);
$constraint->constraints = array_values($constraints);
return $constraint;
}
@@ -49,7 +51,7 @@ class LogicalOr extends Constraint
}
/**
* Evaluates the constraint for parameter $other
* Evaluates the constraint for parameter $other.
*
* If $returnResult is set to false (the default), an exception is thrown
* in case of a failure. null is returned otherwise.
@@ -58,14 +60,10 @@ 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 string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws ExpectationFailedException
*/
public function evaluate($other, $description = '', $returnResult = false)
public function evaluate($other, string $description = '', bool $returnResult = false)
{
$success = false;
@@ -112,7 +110,7 @@ class LogicalOr extends Constraint
$count = 0;
foreach ($this->constraints as $constraint) {
$count += \count($constraint);
$count += count($constraint);
}
return $count;

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,12 +9,14 @@
*/
namespace PHPUnit\Framework\Constraint;
use function array_values;
use function count;
use PHPUnit\Framework\ExpectationFailedException;
/**
* Logical XOR.
*/
class LogicalXor extends Constraint
final class LogicalXor extends Constraint
{
/**
* @var Constraint[]
@@ -25,7 +27,7 @@ class LogicalXor extends Constraint
{
$constraint = new self;
$constraint->constraints = \array_values($constraints);
$constraint->constraints = array_values($constraints);
return $constraint;
}
@@ -49,7 +51,7 @@ class LogicalXor extends Constraint
}
/**
* Evaluates the constraint for parameter $other
* Evaluates the constraint for parameter $other.
*
* If $returnResult is set to false (the default), an exception is thrown
* in case of a failure. null is returned otherwise.
@@ -58,14 +60,10 @@ 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 string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws ExpectationFailedException
*/
public function evaluate($other, $description = '', $returnResult = false)
public function evaluate($other, string $description = '', bool $returnResult = false)
{
$success = true;
$lastResult = null;
@@ -117,7 +115,7 @@ class LogicalXor extends Constraint
$count = 0;
foreach ($this->constraints as $constraint) {
$count += \count($constraint);
$count += count($constraint);
}
return $count;

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -17,7 +17,7 @@ use ReflectionObject;
*
* The attribute name is passed in the constructor.
*/
class ObjectHasAttribute extends ClassHasAttribute
final class ObjectHasAttribute extends ClassHasAttribute
{
/**
* Evaluates the constraint for parameter $other. Returns true if the
@@ -27,8 +27,6 @@ class ObjectHasAttribute extends ClassHasAttribute
*/
protected function matches($other): bool
{
$object = new ReflectionObject($other);
return $object->hasProperty($this->attributeName());
return (new ReflectionObject($other))->hasProperty($this->attributeName());
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,6 +9,9 @@
*/
namespace PHPUnit\Framework\Constraint;
use function preg_match;
use function sprintf;
/**
* Constraint that asserts that the string it is evaluated for matches
* a regular expression.
@@ -27,8 +30,6 @@ class RegularExpression extends Constraint
public function __construct(string $pattern)
{
parent::__construct();
$this->pattern = $pattern;
}
@@ -37,7 +38,7 @@ class RegularExpression extends Constraint
*/
public function toString(): string
{
return \sprintf(
return sprintf(
'matches PCRE pattern "%s"',
$this->pattern
);
@@ -51,6 +52,6 @@ class RegularExpression extends Constraint
*/
protected function matches($other): bool
{
return \preg_match($this->pattern, $other) > 0;
return preg_match($this->pattern, $other) > 0;
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,7 +9,7 @@
*/
namespace PHPUnit\Framework\Constraint;
class SameSize extends Count
final class SameSize extends Count
{
public function __construct(iterable $expected)
{

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,6 +9,11 @@
*/
namespace PHPUnit\Framework\Constraint;
use function mb_stripos;
use function mb_strpos;
use function mb_strtolower;
use function sprintf;
/**
* Constraint that asserts that the string it is evaluated for contains
* a given string.
@@ -18,7 +23,7 @@ namespace PHPUnit\Framework\Constraint;
*
* The sub-string is passed in the constructor.
*/
class StringContains extends Constraint
final class StringContains extends Constraint
{
/**
* @var string
@@ -32,8 +37,6 @@ class StringContains extends Constraint
public function __construct(string $string, bool $ignoreCase = false)
{
parent::__construct();
$this->string = $string;
$this->ignoreCase = $ignoreCase;
}
@@ -44,12 +47,12 @@ class StringContains extends Constraint
public function toString(): string
{
if ($this->ignoreCase) {
$string = \mb_strtolower($this->string);
$string = mb_strtolower($this->string);
} else {
$string = $this->string;
}
return \sprintf(
return sprintf(
'contains "%s"',
$string
);
@@ -68,9 +71,9 @@ class StringContains extends Constraint
}
if ($this->ignoreCase) {
return \mb_stripos($other, $this->string) !== false;
return mb_stripos($other, $this->string) !== false;
}
return \mb_strpos($other, $this->string) !== false;
return mb_strpos($other, $this->string) !== false;
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,11 +9,14 @@
*/
namespace PHPUnit\Framework\Constraint;
use function strlen;
use function substr;
/**
* Constraint that asserts that the string it is evaluated for ends with a given
* suffix.
*/
class StringEndsWith extends Constraint
final class StringEndsWith extends Constraint
{
/**
* @var string
@@ -22,8 +25,6 @@ class StringEndsWith extends Constraint
public function __construct(string $suffix)
{
parent::__construct();
$this->suffix = $suffix;
}
@@ -43,6 +44,6 @@ class StringEndsWith extends Constraint
*/
protected function matches($other): bool
{
return \substr($other, 0 - \strlen($this->suffix)) === $this->suffix;
return substr($other, 0 - strlen($this->suffix)) === $this->suffix;
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,12 +9,19 @@
*/
namespace PHPUnit\Framework\Constraint;
use const DIRECTORY_SEPARATOR;
use function explode;
use function implode;
use function preg_match;
use function preg_quote;
use function preg_replace;
use function strtr;
use SebastianBergmann\Diff\Differ;
/**
* ...
*/
class StringMatchesFormatDescription extends RegularExpression
final class StringMatchesFormatDescription extends RegularExpression
{
/**
* @var string
@@ -52,34 +59,32 @@ class StringMatchesFormatDescription extends RegularExpression
protected function additionalFailureDescription($other): string
{
$from = \explode("\n", $this->string);
$to = \explode("\n", $this->convertNewlines($other));
$from = explode("\n", $this->string);
$to = explode("\n", $this->convertNewlines($other));
foreach ($from as $index => $line) {
if (isset($to[$index]) && $line !== $to[$index]) {
$line = $this->createPatternFromFormat($line);
if (\preg_match($line, $to[$index]) > 0) {
if (preg_match($line, $to[$index]) > 0) {
$from[$index] = $to[$index];
}
}
}
$this->string = \implode("\n", $from);
$other = \implode("\n", $to);
$this->string = implode("\n", $from);
$other = implode("\n", $to);
$differ = new Differ("--- Expected\n+++ Actual\n");
return $differ->diff($this->string, $other);
return (new Differ("--- Expected\n+++ Actual\n"))->diff($this->string, $other);
}
private function createPatternFromFormat(string $string): string
{
$string = \strtr(
\preg_quote($string, '/'),
$string = strtr(
preg_quote($string, '/'),
[
'%%' => '%',
'%e' => '\\' . \DIRECTORY_SEPARATOR,
'%e' => '\\' . DIRECTORY_SEPARATOR,
'%s' => '[^\r\n]+',
'%S' => '[^\r\n]*',
'%a' => '.+',
@@ -98,6 +103,6 @@ class StringMatchesFormatDescription extends RegularExpression
private function convertNewlines($text): string
{
return \preg_replace('/\r\n/', "\n", $text);
return preg_replace('/\r\n/', "\n", $text);
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,13 +9,15 @@
*/
namespace PHPUnit\Framework\Constraint;
use PHPUnit\Util\InvalidArgumentHelper;
use function strlen;
use function strpos;
use PHPUnit\Framework\InvalidArgumentException;
/**
* Constraint that asserts that the string it is evaluated for begins with a
* given prefix.
*/
class StringStartsWith extends Constraint
final class StringStartsWith extends Constraint
{
/**
* @var string
@@ -24,10 +26,8 @@ class StringStartsWith extends Constraint
public function __construct(string $prefix)
{
parent::__construct();
if (\strlen($prefix) === 0) {
throw InvalidArgumentHelper::factory(1, 'non-empty string');
if (strlen($prefix) === 0) {
throw InvalidArgumentException::create(1, 'non-empty string');
}
$this->prefix = $prefix;
@@ -49,6 +49,6 @@ class StringStartsWith extends Constraint
*/
protected function matches($other): bool
{
return \strpos($other, $this->prefix) === 0;
return strpos((string) $other, $this->prefix) === 0;
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,13 +9,20 @@
*/
namespace PHPUnit\Framework\Constraint;
use function is_array;
use function is_object;
use function is_string;
use function sprintf;
use function strpos;
use SplObjectStorage;
/**
* Constraint that asserts that the Traversable it is applied to contains
* a given value.
*
* @deprecated Use TraversableContainsEqual or TraversableContainsIdentical instead
*/
class TraversableContains extends Constraint
final class TraversableContains extends Constraint
{
/**
* @var bool
@@ -32,13 +39,8 @@ class TraversableContains extends Constraint
*/
private $value;
/**
* @throws \PHPUnit\Framework\Exception
*/
public function __construct($value, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false)
{
parent::__construct();
$this->checkForObjectIdentity = $checkForObjectIdentity;
$this->checkForNonObjectIdentity = $checkForNonObjectIdentity;
$this->value = $value;
@@ -51,11 +53,11 @@ class TraversableContains extends Constraint
*/
public function toString(): string
{
if (\is_string($this->value) && \strpos($this->value, "\n") !== false) {
if (is_string($this->value) && strpos($this->value, "\n") !== false) {
return 'contains "' . $this->value . '"';
}
return 'contains ' . $this->exporter->export($this->value);
return 'contains ' . $this->exporter()->export($this->value);
}
/**
@@ -70,7 +72,7 @@ class TraversableContains extends Constraint
return $other->contains($this->value);
}
if (\is_object($this->value)) {
if (is_object($this->value)) {
foreach ($other as $element) {
if ($this->checkForObjectIdentity && $element === $this->value) {
return true;
@@ -98,7 +100,7 @@ class TraversableContains extends Constraint
}
/**
* Returns the description of the failure
* 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.
@@ -109,9 +111,9 @@ class TraversableContains extends Constraint
*/
protected function failureDescription($other): string
{
return \sprintf(
return sprintf(
'%s %s',
\is_array($other) ? 'an array' : 'a traversable',
is_array($other) ? 'an array' : 'a traversable',
$this->toString()
);
}

View File

@@ -0,0 +1,88 @@
<?php declare(strict_types=1);
/*
* 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\Constraint;
use function is_array;
use function is_string;
use function sprintf;
use function strpos;
use SplObjectStorage;
/**
* Constraint that asserts that the Traversable it is applied to contains
* a given value (using non-strict comparison).
*/
final class TraversableContainsEqual extends Constraint
{
/**
* @var mixed
*/
private $value;
public function __construct($value)
{
$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
*/
protected function matches($other): bool
{
if ($other instanceof SplObjectStorage) {
return $other->contains($this->value);
}
foreach ($other as $element) {
/* @noinspection TypeUnsafeComparisonInspection */
if ($this->value == $element) {
return true;
}
}
return false;
}
/**
* 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
{
return sprintf(
'%s %s',
is_array($other) ? 'an array' : 'a traversable',
$this->toString()
);
}
}

View File

@@ -0,0 +1,87 @@
<?php declare(strict_types=1);
/*
* 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\Constraint;
use function is_array;
use function is_string;
use function sprintf;
use function strpos;
use SplObjectStorage;
/**
* Constraint that asserts that the Traversable it is applied to contains
* a given value (using strict comparison).
*/
final class TraversableContainsIdentical extends Constraint
{
/**
* @var mixed
*/
private $value;
public function __construct($value)
{
$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
*/
protected function matches($other): bool
{
if ($other instanceof SplObjectStorage) {
return $other->contains($this->value);
}
foreach ($other as $element) {
if ($this->value === $element) {
return true;
}
}
return false;
}
/**
* 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
{
return sprintf(
'%s %s',
is_array($other) ? 'an array' : 'a traversable',
$this->toString()
);
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -15,7 +15,7 @@ use PHPUnit\Framework\ExpectationFailedException;
* Constraint that asserts that the Traversable it is applied to contains
* only values of a given type.
*/
class TraversableContainsOnly extends Constraint
final class TraversableContainsOnly extends Constraint
{
/**
* @var Constraint
@@ -32,8 +32,6 @@ class TraversableContainsOnly extends Constraint
*/
public function __construct(string $type, bool $isNativeType = true)
{
parent::__construct();
if ($isNativeType) {
$this->constraint = new IsType($type);
} else {
@@ -46,7 +44,7 @@ class TraversableContainsOnly extends Constraint
}
/**
* Evaluates the constraint for parameter $other
* Evaluates the constraint for parameter $other.
*
* If $returnResult is set to false (the default), an exception is thrown
* in case of a failure. null is returned otherwise.
@@ -55,14 +53,10 @@ 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 string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws ExpectationFailedException
*/
public function evaluate($other, $description = '', $returnResult = false)
public function evaluate($other, string $description = '', bool $returnResult = false)
{
$success = true;

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,7 +9,14 @@
*/
namespace PHPUnit\Framework;
class DataProviderTestSuite extends TestSuite
use function count;
use function explode;
use PHPUnit\Util\Test as TestUtil;
/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
final class DataProviderTestSuite extends TestSuite
{
/**
* @var string[]
@@ -39,6 +46,18 @@ class DataProviderTestSuite extends TestSuite
public function hasDependencies(): bool
{
return \count($this->dependencies) > 0;
return count($this->dependencies) > 0;
}
/**
* Returns the size of the each test created using the data provider(s).
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function getSize(): int
{
[$className, $methodName] = explode('::', $this->getName());
return TestUtil::getSize($className, $methodName);
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,7 +9,6 @@
*/
namespace PHPUnit\Framework\Error;
class Deprecated extends Error
final class Deprecated extends Error
{
public static $enabled = true;
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -11,9 +11,6 @@ namespace PHPUnit\Framework\Error;
use PHPUnit\Framework\Exception;
/**
* Wrapper for PHP errors.
*/
class Error extends Exception
{
public function __construct(string $message, int $code, string $file, int $line, \Exception $previous = null)

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,7 +9,6 @@
*/
namespace PHPUnit\Framework\Error;
class Notice extends Error
final class Notice extends Error
{
public static $enabled = true;
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,7 +9,6 @@
*/
namespace PHPUnit\Framework\Error;
class Warning extends Error
final class Warning extends Error
{
public static $enabled = true;
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -10,7 +10,7 @@
namespace PHPUnit\Framework;
/**
* Thrown when an assertion failed.
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
class AssertionFailedError extends Exception implements SelfDescribing
{

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,6 +9,9 @@
*/
namespace PHPUnit\Framework;
/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
class CodeCoverageException extends Exception
{
}

View File

@@ -0,0 +1,17 @@
<?php declare(strict_types=1);
/*
* 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;
/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
final class CoveredCodeNotExecutedException extends RiskyTestError
{
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,7 +9,11 @@
*/
namespace PHPUnit\Framework;
use function array_keys;
use function get_object_vars;
use PHPUnit\Util\Filter;
use RuntimeException;
use Throwable;
/**
* Base class for all PHPUnit Framework exceptions.
@@ -30,28 +34,27 @@ use PHPUnit\Util\Filter;
* the parent would break the intended encapsulation of process isolation.
*
* @see http://fabien.potencier.org/article/9/php-serialization-stack-traces-and-exceptions
*
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
class Exception extends \RuntimeException implements \PHPUnit\Exception
class Exception extends RuntimeException implements \PHPUnit\Exception
{
/**
* @var array
*/
protected $serializableTrace;
public function __construct($message = '', $code = 0, \Exception $previous = null)
public function __construct($message = '', $code = 0, Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
$this->serializableTrace = $this->getTrace();
foreach ($this->serializableTrace as $i => $call) {
unset($this->serializableTrace[$i]['args']);
foreach (array_keys($this->serializableTrace) as $key) {
unset($this->serializableTrace[$key]['args']);
}
}
/**
* @throws \InvalidArgumentException
*/
public function __toString(): string
{
$string = TestFailure::exceptionToString($this);
@@ -65,7 +68,7 @@ class Exception extends \RuntimeException implements \PHPUnit\Exception
public function __sleep(): array
{
return \array_keys(\get_object_vars($this));
return array_keys(get_object_vars($this));
}
/**

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,6 +9,7 @@
*/
namespace PHPUnit\Framework;
use Exception;
use SebastianBergmann\Comparator\ComparisonFailure;
/**
@@ -17,15 +18,17 @@ use SebastianBergmann\Comparator\ComparisonFailure;
* The exception contains the error message and optionally a
* SebastianBergmann\Comparator\ComparisonFailure which is used to
* generate diff output of the failed expectations.
*
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
class ExpectationFailedException extends AssertionFailedError
final class ExpectationFailedException extends AssertionFailedError
{
/**
* @var ComparisonFailure
*/
protected $comparisonFailure;
public function __construct(string $message, ComparisonFailure $comparisonFailure = null, \Exception $previous = null)
public function __construct(string $message, ComparisonFailure $comparisonFailure = null, Exception $previous = null)
{
$this->comparisonFailure = $comparisonFailure;

View File

@@ -7,16 +7,11 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use PHPUnit\Framework\TestCase;
namespace PHPUnit\Framework;
/**
* @coversNothing
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
class CoverageClassNothingTest extends TestCase
final class IncompleteTestError extends AssertionFailedError implements IncompleteTest
{
public function testSomething(): void
{
$o = new CoveredClass;
$o->publicMethod();
}
}

View File

@@ -0,0 +1,46 @@
<?php declare(strict_types=1);
/*
* 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;
use function debug_backtrace;
use function in_array;
use function lcfirst;
use function sprintf;
/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
final class InvalidArgumentException extends Exception
{
public static function create(int $argument, string $type): self
{
$stack = debug_backtrace();
$function = $stack[1]['function'];
if (isset($stack[1]['class'])) {
$function = sprintf('%s::%s', $stack[1]['class'], $stack[1]['function']);
}
return new self(
sprintf(
'Argument #%d of %s() must be %s %s',
$argument,
$function,
in_array(lcfirst($type)[0], ['a', 'e', 'i', 'o', 'u'], true) ? 'an' : 'a',
$type
)
);
}
private function __construct(string $message = '', int $code = 0, \Exception $previous = null)
{
parent::__construct($message, $code, $previous);
}
}

View File

@@ -7,18 +7,11 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework;
final class FinalClass
/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
final class InvalidCoversTargetException extends CodeCoverageException
{
private $value;
public function __construct($value)
{
$this->value = $value;
}
public function value()
{
return $this->value;
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,6 +9,9 @@
*/
namespace PHPUnit\Framework;
class CoveredCodeNotExecutedException extends RiskyTestError
/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
final class InvalidDataProviderException extends Exception
{
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,6 +9,9 @@
*/
namespace PHPUnit\Framework;
class MissingCoversAnnotationException extends RiskyTestError
/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
final class MissingCoversAnnotationException extends RiskyTestError
{
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,6 +9,9 @@
*/
namespace PHPUnit\Framework;
class IncompleteTestError extends AssertionFailedError implements IncompleteTest
/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
final class NoChildTestSuiteException extends Exception
{
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,6 +9,9 @@
*/
namespace PHPUnit\Framework;
class OutputError extends AssertionFailedError
/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
final class OutputError extends AssertionFailedError
{
}

View File

@@ -0,0 +1,32 @@
<?php declare(strict_types=1);
/*
* 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;
/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
final class PHPTAssertionFailedError extends SyntheticError
{
/**
* @var string
*/
private $diff;
public function __construct(string $message, int $code, string $file, int $line, array $trace, string $diff)
{
parent::__construct($message, $code, $file, $line, $trace);
$this->diff = $diff;
}
public function getDiff(): string
{
return $this->diff;
}
}

View File

@@ -9,6 +9,9 @@
*/
namespace PHPUnit\Framework;
final class UnexpectedValueException extends Exception
/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
class RiskyTestError extends AssertionFailedError
{
}

View File

@@ -7,13 +7,11 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use PHPUnit\Framework\TestCase;
namespace PHPUnit\Framework;
class CoverageClassWithoutAnnotationsTest extends TestCase
/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
final class SkippedTestError extends AssertionFailedError implements SkippedTest
{
public function testSomething(): void
{
$o = new CoveredClass;
$o->publicMethod();
}
}

View File

@@ -0,0 +1,17 @@
<?php declare(strict_types=1);
/*
* 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;
/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
final class SkippedTestSuiteError extends AssertionFailedError implements SkippedTest
{
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -10,7 +10,7 @@
namespace PHPUnit\Framework;
/**
* Creates a synthetic failed assertion.
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
class SyntheticError extends AssertionFailedError
{

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,6 +9,9 @@
*/
namespace PHPUnit\Framework;
class SkippedTestSuiteError extends AssertionFailedError implements SkippedTest
/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
final class SyntheticSkippedError extends SyntheticError implements SkippedTest
{
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -10,9 +10,8 @@
namespace PHPUnit\Framework;
/**
* Extension to PHPUnit\Framework\AssertionFailedError to mark the special
* case of a test that unintentionally covers code.
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
class UnintentionallyCoveredCodeError extends RiskyTestError
final class UnintentionallyCoveredCodeError extends RiskyTestError
{
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -10,9 +10,9 @@
namespace PHPUnit\Framework;
/**
* Thrown when there is a warning.
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
class Warning extends Exception implements SelfDescribing
final class Warning extends Exception implements SelfDescribing
{
/**
* Wrapper for getMessage() which is declared as final.

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -9,6 +9,9 @@
*/
namespace PHPUnit\Framework;
use function array_keys;
use function get_class;
use function spl_object_hash;
use PHPUnit\Util\Filter;
use Throwable;
@@ -20,8 +23,10 @@ use Throwable;
*
* Unlike PHPUnit\Framework_\Exception, the complete stack of previous Exceptions
* is processed.
*
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
class ExceptionWrapper extends Exception
final class ExceptionWrapper extends Exception
{
/**
* @var string
@@ -41,9 +46,6 @@ class ExceptionWrapper extends Exception
$this->setOriginalException($t);
}
/**
* @throws \InvalidArgumentException
*/
public function __toString(): string
{
$string = TestFailure::exceptionToString($this);
@@ -74,18 +76,18 @@ class ExceptionWrapper extends Exception
$this->className = $className;
}
public function setOriginalException(\Throwable $t): void
public function setOriginalException(Throwable $t): void
{
$this->originalException($t);
$this->className = \get_class($t);
$this->className = get_class($t);
$this->file = $t->getFile();
$this->line = $t->getLine();
$this->serializableTrace = $t->getTrace();
foreach ($this->serializableTrace as $i => $call) {
unset($this->serializableTrace[$i]['args']);
foreach (array_keys($this->serializableTrace) as $key) {
unset($this->serializableTrace[$key]['args']);
}
if ($t->getPrevious()) {
@@ -101,13 +103,13 @@ class ExceptionWrapper extends Exception
/**
* 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()
* Approach works both for var_dump() and var_export() and print_r().
*/
private function originalException(Throwable $exceptionToStore = null): ?Throwable
{
static $originalExceptions;
$instanceId = \spl_object_hash($this);
$instanceId = spl_object_hash($this);
if ($exceptionToStore) {
$originalExceptions[$instanceId] = $exceptionToStore;

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
@@ -10,8 +10,7 @@
namespace PHPUnit\Framework;
/**
* A marker interface for marking any exception/error as result of an unit
* test as incomplete implementation or currently not implemented.
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
interface IncompleteTest
{

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