PK O j j phpdoc.dist.xmlnu W+A
bovigo/callmap API Doc
docs/api
docs/api
src/main/php
PK Op .travis.ymlnu W+A language: php
php:
- 7.2
- 7.3
- 7.4
- 7.4snapshot
- nightly
matrix:
fast_finish: true
allow_failures:
- php: nightly
- php: 7.4snapshot
install:
- composer install
script:
- vendor/bin/phpunit --coverage-text
after_success:
- composer require php-coveralls/php-coveralls
- travis_retry vendor/bin/php-coveralls
- composer require phpstan/phpstan
- vendor/bin/phpstan analyse
PK Oqf!W W .coveralls.ymlnu W+A coverage_clover: docs/phpunit/clover.xml
json_path: docs/phpunit/coveralls-upload.json
PK O
composer.locknu W+A {
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "3b76d5b45e1968c057d391eb62b6a200",
"packages": [
{
"name": "mikey179/vfsstream",
"version": "v1.6.8",
"source": {
"type": "git",
"url": "https://github.com/bovigo/vfsStream.git",
"reference": "231c73783ebb7dd9ec77916c10037eff5a2b6efe"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bovigo/vfsStream/zipball/231c73783ebb7dd9ec77916c10037eff5a2b6efe",
"reference": "231c73783ebb7dd9ec77916c10037eff5a2b6efe",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "^4.5|^5.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.6.x-dev"
}
},
"autoload": {
"psr-0": {
"org\\bovigo\\vfs\\": "src/main/php"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Frank Kleine",
"homepage": "http://frankkleine.de/",
"role": "Developer"
}
],
"description": "Virtual file system to mock the real file system in unit tests.",
"homepage": "http://vfs.bovigo.org/",
"time": "2019-10-30T15:31:00+00:00"
},
{
"name": "sebastian/comparator",
"version": "3.0.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/comparator.git",
"reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da",
"reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da",
"shasum": ""
},
"require": {
"php": "^7.1",
"sebastian/diff": "^3.0",
"sebastian/exporter": "^3.1"
},
"require-dev": {
"phpunit/phpunit": "^7.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Jeff Welch",
"email": "whatthejeff@gmail.com"
},
{
"name": "Volker Dusch",
"email": "github@wallbash.com"
},
{
"name": "Bernhard Schussek",
"email": "bschussek@2bepublished.at"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Provides the functionality to compare PHP values for equality",
"homepage": "https://github.com/sebastianbergmann/comparator",
"keywords": [
"comparator",
"compare",
"equality"
],
"time": "2018-07-12T15:12:46+00:00"
},
{
"name": "sebastian/diff",
"version": "3.0.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/diff.git",
"reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/720fcc7e9b5cf384ea68d9d930d480907a0c1a29",
"reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29",
"shasum": ""
},
"require": {
"php": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "^7.5 || ^8.0",
"symfony/process": "^2 || ^3.3 || ^4"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Kore Nordmann",
"email": "mail@kore-nordmann.de"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Diff implementation",
"homepage": "https://github.com/sebastianbergmann/diff",
"keywords": [
"diff",
"udiff",
"unidiff",
"unified diff"
],
"time": "2019-02-04T06:01:07+00:00"
},
{
"name": "sebastian/exporter",
"version": "3.1.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git",
"reference": "234199f4528de6d12aaa58b612e98f7d36adb937"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/234199f4528de6d12aaa58b612e98f7d36adb937",
"reference": "234199f4528de6d12aaa58b612e98f7d36adb937",
"shasum": ""
},
"require": {
"php": "^7.0",
"sebastian/recursion-context": "^3.0"
},
"require-dev": {
"ext-mbstring": "*",
"phpunit/phpunit": "^6.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.1.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Jeff Welch",
"email": "whatthejeff@gmail.com"
},
{
"name": "Volker Dusch",
"email": "github@wallbash.com"
},
{
"name": "Bernhard Schussek",
"email": "bschussek@2bepublished.at"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "Adam Harvey",
"email": "aharvey@php.net"
}
],
"description": "Provides the functionality to export PHP variables for visualization",
"homepage": "http://www.github.com/sebastianbergmann/exporter",
"keywords": [
"export",
"exporter"
],
"time": "2017-04-03T13:19:02+00:00"
},
{
"name": "sebastian/recursion-context",
"version": "3.0.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/recursion-context.git",
"reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8",
"reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8",
"shasum": ""
},
"require": {
"php": "^7.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Jeff Welch",
"email": "whatthejeff@gmail.com"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "Adam Harvey",
"email": "aharvey@php.net"
}
],
"description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
"time": "2017-03-03T06:23:57+00:00"
}
],
"packages-dev": [
{
"name": "doctrine/instantiator",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
"reference": "a2c590166b2133a4633738648b6b064edae0814a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/a2c590166b2133a4633738648b6b064edae0814a",
"reference": "a2c590166b2133a4633738648b6b064edae0814a",
"shasum": ""
},
"require": {
"php": "^7.1"
},
"require-dev": {
"doctrine/coding-standard": "^6.0",
"ext-pdo": "*",
"ext-phar": "*",
"phpbench/phpbench": "^0.13",
"phpstan/phpstan-phpunit": "^0.11",
"phpstan/phpstan-shim": "^0.11",
"phpunit/phpunit": "^7.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Marco Pivetta",
"email": "ocramius@gmail.com",
"homepage": "http://ocramius.github.com/"
}
],
"description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
"homepage": "https://www.doctrine-project.org/projects/instantiator.html",
"keywords": [
"constructor",
"instantiate"
],
"time": "2019-03-17T17:37:11+00:00"
},
{
"name": "myclabs/deep-copy",
"version": "1.9.0",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
"reference": "78af75148f9fdd34ea727c8b529a9b4a8f7b740c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/78af75148f9fdd34ea727c8b529a9b4a8f7b740c",
"reference": "78af75148f9fdd34ea727c8b529a9b4a8f7b740c",
"shasum": ""
},
"require": {
"php": "^7.2"
},
"replace": {
"myclabs/deep-copy": "self.version"
},
"require-dev": {
"doctrine/collections": "^1.0",
"doctrine/common": "^2.6",
"phpstan/phpstan": "^0.9.2",
"phpstan/phpstan-phpunit": "^0.9.4",
"phpunit/phpunit": "^7.1"
},
"type": "library",
"autoload": {
"psr-4": {
"DeepCopy\\": "src/DeepCopy/"
},
"files": [
"src/DeepCopy/deep_copy.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Create deep copies (clones) of your objects",
"keywords": [
"clone",
"copy",
"duplicate",
"object",
"object graph"
],
"time": "2018-10-30T00:14:44+00:00"
},
{
"name": "phar-io/manifest",
"version": "1.0.3",
"source": {
"type": "git",
"url": "https://github.com/phar-io/manifest.git",
"reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phar-io/manifest/zipball/7761fcacf03b4d4f16e7ccb606d4879ca431fcf4",
"reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-phar": "*",
"phar-io/version": "^2.0",
"php": "^5.6 || ^7.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Arne Blankerts",
"email": "arne@blankerts.de",
"role": "Developer"
},
{
"name": "Sebastian Heuer",
"email": "sebastian@phpeople.de",
"role": "Developer"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "Developer"
}
],
"description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
"time": "2018-07-08T19:23:20+00:00"
},
{
"name": "phar-io/version",
"version": "2.0.1",
"source": {
"type": "git",
"url": "https://github.com/phar-io/version.git",
"reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phar-io/version/zipball/45a2ec53a73c70ce41d55cedef9063630abaf1b6",
"reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6",
"shasum": ""
},
"require": {
"php": "^5.6 || ^7.0"
},
"type": "library",
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Arne Blankerts",
"email": "arne@blankerts.de",
"role": "Developer"
},
{
"name": "Sebastian Heuer",
"email": "sebastian@phpeople.de",
"role": "Developer"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "Developer"
}
],
"description": "Library for handling version information and constraints",
"time": "2018-07-08T19:19:57+00:00"
},
{
"name": "phpdocumentor/reflection-common",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionCommon.git",
"reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6",
"reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6",
"shasum": ""
},
"require": {
"php": ">=5.5"
},
"require-dev": {
"phpunit/phpunit": "^4.6"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"phpDocumentor\\Reflection\\": [
"src"
]
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jaap van Otterdijk",
"email": "opensource@ijaap.nl"
}
],
"description": "Common reflection classes used by phpdocumentor to reflect the code structure",
"homepage": "http://www.phpdoc.org",
"keywords": [
"FQSEN",
"phpDocumentor",
"phpdoc",
"reflection",
"static analysis"
],
"time": "2017-09-11T18:02:19+00:00"
},
{
"name": "phpdocumentor/reflection-docblock",
"version": "4.3.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
"reference": "94fd0001232e47129dd3504189fa1c7225010d08"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08",
"reference": "94fd0001232e47129dd3504189fa1c7225010d08",
"shasum": ""
},
"require": {
"php": "^7.0",
"phpdocumentor/reflection-common": "^1.0.0",
"phpdocumentor/type-resolver": "^0.4.0",
"webmozart/assert": "^1.0"
},
"require-dev": {
"doctrine/instantiator": "~1.0.5",
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^6.4"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.x-dev"
}
},
"autoload": {
"psr-4": {
"phpDocumentor\\Reflection\\": [
"src/"
]
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mike van Riel",
"email": "me@mikevanriel.com"
}
],
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
"time": "2017-11-30T07:14:17+00:00"
},
{
"name": "phpdocumentor/type-resolver",
"version": "0.4.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git",
"reference": "9c977708995954784726e25d0cd1dddf4e65b0f7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7",
"reference": "9c977708995954784726e25d0cd1dddf4e65b0f7",
"shasum": ""
},
"require": {
"php": "^5.5 || ^7.0",
"phpdocumentor/reflection-common": "^1.0"
},
"require-dev": {
"mockery/mockery": "^0.9.4",
"phpunit/phpunit": "^5.2||^4.8.24"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"phpDocumentor\\Reflection\\": [
"src/"
]
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mike van Riel",
"email": "me@mikevanriel.com"
}
],
"time": "2017-07-14T14:27:02+00:00"
},
{
"name": "phpspec/prophecy",
"version": "1.8.0",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
"reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06",
"reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.0.2",
"php": "^5.3|^7.0",
"phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0",
"sebastian/comparator": "^1.1|^2.0|^3.0",
"sebastian/recursion-context": "^1.0|^2.0|^3.0"
},
"require-dev": {
"phpspec/phpspec": "^2.5|^3.2",
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.8.x-dev"
}
},
"autoload": {
"psr-0": {
"Prophecy\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Konstantin Kudryashov",
"email": "ever.zet@gmail.com",
"homepage": "http://everzet.com"
},
{
"name": "Marcello Duarte",
"email": "marcello.duarte@gmail.com"
}
],
"description": "Highly opinionated mocking framework for PHP 5.3+",
"homepage": "https://github.com/phpspec/prophecy",
"keywords": [
"Double",
"Dummy",
"fake",
"mock",
"spy",
"stub"
],
"time": "2018-08-05T17:53:17+00:00"
},
{
"name": "phpunit/php-code-coverage",
"version": "7.0.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "0317a769a81845c390e19684d9ba25d7f6aa4707"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/0317a769a81845c390e19684d9ba25d7f6aa4707",
"reference": "0317a769a81845c390e19684d9ba25d7f6aa4707",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-xmlwriter": "*",
"php": "^7.2",
"phpunit/php-file-iterator": "^2.0.2",
"phpunit/php-text-template": "^1.2.1",
"phpunit/php-token-stream": "^3.0.1",
"sebastian/code-unit-reverse-lookup": "^1.0.1",
"sebastian/environment": "^4.1",
"sebastian/version": "^2.0.1",
"theseer/tokenizer": "^1.1"
},
"require-dev": {
"phpunit/phpunit": "^8.0"
},
"suggest": {
"ext-xdebug": "^2.6.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "7.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.",
"homepage": "https://github.com/sebastianbergmann/php-code-coverage",
"keywords": [
"coverage",
"testing",
"xunit"
],
"time": "2019-02-26T07:38:26+00:00"
},
{
"name": "phpunit/php-file-iterator",
"version": "2.0.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
"reference": "050bedf145a257b1ff02746c31894800e5122946"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/050bedf145a257b1ff02746c31894800e5122946",
"reference": "050bedf145a257b1ff02746c31894800e5122946",
"shasum": ""
},
"require": {
"php": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "^7.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "FilterIterator implementation that filters files based on a list of suffixes.",
"homepage": "https://github.com/sebastianbergmann/php-file-iterator/",
"keywords": [
"filesystem",
"iterator"
],
"time": "2018-09-13T20:33:42+00:00"
},
{
"name": "phpunit/php-text-template",
"version": "1.2.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-text-template.git",
"reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686",
"reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "Simple template engine.",
"homepage": "https://github.com/sebastianbergmann/php-text-template/",
"keywords": [
"template"
],
"time": "2015-06-21T13:50:34+00:00"
},
{
"name": "phpunit/php-timer",
"version": "2.1.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-timer.git",
"reference": "8b389aebe1b8b0578430bda0c7c95a829608e059"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/8b389aebe1b8b0578430bda0c7c95a829608e059",
"reference": "8b389aebe1b8b0578430bda0c7c95a829608e059",
"shasum": ""
},
"require": {
"php": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "^7.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.1-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "Utility class for timing",
"homepage": "https://github.com/sebastianbergmann/php-timer/",
"keywords": [
"timer"
],
"time": "2019-02-20T10:12:59+00:00"
},
{
"name": "phpunit/php-token-stream",
"version": "3.0.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
"reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/c99e3be9d3e85f60646f152f9002d46ed7770d18",
"reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"php": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "^7.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Wrapper around PHP's tokenizer extension.",
"homepage": "https://github.com/sebastianbergmann/php-token-stream/",
"keywords": [
"tokenizer"
],
"time": "2018-10-30T05:52:18+00:00"
},
{
"name": "phpunit/phpunit",
"version": "8.1.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "b258457b6259f1e8130a91d3065c993961721f47"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b258457b6259f1e8130a91d3065c993961721f47",
"reference": "b258457b6259f1e8130a91d3065c993961721f47",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.1",
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-xml": "*",
"ext-xmlwriter": "*",
"myclabs/deep-copy": "^1.7",
"phar-io/manifest": "^1.0.2",
"phar-io/version": "^2.0",
"php": "^7.2",
"phpspec/prophecy": "^1.7",
"phpunit/php-code-coverage": "^7.0",
"phpunit/php-file-iterator": "^2.0.1",
"phpunit/php-text-template": "^1.2.1",
"phpunit/php-timer": "^2.1",
"sebastian/comparator": "^3.0",
"sebastian/diff": "^3.0",
"sebastian/environment": "^4.1",
"sebastian/exporter": "^3.1",
"sebastian/global-state": "^3.0",
"sebastian/object-enumerator": "^3.0.3",
"sebastian/resource-operations": "^2.0",
"sebastian/version": "^2.0.1"
},
"require-dev": {
"ext-pdo": "*"
},
"suggest": {
"ext-soap": "*",
"ext-xdebug": "*",
"phpunit/php-invoker": "^2.0"
},
"bin": [
"phpunit"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "8.1-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "The PHP Unit Testing framework.",
"homepage": "https://phpunit.de/",
"keywords": [
"phpunit",
"testing",
"xunit"
],
"time": "2019-04-08T05:40:17+00:00"
},
{
"name": "sebastian/code-unit-reverse-lookup",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git",
"reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18",
"reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18",
"shasum": ""
},
"require": {
"php": "^5.6 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7 || ^6.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Looks up which function or method a line of code belongs to",
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
"time": "2017-03-04T06:30:41+00:00"
},
{
"name": "sebastian/environment",
"version": "4.1.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/environment.git",
"reference": "6fda8ce1974b62b14935adc02a9ed38252eca656"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6fda8ce1974b62b14935adc02a9ed38252eca656",
"reference": "6fda8ce1974b62b14935adc02a9ed38252eca656",
"shasum": ""
},
"require": {
"php": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "^7.5"
},
"suggest": {
"ext-posix": "*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.1-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Provides functionality to handle HHVM/PHP environments",
"homepage": "http://www.github.com/sebastianbergmann/environment",
"keywords": [
"Xdebug",
"environment",
"hhvm"
],
"time": "2019-02-01T05:27:49+00:00"
},
{
"name": "sebastian/global-state",
"version": "3.0.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git",
"reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4",
"reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4",
"shasum": ""
},
"require": {
"php": "^7.2",
"sebastian/object-reflector": "^1.1.1",
"sebastian/recursion-context": "^3.0"
},
"require-dev": {
"ext-dom": "*",
"phpunit/phpunit": "^8.0"
},
"suggest": {
"ext-uopz": "*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Snapshotting of global state",
"homepage": "http://www.github.com/sebastianbergmann/global-state",
"keywords": [
"global state"
],
"time": "2019-02-01T05:30:01+00:00"
},
{
"name": "sebastian/object-enumerator",
"version": "3.0.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/object-enumerator.git",
"reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5",
"reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5",
"shasum": ""
},
"require": {
"php": "^7.0",
"sebastian/object-reflector": "^1.1.1",
"sebastian/recursion-context": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Traverses array structures and object graphs to enumerate all referenced objects",
"homepage": "https://github.com/sebastianbergmann/object-enumerator/",
"time": "2017-08-03T12:35:26+00:00"
},
{
"name": "sebastian/object-reflector",
"version": "1.1.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/object-reflector.git",
"reference": "773f97c67f28de00d397be301821b06708fca0be"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be",
"reference": "773f97c67f28de00d397be301821b06708fca0be",
"shasum": ""
},
"require": {
"php": "^7.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Allows reflection of object attributes, including inherited and non-public ones",
"homepage": "https://github.com/sebastianbergmann/object-reflector/",
"time": "2017-03-29T09:07:27+00:00"
},
{
"name": "sebastian/resource-operations",
"version": "2.0.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/resource-operations.git",
"reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/4d7a795d35b889bf80a0cc04e08d77cedfa917a9",
"reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9",
"shasum": ""
},
"require": {
"php": "^7.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Provides a list of PHP built-in functions that operate on resources",
"homepage": "https://www.github.com/sebastianbergmann/resource-operations",
"time": "2018-10-04T04:07:39+00:00"
},
{
"name": "sebastian/version",
"version": "2.0.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/version.git",
"reference": "99732be0ddb3361e16ad77b68ba41efc8e979019"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019",
"reference": "99732be0ddb3361e16ad77b68ba41efc8e979019",
"shasum": ""
},
"require": {
"php": ">=5.6"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version",
"time": "2016-10-03T07:35:21+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.11.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "82ebae02209c21113908c229e9883c419720738a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a",
"reference": "82ebae02209c21113908c229e9883c419720738a",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.11-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
},
{
"name": "Gert de Pagter",
"email": "backendtea@gmail.com"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"time": "2019-02-06T07:57:58+00:00"
},
{
"name": "theseer/tokenizer",
"version": "1.1.2",
"source": {
"type": "git",
"url": "https://github.com/theseer/tokenizer.git",
"reference": "1c42705be2b6c1de5904f8afacef5895cab44bf8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/theseer/tokenizer/zipball/1c42705be2b6c1de5904f8afacef5895cab44bf8",
"reference": "1c42705be2b6c1de5904f8afacef5895cab44bf8",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-tokenizer": "*",
"ext-xmlwriter": "*",
"php": "^7.0"
},
"type": "library",
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Arne Blankerts",
"email": "arne@blankerts.de",
"role": "Developer"
}
],
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
"time": "2019-04-04T09:56:43+00:00"
},
{
"name": "webmozart/assert",
"version": "1.4.0",
"source": {
"type": "git",
"url": "https://github.com/webmozart/assert.git",
"reference": "83e253c8e0be5b0257b881e1827274667c5c17a9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webmozart/assert/zipball/83e253c8e0be5b0257b881e1827274667c5c17a9",
"reference": "83e253c8e0be5b0257b881e1827274667c5c17a9",
"shasum": ""
},
"require": {
"php": "^5.3.3 || ^7.0",
"symfony/polyfill-ctype": "^1.8"
},
"require-dev": {
"phpunit/phpunit": "^4.6",
"sebastian/version": "^1.0.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.3-dev"
}
},
"autoload": {
"psr-4": {
"Webmozart\\Assert\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Bernhard Schussek",
"email": "bschussek@gmail.com"
}
],
"description": "Assertions to validate method input/output with nice error messages.",
"keywords": [
"assert",
"check",
"validate"
],
"time": "2018-12-25T11:19:39+00:00"
}
],
"aliases": [],
"minimum-stability": "dev",
"stability-flags": [],
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
"php": "^7.2"
},
"platform-dev": []
}
PK O(]5
CODE_OF_CONDUCT.mdnu W+A # Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
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.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at team@bovigo.org. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
PK OU~u5c 5c README.mdnu W+A bovigo/assert
==============
Provides assertions for unit tests.
Package status
--------------
[![Build Status](https://secure.travis-ci.org/bovigo/assert.png)](http://travis-ci.org/bovigo/assert) [![Build Status Windows](https://ci.appveyor.com/api/projects/status/t1u7ylbvdkbqqxyv?svg=true)](https://ci.appveyor.com/project/mikey179/assert) [![Coverage Status](https://coveralls.io/repos/github/bovigo/assert/badge.svg?branch=master)](https://coveralls.io/github/bovigo/assert?branch=master)
[![Latest Stable Version](https://poser.pugx.org/bovigo/assert/version.png)](https://packagist.org/packages/bovigo/assert) [![Latest Unstable Version](https://poser.pugx.org/bovigo/assert/v/unstable.png)](//packagist.org/packages/bovigo/assert)
Installation
------------
_bovigo/assert_ is distributed as [Composer](https://getcomposer.org/) package.
To install it as a development dependency of your package use the following
command:
composer require --dev "bovigo/assert": "^5.0"
To install it as a runtime dependency for your package use the following command:
composer require "bovigo/assert=^5.0"
Requirements
------------
_bovigo/assert_ 5.x requires at least PHP 7.2.
Why?
----
The original idea was to explore how a more functional approach to using
assertions in unit tests could look like, and if it would make for a better
reading of test code. Personally, I found the results convincing enough that I
wanted to use it in my own code, so I made a package of it.
Usage
-----
All assertions are written in the same way using functions:
```php
assertThat(303, equals(303));
assertThat($someArray, isOfSize(3), 'array always must have size 3');
```
The first parameter is the value to test, and the second is the predicate that
should be used to test the value. Additionally, an optional description can be
supplied to enhance clarity in case the assertion fails.
In case the predicate fails an `AssertionFailure` will be thrown with useful
information of why the test failed. In case PHPUnit is used `AssertionFailure`
is an instance of `\PHPUnit\Framework\AssertionFailedError` so it
integrates nicely into PHPUnit, yielding a similar test output as PHPUnit's
constraints. Here is an example of the output in case of a test failure:
```
1) bovigo\assert\predicate\RegexTest::stringRepresentationContainsRegex
Failed asserting that 'matches regular expression "/^([a-z]{3})$/"' is equal to .
--- Expected
+++ Actual
@@ @@
-'matches regular expession "/^([a-z]{3})$/"'
+'matches regular expression "/^([a-z]{3})$/"'
bovigo-assert/src/test/php/predicate/RegexTest.php:99
```
For the sake of brevity below it is assumed the used functions are imported into
the current namespace via
```php
use function bovigo\assert\assertThat;
use function bovigo\assert\predicate\isOfSize;
use function bovigo\assert\predicate\equals;
// ... and so on
```
List of predicates
------------------
This is the list of predicates that are included in _bovigo/assert_ by default.
### `isNull()`
Tests if value is `null`.
```php
assertThat($value, isNull());
```
Alias: `bovigo\assert\assertNull($value, $description = null)`
### `isNotNull()`
Tests that value is not `null`.
```php
assertThat($value, isNotNull());
```
Alias: `bovigo\assert\assertNotNull($value, $description = null)`
### `isEmpty()`
Tests that value is empty. Empty is defined as follows:
* In case the value is an instance of `\Countable` it is empty when its count
is 0.
* For all other values the rules for PHP's `empty()` apply.
```php
assertThat($value, isEmpty());
```
Aliases:
* `bovigo\assert\assertEmpty($value, $description = null)`
* `bovigo\assert\assertEmptyString($value, $description = null)`
* `bovigo\assert\assertEmptyArray($value, $description = null)`
### `isNotEmpty()`
Tests that value is not empty. See `isEmpty()` for definition of emptyness.
```php
assertThat($value, isNotEmpty());
```
Alias: `bovigo\assert\assertNotEmpty($value, $description = null)`
### `isTrue()`
Tests that a value is true. The value must be boolean true, no value conversion
is applied.
```php
assertThat($value, isTrue());
```
Alias: `bovigo\assert\assertTrue($value, $description = null)`
### `isFalse()`
Tests that a value is false. The value must be boolean false, no value
conversion is applied.
```php
assertThat($value, isFalse());
```
Alias: `bovigo\assert\assertFalse($value, $description = null)`
### `equals($expected, $delta = 0.0)`
Tests that a value equals the expected value. The optional parameter `$delta`
can be used when equality of float values should be tested and allows for a
certain range in which two floats are considered equal.
```php
assertThat($value, equals('Roland TB 303'));
```
### `isNotEqualTo($unexpected, $delta = 0.0)`
Tests that a value is not equal to the unexpected value. The optional parameter
`$delta` can be used when equality of float values should be tested and allows
for a certain range in which two floats are considered equal.
```php
assertThat($value, isNotEqualTo('Roland TB 303'));
```
### `isInstanceOf($expectedType)`
Tests that a value is an instance of the expected type.
```php
assertThat($value, isInstanceOf(\stdClass::class));
```
### `isNotInstanceOf($unexpectedType)`
Tests that a value is not an instance of the unexpected type.
```php
assertThat($value, isNotInstanceOf(\stdClass::class));
```
### `isSameAs($expected)`
Tests that a value is identical to the expected value. Both values are compared
with `===`, the according rules apply.
```php
assertThat($value, isSameAs($anotherValue));
```
### `isNotSameAs($unexpected)`
Tests that a value is not identical to the unexpected value. Both values are
compared with `===`, the according rules apply.
```php
assertThat($value, isNotSameAs($anotherValue));
```
### `isOfSize($expectedSize)`
Tests that a value has the expected size. The rules for the size are as follows:
* For strings, their length in bytes is used.
* For array and instances of `\Countable` the value of `count()` is used.
* For instances of `\Traversable` the value of `iterator_count()` is used. To
prevent moving the pointer of the traversable, `iterator_count()` is applied
against a clone of the traversable.
* All other value types will be rejected.
```php
assertThat($value, isOfSize(3));
```
### `isNotOfSize($unexpectedSize)`
Tests that a value does not have the unexpected size. The rules are the same as
for `isOfSize($expectedSize)`.
```php
assertThat($value, isNotOfSize(3));
```
### `isOfType($expectedType)`
Tests that a value is of the expected internal PHP type.
```php
assertThat($value, isOfType('resource'));
```
#### Aliases
Since release 5.0 some alias functions are provided to prevent typos in usages of that function:
* `bovigo\assert\predicate\isArray()`
* `bovigo\assert\predicate\isBool()`
* `bovigo\assert\predicate\isFloat()`
* `bovigo\assert\predicate\isInt()`
* `bovigo\assert\predicate\isNumeric()`
* `bovigo\assert\predicate\isObject()`
* `bovigo\assert\predicate\isResource()`
* `bovigo\assert\predicate\isString()`
* `bovigo\assert\predicate\isScalar()`
* `bovigo\assert\predicate\isCallable()`
* `bovigo\assert\predicate\isIterable()`
### `isNotOfType($unexpectedType)`
Tests that a value is not of the unexpected internal PHP type.
```php
assertThat($value, isNotOfType('resource'));
```
#### Aliases
Since release 5.0 some alias functions are provided to prevent typos in usages of that function. Please note that some are specific to ensure the code you write with them forms a grammatically valid sentence.
* `bovigo\assert\predicate\isNotAnArray()`
* `bovigo\assert\predicate\isNotBool()`
* `bovigo\assert\predicate\isNotFloat()`
* `bovigo\assert\predicate\isNotInt()`
* `bovigo\assert\predicate\isNotNumeric()`
* `bovigo\assert\predicate\isNotAnObject()`
* `bovigo\assert\predicate\isNotAResource()`
* `bovigo\assert\predicate\isNotAString()`
* `bovigo\assert\predicate\isNotScalar()`
* `bovigo\assert\predicate\isNotCallable()`
* `bovigo\assert\predicate\isNotIterable()`
### `isGreaterThan($expected)`
Tests that a value is greater than the expected value.
```php
assertThat($value, isGreaterThan(3));
```
### `isGreaterThanOrEqualTo($expected)`
Tests that a value is greater than or equal to the expected value.
```php
assertThat($value, isGreaterThanOrEqualTo(3));
```
### `isLessThan($expected)`
Tests that a value is less than the expected value.
```php
assertThat($value, isLessThan(3));
```
### `isLessThanOrEqualTo($expected)`
Tests that a value is less than or equal to the expected value.
```php
assertThat($value, isLessThanOrEqualTo(3));
```
### `contains($needle)`
Tests that `$needle` is contained in value. The following rules apply:
* `null` is contained in `null`.
* A string can be contained in another string. The comparison is case sensitive.
* `$needle` can be a value of an array or a `\Traversable`. Value and `$needle`
are compared with `===`.
* For all other cases, the value is rejected.
```php
assertThat($value, contains('Roland TB 303'));
```
Sometimes it is necessary to differentiate between arrays, Traversables and strings.
If a particular type should be enforced it is recommended to combine predicates:
```php
assertThat($value, isArray()->and(contains('Roland TB 303')));
assertThat($value, isString()->and(contains('Roland TB 303')));
assertThat($value, isInstanceOf(\Iterator::class)->and(contains('Roland TB 303')));
```
### `doesNotContain($needle)`
Tests that `$needle` is not contained in value. The rules of `contains($needle)`
apply.
```php
assertThat($value, doesNotContain('Roland TB 303'));
```
### `hasKey($key)`
Tests that an array or an instance of `\ArrayAccess` have a key with given name.
The key must be either of type `integer` or `string`. Values that are neither an
array nor an instance of `\ArrayAccess` are rejected.
```php
assertThat($value, hasKey('roland'));
```
### `doesNotHaveKey($key)`
Tests that an array or an instance of `\ArrayAccess` does not have a key with
given name. The key must be either of type `integer` or `string`. Values that
are neither an array nor an instance of `\ArrayAccess` are rejected.
```php
assertThat($value, doesNotHaveKey('roland'));
```
### `matches($pattern)`
Tests that a string matches the given pattern of a regular expression. If the
value is not a string it is rejected. The test is successful if the pattern
yields at least one match in the value.
```php
assertThat($value, matches('/^([a-z]{3})$/'));
```
### `doesNotMatch($pattern)`
Tests that a string does not match the given pattern of a regular expression. If
the value is not a string it is rejected. The test is successful if the pattern
yields no match in the value.
```php
assertThat($value, doesNotMatch('/^([a-z]{3})$/'));
```
### `matchesFormat($format)`
_Available since release 3.2.0._
Tests that a string matches the given PHP format expression. If the value is not
a string it is rejected. The test is successful if the format yields at least
one match in the value. The format string may contain the following placeholders:
* `%e`: Represents a directory separator, for example / on Linux.
* `%s`: One or more of anything (character or white space) except the end of line character.
* `%S`: Zero or more of anything (character or white space) except the end of line character.
* `%a`: One or more of anything (character or white space) including the end of line character.
* `%A`: Zero or more of anything (character or white space) including the end of line character.
* `%w`: Zero or more white space characters.
* `%i`: A signed integer value, for example +3142, -3142.
* `%d`: An unsigned integer value, for example 123456.
* `%x`: One or more hexadecimal character. That is, characters in the range 0-9, a-f, A-F.
* `%f`: A floating point number, for example: 3.142, -3.142, 3.142E-10, 3.142e+10.
* `%c`: A single character of any sort.
```php
assertThat($value, matchesFormat('%w'));
```
### `doesNotMatchFormat($format)`
_Available since release 3.2.0._
Tests that a string does not match the given PHP format expression. If the value
is not a string it is rejected. The test is successful if the pattern yields no
match in the value. See above for a list of possible formats.
```php
assertThat($value, doesNotMatchFormat('%w'));
```
### `isExistingFile($basePath = null)`
Tests that the value denotes an existing file. If no `$basepath` is supplied the
value must either be an absolute path or a relative path to the current working
directory. When `$basepath` is given the value must be a relative path to this
basepath.
```php
assertThat($value, isExistingFile());
assertThat($value, isExistingFile('/path/to/files'));
```
### `isNonExistingFile($basePath = null)`
Tests that the value denotes a file which does not exist. If no `$basepath` is
supplied the value must either be an absolute path or a relative path to the
current working directory. When `$basepath` is given the value must be a
relative path to this basepath.
```php
assertThat($value, isNonExistingFile());
assertThat($value, isNonExistingFile('/path/to/files'));
```
### `isExistingDirectory($basePath = null)`
Tests that the value denotes an existing directory. If no `$basepath` is
supplied the value must either be an absolute path or a relative path to the
current working directory. When `$basepath` is given the value must be a
relative path to this basepath.
```php
assertThat($value, isExistingDirectory());
assertThat($value, isExistingDirectory('/path/to/directories'));
```
### `isNonExistingDirectory($basePath = null)`
Tests that the value denotes a non-existing directory. If no `$basepath` is
supplied the value must either be an absolute path or a relative path to the
current working directory. When `$basepath` is given the value must be a
relative path to this basepath.
```php
assertThat($value, isNonExistingDirectory());
assertThat($value, isNonExistingDirectory('/path/to/directories'));
```
### `startsWith($prefix)`
_Available since release 1.1.0._
Tests that the value which must be a string starts with given prefix.
```php
assertThat($value, startsWith('foo'));
```
### `doesNotStartWith($prefix)`
_Available since release 1.1.0._
Tests that the value which must be a string does not start with given prefix.
```php
assertThat($value, startsWith('foo'));
```
### `endsWith($suffix)`
_Available since release 1.1.0._
Tests that the value which must be a string ends with given suffix.
```php
assertThat($value, endsWith('foo'));
```
### `doesNotEndWith($suffix)`
_Available since release 1.1.0._
Tests that the value which must be a string does not end with given suffix.
```php
assertThat($value, doesNotEndWith('foo'));
```
### `each($predicate)`
_Available since release 1.1.0._
Applies a predicate to each value of an array or traversable.
```php
assertThat($value, each(isInstanceOf($expectedType));
```
Please note that an empty array or traversable will result in a successful test.
If it must not be empty use `isNotEmpty()->and(each($predicate))`:
```php
assertThat($value, isNotEmpty()->and(each(isInstanceOf($expectedType))));
```
It can also be used with any callable:
```php
assertThat($value, each('is_nan'));
assertThat($value, each(function($value) { return substr($value, 4, 3) === 'foo'; }));
```
### `eachKey($predicate)`
_Available since release 1.3.0._
Applies a predicate to each key of an array or traversable.
```php
assertThat($value, eachKey(isOfType('int'));
```
Please note that an empty array or traversable will result in a successful test.
If it must not be empty use `isNotEmpty()->and(eachKey($predicate))`:
```php
assertThat($value, isNotEmpty()->and(eachKey(isOfType('int'))));
```
It can also be used with any callable:
```php
assertThat($value, eachKey('is_int'));
assertThat($value, eachKey(function($value) { return substr($value, 4, 3) === 'foo'; }));
```
### `not($predicate)`
Reverses the meaning of a predicate.
```php
assertThat($value, not(isTrue()));
```
It can also be used with any callable:
```php
assertThat($value, not('is_nan'));
assertThat($value, not(function($value) { return substr($value, 4, 3) === 'foo'; }));
```
Combining predicates
--------------------
Each predicate provides both two methods to combine this predicate with another
predicate into a new predicate.
### `and($predicate)`
Creates a predicate where both combined predicate must be `true` so that the
combined predicate is `true` as well. If one of the predicates fails, the
combined predicate will fail as well.
```php
assertThat($value, isNotEmpty()->and(eachKey(isOfType('int'))));
```
It can also be used with any callable:
```php
assertThat($value, isNotEmpty()->and('is_string'));
```
### `or($predicate)`
Creates a predicate where one of the combined predicates must be `true`. Only if
all predicates fail the combined predicate will fail as well.
```php
assertThat($value, equals(5)->or(isLessThan(5)));
```
It can also be used with any callable:
```php
assertThat($value, isNull()->or('is_finite'));
```
User defined predicates
-----------------------
To define a predicate to be used in an assertion there are two possibilities:
### Use a callable
You can pass anything that is a `callable` to the `assertThat()` function:
```php
assertThat($value, 'is_nan');
```
This will create a predicate which uses PHP's builtin `is_nan()` function to
test the value.
The callable should accept a single value (the value to test, obviously) and
must return `true` on success and `false` on failure. It is also allowed to
throw any exception.
Here is an example with a closure:
```php
assertThat(
$value,
function($value)
{
if (!is_string($value)) {
throw new \InvalidArgumentException(
'Given value is not a string.'
);
}
return substr($value, 4, 3) === 'foo';
}
);
```
### Extend `bovigo\assert\predicate\Predicate`
The other possibility is to extend the `bovigo\assert\predicate\Predicate` class.
You need to implement at least the following methods:
#### `public function test($value)`
This method receives the value to test and should return `true` on success and
`false` on failure. It is also allowed to throw any exception.
#### `public function __toString()`
This method must return a proper description of the predicate which fits into
the sentences shown when an asssertion fails. These sentences are composed as
follows:
_Failed asserting that [description of value] [description of predicate]._
Additionally, the predicate can influence _[description of value]_ by overriding
the `describeValue(Exporter $exporter, $value)` method.
Instant failure
---------------
_Available since release 1.2.0._
In case assertions are not enough and the test needs to fail when it reaches a
certain point, `bovigo\assert\fail($description)` can be used to trigger an
instant assertion failure:
```php
try {
somethingThatThrowsFooException();
fail('Expected ' . FooException::class . ', gone none');
} catch (FooException $fo) {
// some assertions on FooException
}
```
Expectations
------------
_Available since release 1.6.0_
Expectations can be used to check that a specific piece of code does or does not
throw an exception or trigger an error. It can also be used to check that after
a specific piece of code ran assertions are still true, despite of whether the
code in question succeeded or not.
### Expectations on exceptions
Note: since release 2.1.0 it is also possible to use expectations with `\Error`.
Check that a piece of code, e.g. a function or method, throws an exception:
```php
expect(function() {
// some piece of code which is expected to throw SomeException
})->throws(SomeException::class);
```
It is also possible to expect any exception, not just a specific one, by leaving
out the class name of the exception:
```php
expect(function() {
// some piece of code which is expected to throw any exception
})->throws();
```
Since release 2.1.0 it is possible to verify that exactly a given exception was
thrown:
```php
$exception = new \Exception('failure');
expect(function() use ($exception) {
throw $exception;
})->throws($exception);
```
This will perform an assertion with `isSameAs($exception)` for the thrown
exception.
Additionally checks on the thrown exception can be performed:
```php
expect(function() {
// some piece of code which is expected to throw SomeException
})
->throws(SomeException::class)
->withMessage('some failure occured');
```
The following checks on the exception are possible:
* `withMessage(string $expectedMessage)`
Performs an assertion with `equals()` on the exception message.
* `message($predicate)`
Performs an assertion with the given predicate on the exception message.
* `withCode(int $expectedCode)`
Performs an assertion with `equals()` on the exception code.
* `with($predicate)`
Performs an assertion on the whole exception with given predicate. The
predicate will receive the exception as argument and can perform any check.
```php
expect(function() {
// some piece of code which is expected to throw SomeException
})
->throws(SomeException::class)
->with(
function(SomeException $e) { return null !== $e->getPrevious(); },
'exception does have a previous exception'
);
```
Of course you can also check that a specific exception did not occur:
```php
expect(function() {
// some piece of code which is expected to not throw SomeException
})->doesNotThrow(SomeException::class);
```
By leaving out the exception name you ensure that the code doesn't throw any
exception at all:
```php
expect(function() {
// some piece of code which is expected to not throw any exception
})->doesNotThrow();
```
In case any of these expectations fail an `AssertionFailure` will be thrown.
### Expectations on errors
_Available since release 2.1.0_
Check that a piece of code, e.g. a function or method, triggers an error:
```php
expect(function() {
// some piece of code which is expected to trigger an error
})->triggers(E_USER_ERROR);
```
It is also possible to expect any error, not just a specific one, by leaving
out the error level:
```php
expect(function() {
// some piece of code which is expected to trigger an error
})->triggers();
```
Additionally checks on the triggered error can be performed:
```php
expect(function() {
// some piece of code which is expected to trigger an error
})
->triggers(E_USER_WARNING)
->withMessage('some error occured');
```
The following checks on the exception are possible:
* `withMessage(string $expectedMessage)`
Performs an assertion with `equals()` on the error message.
* `message($predicate)`
Performs an assertion with the given predicate on the error message.
In case any of these expectations fail an `AssertionFailure` will be thrown.
### Expectations on state after a piece of code was executed
Sometimes it may be useful to assert that a certain state exists after some
piece of code is executed, regardless of whether this execution succeeds.
```php
expect(function() {
// some piece of code here
})
->after(SomeClass::$value, equals(303));
```
It is possible to combine this with expectations on whether an exception is
thrown or not:
```php
expect(function() {
// some piece of code here
})
->doesNotThrow()
->after(SomeClass::$value, equals(303));
expect(function() {
// some piece of code here
})
->throws(SomeException::class)
->after(SomeClass::$value, equals(303));
```
Verify output of a function or method
-------------------------------------
_Available since release 2.1.0_
When a function or method utilizes `echo` it can be cumbersome to check if it
prints the correct output. For this, the `outputOf()` function was introduced:
```php
outputOf(
function() { echo 'Hello you!'; },
equals('Hello world!')
);
```
The first parameter is a callable which prints some output, the second is any
predicate which will than be applied to the output. `outputOf()` takes care of
enabling and disabling output buffering to catch the output.
PHPUnit compatibility layer
---------------------------
In case you want to check out how _bovigo/assert_ works with your tests there is
a PHPUnit compatibility layer available. Instead of extending directly from
`\PHPUnit\Framework\TestCase` let your tests extend
`bovigo\assert\phpunit\TestCase`. It overlays all constraints
from PHPUnit with predicates from _bovigo/assert_ where they are available.
For constraints which have no equivalent predicate in _bovigo/assert_ the
default constraints from PHPUnit are used.
FAQ
---
### How can I access a property of a class or object for the assertions?
Unlike PHPUnit _bovigo/assert_ does not provide means to assert that a property
of a class fullfills a certain constraint. If the property is public you can
pass it directly into the `assertThat()` function as a value. In any other case
_bovigo/assert_ does not support accessing protected or private properties.
There's a reason why they are protected or private, and a test should only be
against the public API of a class, not against their inner workings.
PK O
.gitignorenu W+A docs/*
vendor
PK OLK>y\ \ src/main/php/Expectation.phpnu W+A code = $code;
}
/**
* runs code and returns result
*
* @return mixed
*/
private function runCode()
{
if ($this->executed) {
return $this->result;
}
$code = $this->code;
try {
$this->result = $code();
} catch (\Throwable $ex) {
$this->exception = $ex;
} finally {
$this->executed = true;
}
return $this->result;
}
/**
* asserts the code throws an exception when executed
*
* If no expected is given any thrown exception will be sufficient.
*
* @api
* @param string|\Throwable $expected optional type of exception or the exact exception
* @return \bovigo\assert\CatchedException
* @throws \bovigo\assert\AssertionFailure
* @throws \InvalidArgumentException
*/
public function throws($expected = null): CatchedException
{
$this->runCode();
if (null === $this->exception) {
throw new AssertionFailure(
'Failed asserting that '
. (null !== $expected
? 'exception of type "' . (is_string($expected) ? $expected : get_class($expected)) . '"'
: 'an exception'
)
. ' is thrown.'
);
} elseif (null !== $expected) {
if (is_string($expected)) {
$isExpected = new ExpectedException($expected);
} elseif ($expected instanceof \Throwable) {
$isExpected = isSameAs($expected);
} else {
throw new \InvalidArgumentException(
'Given expected is neither a class name nor an instance'
. ' of \Throwable, but of type ' . gettype($expected)
);
}
assertThat($this->exception, $isExpected);
}
return new CatchedException($this->exception);
}
/**
* asserts that code does not throw an exception when executed
*
* If no expected type is given the code is not allowed to throw any
* exception.
*
* @api
* @param string $unexpectedType optional type of exception which should not be thrown
* @return \bovigo\assert\Expectation
* @throws \bovigo\assert\AssertionFailure
*/
public function doesNotThrow(string $unexpectedType = null): self
{
increaseAssertionCounter(1);
$this->runCode();
if (null !== $this->exception
&& (null === $unexpectedType || $this->exception instanceof $unexpectedType)) {
throw new AssertionFailure(
'Failed asserting that no exception'
. (null !== $unexpectedType
? ' of type "' . $unexpectedType . '"'
: ''
)
. ' is thrown, got ' . get_class($this->exception)
. ' with message "' . $this->exception->getMessage() . '".'
);
}
return $this;
}
/**
* asserts the code triggers an error when executed
*
* If no expected error level is given any triggered error will be sufficient.
*
* @api
* @param int $expectedError optional error level to expect
* @return \bovigo\assert\CatchedError
* @throws \InvalidArgumentException in case the given expected error is unknown
* @throws \bovigo\assert\AssertionFailure
* @since 2.1.0
*/
public function triggers(int $expectedError = null): CatchedError
{
if (null !== $expectedError && !CatchedError::knowsLevel($expectedError)) {
throw new \InvalidArgumentException('Unknown error level ' . $expectedError);
}
set_error_handler(
function(int $errno , string $errstr, string $errfile, int $errline, array $errcontext): bool
{
$this->error = new CatchedError($errno, $errstr, $errfile, $errline, $errcontext);
return true;
}
);
$this->runCode();
restore_error_handler();
if (null === $this->error) {
throw new AssertionFailure(
'Failed asserting that '
. (null !== $expectedError
? 'error of type "' . CatchedError::nameOf($expectedError) . '"'
: 'an error'
)
. ' is triggered.'
);
} elseif (null !== $expectedError) {
assertThat($this->error, new ExpectedError($expectedError));
}
return $this->error;
}
/**
* asserts result of executed code fulfills a predicate
*
* @param \bovigo\assert\predicate\Predicate|callable $predicate predicate or callable to test given value
* @param string $description optional additional description for failure message
* @return \bovigo\assert\Expectation
*/
public function result(callable $predicate, string $description = null): self
{
$this->runCode();
if (null !== $this->exception) {
throw new AssertionFailure(
'Failed asserting that result '
. Predicate::castFrom($predicate)
. ' because exception of type '
. get_class($this->exception)
. ' with message "' . $this->exception->getMessage()
. '" was thrown.'
);
}
assertThat($this->result, $predicate, $description);
return $this;
}
/**
* asserts anything after the code was executed, even if it threw an exception
*
* @api
* @param mixed $value value to test
* @param \bovigo\assert\predicate\Predicate|callable $predicate predicate or callable to test given value
* @param string $description optional additional description for failure message
* @return \bovigo\assert\Expectation
*/
public function after($value, callable $predicate, string $description = null): self
{
$this->runCode();
assertThat($value, $predicate, $description);
return $this;
}
}
PK O9?h h ! src/main/php/AssertionFailure.phpnu W+A actualException = $actualException;
}
/**
* asserts actual exception equals expected message
*
* @api
* @param string $expectedMessage
* @return \bovigo\assert\CatchedException
*/
public function withMessage(string $expectedMessage): self
{
return $this->message(equals($expectedMessage));
}
/**
* asserts actual exception fulfills given predicate
*
* @api
* @param \bovigo\assert\predicate\Predicate|callable $predicate
* @return \bovigo\assert\CatchedException
*/
public function message(callable $predicate): self
{
assertThat(
$this->actualException->getMessage(),
new Wrap(Predicate::castFrom($predicate), 'exception message %s')
);
return $this;
}
/**
* asserts actual exception code equals expected code
*
* @api
* @param int $expectedCode
* @return \bovigo\assert\CatchedException
*/
public function withCode(int $expectedCode): self
{
assertThat(
$this->actualException->getCode(),
new Wrap(equals($expectedCode), 'exception code %s')
);
return $this;
}
/**
* asserts actual exception fulfills predicate
*
* @api
* @param \bovigo\assert\predicate\Predicate|callable $predicate
* @param string $description optional additional description for failure message
* @return \bovigo\assert\CatchedException
*/
public function with(callable $predicate, string $description = null): self
{
assertThat($this->actualException, $predicate, $description);
return $this;
}
/**
* asserts anything after the exception was catched
*
* @api
* @param mixed $value value to test
* @param \bovigo\assert\predicate\Predicate|callable $predicate predicate or callable to test given value
* @param string $description optional additional description for failure message
* @return \bovigo\assert\CatchedException
*/
public function after($value, callable $predicate, string $description = null): self
{
assertThat($value, $predicate, $description);
return $this;
}
}
PK Oa[ src/main/php/CatchedError.phpnu W+A 'E_ERROR',
E_WARNING => 'E_WARNING',
E_PARSE => 'E_PARSE',
E_NOTICE => 'E_NOTICE',
E_CORE_ERROR => 'E_CORE_ERROR',
E_CORE_WARNING => 'E_CORE_WARNING',
E_COMPILE_ERROR => 'E_COMPILE_ERROR',
E_COMPILE_WARNING => 'E_COMPILE_WARNING',
E_USER_ERROR => 'E_USER_ERROR',
E_USER_WARNING => 'E_USER_WARNING',
E_USER_NOTICE => 'E_USER_NOTICE',
E_STRICT => 'E_STRICT',
E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
E_DEPRECATED => 'E_DEPRECATED',
E_USER_DEPRECATED => 'E_USER_DEPRECATED',
E_ALL => 'E_ALL'
];
/**
* checks whether a given error level value is known
*
* @since 3.0.0
* @param int $level
* @return bool
*/
public static function knowsLevel(int $level): bool
{
return isset(CatchedError::LEVEL[$level]);
}
/**
* returns the name of the integer error level
*
* @param int $level
* @return string
*/
public static function nameOf(int $level): string
{
return self::LEVEL[$level] ?? 'Unknown error ' . $level;
}
private $errno;
private $errstr;
private $errfile;
private $errline;
private $errcontext;
/**
* constructor
*
* @param int $errno
* @param string $errstr
* @param string $errfile
* @param int $errline
* @param array $errcontext
*/
public function __construct(int $errno , string $errstr, string $errfile, int $errline, array $errcontext = [])
{
$this->errno = $errno;
$this->errstr = $errstr;
$this->errfile = $errfile;
$this->errline = $errline;
$this->errcontext = $errcontext;
}
/**
* returns the error level of the catched error
*
* @return int
*/
public function level(): int
{
return $this->errno;
}
/**
* returns the error level name of the catched error
*
* @return string
*/
public function name(): string
{
return self::nameOf($this->errno);
}
/**
* returns the actual error strin, i.e. the error message
*
* @return string
*/
public function errstr(): string
{
return $this->errstr;
}
/**
* asserts actual error message equals expected message
*
* @api
* @param string $expectedMessage
* @return \bovigo\assert\CatchedError
*/
public function withMessage(string $expectedMessage): self
{
return $this->message(equals($expectedMessage));
}
/**
* asserts actual error message fulfills given predicate
*
* @api
* @param \bovigo\assert\predicate\Predicate|callable $predicate
* @return \bovigo\assert\CatchedError
*/
public function message(callable $predicate): self
{
assertThat($this->errstr, new Wrap(Predicate::castFrom($predicate), 'error message %s'));
return $this;
}
/**
* returns file in which the error was triggered
*
* @return string
*/
public function file(): string
{
return $this->errfile;
}
/**
* returns the line on which the error was triggered
*
* @return int
*/
public function line(): int
{
return $this->errline;
}
/**
* asserts anything after the error was catched
*
* @api
* @param mixed $value value to test
* @param \bovigo\assert\predicate\Predicate|callable $predicate predicate or callable to test given value
* @param string $description optional additional description for failure message
* @return \bovigo\assert\CatchedError
*/
public function after($value, callable $predicate, string $description = null): self
{
assertThat($value, $predicate, $description);
return $this;
}
}
PK OBVe Ve ! src/main/php/phpunit/TestCase.phpnu W+A .
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* 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.
*
* * 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.
*
* 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.
*/
namespace bovigo\assert\phpunit;
use PHPUnit\Framework\TestCase as Original;
use PHPUnit\Framework\Constraint\Constraint;
use PHPUnit\Util\Type;
use function bovigo\assert\{
assertThat,
assertEmpty,
assertFalse,
assertNotEmpty,
assertNotNull,
assertNull,
assertTrue
};
use function bovigo\assert\predicate\{
contains,
doesNotContain,
doesNotEndWith,
doesNotHaveKey,
doesNotMatch,
doesNotMatchFormat,
doesNotStartWith,
each,
endsWith,
equals,
hasKey,
isExistingDirectory,
isExistingFile,
isGreaterThan,
isGreaterThanOrEqualTo,
isInstanceOf,
isLessThan,
isLessThanOrEqualTo,
isNonExistingDirectory,
isNonExistingFile,
isNotEqualTo,
isNotInstanceOf,
isNotOfSize,
isNotOfType,
isNotSameAs,
isOfSize,
isOfType,
isSameAs,
matches,
matchesFormat,
startsWith
};
/**
* Compatibility layer to use bovigo/assert in $this->assert*() style.
*
* Please note that it only overlays constraints supported by bovigo/assert. All
* other constraints are PHPUnit's original constraints.
*
* @api
*/
abstract class TestCase extends Original
{
/**
* Asserts that an array has a specified key.
*
* @param mixed $key
* @param array|\ArrayAccess $array
* @param string $message
*/
public static function assertArrayHasKey($key, $array, string $message = ''): void
{
assertThat($array, hasKey($key), $message);
}
/**
* Asserts that an array does not have a specified key.
*
* @param mixed $key
* @param array|\ArrayAccess $array
* @param string $message
*/
public static function assertArrayNotHasKey($key, $array, string $message = ''): void
{
assertThat($array, doesNotHaveKey($key), $message);
}
/**
* Asserts that a haystack contains a needle.
*
* Please note that setting $ignoreCase, $checkForObjectIdentity or
* $checkForNonObjectIdentity to a non-default value will cause a fallback
* to PHPUnit's constraint.
*
* @param mixed $needle
* @param mixed $haystack
* @param string $message
* @param bool $ignoreCase
* @param bool $checkForObjectIdentity
* @param bool $checkForNonObjectIdentity
*/
public static function assertContains($needle, $haystack, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false): void
{
if (true === $ignoreCase || false === $checkForObjectIdentity || true === $checkForNonObjectIdentity) {
parent::assertContains($needle, $haystack, $message, $ignoreCase, $checkForObjectIdentity, $checkForNonObjectIdentity);
} else {
assertThat($haystack, contains($needle), $message);
}
}
/**
* Asserts that a haystack does not contain a needle.
*
* Please note that setting $ignoreCase, $checkForObjectIdentity or
* $checkForNonObjectIdentity to a non-default value will cause a fallback
* to PHPUnit's constraint.
*
* @param mixed $needle
* @param mixed $haystack
* @param string $message
* @param bool $ignoreCase
* @param bool $checkForObjectIdentity
* @param bool $checkForNonObjectIdentity
*/
public static function assertNotContains($needle, $haystack, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false): void
{
if (true === $ignoreCase || false === $checkForObjectIdentity || true === $checkForNonObjectIdentity) {
parent::assertNotContains($needle, $haystack, $message, $ignoreCase, $checkForObjectIdentity, $checkForNonObjectIdentity);
} else {
assertThat($haystack, doesNotContain($needle), $message);
}
}
/**
* Asserts that a haystack contains only values of a given type.
*
* @param string $type
* @param iterable $haystack
* @param bool $isNativeType
* @param string $message
* @since 1.1.0
*/
public static function assertContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = null, string $message = ''): void
{
if (null === $isNativeType) {
$isNativeType = Type::isType($type);
}
if (false === $isNativeType) {
self::assertContainsOnlyInstancesOf($type, $haystack, $message);
} else {
assertThat($haystack, each(isOfType($type)), $message);
}
}
/**
* Asserts that a haystack contains only instances of a given classname
*
* @param string $classname
* @param iterable $haystack
* @param string $message
* @since 1.1.0
*/
public static function assertContainsOnlyInstancesOf(string $classname, iterable $haystack, string $message = ''): void
{
assertThat($haystack, each(isInstanceOf($classname)), $message);
}
/**
* Asserts that a haystack does not contain only values of a given type.
*
* @param string $type
* @param iterable $haystack
* @param bool $isNativeType
* @param string $message
* @since 1.1.0
*/
public static function assertNotContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = null, string $message = ''): void
{
if (null === $isNativeType) {
$isNativeType = Type::isType($type);
}
assertThat(
$haystack,
each(false === $isNativeType ? isNotInstanceOf($type) : isNotOfType($type)),
$message
);
}
/**
* Asserts the number of elements of an array, Countable or Traversable.
*
* @param int $expectedCount
* @param mixed $haystack
* @param string $message
*/
public static function assertCount(int $expectedCount, $haystack, string $message = ''): void
{
assertThat($haystack, isOfSize($expectedCount), $message);
}
/**
* Asserts the number of elements of an array, Countable or Traversable.
*
* @param int $expectedCount
* @param mixed $haystack
* @param string $message
*/
public static function assertNotCount(int $expectedCount, $haystack, string $message = ''): void
{
assertThat($haystack, isNotOfSize($expectedCount), $message);
}
/**
* Asserts that two variables are equal.
*
* Please note that setting $canonicalize or $ignoreCase to true will cause
* a fallback to PHPUnit's constraint.
*
* @param mixed $expected
* @param mixed $actual
* @param string $message
* @param float $delta
* @param int $maxDepth ignored, same as in PHPUnit
* @param bool $canonicalize
* @param bool $ignoreCase
*/
public static function assertEquals($expected, $actual, string $message = '', float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false): void
{
if (true === $canonicalize || true === $ignoreCase) {
parent::assertEquals($expected, $actual, $message, $delta, $maxDepth, $canonicalize, $ignoreCase);
} else {
assertThat($actual, equals($expected, $delta), $message);
}
}
/**
* Asserts that two variables are not equal.
*
* Please note that setting $canonicalize or $ignoreCase to true will cause
* a fallback to PHPUnit's constraint.
*
* @param mixed $expected
* @param mixed $actual
* @param string $message
* @param float $delta
* @param int $maxDepth ignored, same as in PHPUnit
* @param bool $canonicalize
* @param bool $ignoreCase
*/
public static function assertNotEquals($expected, $actual, string $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false): void
{
if (true === $canonicalize || true === $ignoreCase) {
parent::assertNotEquals($expected, $actual, $message, $delta, $maxDepth, $canonicalize, $ignoreCase);
} else {
assertThat($actual, isNotEqualTo($expected, $delta), $message);
}
}
/**
* Asserts that a variable is empty.
*
* @param mixed $actual
* @param string $message
*/
public static function assertEmpty($actual, string $message = ''): void
{
assertEmpty($actual, $message);
}
/**
* Asserts that a variable is not empty.
*
* @param mixed $actual
* @param string $message
*/
public static function assertNotEmpty($actual, string $message = ''): void
{
assertNotEmpty($actual, $message);
}
/**
* Asserts that a value is greater than another value.
*
* @param mixed $expected
* @param mixed $actual
* @param string $message
*/
public static function assertGreaterThan($expected, $actual, string $message = ''): void
{
assertThat($actual, isGreaterThan($expected), $message);
}
/**
* Asserts that a value is greater than or equal to another value.
*
* @param mixed $expected
* @param mixed $actual
* @param string $message
*/
public static function assertGreaterThanOrEqual($expected, $actual, string $message = ''): void
{
assertThat($actual, isGreaterThanOrEqualTo($expected), $message);
}
/**
* Asserts that a value is smaller than another value.
*
* @param mixed $expected
* @param mixed $actual
* @param string $message
*/
public static function assertLessThan($expected, $actual, string $message = ''): void
{
assertThat($actual, isLessThan($expected), $message);
}
/**
* Asserts that a value is smaller than or equal to another value.
*
* @param mixed $expected
* @param mixed $actual
* @param string $message
*/
public static function assertLessThanOrEqual($expected, $actual, string $message = ''): void
{
assertThat($actual, isLessThanOrEqualTo($expected), $message);
}
/**
* Asserts that a file exists.
*
* @param string $filename
* @param string $message
*/
public static function assertFileExists(string $filename, string $message = ''): void
{
assertThat($filename, isExistingFile()->or(isExistingDirectory()), $message);
}
/**
* Asserts that a file does not exist.
*
* @param string $filename
* @param string $message
*/
public static function assertFileNotExists(string $filename, string $message = ''): void
{
assertThat($filename, isNonExistingFile()->and(isNonExistingDirectory()), $message);
}
/**
* Asserts that a condition is true.
*
* @param bool $condition
* @param string $message
*/
public static function assertTrue($condition, string $message = ''): void
{
assertTrue($condition, $message);
}
/**
* Asserts that a condition is false.
*
* @param bool $condition
* @param string $message
*/
public static function assertFalse($condition, string $message = ''): void
{
assertFalse($condition, $message);
}
/**
* Asserts that a variable is not null.
*
* @param mixed $actual
* @param string $message
*/
public static function assertNotNull($actual, string $message = ''): void
{
assertNotNull($actual, $message);
}
/**
* Asserts that a variable is null.
*
* @param mixed $actual
* @param string $message
*/
public static function assertNull($actual, string $message = ''): void
{
assertNull($actual, $message);
}
/**
* Asserts that a variable is finite.
*
* @param mixed $actual
* @param string $message
* @since 1.1.0
*/
public static function assertFinite($actual, string $message = ''): void
{
assertThat($actual, 'is_finite', $message);
}
/**
* Asserts that a variable is infinite.
*
* @param mixed $actual
* @param string $message
* @since 1.1.0
*/
public static function assertInfinite($actual, string $message = ''): void
{
assertThat($actual, 'is_infinite', $message);
}
/**
* Asserts that a variable is nan.
*
* @param mixed $actual
* @param string $message
* @since 1.1.0
*/
public static function assertNan($actual, string $message = ''): void
{
assertThat($actual, 'is_nan', $message);
}
/**
* Asserts that two variables have the same type and value.
* Used on objects, it asserts that two variables reference
* the same object.
*
* @param mixed $expected
* @param mixed $actual
* @param string $message
*/
public static function assertSame($expected, $actual, string $message = ''): void
{
assertThat($actual, isSameAs($expected), $message);
}
/**
* Asserts that two variables do not have the same type and value.
* Used on objects, it asserts that two variables do not reference
* the same object.
*
* @param mixed $expected
* @param mixed $actual
* @param string $message
*/
public static function assertNotSame($expected, $actual, string $message = ''): void
{
assertThat($actual, isNotSameAs($expected), $message);
}
/**
* Asserts that a variable is of a given type.
*
* @param string $expected
* @param mixed $actual
* @param string $message
*/
public static function assertInstanceOf(string $expected, $actual, string $message = ''): void
{
assertThat($actual, isInstanceOf($expected), $message);
}
/**
* Asserts that a variable is not of a given type.
*
* @param string $expected
* @param mixed $actual
* @param string $message
*/
public static function assertNotInstanceOf(string $expected, $actual, string $message = ''): void
{
assertThat($actual, isNotInstanceOf($expected), $message);
}
/**
* Asserts that a variable is of a given type.
*
* @param string $expected
* @param mixed $actual
* @param string $message
*/
public static function assertInternalType(string $expected, $actual, string $message = ''): void
{
assertThat($actual, isOfType($expected), $message);
}
/**
* Asserts that a variable is not of a given type.
*
* @param string $expected
* @param mixed $actual
* @param string $message
*/
public static function assertNotInternalType(string $expected, $actual, string $message = ''): void
{
assertThat($actual, isNotOfType($expected), $message);
}
/**
* Asserts that a string matches a given regular expression.
*
* @param string $pattern
* @param string $string
* @param string $message
*/
public static function assertRegExp(string $pattern, string $string, string $message = ''): void
{
assertThat($string, matches($pattern), $message);
}
/**
* Asserts that a string does not match a given regular expression.
*
* @param string $pattern
* @param string $string
* @param string $message
*/
public static function assertNotRegExp(string $pattern, string $string, string $message = ''): void
{
assertThat($string, doesNotMatch($pattern), $message);
}
/**
* Asserts that a string matches a given format string.
*
* @param string $format
* @param string $string
* @param string $message
*/
public static function assertStringMatchesFormat(string $format, string $string, string $message = ''): void
{
assertThat($string, matchesFormat($format), $message);
}
/**
* Asserts that a string does not match a given format string.
*
* @param string $format
* @param string $string
* @param string $message
*/
public static function assertStringNotMatchesFormat(string $format, string $string, string $message = ''): void
{
assertThat($string, doesNotMatchFormat($format), $message);
}
/**
* Asserts that a string starts with a given prefix.
*
* @param string $prefix
* @param string $string
* @param string $message
* @since 1.1.0
*/
public static function assertStringStartsWith(string $prefix, string $string, string $message = ''): void
{
assertThat($string, startsWith($prefix), $message);
}
/**
* Asserts that a string starts not with a given prefix.
*
* @param string $prefix
* @param string $string
* @param string $message
* @since 1.1.0
*/
public static function assertStringStartsNotWith($prefix, $string, string $message = ''): void
{
assertThat($string, doesNotStartWith($prefix), $message);
}
/**
* Asserts that a string ends with a given suffix.
*
* @param string $suffix
* @param string $string
* @param string $message
* @since 1.1.0
*/
public static function assertStringEndsWith(string $suffix, string $string, string $message = ''): void
{
assertThat($string, endsWith($suffix), $message);
}
/**
* Asserts that a string ends not with a given suffix.
*
* @param string $suffix
* @param string $string
* @param string $message
* @since 1.1.0
*/
public static function assertStringEndsNotWith(string $suffix, string $string, string $message = ''): void
{
assertThat($string, doesNotEndWith($suffix), $message);
}
/**
* Asserts that a variable is of type array.
*
* @since 5.0.0
*/
public static function assertIsArray($actual, string $message = ''): void
{
assertThat($actual, isOfType('array'), $message);
}
/**
* Asserts that a variable is of type bool.
*
* @since 5.0.0
*/
public static function assertIsBool($actual, string $message = ''): void
{
assertThat($actual, isOfType('bool'), $message);
}
/**
* Asserts that a variable is of type float.
*
* @since 5.0.0
*/
public static function assertIsFloat($actual, string $message = ''): void
{
assertThat($actual, isOfType('float'), $message);
}
/**
* Asserts that a variable is of type int.
*
* @since 5.0.0
*/
public static function assertIsInt($actual, string $message = ''): void
{
assertThat($actual, isOfType('int'), $message);
}
/**
* Asserts that a variable is of type numeric.
*
* @since 5.0.0
*/
public static function assertIsNumeric($actual, string $message = ''): void
{
assertThat($actual, isOfType('numeric'), $message);
}
/**
* Asserts that a variable is of type object.
*
* @since 5.0.0
*/
public static function assertIsObject($actual, string $message = ''): void
{
assertThat($actual, isOfType('object'), $message);
}
/**
* Asserts that a variable is of type resource.
*
* @since 5.0.0
*/
public static function assertIsResource($actual, string $message = ''): void
{
assertThat($actual, isOfType('resource'), $message);
}
/**
* Asserts that a variable is of type string.
*
* @since 5.0.0
*/
public static function assertIsString($actual, string $message = ''): void
{
assertThat($actual, isOfType('string'), $message);
}
/**
* Asserts that a variable is of type scalar.
*
* @since 5.0.0
*/
public static function assertIsScalar($actual, string $message = ''): void
{
assertThat($actual, isOfType('scalar'), $message);
}
/**
* Asserts that a variable is of type callable.
*
* @since 5.0.0
*/
public static function assertIsCallable($actual, string $message = ''): void
{
assertThat($actual, isOfType('callable'), $message);
}
/**
* Asserts that a variable is of type iterable.
*
* @since 5.0.0
*/
public static function assertIsIterable($actual, string $message = ''): void
{
assertThat($actual, isOfType('iterable'), $message);
}
/**
* Asserts that a variable is not of type array.
*
* @since 5.0.0
*/
public static function assertIsNotArray($actual, string $message = ''): void
{
assertThat($actual, isNotOfType('array'), $message);
}
/**
* Asserts that a variable is not of type bool.
*
* @since 5.0.0
*/
public static function assertIsNotBool($actual, string $message = ''): void
{
assertThat($actual, isNotOfType('bool'), $message);
}
/**
* Asserts that a variable is not of type float.
*
* @since 5.0.0
*/
public static function assertIsNotFloat($actual, string $message = ''): void
{
assertThat($actual, isNotOfType('float'), $message);
}
/**
* Asserts that a variable is not of type int.
*
* @since 5.0.0
*/
public static function assertIsNotInt($actual, string $message = ''): void
{
assertThat($actual, isNotOfType('int'), $message);
}
/**
* Asserts that a variable is not of type numeric.
*
* @since 5.0.0
*/
public static function assertIsNotNumeric($actual, string $message = ''): void
{
assertThat($actual, isNotOfType('numeric'), $message);
}
/**
* Asserts that a variable is not of type object.
*
* @since 5.0.0
*/
public static function assertIsNotObject($actual, string $message = ''): void
{
assertThat($actual, isNotOfType('object'), $message);
}
/**
* Asserts that a variable is not of type resource.
*
* @since 5.0.0
*/
public static function assertIsNotResource($actual, string $message = ''): void
{
assertThat($actual, isNotOfType('resource'), $message);
}
/**
* Asserts that a variable is not of type string.
*
* @since 5.0.0
*/
public static function assertIsNotString($actual, string $message = ''): void
{
assertThat($actual, isNotOfType('string'), $message);
}
/**
* Asserts that a variable is not of type scalar.
*
* @since 5.0.0
*/
public static function assertIsNotScalar($actual, string $message = ''): void
{
assertThat($actual, isNotOfType('scalar'), $message);
}
/**
* Asserts that a variable is not of type callable.
*
* @since 5.0.0
*/
public static function assertIsNotCallable($actual, string $message = ''): void
{
assertThat($actual, isNotOfType('callable'), $message);
}
/**
* Asserts that a variable is not of type iterable.
*
* @since 5.0.0
*/
public static function assertIsNotIterable($actual, string $message = ''): void
{
assertThat($actual, isNotOfType('iterable'), $message);
}
/**
* Evaluates a PHPUnit\Framework\Constraint\Constraint matcher object.
*
* @param mixed $value
* @param \PHPUnit\Framework\Constraint\Constraint $constraint
* @param string $message
*/
public static function assertThat($value, Constraint $constraint, string $message = ''): void
{
assertThat($value, new ConstraintAdapter($constraint), $message);
}
}
PK OΪ * src/main/php/phpunit/ConstraintAdapter.phpnu W+A constraint = $constraint;
}
/**
* evaluates predicate against given value
*
* @param mixed $value
* @return bool
*/
public function test($value): bool
{
return $this->constraint->evaluate($value, '', true);
}
/**
* returns amount of checks done in this predicate
*
* @return int
*/
public function count(): int
{
return count($this->constraint);
}
/**
* returns string representation of predicate
*
* @return string
*/
public function __toString(): string
{
return '';
}
/**
* returns a textual description of given value
*
* @param \SebastianBergmann\Exporter\Exporter $exporter
* @param mixed $value
* @return string
*/
public function describeValue(Exporter $exporter, $value): string
{
$refMethod = new \ReflectionMethod(get_class($this->constraint), 'failureDescription');
$refMethod->setAccessible(true);
return $refMethod->invoke($this->constraint, $value);
}
}
PK OW+ , src/main/php/predicate/CallablePredicate.phpnu W+A predicate = $predicate;
$this->description = $description;
}
/**
* evaluates predicate against given value
*
* @param mixed $value
* @return bool
*/
public function test($value): bool
{
$predicate = $this->predicate;
return $predicate($value);
}
/**
* returns string representation of predicate
*
* @return string
*/
public function __toString(): string
{
if (empty($this->description)) {
return 'satisfies ' . $this->predicateName();
}
return $this->description;
}
/**
* tries to determine a name for the callable
*
* @return string
*/
private function predicateName(): string
{
if (is_array($this->predicate)) {
if (is_string($this->predicate[0])) {
return $this->predicate[0] . '::' . $this->predicate[1] . '()';
}
return get_class($this->predicate[0]) . '->' . $this->predicate[1] . '()';
} elseif (is_string($this->predicate)) {
return $this->predicate . '()';
}
return 'a lambda function';
}
}
PK OUJ` ` $ src/main/php/predicate/Predicate.phpnu W+A test($value);
}
/**
* provide utility methods "and" and "or" to combine predicates
*
* @param string $method
* @param mixed[] $arguments
* @return \bovigo\assert\predicate\Predicate
* @throws \BadMethodCallException
* @since 1.4.0
*/
public function __call(string $method, $arguments): self
{
switch ($method) {
case 'and':
return new AndPredicate($this, ...$arguments);
case 'or':
return new OrPredicate($this, ...$arguments);
default:
throw new \BadMethodCallException(
'Call to undefined method '
. get_class($this) . '->' . $method . '()'
);
}
}
/**
* returns amount of checks done in this predicate
*
* @return int
*/
public function count(): int
{
return 1;
}
/**
* returns string representation of predicate
*
* @return string
*/
public abstract function __toString(): string;
/**
* returns a textual description of given value
*
* @param \SebastianBergmann\Exporter\Exporter $exporter
* @param mixed $value
* @return string
*/
public function describeValue(Exporter $exporter, $value): string
{
if (is_array($value)) {
return 'an array';
}
return $exporter->export($value);
}
}
PK OiE< # src/main/php/predicate/IsOfSize.phpnu W+A expectedSize = $expectedSize;
}
/**
* test that the given value is of a certain size
*
* @param mixed $value
* @return bool true if size of value is equal to expected size, else false
* @throws \InvalidArgumentException
*/
public function test($value): bool
{
if (!$this->isCountable($value)) {
throw new \InvalidArgumentException(
'Given value is neither a string, an array,'
. ' nor an instance of \Countable or \Traversable,'
. ' but of type ' . gettype($value)
);
}
return $this->sizeOf($value) === $this->expectedSize;
}
/**
* checks if given value is countable
*
* @param mixed $value
* @return bool
*/
private function isCountable($value): bool
{
return is_string($value) || is_array($value) || $value instanceof \Countable || $value instanceof \Traversable;
}
/**
* calculates the size of given value
*
* @param string|array|\Countable|\Iterator|\IteratorAggregate $value
* @return int
*/
private function sizeOf($value): int
{
if (is_string($value)) {
return strlen($value);
} elseif (is_array($value) || $value instanceof \Countable) {
return count($value);
}
$traversable = $this->traversable($value);
$key = $traversable->key();
$count = iterator_count($traversable);
// rewinds traversable to previous key to not change state of traversable
// because iterator_count() changes the pointer
$traversable->rewind();
while ($traversable->valid() && $key !== $traversable->key()) {
$traversable->next();
}
return $count;
}
/**
* retrieve actual iterator
*
* @param \Iterator|\IteratorAggregate $traversable
* @return \Iterator
*/
private function traversable($traversable): \Iterator
{
if ($traversable instanceof \IteratorAggregate) {
return $this->traversable($traversable->getIterator());
}
return $traversable;
}
/**
* returns string representation of predicate
*
* @return string
*/
public function __toString(): string
{
return sprintf('matches expected size %d', $this->expectedSize);
}
/**
* returns a textual description of given value
*
* @param \SebastianBergmann\Exporter\Exporter $exporter
* @param mixed $value
* @return string
*/
public function describeValue(Exporter $exporter, $value): string
{
if ($this->isCountable($value)) {
if (is_string($value)) {
$type = 'string';
} elseif (is_array($value)) {
$type = 'array';
} else {
$type = 'instance of type ' . get_class($value);
}
return $type . ' with actual size ' . $this->sizeOf($value);
}
return parent::describeValue($exporter, $value);
}
}
PK ORi i &