Skip to content

Commit

Permalink
Drop php 5.5 support
Browse files Browse the repository at this point in the history
  • Loading branch information
veewee committed Nov 20, 2016
1 parent d8219af commit 3c1934b
Show file tree
Hide file tree
Showing 32 changed files with 204 additions and 88 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ cache:

matrix:
include:
- php: 5.5
- php: 5.5
env: DEPENDENCIES='low'
- php: 5.6
- php: 5.6
env: DEPENDENCIES='low'
Expand Down
2 changes: 1 addition & 1 deletion 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": ">=5.5.0",
"php": ">=5.6.0",
"composer-plugin-api": "~1.0",
"composer/composer": "^1.0",
"doctrine/collections": "~1.2",
Expand Down
7 changes: 5 additions & 2 deletions resources/config/linters.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
services:
linter.jsonlint:
class: GrumPHP\Linter\Json\JsonLinter
arguments: []
arguments:
- '@grumphp.util.filesystem'
- '@json.parser'

linter.xmllint:
class: GrumPHP\Linter\Xml\XmlLinter
arguments: []

linter.yamllint:
class: GrumPHP\Linter\Yaml\YamlLinter
arguments: []
arguments:
- '@grumphp.util.filesystem'
1 change: 1 addition & 0 deletions resources/config/parsers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ services:
arguments:
- '@grumphp.parser.php.factory.parser'
- '@grumphp.parser.php.factory.traverser'
- '@grumphp.util.filesystem'

#
# AVAILABLE PHP PARSER VISITORS ...
Expand Down
5 changes: 4 additions & 1 deletion resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
- '@service_container'

filesystem:
class: Symfony\Component\Filesystem\Filesystem
alias: grumphp.util.filesystem

executable_finder:
class: Symfony\Component\Process\ExecutableFinder
Expand Down Expand Up @@ -91,3 +91,6 @@ services:
console.output:
class: Symfony\Component\Console\Output\ConsoleOutput
synthetic: true

json.parser:
class: Seld\JsonLint\JsonParser
1 change: 1 addition & 0 deletions resources/config/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ services:
- '@config'
- '@process_builder'
- '@formatter.raw_process'
- '@grumphp.util.filesystem'
tags:
- {name: grumphp.task, config: composer}

Expand Down
3 changes: 3 additions & 0 deletions resources/config/util.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
services:
grumphp.util.composer:
class: GrumPHP\Util\Composer

grumphp.util.filesystem:
class: GrumPHP\Util\Filesystem
2 changes: 1 addition & 1 deletion spec/GrumPHP/Console/Helper/PathsHelperSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use GrumPHP\Console\Helper\PathsHelper;
use GrumPHP\Exception\FileNotFoundException;
use GrumPHP\Locator\ExternalCommand;
use GrumPHP\Util\Filesystem;
use Symfony\Component\Console\Helper\Helper;
use Symfony\Component\Filesystem\Filesystem;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

Expand Down
7 changes: 7 additions & 0 deletions spec/GrumPHP/Linter/Json/JsonLinterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@

use GrumPHP\Linter\Json\JsonLinter;
use GrumPHP\Linter\LinterInterface;
use GrumPHP\Util\Filesystem;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Seld\JsonLint\JsonParser;

/**
* @mixin JsonLinter
*/
class JsonLinterSpec extends ObjectBehavior
{
function let(Filesystem $filesystem, JsonParser $jsonParser)
{
$this->beConstructedWith($filesystem, $jsonParser);
}

function it_is_initializable()
{
$this->shouldHaveType(JsonLinter::class);
Expand Down
6 changes: 6 additions & 0 deletions spec/GrumPHP/Linter/Yaml/YamlLinterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use GrumPHP\Linter\LinterInterface;
use GrumPHP\Linter\Yaml\YamlLinter;
use GrumPHP\Util\Filesystem;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

Expand All @@ -12,6 +13,11 @@
*/
class YamlLinterSpec extends ObjectBehavior
{
function let(Filesystem $filesystem)
{
$this->beConstructedWith($filesystem);
}

function it_is_initializable()
{
$this->shouldHaveType(YamlLinter::class);
Expand Down
2 changes: 1 addition & 1 deletion spec/GrumPHP/Locator/ConfigurationFileSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use Composer\Package\PackageInterface;
use GrumPHP\Locator\ConfigurationFile;
use GrumPHP\Util\Filesystem;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Symfony\Component\Filesystem\Filesystem;

/**
* @mixin ConfigurationFile
Expand Down
23 changes: 7 additions & 16 deletions spec/GrumPHP/Parser/Php/PhpParserSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use GrumPHP\Parser\Php\Factory\ParserFactory;
use GrumPHP\Parser\Php\Factory\TraverserFactory;
use GrumPHP\Parser\Php\PhpParser;
use GrumPHP\Util\Filesystem;
use PhpParser\Error;
use PhpParser\NodeTraverserInterface;
use PhpParser\Parser;
Expand All @@ -22,29 +23,19 @@
*/
class PhpParserSpec extends ObjectBehavior
{
/**
* @var string
*/
protected $tempFile;

function let(
ParserFactory $parserFactory,
TraverserFactory $traverserFactory,
Parser $parser,
NodeTraverserInterface $traverser
NodeTraverserInterface $traverser,
Filesystem $filesystem
) {
$this->beConstructedWith($parserFactory, $traverserFactory);
$this->tempFile = tempnam(sys_get_temp_dir(), 'phpparser');
$this->beConstructedWith($parserFactory, $traverserFactory, $filesystem);
$parserFactory->createFromOptions(Argument::any())->willReturn($parser);
$traverserFactory->createForTaskContext(Argument::cetera())->willReturn($traverser);
$parser->parse(Argument::any())->willReturn([]);
}

function letgo()
{
unlink($this->tempFile);
}

function it_is_initializable()
{
$this->shouldHaveType(PhpParser::class);
Expand All @@ -56,7 +47,7 @@ function it_uses_parser_options(
Parser $parser,
NodeTraverserInterface $traverser
) {
$file = new SplFileInfo($this->tempFile);
$file = new SplFileInfo('php://memory');
$this->setParserOptions($options = ['kind' => 'php7']);

$parserFactory->createFromOptions($options)->shouldBeCalled()->willReturn($parser);
Expand All @@ -70,7 +61,7 @@ function it_uses_parser_options(

function it_parses_a_file(NodeTraverserInterface $traverser)
{
$file = new SplFileInfo($this->tempFile);
$file = new SplFileInfo('php://memory');
$traverser->traverse([])->shouldBeCalled();
$errors = $this->parse($file);

Expand All @@ -80,7 +71,7 @@ function it_parses_a_file(NodeTraverserInterface $traverser)

function it_catches_parse_exceptions(Parser $parser)
{
$file = new SplFileInfo($this->tempFile);
$file = new SplFileInfo('php://memory');
$parser->parse(Argument::any())->willThrow(new Error('Error ....'));
$errors = $this->parse($file);

Expand Down
15 changes: 6 additions & 9 deletions spec/GrumPHP/Task/CloverCoverageSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
use GrumPHP\Task\Context\GitCommitMsgContext;
use GrumPHP\Task\Context\GitPreCommitContext;
use GrumPHP\Task\Context\RunContext;
use GrumPHP\Util\Filesystem;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* @mixin CloverCoverage
*/
class CloverCoverageSpec extends ObjectBehavior
{
function let(GrumPHP $grumPHP, Filesystem $filesystem)
function let(GrumPHP $grumPHP)
{
$grumPHP->getTaskConfiguration('clover_coverage')->willReturn([]);
$this->beConstructedWith($grumPHP, $filesystem);
$this->beConstructedWith($grumPHP, new Filesystem());
}

function it_is_initializable()
Expand Down Expand Up @@ -58,38 +58,35 @@ function it_should_not_run_in_commit_message_context(GitCommitMsgContext $contex
$this->canRunInContext($context)->shouldReturn(false);
}

function it_runs_the_suite_but_fails_when_file_doesnt_exists(GrumPHP $grumPHP, GitCommitMsgContext $context, Filesystem $filesystem)
function it_runs_the_suite_but_fails_when_file_doesnt_exists(GrumPHP $grumPHP, GitCommitMsgContext $context)
{
$grumPHP->getTaskConfiguration('clover_coverage')->willReturn([
'clover_file' => 'foo.bar',
]);
$filesystem->exists('foo.bar')->willReturn(false);
$result = $this->run($context);
$result->shouldBeAnInstanceOf(TaskResultInterface::class);
$result->getResultCode()->shouldBe(TaskResult::FAILED);
}

function it_runs_the_suite(GrumPHP $grumPHP, GitCommitMsgContext $context, Filesystem $filesystem)
function it_runs_the_suite(GrumPHP $grumPHP, GitCommitMsgContext $context)
{
$filename = dirname(dirname(dirname(__DIR__))) . '/test/fixtures/clover_coverage/60-percent-coverage.xml';
$grumPHP->getTaskConfiguration('clover_coverage')->willReturn([
'clover_file' => $filename,
'level' => 50,
]);
$filesystem->exists($filename)->willReturn(true);
$result = $this->run($context);
$result->shouldBeAnInstanceOf(TaskResultInterface::class);
$result->getResultCode()->shouldBe(TaskResult::PASSED);
}

function it_runs_the_suite_but_not_reaching_coverage(GrumPHP $grumPHP, GitCommitMsgContext $context, Filesystem $filesystem)
function it_runs_the_suite_but_not_reaching_coverage(GrumPHP $grumPHP, GitCommitMsgContext $context)
{
$filename = dirname(dirname(dirname(__DIR__))) . '/test/fixtures/clover_coverage/60-percent-coverage.xml';
$grumPHP->getTaskConfiguration('clover_coverage')->willReturn([
'clover_file' => $filename,
'level' => 100,
]);
$filesystem->exists($filename)->willReturn(true);
$result = $this->run($context);
$result->shouldBeAnInstanceOf(TaskResultInterface::class);
$result->getResultCode()->shouldBe(TaskResult::FAILED);
Expand Down
32 changes: 16 additions & 16 deletions spec/GrumPHP/Task/ComposerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
use GrumPHP\Task\Context\ContextInterface;
use GrumPHP\Task\Context\GitPreCommitContext;
use GrumPHP\Task\Context\RunContext;
use GrumPHP\Util\Filesystem;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use SplFileObject;
use Symfony\Component\Finder\SplFileInfo;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Process\Process;
Expand All @@ -24,10 +26,10 @@
*/
class ComposerSpec extends ObjectBehavior
{
function let(GrumPHP $grumPHP, ProcessBuilder $processBuilder, ProcessFormatterInterface $formatter)
function let(GrumPHP $grumPHP, ProcessBuilder $processBuilder, ProcessFormatterInterface $formatter, Filesystem $filesystem)
{
$grumPHP->getTaskConfiguration('composer')->willReturn([]);
$this->beConstructedWith($grumPHP, $processBuilder, $formatter);
$this->beConstructedWith($grumPHP, $processBuilder, $formatter, $filesystem);
}

function it_is_initializable()
Expand Down Expand Up @@ -116,18 +118,17 @@ function it_throws_exception_if_the_process_fails(
function it_fails_when_it_has_local_repositories(
GrumPHP $grumPHP,
ProcessBuilder $processBuilder,
Filesystem $filesystem,
Process $process,
ContextInterface $context
)
{
$composerFile = tempnam(sys_get_temp_dir(), 'grumphp-composer');
$composerFile = 'composer.json';
$grumPHP->getTaskConfiguration('composer')->willReturn([
'file' => str_replace('\\', '/', $composerFile),
'file' => $composerFile,
'no_local_repository' => true
]);

file_put_contents($composerFile, '{"repositories": [{"type": "path", "url": "/"}]}');

$arguments = new ProcessArgumentsCollection();
$processBuilder->createArgumentsForCommand('composer')->willReturn($arguments);
$processBuilder->buildProcess($arguments)->willReturn($process);
Expand All @@ -136,32 +137,31 @@ function it_fails_when_it_has_local_repositories(
$process->isSuccessful()->willReturn(true);

$context->getFiles()->willReturn(new FilesCollection([
new SplFileInfo($composerFile, '.', $composerFile)
$composerFile = new SplFileInfo($composerFile, '.', $composerFile)
]));

$filesystem->readFromFileInfo($composerFile)->willReturn('{"repositories": [{"type": "path", "url": "/"}]}');

$result = $this->run($context);
$result->shouldBeAnInstanceOf(TaskResultInterface::class);
$result->isPassed()->shouldBe(false);

unlink($composerFile);
}


function it_succeeds_when_it_has_no_local_repositories(
GrumPHP $grumPHP,
ProcessBuilder $processBuilder,
Filesystem $filesystem,
Process $process,
ContextInterface $context
)
{
$composerFile = tempnam(sys_get_temp_dir(), 'grumphp-composer');
$composerFile = 'composer.json';
$grumPHP->getTaskConfiguration('composer')->willReturn([
'file' => str_replace('\\', '/', $composerFile),
'file' => $composerFile,
'no_local_repository' => true
]);

file_put_contents($composerFile, '{"repositories": [{"type": "vcs", "url": "/"}]}');

$arguments = new ProcessArgumentsCollection();
$processBuilder->createArgumentsForCommand('composer')->willReturn($arguments);
$processBuilder->buildProcess($arguments)->willReturn($process);
Expand All @@ -170,13 +170,13 @@ function it_succeeds_when_it_has_no_local_repositories(
$process->isSuccessful()->willReturn(true);

$context->getFiles()->willReturn(new FilesCollection([
new SplFileInfo($composerFile, '.', $composerFile)
$composerFile = new SplFileInfo($composerFile, '.', $composerFile)
]));

$filesystem->readFromFileInfo($composerFile)->willReturn('{"repositories": [{"type": "vcs", "url": "/"}]}');

$result = $this->run($context);
$result->shouldBeAnInstanceOf(TaskResultInterface::class);
$result->isPassed()->shouldBe(true);

unlink($composerFile);
}
}
2 changes: 1 addition & 1 deletion src/GrumPHP/Configuration/ContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
namespace GrumPHP\Configuration;

use GrumPHP\Configuration\Compiler;
use GrumPHP\Util\Filesystem;
use Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
use Symfony\Component\Filesystem\Filesystem;

/**
* Class ContainerFactory
Expand Down
Loading

0 comments on commit 3c1934b

Please sign in to comment.