Skip to content

Commit

Permalink
♻️ Fix PHP8 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jmleroux committed Aug 25, 2023
1 parent 488d3eb commit c7e1021
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 19 deletions.
4 changes: 2 additions & 2 deletions spec/Akeneo/Crowdin/PackagesDownloaderSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ function it_download_every_locale(
Download $downloadApi
) {
$client->api('export')->willReturn($exportApi);
$exportApi->setBranch('master')->shouldBeCalled();
$exportApi->setBranch('master')->willReturn($exportApi)->shouldBeCalled();
$exportApi->execute()->shouldBeCalled();

$client->api('download')->willReturn($downloadApi);
$downloadApi->setBranch('master')->shouldBeCalled();
$downloadApi->setBranch('master')->willReturn($downloadApi)->shouldBeCalled();
$downloadApi->setCopyDestination('/tmp/')->shouldBeCalled()->willReturn($downloadApi);

$downloadApi->setPackage('fr.zip')->shouldBeCalled()->willReturn($downloadApi);
Expand Down
4 changes: 2 additions & 2 deletions spec/Akeneo/Crowdin/TranslatedProgressSelectorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ function it_displays_packages(
$statusApi->execute()->willReturn(self::XML_STATUS);
$client->api('language-status')->willReturn($languageStatusApi);

$languageStatusApi->setLanguage('af')->shouldBeCalled();
$languageStatusApi->setLanguage('fr')->shouldBeCalled();
$languageStatusApi->setLanguage('af')->willReturn($languageStatusApi)->shouldBeCalled();
$languageStatusApi->setLanguage('fr')->willReturn($languageStatusApi)->shouldBeCalled();
$languageStatusApi->execute()->willReturn(self::XML_LANGUAGE_STATUS);

$this->display(new ConsoleOutput());
Expand Down
4 changes: 2 additions & 2 deletions spec/Akeneo/Crowdin/TranslationFilesCreatorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ function it_should_create_file_when_it_does_not_exist(
$file->getPattern()->willReturn('Project/src/fr.yml');
$resolver->getTarget('/tmp/', '/tmp/src/fr.yml')->willReturn('fr.yml');

$addFileApi->setBranch('master')->shouldBeCalled();
$addFileApi->addTranslation('/tmp/src/fr.yml', 'fr.yml', 'Project/src/fr.yml')->shouldBeCalled();
$addFileApi->setBranch('master')->willReturn($addFileApi)->shouldBeCalled();
$addFileApi->addTranslation('/tmp/src/fr.yml', 'fr.yml', 'Project/src/fr.yml')->willReturn($addFileApi)->shouldBeCalled();
$addFileApi->getTranslations()->willReturn(['a_translation']);
$addFileApi->execute()->shouldBeCalled();

Expand Down
2 changes: 1 addition & 1 deletion spec/Akeneo/Crowdin/TranslationFilesUpdaterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function it_should_update_files(
$file->getPattern()->willReturn('Project/src/fr.yml');
$resolver->getTarget('/tmp/', '/tmp/src/fr.yml')->willReturn('fr.yml');

$updateFileApi->addTranslation('/tmp/src/fr.yml', 'fr.yml', 'Project/src/fr.yml')->shouldBeCalled();
$updateFileApi->addTranslation('/tmp/src/fr.yml', 'fr.yml', 'Project/src/fr.yml')->willReturn($updateFileApi)->shouldBeCalled();
$updateFileApi->getTranslations()->willReturn(['a_translation']);
$updateFileApi->execute()->shouldBeCalled();

Expand Down
2 changes: 1 addition & 1 deletion src/Akeneo/Git/ProjectCloner.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected function cloneUpstream($projectDir): void
$this->repository
)
);
$this->eventDispatcher->dispatch(New GenericEvent(), Events::POST_GITHUB_CLONE);
$this->eventDispatcher->dispatch(new GenericEvent(), Events::POST_GITHUB_CLONE);
}

/**
Expand Down
10 changes: 1 addition & 9 deletions src/Akeneo/Git/PullRequestCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,8 @@ public function __construct(

/**
* Create a new Pull Request
*
* @param string|null $baseBranch
* @param string $baseDir
* @param string $projectDir
* @param boolean $dryRun
*
* @return array|null
* @throws \Exception
*/
public function create($baseBranch, $baseDir, $projectDir, $dryRun = false): ?array
public function create(?string $baseBranch, string $baseDir, string $projectDir, bool $dryRun = false): ?array
{
$branch = $this->getBranchName($baseBranch);

Expand Down
2 changes: 1 addition & 1 deletion src/Akeneo/Nelson/PullTranslationsExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected function pullTranslations(

if ($this->diffChecker->haveDiff($projectDir)) {
$pullRequest = $this->pullRequestCreator->create($githubBranch, $options['base_dir'], $projectDir, $dryRun);
if (null !== $pullRequest) {
if (!$dryRun && null !== $pullRequest) {
$this->pullRequestMerger->mergePullRequest($pullRequest);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private function createMockCLient(): Client
);

$languageStatus = $this->createMock(LanguageStatus::class);
$languageStatus->method('setLanguage')->willReturn(null);
$languageStatus->method('setLanguage')->willReturn($languageStatus);
$languageStatus->expects($this->atLeast(2))
->method('execute')
->willReturnOnConsecutiveCalls(
Expand Down

0 comments on commit c7e1021

Please sign in to comment.