Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust pretty name of closures on PHP 8.4 #96

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
os: >-
['ubuntu-latest', 'windows-latest']
php: >-
['7.4', '8.0', '8.1', '8.2', '8.3']
['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 1.2.1 under development

- Enh #96: Adjust pretty name of closures on PHP 8.4 in exception messages (@staabm)
- Enh #98: Refactor `Injector::invoke()` to improve debug trace (@xepozz)

## 1.2.0 December 20, 2023
Expand Down
4 changes: 2 additions & 2 deletions src/ArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use function is_object;
use function method_exists;
use function sprintf;
use function substr;
use function strpos;
use function var_export;

abstract class ArgumentException extends \InvalidArgumentException
Expand All @@ -36,7 +36,7 @@

if ($class === null) {
$method = $function;
if (substr($method, -9) === '{closure}') {
if (strpos($method, '{closure') !== false) {
$method = $this->renderClosureSignature($reflection);
}
} else {
Expand Down Expand Up @@ -102,7 +102,7 @@
if ($type instanceof ReflectionUnionType) {
/** @var ReflectionNamedType[] $types */
$types = $type->getTypes();
return implode('|', array_map(

Check warning on line 105 in src/ArgumentException.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "UnwrapArrayMap": --- Original +++ New @@ @@ if ($type instanceof ReflectionUnionType) { /** @var ReflectionNamedType[] $types */ $types = $type->getTypes(); - return implode('|', array_map(static fn(ReflectionNamedType $r) => $r->getName(), $types)) . ' '; + return implode('|', $types) . ' '; } if ($type instanceof ReflectionIntersectionType) { /** @var ReflectionNamedType[] $types */
static fn (ReflectionNamedType $r) => $r->getName(),
$types
)) . ' ';
Expand All @@ -110,7 +110,7 @@
if ($type instanceof ReflectionIntersectionType) {
/** @var ReflectionNamedType[] $types */
$types = $type->getTypes();
return implode('&', array_map(

Check warning on line 113 in src/ArgumentException.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "UnwrapArrayMap": --- Original +++ New @@ @@ if ($type instanceof ReflectionIntersectionType) { /** @var ReflectionNamedType[] $types */ $types = $type->getTypes(); - return implode('&', array_map(static fn(ReflectionNamedType $r) => $r->getName(), $types)) . ' '; + return implode('&', $types) . ' '; } return ''; } }
static fn (ReflectionNamedType $r) => $r->getName(),
$types
)) . ' ';
Expand Down
Loading