-
-
Notifications
You must be signed in to change notification settings - Fork 384
Closed
Labels
Description
Q | A |
---|---|
PHPUnit version | 9.6.4 |
PHP version | 8.1.6 |
Installation Method | Composer |
Summary
PHP 8.1 introduced First class callable syntax. For executed code in the passed method, the HTML coverage report shows zero branches and paths coverage.
I do not know if this also happens in PHPUnit 10.
When the parameter is changed to an inline function that calls the same method, the branches and paths coverage is the expected number..
Example code
class MyClass {
public function cb (
CallResult $rslt
): CallResult {
// Passing handle this way generates no Branches & Paths coverage.
return (new LoopingHandler($this->handle(...)))->cb($rslt);
// This would generate Branches & Paths coverage.
// return (new LoopingHandler(fn ($r) => $this->handle($r)))->cb($rslt);
}
private function handle (
CallResult $rslt
): mixed {
$val = $rslt->getval();
if (!is_string($val)) {
return $val;
}
return $this->extractval($val);
}
}
Current behavior
No Branches and Paths coverage in the report for the handle
method:
How to reproduce
Run a test that calls the cb
method.
Expected behavior
Branches and paths coverage included the report:
Composer info:
composer/pcre 3.1.0 PCRE wrapping library that offers type-safe preg_* replacements.
composer/xdebug-handler 3.0.3 Restarts a process without Xdebug.
dealerdirect/phpcodesniffer-composer-installer v1.0.0 PHP_CodeSniffer Standards Composer Installer Plugin
doctrine/instantiator 2.0.0 A small, lightweight utility to instantiate objects in PHP without i...
guzzlehttp/guzzle 7.5.0 Guzzle is a PHP HTTP client library
guzzlehttp/promises 1.5.2 Guzzle promises library
guzzlehttp/psr7 2.4.3 PSR-7 message implementation that also provides common utility methods
monolog/monolog 3.3.1 Sends your logs to files, sockets, inboxes, databases and various we...
myclabs/deep-copy 1.11.0 Create deep copies (clones) of your objects
nikic/php-parser v4.15.3 A PHP parser written in PHP
pdepend/pdepend 2.12.1 Official version of pdepend to be handled with Composer
phar-io/manifest 2.0.3 Component for reading phar.io manifest information from a PHP Archiv...
phar-io/version 3.2.1 Library for handling version information and constraints
php-mock/php-mock 2.4.0 PHP-Mock can mock built-in PHP functions (e.g. time()). PHP-Mock rel...
phpmd/phpmd 2.13.0 PHPMD is a spin-off project of PHP Depend and aims to be a PHP equiv...
phpmetrics/phpmetrics v2.8.1 Static analyzer tool for PHP : Coupling, Cyclomatic complexity, Main...
phpstan/phpdoc-parser 1.15.3 PHPDoc parser with support for nullable, intersection and generic types
phpstan/phpstan 1.10.3 PHPStan - PHP Static Analysis Tool
phpunit/php-code-coverage 9.2.25 Library that provides collection, processing, and rendering function...
phpunit/php-file-iterator 3.0.6 FilterIterator implementation that filters files based on a list of ...
phpunit/php-invoker 3.1.1 Invoke callables with a timeout
phpunit/php-text-template 2.0.4 Simple template engine.
phpunit/php-timer 5.0.3 Utility class for timing
phpunit/phpunit 9.6.4 The PHP Unit Testing framework.
psr/container 2.0.2 Common Container Interface (PHP FIG PSR-11)
psr/http-client 1.0.1 Common interface for HTTP clients
psr/http-factory 1.0.1 Common interfaces for PSR-7 HTTP message factories
psr/http-message 1.0.1 Common interface for HTTP messages
psr/log 3.0.0 Common interface for logging libraries
ralouphie/getallheaders 3.0.3 A polyfill for getallheaders.
sebastian/cli-parser 1.0.1 Library for parsing CLI options
sebastian/code-unit-reverse-lookup 2.0.3 Looks up which function or method a line of code belongs to
sebastian/code-unit 1.0.8 Collection of value objects that represent the PHP code units
sebastian/comparator 4.0.8 Provides the functionality to compare PHP values for equality
sebastian/complexity 2.0.2 Library for calculating the complexity of PHP code units
sebastian/diff 4.0.4 Diff implementation
sebastian/environment 5.1.5 Provides functionality to handle HHVM/PHP environments
sebastian/exporter 4.0.5 Provides the functionality to export PHP variables for visualization
sebastian/global-state 5.0.5 Snapshotting of global state
sebastian/lines-of-code 1.0.3 Library for counting the lines of code in PHP source code
sebastian/object-enumerator 4.0.4 Traverses array structures and object graphs to enumerate all refere...
sebastian/object-reflector 2.0.4 Allows reflection of object attributes, including inherited and non-...
sebastian/recursion-context 4.0.5 Provides functionality to recursively process PHP variables
sebastian/resource-operations 3.0.3 Provides a list of PHP built-in functions that operate on resources
sebastian/type 3.2.1 Collection of value objects that represent the types of the PHP type...
sebastian/version 3.0.2 Library that helps with managing the version number of Git-hosted PH...
slevomat/coding-standard 8.8.0 Slevomat Coding Standard for PHP_CodeSniffer complements Consistence...
softcreatr/jsonpath 0.8.1 JSONPath implementation for parsing, searching and flattening arrays
squizlabs/php_codesniffer 3.7.2 PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects ...
symfony/config v6.2.5 Helps you find, load, combine, autofill and validate configuration v...
symfony/dependency-injection v6.2.6 Allows you to standardize and centralize the way objects are constru...
symfony/deprecation-contracts v3.2.0 A generic function and convention to trigger deprecation notices
symfony/filesystem v6.2.5 Provides basic utilities for the filesystem
symfony/polyfill-ctype v1.27.0 Symfony polyfill for ctype functions
symfony/polyfill-mbstring v1.27.0 Symfony polyfill for the Mbstring extension
symfony/process v6.2.7 Executes commands in sub-processes
symfony/service-contracts v3.2.0 Generic abstractions related to writing services
symfony/var-exporter v6.2.5 Allows exporting any serializable PHP data structure to plain PHP code
theseer/tokenizer 1.2.1 A small library for converting tokenized PHP source code into XML an...