From c96944b5042262b32d2dad1d339f7a5f9cbb4475 Mon Sep 17 00:00:00 2001 From: Rasso Hilber Date: Wed, 17 Apr 2024 16:16:49 +0200 Subject: [PATCH 1/9] Full Compatibility with Monolog 3.6 --- LICENSE | 2 +- composer.json | 18 +- composer.lock | 900 +++++++-------------- src/Monolog/Handler/WPCLIHandler.php | 278 +++---- tests/Monolog/Handler/WPCLIHandlerTest.php | 332 ++------ tests/Monolog/Stubs/MockWPCLI.php | 10 +- 6 files changed, 486 insertions(+), 1054 deletions(-) diff --git a/LICENSE b/LICENSE index 2a42765..417f428 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 MHCG LTD +Copyright (c) 2024 Rasso Hilber Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/composer.json b/composer.json index 0dffb47..a9603ff 100755 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { - "name": "mhcg/monolog-wp-cli", - "description": "Extension for Monolog to support outputting to WP-CLI (The WordPress command line interface) when running wp command lines.", + "name": "hirasso/monolog-wp-cli", + "description": "Extension for Monolog to support outputting to WP-CLI (The WordPress command line interface) when running wp commands.", "keywords": [ "log", "logging", @@ -9,20 +9,24 @@ ], "license": "MIT", "authors": [ + { + "name": "Rasso Hilber", + "email": "mail@rassohilber.com" + }, { "name": "Mark Heydon", - "email": "contact@mhcg.co.uk", - "role": "Developer" + "email": "contact@mhcg.co.uk" } ], "type": "library", "require": { - "php": "^7.3 | ^7.4 | ^8.0", - "monolog/monolog": "^2.5" + "php": "8.2", + "monolog/monolog": "^3.6" }, "require-dev": { "wp-cli/wp-cli": "^2.0", - "phpunit/phpunit": "^9.5" + "phpunit/phpunit": "^9.5", + "symfony/var-dumper": "^7.0" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 157b7a0..93574e4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,46 +4,45 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c85f4ac9f9f7bc7382478f788e944662", + "content-hash": "fadfd065a040866f1fad9be3760c254e", "packages": [ { "name": "monolog/monolog", - "version": "2.8.0", + "version": "3.6.0", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "720488632c590286b88b80e62aa3d3d551ad4a50" + "reference": "4b18b21a5527a3d5ffdac2fd35d3ab25a9597654" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/720488632c590286b88b80e62aa3d3d551ad4a50", - "reference": "720488632c590286b88b80e62aa3d3d551ad4a50", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/4b18b21a5527a3d5ffdac2fd35d3ab25a9597654", + "reference": "4b18b21a5527a3d5ffdac2fd35d3ab25a9597654", "shasum": "" }, "require": { - "php": ">=7.2", - "psr/log": "^1.0.1 || ^2.0 || ^3.0" + "php": ">=8.1", + "psr/log": "^2.0 || ^3.0" }, "provide": { - "psr/log-implementation": "1.0.0 || 2.0.0 || 3.0.0" + "psr/log-implementation": "3.0.0" }, "require-dev": { - "aws/aws-sdk-php": "^2.4.9 || ^3.0", + "aws/aws-sdk-php": "^3.0", "doctrine/couchdb": "~1.0@dev", "elasticsearch/elasticsearch": "^7 || ^8", "ext-json": "*", - "graylog2/gelf-php": "^1.4.2", - "guzzlehttp/guzzle": "^7.4", + "graylog2/gelf-php": "^1.4.2 || ^2.0", + "guzzlehttp/guzzle": "^7.4.5", "guzzlehttp/psr7": "^2.2", "mongodb/mongodb": "^1.8", "php-amqplib/php-amqplib": "~2.4 || ^3", - "phpspec/prophecy": "^1.15", - "phpstan/phpstan": "^0.12.91", - "phpunit/phpunit": "^8.5.14", - "predis/predis": "^1.1 || ^2.0", - "rollbar/rollbar": "^1.3 || ^2 || ^3", + "phpstan/phpstan": "^1.9", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-strict-rules": "^1.4", + "phpunit/phpunit": "^10.5.17", + "predis/predis": "^1.1 || ^2", "ruflin/elastica": "^7", - "swiftmailer/swiftmailer": "^5.3|^6.0", "symfony/mailer": "^5.4 || ^6", "symfony/mime": "^5.4 || ^6" }, @@ -66,7 +65,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "2.x-dev" + "dev-main": "3.x-dev" } }, "autoload": { @@ -94,7 +93,7 @@ ], "support": { "issues": "https://github.com/Seldaek/monolog/issues", - "source": "https://github.com/Seldaek/monolog/tree/2.8.0" + "source": "https://github.com/Seldaek/monolog/tree/3.6.0" }, "funding": [ { @@ -106,34 +105,34 @@ "type": "tidelift" } ], - "time": "2022-07-24T11:55:47+00:00" + "time": "2024-04-12T21:02:21+00:00" }, { "name": "psr/log", - "version": "1.1.4", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "3.x-dev" } }, "autoload": { "psr-4": { - "Psr\\Log\\": "Psr/Log/" + "Psr\\Log\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -154,38 +153,38 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/1.1.4" + "source": "https://github.com/php-fig/log/tree/3.0.0" }, - "time": "2021-05-03T11:20:27+00:00" + "time": "2021-07-14T16:46:02+00:00" } ], "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.4.1", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc" + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc", - "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0" + "php": "^8.1" }, "require-dev": { - "doctrine/coding-standard": "^9", + "doctrine/coding-standard": "^11", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.16 || ^1", - "phpstan/phpstan": "^1.4", - "phpstan/phpstan-phpunit": "^1", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.22" + "phpbench/phpbench": "^1.2", + "phpstan/phpstan": "^1.9.4", + "phpstan/phpstan-phpunit": "^1.3", + "phpunit/phpunit": "^9.5.27", + "vimeo/psalm": "^5.4" }, "type": "library", "autoload": { @@ -212,7 +211,7 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.4.1" + "source": "https://github.com/doctrine/instantiator/tree/2.0.0" }, "funding": [ { @@ -228,20 +227,20 @@ "type": "tidelift" } ], - "time": "2022-03-03T08:28:38+00:00" + "time": "2022-12-30T00:23:10+00:00" }, { "name": "mustache/mustache", - "version": "v2.14.1", + "version": "v2.14.2", "source": { "type": "git", "url": "https://github.com/bobthecow/mustache.php.git", - "reference": "579ffa5c96e1d292c060b3dd62811ff01ad8c24e" + "reference": "e62b7c3849d22ec55f3ec425507bf7968193a6cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/mustache.php/zipball/579ffa5c96e1d292c060b3dd62811ff01ad8c24e", - "reference": "579ffa5c96e1d292c060b3dd62811ff01ad8c24e", + "url": "https://api.github.com/repos/bobthecow/mustache.php/zipball/e62b7c3849d22ec55f3ec425507bf7968193a6cb", + "reference": "e62b7c3849d22ec55f3ec425507bf7968193a6cb", "shasum": "" }, "require": { @@ -276,22 +275,22 @@ ], "support": { "issues": "https://github.com/bobthecow/mustache.php/issues", - "source": "https://github.com/bobthecow/mustache.php/tree/v2.14.1" + "source": "https://github.com/bobthecow/mustache.php/tree/v2.14.2" }, - "time": "2022-01-21T06:08:36+00:00" + "time": "2022-08-23T13:07:01+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.11.0", + "version": "1.11.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614" + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614", - "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", "shasum": "" }, "require": { @@ -329,7 +328,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" }, "funding": [ { @@ -337,29 +336,31 @@ "type": "tidelift" } ], - "time": "2022-03-03T13:19:32+00:00" + "time": "2023-03-08T13:26:56+00:00" }, { "name": "nikic/php-parser", - "version": "v4.14.0", + "version": "v5.0.2", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "34bea19b6e03d8153165d8f30bba4c3be86184c1" + "reference": "139676794dc1e9231bf7bcd123cfc0c99182cb13" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/34bea19b6e03d8153165d8f30bba4c3be86184c1", - "reference": "34bea19b6e03d8153165d8f30bba4c3be86184c1", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/139676794dc1e9231bf7bcd123cfc0c99182cb13", + "reference": "139676794dc1e9231bf7bcd123cfc0c99182cb13", "shasum": "" }, "require": { + "ext-ctype": "*", + "ext-json": "*", "ext-tokenizer": "*", - "php": ">=7.0" + "php": ">=7.4" }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", - "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" }, "bin": [ "bin/php-parse" @@ -367,7 +368,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.9-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -391,26 +392,27 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.14.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.0.2" }, - "time": "2022-05-31T20:59:12+00:00" + "time": "2024-03-05T20:51:40+00:00" }, { "name": "phar-io/manifest", - "version": "2.0.3", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", - "reference": "97803eca37d319dfa7826cc2437fc020857acb53" + "reference": "54750ef60c58e43759730615a392c31c80e23176" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", - "reference": "97803eca37d319dfa7826cc2437fc020857acb53", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176", + "reference": "54750ef60c58e43759730615a392c31c80e23176", "shasum": "" }, "require": { "ext-dom": "*", + "ext-libxml": "*", "ext-phar": "*", "ext-xmlwriter": "*", "phar-io/version": "^3.0.1", @@ -451,9 +453,15 @@ "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", "support": { "issues": "https://github.com/phar-io/manifest/issues", - "source": "https://github.com/phar-io/manifest/tree/2.0.3" + "source": "https://github.com/phar-io/manifest/tree/2.0.4" }, - "time": "2021-07-20T11:28:43+00:00" + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:33:53+00:00" }, { "name": "phar-io/version", @@ -506,252 +514,25 @@ }, "time": "2022-02-21T01:04:05+00:00" }, - { - "name": "phpdocumentor/reflection-common", - "version": "2.2.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-2.x": "2.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" - ], - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", - "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" - }, - "time": "2020-06-27T09:03:43+00:00" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "5.3.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", - "shasum": "" - }, - "require": { - "ext-filter": "*", - "php": "^7.2 || ^8.0", - "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "^1.3", - "webmozart/assert": "^1.9.1" - }, - "require-dev": { - "mockery/mockery": "~1.3.2", - "psalm/phar": "^4.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - }, - { - "name": "Jaap van Otterdijk", - "email": "account@ijaap.nl" - } - ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" - }, - "time": "2021-10-19T17:43:47+00:00" - }, - { - "name": "phpdocumentor/type-resolver", - "version": "1.6.1", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "77a32518733312af16a44300404e945338981de3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/77a32518733312af16a44300404e945338981de3", - "reference": "77a32518733312af16a44300404e945338981de3", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "phpdocumentor/reflection-common": "^2.0" - }, - "require-dev": { - "ext-tokenizer": "*", - "psalm/phar": "^4.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-1.x": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "support": { - "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.1" - }, - "time": "2022-03-15T21:29:03+00:00" - }, - { - "name": "phpspec/prophecy", - "version": "v1.15.0", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/bbcd7380b0ebf3961ee21409db7b38bc31d69a13", - "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.2", - "php": "^7.2 || ~8.0, <8.2", - "phpdocumentor/reflection-docblock": "^5.2", - "sebastian/comparator": "^3.0 || ^4.0", - "sebastian/recursion-context": "^3.0 || ^4.0" - }, - "require-dev": { - "phpspec/phpspec": "^6.0 || ^7.0", - "phpunit/phpunit": "^8.0 || ^9.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Prophecy\\": "src/Prophecy" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "support": { - "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/v1.15.0" - }, - "time": "2021-12-08T12:19:24+00:00" - }, { "name": "phpunit/php-code-coverage", - "version": "9.2.15", + "version": "9.2.31", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f" + "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2e9da11878c4202f97915c1cb4bb1ca318a63f5f", - "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/48c34b5d8d983006bd2adc2d0de92963b9155965", + "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.13.0", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=7.3", "phpunit/php-file-iterator": "^3.0.3", "phpunit/php-text-template": "^2.0.2", @@ -766,8 +547,8 @@ "phpunit/phpunit": "^9.3" }, "suggest": { - "ext-pcov": "*", - "ext-xdebug": "*" + "ext-pcov": "PHP extension that provides line coverage", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" }, "type": "library", "extra": { @@ -800,7 +581,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.15" + "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.31" }, "funding": [ { @@ -808,7 +590,7 @@ "type": "github" } ], - "time": "2022-03-07T09:28:20+00:00" + "time": "2024-03-02T06:37:42+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1053,20 +835,20 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.21", + "version": "9.6.19", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "0e32b76be457de00e83213528f6bb37e2a38fcb1" + "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0e32b76be457de00e83213528f6bb37e2a38fcb1", - "reference": "0e32b76be457de00e83213528f6bb37e2a38fcb1", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a1a54a473501ef4cdeaae4e06891674114d79db8", + "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.3.1", + "doctrine/instantiator": "^1.3.1 || ^2", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", @@ -1077,30 +859,26 @@ "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", "php": ">=7.3", - "phpspec/prophecy": "^1.12.1", - "phpunit/php-code-coverage": "^9.2.13", + "phpunit/php-code-coverage": "^9.2.28", "phpunit/php-file-iterator": "^3.0.5", "phpunit/php-invoker": "^3.1.1", "phpunit/php-text-template": "^2.0.3", "phpunit/php-timer": "^5.0.2", "sebastian/cli-parser": "^1.0.1", "sebastian/code-unit": "^1.0.6", - "sebastian/comparator": "^4.0.5", + "sebastian/comparator": "^4.0.8", "sebastian/diff": "^4.0.3", "sebastian/environment": "^5.1.3", - "sebastian/exporter": "^4.0.3", + "sebastian/exporter": "^4.0.5", "sebastian/global-state": "^5.0.1", "sebastian/object-enumerator": "^4.0.3", "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^3.0", + "sebastian/type": "^3.2", "sebastian/version": "^3.0.2" }, - "require-dev": { - "phpspec/prophecy-phpunit": "^2.0.1" - }, "suggest": { - "ext-soap": "*", - "ext-xdebug": "*" + "ext-soap": "To be able to generate mocks based on WSDL files", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" }, "bin": [ "phpunit" @@ -1108,7 +886,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "9.5-dev" + "dev-master": "9.6-dev" } }, "autoload": { @@ -1139,7 +917,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.21" + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.19" }, "funding": [ { @@ -1149,82 +928,26 @@ { "url": "https://github.com/sebastianbergmann", "type": "github" - } - ], - "time": "2022-06-19T12:14:25+00:00" - }, - { - "name": "rmccue/requests", - "version": "v1.8.1", - "source": { - "type": "git", - "url": "https://github.com/WordPress/Requests.git", - "reference": "82e6936366eac3af4d836c18b9d8c31028fe4cd5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/WordPress/Requests/zipball/82e6936366eac3af4d836c18b9d8c31028fe4cd5", - "reference": "82e6936366eac3af4d836c18b9d8c31028fe4cd5", - "shasum": "" - }, - "require": { - "php": ">=5.2" - }, - "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7", - "php-parallel-lint/php-console-highlighter": "^0.5.0", - "php-parallel-lint/php-parallel-lint": "^1.3", - "phpcompatibility/php-compatibility": "^9.0", - "phpunit/phpunit": "^4.8 || ^5.7 || ^6.5 || ^7.5", - "requests/test-server": "dev-master", - "squizlabs/php_codesniffer": "^3.5", - "wp-coding-standards/wpcs": "^2.0" - }, - "type": "library", - "autoload": { - "psr-0": { - "Requests": "library/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "ISC" - ], - "authors": [ + }, { - "name": "Ryan McCue", - "homepage": "http://ryanmccue.info" + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" } ], - "description": "A HTTP library written in PHP, for human beings.", - "homepage": "http://github.com/WordPress/Requests", - "keywords": [ - "curl", - "fsockopen", - "http", - "idna", - "ipv6", - "iri", - "sockets" - ], - "support": { - "issues": "https://github.com/WordPress/Requests/issues", - "source": "https://github.com/WordPress/Requests/tree/v1.8.1" - }, - "time": "2021-06-04T09:56:25+00:00" + "time": "2024-04-05T04:35:58+00:00" }, { "name": "sebastian/cli-parser", - "version": "1.0.1", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/2b56bea83a09de3ac06bb18b92f068e60cc6f50b", + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b", "shasum": "" }, "require": { @@ -1259,7 +982,7 @@ "homepage": "https://github.com/sebastianbergmann/cli-parser", "support": { "issues": "https://github.com/sebastianbergmann/cli-parser/issues", - "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.2" }, "funding": [ { @@ -1267,7 +990,7 @@ "type": "github" } ], - "time": "2020-09-28T06:08:49+00:00" + "time": "2024-03-02T06:27:43+00:00" }, { "name": "sebastian/code-unit", @@ -1382,16 +1105,16 @@ }, { "name": "sebastian/comparator", - "version": "4.0.6", + "version": "4.0.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "55f4261989e546dc112258c7a75935a81a7ce382" + "reference": "fa0f136dd2334583309d32b62544682ee972b51a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55f4261989e546dc112258c7a75935a81a7ce382", - "reference": "55f4261989e546dc112258c7a75935a81a7ce382", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a", + "reference": "fa0f136dd2334583309d32b62544682ee972b51a", "shasum": "" }, "require": { @@ -1444,7 +1167,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.6" + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8" }, "funding": [ { @@ -1452,24 +1175,24 @@ "type": "github" } ], - "time": "2020-10-26T15:49:45+00:00" + "time": "2022-09-14T12:41:17+00:00" }, { "name": "sebastian/complexity", - "version": "2.0.2", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/25f207c40d62b8b7aa32f5ab026c53561964053a", + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a", "shasum": "" }, "require": { - "nikic/php-parser": "^4.7", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=7.3" }, "require-dev": { @@ -1501,7 +1224,7 @@ "homepage": "https://github.com/sebastianbergmann/complexity", "support": { "issues": "https://github.com/sebastianbergmann/complexity/issues", - "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.3" }, "funding": [ { @@ -1509,20 +1232,20 @@ "type": "github" } ], - "time": "2020-10-26T15:52:27+00:00" + "time": "2023-12-22T06:19:30+00:00" }, { "name": "sebastian/diff", - "version": "4.0.4", + "version": "4.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", - "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc", "shasum": "" }, "require": { @@ -1567,7 +1290,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.6" }, "funding": [ { @@ -1575,20 +1298,20 @@ "type": "github" } ], - "time": "2020-10-26T13:10:38+00:00" + "time": "2024-03-02T06:30:58+00:00" }, { "name": "sebastian/environment", - "version": "5.1.4", + "version": "5.1.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7" + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1b5dff7bb151a4db11d49d90e5408e4e938270f7", - "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", "shasum": "" }, "require": { @@ -1630,7 +1353,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/5.1.4" + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.5" }, "funding": [ { @@ -1638,20 +1361,20 @@ "type": "github" } ], - "time": "2022-04-03T09:37:03+00:00" + "time": "2023-02-03T06:03:51+00:00" }, { "name": "sebastian/exporter", - "version": "4.0.4", + "version": "4.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9" + "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/65e8b7db476c5dd267e65eea9cab77584d3cfff9", - "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/78c00df8f170e02473b682df15bfcdacc3d32d72", + "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72", "shasum": "" }, "require": { @@ -1707,7 +1430,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.6" }, "funding": [ { @@ -1715,20 +1438,20 @@ "type": "github" } ], - "time": "2021-11-11T14:18:36+00:00" + "time": "2024-03-02T06:33:00+00:00" }, { "name": "sebastian/global-state", - "version": "5.0.5", + "version": "5.0.7", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2" + "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2", - "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", + "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", "shasum": "" }, "require": { @@ -1771,7 +1494,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5" + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.7" }, "funding": [ { @@ -1779,24 +1502,24 @@ "type": "github" } ], - "time": "2022-02-14T08:28:10+00:00" + "time": "2024-03-02T06:35:11+00:00" }, { "name": "sebastian/lines-of-code", - "version": "1.0.3", + "version": "1.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5", "shasum": "" }, "require": { - "nikic/php-parser": "^4.6", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=7.3" }, "require-dev": { @@ -1828,7 +1551,7 @@ "homepage": "https://github.com/sebastianbergmann/lines-of-code", "support": { "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.4" }, "funding": [ { @@ -1836,7 +1559,7 @@ "type": "github" } ], - "time": "2020-11-28T06:42:11+00:00" + "time": "2023-12-22T06:20:34+00:00" }, { "name": "sebastian/object-enumerator", @@ -1952,16 +1675,16 @@ }, { "name": "sebastian/recursion-context", - "version": "4.0.4", + "version": "4.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172" + "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172", - "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", + "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", "shasum": "" }, "require": { @@ -2000,10 +1723,10 @@ } ], "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "homepage": "https://github.com/sebastianbergmann/recursion-context", "support": { "issues": "https://github.com/sebastianbergmann/recursion-context/issues", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.5" }, "funding": [ { @@ -2011,20 +1734,20 @@ "type": "github" } ], - "time": "2020-10-26T13:17:30+00:00" + "time": "2023-02-03T06:07:39+00:00" }, { "name": "sebastian/resource-operations", - "version": "3.0.3", + "version": "3.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e", + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e", "shasum": "" }, "require": { @@ -2036,7 +1759,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-main": "3.0-dev" } }, "autoload": { @@ -2057,8 +1780,7 @@ "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", "support": { - "issues": "https://github.com/sebastianbergmann/resource-operations/issues", - "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.4" }, "funding": [ { @@ -2066,20 +1788,20 @@ "type": "github" } ], - "time": "2020-09-28T06:45:17+00:00" + "time": "2024-03-14T16:00:52+00:00" }, { "name": "sebastian/type", - "version": "3.0.0", + "version": "3.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad" + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b233b84bc4465aff7b57cf1c4bc75c86d00d6dad", - "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", "shasum": "" }, "require": { @@ -2091,7 +1813,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.2-dev" } }, "autoload": { @@ -2114,7 +1836,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/3.0.0" + "source": "https://github.com/sebastianbergmann/type/tree/3.2.1" }, "funding": [ { @@ -2122,7 +1844,7 @@ "type": "github" } ], - "time": "2022-03-15T09:54:48+00:00" + "time": "2023-02-03T06:13:03+00:00" }, { "name": "sebastian/version", @@ -2178,35 +1900,32 @@ "time": "2020-09-28T06:39:44+00:00" }, { - "name": "symfony/deprecation-contracts", - "version": "v2.5.2", + "name": "symfony/finder", + "version": "v7.0.0", "source": { "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66" + "url": "https://github.com/symfony/finder.git", + "reference": "6e5688d69f7cfc4ed4a511e96007e06c2d34ce56" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66", + "url": "https://api.github.com/repos/symfony/finder/zipball/6e5688d69f7cfc4ed4a511e96007e06c2d34ce56", + "reference": "6e5688d69f7cfc4ed4a511e96007e06c2d34ce56", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=8.2" }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } + "require-dev": { + "symfony/filesystem": "^6.4|^7.0" }, + "type": "library", "autoload": { - "files": [ - "function.php" + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -2215,18 +1934,18 @@ ], "authors": [ { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" + "name": "Fabien Potencier", + "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "A generic function and convention to trigger deprecation notices", + "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.2" + "source": "https://github.com/symfony/finder/tree/v7.0.0" }, "funding": [ { @@ -2242,35 +1961,45 @@ "type": "tidelift" } ], - "time": "2022-01-02T09:53:40+00:00" + "time": "2023-10-31T17:59:56+00:00" }, { - "name": "symfony/finder", - "version": "v5.4.11", + "name": "symfony/polyfill-mbstring", + "version": "v1.29.0", "source": { "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "7872a66f57caffa2916a584db1aa7f12adc76f8c" + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/7872a66f57caffa2916a584db1aa7f12adc76f8c", - "reference": "7872a66f57caffa2916a584db1aa7f12adc76f8c", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-php80": "^1.16" + "php": ">=7.1" + }, + "provide": { + "ext-mbstring": "*" + }, + "suggest": { + "ext-mbstring": "For best performance" }, "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, "autoload": { + "files": [ + "bootstrap.php" + ], "psr-4": { - "Symfony\\Component\\Finder\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] + "Symfony\\Polyfill\\Mbstring\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -2278,18 +2007,25 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "Finds files and directories via an intuitive fluent interface", + "description": "Symfony polyfill for the Mbstring extension", "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], "support": { - "source": "https://github.com/symfony/finder/tree/v5.4.11" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" }, "funding": [ { @@ -2305,44 +2041,50 @@ "type": "tidelift" } ], - "time": "2022-07-29T07:37:50+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { - "name": "symfony/polyfill-php80", - "version": "v1.26.0", + "name": "symfony/var-dumper", + "version": "v7.0.6", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace" + "url": "https://github.com/symfony/var-dumper.git", + "reference": "66d13dc207d5dab6b4f4c2b5460efe1bea29dbfb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/cfa0ae98841b9e461207c13ab093d76b0fa7bace", - "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/66d13dc207d5dab6b4f4c2b5460efe1bea29dbfb", + "reference": "66d13dc207d5dab6b4f4c2b5460efe1bea29dbfb", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=8.2", + "symfony/polyfill-mbstring": "~1.0" }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.26-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } + "conflict": { + "symfony/console": "<6.4" + }, + "require-dev": { + "ext-iconv": "*", + "symfony/console": "^6.4|^7.0", + "symfony/http-kernel": "^6.4|^7.0", + "symfony/process": "^6.4|^7.0", + "symfony/uid": "^6.4|^7.0", + "twig/twig": "^3.0.4" }, + "bin": [ + "Resources/bin/var-dump-server" + ], + "type": "library", "autoload": { "files": [ - "bootstrap.php" + "Resources/functions/dump.php" ], "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" + "Symfony\\Component\\VarDumper\\": "" }, - "classmap": [ - "Resources/stubs" + "exclude-from-classmap": [ + "/Tests/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -2350,10 +2092,6 @@ "MIT" ], "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, { "name": "Nicolas Grekas", "email": "p@tchwork.com" @@ -2363,16 +2101,14 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "description": "Provides mechanisms for walking through any arbitrary PHP variable", "homepage": "https://symfony.com", "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" + "debug", + "dump" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.26.0" + "source": "https://github.com/symfony/var-dumper/tree/v7.0.6" }, "funding": [ { @@ -2388,20 +2124,20 @@ "type": "tidelift" } ], - "time": "2022-05-10T07:21:04+00:00" + "time": "2024-03-19T11:57:22+00:00" }, { "name": "theseer/tokenizer", - "version": "1.2.1", + "version": "1.2.3", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", "shasum": "" }, "require": { @@ -2430,7 +2166,7 @@ "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "support": { "issues": "https://github.com/theseer/tokenizer/issues", - "source": "https://github.com/theseer/tokenizer/tree/1.2.1" + "source": "https://github.com/theseer/tokenizer/tree/1.2.3" }, "funding": [ { @@ -2438,65 +2174,7 @@ "type": "github" } ], - "time": "2021-07-28T10:34:58+00:00" - }, - { - "name": "webmozart/assert", - "version": "1.11.0", - "source": { - "type": "git", - "url": "https://github.com/webmozarts/assert.git", - "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/11cb2199493b2f8a3b53e7f19068fc6aac760991", - "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991", - "shasum": "" - }, - "require": { - "ext-ctype": "*", - "php": "^7.2 || ^8.0" - }, - "conflict": { - "phpstan/phpstan": "<0.12.20", - "vimeo/psalm": "<4.6.1 || 4.6.2" - }, - "require-dev": { - "phpunit/phpunit": "^8.5.13" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.10-dev" - } - }, - "autoload": { - "psr-4": { - "Webmozart\\Assert\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Assertions to validate method input/output with nice error messages.", - "keywords": [ - "assert", - "check", - "validate" - ], - "support": { - "issues": "https://github.com/webmozarts/assert/issues", - "source": "https://github.com/webmozarts/assert/tree/1.11.0" - }, - "time": "2022-06-03T18:03:27+00:00" + "time": "2024-03-03T12:36:25+00:00" }, { "name": "wp-cli/mustangostang-spyc", @@ -2551,22 +2229,31 @@ }, { "name": "wp-cli/php-cli-tools", - "version": "v0.11.14", + "version": "v0.11.22", "source": { "type": "git", "url": "https://github.com/wp-cli/php-cli-tools.git", - "reference": "f8f340e4a87687549d046e2da516242f7f36c934" + "reference": "a6bb94664ca36d0962f9c2ff25591c315a550c51" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wp-cli/php-cli-tools/zipball/f8f340e4a87687549d046e2da516242f7f36c934", - "reference": "f8f340e4a87687549d046e2da516242f7f36c934", + "url": "https://api.github.com/repos/wp-cli/php-cli-tools/zipball/a6bb94664ca36d0962f9c2ff25591c315a550c51", + "reference": "a6bb94664ca36d0962f9c2ff25591c315a550c51", "shasum": "" }, "require": { "php": ">= 5.3.0" }, + "require-dev": { + "roave/security-advisories": "dev-latest", + "wp-cli/wp-cli-tests": "^4" + }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.11.x-dev" + } + }, "autoload": { "files": [ "lib/cli/cli.php" @@ -2599,29 +2286,28 @@ ], "support": { "issues": "https://github.com/wp-cli/php-cli-tools/issues", - "source": "https://github.com/wp-cli/php-cli-tools/tree/v0.11.14" + "source": "https://github.com/wp-cli/php-cli-tools/tree/v0.11.22" }, - "time": "2022-07-04T21:44:34+00:00" + "time": "2023-12-03T19:25:05+00:00" }, { "name": "wp-cli/wp-cli", - "version": "v2.6.0", + "version": "v2.10.0", "source": { "type": "git", "url": "https://github.com/wp-cli/wp-cli.git", - "reference": "dee13c2baf6bf972484a63f8b8dab48f7220f095" + "reference": "a339dca576df73c31af4b4d8054efc2dab9a0685" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/dee13c2baf6bf972484a63f8b8dab48f7220f095", - "reference": "dee13c2baf6bf972484a63f8b8dab48f7220f095", + "url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/a339dca576df73c31af4b4d8054efc2dab9a0685", + "reference": "a339dca576df73c31af4b4d8054efc2dab9a0685", "shasum": "" }, "require": { "ext-curl": "*", "mustache/mustache": "^2.14.1", "php": "^5.6 || ^7.0 || ^8.0", - "rmccue/requests": "^1.8", "symfony/finder": ">2.7", "wp-cli/mustangostang-spyc": "^0.6.3", "wp-cli/php-cli-tools": "~0.11.2" @@ -2632,7 +2318,7 @@ "wp-cli/entity-command": "^1.2 || ^2", "wp-cli/extension-command": "^1.1 || ^2", "wp-cli/package-command": "^1 || ^2", - "wp-cli/wp-cli-tests": "^3.1.3" + "wp-cli/wp-cli-tests": "^4.0.1" }, "suggest": { "ext-readline": "Include for a better --prompt implementation", @@ -2645,7 +2331,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6.x-dev" + "dev-main": "2.10.x-dev" } }, "autoload": { @@ -2672,7 +2358,7 @@ "issues": "https://github.com/wp-cli/wp-cli/issues", "source": "https://github.com/wp-cli/wp-cli" }, - "time": "2022-01-25T16:31:27+00:00" + "time": "2024-02-08T16:52:43+00:00" } ], "aliases": [], @@ -2681,8 +2367,8 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^7.3 | ^7.4 | ^8.0" + "php": "*" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/src/Monolog/Handler/WPCLIHandler.php b/src/Monolog/Handler/WPCLIHandler.php index a6eda53..6db1121 100644 --- a/src/Monolog/Handler/WPCLIHandler.php +++ b/src/Monolog/Handler/WPCLIHandler.php @@ -1,192 +1,144 @@ - * @author Mark Heydon - * @license MIT + * */ namespace MHCG\Monolog\Handler; -use Monolog\Logger; use Monolog\Formatter\LineFormatter; use Monolog\Formatter\FormatterInterface; use Monolog\Handler\AbstractProcessingHandler; +use Monolog\Level; +use Monolog\LogRecord; use WP_CLI; + +readonly class LoggerMapEntry +{ + public function __construct( + public Level $level, + public string $method, + public bool $includeLevelName = false, + public bool $exit = false + ) { + if ($level->isLowerThan(Level::Error) && $exit === true) { + throw new \InvalidArgumentException("`exit` is only allowed for levels >= Error"); + } + } +} + /** * Handler for Monolog that uses WP-CLI methods to for logging. * * @package MHCG\Monolog\Handler */ -class WPCLIHandler extends AbstractProcessingHandler +final class WPCLIHandler extends AbstractProcessingHandler { - /** @var string Format used when WP_DEBUG disabled */ - const WP_CLI_FORMAT_STANDARD = "%message%"; - /** @var string Format used when WP_DEBUG enabled */ - const WP_CLI_FORMAT_VERBOSE = "%message% %context% %extra%"; - - /** @var bool Use verbose style log message format */ - private $verbose = false; + /** Use verbose style log message format */ + private bool $verbose = false; - /** @var array Logger map to use for mapping Logger methods to WP-CLI methods */ - private $loggerMap; + /** null|LoggerMapEntry[] Logger map to use for mapping Logger methods to WP-CLI methods */ + private ?array $loggerMap = null; /** * WPCLIHandler constructor. - * - * @param int $level The minimum logging level at which this handler will be triggered - * @param bool $bubble Whether the messages that are handled can bubble up the stack or not - * @param bool $verbose Will use this or WP_DEBUG to include extra information in logging messages */ - public function __construct($level = Logger::WARNING, $bubble = true, $verbose = false) - { - $isInCLI = (defined('WP_CLI') && WP_CLI); - if (!$isInCLI) { - throw new \RuntimeException(''); + public function __construct( + ?Level $level = Level::Info, + ?bool $bubble = true, + ?bool $verbose = false + ) { + if (!self::isWPCLI()) { + throw new \RuntimeException('WPCLIHandler only works in WP_CLI'); } parent::__construct($level, $bubble); - $verbose = (defined('WP_DEBUG') ? WP_DEBUG : false) || $verbose; $this->verbose = $verbose; } /** - * {@inheritdoc} + * Conditional to check if inside WP_CLI + */ + public static function isWPCLI(): bool + { + return defined('WP_CLI') && WP_CLI; + } + + /** + * @inheritDoc */ - public function isHandling(array $record): bool + public function isHandling(LogRecord $record): bool { - // bodge for debug level as needs to always call that; + // First check if this record should be handled at all + if (!parent::isHandling($record)) return false; + // WP_CLI deals with --debug command argument - $level = (int)$record['level']; - if ($level == Logger::DEBUG) { + if ($record->level === Level::Debug) { return true; } - // check level is one we know how to handle as more could be added in the future - // that would need mapping to the WP-CLI:: method. - $supported = self::getSupportedLevels($this->getLoggerMap()); - $isSupported = in_array($level, $supported, true); - - return $isSupported && parent::isHandling($record); + return !!$this->getLoggerMapEntry($record->level); } /** - * Returns a list of supported Logger levels based on the supplied logger map. - * - * @param array $map Logger map containing mappings. - * - * @return array Array of supported Logger levels. + * Check if a provided log record's level matches on supported by us */ - public static function getSupportedLevels(array $map) + public function getLoggerMapEntry(Level $level): ?LoggerMapEntry { - $results = []; - // validate the supplied map and return only the valid levels - $levels = array_keys($map); - foreach ($levels as $level) { - try { - self::validateLoggerMap($map, $level, Logger::getLevelName($level)); - $results[] = $level; - } catch (\Exception $e) { - // do nothing - } + foreach ($this->getLoggerMap() as $entry) { + if ($entry->level === $level) return $entry; } - return $results; + return null; } /** * Writes the record down to the log of the implementing handler * * @see https://seldaek.github.io/monolog/doc/message-structure.html - * - * @param array $record - * - * @return void - * @throws \RuntimeException If a level is passed that is not currently mapped to a WP_CLI:: method. - * @throws \InvalidArgumentException if something in $record is invalid. */ - protected function write(array $record): void + protected function write(LogRecord $record): void { - // init vars for whatever being used - $level = (int)$record['level']; // no default as think it would be an error to be empty - $levelName = (string)$record['level_name'] ?: ''; - $formattedMessage = $this->getFormatter()->format($record); - - // build up details of calling method - $loggerMap = $this->getLoggerMap(); - self::validateLoggerMap($loggerMap, $level, $levelName); - - $method = $loggerMap[$level]['method']; - $includeLevelName = isset($loggerMap[$level]['includeLevelName']) - ? (bool)$loggerMap[$level]['includeLevelName'] : false; - $exit = isset($loggerMap[$level]['exit']) ? (bool)$loggerMap[$level]['exit'] : false; - - if ($includeLevelName) { - $logMessage = '(' . $levelName . ') ' . $formattedMessage; - } else { - $logMessage = $formattedMessage; + // Bail early if the current record's log level doesn't match any of ours + if (!$mapEntry = $this->getLoggerMapEntry($record->level)) { + return; } - // call it - if ($method != 'error') { - WP_CLI::$method($logMessage); - } else { - WP_CLI::$method($logMessage, $exit); - } - } + $message = $this->getFormatter()->format($record); + $method = $mapEntry->method; - /** - * Sanity check a logger map. - * - * Checks to make sure the logger map contains a supported log level and has an existing method in WP_CLI. - * - * @param array $map The logger map to be checked. - * @param int $level The level to be checked. - * @param string $levelName The name of the level for error reporting. - * - * @throws \InvalidArgumentException - */ - public static function validateLoggerMap(array $map, int $level, string $levelName = '') - { - $entry = isset($map[(string)$level]) ? $map[(string)$level] : array(); - if (empty($entry)) { - throw new \InvalidArgumentException( - 'Logger map has no entry for level ' . $levelName . '(' . $level . ')' - ); + if ($mapEntry->includeLevelName) { + $message = "({$mapEntry->level->name}) $message"; } - if (!method_exists('WP_CLI', $entry['method'])) { - throw new \InvalidArgumentException( - 'Logger map contains an invalid method for level ' . $levelName . '(' . $level . ')' - ); - } - if ($entry['method'] !== 'error' && isset($entry['exit']) && $entry['exit'] === true) { - throw new \InvalidArgumentException( - 'Logger map for level ' . $levelName . '(' . $level . ') specifies exit but - exit is only valid for \'error\' method' - ); + + if ($method !== 'error') { + WP_CLI::$method($message); + return; } + + WP_CLI::$method($message, $mapEntry->exit); } /** * Returns the Logger map. * - * @return array Logger map/ + * @return LoggerMapEntry[] */ protected function getLoggerMap() { if (!$this->loggerMap) { - $this->loggerMap = self::getDefaultLoggerMap(); + $this->loggerMap = $this->getDefaultLoggerMap(); } return $this->loggerMap; @@ -195,57 +147,63 @@ protected function getLoggerMap() /*** * Returns an array of default mappings to map Logger methods to WP-CLI methods. * - * @return array + * @return LoggerMapEntry[] */ - public static function getDefaultLoggerMap() + public function getDefaultLoggerMap() { return [ - Logger::DEBUG => [ - 'method' => 'debug', - ], - Logger::INFO => [ - 'method' => 'log', - ], - Logger::NOTICE => [ - 'method' => 'warning', - 'includeLevelName' => true, - ], - Logger::WARNING => [ - 'method' => 'warning', - 'includeLevelName' => true, - ], - Logger::ERROR => [ - 'method' => 'error', - 'includeLevelName' => true, - 'exit' => false, - ], - Logger::CRITICAL => [ - 'method' => 'error', - 'includeLevelName' => true, - 'exit' => true, - ], - Logger::ALERT => [ - 'method' => 'error', - 'includeLevelName' => true, - 'exit' => true, - ], - Logger::EMERGENCY => [ - 'method' => 'error', - 'includeLevelName' => true, - 'exit' => true, - ] + new LoggerMapEntry( + level: Level::Debug, + method: 'debug', + ), + new LoggerMapEntry( + level: Level::Info, + method: 'log', + ), + new LoggerMapEntry( + level: Level::Notice, + method: 'log', + ), + new LoggerMapEntry( + level: Level::Warning, + method: 'warning', + ), + new LoggerMapEntry( + level: Level::Error, + method: 'error', + includeLevelName: true, + exit: false, + ), + new LoggerMapEntry( + level: Level::Critical, + method: 'error', + includeLevelName: true, + exit: true, + ), + new LoggerMapEntry( + level: Level::Alert, + method: 'error', + includeLevelName: true, + exit: true, + ), + new LoggerMapEntry( + level: Level::Emergency, + method: 'error', + includeLevelName: true, + exit: true, + ) ]; } /** - * {@inheritdoc} + * @inheritDoc */ protected function getDefaultFormatter(): FormatterInterface { if ($this->verbose) { - return new LineFormatter(self::WP_CLI_FORMAT_VERBOSE); - } else { - return new LineFormatter(self::WP_CLI_FORMAT_STANDARD); + return new LineFormatter("%message% %context% %extra%"); } + + return new LineFormatter("%message%"); } } diff --git a/tests/Monolog/Handler/WPCLIHandlerTest.php b/tests/Monolog/Handler/WPCLIHandlerTest.php index 7e19591..bf10b16 100644 --- a/tests/Monolog/Handler/WPCLIHandlerTest.php +++ b/tests/Monolog/Handler/WPCLIHandlerTest.php @@ -1,4 +1,6 @@ - /** * Sanity check for all (well most at least) tests. @@ -69,7 +73,7 @@ private function pretendToBeInWPCLI(): void */ private static function getHandleObjectForStandardTest(): WPCLIHandler { - return new WPCLIHandler(Logger::DEBUG); + return new WPCLIHandler(Level::Debug); } /** @@ -88,7 +92,7 @@ private static function getLoggerObjectForStandardTest(): Logger * @param int $level * @return array */ - private static function getLoggerRecordArrayWithLevel(int $level = Logger::DEBUG): array + private static function getLoggerRecordArrayWithLevel(int $level = Level::Debug): array { $array = array( 'level' => $level @@ -96,9 +100,8 @@ private static function getLoggerRecordArrayWithLevel(int $level = Logger::DEBUG return $array; } - // - // + /** * @covers \MHCG\Monolog\Handler\WPCLIHandler::__construct @@ -135,7 +138,7 @@ public function testConstructorInWPCLIVerbose() $this->sanityCheck(); $this->pretendToBeInWPCLI(); - $var = new WPCLIHandler(Logger::DEBUG, true, true); + $var = new WPCLIHandler(Level::Debug, true, true); $this->assertTrue(is_object($var)); $this->isInstanceOf('\MHCG\Monolog\Handler\WPCLIHandler'); unset($var); @@ -151,49 +154,57 @@ public function testFormatterDifferent() $this->sanityCheck(); $this->pretendToBeInWPCLI(); - $standard = new WPCLIHandler(Logger::DEBUG, true, false); - $verbose = new WPCLIHandler(Logger::DEBUG, true, true); - $testRecord = array( - 'message' => 'This is a message', - 'context' => array('whatever' => 'something'), - 'extra' => array('whatever2' => 'someting else') + + $logger = new Logger('test', [ + $handler = new TestHandler, + ]); + $logger->info( + message: 'test', + context: ['context'] + ); + $testRecord = $handler->getRecords()[0]; + + $standardHandler = new WPCLIHandler( + level: Level::Debug, + bubble: true, + verbose: false ); - $testStandard = $standard->getFormatter()->format($testRecord); - $testVerbose = $verbose->getFormatter()->format($testRecord); + $verboseHandler = new WPCLIHandler( + level: Level::Debug, + bubble: true, + verbose: true + ); - // test there is something in both - $this->assertTrue(strlen($testStandard) > 1); - $this->assertTrue(strlen($testVerbose) > 1); + $testStandard = $standardHandler->getFormatter()->format($testRecord); + $testVerbose = $verboseHandler->getFormatter()->format($testRecord); - // then test they are different (which they should be) - $this->assertNotEquals($testStandard, $testVerbose); + $this->assertTrue($testStandard === 'test'); + $this->assertTrue($testVerbose === 'test ["context"] []'); } - // - // + /** * Tests the default logger map contains all the Logger supported levels. * - * @covers \MHCG\Monolog\Handler\WPCLIHandler::getDefaultLoggerMap + * @covers \MHCG\Monolog\Handler\WPCLIHandler->getLoggerMapEntry */ - public function testDefaultMap() + public function testAllLevelsImplemented() { + $builtinLevels = array_map( + fn (string $levelName) => Logger::toMonologLevel($levelName), + Level::NAMES + ); - // totally round the houses this but Logger doesn't currently return a set of all the level constants - $supportedNames = Logger::getLevels(); - $loggerLevels = []; - foreach ($supportedNames as $levelName) { - $loggerLevels[] = Logger::toMonologLevel($levelName); + $handler = new WPCLIHandler(); + + foreach ($builtinLevels as $level) { + $this->assertNotEmpty( + $handler->getLoggerMapEntry($level), + message: "Level " . $level->getName() . "not implemented in WP_CLI handler" + ); } - $loggerMap = WPCLIHandler::getDefaultLoggerMap(); - $difference = array_diff($loggerLevels, array_keys($loggerMap)); - $this->assertCount( - 0, - $difference, - 'Default logger map is missed some Logger supported levels' - ); } /** @@ -203,81 +214,26 @@ public function testDefaultMap() */ public function testValidateLoggerMapDefaultMap() { - $defaultMap = WPCLIHandler::getDefaultLoggerMap(); - foreach ($defaultMap as $level => $mapping) { - $this->assertTrue(count($mapping) > 0); - $levelName = Logger::getLevelName($level); - // this shouldn't throw an exception - WPCLIHandler::validateLoggerMap($defaultMap, $level, $levelName); - $this->assertTrue(true); + $handler = new WPCLIHandler(); + $map = $handler->getDefaultLoggerMap(); + foreach ($map as $entry) { + $this->assertTrue($entry instanceof LoggerMapEntry); } } - /** - * @covers \MHCG\Monolog\Handler\WPCLIHandler::validateLoggerMap - */ - public function testValidateLoggerMapInvalidLevel() - { - $defaultMap = WPCLIHandler::getDefaultLoggerMap(); - $this->expectExceptionMessageMatches('/has no entry for level/'); - WPCLIHandler::validateLoggerMap($defaultMap, 999999, 'Whatever'); - } - - /** - * @covers \MHCG\Monolog\Handler\WPCLIHandler::validateLoggerMap - */ - public function testValidateLoggerMapInvalidMethod() - { - $map = [ - 999999 => [ - 'method' => 'method_does_not_exist' - ] - ]; - $this->expectExceptionMessageMatches('/invalid method/'); - WPCLIHandler::validateLoggerMap($map, 999999, 'Whatever'); - } - /** * @covers \MHCG\Monolog\Handler\WPCLIHandler::validateLoggerMap */ public function testValidateLoggerMapInvalidUseOfExit() { - $map = [ - Logger::DEBUG => [ - 'method' => 'debug', - 'exit' => true - ] - ]; - $this->expectExceptionMessageMatches('/specifies exit/'); - WPCLIHandler::validateLoggerMap( - $map, - Logger::DEBUG, - Logger::getLevelName(Logger::DEBUG) - ); - } + $this->expectExceptionMessageMatches('/is only allowed/'); - /** - * @covers \MHCG\Monolog\Handler\WPCLIHandler::validateLoggerMap - */ - public function testValidateLoggerMapValidUseOfExit() - { - $map = [ - Logger::DEBUG => [ - 'method' => 'error', - 'exit' => true - ] - ]; - // shouldn't throw an exception - WPCLIHandler::validateLoggerMap( - $map, - Logger::DEBUG, - Logger::getLevelName(Logger::DEBUG) + $entry = new LoggerMapEntry( + level: Level::Debug, + method: 'debug', + exit: true ); - $this->assertTrue(true); } - // - - // /** * Tests the handler can actually be added to a Logger ok. @@ -294,180 +250,8 @@ public function testPushHandler() $this->assertTrue(true); } - // - - // - /** - * Tests to make sure all of the default supported levels are actually showing as supported - * - * @covers \MHCG\Monolog\Handler\WPCLIHandler::getSupportedLevels - */ - public function testSupportedDefault() - { - $defaultMap = WPCLIHandler::getDefaultLoggerMap(); - $supported = WPCLIHandler::getSupportedLevels($defaultMap); - - $this->assertTrue(count($defaultMap) > 0); - $this->assertTrue(count($supported) > 0); - - $countOfMap = count(array_keys($defaultMap)); - $this->assertCount($countOfMap, $supported); - $this->assertEquals(array_keys($defaultMap), $supported); - } - - /** - * Tests to make sure the getSupportedLevels methods correctly ignores invalid map entries - * - * @covers \MHCG\Monolog\Handler\WPCLIHandler::getSupportedLevels - */ - public function testSupportedDoesNotIncludeInvalid() - { - $map = [ - 999999 => [ - 'method' => 'method_does_not_exist' - ], - Logger::DEBUG => [ - 'method' => 'debug', - ] - ]; - - $supported = WPCLIHandler::getSupportedLevels($map); - $this->assertCount(2, $map); - $this->assertCount(1, $supported); - $this->assertEquals($supported[0], Logger::DEBUG); - } - - /** - * Tests isHandling of WPCLIHandler returns false for an unsupported logging level. - * - * @covers \MHCG\Monolog\Handler\WPCLIHandler::isHandling - */ - public function testIsHandlingInvalid() - { - $this->sanityCheck(); - - $this->pretendToBeInWPCLI(); - $handler = self::getHandleObjectForStandardTest(); - $this->assertFalse($handler->isHandling(self::getLoggerRecordArrayWithLevel(999))); - } - - /** - * Tests isHandling of WPCLIHandler returns true for support logging level DEBUG. - * - * @covers \MHCG\Monolog\Handler\WPCLIHandler::isHandling - */ - public function testIsHandlingValidDebug() - { - $this->sanityCheck(); - - $this->pretendToBeInWPCLI(); - $handler = self::getHandleObjectForStandardTest(); - $this->assertTrue($handler->isHandling(self::getLoggerRecordArrayWithLevel(Logger::DEBUG))); - } - - /** - * Tests isHandling of WPCLIHandler returns true for support logging level INFO. - * - * @covers \MHCG\Monolog\Handler\WPCLIHandler::isHandling - */ - public function testIsHandlingValidInfo() - { - $this->sanityCheck(); - - $this->pretendToBeInWPCLI(); - $handler = self::getHandleObjectForStandardTest(); - $this->assertTrue($handler->isHandling(self::getLoggerRecordArrayWithLevel(Logger::INFO))); - } - - /** - * Tests isHandling of WPCLIHandler returns true for support logging level NOTICE. - * - * @covers \MHCG\Monolog\Handler\WPCLIHandler::isHandling - */ - public function testIsHandlingValidNotice() - { - $this->sanityCheck(); - - $this->pretendToBeInWPCLI(); - $handler = self::getHandleObjectForStandardTest(); - $this->assertTrue($handler->isHandling(self::getLoggerRecordArrayWithLevel(Logger::NOTICE))); - } - - /** - * Tests isHandling of WPCLIHandler returns true for support logging level WARNING. - * - * @covers \MHCG\Monolog\Handler\WPCLIHandler::isHandling - */ - public function testIsHandlingValidWarning() - { - $this->sanityCheck(); - - $this->pretendToBeInWPCLI(); - $handler = self::getHandleObjectForStandardTest(); - $this->assertTrue($handler->isHandling(self::getLoggerRecordArrayWithLevel(Logger::WARNING))); - } - - /** - * Tests isHandling of WPCLIHandler returns true for support logging level ERROR. - * - * @covers \MHCG\Monolog\Handler\WPCLIHandler::isHandling - */ - public function testIsHandlingValidError() - { - $this->sanityCheck(); - - $this->pretendToBeInWPCLI(); - $handler = self::getHandleObjectForStandardTest(); - $this->assertTrue($handler->isHandling(self::getLoggerRecordArrayWithLevel(Logger::ERROR))); - } - - /** - * Tests isHandling of WPCLIHandler returns true for support logging level CRITICAL. - * - * @covers \MHCG\Monolog\Handler\WPCLIHandler::isHandling - */ - public function testIsHandlingValidCritical() - { - $this->sanityCheck(); - - $this->pretendToBeInWPCLI(); - $handler = self::getHandleObjectForStandardTest(); - $this->assertTrue($handler->isHandling(self::getLoggerRecordArrayWithLevel(Logger::CRITICAL))); - } - - /** - * Tests isHandling of WPCLIHandler returns true for support logging level ALERT. - * - * @covers \MHCG\Monolog\Handler\WPCLIHandler::isHandling - */ - public function testIsHandlingValidAlert() - { - $this->sanityCheck(); - - $this->pretendToBeInWPCLI(); - $handler = self::getHandleObjectForStandardTest(); - $this->assertTrue($handler->isHandling(self::getLoggerRecordArrayWithLevel(Logger::ALERT))); - } - - /** - * Tests isHandling of WPCLIHandler returns true for support logging level EMERGENCY. - * - * @covers \MHCG\Monolog\Handler\WPCLIHandler::isHandling - */ - public function testIsHandlingValidEmergency() - { - $this->sanityCheck(); - - $this->pretendToBeInWPCLI(); - $handler = self::getHandleObjectForStandardTest(); - $this->assertTrue($handler->isHandling(self::getLoggerRecordArrayWithLevel(Logger::EMERGENCY))); - } - - // - - // /** - * Test that Logger::debug() doesn't throw an error using WPCLIHander. + * Test that Level::Debug() doesn't throw an error using WPCLIHander. * * @covers \MHCG\Monolog\Handler\WPCLIHandler::write */ @@ -620,5 +404,5 @@ public function disabledtestHandlerOkForEmergency() unset($logger); $this->assertTrue(true); } - // + } diff --git a/tests/Monolog/Stubs/MockWPCLI.php b/tests/Monolog/Stubs/MockWPCLI.php index cdd65d1..717e8f6 100644 --- a/tests/Monolog/Stubs/MockWPCLI.php +++ b/tests/Monolog/Stubs/MockWPCLI.php @@ -1,4 +1,6 @@ - public function __call($name, $arguments) { // Note: value of $name is case sensitive. $message = "Mock object method not implemented '$name' " - . implode(', ', $arguments). "\n"; + . implode(', ', $arguments) . "\n"; throw new \RuntimeException($message); } @@ -22,10 +23,9 @@ public static function __callStatic($name, $arguments) { // Note: value of $name is case sensitive. $message = "Mock static method not implemented '$name' " - . implode(', ', $arguments). "\n"; + . implode(', ', $arguments) . "\n"; throw new \RuntimeException($message); } - // public static function log($message) { From cab775ee001ef4bf55a0e86a7e2e5c6a9df43f32 Mon Sep 17 00:00:00 2001 From: Rasso Hilber Date: Wed, 17 Apr 2024 16:22:13 +0200 Subject: [PATCH 2/9] untrack `.DS_Store` --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 841f5d2..b9e4f7b 100755 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ composer.phar /vendor/ /build/ *.cache +.DS_Store \ No newline at end of file From 2dcadf21eb9fc1b8389a33654ea872b610b08556 Mon Sep 17 00:00:00 2001 From: Rasso Hilber Date: Wed, 17 Apr 2024 16:22:21 +0200 Subject: [PATCH 3/9] Revert repo link --- src/Monolog/Handler/WPCLIHandler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Monolog/Handler/WPCLIHandler.php b/src/Monolog/Handler/WPCLIHandler.php index 6db1121..b69c472 100644 --- a/src/Monolog/Handler/WPCLIHandler.php +++ b/src/Monolog/Handler/WPCLIHandler.php @@ -7,10 +7,10 @@ * * @version 2.0.0 * - * @link https://github.com/hirasso/monolog-wp-cli + * @link https://github.com/mhcg/monolog-wp-cli * - * @author Rasso Hilber * @author Mark Heydon + * @author Rasso Hilber * */ From dce8e8e13a77faa739ae5a8c2d076d8f539627bd Mon Sep 17 00:00:00 2001 From: Rasso Hilber Date: Wed, 17 Apr 2024 16:42:07 +0200 Subject: [PATCH 4/9] Simplify `getLoggerMap` --- src/Monolog/Handler/WPCLIHandler.php | 16 +--------------- tests/Monolog/Handler/WPCLIHandlerTest.php | 4 ++-- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/Monolog/Handler/WPCLIHandler.php b/src/Monolog/Handler/WPCLIHandler.php index b69c472..1593c8a 100644 --- a/src/Monolog/Handler/WPCLIHandler.php +++ b/src/Monolog/Handler/WPCLIHandler.php @@ -135,21 +135,7 @@ protected function write(LogRecord $record): void * * @return LoggerMapEntry[] */ - protected function getLoggerMap() - { - if (!$this->loggerMap) { - $this->loggerMap = $this->getDefaultLoggerMap(); - } - - return $this->loggerMap; - } - - /*** - * Returns an array of default mappings to map Logger methods to WP-CLI methods. - * - * @return LoggerMapEntry[] - */ - public function getDefaultLoggerMap() + public function getLoggerMap() { return [ new LoggerMapEntry( diff --git a/tests/Monolog/Handler/WPCLIHandlerTest.php b/tests/Monolog/Handler/WPCLIHandlerTest.php index bf10b16..b54a8c0 100644 --- a/tests/Monolog/Handler/WPCLIHandlerTest.php +++ b/tests/Monolog/Handler/WPCLIHandlerTest.php @@ -212,10 +212,10 @@ public function testAllLevelsImplemented() * * @covers \MHCG\Monolog\Handler\WPCLIHandler::validateLoggerMap */ - public function testValidateLoggerMapDefaultMap() + public function testValidLoggerMap() { $handler = new WPCLIHandler(); - $map = $handler->getDefaultLoggerMap(); + $map = $handler->getLoggerMap(); foreach ($map as $entry) { $this->assertTrue($entry instanceof LoggerMapEntry); } From d3af7c365e3eaecbacdfee3ce64bafc9eb33086c Mon Sep 17 00:00:00 2001 From: Rasso Hilber Date: Wed, 17 Apr 2024 16:45:17 +0200 Subject: [PATCH 5/9] Put package version into composer.json --- composer.json | 1 + src/Monolog/Handler/WPCLIHandler.php | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index a9603ff..4ce92f1 100755 --- a/composer.json +++ b/composer.json @@ -1,6 +1,7 @@ { "name": "hirasso/monolog-wp-cli", "description": "Extension for Monolog to support outputting to WP-CLI (The WordPress command line interface) when running wp commands.", + "version": "2.0.0", "keywords": [ "log", "logging", diff --git a/src/Monolog/Handler/WPCLIHandler.php b/src/Monolog/Handler/WPCLIHandler.php index 1593c8a..6c9d556 100644 --- a/src/Monolog/Handler/WPCLIHandler.php +++ b/src/Monolog/Handler/WPCLIHandler.php @@ -5,8 +5,6 @@ /** * Handler for Monolog that uses WP-CLI methods to for logging. * - * @version 2.0.0 - * * @link https://github.com/mhcg/monolog-wp-cli * * @author Mark Heydon From bcb28ee36c9a0a64adfa73ed89c97a9b41938acf Mon Sep 17 00:00:00 2001 From: Rasso Hilber Date: Wed, 17 Apr 2024 18:00:59 +0200 Subject: [PATCH 6/9] Pretty-Print context using `symfony/var-dumper` --- src/Monolog/Handler/WPCLIHandler.php | 45 +++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/src/Monolog/Handler/WPCLIHandler.php b/src/Monolog/Handler/WPCLIHandler.php index 6c9d556..9be2b35 100644 --- a/src/Monolog/Handler/WPCLIHandler.php +++ b/src/Monolog/Handler/WPCLIHandler.php @@ -21,6 +21,9 @@ use Monolog\LogRecord; use WP_CLI; +use Symfony\Component\VarDumper\Caster\ScalarStub; +use Symfony\Component\VarDumper\VarDumper; + readonly class LoggerMapEntry { @@ -120,12 +123,18 @@ protected function write(LogRecord $record): void $message = "({$mapEntry->level->name}) $message"; } - if ($method !== 'error') { - WP_CLI::$method($message); - return; + // Print the message to the console + WP_CLI::$method($message); + + // If there is a context available, pretty-print it using symphony/var-dumper + if (!empty($record->context)) { + $this->dump($record->context); } - WP_CLI::$method($message, $mapEntry->exit); + // If the script should exit, do it. + if ($mapEntry->exit) { + exit; + } } /** @@ -190,4 +199,32 @@ protected function getDefaultFormatter(): FormatterInterface return new LineFormatter("%message%"); } + + /** + * @author Nicolas Grekas + * @author Alexandre Daubois + */ + private function dump(mixed ...$vars): mixed + { + if (!$vars) { + VarDumper::dump(new ScalarStub('🐛')); + + return null; + } + + if (array_key_exists(0, $vars) && 1 === count($vars)) { + VarDumper::dump($vars[0]); + $k = 0; + } else { + foreach ($vars as $k => $v) { + VarDumper::dump($v, is_int($k) ? 1 + $k : $k); + } + } + + if (1 < count($vars)) { + return $vars; + } + + return $vars[$k]; + } } From 8f2f97e7227ae62eaa93c1fbbc99b11b77adf8fd Mon Sep 17 00:00:00 2001 From: Rasso Hilber Date: Wed, 17 Apr 2024 19:34:43 +0200 Subject: [PATCH 7/9] Switch composer.authors order --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 4ce92f1..9e7be2d 100755 --- a/composer.json +++ b/composer.json @@ -10,14 +10,14 @@ ], "license": "MIT", "authors": [ + { + "name": "Mark Heydon", + "email": "contact@mhcg.co.uk" + }, { "name": "Rasso Hilber", "email": "mail@rassohilber.com" }, - { - "name": "Mark Heydon", - "email": "contact@mhcg.co.uk" - } ], "type": "library", "require": { From fb9a976713f70410dc98ddc253159d211f5282f2 Mon Sep 17 00:00:00 2001 From: Rasso Hilber Date: Tue, 23 Apr 2024 12:31:42 +0200 Subject: [PATCH 8/9] Do not exit via WP_CLI, but rather in the handler itself --- src/Monolog/Handler/WPCLIHandler.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Monolog/Handler/WPCLIHandler.php b/src/Monolog/Handler/WPCLIHandler.php index 9be2b35..be334e7 100644 --- a/src/Monolog/Handler/WPCLIHandler.php +++ b/src/Monolog/Handler/WPCLIHandler.php @@ -124,11 +124,15 @@ protected function write(LogRecord $record): void } // Print the message to the console - WP_CLI::$method($message); + if ($mapEntry->method === 'error') { + WP_CLI::error($message, false); + } else { + WP_CLI::$method($message); + } // If there is a context available, pretty-print it using symphony/var-dumper if (!empty($record->context)) { - $this->dump($record->context); + $this->dump(['context' => $record->context]); } // If the script should exit, do it. From f75cdab684cca09821b11076d6bd7f200e836c96 Mon Sep 17 00:00:00 2001 From: Rasso Hilber Date: Thu, 25 Apr 2024 08:39:37 +0200 Subject: [PATCH 9/9] minor cleanup --- src/Monolog/Handler/WPCLIHandler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Monolog/Handler/WPCLIHandler.php b/src/Monolog/Handler/WPCLIHandler.php index be334e7..072b055 100644 --- a/src/Monolog/Handler/WPCLIHandler.php +++ b/src/Monolog/Handler/WPCLIHandler.php @@ -124,7 +124,7 @@ protected function write(LogRecord $record): void } // Print the message to the console - if ($mapEntry->method === 'error') { + if ($method === 'error') { WP_CLI::error($message, false); } else { WP_CLI::$method($message); @@ -132,7 +132,7 @@ protected function write(LogRecord $record): void // If there is a context available, pretty-print it using symphony/var-dumper if (!empty($record->context)) { - $this->dump(['context' => $record->context]); + $this->dump($record->context); } // If the script should exit, do it.