Commit 280968ce authored by Daniel Hürtgen's avatar Daniel Hürtgen

Merge branch 'develop' into 7-implement-tests

* develop:
  FEATURE: Drop support for PHP 5.3
  FEATURE: Provide minimal required php version in composer.json
  FEATURE: Provide source & issues url via composer.json

# Conflicts:
#	.gitlab-ci.yml
#	src/PHPCodeSniffer/Standards/Standards.php
#	tests/Integration/PHPCodeSniffer/FinderTest.php
#	tests/Unit/PHPCodeSniffer/Standards/FactoryTest.php
#	tests/Unit/PHPCodeSniffer/Standards/Standard/FactoryTest.php
#	tests/Unit/PHPCodeSniffer/Standards/Standard/StandardTest.php
parents b097d41f 9a1bf782
Pipeline #385 passed with stages
in 5 minutes and 59 seconds
......@@ -48,9 +48,6 @@ lint:php-mass-detection:
script:
- ./vendor/bin/phpunit --coverage-text --colors=never
test:5.3:
<<: *test
image: tetraweb/php:5.3
test:5.4:
<<: *test
image: tetraweb/php:5.4
......
......@@ -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
......
......@@ -17,6 +17,10 @@
"role": "Developer"
}
],
"support": {
"issues": "https://git.higidi.com/higidi/composer-phpcodesniffer-standards-plugin/issues",
"source": "https://git.higidi.com/higidi/composer-phpcodesniffer-standards-plugin"
},
"autoload": {
"psr-4": {
"Higidi\\ComposerPhpCSStandardsPlugin\\": "src/"
......@@ -28,6 +32,7 @@
}
},
"require": {
"php": "^5.4 || ^7.0",
"composer-plugin-api": "^1.1",
"squizlabs/php_codesniffer": "^2.0",
"symfony/finder": "^2.1 || ^3.0",
......
......@@ -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)
);
......@@ -78,8 +78,7 @@ class Standard implements StandardInterface
{
try {
$ruleSet = new \SimpleXMLElement(file_get_contents($ruleSetXmlPath));
$attributes = $ruleSet->attributes();
$name = trim($attributes['name']);
$name = trim($ruleSet->attributes()['name']);
if ($name !== '') {
return $name;
}
......
......@@ -36,7 +36,7 @@ class Standards implements \Iterator
/**
* @param StandardInterface[] $standards
*/
public function __construct(array $standards = array())
public function __construct(array $standards = [])
{
$this->setStandards($standards);
}
......@@ -92,7 +92,7 @@ class Standards implements \Iterator
*/
public function getStandard($standard)
{
if (!$this->hasStandard($standard)) {
if (! $this->hasStandard($standard)) {
return null;
}
......@@ -144,6 +144,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
......@@ -155,6 +156,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
......@@ -166,6 +168,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
......@@ -179,6 +182,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.
......@@ -191,6 +195,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
......
......@@ -60,14 +60,14 @@ class FinderTest extends 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())
......
......@@ -81,28 +81,28 @@ class FinderTest extends 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())
......
......@@ -68,10 +68,10 @@ class FactoryTest extends 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)))
......
......@@ -52,7 +52,7 @@ class FactoryTest extends TestCase
{
$path = implode(
DIRECTORY_SEPARATOR,
array(__DIR__, '..', '..', '..', '..', 'Fixtures', 'Standards', 'Standard1')
[__DIR__, '..', '..', '..', '..', 'Fixtures', 'Standards', 'Standard1']
);
$standard = $this->classUnderTesting->create($path);
......
......@@ -38,7 +38,7 @@ class StandardTest extends TestCase
{
$path = implode(
DIRECTORY_SEPARATOR,
array(__DIR__, '..', '..', '..', '..', 'Fixtures', 'Standards', $standardName)
[__DIR__, '..', '..', '..', '..', 'Fixtures', 'Standards', $standardName]
);
$ruleSetXmlPath = $path . DIRECTORY_SEPARATOR . 'ruleset.xml';
......@@ -63,20 +63,20 @@ class StandardTest extends 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',
),
);
],
];
}
/**
......@@ -94,7 +94,7 @@ class StandardTest extends TestCase
{
$path = implode(
DIRECTORY_SEPARATOR,
array(__DIR__, '..', '..', '..', '..', 'Fixtures', 'Standards', 'InvalidStandard')
[__DIR__, '..', '..', '..', '..', 'Fixtures', 'Standards', 'InvalidStandard']
);
new Standard($path);
......
......@@ -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);
......
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