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

QA tool updates and PHP 5.5 removal #65

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ env:
matrix:
fast_finish: true
include:
- php: 5.5
env:
- EXECUTE_CS_CHECK=true
- php: 5.6
env:
- EXECUTE_TEST_COVERALLS=true
- TEST_COVERAGE=true
- DEPLOY_DOCS="$(if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then echo -n 'true' ; else echo -n 'false' ; fi)"
- PATH="$HOME/.local/bin:$PATH"
- php: 7
env:
- CS_CHECK=true
- php: hhvm
allow_failures:
- php: hhvm
Expand All @@ -42,21 +41,21 @@ notifications:
email: false

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

install:
- travis_retry composer install --no-interaction --ignore-platform-reqs

script:
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/phpunit --coverage-clover clover.xml ; fi
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then ./vendor/bin/phpunit ; fi
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/php-cs-fixer fix -v --diff --dry-run ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; fi
- if [[ $TEST_COVERAGE != 'true' ]]; then composer test ; fi
- if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi
- 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

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

after_script:
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/coveralls ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then composer upload-coverage ; fi
13 changes: 10 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
}
},
"require": {
"php": "^5.5 || ^7.0"
"php": "^5.6 || ^7.0"
},
"require-dev": {
"fabpot/php-cs-fixer": "1.7.*",
"athletic/athletic": "~0.1",
"phpunit/PHPUnit": "~4.0",
"athletic/athletic": "~0.1"
"squizlabs/php_codesniffer": "^2.6.2"
},
"extra": {
"branch-alias": {
Expand All @@ -31,5 +31,12 @@
"ZendTest\\Stdlib\\": "test/",
"ZendBench\\Stdlib\\": "benchmark/"
}
},
"scripts": {
"cs-check": "phpcs --colors",
"cs-fix": "phpcbf --colors",
"test": "phpunit --colors=always",
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
"upload-coverage": "coveralls -v"
}
}
27 changes: 27 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<ruleset name="Zend Framework coding standard">
<description>Zend Framework coding standard</description>

<!-- display progress -->
<arg value="p"/>
<arg name="colors"/>

<!-- inherit rules from: -->
<rule ref="PSR2"/>
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<rule ref="Generic.Formatting.SpaceAfterNot"/>
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>

<!-- Paths to check -->
<file>src</file>
<file>test</file>
</ruleset>
4 changes: 3 additions & 1 deletion src/AbstractOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@

abstract class AbstractOptions implements ParameterObjectInterface
{
// @codingStandardsIgnoreStart
/**
* We use the __ prefix to avoid collisions with properties in
* user-implementations.
*
* @var bool
*/
protected $__strictMode__ = true;
// @codingStandardsIgnoreEnd

/**
* Constructor
Expand All @@ -46,7 +48,7 @@ public function setFromArray($options)
$options = $options->toArray();
}

if (!is_array($options) && !$options instanceof Traversable) {
if (! is_array($options) && ! $options instanceof Traversable) {
throw new Exception\InvalidArgumentException(
sprintf(
'Parameter provided to %s must be an %s, %s or %s',
Expand Down
10 changes: 6 additions & 4 deletions src/ArrayObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,16 @@ public function count()
*/
public function exchangeArray($data)
{
if (!is_array($data) && !is_object($data)) {
throw new Exception\InvalidArgumentException('Passed variable is not an array or object, using empty array instead');
if (! is_array($data) && ! is_object($data)) {
throw new Exception\InvalidArgumentException(
'Passed variable is not an array or object, using empty array instead'
);
}

if (is_object($data) && ($data instanceof self || $data instanceof \ArrayObject)) {
$data = $data->getArrayCopy();
}
if (!is_array($data)) {
if (! is_array($data)) {
$data = (array) $data;
}

Expand Down Expand Up @@ -290,7 +292,7 @@ public function offsetExists($key)
public function &offsetGet($key)
{
$ret = null;
if (!$this->offsetExists($key)) {
if (! $this->offsetExists($key)) {
return $ret;
}
$ret =& $this->storage[$key];
Expand Down
30 changes: 15 additions & 15 deletions src/ArrayUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ abstract class ArrayUtils
*/
public static function hasStringKeys($value, $allowEmpty = false)
{
if (!is_array($value)) {
if (! is_array($value)) {
return false;
}

if (!$value) {
if (! $value) {
return $allowEmpty;
}

Expand All @@ -59,11 +59,11 @@ public static function hasStringKeys($value, $allowEmpty = false)
*/
public static function hasIntegerKeys($value, $allowEmpty = false)
{
if (!is_array($value)) {
if (! is_array($value)) {
return false;
}

if (!$value) {
if (! $value) {
return $allowEmpty;
}

Expand All @@ -86,11 +86,11 @@ public static function hasIntegerKeys($value, $allowEmpty = false)
*/
public static function hasNumericKeys($value, $allowEmpty = false)
{
if (!is_array($value)) {
if (! is_array($value)) {
return false;
}

if (!$value) {
if (! $value) {
return $allowEmpty;
}

Expand Down Expand Up @@ -119,11 +119,11 @@ public static function hasNumericKeys($value, $allowEmpty = false)
*/
public static function isList($value, $allowEmpty = false)
{
if (!is_array($value)) {
if (! is_array($value)) {
return false;
}

if (!$value) {
if (! $value) {
return $allowEmpty;
}

Expand Down Expand Up @@ -161,11 +161,11 @@ public static function isList($value, $allowEmpty = false)
*/
public static function isHashTable($value, $allowEmpty = false)
{
if (!is_array($value)) {
if (! is_array($value)) {
return false;
}

if (!$value) {
if (! $value) {
return $allowEmpty;
}

Expand All @@ -187,7 +187,7 @@ public static function isHashTable($value, $allowEmpty = false)
*/
public static function inArray($needle, array $haystack, $strict = false)
{
if (!$strict) {
if (! $strict) {
if (is_int($needle) || is_float($needle)) {
$needle = (string) $needle;
}
Expand Down Expand Up @@ -215,11 +215,11 @@ public static function inArray($needle, array $haystack, $strict = false)
*/
public static function iteratorToArray($iterator, $recursive = true)
{
if (!is_array($iterator) && !$iterator instanceof Traversable) {
if (! is_array($iterator) && ! $iterator instanceof Traversable) {
throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable object');
}

if (!$recursive) {
if (! $recursive) {
if (is_array($iterator)) {
return $iterator;
}
Expand Down Expand Up @@ -274,15 +274,15 @@ public static function merge(array $a, array $b, $preserveNumericKeys = false)
} elseif (isset($a[$key]) || array_key_exists($key, $a)) {
if ($value instanceof MergeRemoveKey) {
unset($a[$key]);
} elseif (!$preserveNumericKeys && is_int($key)) {
} elseif (! $preserveNumericKeys && is_int($key)) {
$a[] = $value;
} elseif (is_array($value) && is_array($a[$key])) {
$a[$key] = static::merge($a[$key], $value, $preserveNumericKeys);
} else {
$a[$key] = $value;
}
} else {
if (!$value instanceof MergeRemoveKey) {
if (! $value instanceof MergeRemoveKey) {
$a[$key] = $value;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static function getNestedLevel()
*/
public static function start($errorLevel = \E_WARNING)
{
if (!static::$stack) {
if (! static::$stack) {
set_error_handler([get_called_class(), 'addError'], $errorLevel);
}

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

if (!static::$stack) {
if (! static::$stack) {
restore_error_handler();
}

Expand Down
6 changes: 3 additions & 3 deletions src/Glob.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ abstract class Glob
*/
public static function glob($pattern, $flags = 0, $forceFallback = false)
{
if (!defined('GLOB_BRACE') || $forceFallback) {
if (! defined('GLOB_BRACE') || $forceFallback) {
return static::fallbackGlob($pattern, $flags);
}

Expand Down Expand Up @@ -96,7 +96,7 @@ protected static function systemGlob($pattern, $flags)
*/
protected static function fallbackGlob($pattern, $flags)
{
if (!$flags & self::GLOB_BRACE) {
if (! $flags & self::GLOB_BRACE) {
return static::systemGlob($pattern, $flags);
}

Expand Down Expand Up @@ -182,7 +182,7 @@ protected static function nextBraceSub($pattern, $begin, $flags)
$current = $begin;

while ($current < $length) {
if (!$flags & self::GLOB_NOESCAPE && $pattern[$current] === '\\') {
if (! $flags & self::GLOB_NOESCAPE && $pattern[$current] === '\\') {
if (++$current === $length) {
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Guard/ArrayOrTraversableGuardTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function guardForArrayOrTraversable(
$dataName = 'Argument',
$exceptionClass = 'Zend\Stdlib\Exception\InvalidArgumentException'
) {
if (!is_array($data) && !($data instanceof Traversable)) {
if (! is_array($data) && ! ($data instanceof Traversable)) {
$message = sprintf(
"%s must be an array or Traversable, [%s] given",
$dataName,
Expand Down
4 changes: 2 additions & 2 deletions src/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function setMetadata($spec, $value = null)
$this->metadata[$spec] = $value;
return $this;
}
if (!is_array($spec) && !$spec instanceof Traversable) {
if (! is_array($spec) && ! $spec instanceof Traversable) {
throw new Exception\InvalidArgumentException(sprintf(
'Expected a string, array, or Traversable argument in first position; received "%s"',
(is_object($spec) ? get_class($spec) : gettype($spec))
Expand All @@ -66,7 +66,7 @@ public function getMetadata($key = null, $default = null)
return $this->metadata;
}

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

Expand Down
10 changes: 5 additions & 5 deletions src/PriorityList.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class PriorityList implements Iterator, Countable
*/
public function insert($name, $value, $priority = 0)
{
if (!isset($this->items[$name])) {
if (! isset($this->items[$name])) {
$this->count++;
}

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

Expand Down Expand Up @@ -131,7 +131,7 @@ public function clear()
*/
public function get($name)
{
if (!isset($this->items[$name])) {
if (! isset($this->items[$name])) {
return;
}

Expand All @@ -145,7 +145,7 @@ public function get($name)
*/
protected function sort()
{
if (!$this->sorted) {
if (! $this->sorted) {
uasort($this->items, [$this, 'compare']);
$this->sorted = true;
}
Expand All @@ -161,7 +161,7 @@ protected function sort()
protected function compare(array $item1, array $item2)
{
return ($item1['priority'] === $item2['priority'])
? ($item1['serial'] > $item2['serial'] ? -1 : 1) * $this->isLIFO
? ($item1['serial'] > $item2['serial'] ? -1 : 1) * $this->isLIFO
: ($item1['priority'] > $item2['priority'] ? -1 : 1);
}

Expand Down
Loading