Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/bc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.0']
['8.4']
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
os: >-
['ubuntu-latest', 'windows-latest']
php: >-
['8.0', '8.1', '8.2', '8.3']
['8.0', '8.1', '8.2', '8.3', '8.4']
2 changes: 1 addition & 1 deletion .github/workflows/composer-require-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.0', '8.1', '8.2', '8.3']
['8.0', '8.1', '8.2', '8.3', '8.4']
2 changes: 1 addition & 1 deletion .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.3']
['8.4']
secrets:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
2 changes: 1 addition & 1 deletion .github/workflows/rector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.3']
['8.4']
2 changes: 1 addition & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.0', '8.1', '8.2', '8.3']
['8.0', '8.1', '8.2', '8.3', '8.4']
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## 2.1.1 under development

- no changes in this release.
- Bug #123: Explicitly marking parameters as nullable (@Tigrov)
- Bug #123: Fix `ContextValueExtractor::extract()` with empty key in PHP 8.4 (@Tigrov)

## 2.1.0 July 03, 2024

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
},
"require-dev": {
"maglnet/composer-require-checker": "^4.4",
"phpunit/phpunit": "^9.5",
"rector/rector": "^1.2",
"phpunit/phpunit": "^9.6",
"rector/rector": "^2.0",
"roave/infection-static-analysis-plugin": "^1.18",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.25"
"vimeo/psalm": "^4.30|^5.25|^6.0"
},
"provide": {
"psr/log-implementation": "1.0.0"
Expand Down
2 changes: 2 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
ensureOverrideAttribute="false"
findUnusedBaselineEntry="true"
findUnusedCode="false"
strictBinaryOperands="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
Expand Down
3 changes: 2 additions & 1 deletion src/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function message(): string
*
* @return mixed The context parameter value.
*/
public function context(string $name = null, mixed $default = null): mixed
public function context(?string $name = null, mixed $default = null): mixed
{
if ($name === null) {
return $this->context;
Expand Down Expand Up @@ -206,6 +206,7 @@ private function parse(string|Stringable $message, array $context): string
{
$message = (string) $message;

/** @var string */
return preg_replace_callback(
'/{(.*)}/',
static function (array $matches) use ($context) {
Expand Down
1 change: 0 additions & 1 deletion src/Message/CategoryFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Yiisoft\Log\Message;

use InvalidArgumentException;

use Yiisoft\Log\Message;

use function is_string;
Expand Down
5 changes: 3 additions & 2 deletions src/Message/ContextValueExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

$lastKey = array_pop($path);
$array = $context;

foreach ($path as $pathItem) {
$array = array_key_exists($pathItem, $array) ? $array[$pathItem] : null;
if (!is_array($array)) {
Expand All @@ -31,12 +32,12 @@
}

/**
* @psalm-return list<string>
* @psalm-return non-empty-list<string>
*/
private static function parsePath(string $path): array
{
if ($path === '') {
return [];
return [''];
}

if (!str_contains($path, '.')) {
Expand All @@ -57,8 +58,8 @@
$result = [];
$countResults = count($matches);
for ($i = 1; $i < $countResults; $i++) {
$l = $matches[$i][1] - $matches[$i - 1][1] - strlen($matches[$i - 1][0]) - 1;

Check warning on line 61 in src/Message/ContextValueExtractor.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "IncrementInteger": @@ @@ $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];
$result[] = $matches[$i - 1][0] . ($l > 0 ? str_repeat('\\', $l) : '');

Check warning on line 62 in src/Message/ContextValueExtractor.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "GreaterThan": @@ @@ $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); } }
}
$result[] = $matches[$countResults - 1][0];

Expand Down
Loading