Skip to content

Commit

Permalink
CS Fixes - Doc Comments & Nowdocs
Browse files Browse the repository at this point in the history
- SlevomatCodingStandard.Commenting.RequireOneLineDocComment
- SlevomatCodingStandard.PHP.RequireNowdoc

Signed-off-by: George Steel <[email protected]>
  • Loading branch information
gsteel committed Aug 29, 2022
1 parent 6edfebc commit b6d38ba
Show file tree
Hide file tree
Showing 23 changed files with 102 additions and 161 deletions.
4 changes: 1 addition & 3 deletions src/Changelog/ChangelogExists.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

interface ChangelogExists
{
/**
* @param non-empty-string $repositoryDirectory
*/
/** @param non-empty-string $repositoryDirectory */
public function __invoke(
BranchName $sourceBranch,
string $repositoryDirectory,
Expand Down
4 changes: 1 addition & 3 deletions src/Changelog/ChangelogExistsViaConsole.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

class ChangelogExistsViaConsole implements ChangelogExists
{
/**
* @param non-empty-string $repositoryDirectory
*/
/** @param non-empty-string $repositoryDirectory */
public function __invoke(
BranchName $sourceBranch,
string $repositoryDirectory,
Expand Down
16 changes: 4 additions & 12 deletions src/Changelog/ChangelogReleaseNotes.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
use Psl\Str;
use RuntimeException;

/**
* @psalm-immutable
*/
/** @psalm-immutable */
class ChangelogReleaseNotes
{
private const CONCATENATION_STRING = "\n\n-----\n\n";
Expand All @@ -22,9 +20,7 @@ class ChangelogReleaseNotes
/** @psalm-var non-empty-string */
private string $contents;

/**
* @psalm-param non-empty-string $changelogFile
*/
/** @psalm-param non-empty-string $changelogFile */
public static function writeChangelogFile(string $changelogFile, self $releaseNotes): void
{
// Nothing to do
Expand All @@ -44,9 +40,7 @@ public static function writeChangelogFile(string $changelogFile, self $releaseNo
);
}

/**
* @psalm-param non-empty-string $contents
*/
/** @psalm-param non-empty-string $contents */
public function __construct(
string $contents,
?ChangelogEntry $changelogEntry = null,
Expand All @@ -59,9 +53,7 @@ public function __construct(
$this->changelogEntry = $changelogEntry;
}

/**
* @psalm-return non-empty-string
*/
/** @psalm-return non-empty-string */
public function contents(): string
{
return $this->contents;
Expand Down
4 changes: 1 addition & 3 deletions src/Changelog/CommitReleaseChangelog.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

interface CommitReleaseChangelog
{
/**
* @psalm-param non-empty-string $repositoryDirectory
*/
/** @psalm-param non-empty-string $repositoryDirectory */
public function __invoke(
ChangelogReleaseNotes $releaseNotes,
string $repositoryDirectory,
Expand Down
4 changes: 1 addition & 3 deletions src/Changelog/CommitReleaseChangelogViaKeepAChangelog.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ public function __construct(
$this->logger = $logger;
}

/**
* @psalm-param non-empty-string $repositoryDirectory
*/
/** @psalm-param non-empty-string $repositoryDirectory */
public function __invoke(
ChangelogReleaseNotes $releaseNotes,
string $repositoryDirectory,
Expand Down
4 changes: 1 addition & 3 deletions src/Git/CheckoutBranch.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

interface CheckoutBranch
{
/**
* @psalm-param non-empty-string $repositoryDirectory
*/
/** @psalm-param non-empty-string $repositoryDirectory */
public function __invoke(
string $repositoryDirectory,
BranchName $branchName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ public function url(): UriInterface
return $this->url;
}

/**
* @psalm-suppress ImpureFunctionCall the {@see \Psl\Iter\all()} API is conditionally pure
*/
/** @psalm-suppress ImpureFunctionCall the {@see \Psl\Iter\all()} API is conditionally pure */
public function assertAllIssuesAreClosed(): void
{
Psl\invariant(Iter\all($this->entries, static function (IssueOrPullRequest $entry): bool {
Expand Down
4 changes: 1 addition & 3 deletions src/Github/CreateReleaseText.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@

interface CreateReleaseText
{
/**
* @psalm-param non-empty-string $repositoryDirectory
*/
/** @psalm-param non-empty-string $repositoryDirectory */
public function __invoke(
Milestone $milestone,
RepositoryName $repositoryName,
Expand Down
33 changes: 17 additions & 16 deletions test/unit/Application/CreateMergeUpPullRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,19 @@ protected function setUp(): void
$this->createPullRequest,
);

$this->event = MilestoneClosedEvent::fromEventJson(<<<'JSON'
{
"milestone": {
"title": "1.2.3",
"number": 123
},
"repository": {
"full_name": "foo/bar"
},
"action": "closed"
}
JSON,
$this->event = MilestoneClosedEvent::fromEventJson(
<<<'JSON'
{
"milestone": {
"title": "1.2.3",
"number": 123
},
"repository": {
"full_name": "foo/bar"
},
"action": "closed"
}
JSON,
);

$this->branches = MergeTargetCandidateBranches::fromAllBranches(
Expand Down Expand Up @@ -245,10 +246,10 @@ public function testWillSkipMergeUpPullRequestOnNoMergeUpCandidate(): void
self::assertSame(0, $this->command->run(new ArrayInput([]), $output));

self::assertSame(
<<<OUTPUT
No merge-up candidate for release 1.2.3 - skipping pull request creation
OUTPUT
<<<'OUTPUT'
No merge-up candidate for release 1.2.3 - skipping pull request creation
OUTPUT
,
$output->fetch(),
);
Expand Down
9 changes: 4 additions & 5 deletions test/unit/Application/CreateMilestonesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;

/**
* @covers \Laminas\AutomaticReleases\Application\Command\CreateMilestones
*/
/** @covers \Laminas\AutomaticReleases\Application\Command\CreateMilestones */
final class CreateMilestonesTest extends TestCase
{
/** @var LoadCurrentGithubEvent&MockObject */
Expand All @@ -45,7 +43,8 @@ protected function setUp(): void
$this->createMilestone,
);

$this->event = MilestoneClosedEvent::fromEventJson(<<<'JSON'
$this->event = MilestoneClosedEvent::fromEventJson(
<<<'JSON'
{
"milestone": {
"title": "1.2.3",
Expand All @@ -56,7 +55,7 @@ protected function setUp(): void
},
"action": "closed"
}
JSON,
JSON,
);

$this->releaseVersion = SemVerVersion::fromMilestoneName('1.2.3');
Expand Down
25 changes: 13 additions & 12 deletions test/unit/Application/ReleaseCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,19 @@ protected function setUp(): void
$this->createRelease,
);

$this->event = MilestoneClosedEvent::fromEventJson(<<<'JSON'
{
"milestone": {
"title": "1.2.3",
"number": 123
},
"repository": {
"full_name": "foo/bar"
},
"action": "closed"
}
JSON,
$this->event = MilestoneClosedEvent::fromEventJson(
<<<'JSON'
{
"milestone": {
"title": "1.2.3",
"number": 123
},
"repository": {
"full_name": "foo/bar"
},
"action": "closed"
}
JSON,
);

$this->branches = MergeTargetCandidateBranches::fromAllBranches(
Expand Down
33 changes: 17 additions & 16 deletions test/unit/Application/SwitchDefaultBranchToNextMinorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,19 @@ protected function setUp(): void
$this->bumpChangelogVersion,
);

$this->event = MilestoneClosedEvent::fromEventJson(<<<'JSON'
{
"milestone": {
"title": "1.2.3",
"number": 123
},
"repository": {
"full_name": "foo/bar"
},
"action": "closed"
}
JSON,
$this->event = MilestoneClosedEvent::fromEventJson(
<<<'JSON'
{
"milestone": {
"title": "1.2.3",
"number": 123
},
"repository": {
"full_name": "foo/bar"
},
"action": "closed"
}
JSON,
);

$key = (new ImportGpgKeyFromStringViaTemporaryFile())
Expand Down Expand Up @@ -239,10 +240,10 @@ public function testWillNotSwitchDefaultBranchIfNoBranchesExist(): void
self::assertSame(0, $this->command->run(new ArrayInput([]), $output));

self::assertSame(
<<<OUTPUT
No stable branches found: cannot switch default branch
OUTPUT
<<<'OUTPUT'
No stable branches found: cannot switch default branch
OUTPUT
,
$output->fetch(),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,7 @@ public function testAddsNewReleaseVersionUsingBumpTypeToChangelogFileAndCommitsA
);
}

/**
* @psalm-return non-empty-string
*/
/** @psalm-return non-empty-string */
private function createMockChangelog(): string
{
$repo = Filesystem\create_temporary_file(Env\temp_dir(), 'BumpAndCommitChangelogVersion');
Expand Down
4 changes: 1 addition & 3 deletions test/unit/Changelog/ChangelogExistsViaConsoleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ public function testReturnsTrueWhenChangelogIsPresentInBranch(): void
);
}

/**
* @psalm-return non-empty-string
*/
/** @psalm-return non-empty-string */
private function createMockRepositoryWithChangelog(): string
{
$repo = Filesystem\create_temporary_file(Env\temp_dir(), 'ChangelogExists');
Expand Down
8 changes: 2 additions & 6 deletions test/unit/Changelog/ChangelogReleaseNotesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
use function Psl\File\read;
use function Psl\File\write;

/**
* @covers \Laminas\AutomaticReleases\Changelog\ChangelogReleaseNotes
*/
/** @covers \Laminas\AutomaticReleases\Changelog\ChangelogReleaseNotes */
class ChangelogReleaseNotesTest extends TestCase
{
public function testInitialContentsAreThoseProvidedToConstructor(): void
Expand Down Expand Up @@ -150,9 +148,7 @@ public function releaseNotesProvider(): iterable
];
}

/**
* @dataProvider releaseNotesProvider
*/
/** @dataProvider releaseNotesProvider */
public function testMergedInstanceContainsChangelogEntryFromTheInstanceThatHadOne(
ChangelogReleaseNotes $original,
ChangelogReleaseNotes $secondary,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,7 @@ public function testWritesCommitsAndPushesChangelogWhenFoundAndReadyToRelease():
$this->assertStringNotContainsString($existingChangelog, $contents);
}

/**
* @psalm-return non-empty-string
*/
/** @psalm-return non-empty-string */
private function createMockRepositoryWithChangelog(
string $template,
string $filename = 'CHANGELOG.md',
Expand Down
20 changes: 5 additions & 15 deletions test/unit/Git/Value/BranchNameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

final class BranchNameTest extends TestCase
{
/**
* @dataProvider genericBranchNames
*/
/** @dataProvider genericBranchNames */
public function testAllowsAnyBranchName(string $inputName): void
{
$branch = BranchName::fromName($inputName);
Expand Down Expand Up @@ -44,9 +42,7 @@ public function testDisallowsEmptyBranchName(): void
BranchName::fromName('');
}

/**
* @dataProvider releaseBranches
*/
/** @dataProvider releaseBranches */
public function testDetectsReleaseBranchVersions(string $inputName, int $major, int $minor): void
{
$branch = BranchName::fromName($inputName);
Expand Down Expand Up @@ -75,9 +71,7 @@ public function testEquals(): void
self::assertTrue(BranchName::fromName('foo')->equals(BranchName::fromName('foo')));
}

/**
* @dataProvider versionEqualityProvider
*/
/** @dataProvider versionEqualityProvider */
public function testIsForVersion(string $milestoneName, string $branchName, bool $expected): void
{
self::assertSame(
Expand All @@ -104,9 +98,7 @@ public function versionEqualityProvider(): array
];
}

/**
* @dataProvider newerVersionComparisonProvider
*/
/** @dataProvider newerVersionComparisonProvider */
public function testIsForNewerVersionThan(string $milestoneName, string $branchName, bool $expected): void
{
self::assertSame(
Expand Down Expand Up @@ -134,9 +126,7 @@ public function newerVersionComparisonProvider(): array
];
}

/**
* @dataProvider targetVersionProvider
*/
/** @dataProvider targetVersionProvider */
public function testTargetMinorReleaseVersion(string $branchName, string $expectedVersion): void
{
self::assertEquals(
Expand Down
Loading

0 comments on commit b6d38ba

Please sign in to comment.