Skip to content

Commit

Permalink
Merge pull request #553 from laurieplo/php7.0-upgrade
Browse files Browse the repository at this point in the history
Add missing typehints and return types
  • Loading branch information
Landerstraeten authored Oct 24, 2018
2 parents 4d2fbd7 + 9139cfe commit bd2efcc
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/Composer/DevelopmentIntegrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static function integrate(Event $event)
$event->getIO()->write('<fg=yellow>'.$process->getOutput().'</fg=yellow>');
}

private static function noramlizePath($path): string
private static function noramlizePath(string $path): string
{
return strtr($path, '/', DIRECTORY_SEPARATOR);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/GrumPHPPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function activate(Composer $composer, IOInterface $io)
*
* {@inheritdoc}
*/
public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return [
PackageEvents::POST_PACKAGE_INSTALL => 'postPackageInstall',
Expand Down
2 changes: 1 addition & 1 deletion src/Configuration/GrumPHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function getTestSuites(): TestSuiteCollection
*
* @return string|null
*/
public function getAsciiContentPath($resource)
public function getAsciiContentPath(string $resource)
{
$paths = $this->container->getParameter('ascii');
if (!array_key_exists($resource, $paths)) {
Expand Down
8 changes: 5 additions & 3 deletions src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Symfony\Component\Console\Application as SymfonyConsole;
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\ConsoleOutput;
Expand Down Expand Up @@ -54,7 +56,7 @@ public function __construct()
parent::__construct(self::APP_NAME, self::APP_VERSION);
}

protected function getDefaultInputDefinition()
protected function getDefaultInputDefinition(): InputDefinition
{
$definition = parent::getDefaultInputDefinition();
$definition->addOption(
Expand All @@ -70,7 +72,7 @@ protected function getDefaultInputDefinition()
return $definition;
}

protected function getDefaultCommands()
protected function getDefaultCommands(): array
{
$commands = parent::getDefaultCommands();

Expand Down Expand Up @@ -106,7 +108,7 @@ protected function getDefaultCommands()
return $commands;
}

protected function getDefaultHelperSet()
protected function getDefaultHelperSet(): HelperSet
{
$helperSet = parent::getDefaultHelperSet();
$helperSet->set($this->initializeComposerHelper());
Expand Down
4 changes: 2 additions & 2 deletions src/Console/Helper/PathsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,15 @@ public function getBinDir(): string
* Search a command in the bin folder
* Note: the command locator is not injected because it needs the relative bin path.
*/
public function getBinCommand($command, $forceUnix = false): string
public function getBinCommand($command, bool $forceUnix = false): string
{
return $this->externalCommandLocator->locate($command, $forceUnix);
}

/**
* @throws FileNotFoundException If file doesn't exists
*/
public function getRelativePath($path): string
public function getRelativePath(string $path): string
{
$realpath = $this->getAbsolutePath($path);

Expand Down
2 changes: 1 addition & 1 deletion src/Console/Helper/TaskRunnerHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private function returnWarningMessages(OutputInterface $output, array $warningMe
/**
* {@inheritdoc}
*/
public function getName()
public function getName(): string
{
return self::HELPER_NAME;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Locator/ConfigurationFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function locate(string $workingDir, PackageInterface $package = null): st
return $defaultPath;
}

private function useConfigPathFromComposer(PackageInterface $package, $defaultPath): string
private function useConfigPathFromComposer(PackageInterface $package, string $defaultPath): string
{
$extra = $package->getExtra();
if (!isset($extra['grumphp']['config-default-path'])) {
Expand All @@ -57,7 +57,7 @@ private function useConfigPathFromComposer(PackageInterface $package, $defaultPa
return $this->locateConfigFileWithDistSupport($composerDefaultPath);
}

private function locateConfigFileWithDistSupport($defaultPath): string
private function locateConfigFileWithDistSupport(string $defaultPath): string
{
$distPath = ('.dist' !== strpos($defaultPath, -5)) ? $defaultPath.'.dist' : $defaultPath;
if ($this->filesystem->exists($defaultPath) || !$this->filesystem->exists($distPath)) {
Expand Down
4 changes: 1 addition & 3 deletions src/Parser/Php/Configurator/TraverserConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@ public function registerVisitorId(string $alias, string $visitorId)
}

/**
* @param array|null $visitorOptions
*
* @throws \GrumPHP\Exception\RuntimeException
*/
public function registerStandardEnabledVisitor($alias, array $visitorOptions = null)
public function registerStandardEnabledVisitor(string $alias, array $visitorOptions = null)
{
if (array_key_exists($alias, $this->standardEnabledVisitors)) {
throw new RuntimeException(
Expand Down
2 changes: 1 addition & 1 deletion src/Process/ProcessFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
final class ProcessFactory
{
public static function fromArguments(ProcessArgumentsCollection $arguments)
public static function fromArguments(ProcessArgumentsCollection $arguments): Process
{
// @todo Remove backward compatibility layer as soon as Symfony Process accepts an array (3.3+).
// From then on, you can simply pass `$arguments->getValues()` directly as the first constructor argument.
Expand Down
2 changes: 1 addition & 1 deletion src/Util/Regex.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Regex
/**
* Regex constructor.
*/
public function __construct($string)
public function __construct(string $string)
{
$this->regex = $this->toRegex($string);
}
Expand Down

0 comments on commit bd2efcc

Please sign in to comment.