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
3 changes: 2 additions & 1 deletion .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ concurrency:

jobs:
mutation:
uses: yiisoft/actions/.github/workflows/roave-infection.yml@master
uses: yiisoft/actions/.github/workflows/infection.yml@master
with:
os: >-
['ubuntu-latest']
php: >-
['8.5']
infection-args: --ignore-msi-with-no-mutations
secrets:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.92.5",
"httpsoft/http-message": "^1.1.6",
"infection/infection": "^0.29.8 || ^0.35.8",
"phpunit/phpunit": "^10.5.52",
"rector/rector": "^2.1.4",
"roave/infection-static-analysis-plugin": "^1.35",
"shipmonk/composer-dependency-analyser": "^1.8",
"vimeo/psalm": "^5.26.1 || ^6.8.0",
"yiisoft/di": "^1.4",
Expand Down
5 changes: 2 additions & 3 deletions docs/internals.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ The package is tested with [PHPUnit](https://phpunit.de/). To run tests:

## Mutation testing

The package tests are checked with [Infection](https://infection.github.io/) mutation framework with
[Infection Static Analysis Plugin](https://github.com/Roave/infection-static-analysis-plugin). To run it:
The package tests are checked with [Infection](https://infection.github.io/) mutation framework. To run it:

```shell
./vendor/bin/roave-infection-static-analysis-plugin
./vendor/bin/infection
```

## Static analysis
Expand Down
4 changes: 1 addition & 3 deletions src/DataStream/StringStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

public function eof(): bool
{
return $this->closed || $this->position >= $this->getContentSize();

Check warning on line 63 in src/DataStream/StringStream.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "LogicalOrAllSubExprNegation": @@ @@ public function eof(): bool { - return $this->closed || $this->position >= $this->getContentSize(); + return !$this->closed || !($this->position >= $this->getContentSize()); } public function isSeekable(): bool
}

public function isSeekable(): bool
Expand All @@ -83,7 +83,7 @@
default => throw new RuntimeException('Invalid whence value.'),
};

if ($newPosition < 0 || $newPosition > $size) {

Check warning on line 86 in src/DataStream/StringStream.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "GreaterThan": @@ @@ default => throw new RuntimeException('Invalid whence value.'), }; - if ($newPosition < 0 || $newPosition > $size) { + if ($newPosition < 0 || $newPosition >= $size) { throw new RuntimeException('Invalid seek position.'); }
throw new RuntimeException('Invalid seek position.');
}

Expand Down Expand Up @@ -116,11 +116,11 @@
throw new RuntimeException('Stream is closed.');
}

if ($length < 0) {

Check warning on line 119 in src/DataStream/StringStream.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "LessThan": @@ @@ throw new RuntimeException('Stream is closed.'); } - if ($length < 0) { + if ($length <= 0) { throw new RuntimeException('Length must be non-negative.'); }
throw new RuntimeException('Length must be non-negative.');
}

if ($this->position >= $this->getContentSize()) {

Check warning on line 123 in src/DataStream/StringStream.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "GreaterThanOrEqualTo": @@ @@ throw new RuntimeException('Length must be non-negative.'); } - if ($this->position >= $this->getContentSize()) { + if ($this->position > $this->getContentSize()) { return ''; }
return '';
}

Expand Down Expand Up @@ -157,9 +157,7 @@

private function getContentSize(): int
{
if ($this->size === null) {
$this->size = strlen($this->content);
}
$this->size ??= strlen($this->content);

return $this->size;
}
Expand Down
Loading