Skip to content

Commit 0fe5e21

Browse files
authored
Merge pull request #1320 from kukulich/mutants
100 % mutation score
2 parents 03ad057 + 53c720d commit 0fe5e21

17 files changed

+370
-242
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Better Reflection
22
=================
33

4-
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FRoave%2FBetterReflection%2F6.0.x)](https://dashboard.stryker-mutator.io/reports/github.com/Roave/BetterReflection/6.0.x)
4+
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FRoave%2FBetterReflection%2F6.6.x)](https://dashboard.stryker-mutator.io/reports/github.com/Roave/BetterReflection/6.6.x)
55
[![Type Coverage](https://shepherd.dev/github/Roave/BetterReflection/coverage.svg)](https://shepherd.dev/github/Roave/BetterReflection)
66
[![Latest Stable Version](https://poser.pugx.org/roave/better-reflection/v/stable)](https://packagist.org/packages/roave/better-reflection)
77
[![License](https://poser.pugx.org/roave/better-reflection/license)](https://packagist.org/packages/roave/better-reflection)

composer.lock

Lines changed: 140 additions & 137 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

infection.json.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
"mutators": {
1414
"@default": true
1515
},
16-
"minMsi": 99,
16+
"minMsi": 100,
1717
"minCoveredMsi": 100
1818
}

src/SourceLocator/Type/AutoloadSourceLocator/FileReadTrapStreamWrapper.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static function withStreamWrapperOverride(
7272
$result = $executeMeWithinStreamWrapperOverride();
7373
} finally {
7474
foreach ($streamWrapperProtocols as $protocol) {
75-
stream_wrapper_restore($protocol);
75+
@stream_wrapper_restore($protocol);
7676
}
7777

7878
self::$registeredStreamWrapperProtocols = null;
@@ -101,6 +101,7 @@ public function stream_open($path, $mode, $options, &$opened_path): bool
101101
{
102102
self::$autoloadLocatedFile = $path;
103103

104+
// @infection-ignore-all FalseValue
104105
return false;
105106
}
106107

@@ -130,7 +131,7 @@ public function url_stat($path, $flags): array|bool
130131
stream_wrapper_restore($protocol);
131132
}
132133

133-
if ($flags & STREAM_URL_STAT_QUIET) {
134+
if (($flags & STREAM_URL_STAT_QUIET) === STREAM_URL_STAT_QUIET) {
134135
$result = @stat($path);
135136
} else {
136137
$result = stat($path);

src/SourceLocator/Type/Composer/Factory/MakeLocatorForComposerJson.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use function is_array;
2626
use function is_dir;
2727
use function is_file;
28+
use function is_string;
2829
use function json_decode;
2930
use function realpath;
3031

@@ -61,8 +62,11 @@ public function __invoke(string $installationPath, Locator $astLocator): SourceL
6162
throw MissingComposerJson::inProjectPath($installationPath);
6263
}
6364

65+
$composerJsonContent = file_get_contents($composerJsonPath);
66+
assert(is_string($composerJsonContent));
67+
6468
/** @psalm-var array{autoload: ComposerAutoload}|null $composer */
65-
$composer = json_decode((string) file_get_contents($composerJsonPath), true);
69+
$composer = json_decode($composerJsonContent, true);
6670

6771
if (! is_array($composer)) {
6872
throw FailedToParseJson::inFile($composerJsonPath);

src/SourceLocator/Type/Composer/Factory/MakeLocatorForComposerJsonAndInstalledJson.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use function is_array;
2828
use function is_dir;
2929
use function is_file;
30+
use function is_string;
3031
use function json_decode;
3132
use function realpath;
3233
use function rtrim;
@@ -52,8 +53,11 @@ public function __invoke(string $installationPath, Locator $astLocator): SourceL
5253
throw MissingComposerJson::inProjectPath($installationPath);
5354
}
5455

56+
$composerJsonContent = file_get_contents($composerJsonPath);
57+
assert(is_string($composerJsonContent));
58+
5559
/** @psalm-var Composer|null $composer */
56-
$composer = json_decode((string) file_get_contents($composerJsonPath), true);
60+
$composer = json_decode($composerJsonContent, true);
5761
$vendorDir = $composer['config']['vendor-dir'] ?? 'vendor';
5862
$vendorDir = rtrim($vendorDir, '/');
5963

@@ -63,8 +67,11 @@ public function __invoke(string $installationPath, Locator $astLocator): SourceL
6367
throw MissingInstalledJson::inProjectPath($realInstallationPath . '/' . $vendorDir);
6468
}
6569

70+
$jsonContent = file_get_contents($installedJsonPath);
71+
assert(is_string($jsonContent));
72+
6673
/** @psalm-var array{packages: list<mixed[]>}|list<mixed[]>|null $installedJson */
67-
$installedJson = json_decode((string) file_get_contents($installedJsonPath), true);
74+
$installedJson = json_decode($jsonContent, true);
6875

6976
if (! is_array($composer)) {
7077
throw FailedToParseJson::inFile($composerJsonPath);

src/SourceLocator/Type/Composer/Factory/MakeLocatorForInstalledJson.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use function is_array;
2828
use function is_dir;
2929
use function is_file;
30+
use function is_string;
3031
use function json_decode;
3132
use function realpath;
3233
use function rtrim;
@@ -52,8 +53,11 @@ public function __invoke(string $installationPath, Locator $astLocator): SourceL
5253
throw MissingComposerJson::inProjectPath($installationPath);
5354
}
5455

56+
$composerJsonContent = file_get_contents($composerJsonPath);
57+
assert(is_string($composerJsonContent));
58+
5559
/** @psalm-var Composer|null $composer */
56-
$composer = json_decode((string) file_get_contents($composerJsonPath), true);
60+
$composer = json_decode($composerJsonContent, true);
5761
$vendorDir = $composer['config']['vendor-dir'] ?? 'vendor';
5862
$vendorDir = rtrim($vendorDir, '/');
5963

@@ -63,8 +67,11 @@ public function __invoke(string $installationPath, Locator $astLocator): SourceL
6367
throw MissingInstalledJson::inProjectPath($realInstallationPath . '/' . $vendorDir);
6468
}
6569

70+
$jsonContent = file_get_contents($installedJsonPath);
71+
assert(is_string($jsonContent));
72+
6673
/** @var array{packages: list<mixed[]>}|list<mixed[]>|null $installedJson */
67-
$installedJson = json_decode((string) file_get_contents($installedJsonPath), true);
74+
$installedJson = json_decode($jsonContent, true);
6875

6976
if (! is_array($installedJson)) {
7077
throw FailedToParseJson::inFile($installedJsonPath);

src/SourceLocator/Type/FileIteratorSourceLocator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public function __construct(Iterator $fileInfoIterator, private Locator $astLoca
5353
/** @throws InvalidFileLocation */
5454
private function getAggregatedSourceLocator(): AggregateSourceLocator
5555
{
56+
// @infection-ignore-all Coalesce: There's no difference, it's just optimization
5657
return $this->aggregateSourceLocator
5758
?? $this->aggregateSourceLocator = new AggregateSourceLocator(array_values(array_filter(array_map(
5859
function (SplFileInfo $item): SingleFileSourceLocator|null {

src/Util/FileHelper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use function assert;
88
use function preg_match;
9+
use function sprintf;
910
use function str_replace;
1011

1112
use const DIRECTORY_SEPARATOR;
@@ -43,13 +44,14 @@ public static function normalizeSystemPath(string $originalPath): string
4344
[, $scheme, $path] = $matches;
4445
}
4546

47+
// @infection-ignore-all Identical Needed only on Windows
4648
if (DIRECTORY_SEPARATOR === '\\') {
4749
// @infection-ignore-all UnwrapStrReplace Needed only on Windows
4850
$path = str_replace('/', DIRECTORY_SEPARATOR, $path);
4951
}
5052

5153
assert($path !== '');
5254

53-
return ($scheme !== null ? $scheme . '://' : '') . $path;
55+
return ($scheme !== null ? sprintf('%s://', $scheme) : '') . $path;
5456
}
5557
}

test/unit/Fixture/InitializedProperties.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ public function __construct()
2424

2525
public function __get($property)
2626
{
27-
throw new Error();
27+
throw new Error('Removed property');
2828
}
2929
}

0 commit comments

Comments
 (0)