Commit 9a1bf782 authored by Daniel Hürtgen's avatar Daniel Hürtgen

Merge branch '42-drop-support-for-php-5-3' into 'develop'

FEATURE: Drop support for PHP 5.3

Closes #42

See merge request !46
parents a6c83bbb 7ee2a337
Pipeline #383 passed with stage
in 4 minutes and 39 seconds
......@@ -25,8 +25,8 @@ lint:php-mass-detection:
- mkdir result
- ./vendor/bin/phpmd src text phpmd.xml | tee result/phpmd.txt
test:5.3: &PHP-UNITTESTING
image: tetraweb/php:5.3
test:5.4: &PHP-UNITTESTING
image: tetraweb/php:5.4
stage: test
tags:
- docker
......@@ -35,9 +35,6 @@ test:5.3: &PHP-UNITTESTING
WITH_XDEBUG: "true"
script:
- ./vendor/bin/phpunit --coverage-text --colors=never
test:5.4:
<<: *PHP-UNITTESTING
image: tetraweb/php:5.4
test:5.5:
<<: *PHP-UNITTESTING
image: tetraweb/php:5.5
......
......@@ -8,7 +8,7 @@ Composer plugin installs [PHP_CodeSniffer](https://github.com/squizlabs/PHP_Code
Requirements
------------
- `PHP >= 5.3.3`
- `PHP >= 5.4`
- Composer package providing the PHP CodeSniffer Rulesets & Sniffs
Installation
......
......@@ -32,7 +32,7 @@
}
},
"require": {
"php": ">=5.3.3",
"php": "^5.4 || ^7.0",
"composer-plugin-api": "^1.1",
"squizlabs/php_codesniffer": "^2.0",
"symfony/finder": "^2.1 || ^3.0",
......
......@@ -21,8 +21,8 @@ namespace Higidi\ComposerPhpCSStandardsPlugin\PHPCodeSniffer;
* 02110-1301, USA.
*/
use Higidi\ComposerPhpCSStandardsPlugin\PHPCodeSniffer\Standards\Standards;
use Higidi\ComposerPhpCSStandardsPlugin\PHPCodeSniffer\Standards\Factory;
use Higidi\ComposerPhpCSStandardsPlugin\PHPCodeSniffer\Standards\Standards;
use Higidi\ComposerPhpCSStandardsPlugin\Symfony\Finder\Factory as FinderFactory;
use Symfony\Component\Finder\Finder as SymfonyFinder;
......@@ -55,6 +55,7 @@ class Finder
* Find and return PHPCodeSniffer standards.
*
* @param string $path
*
* @return Standards
*
* @SuppressWarnings(PHPMD.ShortMethodName)
......@@ -91,6 +92,7 @@ class Finder
* Creates PHPCodeSniffer standards from paths.
*
* @param array $path
*
* @return Standards
*/
protected function createStandardsFromPaths(array $paths)
......
......@@ -45,6 +45,7 @@ class Factory
* Creates PHPCodeSniffer standards from paths.
*
* @param array $paths Paths with PHPCodeSniffer standard paths.
*
* @return Standards PHPCodeSniffer standards object.
*/
public function create(array $paths)
......
......@@ -30,6 +30,7 @@ class Factory
* Creates PHPCodeSniffer standard from path.
*
* @param string $path Path to the PHPCodeSniffer standard.
*
* @return Standard PHPCodeSniffer standard object.
*/
public function create($path)
......
......@@ -51,7 +51,7 @@ class Standard implements StandardInterface
*/
public function __construct($path)
{
if (!is_readable($path)) {
if (! is_readable($path)) {
throw new StandardPathAccessDeniedException(
sprintf('Standard path "%s" is not accessable.', $path)
);
......@@ -60,7 +60,7 @@ class Standard implements StandardInterface
$this->ruleSetXmlPath = $path . DIRECTORY_SEPARATOR . static::RULESET_FILENAME;
$this->name = $this->getNameFromRuleSet($this->ruleSetXmlPath);
if (!is_readable($this->ruleSetXmlPath)) {
if (! is_readable($this->ruleSetXmlPath)) {
throw new InvalidStandardException(
sprintf('Standard "%s" doesn\'t contain a "ruleset.xml" file.', $this->name)
);
......@@ -71,14 +71,14 @@ class Standard implements StandardInterface
* Fetch PHPCodeSniffer standard name from ruleset.xml.
*
* @param string $ruleSetXmlPath The absolute path to ruleset.xml.
*
* @return string The name of the PHPCodeSniffer standard.
*/
protected function getNameFromRuleSet($ruleSetXmlPath)
{
try {
$ruleSet = new \SimpleXMLElement(file_get_contents($ruleSetXmlPath));
$attributes = $ruleSet->attributes();
$name = trim($attributes['name']);
$name = trim($ruleSet->attributes()['name']);
if ($name !== '') {
return $name;
}
......
......@@ -34,7 +34,7 @@ class Standards implements \Iterator
/**
* @param StandardInterface[] $standards
*/
public function __construct(array $standards = array())
public function __construct(array $standards = [])
{
foreach ($standards as $standard) {
$this->addStandard($standard);
......@@ -43,6 +43,7 @@ class Standards implements \Iterator
/**
* @param StandardInterface $standard
*
* @return $this
*/
public function addStandard(StandardInterface $standard)
......@@ -54,6 +55,7 @@ class Standards implements \Iterator
/**
* @param string|StandardInterface $standard
*
* @return bool
*/
public function hasStandard($standard)
......@@ -63,6 +65,7 @@ class Standards implements \Iterator
/**
* @param string|StandardInterface $standard
*
* @return $this
*/
public function removeStandard($standard)
......@@ -76,11 +79,12 @@ class Standards implements \Iterator
/**
* @param string|StandardInterface $standard
*
* @return StandardInterface|null
*/
public function getStandard($standard)
{
if (!$this->hasStandard($standard)) {
if (! $this->hasStandard($standard)) {
return null;
}
......@@ -97,6 +101,7 @@ class Standards implements \Iterator
/**
* @param string|StandardInterface $standard
*
* @return string
*/
protected function getStandardName($standard)
......@@ -110,6 +115,7 @@ class Standards implements \Iterator
/**
* Return the current element
*
* @link http://php.net/manual/en/iterator.current.php
* @return StandardInterface Can return any type.
* @since 5.0.0
......@@ -121,6 +127,7 @@ class Standards implements \Iterator
/**
* Move forward to next element
*
* @link http://php.net/manual/en/iterator.next.php
* @return void Any returned value is ignored.
* @since 5.0.0
......@@ -132,6 +139,7 @@ class Standards implements \Iterator
/**
* Return the key of the current element
*
* @link http://php.net/manual/en/iterator.key.php
* @return mixed scalar on success, or null on failure.
* @since 5.0.0
......@@ -143,6 +151,7 @@ class Standards implements \Iterator
/**
* Checks if current position is valid
*
* @link http://php.net/manual/en/iterator.valid.php
* @return boolean The return value will be casted to boolean and then evaluated.
* Returns true on success or false on failure.
......@@ -155,6 +164,7 @@ class Standards implements \Iterator
/**
* Rewind the Iterator to the first element
*
* @link http://php.net/manual/en/iterator.rewind.php
* @return void Any returned value is ignored.
* @since 5.0.0
......
......@@ -30,7 +30,7 @@ function includeIfExists($file)
return file_exists($file) ? include $file : false;
}
if (!$autoLoader = includeIfExists(__DIR__ . '/../vendor/autoload.php')) {
if (! $autoLoader = includeIfExists(__DIR__ . '/../vendor/autoload.php')) {
echo 'You must set up the project dependencies, run the following command from the project root:' . PHP_EOL .
'php composer.phar install' . PHP_EOL;
exit(1);
......
......@@ -59,14 +59,14 @@ class FinderTest extends \PHPUnit_Framework_TestCase
public function testFinder()
{
$path = realpath(implode(DIRECTORY_SEPARATOR, array(__DIR__, '..', '..', '..', 'Fixtures', 'Standards')));
$expected = array(
$path = realpath(implode(DIRECTORY_SEPARATOR, [__DIR__, '..', '..', '..', 'Fixtures', 'Standards']));
$expected = [
$path . DIRECTORY_SEPARATOR . 'Standard1',
$path . DIRECTORY_SEPARATOR . 'Standard2',
$path . DIRECTORY_SEPARATOR . 'Standard3',
$path . DIRECTORY_SEPARATOR . 'standard_with_ruleset',
$path . DIRECTORY_SEPARATOR . 'standard_with_ruleset_without_name',
);
];
$this->standardsFactoryMock
->expects($this->once())
......
......@@ -78,28 +78,28 @@ class FinderTest extends \PHPUnit_Framework_TestCase
public function testFinder()
{
$path = realpath(implode(DIRECTORY_SEPARATOR, array(__DIR__, '..', '..', '..', 'Fixtures', 'Standards')));
$expected = array(
$path = realpath(implode(DIRECTORY_SEPARATOR, [__DIR__, '..', '..', '..', 'Fixtures', 'Standards']));
$expected = [
$path . DIRECTORY_SEPARATOR . 'Standard1',
);
];
foreach (array('in', 'files', 'name', 'sortByName') as $fluentMethod) {
foreach (['in', 'files', 'name', 'sortByName'] as $fluentMethod) {
$this->symfonyFinderMock
->method($fluentMethod)
->willReturn($this->symfonyFinderMock);
}
$splFileInfoMock = $this->getMockBuilder('Symfony\Component\Finder\SplFileInfo')
->setConstructorArgs(array(null, null, null))
->setConstructorArgs([null, null, null])
->getMock();
$splFileInfoMock
->expects($this->once())
->method('getPath')
->willReturn($path . DIRECTORY_SEPARATOR . 'Standard1');
$finderIterator = new \ArrayIterator(
array(
[
$splFileInfoMock,
)
]
);
$this->symfonyFinderMock
->expects($this->once())
......
......@@ -23,7 +23,6 @@ namespace Higidi\ComposerPhpCSStandardsPlugin\Tests\Unit\PHPCodeSniffer\Standard
use Higidi\ComposerPhpCSStandardsPlugin\PHPCodeSniffer\Standards\Factory;
use Higidi\ComposerPhpCSStandardsPlugin\PHPCodeSniffer\Standards\Standard\Factory as StandardFactory;
use Higidi\ComposerPhpCSStandardsPlugin\PHPCodeSniffer\Standards\Standard\Standard;
/**
* Test case for class \Higidi\ComposerPhpCSStandardsPlugin\PHPCodeSniffer\Standards\StandardsFactory
......@@ -66,10 +65,10 @@ class FactoryTest extends \PHPUnit_Framework_TestCase
public function testCreateStandard()
{
$paths = array();
$paths = [];
$paths[] = implode(
DIRECTORY_SEPARATOR,
array(__DIR__, '..', '..', '..', '..', 'Fixtures', 'Standards', 'Standard1')
[__DIR__, '..', '..', '..', '..', 'Fixtures', 'Standards', 'Standard1']
);
$this->standardFactoryMock
->expects($this->exactly(count($paths)))
......
......@@ -49,7 +49,7 @@ class FactoryTest extends \PHPUnit_Framework_TestCase
{
$path = implode(
DIRECTORY_SEPARATOR,
array(__DIR__, '..', '..', '..', '..', '..', 'Fixtures', 'Standards', 'Standard1')
[__DIR__, '..', '..', '..', '..', '..', 'Fixtures', 'Standards', 'Standard1']
);
$standard = $this->classUnderTesting->create($path);
......
......@@ -35,7 +35,7 @@ class StandardTest extends \PHPUnit_Framework_TestCase
{
$path = implode(
DIRECTORY_SEPARATOR,
array(__DIR__, '..', '..', '..', '..', '..', 'Fixtures', 'Standards', $standardName)
[__DIR__, '..', '..', '..', '..', '..', 'Fixtures', 'Standards', $standardName]
);
$ruleSetXmlPath = $path . DIRECTORY_SEPARATOR . 'ruleset.xml';
......@@ -60,20 +60,20 @@ class StandardTest extends \PHPUnit_Framework_TestCase
public function differentStandards()
{
return array(
'No Ruleset' => array(
return [
'No Ruleset' => [
'Standard1',
'Standard1',
),
'Ruleset with name' => array(
],
'Ruleset with name' => [
'standard_with_ruleset',
'CustomStandard',
),
'Ruleset without name' => array(
],
'Ruleset without name' => [
'standard_with_ruleset_without_name',
'standard_with_ruleset_without_name',
),
);
],
];
}
/**
......@@ -91,7 +91,7 @@ class StandardTest extends \PHPUnit_Framework_TestCase
{
$path = implode(
DIRECTORY_SEPARATOR,
array(__DIR__, '..', '..', '..', '..', '..', 'Fixtures', 'Standards', 'InvalidStandard')
[__DIR__, '..', '..', '..', '..', '..', 'Fixtures', 'Standards', 'InvalidStandard']
);
new Standard($path);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment