Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to php 7.1 #616

Merged
merged 6 commits into from
May 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "composer-plugin",
"license": "MIT",
"require": {
"php": ">=7.1",
"php": "^7.1",
"composer-plugin-api": "~1.0",
"composer/composer": "^1.8.5",
"doctrine/collections": "~1.2",
Expand All @@ -25,7 +25,7 @@
"brianium/paratest": "^2.2.0",
"friendsofphp/php-cs-fixer": "~2",
"jakub-onderka/php-parallel-lint": "^0.9.2",
"nikic/php-parser": "~2.1",
"nikic/php-parser": "^3.0",
"phpspec/phpspec": "^5.1",
"phpunit/phpunit": "^7.5.12",
"sensiolabs/security-checker": "^5.0",
Expand Down
39 changes: 18 additions & 21 deletions src/Collection/ProcessArgumentsCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ public static function forExecutable(string $executable): self
return new self([$executable]);
}

/**
* @param string|null $value
*/
public function addOptionalArgument(string $argument, $value)
public function addOptionalArgument(string $argument, $value = null): void
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public function addOptionalArgument(string $argument, $value = null): void
public function addOptionalArgument(string $argument, string $value = null): void

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SerkanYildiz $value can also be null or an integer

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, according to the removed php docblock it should be an string|null, that's why it was my suggested change :)

{
if (!$value) {
return;
Expand All @@ -26,7 +23,7 @@ public function addOptionalArgument(string $argument, $value)
$this->add(sprintf($argument, $value));
}

public function addOptionalArgumentWithSeparatedValue(string $argument, $value)
public function addOptionalArgumentWithSeparatedValue(string $argument, $value = null): void
{
if (!$value) {
return;
Expand All @@ -36,7 +33,7 @@ public function addOptionalArgumentWithSeparatedValue(string $argument, $value)
$this->add($value);
}

public function addOptionalCommaSeparatedArgument(string $argument, array $values, string $delimiter = ',')
public function addOptionalCommaSeparatedArgument(string $argument, array $values, string $delimiter = ','): void
{
if (!\count($values)) {
return;
Expand All @@ -45,7 +42,7 @@ public function addOptionalCommaSeparatedArgument(string $argument, array $value
$this->add(sprintf($argument, implode($delimiter, $values)));
}

public function addArgumentArray(string $argument, array $values)
public function addArgumentArray(string $argument, array $values): void
{
foreach ($values as $value) {
$this->add(sprintf($argument, $value));
Expand All @@ -55,15 +52,15 @@ public function addArgumentArray(string $argument, array $values)
/**
* Some CLI tools prefer to split the argument and the value.
*/
public function addArgumentArrayWithSeparatedValue(string $argument, array $values)
public function addArgumentArrayWithSeparatedValue(string $argument, array $values): void
{
foreach ($values as $value) {
$this->add(sprintf($argument, $value));
$this->add($value);
}
}

public function addSeparatedArgumentArray(string $argument, array $values)
public function addSeparatedArgumentArray(string $argument, array $values): void
{
if (!\count($values)) {
return;
Expand All @@ -75,7 +72,7 @@ public function addSeparatedArgumentArray(string $argument, array $values)
}
}

public function addRequiredArgument(string $argument, string $value)
public function addRequiredArgument(string $argument, string $value): void
{
if (!$value) {
throw new InvalidArgumentException(sprintf('The argument %s is required.', $argument));
Expand All @@ -84,19 +81,19 @@ public function addRequiredArgument(string $argument, string $value)
$this->add(sprintf($argument, $value));
}

public function addFiles(FilesCollection $files)
public function addFiles(FilesCollection $files): void
{
foreach ($files as $file) {
$this->addFile($file);
}
}

public function addFile(\SplFileInfo $file)
public function addFile(\SplFileInfo $file): void
{
$this->add($file->getPathname());
}

public function addCommaSeparatedFiles(FilesCollection $files)
public function addCommaSeparatedFiles(FilesCollection $files): void
{
$paths = [];

Expand All @@ -107,7 +104,7 @@ public function addCommaSeparatedFiles(FilesCollection $files)
$this->add(implode(',', $paths));
}

public function addArgumentWithCommaSeparatedFiles(string $argument, FilesCollection $files)
public function addArgumentWithCommaSeparatedFiles(string $argument, FilesCollection $files): void
{
$paths = [];

Expand All @@ -118,20 +115,20 @@ public function addArgumentWithCommaSeparatedFiles(string $argument, FilesCollec
$this->add(sprintf($argument, implode(',', $paths)));
}

public function addOptionalBooleanArgument(string $argument, $value, string $trueFormat, string $falseFormat)
{
public function addOptionalBooleanArgument(
string $argument,
?bool $value,
string $trueFormat,
string $falseFormat
): void {
if (null === $value) {
return;
}

$this->add(sprintf($argument, $value ? $trueFormat : $falseFormat));
}

/**
* @param string $argument
* @param int|null $value
*/
public function addOptionalIntegerArgument(string $argument, $value)
public function addOptionalIntegerArgument(string $argument, ?int $value): void
{
$this->addOptionalMixedArgument($argument, $value);
}
Expand Down
5 changes: 1 addition & 4 deletions src/Collection/TasksCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ public function filterByContext(ContextInterface $context): self
});
}

/**
* @param TestSuiteInterface|null $testSuite
*/
public function filterByTestSuite(TestSuiteInterface $testSuite = null): self
public function filterByTestSuite(?TestSuiteInterface $testSuite = null): self
{
if (null === $testSuite) {
return $this;
Expand Down
8 changes: 1 addition & 7 deletions src/Collection/TestSuiteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

class TestSuiteCollection extends ArrayCollection
{
/**
* @throws \GrumPHP\Exception\InvalidArgumentException
*/
public function getRequired(string $name): TestSuiteInterface
{
if (!$this->containsKey($name)) {
Expand All @@ -22,10 +19,7 @@ public function getRequired(string $name): TestSuiteInterface
return $this->get($name);
}

/**
* @return TestSuiteInterface|null
*/
public function getOptional(string $name)
public function getOptional(string $name): ?TestSuiteInterface
{
return $this->get($name);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/DevelopmentIntegrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DevelopmentIntegrator
/**
* This method makes sure that GrumPHP registers itself during development.
*/
public static function integrate(Event $event)
public static function integrate(Event $event): void
{
$filesystem = new Filesystem();

Expand Down
16 changes: 8 additions & 8 deletions src/Composer/GrumPHPPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class GrumPHPPlugin implements PluginInterface, EventSubscriberInterface
/**
* {@inheritdoc}
*/
public function activate(Composer $composer, IOInterface $io)
public function activate(Composer $composer, IOInterface $io): void
{
$this->composer = $composer;
$this->io = $io;
Expand All @@ -76,7 +76,7 @@ public static function getSubscribedEvents(): array
/**
* When this package is updated, the git hook is also initialized.
*/
public function postPackageInstall(PackageEvent $event)
public function postPackageInstall(PackageEvent $event): void
{
/** @var InstallOperation $operation */
$operation = $event->getOperation();
Expand All @@ -94,7 +94,7 @@ public function postPackageInstall(PackageEvent $event)
/**
* When this package is updated, the git hook is also updated.
*/
public function postPackageUpdate(PackageEvent $event)
public function postPackageUpdate(PackageEvent $event): void
{
/** @var UpdateOperation $operation */
$operation = $event->getOperation();
Expand All @@ -111,7 +111,7 @@ public function postPackageUpdate(PackageEvent $event)
/**
* When this package is uninstalled, the generated git hooks need to be removed.
*/
public function prePackageUninstall(PackageEvent $event)
public function prePackageUninstall(PackageEvent $event): void
{
/** @var UninstallOperation $operation */
$operation = $event->getOperation();
Expand All @@ -125,7 +125,7 @@ public function prePackageUninstall(PackageEvent $event)
$this->deInitGitHook();
}

public function runScheduledTasks(Event $event)
public function runScheduledTasks(Event $event): void
{
if ($this->initScheduled) {
$this->runGrumPhpCommand(ConfigureCommand::COMMAND_NAME);
Expand All @@ -143,23 +143,23 @@ protected function guardIsGrumPhpPackage(PackageInterface $package): bool
/**
* Initialize git hooks.
*/
protected function initGitHook()
protected function initGitHook(): void
{
$this->runGrumPhpCommand(InitCommand::COMMAND_NAME);
}

/**
* Deinitialize git hooks.
*/
protected function deInitGitHook()
protected function deInitGitHook(): void
{
$this->runGrumPhpCommand(DeInitCommand::COMMAND_NAME);
}

/**
* Run the GrumPHP console to (de)init the git hooks.
*/
protected function runGrumPhpCommand(string $command)
protected function runGrumPhpCommand(string $command): void
{
$config = $this->composer->getConfig();
$commandLocator = new ExternalCommand($config->get('bin-dir'), new ExecutableFinder());
Expand Down
2 changes: 1 addition & 1 deletion src/Configuration/Compiler/ExtensionCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class ExtensionCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
$extensions = $container->getParameter('extensions');
$extensions = \is_array($extensions) ? $extensions : [];
Expand Down
4 changes: 2 additions & 2 deletions src/Configuration/Compiler/PhpParserCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class PhpParserCompilerPass implements CompilerPassInterface
* @throws \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
* @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
$traverserConfigurator = $container->findDefinition('grumphp.parser.php.configurator.traverser');
foreach ($container->findTaggedServiceIds(self::TAG) as $id => $tags) {
Expand All @@ -46,7 +46,7 @@ public function process(ContainerBuilder $container)
*
* @throws \GrumPHP\Exception\RuntimeException
*/
public function markServiceAsPrototype(Definition $definition)
public function markServiceAsPrototype(Definition $definition): void
{
if (method_exists($definition, 'setShared')) {
$definition->setShared(false);
Expand Down
2 changes: 1 addition & 1 deletion src/Configuration/Compiler/TaskCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class TaskCompilerPass implements CompilerPassInterface
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
$definition = $container->findDefinition('task_runner');
$taggedServices = $container->findTaggedServiceIds(self::TAG_GRUMPHP_TASK);
Expand Down
2 changes: 1 addition & 1 deletion src/Configuration/Compiler/TestSuiteCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class TestSuiteCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
$testSuites = $container->getParameter('testsuites');
$registeredTasks = (array) $container->getParameter('grumphp.tasks.registered');
Expand Down
22 changes: 4 additions & 18 deletions src/Configuration/GrumPHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ public function getGitDir(): string
return $this->container->getParameter('git_dir');
}

/**
* @return string|null
*/
public function getHooksDir()
public function getHooksDir(): ?string
{
return $this->container->getParameter('hooks_dir');
}
Expand Down Expand Up @@ -71,10 +68,7 @@ public function getProcessAsyncWaitTime(): int
return (int) $this->container->getParameter('process_async_wait');
}

/**
* @return float|null
*/
public function getProcessTimeout()
public function getProcessTimeout(): ?float
{
$timeout = $this->container->getParameter('process_timeout');
if (null === $timeout) {
Expand All @@ -84,10 +78,7 @@ public function getProcessTimeout()
return (float) $timeout;
}

/**
* @return null|string
*/
public function getAdditionalInfo()
public function getAdditionalInfo(): ?string
{
return $this->container->getParameter('additional_info');
}
Expand Down Expand Up @@ -130,12 +121,7 @@ public function getTestSuites(): TestSuiteCollection
return $this->container->getParameter('grumphp.testsuites');
}

/**
* Get ascii content path from grumphp.yml file.
*
* @return string|null
*/
public function getAsciiContentPath(string $resource)
public function getAsciiContentPath(string $resource): ?string
{
if (null === $this->container->getParameter('ascii')) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ protected function getContainer(): ContainerBuilder
return $this->container;
}

protected function configureIO(InputInterface $input, OutputInterface $output)
protected function configureIO(InputInterface $input, OutputInterface $output): void
{
parent::configureIO($input, $output);

Expand Down
2 changes: 1 addition & 1 deletion src/Console/Command/ConfigureCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct(GrumPHP $config, Filesystem $filesystem, Repository
/**
* Configure command.
*/
protected function configure()
protected function configure(): void
{
$this->setName(self::COMMAND_NAME);
$this->addOption(
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Command/Git/CommitMsgCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct(GrumPHP $grumPHP, ChangedFiles $changedFilesLocator,
/**
* Configure command.
*/
protected function configure()
protected function configure(): void
{
$this->setName(self::COMMAND_NAME);
$this->setDescription('Executed by the commit-msg commit hook');
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Command/Git/DeInitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct(GrumPHP $grumPHP, Filesystem $filesystem)
/**
* Configure command.
*/
protected function configure()
protected function configure(): void
{
$this->setName(self::COMMAND_NAME);
$this->setDescription('Removes the commit hooks');
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Command/Git/InitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function __construct(GrumPHP $grumPHP, Filesystem $filesystem, ProcessBui
/**
* Configure command.
*/
protected function configure()
protected function configure(): void
{
$this->setName(self::COMMAND_NAME);
$this->setDescription('Registers the Git hooks');
Expand Down
Loading