Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Declaration of Monolog\Logger::emergency void must be compatible #1764

Closed
RobertEcker opened this issue Sep 28, 2022 · 10 comments
Closed

Declaration of Monolog\Logger::emergency void must be compatible #1764

RobertEcker opened this issue Sep 28, 2022 · 10 comments
Labels

Comments

@RobertEcker
Copy link

RobertEcker commented Sep 28, 2022

Monolog version 3
PHP 8.1.8

Fatal error: Declaration of Monolog\Logger::emergency(Stringable|string $message, array $context = []): void must be compatible with Psr\Log\LoggerInterface::emergency($message, array $context = []): void in C:\wamp\www\rob.ec\hp\vendor\seldaek\monolog\src\Monolog\Logger.php on line 651

Removing some "Stringable|string" in "monolog/src/Monolog/Logger.php" fixed it (e.g., emergency, alert, critical, ...)

@stof
Copy link
Contributor

stof commented Sep 28, 2022

which version of psr/log are you using ?

@stof
Copy link
Contributor

stof commented Sep 28, 2022

psr/log 2+ has the typehint in the argument: https://github.com/php-fig/log/blob/2.0.0/src/LoggerInterface.php#L30

And Monolog 3 does not support psr/log 1. So you probably did something weird to get such error, as the signature reported for Psr\Log\LoggerInterface::emergency in the error message is not the actual Psr signature.

@RobertEcker
Copy link
Author

RobertEcker commented Sep 28, 2022

hi Christophe,
I downloaded via "Download ZIP" and started composer install --ignore-platform-reqs to create vendor directory
in composer.json, it says

    "require": {
        "php": ">=8.1",
        "psr/log": "^2.0 || ^3.0"

@stof
Copy link
Contributor

stof commented Sep 28, 2022

please run composer show to see the list of installed packages.
And please also run composer show -p to see the platform packages. One idea could be that you installed the psr extension and so the LoggerInterface comes from the extension and not from psr/log (and so it might still provide the psr/log 1.x extension). If this is the case, please uninstall the psr extension (psr interfaces are meant to be shipped through composer packages, not through an extension which ignores the fact that we have multiple versions of the interface)

@RobertEcker
Copy link
Author

...
psr/container 2.0.2 Common Container Interface (PHP FIG PSR-11)
psr/event-dispatcher 1.0.0 Standard interfaces for event handling.
psr/http-client 1.0.1 Common interface for HTTP clients
psr/http-factory 1.0.1 Common interfaces for PSR-7 HTTP message factories
psr/http-message 1.0.1 Common interface for HTTP messages
psr/log 2.0.0 Common interface for logging libraries
...

@RobertEcker
Copy link
Author

so I guess you are right, how can i remove the not needed part?

@stof
Copy link
Contributor

stof commented Sep 28, 2022

@RobertEcker which "not needed part" are you talking about ?

side note: you haven't pasted the output of the second command, which would be the one indicating whether my idea is indeed the cause of your problem.

@RobertEcker
Copy link
Author

here the full list

composer show

aws/aws-crt-php v1.0.2 AWS Common Runtime for PHP
aws/aws-sdk-php 3.236.1 AWS SDK for PHP - Use Amazon Web Services in your PHP project
doctrine/couchdb dev-master 9eeb9e5 CouchDB Client
doctrine/instantiator 1.4.1 A small, lightweight utility to instantiate objects in PHP w...
doctrine/lexer 1.2.3 PHP Doctrine Lexer parser library that can be used in Top-Do...
egulias/email-validator 3.2.1 A library for validating emails against several RFCs
elasticsearch/elasticsearch v7.17.0 PHP Client for Elasticsearch
ezimuel/guzzlestreams 3.0.1 Fork of guzzle/streams (abandoned) to be used with elasticse...
ezimuel/ringphp 1.2.0 Fork of guzzle/RingPHP (abandoned) to be used with elasticse...
graylog2/gelf-php 1.7.1 A php implementation to send log-messages to a GELF compatib...
guzzlehttp/guzzle 7.5.0 Guzzle is a PHP HTTP client library
guzzlehttp/promises 1.5.2 Guzzle promises library
guzzlehttp/psr7 2.4.1 PSR-7 message implementation that also provides common utili...
jean85/pretty-package-versions 2.0.5 A library to get pretty versions strings of installed depend...
mongodb/mongodb 1.13.1 MongoDB driver library
mtdowling/jmespath.php 2.6.1 Declaratively specify how to extract elements from a JSON do...
myclabs/deep-copy 1.11.0 Create deep copies (clones) of your objects
nikic/php-parser v4.15.1 A PHP parser written in PHP
nyholm/dsn 2.0.1 Parse your DSN strings in a powerful and flexible way
paragonie/constant_time_encoding v2.6.3 Constant-time Implementations of RFC 4648 Encoding (Base-64,...
paragonie/random_compat v9.99.100 PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
phar-io/manifest 2.0.3 Component for reading phar.io manifest information from a PH...
phar-io/version 3.2.1 Library for handling version information and constraints
php-amqplib/php-amqplib v3.2.0 Formerly videlalvaro/php-amqplib. This library is a pure PH...
phpseclib/phpseclib 3.0.16 PHP Secure Communications Library - Pure-PHP implementations...
phpstan/phpstan 1.8.6 PHPStan - PHP Static Analysis Tool
phpstan/phpstan-deprecation-rules 1.0.0 PHPStan rules for detecting usage of deprecated classes, met...
phpstan/phpstan-strict-rules 1.4.4 Extra strict and opinionated rules for PHPStan
phpunit/php-code-coverage 9.2.17 Library that provides collection, processing, and rendering ...
phpunit/php-file-iterator 3.0.6 FilterIterator implementation that filters files based on a ...
phpunit/php-invoker 3.1.1 Invoke callables with a timeout
phpunit/php-text-template 2.0.4 Simple template engine.
phpunit/php-timer 5.0.3 Utility class for timing
phpunit/phpunit 9.5.25 The PHP Unit Testing framework.
predis/predis v1.1.10 Flexible and feature-complete Redis client for PHP and HHVM
psr/container 2.0.2 Common Container Interface (PHP FIG PSR-11)
psr/event-dispatcher 1.0.0 Standard interfaces for event handling.
psr/http-client 1.0.1 Common interface for HTTP clients
psr/http-factory 1.0.1 Common interfaces for PSR-7 HTTP message factories
psr/http-message 1.0.1 Common interface for HTTP messages
psr/log 2.0.0 Common interface for logging libraries
ralouphie/getallheaders 3.0.3 A polyfill for getallheaders.
react/promise v2.9.0 A lightweight implementation of CommonJS Promises/A for PHP
ruflin/elastica 7.2.0 Elasticsearch Client
sebastian/cli-parser 1.0.1 Library for parsing CLI options
sebastian/code-unit 1.0.8 Collection of value objects that represent the PHP code units
sebastian/code-unit-reverse-lookup 2.0.3 Looks up which function or method a line of code belongs to
sebastian/comparator 4.0.8 Provides the functionality to compare PHP values for equality
sebastian/complexity 2.0.2 Library for calculating the complexity of PHP code units
sebastian/diff 4.0.4 Diff implementation
sebastian/environment 5.1.4 Provides functionality to handle HHVM/PHP environments
sebastian/exporter 4.0.5 Provides the functionality to export PHP variables for visua...
sebastian/global-state 5.0.5 Snapshotting of global state
sebastian/lines-of-code 1.0.3 Library for counting the lines of code in PHP source code
sebastian/object-enumerator 4.0.4 Traverses array structures and object graphs to enumerate al...
sebastian/object-reflector 2.0.4 Allows reflection of object attributes, including inherited ...
sebastian/recursion-context 4.0.4 Provides functionality to recursively process PHP variables
sebastian/resource-operations 3.0.3 Provides a list of PHP built-in functions that operate on re...
sebastian/type 3.2.0 Collection of value objects that represent the types of the ...
sebastian/version 3.0.2 Library that helps with managing the version number of Git-h...
symfony/deprecation-contracts v3.1.1 A generic function and convention to trigger deprecation not...
symfony/event-dispatcher v6.1.0 Provides tools that allow your application components to com...
symfony/event-dispatcher-contracts v3.1.1 Generic abstractions related to dispatching event
symfony/mailer v6.1.4 Helps sending emails
symfony/mime v6.1.4 Allows manipulating MIME messages
symfony/polyfill-intl-idn v1.26.0 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 fun...
symfony/polyfill-intl-normalizer v1.26.0 Symfony polyfill for intl's Normalizer class and related fun...
symfony/polyfill-mbstring v1.26.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php72 v1.26.0 Symfony polyfill backporting some PHP 7.2+ features to lower...
symfony/polyfill-php73 v1.26.0 Symfony polyfill backporting some PHP 7.3+ features to lower...
symfony/polyfill-php80 v1.26.0 Symfony polyfill backporting some PHP 8.0+ features to lower...
symfony/service-contracts v3.1.1 Generic abstractions related to writing services
theseer/tokenizer 1.2.1 A small library for converting tokenized PHP source code int...

composer show -p

composer 2.3.10 Composer package
composer-plugin-api 2.3.0 The Composer Plugin API
composer-runtime-api 2.2.2 The Composer Runtime API
ext-bcmath 8.1.8 The bcmath PHP extension
ext-bz2 8.1.8 The bz2 PHP extension
ext-calendar 8.1.8 The calendar PHP extension
ext-com_dotnet 8.1.8 The com_dotnet PHP extension
ext-ctype 8.1.8 The ctype PHP extension
ext-curl 8.1.8 The curl PHP extension
ext-date 8.1.8 The date PHP extension
ext-dom 20031129 The dom PHP extension
ext-exif 8.1.8 The exif PHP extension
ext-fileinfo 8.1.8 The fileinfo PHP extension
ext-filter 8.1.8 The filter PHP extension
ext-gd 8.1.8 The gd PHP extension
ext-gettext 8.1.8 The gettext PHP extension
ext-gmp 8.1.8 The gmp PHP extension
ext-hash 8.1.8 The hash PHP extension
ext-iconv 8.1.8 The iconv PHP extension
ext-imap 8.1.8 The imap PHP extension
ext-intl 8.1.8 The intl PHP extension
ext-json 8.1.8 The json PHP extension
ext-ldap 8.1.8 The ldap PHP extension
ext-libxml 8.1.8 The libxml PHP extension
ext-mbstring 8.1.8 The mbstring PHP extension
ext-mysqli 8.1.8 The mysqli PHP extension
ext-mysqlnd 0 The mysqlnd PHP extension (actual version: mysqlnd 8.1.8)
ext-openssl 8.1.8 The openssl PHP extension
ext-pcre 8.1.8 The pcre PHP extension
ext-pdo 8.1.8 The PDO PHP extension
ext-pdo_mysql 8.1.8 The pdo_mysql PHP extension
ext-pdo_sqlite 8.1.8 The pdo_sqlite PHP extension
ext-phar 8.1.8 The Phar PHP extension
ext-readline 8.1.8 The readline PHP extension
ext-reflection 8.1.8 The Reflection PHP extension
ext-session 8.1.8 The session PHP extension
ext-simplexml 8.1.8 The SimpleXML PHP extension
ext-soap 8.1.8 The soap PHP extension
ext-sockets 8.1.8 The sockets PHP extension
ext-spl 8.1.8 The SPL PHP extension
ext-sqlite3 8.1.8 The sqlite3 PHP extension
ext-tokenizer 8.1.8 The tokenizer PHP extension
ext-xdebug 3.1.5 The xdebug PHP extension
ext-xml 8.1.8 The xml PHP extension
ext-xmlreader 8.1.8 The xmlreader PHP extension
ext-xmlwriter 8.1.8 The xmlwriter PHP extension
ext-xsl 8.1.8 The xsl PHP extension
ext-zend-opcache 8.1.8 The Zend OPcache PHP extension
ext-zip 1.19.5 The zip PHP extension
ext-zlib 8.1.8 The zlib PHP extension
lib-bz2 1.0.8 The bz2 library
lib-curl 7.77.0 The curl library
lib-curl-libssh2 1.10.0 curl libssh2 version
lib-curl-openssl 1.1.1.16 curl OpenSSL version (1.1.1.16)
lib-curl-zlib 1.2.12 curl zlib version
lib-date-timelib 2021.12 date timelib version
lib-date-zoneinfo 2022.1 zoneinfo ("Olson") database for date
lib-fileinfo-libmagic 540 fileinfo libmagic version
lib-gd 2.0.35 The gd library
lib-gd-freetype 2.9.1 freetype version for gd
lib-gd-libjpeg 8.0 libjpeg version for gd
lib-gd-libpng 1.6.34 libpng version for gd
lib-gd-libxpm 3.5.12 libxpm version for gd
lib-gmp 6.0.0 The gmp library
lib-iconv 1.16 The iconv library
lib-icu 70.1 The ICU unicode and globalization support library
lib-icu-cldr 40 ICU CLDR project version
lib-icu-unicode 14.0.0 ICU unicode version
lib-ldap-openldap 2.4.47 OpenLDAP version of ldap
lib-libxml 2.9.12 libxml library version
lib-libxslt 1.1.34 The libxslt library
lib-libxslt-libxml 2.9.10 libxml version libxslt is compiled against
lib-mbstring-libmbfl 1.3.2 mbstring libmbfl version
lib-mbstring-oniguruma 6.9.7 mbstring oniguruma version
lib-openssl 1.1.1.16 OpenSSL 1.1.1p 21 Jun 2022
lib-pcre 10.39 The pcre library
lib-pcre-unicode 14.0.0 PCRE Unicode version support
lib-pdo_sqlite-sqlite 3.36.0 The pdo_sqlite-sqlite library
lib-sqlite3-sqlite 3.36.0 The sqlite3-sqlite library
lib-zip-libzip 1.7.1 The zip-libzip library
lib-zlib 1.2.12 The zlib library
php 8.1.8 The PHP interpreter
php-64bit 8.1.8 The PHP interpreter, 64bit
php-ipv6 8.1.8 The PHP interpreter, with IPv6 support
php-zts 8.1.8 The PHP interpreter, with Zend Thread Safety

@stof
Copy link
Contributor

stof commented Sep 28, 2022

Well, ext-psr is not in the list, so my idea is not the root cause (unless you have several PHP runtimes with different configuration of course).

So now, you will need to debug where the Psr\Log\LoggerInterface is coming from, to understand why its signature is not the one defined in psr/log 2.0.0

@RobertEcker
Copy link
Author

i am using WAMP
thank you so far for the help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants