Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.
Merged
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
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,12 @@ install:
- composer show

script:
- if [[ $TEST_COVERAGE == 'true' ]]; then ./vendor/bin/phpunit --coverage-clover clover.xml ; fi
- if [[ $TEST_COVERAGE != 'true' ]]; then ./vendor/bin/phpunit ; fi
- if [[ $CS_CHECK == 'true' ]]; then ./vendor/bin/phpcs ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; else 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 [[ $TEST_COVERAGE == 'true' ]]; then ./vendor/bin/coveralls ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then composer upload-coverage ; fi
14 changes: 7 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,24 @@ To do so:

## Running Coding Standards Checks

This component uses [php-cs-fixer](http://cs.sensiolabs.org/) for coding
This component uses [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) for coding
standards checks, and provides configuration for our selected checks.
`php-cs-fixer` is installed by default via Composer.
`phpcs` is installed by default via Composer.

To run checks only:

```console
$ ./vendor/bin/php-cs-fixer fix . -v --diff --dry-run --config-file=.php_cs
$ composer cs-check
```

To have `php-cs-fixer` attempt to fix problems for you, omit the `--dry-run`
flag:
`phpcs` also includes a tool for fixing most CS violations, `phpcbf`:


```console
$ ./vendor/bin/php-cs-fixer fix . -v --diff --config-file=.php_cs
$ composer cs-fix
```

If you allow php-cs-fixer to fix CS issues, please re-run the tests to ensure
If you allow `phpcbf` to fix CS issues, please re-run the tests to ensure
they pass, and make sure you add and commit the changes after verification.

## Recommended Workflow for Contributions
Expand Down
13 changes: 12 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"require-dev": {
"phpunit/phpUnit": "^4.8",
"squizlabs/php_codesniffer": "^2.3.1"
"zendframework/zend-coding-standard": "~1.0.0"
},
"autoload": {
"psr-4": {
Expand All @@ -34,5 +34,16 @@
"files": [
"test/TestAsset/reflectionTestFunction.php"
]
},
"scripts": {
"check": [
"@cs-check",
"@test"
],
"cs-check": "phpcs",
"cs-fix": "phpcbf",
"test": "phpunit --colors=always",
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
"upload-coverage": "coveralls -v"
}
}
43 changes: 36 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 1 addition & 17 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
<?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="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
<rule ref="./vendor/zendframework/zend-coding-standard/ruleset.xml"/>

<!-- Paths to check -->
<file>src</file>
<file>test</file>
<exclude-pattern>*/TestAsset/*</exclude-pattern>
<exclude-pattern>*/_files/*</exclude-pattern>
<exclude-pattern>*/compatibility/*</exclude-pattern>
</ruleset>
6 changes: 3 additions & 3 deletions src/AbstractServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected function _buildSignature(Reflection\AbstractFunction $reflection, $cla
$name = $reflection->getName();
$method = empty($ns) ? $name : $ns . '.' . $name;

if (!$this->overwriteExistingMethods && $this->table->hasMethod($method)) {
if (! $this->overwriteExistingMethods && $this->table->hasMethod($method)) {
throw new Exception\RuntimeException('Duplicate method registered: ' . $method);
}

Expand Down Expand Up @@ -153,9 +153,9 @@ protected function _dispatch(Method\Definition $invokable, array $params)
}

$object = $invokable->getObject();
if (!is_object($object)) {
if (! is_object($object)) {
$invokeArgs = $invokable->getInvokeArguments();
if (!empty($invokeArgs)) {
if (! empty($invokeArgs)) {
$reflection = new ReflectionClass($class);
$object = $reflection->newInstanceArgs($invokeArgs);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Cache
*/
public static function save($filename, Server $server)
{
if (!is_string($filename) || (!file_exists($filename) && !is_writable(dirname($filename)))) {
if (! is_string($filename) || (! file_exists($filename) && ! is_writable(dirname($filename)))) {
return false;
}

Expand Down Expand Up @@ -96,7 +96,7 @@ public static function save($filename, Server $server)
*/
public static function get($filename, Server $server)
{
if (!is_string($filename) || !file_exists($filename) || !is_readable($filename)) {
if (! is_string($filename) || ! file_exists($filename) || ! is_readable($filename)) {
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Definition.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function addMethod($method, $name = null)
{
if (is_array($method)) {
$method = new Method\Definition($method);
} elseif (!$method instanceof Method\Definition) {
} elseif (! $method instanceof Method\Definition) {
throw new Exception\InvalidArgumentException('Invalid method provided');
}

Expand All @@ -79,7 +79,7 @@ public function addMethod($method, $name = null)
throw new Exception\InvalidArgumentException('No method name provided');
}

if (!$this->overwriteExistingMethods && array_key_exists($name, $this->methods)) {
if (! $this->overwriteExistingMethods && array_key_exists($name, $this->methods)) {
throw new Exception\InvalidArgumentException(sprintf('Method by name of "%s" already exists', $name));
}
$this->methods[$name] = $method;
Expand Down
2 changes: 1 addition & 1 deletion src/Method/Callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function getMethod()
*/
public function setType($type)
{
if (!in_array($type, $this->types)) {
if (! in_array($type, $this->types)) {
throw new Server\Exception\InvalidArgumentException(sprintf(
'Invalid method callback type "%s" passed to %s',
$type,
Expand Down
6 changes: 3 additions & 3 deletions src/Method/Definition.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function setCallback($callback)
{
if (is_array($callback)) {
$callback = new Callback($callback);
} elseif (!$callback instanceof Callback) {
} elseif (! $callback instanceof Callback) {
throw new Server\Exception\InvalidArgumentException('Invalid method callback provided');
}
$this->callback = $callback;
Expand Down Expand Up @@ -136,7 +136,7 @@ public function addPrototype($prototype)
{
if (is_array($prototype)) {
$prototype = new Prototype($prototype);
} elseif (!$prototype instanceof Prototype) {
} elseif (! $prototype instanceof Prototype) {
throw new Server\Exception\InvalidArgumentException('Invalid method prototype provided');
}
$this->prototypes[] = $prototype;
Expand Down Expand Up @@ -211,7 +211,7 @@ public function getMethodHelp()
*/
public function setObject($object)
{
if (!is_object($object) && (null !== $object)) {
if (! is_object($object) && (null !== $object)) {
throw new Server\Exception\InvalidArgumentException(sprintf(
'Invalid object passed to %s',
__METHOD__
Expand Down
2 changes: 1 addition & 1 deletion src/Method/Prototype.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function getParameterObjects()
*/
public function getParameter($index)
{
if (!is_string($index) && !is_numeric($index)) {
if (! is_string($index) && ! is_numeric($index)) {
return;
}
if (array_key_exists($index, $this->parameterNameMap)) {
Expand Down
6 changes: 3 additions & 3 deletions src/Reflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static function reflectClass($class, $argv = false, $namespace = '')
throw new Reflection\Exception\InvalidArgumentException('Invalid class or object passed to attachClass()');
}

if ($argv && !is_array($argv)) {
if ($argv && ! is_array($argv)) {
throw new Reflection\Exception\InvalidArgumentException('Invalid argv argument passed to reflectClass');
}

Expand All @@ -70,14 +70,14 @@ public static function reflectClass($class, $argv = false, $namespace = '')
*/
public static function reflectFunction($function, $argv = false, $namespace = '')
{
if (!is_string($function) || !function_exists($function)) {
if (! is_string($function) || ! function_exists($function)) {
throw new Reflection\Exception\InvalidArgumentException(sprintf(
'Invalid function "%s" passed to reflectFunction',
$function
));
}

if ($argv && !is_array($argv)) {
if ($argv && ! is_array($argv)) {
throw new Reflection\Exception\InvalidArgumentException('Invalid argv argument passed to reflectFunction');
}

Expand Down
8 changes: 4 additions & 4 deletions src/Reflection/AbstractFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ protected function buildSignatures($return, $returnDesc, $paramTypes, $paramDesc
}

foreach ($endPoints as $node) {
if (!$node instanceof Node) {
if (! $node instanceof Node) {
continue;
}

Expand Down Expand Up @@ -242,7 +242,7 @@ protected function reflect()
$paramCount = $function->getNumberOfParameters();
$parameters = $function->getParameters();

if (!$this->docComment) {
if (! $this->docComment) {
$this->docComment = $function->getDocComment();
}

Expand Down Expand Up @@ -376,7 +376,7 @@ public function setNamespace($namespace)
return;
}

if (!is_string($namespace) || !preg_match('/[a-z0-9_\.]+/i', $namespace)) {
if (! is_string($namespace) || ! preg_match('/[a-z0-9_\.]+/i', $namespace)) {
throw new Exception\InvalidArgumentException('Invalid namespace');
}

Expand All @@ -402,7 +402,7 @@ public function getNamespace()
*/
public function setDescription($string)
{
if (!is_string($string)) {
if (! is_string($string)) {
throw new Exception\InvalidArgumentException('Invalid description');
}

Expand Down
6 changes: 3 additions & 3 deletions src/Reflection/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function setValue($value)
public function getEndPoints()
{
$endPoints = [];
if (!$this->hasChildren()) {
if (! $this->hasChildren()) {
return $endPoints;
}

Expand All @@ -170,10 +170,10 @@ public function getEndPoints()
$endPoints[] = $this;
} elseif ((null !== $value) && $child->hasChildren()) {
$childEndPoints = $child->getEndPoints();
if (!empty($childEndPoints)) {
if (! empty($childEndPoints)) {
$endPoints = array_merge($endPoints, $childEndPoints);
}
} elseif ((null !== $value) && !$child->hasChildren()) {
} elseif ((null !== $value) && ! $child->hasChildren()) {
$endPoints[] = $child;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Reflection/Prototype.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(ReflectionReturnValue $return, array $params = [])
$this->return = $return;

foreach ($params as $param) {
if (!$param instanceof ReflectionParameter) {
if (! $param instanceof ReflectionParameter) {
throw new Exception\InvalidArgumentException('One or more params are invalid');
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Reflection/ReflectionClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function setNamespace($namespace)
return;
}

if (!is_string($namespace) || !preg_match('/[a-z0-9_\.]+/i', $namespace)) {
if (! is_string($namespace) || ! preg_match('/[a-z0-9_\.]+/i', $namespace)) {
throw new Exception\InvalidArgumentException('Invalid namespace');
}

Expand Down
Loading