Skip to content

Commit

Permalink
Fix PHP 7.4 compatibility (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloKowalczyk committed Sep 28, 2019
1 parent da88549 commit 8ef1370
Show file tree
Hide file tree
Showing 7 changed files with 2,674 additions and 6 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ php:

matrix:
fast_finish: true
allow_failures:
- php: 7.4snapshot

env:
matrix:
Expand Down
18 changes: 17 additions & 1 deletion bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,31 @@

require_once __DIR__ . '/vendor/autoload.php';

// Disable deprecation helper
$envFlags = new \Crunz\EnvFlags\EnvFlags();
$envFlags->disableDeprecationHandler();

// Make sure current working directory is "tests"
$filesystem = new \Crunz\Filesystem\Filesystem();

if (\strpos($filesystem->getCwd(), 'tests') !== false) {
return;
}

if (!\chdir('tests')) {
throw new RuntimeException("Unable to change current directory to 'tests'.");
}

// Money patch PHPUnit_Framework_MockObject_Generator to avoid
// "Function ReflectionType::__toString() is deprecated" warnings
$mockObjectVersion = PHP_VERSION_ID >= 70100
? '71'
: 'org'
;
$mockObjectFilePath = __DIR__ . "/tests/resources/patches/php-mock-object-{$mockObjectVersion}.php";

if (PHP_VERSION_ID >= 70100) {
\file_put_contents(
__DIR__ . '/vendor-bin/phpunit/vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator.php',
\file_get_contents($mockObjectFilePath)
);
}
6 changes: 6 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ parameters:
-
message: '#Parameter \#1 \$command of static method Symfony\\Component\\Process\\Process::fromShellCommandline\(\) expects string, array|string given#'
path: src/Process/Process.php
-
message: '#.+#'
path: tests/resources/patches/php-mock-object-71.php
-
message: '#.+#'
path: tests/resources/patches/php-mock-object-org.php

includes:
- vendor-bin/phpstan/vendor/phpstan/phpstan-phpunit/extension.neon
Expand Down
4 changes: 2 additions & 2 deletions src/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -1323,8 +1323,8 @@ private function splitCamel($text)

return \strtolower(
\implode(
$segments,
' '
' ',
$segments
)
);
}
Expand Down
6 changes: 5 additions & 1 deletion tests/Unit/Console/Command/ScheduleRunCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,17 @@ function ($schedules) {
return $mockEventRunner;
}

private function mockInput(array $options)
private function mockInput(array $options, array $arguments = ['source' => ''])
{
$mockInput = $this->createMock(InputInterface::class);
$mockInput
->method('getOptions')
->willReturn($options)
;
$mockInput
->method('getArguments')
->willReturn($arguments)
;

return $mockInput;
}
Expand Down

0 comments on commit 8ef1370

Please sign in to comment.