Skip to content
Closed
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 composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"php-http/discovery": "^1.19",
"php-http/multipart-stream-builder": "^1.1.2",
"psr/http-client": "^1.0",
"webmozart/assert": "^1.9.1"
"webmozart/assert": "^1.9.1 || ^2.0"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.43",
Expand Down
26 changes: 17 additions & 9 deletions src/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,26 @@
/**
* We need to override Webmozart\Assert because we want to throw our own Exception.
*
* Webmozart\Assert version 2.0 is required for PHP 8.4 support, but
* incompatible with versions 1.x. So unfortunately we need this conditional
* class definition.
*
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
final class Assert extends \Webmozart\Assert\Assert
{
/**
* @psalm-pure this method is not supposed to perform side-effects
* @psalm-return never
* @param mixed $message
* @return void
*/
if (version_compare(\Composer\InstalledVersions::getVersion('webmozart/assert'), '2.0.0', '>=')) {
final class Assert extends \Webmozart\Assert\Assert
{
protected static function reportInvalidArgument(string $message): never

Check failure on line 28 in src/Assert.php

View workflow job for this annotation

GitHub Actions / PHPStan

Parameter #1 $message (string) of method Mailgun\Assert::reportInvalidArgument() is not contravariant with parameter #1 $message (mixed) of method Webmozart\Assert\Assert::reportInvalidArgument().
{
throw new InvalidArgumentException($message);
}
}
} else {
final class Assert extends \Webmozart\Assert\Assert

Check failure on line 34 in src/Assert.php

View workflow job for this annotation

GitHub Actions / Psalm

Class Mailgun\Assert has already been defined in /home/runner/work/mailgun-php/mailgun-php/src/Assert.php (see https://psalm.dev/071)
{
protected static function reportInvalidArgument($message): void
{
throw new InvalidArgumentException($message);
throw new InvalidArgumentException($message);
}
}
}
Loading