Develop#5
Merged
Merged
Conversation
…e test suite quality The previous implementation of the IntrospectionProcessor was brittle, relying on a fixed 'stackDepth' that would break tests when the call stack changed due to framework updates or other refactors. This commit introduces a more robust and intelligent approach: - The IntrospectionProcessor is refactored to dynamically find the true origin of a log call by identifying the boundary between application code and the logging library itself. This removes the fragile 'stackDepth' configuration. - Key test suites, including IntrospectionProcessorTest, LoggerManagerTest, and LoggerBuilderTest, have been rewritten to a higher quality standard, using semantic method names, clear Arrange-Act-Assert blocks, and more precise assertions. - The obsolete `toArray()` method has been removed from `LogRecord` and related formatters, promoting direct property access and a cleaner immutable pattern. - A new, comprehensive `real_world_example.php` has been added to provide a practical demonstration of the library's features in a realistic application context, replacing the older example file.
Previously, components requiring a logger had to handle cases where one might not be provided, often leading to nullable properties (`?Logger`) and conditional checks. This increased complexity and the risk of fatal errors if a null logger was used. This commit introduces the `SilentLogger`, a new class that implements the Null Object Pattern for the Logger interface. - The `SilentLogger` can be used as a default or fallback logger. - It silently discards all log messages it receives, ensuring that calls to methods like `info()` or `error()` are always safe, even when no actual logging is configured. - This eliminates the need for `null` checks in client code (e.g., services, command executors), resulting in a cleaner and more robust design. A corresponding PHPUnit test (`SilentLoggerTest.php`) is included to ensure the class adheres to the Logger contract and functions correctly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.