Improve psalm #443
Annotations
10 warnings
mutation / PHP 8.3-ubuntu-latest:
src/ContextProvider/SystemContextProvider.php#L28
Escaped Mutant for Mutator "DecrementInteger":
--- Original
+++ New
@@ @@
* @param string[] $excludedTracePaths Array of paths to exclude from tracing when tracing is enabled
* with {@see $traceLevel}.
*/
- public function __construct(private int $traceLevel = 0, array $excludedTracePaths = [])
+ public function __construct(private int $traceLevel = -1, array $excludedTracePaths = [])
{
/** @psalm-suppress DeprecatedMethod `setExcludedTracePaths` will be private and not deprecated */
$this->setExcludedTracePaths($excludedTracePaths);
|
mutation / PHP 8.3-ubuntu-latest:
src/ContextProvider/SystemContextProvider.php#L40
Escaped Mutant for Mutator "ArrayItemRemoval":
--- Original
+++ New
@@ @@
/** @psalm-var list<TraceItem> $trace */
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
array_shift($trace);
- return ['time' => microtime(true), 'trace' => $this->collectTrace($trace), 'memory' => memory_get_usage(), 'category' => Message::DEFAULT_CATEGORY];
+ return ['trace' => $this->collectTrace($trace), 'memory' => memory_get_usage(), 'category' => Message::DEFAULT_CATEGORY];
}
/**
* Sets how much call stack information (file name and line number) should be logged for each log message.
|
mutation / PHP 8.3-ubuntu-latest:
src/ContextProvider/SystemContextProvider.php#L41
Escaped Mutant for Mutator "ArrayItem":
--- Original
+++ New
@@ @@
/** @psalm-var list<TraceItem> $trace */
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
array_shift($trace);
- return ['time' => microtime(true), 'trace' => $this->collectTrace($trace), 'memory' => memory_get_usage(), 'category' => Message::DEFAULT_CATEGORY];
+ return ['time' > microtime(true), 'trace' => $this->collectTrace($trace), 'memory' => memory_get_usage(), 'category' => Message::DEFAULT_CATEGORY];
}
/**
* Sets how much call stack information (file name and line number) should be logged for each log message.
|
mutation / PHP 8.3-ubuntu-latest:
src/ContextProvider/SystemContextProvider.php#L110
Escaped Mutant for Mutator "UnwrapArrayFilter":
--- Original
+++ New
@@ @@
$count = 0;
foreach ($backtrace as $trace) {
if (isset($trace['file'], $trace['line'])) {
- $excludedMatch = array_filter($this->excludedTracePaths, static fn($path) => str_contains($trace['file'], $path));
+ $excludedMatch = $this->excludedTracePaths;
if (empty($excludedMatch)) {
$traces[] = $trace;
if (++$count >= $this->traceLevel) {
|
mutation / PHP 8.3-ubuntu-latest:
src/Logger.php#L92
Escaped Mutant for Mutator "FunctionCallRemoval":
--- Original
+++ New
@@ @@
{
$this->setTargets($targets);
$this->contextProvider = $contextProvider ?? new SystemContextProvider();
- register_shutdown_function(function () {
- // make regular flush before other shutdown functions, which allows session data collection and so on
- $this->flush();
- // make sure log entries written by shutdown functions are also flushed
- // ensure "flush()" is called last when there are multiple shutdown functions
- register_shutdown_function([$this, 'flush'], true);
- });
+
}
/**
* Returns the text display of the specified level.
|
mutation / PHP 8.3-ubuntu-latest:
src/Logger.php#L149
Escaped Mutant for Mutator "GreaterThan":
--- Original
+++ New
@@ @@
{
self::assertLevelIsString($level);
$this->messages[] = new Message($level, $message, array_merge($this->contextProvider->getContext(), $context));
- if ($this->flushInterval > 0 && count($this->messages) >= $this->flushInterval) {
+ if ($this->flushInterval >= 0 && count($this->messages) >= $this->flushInterval) {
$this->flush();
}
}
|
mutation / PHP 8.3-ubuntu-latest:
src/Logger.php#L234
Escaped Mutant for Mutator "MethodCallRemoval":
--- Original
+++ New
@@ @@
public static function assertLevelIsValid(mixed $level) : void
{
self::assertLevelIsString($level);
- self::assertLevelIsSupported($level);
+
}
/**
* Asserts that the log message level is a string.
|
mutation / PHP 8.3-ubuntu-latest:
src/Logger.php#L246
Escaped Mutant for Mutator "PublicVisibility":
--- Original
+++ New
@@ @@
*
* @psalm-assert string $level
*/
- public static function assertLevelIsString(mixed $level) : void
+ protected static function assertLevelIsString(mixed $level) : void
{
if (is_string($level)) {
return;
|
mutation / PHP 8.3-ubuntu-latest:
src/Message/ContextValueExtractor.php#L60
Escaped Mutant for Mutator "IncrementInteger":
--- Original
+++ New
@@ @@
$result = [];
$countResults = count($matches);
for ($i = 1; $i < $countResults; $i++) {
- $l = $matches[$i][1] - $matches[$i - 1][1] - strlen($matches[$i - 1][0]) - 1;
+ $l = $matches[$i][1] - $matches[$i - 1][1] - strlen($matches[$i - 1][0]) - 2;
$result[] = $matches[$i - 1][0] . ($l > 0 ? str_repeat('\\', $l) : '');
}
$result[] = $matches[$countResults - 1][0];
|
mutation / PHP 8.3-ubuntu-latest:
src/Message/ContextValueExtractor.php#L61
Escaped Mutant for Mutator "GreaterThan":
--- Original
+++ New
@@ @@
$countResults = count($matches);
for ($i = 1; $i < $countResults; $i++) {
$l = $matches[$i][1] - $matches[$i - 1][1] - strlen($matches[$i - 1][0]) - 1;
- $result[] = $matches[$i - 1][0] . ($l > 0 ? str_repeat('\\', $l) : '');
+ $result[] = $matches[$i - 1][0] . ($l >= 0 ? str_repeat('\\', $l) : '');
}
$result[] = $matches[$countResults - 1][0];
return array_map(static fn(string $key): string => str_replace(['\\\\', '\\.'], ['\\', '.'], $key), $result);
}
}
|