Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit a51b3d5

Browse files
committed
Merge branch 'feature/phpcs' into develop
Close #65
2 parents 9aaa0e6 + b06c38a commit a51b3d5

33 files changed

+160
-95
lines changed

.travis.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,14 @@ env:
2424
matrix:
2525
fast_finish: true
2626
include:
27-
- php: 5.5
28-
env:
29-
- EXECUTE_CS_CHECK=true
3027
- php: 5.6
3128
env:
32-
- EXECUTE_TEST_COVERALLS=true
29+
- TEST_COVERAGE=true
3330
- DEPLOY_DOCS="$(if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then echo -n 'true' ; else echo -n 'false' ; fi)"
3431
- PATH="$HOME/.local/bin:$PATH"
3532
- php: 7
33+
env:
34+
- CS_CHECK=true
3635
- php: hhvm
3736
allow_failures:
3837
- php: hhvm
@@ -42,21 +41,21 @@ notifications:
4241
email: false
4342

4443
before_install:
45-
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
44+
- if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
4645
- composer self-update
47-
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi
46+
- if [[ $TEST_COVERAGE == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi
4847

4948
install:
5049
- travis_retry composer install --no-interaction --ignore-platform-reqs
5150

5251
script:
53-
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/phpunit --coverage-clover clover.xml ; fi
54-
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then ./vendor/bin/phpunit ; fi
55-
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/php-cs-fixer fix -v --diff --dry-run ; fi
52+
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; fi
53+
- if [[ $TEST_COVERAGE != 'true' ]]; then composer test ; fi
54+
- if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi
5655
- if [[ $DEPLOY_DOCS == "true" && "$TRAVIS_TEST_RESULT" == "0" ]]; then wget -O theme-installer.sh "https://raw.githubusercontent.com/zendframework/zf-mkdoc-theme/master/theme-installer.sh" ; chmod 755 theme-installer.sh ; ./theme-installer.sh ; fi
5756

5857
after_success:
5958
- if [[ $DEPLOY_DOCS == "true" ]]; then echo "Preparing to build and deploy documentation" ; ./zf-mkdoc-theme/deploy.sh ; echo "Completed deploying documentation" ; fi
6059

6160
after_script:
62-
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/coveralls ; fi
61+
- if [[ $TEST_COVERAGE == 'true' ]]; then composer upload-coverage ; fi

composer.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
}
1414
},
1515
"require": {
16-
"php": "^5.5 || ^7.0"
16+
"php": "^5.6 || ^7.0"
1717
},
1818
"require-dev": {
19-
"fabpot/php-cs-fixer": "1.7.*",
19+
"athletic/athletic": "~0.1",
2020
"phpunit/PHPUnit": "~4.0",
21-
"athletic/athletic": "~0.1"
21+
"squizlabs/php_codesniffer": "^2.6.2"
2222
},
2323
"extra": {
2424
"branch-alias": {
@@ -31,5 +31,12 @@
3131
"ZendTest\\Stdlib\\": "test/",
3232
"ZendBench\\Stdlib\\": "benchmark/"
3333
}
34+
},
35+
"scripts": {
36+
"cs-check": "phpcs --colors",
37+
"cs-fix": "phpcbf --colors",
38+
"test": "phpunit --colors=always",
39+
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
40+
"upload-coverage": "coveralls -v"
3441
}
3542
}

phpcs.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Zend Framework coding standard">
3+
<description>Zend Framework coding standard</description>
4+
5+
<!-- display progress -->
6+
<arg value="p"/>
7+
<arg name="colors"/>
8+
9+
<!-- inherit rules from: -->
10+
<rule ref="PSR2"/>
11+
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
12+
<rule ref="Generic.Formatting.SpaceAfterNot"/>
13+
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
14+
<properties>
15+
<property name="ignoreNewlines" value="true"/>
16+
</properties>
17+
</rule>
18+
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
19+
<properties>
20+
<property name="ignoreBlankLines" value="false"/>
21+
</properties>
22+
</rule>
23+
24+
<!-- Paths to check -->
25+
<file>src</file>
26+
<file>test</file>
27+
</ruleset>

src/AbstractOptions.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313

1414
abstract class AbstractOptions implements ParameterObjectInterface
1515
{
16+
// @codingStandardsIgnoreStart
1617
/**
1718
* We use the __ prefix to avoid collisions with properties in
1819
* user-implementations.
1920
*
2021
* @var bool
2122
*/
2223
protected $__strictMode__ = true;
24+
// @codingStandardsIgnoreEnd
2325

2426
/**
2527
* Constructor
@@ -46,7 +48,7 @@ public function setFromArray($options)
4648
$options = $options->toArray();
4749
}
4850

49-
if (!is_array($options) && !$options instanceof Traversable) {
51+
if (! is_array($options) && ! $options instanceof Traversable) {
5052
throw new Exception\InvalidArgumentException(
5153
sprintf(
5254
'Parameter provided to %s must be an %s, %s or %s',

src/ArrayObject.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,16 @@ public function count()
180180
*/
181181
public function exchangeArray($data)
182182
{
183-
if (!is_array($data) && !is_object($data)) {
184-
throw new Exception\InvalidArgumentException('Passed variable is not an array or object, using empty array instead');
183+
if (! is_array($data) && ! is_object($data)) {
184+
throw new Exception\InvalidArgumentException(
185+
'Passed variable is not an array or object, using empty array instead'
186+
);
185187
}
186188

187189
if (is_object($data) && ($data instanceof self || $data instanceof \ArrayObject)) {
188190
$data = $data->getArrayCopy();
189191
}
190-
if (!is_array($data)) {
192+
if (! is_array($data)) {
191193
$data = (array) $data;
192194
}
193195

@@ -290,7 +292,7 @@ public function offsetExists($key)
290292
public function &offsetGet($key)
291293
{
292294
$ret = null;
293-
if (!$this->offsetExists($key)) {
295+
if (! $this->offsetExists($key)) {
294296
return $ret;
295297
}
296298
$ret =& $this->storage[$key];

src/ArrayUtils.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ abstract class ArrayUtils
3939
*/
4040
public static function hasStringKeys($value, $allowEmpty = false)
4141
{
42-
if (!is_array($value)) {
42+
if (! is_array($value)) {
4343
return false;
4444
}
4545

46-
if (!$value) {
46+
if (! $value) {
4747
return $allowEmpty;
4848
}
4949

@@ -59,11 +59,11 @@ public static function hasStringKeys($value, $allowEmpty = false)
5959
*/
6060
public static function hasIntegerKeys($value, $allowEmpty = false)
6161
{
62-
if (!is_array($value)) {
62+
if (! is_array($value)) {
6363
return false;
6464
}
6565

66-
if (!$value) {
66+
if (! $value) {
6767
return $allowEmpty;
6868
}
6969

@@ -86,11 +86,11 @@ public static function hasIntegerKeys($value, $allowEmpty = false)
8686
*/
8787
public static function hasNumericKeys($value, $allowEmpty = false)
8888
{
89-
if (!is_array($value)) {
89+
if (! is_array($value)) {
9090
return false;
9191
}
9292

93-
if (!$value) {
93+
if (! $value) {
9494
return $allowEmpty;
9595
}
9696

@@ -119,11 +119,11 @@ public static function hasNumericKeys($value, $allowEmpty = false)
119119
*/
120120
public static function isList($value, $allowEmpty = false)
121121
{
122-
if (!is_array($value)) {
122+
if (! is_array($value)) {
123123
return false;
124124
}
125125

126-
if (!$value) {
126+
if (! $value) {
127127
return $allowEmpty;
128128
}
129129

@@ -161,11 +161,11 @@ public static function isList($value, $allowEmpty = false)
161161
*/
162162
public static function isHashTable($value, $allowEmpty = false)
163163
{
164-
if (!is_array($value)) {
164+
if (! is_array($value)) {
165165
return false;
166166
}
167167

168-
if (!$value) {
168+
if (! $value) {
169169
return $allowEmpty;
170170
}
171171

@@ -187,7 +187,7 @@ public static function isHashTable($value, $allowEmpty = false)
187187
*/
188188
public static function inArray($needle, array $haystack, $strict = false)
189189
{
190-
if (!$strict) {
190+
if (! $strict) {
191191
if (is_int($needle) || is_float($needle)) {
192192
$needle = (string) $needle;
193193
}
@@ -215,11 +215,11 @@ public static function inArray($needle, array $haystack, $strict = false)
215215
*/
216216
public static function iteratorToArray($iterator, $recursive = true)
217217
{
218-
if (!is_array($iterator) && !$iterator instanceof Traversable) {
218+
if (! is_array($iterator) && ! $iterator instanceof Traversable) {
219219
throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable object');
220220
}
221221

222-
if (!$recursive) {
222+
if (! $recursive) {
223223
if (is_array($iterator)) {
224224
return $iterator;
225225
}
@@ -274,15 +274,15 @@ public static function merge(array $a, array $b, $preserveNumericKeys = false)
274274
} elseif (isset($a[$key]) || array_key_exists($key, $a)) {
275275
if ($value instanceof MergeRemoveKey) {
276276
unset($a[$key]);
277-
} elseif (!$preserveNumericKeys && is_int($key)) {
277+
} elseif (! $preserveNumericKeys && is_int($key)) {
278278
$a[] = $value;
279279
} elseif (is_array($value) && is_array($a[$key])) {
280280
$a[$key] = static::merge($a[$key], $value, $preserveNumericKeys);
281281
} else {
282282
$a[$key] = $value;
283283
}
284284
} else {
285-
if (!$value instanceof MergeRemoveKey) {
285+
if (! $value instanceof MergeRemoveKey) {
286286
$a[$key] = $value;
287287
}
288288
}

src/ErrorHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static function getNestedLevel()
5151
*/
5252
public static function start($errorLevel = \E_WARNING)
5353
{
54-
if (!static::$stack) {
54+
if (! static::$stack) {
5555
set_error_handler([get_called_class(), 'addError'], $errorLevel);
5656
}
5757

@@ -72,7 +72,7 @@ public static function stop($throw = false)
7272
if (static::$stack) {
7373
$errorException = array_pop(static::$stack);
7474

75-
if (!static::$stack) {
75+
if (! static::$stack) {
7676
restore_error_handler();
7777
}
7878

src/Glob.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ abstract class Glob
3838
*/
3939
public static function glob($pattern, $flags = 0, $forceFallback = false)
4040
{
41-
if (!defined('GLOB_BRACE') || $forceFallback) {
41+
if (! defined('GLOB_BRACE') || $forceFallback) {
4242
return static::fallbackGlob($pattern, $flags);
4343
}
4444

@@ -96,7 +96,7 @@ protected static function systemGlob($pattern, $flags)
9696
*/
9797
protected static function fallbackGlob($pattern, $flags)
9898
{
99-
if (!$flags & self::GLOB_BRACE) {
99+
if (! $flags & self::GLOB_BRACE) {
100100
return static::systemGlob($pattern, $flags);
101101
}
102102

@@ -182,7 +182,7 @@ protected static function nextBraceSub($pattern, $begin, $flags)
182182
$current = $begin;
183183

184184
while ($current < $length) {
185-
if (!$flags & self::GLOB_NOESCAPE && $pattern[$current] === '\\') {
185+
if (! $flags & self::GLOB_NOESCAPE && $pattern[$current] === '\\') {
186186
if (++$current === $length) {
187187
break;
188188
}

src/Guard/ArrayOrTraversableGuardTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected function guardForArrayOrTraversable(
2929
$dataName = 'Argument',
3030
$exceptionClass = 'Zend\Stdlib\Exception\InvalidArgumentException'
3131
) {
32-
if (!is_array($data) && !($data instanceof Traversable)) {
32+
if (! is_array($data) && ! ($data instanceof Traversable)) {
3333
$message = sprintf(
3434
"%s must be an array or Traversable, [%s] given",
3535
$dataName,

src/Message.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function setMetadata($spec, $value = null)
4040
$this->metadata[$spec] = $value;
4141
return $this;
4242
}
43-
if (!is_array($spec) && !$spec instanceof Traversable) {
43+
if (! is_array($spec) && ! $spec instanceof Traversable) {
4444
throw new Exception\InvalidArgumentException(sprintf(
4545
'Expected a string, array, or Traversable argument in first position; received "%s"',
4646
(is_object($spec) ? get_class($spec) : gettype($spec))
@@ -66,7 +66,7 @@ public function getMetadata($key = null, $default = null)
6666
return $this->metadata;
6767
}
6868

69-
if (!is_scalar($key)) {
69+
if (! is_scalar($key)) {
7070
throw new Exception\InvalidArgumentException('Non-scalar argument provided for key');
7171
}
7272

src/PriorityList.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class PriorityList implements Iterator, Countable
6262
*/
6363
public function insert($name, $value, $priority = 0)
6464
{
65-
if (!isset($this->items[$name])) {
65+
if (! isset($this->items[$name])) {
6666
$this->count++;
6767
}
6868

@@ -85,7 +85,7 @@ public function insert($name, $value, $priority = 0)
8585
*/
8686
public function setPriority($name, $priority)
8787
{
88-
if (!isset($this->items[$name])) {
88+
if (! isset($this->items[$name])) {
8989
throw new \Exception("item $name not found");
9090
}
9191

@@ -131,7 +131,7 @@ public function clear()
131131
*/
132132
public function get($name)
133133
{
134-
if (!isset($this->items[$name])) {
134+
if (! isset($this->items[$name])) {
135135
return;
136136
}
137137

@@ -145,7 +145,7 @@ public function get($name)
145145
*/
146146
protected function sort()
147147
{
148-
if (!$this->sorted) {
148+
if (! $this->sorted) {
149149
uasort($this->items, [$this, 'compare']);
150150
$this->sorted = true;
151151
}
@@ -161,7 +161,7 @@ protected function sort()
161161
protected function compare(array $item1, array $item2)
162162
{
163163
return ($item1['priority'] === $item2['priority'])
164-
? ($item1['serial'] > $item2['serial'] ? -1 : 1) * $this->isLIFO
164+
? ($item1['serial'] > $item2['serial'] ? -1 : 1) * $this->isLIFO
165165
: ($item1['priority'] > $item2['priority'] ? -1 : 1);
166166
}
167167

0 commit comments

Comments
 (0)