Skip to content

Commit

Permalink
Merge pull request #164 from Roave/renovate/doctrine-coding-standard-…
Browse files Browse the repository at this point in the history
…10.x

Update dependency doctrine/coding-standard to v10
  • Loading branch information
Ocramius authored Oct 31, 2022
2 parents d79cc2e + ef3f009 commit 639a4b9
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 69 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"bin/roave-no-leaks"
],
"require-dev": {
"doctrine/coding-standard": "^9.0.2",
"doctrine/coding-standard": "^10.0.0",
"roave/infection-static-analysis-plugin": "^1.25.0",
"psalm/plugin-phpunit": "^0.17.0",
"squizlabs/php_codesniffer": "^3.7.1",
Expand Down
50 changes: 27 additions & 23 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/CollectTestExecutionMemoryFootprints.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ public function executeAfterLastTest(): void

$baselineMemoryUsage = MeasuredBaselineTestMemoryLeak::fromBaselineTestMemoryUsages(
$this->preTestMemoryUsages[EmptyBaselineMemoryUsageTest::class . '::' . EmptyBaselineMemoryUsageTest::TEST_METHOD],
$this->postTestMemoryUsages[EmptyBaselineMemoryUsageTest::class . '::' . EmptyBaselineMemoryUsageTest::TEST_METHOD]
$this->postTestMemoryUsages[EmptyBaselineMemoryUsageTest::class . '::' . EmptyBaselineMemoryUsageTest::TEST_METHOD],
);

unset(
$this->preTestMemoryUsages[EmptyBaselineMemoryUsageTest::class . '::' . EmptyBaselineMemoryUsageTest::TEST_METHOD],
$this->postTestMemoryUsages[EmptyBaselineMemoryUsageTest::class . '::' . EmptyBaselineMemoryUsageTest::TEST_METHOD]
$this->postTestMemoryUsages[EmptyBaselineMemoryUsageTest::class . '::' . EmptyBaselineMemoryUsageTest::TEST_METHOD],
);

$successfullyExecutedTests = array_intersect_key($this->preTestMemoryUsages, $this->postTestMemoryUsages);
Expand All @@ -97,8 +97,8 @@ public function executeAfterLastTest(): void
array_map(
[MeasuredTestRunMemoryLeak::class, 'fromTestMemoryUsages'],
$successfullyExecutedTests,
$this->postTestMemoryUsages
)
$this->postTestMemoryUsages,
),
);

$leaks = array_filter(array_map(static function (MeasuredTestRunMemoryLeak $profile) use ($baselineMemoryUsage): bool {
Expand All @@ -108,7 +108,7 @@ public function executeAfterLastTest(): void
if ($leaks !== []) {
throw new Exception(sprintf(
"The following test produced memory leaks:\n * %s\n",
implode("\n * ", array_keys($leaks))
implode("\n * ", array_keys($leaks)),
));
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/MeasuredBaselineTestMemoryLeak.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private function __construct(private readonly array $baselineTestRunsMemoryLeaks
*/
public static function fromBaselineTestMemoryUsages(
array $preBaselineTestMemoryUsages,
array $postBaselineTestMemoryUsages
array $postBaselineTestMemoryUsages,
): self {
if (count($preBaselineTestMemoryUsages) !== count($postBaselineTestMemoryUsages)) {
throw new Exception('Pre- and post- baseline test run collected memory usages don\'t match in number');
Expand All @@ -62,13 +62,13 @@ public static function fromBaselineTestMemoryUsages(
$relevantMemoryUsages,
static function (int $memoryUsage): bool {
return $memoryUsage >= 0;
}
},
);

if (count($nonNegativeMemoryUsages) < 2) {
throw new Exception(sprintf(
'At least 3 baseline test run memory profiles are required, %d given',
count($nonNegativeMemoryUsages) + 1
count($nonNegativeMemoryUsages) + 1,
));
}

Expand All @@ -80,7 +80,7 @@ static function (int $memoryUsage): bool {
// @TODO good enough for detecting standard deviation for now, I guess? :|
throw new Exception(sprintf(
'Very inconsistent baseline memory usage profiles: could not find two equal values in profile %s',
json_encode($memoryUsages, JSON_THROW_ON_ERROR)
json_encode($memoryUsages, JSON_THROW_ON_ERROR),
));
}

Expand Down
4 changes: 2 additions & 2 deletions src/MeasuredTestRunMemoryLeak.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private function __construct(private readonly array $memoryUsages)
*/
public static function fromTestMemoryUsages(
array $preRunMemoryUsages,
array $postRunMemoryUsages
array $postRunMemoryUsages,
): self {
$snapshotsCount = min(count($preRunMemoryUsages), count($postRunMemoryUsages));

Expand All @@ -52,7 +52,7 @@ public function leaksMemory(MeasuredBaselineTestMemoryLeak $baseline): bool
static function (int $memoryUsage) use ($baseline): bool {
return ! $baseline->lessThan($memoryUsage);
},
$this->memoryUsages
$this->memoryUsages,
)) === [];
}
}
2 changes: 1 addition & 1 deletion test/e2e/LeakyIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function doesNotLeakMemoryIfCyclesAreGarbageCollected(): void
$a = new stdClass();
$b = new stdClass();
$c = new class () extends stdClass {
public ?stdClass $a = null;
public stdClass|null $a = null;

public function __destruct()
{
Expand Down
14 changes: 4 additions & 10 deletions test/unit/CollectTestExecutionMemoryFootprintsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ public function testWillCollectFootprints(): void
$this->expectExceptionMessage(<<<'MESSAGE'
The following test produced memory leaks:
* memoryEatingTest
MESSAGE
);
MESSAGE);

$collector->executeAfterLastTest();

Expand Down Expand Up @@ -120,8 +119,7 @@ public function testGarbageCollectedMemoryCyclesAreNotReportedAsFailures(): void
$this->expectExceptionMessage(<<<'MESSAGE'
The following test produced memory leaks:
* memoryEatingTest
MESSAGE
);
MESSAGE);

$collector->executeAfterLastTest();

Expand All @@ -130,9 +128,7 @@ public function testGarbageCollectedMemoryCyclesAreNotReportedAsFailures(): void

public function testWillFailIfBaselineTestCouldNotBeRun(): void
{
$this->expectExceptionMessage(
'Could not find baseline test: impossible to determine PHPUnit base memory overhead'
);
$this->expectExceptionMessage('Could not find baseline test: impossible to determine PHPUnit base memory overhead');

(new CollectTestExecutionMemoryFootprints())
->executeAfterLastTest();
Expand Down Expand Up @@ -164,9 +160,7 @@ public function testWillFailIfBaselineTestCouldNotBeRunSuccessfully(): void

$collector->executeBeforeTest(Baseline::class . '::' . Baseline::TEST_METHOD);

$this->expectExceptionMessage(
'Could not find baseline test: impossible to determine PHPUnit base memory overhead'
);
$this->expectExceptionMessage('Could not find baseline test: impossible to determine PHPUnit base memory overhead');

$collector->executeAfterLastTest();
}
Expand Down
20 changes: 10 additions & 10 deletions test/unit/MeasuredBaselineTestMemoryLeakTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function testDetectsAverageMemoryLeakThresholdByExcludingFirstProfile():
{
$measured = MeasuredBaselineTestMemoryLeak::fromBaselineTestMemoryUsages(
[100, 40, 50, 60, 70, 80],
[200, 40, 60, 80, 100, 110]
[200, 40, 60, 80, 100, 110],
);

self::assertTrue($measured->lessThan(19));
Expand All @@ -26,12 +26,12 @@ public function testRejectsHighlyInconsistentProfiles(): void
{
$this->expectExceptionMessage(
'Very inconsistent baseline memory usage profiles: '
. 'could not find two equal values in profile [100,10,20,30,40]'
. 'could not find two equal values in profile [100,10,20,30,40]',
);

MeasuredBaselineTestMemoryLeak::fromBaselineTestMemoryUsages(
[100, 50, 60, 70, 80],
[200, 60, 80, 100, 120]
[200, 60, 80, 100, 120],
);
}

Expand All @@ -40,20 +40,20 @@ public function testFiltersNegativeMemoryLeaks(): void
self::assertEquals(
MeasuredBaselineTestMemoryLeak::fromBaselineTestMemoryUsages(
[100, 51, 52, 53],
[200, 51, 53, 54]
[200, 51, 53, 54],
),
MeasuredBaselineTestMemoryLeak::fromBaselineTestMemoryUsages(
[100, 50, 51, 51, 53],
[200, 49, 51, 52, 54]
)
[200, 49, 51, 52, 54],
),
);
}

public function testRejectsDataSetWithTooFewMemoryLeakProfiles(): void
{
$validMeasurement = MeasuredBaselineTestMemoryLeak::fromBaselineTestMemoryUsages(
[100, 50, 60],
[200, 50, 60]
[200, 50, 60],
);

self::assertTrue($validMeasurement->lessThan(1));
Expand All @@ -63,7 +63,7 @@ public function testRejectsDataSetWithTooFewMemoryLeakProfiles(): void

MeasuredBaselineTestMemoryLeak::fromBaselineTestMemoryUsages(
[100, 50],
[200, 50]
[200, 50],
);
}

Expand All @@ -73,7 +73,7 @@ public function testRejectsDataSetWithTooFewValidMemoryLeakProfiles(): void

MeasuredBaselineTestMemoryLeak::fromBaselineTestMemoryUsages(
[100, 50, 50],
[200, 50, 49]
[200, 50, 49],
);
}

Expand All @@ -83,7 +83,7 @@ public function testRejectsDataSetWithDifferentPreAndPostMemoryUsageSnapshots():

MeasuredBaselineTestMemoryLeak::fromBaselineTestMemoryUsages(
[100, 50, 52],
[200, 49]
[200, 49],
);
}
}
Loading

0 comments on commit 639a4b9

Please sign in to comment.