diff --git a/src/Controller/Controller_Actions.php b/src/Controller/Controller_Actions.php index 0a9984d36..08434dc93 100644 --- a/src/Controller/Controller_Actions.php +++ b/src/Controller/Controller_Actions.php @@ -11,7 +11,7 @@ use GFPDF\Helper\Helper_Notices; use GFPDF\Model\Model_Actions; use GFPDF\View\View_Actions; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; /** * @package Gravity PDF diff --git a/src/Controller/Controller_Custom_Fonts.php b/src/Controller/Controller_Custom_Fonts.php index 29b7305fc..87a791dc1 100644 --- a/src/Controller/Controller_Custom_Fonts.php +++ b/src/Controller/Controller_Custom_Fonts.php @@ -20,7 +20,7 @@ use GFPDF\Model\Model_Custom_Fonts; use GFPDF_Vendor\GravityPdf\Upload\Exception as UploadException; use GFPDF_Vendor\GravityPdf\Upload\Validation\Extension; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; use WP_Error; use WP_REST_Request; use WP_REST_Server; diff --git a/src/Controller/Controller_Install.php b/src/Controller/Controller_Install.php index fd3b53f77..66fc0b99a 100644 --- a/src/Controller/Controller_Install.php +++ b/src/Controller/Controller_Install.php @@ -13,7 +13,7 @@ use GFPDF\Helper\Helper_Notices; use GFPDF\Helper\Controller_Uninstaller; use GFPDF\Model\Model_Install; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; /** * @package Gravity PDF diff --git a/src/Controller/Controller_PDF.php b/src/Controller/Controller_PDF.php index 63be1c404..2febd1fcc 100644 --- a/src/Controller/Controller_PDF.php +++ b/src/Controller/Controller_PDF.php @@ -12,7 +12,7 @@ use GFPDF\Model\Model_PDF; use GFPDF\Statics\Debug; use GFPDF\View\View_PDF; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; /** * @package Gravity PDF diff --git a/src/Controller/Controller_Pdf_Queue.php b/src/Controller/Controller_Pdf_Queue.php index eb511fe4e..f9c5debcb 100644 --- a/src/Controller/Controller_Pdf_Queue.php +++ b/src/Controller/Controller_Pdf_Queue.php @@ -9,7 +9,7 @@ use GFPDF\Helper\Helper_Interface_Filters; use GFPDF\Helper\Helper_Pdf_Queue; use GFPDF\Model\Model_PDF; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; /** * @package Gravity PDF diff --git a/src/Controller/Controller_Save_Core_Fonts.php b/src/Controller/Controller_Save_Core_Fonts.php index 1171e3696..cabb04af5 100644 --- a/src/Controller/Controller_Save_Core_Fonts.php +++ b/src/Controller/Controller_Save_Core_Fonts.php @@ -6,7 +6,7 @@ use GFPDF\Helper\Helper_Data; use GFPDF\Helper\Helper_Interface_Actions; use GFPDF\Helper\Helper_Misc; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; /** * @package Gravity PDF diff --git a/src/Controller/Controller_Settings.php b/src/Controller/Controller_Settings.php index c4665a56e..8152bf492 100644 --- a/src/Controller/Controller_Settings.php +++ b/src/Controller/Controller_Settings.php @@ -15,7 +15,7 @@ use GFPDF\Helper\Helper_Notices; use GFPDF\Model\Model_Settings; use GFPDF\View\View_Settings; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; /** * @package Gravity PDF diff --git a/src/Controller/Controller_Shortcodes.php b/src/Controller/Controller_Shortcodes.php index edd9f0830..6b97b5e0e 100644 --- a/src/Controller/Controller_Shortcodes.php +++ b/src/Controller/Controller_Shortcodes.php @@ -8,7 +8,7 @@ use GFPDF\Helper\Helper_Interface_Filters; use GFPDF\Model\Model_Shortcodes; use GFPDF\View\View_Shortcodes; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; /** * @package Gravity PDF diff --git a/src/Helper/Helper_Abstract_Addon.php b/src/Helper/Helper_Abstract_Addon.php index 91bdd0c24..f0116b5de 100644 --- a/src/Helper/Helper_Abstract_Addon.php +++ b/src/Helper/Helper_Abstract_Addon.php @@ -3,7 +3,7 @@ namespace GFPDF\Helper; use GFPDF\Helper\Licensing\EDD_SL_Plugin_Updater; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; /** * @package Gravity PDF diff --git a/src/Helper/Helper_Abstract_Options.php b/src/Helper/Helper_Abstract_Options.php index facc40e3d..5dcc04b9e 100644 --- a/src/Helper/Helper_Abstract_Options.php +++ b/src/Helper/Helper_Abstract_Options.php @@ -5,7 +5,7 @@ use GFPDF\Controller\Controller_Custom_Fonts; use GFPDF\Model\Model_Custom_Fonts; use GFPDF\Statics\Kses; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; use WP_Error; /** diff --git a/src/Helper/Helper_Abstract_Pdf_Shortcode.php b/src/Helper/Helper_Abstract_Pdf_Shortcode.php index 14e9ed4ad..702f4ea74 100644 --- a/src/Helper/Helper_Abstract_Pdf_Shortcode.php +++ b/src/Helper/Helper_Abstract_Pdf_Shortcode.php @@ -8,7 +8,7 @@ use GFPDF\Exceptions\GravityPdfShortcodePdfInactiveException; use GPDFAPI; use GravityView_View; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; /** * @package Gravity PDF diff --git a/src/Helper/Helper_Misc.php b/src/Helper/Helper_Misc.php index 34f9e64df..76969682d 100644 --- a/src/Helper/Helper_Misc.php +++ b/src/Helper/Helper_Misc.php @@ -6,7 +6,7 @@ use Exception; use GFCommon; use GFMultiCurrency; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; use WP_Error; diff --git a/src/Helper/Helper_PDF.php b/src/Helper/Helper_PDF.php index 356d10c54..4ae0666c4 100644 --- a/src/Helper/Helper_PDF.php +++ b/src/Helper/Helper_PDF.php @@ -10,7 +10,7 @@ use GFPDF_Vendor\Mpdf\MpdfException; use GFPDF_Vendor\Mpdf\Utils\UtfString; use GFPDF_Vendor\Mpdf\Container\SimpleContainer; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; /** * @package Gravity PDF diff --git a/src/Helper/Helper_Pdf_Queue.php b/src/Helper/Helper_Pdf_Queue.php index 7d85816f8..989ac9ea8 100644 --- a/src/Helper/Helper_Pdf_Queue.php +++ b/src/Helper/Helper_Pdf_Queue.php @@ -5,7 +5,7 @@ use Exception; use GF_Background_Process; use GFCommon; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; /** * @package Gravity PDF diff --git a/src/Helper/Helper_Templates.php b/src/Helper/Helper_Templates.php index b8aacd2c1..7a86d4722 100644 --- a/src/Helper/Helper_Templates.php +++ b/src/Helper/Helper_Templates.php @@ -4,7 +4,7 @@ use Exception; use GPDFAPI; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; use stdClass; /** diff --git a/src/Helper/Helper_Trait_Logger.php b/src/Helper/Helper_Trait_Logger.php index 1203a21a4..be089c835 100644 --- a/src/Helper/Helper_Trait_Logger.php +++ b/src/Helper/Helper_Trait_Logger.php @@ -2,7 +2,7 @@ namespace GFPDF\Helper; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; /** * @package Gravity PDF diff --git a/src/Helper/Log/Logger.php b/src/Helper/Log/Logger.php index a2a4b0702..3f7840eb7 100644 --- a/src/Helper/Log/Logger.php +++ b/src/Helper/Log/Logger.php @@ -7,10 +7,10 @@ use GFPDF_Vendor\Monolog\Formatter\LineFormatter; use GFPDF_Vendor\Monolog\Handler\NullHandler; use GFPDF_Vendor\Monolog\Handler\StreamHandler; -use GFPDF_Vendor\Monolog\Logger as MonoLoggerPsrLog1; +use GFPDF_Vendor\Monolog\Logger as Monolog; use GFPDF_Vendor\Monolog\Processor\IntrospectionProcessor; use GFPDF_Vendor\Monolog\Processor\MemoryPeakUsageProcessor; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; /** * @package Gravity PDF @@ -134,14 +134,14 @@ protected function setup_logger() { /* Setup our Gravity Forms local file logger, if enabled */ try { - $this->log = $this->get_monolog(); + $this->log = new Monolog( $this->slug ); $this->log->setTimezone( wp_timezone() ); $this->setup_gravityforms_logging(); /* Check if we have a handler pushed and add our Introspection and Memory Peak usage processors */ if ( count( $this->log->getHandlers() ) > 0 && substr( php_sapi_name(), 0, 3 ) !== 'cli' ) { - $this->log->pushProcessor( new IntrospectionProcessor( MonoLoggerPsrLog1::DEBUG, [ 'MonoLogger' ] ) ); + $this->log->pushProcessor( new IntrospectionProcessor( Monolog::DEBUG, [ 'MonoLogger' ] ) ); $this->log->pushProcessor( new MemoryPeakUsageProcessor() ); return; @@ -151,7 +151,7 @@ protected function setup_logger() { } /* Disable logging if using CLI, or if Gravity Forms logging isn't enabled */ - $this->log->pushHandler( new NullHandler( MonoLoggerPsrLog1::INFO ) ); /* throw logs away */ + $this->log->pushHandler( new NullHandler( Monolog::INFO ) ); /* throw logs away */ } /** @@ -198,7 +198,7 @@ protected function setup_gravityforms_logging() { $this->rotate_logs( $log_filename ); /* Convert Gravity Forms log levels to the appropriate Monolog level */ - $monolog_level = $log_level === 4 ? MonoLoggerPsrLog1::ERROR : MonoLoggerPsrLog1::DEBUG; + $monolog_level = $log_level === 4 ? Monolog::ERROR : Monolog::DEBUG; /* Setup our stream and change the format to more-suit Gravity Forms */ $formatter = new LineFormatter( "%datetime% - %level_name% --> %message%\n|--> %context%\n|--> %extra%\n", 'Y-m-d H:i:s.u (P)' ); @@ -273,68 +273,4 @@ function ( $a, $b ) { } } } - - /** - * Return a class that is compatible with the PSR/Log version loaded - * - * This compatibility layer is necessary because: - * - * - \Psr\Log\LoggerInterface is type-hinted throughout Gravity PDF + add-ons and not easily altered - * - Gravity PDF includes v1 of the Psr\Log library, which is incompatible with v2 and v3 - * - While Gravity PDF supports PHP 7.3+ the Psr\Log library cannot be upgraded from v1 - * - Other WordPress plugins are shipping Psr\Log v2 and v3 - * - A PHP declaration error occurs when Gravity PDF runs alongside Psr\Log v2 or v3 - * - * This is a temporary measure. Over time our plugins will be updated to support both \Psr\Log\LoggerInterface and '\GFPDF_Vendor\Psr\Log\LoggerInterface' and this won't be required. - * - * @return LoggerInterface - * @since 6.14.0 - * - */ - protected function get_monolog() { - static $psr_log_version; - - if ( empty( $psr_log_version ) ) { - /* Check what version of \Psr\Log is actually loaded and return a compatible version of Monolog */ - if ( trait_exists( '\Psr\Log\LoggerTrait' ) ) { - $reflected = new \ReflectionClass( '\Psr\Log\LoggerTrait' ); - $psr_log_content = file_get_contents( $reflected->getFileName() ); //phpcs:ignore - - /* Test for v3 */ - if ( strpos( $psr_log_content, 'function log($level, string|\Stringable $message, array $context = []): void;' ) !== false ) { - $psr_log_version = 3; - } - - /* Test for v2 */ - if ( strpos( $psr_log_content, 'function log($level, string|\Stringable $message, array $context = []);' ) !== false ) { - $psr_log_version = 2; - } - - /* Default to v1 when no match found */ - if ( empty( $psr_log_version ) ) { - $psr_log_version = 1; - } - } else { - /* No PSR Log library loaded. Alias namespaced v1 */ - $psr_log_version = 1; - class_alias( '\GFPDF_Vendor\Psr\Log\AbstractLogger', '\Psr\Log\AbstractLogger' ); - class_alias( '\GFPDF_Vendor\Psr\Log\InvalidArgumentException', '\Psr\Log\InvalidArgumentException' ); - class_alias( '\GFPDF_Vendor\Psr\Log\LoggerAwareInterface', '\Psr\Log\LoggerAwareInterface' ); - class_alias( '\GFPDF_Vendor\Psr\Log\LoggerAwareTrait', '\Psr\Log\LoggerAwareTrait' ); - class_alias( '\GFPDF_Vendor\Psr\Log\LoggerInterface', '\Psr\Log\LoggerInterface' ); - class_alias( '\GFPDF_Vendor\Psr\Log\LoggerTrait', '\Psr\Log\LoggerTrait' ); - class_alias( '\GFPDF_Vendor\Psr\Log\LogLevel', '\Psr\Log\LogLevel' ); - class_alias( '\GFPDF_Vendor\Psr\Log\NullLogger', '\Psr\Log\NullLogger' ); - } - } - - switch ( $psr_log_version ) { - case 1: - return new MonoLoggerPsrLog1( $this->slug ); - - case 2: - case 3: - return new MonoLoggerPsrLog2And3( $this->slug ); - } - } } diff --git a/src/Helper/Log/MonoLoggerPsrLog2And3.php b/src/Helper/Log/MonoLoggerPsrLog2And3.php deleted file mode 100644 index 399643617..000000000 --- a/src/Helper/Log/MonoLoggerPsrLog2And3.php +++ /dev/null @@ -1,73 +0,0 @@ -monologger = new \GFPDF_Vendor\Monolog\Logger( $slug ); - } - - public function __call( $method_name, $args ) { - return call_user_func_array( [ $this->monologger, $method_name ], $args ); - } - - public function log( $level, string|\Stringable $message, array $context = [] ): void { - $this->monologger->log( $level, $message, $context ); - } - - public function debug( string|\Stringable $message, array $context = [] ): void { - $this->monologger->debug( $message, $context ); - } - - public function info( string|\Stringable $message, array $context = [] ): void { - $this->monologger->info( $message, $context ); - } - - public function notice( string|\Stringable $message, array $context = [] ): void { - $this->monologger->notice( $message, $context ); - } - - public function warning( string|\Stringable $message, array $context = [] ): void { - $this->monologger->warning( $message, $context ); - } - - public function error( string|\Stringable $message, array $context = [] ): void { - $this->monologger->error( $message, $context ); - } - - public function critical( string|\Stringable $message, array $context = [] ): void { - $this->monologger->critical( $message, $context ); - } - - public function alert( string|\Stringable $message, array $context = [] ): void { - $this->monologger->alert( $message, $context ); - } - - public function emergency( string|\Stringable $message, array $context = [] ): void { - $this->monologger->emergency( $message, $context ); - } -} diff --git a/src/Model/Model_Form_Settings.php b/src/Model/Model_Form_Settings.php index cfe6a0425..b482ade13 100644 --- a/src/Model/Model_Form_Settings.php +++ b/src/Model/Model_Form_Settings.php @@ -16,7 +16,7 @@ use GFPDF\Helper\Helper_PDF_List_Table; use GFPDF\Helper\Helper_Templates; use GFPDF\View\View_GravityForm_Settings_Markup; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; /** * @package Gravity PDF diff --git a/src/Model/Model_Install.php b/src/Model/Model_Install.php index 54315ef13..e9d82a641 100644 --- a/src/Model/Model_Install.php +++ b/src/Model/Model_Install.php @@ -10,7 +10,7 @@ use GFPDF\Helper\Helper_Misc; use GFPDF\Helper\Helper_Notices; use GFPDF\Helper\Helper_Pdf_Queue; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; /** * @package Gravity PDF diff --git a/src/Model/Model_Mergetags.php b/src/Model/Model_Mergetags.php index 62344a813..6c4e19ae8 100644 --- a/src/Model/Model_Mergetags.php +++ b/src/Model/Model_Mergetags.php @@ -7,7 +7,7 @@ use GFPDF\Helper\Helper_Interface_Url_Signer; use GFPDF\Helper\Helper_Misc; use GFPDF\Helper\Helper_Options_Fields; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; /** * @package Gravity PDF diff --git a/src/Model/Model_PDF.php b/src/Model/Model_PDF.php index 9ae179519..8f497d4b5 100644 --- a/src/Model/Model_PDF.php +++ b/src/Model/Model_PDF.php @@ -28,7 +28,7 @@ use GFQuiz; use GFResults; use GP_Populate_Anything_Live_Merge_Tags; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; use WP_Error; diff --git a/src/Model/Model_Settings.php b/src/Model/Model_Settings.php index 7501b5ada..55039e52d 100644 --- a/src/Model/Model_Settings.php +++ b/src/Model/Model_Settings.php @@ -12,7 +12,7 @@ use GFPDF\Helper\Helper_Notices; use GFPDF\Helper\Helper_Options_Fields; use GFPDF\Helper\Helper_Templates; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; /** * @package Gravity PDF diff --git a/src/Model/Model_System_Report.php b/src/Model/Model_System_Report.php index 764858c78..826478c9a 100644 --- a/src/Model/Model_System_Report.php +++ b/src/Model/Model_System_Report.php @@ -10,7 +10,7 @@ use GFPDF\Helper\Helper_Misc; use GFPDF\Helper\Helper_Templates; use GFPDF_Major_Compatibility_Checks; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; /** * @package Gravity PDF diff --git a/src/Model/Model_Templates.php b/src/Model/Model_Templates.php index 9794f8999..3c84324b1 100644 --- a/src/Model/Model_Templates.php +++ b/src/Model/Model_Templates.php @@ -13,7 +13,7 @@ use GFPDF_Vendor\GravityPdf\Upload\Validation\Mimetype; use GFPDF_Vendor\GravityPdf\Upload\Validation\Size; use GPDFAPI; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; /** * @package Gravity PDF diff --git a/src/Model/Model_Uninstall.php b/src/Model/Model_Uninstall.php index b7c48004e..6cddc3e56 100644 --- a/src/Model/Model_Uninstall.php +++ b/src/Model/Model_Uninstall.php @@ -10,7 +10,7 @@ use GFPDF\Helper\Helper_Misc; use GFPDF\Helper\Helper_Notices; use GFPDF\Helper\Helper_Pdf_Queue; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; /** * @package Gravity PDF diff --git a/src/View/View_PDF.php b/src/View/View_PDF.php index fd855874b..e4eb90818 100644 --- a/src/View/View_PDF.php +++ b/src/View/View_PDF.php @@ -22,7 +22,7 @@ use GFPDF\Statics\Debug; use GFPDF\Statics\Kses; use GFPDFEntryDetail; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; use WP_Error; /** diff --git a/src/View/View_Settings.php b/src/View/View_Settings.php index 7aff452b8..7a4ad9dc8 100644 --- a/src/View/View_Settings.php +++ b/src/View/View_Settings.php @@ -12,7 +12,7 @@ use GFPDF\Helper\Helper_Options_Fields; use GFPDF\Helper\Helper_Templates; use GFPDF_Major_Compatibility_Checks; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; /** * @package Gravity PDF diff --git a/src/bootstrap.php b/src/bootstrap.php index 1c10a67e4..9f5a75c6e 100644 --- a/src/bootstrap.php +++ b/src/bootstrap.php @@ -15,7 +15,7 @@ use GFPDF_Major_Compatibility_Checks; use GPDFAPI; use Gravity_Forms\Gravity_Forms\Async\GF_Background_Process; -use Psr\Log\LoggerInterface; +use GFPDF_Vendor\Psr\Log\LoggerInterface; /* * Bootstrap / Router Class diff --git a/tests/phpunit/integration/Helper/Log/Test_Logger.php b/tests/phpunit/integration/Helper/Log/Test_Logger.php index f84e996b1..626b2148a 100644 --- a/tests/phpunit/integration/Helper/Log/Test_Logger.php +++ b/tests/phpunit/integration/Helper/Log/Test_Logger.php @@ -22,7 +22,7 @@ public function set_up(): void { } public function test_logger() { - $this->assertInstanceOf( '\Psr\Log\LoggerInterface', $this->logger->get_logger() ); + $this->assertInstanceOf( '\GFPDF_Vendor\Psr\Log\LoggerInterface', $this->logger->get_logger() ); $this->assertSame( 10, has_filter( diff --git a/tests/phpunit/integration/Helper/Log/Test_MonoLoggerPsrLog2And3.php b/tests/phpunit/integration/Helper/Log/Test_MonoLoggerPsrLog2And3.php deleted file mode 100644 index 64de00e4e..000000000 --- a/tests/phpunit/integration/Helper/Log/Test_MonoLoggerPsrLog2And3.php +++ /dev/null @@ -1,96 +0,0 @@ -source = file_get_contents( __DIR__ . '/../../../../../src/Helper/Log/MonoLoggerPsrLog2And3.php' ); - } - - public function test_class_implements_psr_log_interface() { - $this->assertStringContainsString( - 'class MonoLoggerPsrLog2And3 implements \Psr\Log\LoggerInterface', - $this->source, - 'Proxy must implement the global \Psr\Log\LoggerInterface — Gravity PDF type-hints this interface throughout the codebase.' - ); - } - - public function test_class_holds_an_inner_monolog_instance() { - $this->assertMatchesRegularExpression( - '/protected\s+\$monologger;/', - $this->source, - 'Proxy must keep a $monologger property — __call forwards to it.' - ); - } - - public function test_constructor_builds_monolog_with_supplied_slug() { - $this->assertMatchesRegularExpression( - '/public\s+function\s+__construct\(\s*\$slug\s*\)\s*\{[^}]*new\s+\\\\GFPDF_Vendor\\\\Monolog\\\\Logger\(\s*\$slug\s*\)/', - $this->source, - 'Constructor must instantiate the inner Monolog\\Logger from the supplied slug.' - ); - } - - public function test_call_proxies_unknown_methods_to_monologger() { - $this->assertMatchesRegularExpression( - '/public\s+function\s+__call\(\s*\$method_name,\s*\$args\s*\)\s*\{\s*return\s+call_user_func_array\(\s*\[\s*\$this->monologger,\s*\$method_name\s*\]/', - $this->source, - '__call must forward to the inner monologger so non-PSR methods (e.g. getName, pushHandler) work.' - ); - } - - /** - * @dataProvider psr_log_levels - */ - public function test_psr_log_level_methods_proxy_with_v2_v3_signature( string $level ) { - $pattern = '/public\s+function\s+' . preg_quote( $level, '/' ) - . '\(\s*string\|\\\\Stringable\s+\$message,\s*array\s+\$context\s*=\s*\[\]\s*\)\s*:\s*void\s*\{[^}]*\$this->monologger->' - . preg_quote( $level, '/' ) - . '\(\s*\$message,\s*\$context\s*\)/'; - - $this->assertMatchesRegularExpression( - $pattern, - $this->source, - "PSR-3 level method '$level' must keep its v2/v3 signature (string|\\Stringable \$message, array \$context = []): void and forward to the inner monologger." - ); - } - - public function test_log_method_keeps_psr_v2_v3_signature() { - $pattern = '/public\s+function\s+log\(\s*\$level,\s*string\|\\\\Stringable\s+\$message,\s*array\s+\$context\s*=\s*\[\]\s*\)\s*:\s*void\s*\{[^}]*\$this->monologger->log\(\s*\$level,\s*\$message,\s*\$context\s*\)/'; - - $this->assertMatchesRegularExpression( - $pattern, - $this->source, - 'log() must keep its v2/v3 signature and forward to the inner monologger.' - ); - } - - public function psr_log_levels(): array { - return [ - 'debug' => [ 'debug' ], - 'info' => [ 'info' ], - 'notice' => [ 'notice' ], - 'warning' => [ 'warning' ], - 'error' => [ 'error' ], - 'critical' => [ 'critical' ], - 'alert' => [ 'alert' ], - 'emergency' => [ 'emergency' ], - ]; - } -} diff --git a/tools/php-scoper/config/monolog.php b/tools/php-scoper/config/monolog.php index 2e5ced6ce..88f8c8281 100644 --- a/tools/php-scoper/config/monolog.php +++ b/tools/php-scoper/config/monolog.php @@ -39,8 +39,4 @@ function( string $filePath, string $prefix, string $content ): string { return $content; }, ], - - 'whitelist' => [ - 'Psr\*', - ], ]; diff --git a/tools/php-scoper/config/mpdf.php b/tools/php-scoper/config/mpdf.php index 7d6cc2c7e..462c24099 100644 --- a/tools/php-scoper/config/mpdf.php +++ b/tools/php-scoper/config/mpdf.php @@ -63,18 +63,6 @@ function( string $filePath, string $prefix, string $content ): string { $content = str_replace( "new \\$prefix\\Mpdf\\Cache(", 'new \GFPDF\Helper\Mpdf\Cache(', $content ); } - /* Remove type hinting from prefixed logger */ - $files = [ - 'LoggerAwareInterface.php', - 'LoggerAwareTrait.php', - 'MpdfPsrLogAwareTrait.php', - 'PsrLogAwareTrait.php' - ]; - - if ( in_array( basename( $filePath ), $files, true ) ) { - $content = str_replace( "\\$prefix\\Psr\\Log\\LoggerInterface", '\\Psr\\Log\\LoggerInterface', $content ); - } - /* Global polyfills */ if ( basename( $filePath ) === 'functions.php' ) { $content = str_replace( "namespace $prefix;", '', $content );