Skip to content

Declare the capabilities of Monolog and of psr/log's LoggerInterface in their library stubs - #12480

Closed
danog wants to merge 1 commit into
vimeo:masterfrom
danog:monolog-psr-log-capabilities
Closed

danog wants to merge 1 commit into
vimeo:masterfrom
danog:monolog-psr-log-capabilities

Conversation

@danog

@danog danog commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

Adds @psalm-capabilities (and @psalm-pure on the static level helpers) to the methods of the library stubs for monolog/monolog and to a new library stub for psr/log, so that code with declared capabilities can build a logging setup and log:

  • stubs/libraries/monolog/monolog.phpstub (monolog/monolog 3): Logger (getters read-props, setters read-props|write-this-props, logging, close() and reset() every capability but write-refs, getLevelName()/toMonologLevel() pure), the constructors and setters of AbstractHandler, StreamHandler, SocketHandler, ErrorLogHandler, GroupHandler, NormalizerFormatter, LineFormatter, JsonFormatter and WebProcessor, and FormattableHandlerInterface/FormattableHandlerTrait. The reasons for each set are in the stub's header. The file and SSRF sinks of the StreamHandler and SocketHandler constructors stay.
  • stubs/libraries/psr/log.phpstub: the methods of LoggerInterface, every capability but write-refs. Its signatures are those of psr/log 2, without the native void return types psr/log 3 adds (@return void instead), so that loggers written against psr/log 1 and 2 don't get MethodSignatureMustProvideReturnType once the stub makes the interface a stubbed one.

The declared methods keep the signatures and docblocks of monolog/monolog 3.10, since a stub's declaration replaces the method's.

LibraryStubsTestCase can now list other issue types than the taint ones (getReportedIssueTypePrefixes()); MonologLibraryStubsTest gets cases for the capabilities of Logger, LoggerInterface and a handler setup.

@danog

danog commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator Author

Landed through #12482, which contained this change (commit d1a5e3b): the stubs and tests are identical on master.

@danog danog closed this Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:feature The PR will be included in 'Features' section of the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant