1
0

fix: option to supress vendor deprecation

This commit is contained in:
2026-03-25 07:39:08 +01:00
parent d1eeac6692
commit 80f48f4aba
8 changed files with 134 additions and 1 deletions

View File

@@ -96,6 +96,10 @@ final class ErrorHandler
return true;
}
if (self::shouldSuppressVendorIssue($severity, $file)) {
return true;
}
throw new \ErrorException($message, 0, $severity, $file, $line);
}
@@ -194,4 +198,46 @@ final class ErrorHandler
{
return defined('PHPUNIT_COMPOSER_INSTALL') || defined('__PHPUNIT_PHAR__');
}
private static function shouldSuppressVendorIssue(int $severity, string $file): bool
{
if (!self::isVendorPath($file)) {
return false;
}
return match (self::vendorIssueMode()) {
'suppress_deprecations' => self::isDeprecationSeverity($severity),
'suppress_deprecations_warnings' => self::isDeprecationSeverity($severity) || self::isWarningSeverity($severity),
default => false,
};
}
private static function vendorIssueMode(): string
{
$raw = getenv('APP_VENDOR_PHP_ISSUES_MODE');
if ($raw === false) {
return 'strict';
}
$mode = strtolower(trim((string) $raw));
return in_array($mode, ['strict', 'suppress_deprecations', 'suppress_deprecations_warnings'], true)
? $mode
: 'strict';
}
private static function isDeprecationSeverity(int $severity): bool
{
return in_array($severity, [E_DEPRECATED, E_USER_DEPRECATED], true);
}
private static function isWarningSeverity(int $severity): bool
{
return in_array($severity, [E_WARNING, E_USER_WARNING], true);
}
private static function isVendorPath(string $file): bool
{
$normalized = str_replace('\\', '/', $file);
return str_contains($normalized, '/vendor/');
}
}