Skip to content
Closed

WIP #144

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
1 change: 1 addition & 0 deletions .phpunit.result.cache

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.PHONY: install-phive
install-phive:
mkdir tools; \
wget -O tools/phive.phar https://phar.io/releases/phive.phar; \
wget -O tools/phive.phar.asc https://phar.io/releases/phive.phar.asc; \
gpg --keyserver pool.sks-keyservers.net --recv-keys 0x9D8A98B29B2D5D79; \
gpg --verify tools/phive.phar.asc tools/phive.phar; \
chmod +x tools/phive.phar

.PHONY: setup
setup: install-phive
docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phar-ga:latest php tools/phive.phar install --force-accept-unsigned

.PHONY: phpcs
phpcs:
docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpcs-ga:latest -d memory_limit=1024M

.PHONY: phpstan
phpstan:
docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpstan-ga:latest analyse src --no-progress --level max --configuration phpstan.neon

.PHONY: psaml
psalm:
docker run -it --rm -v${PWD}:/opt/project -w /opt/project mickaelandrieu/psalm-ga

.PHONY: test
test:
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.2 tools/phpunit

.PHONY: pre-commit-test
pre-commit-test: test phpcs phpstan psalm

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"minimum-stability": "alpha",
"require": {
"php": ">=7.1",
"php": "^7.2",
"psr/log": "~1.0",
"nikic/php-parser": "^4.0",
"phpdocumentor/reflection-docblock": "^5"
Expand Down
4 changes: 2 additions & 2 deletions composer.lock

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

4 changes: 2 additions & 2 deletions phive.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpstan" version="^0.9.1" installed="0.11.4" location="./tools/phpstan" copy="true"/>
<phar name="phpunit" version="^7.0" installed="7.5.7" location="./tools/phpunit" copy="true"/>
<phar name="phpunit" version="^8.4.3" installed="8.4.3" location="./tools/phpunit" copy="true"/>
<phar name="phpstan" version="^0.12" installed="0.12.2" location="./tools/phpstan" copy="true"/>
<phar name="phpbench" version="^0.16.9" installed="0.16.9" location="./tools/phpbench" copy="true"/>
</phive>
30 changes: 30 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0"?>
<ruleset name="phpDocumentor">
<description>The coding standard for phpDocumentor.</description>

<file>src</file>
<file>tests/unit</file>
<exclude-pattern>*/tests/unit/Types/ContextFactoryTest.php</exclude-pattern>
<arg value="p"/>
<rule ref="PSR2">
<include-pattern>*\.php</include-pattern>
</rule>

<rule ref="Doctrine">
<exclude name="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint.UselessDocComment" />
</rule>

<rule ref="Squiz.Classes.ValidClassName.NotCamelCaps">
<exclude-pattern>*/src/*_.php</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming.SuperfluousPrefix">
<exclude-pattern>*/src/*/Abstract*.php</exclude-pattern>
</rule>

<rule ref="Generic.Formatting.SpaceAfterNot">
<properties>
<property name="spacing" value="0" />
</properties>
</rule>
</ruleset>
13 changes: 7 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>

<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.0/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
verbose="true"
forceCoversAnnotation="true"
checkForUnintentionallyCoveredCode="false"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutChangesToGlobalState="true"
beStrictAboutTodoAnnotatedTests="true"
>
<testsuites>
<testsuite name="unit">
Expand All @@ -22,15 +27,11 @@
</filter>
<logging>
<log type="coverage-html"
title="phpDocumentor Reflection"
target="build/coverage"
charset="UTF-8"
yui="true"
highlight="false"
lowUpperBound="35"
highLowerBound="70" />
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false" />
<log type="junit" target="build/logs/junit.xml" />
</logging>
<listeners>
<listener class="Mockery\Adapter\Phpunit\TestListener"
Expand Down
5 changes: 5 additions & 0 deletions rector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
parameters:
autoload_paths:
- 'vendor/autoload.php'
- 'stubs/'
php_version_features: '7.2' # your version is 7.3
5 changes: 1 addition & 4 deletions src/phpDocumentor/Reflection/Exception.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/**
Expand All @@ -7,8 +8,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2018 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/

Expand All @@ -17,8 +16,6 @@
/**
* An exception specifically originating from the Reflection component.
*
* @author Mike van Riel <mike.vanriel@naenius.com>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
class Exception extends \Exception
Expand Down
20 changes: 11 additions & 9 deletions src/phpDocumentor/Reflection/File/LocalFile.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/**
Expand All @@ -7,14 +8,17 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2018 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/

namespace phpDocumentor\Reflection\File;

use InvalidArgumentException;
use phpDocumentor\Reflection\File;
use function file_exists;
use function file_get_contents;
use function md5_file;
use function sprintf;

/**
* Represents a local file on the file system.
Expand All @@ -23,17 +27,15 @@ final class LocalFile implements File
{
/**
* Path to the file.
*
* @var string
*/
private $path;

/**
* LocalFile constructor.
*/
public function __construct(string $path)
{
if (!file_exists($path)) {
throw new \InvalidArgumentException(sprintf('File "%s" does not exist', $path));
throw new InvalidArgumentException(sprintf('File "%s" does not exist', $path));
}

$this->path = $path;
Expand All @@ -42,23 +44,23 @@ public function __construct(string $path)
/**
* Returns the content of the file as a string.
*/
public function getContents(): string
public function getContents() : string
{
return (string) file_get_contents($this->path);
}

/**
* Returns md5 hash of the file.
*/
public function md5(): string
public function md5() : string
{
return md5_file($this->path);
}

/**
* Returns an relative path to the file.
*/
public function path(): string
public function path() : string
{
return $this->path;
}
Expand Down
12 changes: 8 additions & 4 deletions src/phpDocumentor/Reflection/Middleware/ChainFactory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/**
Expand All @@ -7,21 +8,24 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/

namespace phpDocumentor\Reflection\Middleware;

use InvalidArgumentException;
use function array_pop;
use function get_class;
use function gettype;
use function is_object;
use function sprintf;

final class ChainFactory
{
/**
* @param Middleware[] $middlewareList
*/
public static function createExecutionChain(array $middlewareList, callable $lastCallable): callable
public static function createExecutionChain(array $middlewareList, callable $lastCallable) : callable
{
while ($middleware = array_pop($middlewareList)) {
if (!$middleware instanceof Middleware) {
Expand All @@ -34,7 +38,7 @@ public static function createExecutionChain(array $middlewareList, callable $las
);
}

$lastCallable = function ($command) use ($middleware, $lastCallable) {
$lastCallable = static function ($command) use ($middleware, $lastCallable) {
return $middleware->execute($command, $lastCallable);
};
}
Expand Down
3 changes: 1 addition & 2 deletions src/phpDocumentor/Reflection/Middleware/Command.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/**
Expand All @@ -7,8 +8,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2018 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/

Expand Down
7 changes: 2 additions & 5 deletions src/phpDocumentor/Reflection/Middleware/Middleware.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/**
Expand All @@ -7,8 +8,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2018 Mike van Riel<mike@phpdoc.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/

Expand All @@ -21,8 +20,6 @@ interface Middleware
{
/**
* Executes this middle ware class.
*
* @return object
*/
public function execute(Command $command, callable $next);
public function execute(Command $command, callable $next) : object;
}
Loading