Skip to content
Snippets Groups Projects
Commit bda23b23 authored by David Prévot's avatar David Prévot
Browse files

Merge tag '2.1.0' into upstream

parents 7c641eb2 6568f468
No related branches found
No related tags found
No related merge requests found
on:
push:
branches:
- master
pull_request:
name: Qa workflow
jobs:
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Restore/cache vendor folder
uses: actions/cache@v1
with:
path: vendor
key: all-build-${{ hashFiles('**/composer.lock') }}
restore-keys: |
all-build-${{ hashFiles('**/composer.lock') }}
all-build-
- name: Restore/cache tools folder
uses: actions/cache@v1
with:
path: tools
key: all-tools-${{ github.sha }}
restore-keys: |
all-tools-${{ github.sha }}-
all-tools-
- name: composer
uses: docker://composer
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: install --no-interaction --prefer-dist --optimize-autoloader
- name: Install phive
run: make install-phive
- name: Install PHAR dependencies
run: tools/phive.phar --no-progress install --copy --trust-gpg-keys 4AA394086372C20A,8A03EA3B385DBAA1 --force-accept-unsigned
phpunit-with-coverage:
runs-on: ubuntu-latest
name: Unit tests
needs: setup
steps:
- uses: actions/checkout@master
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.2
ini-values: memory_limit=2G, display_errors=On, error_reporting=-1
coverage: pcov
- name: Restore/cache tools folder
uses: actions/cache@v1
with:
path: tools
key: all-tools-${{ github.sha }}
restore-keys: |
all-tools-${{ github.sha }}-
all-tools-
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ubuntu-latest-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ubuntu-latest-composer-
- name: Install Composer dependencies
run: |
composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
- name: Run PHPUnit
run: php tools/phpunit
phpunit:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system:
- ubuntu-latest
- windows-latest
- macOS-latest
php-versions: ['7.2', '7.3', '7.4']
name: Unit tests for PHP version ${{ matrix.php-versions }} on ${{ matrix.operating-system }}
needs:
- setup
- phpunit-with-coverage
steps:
- uses: actions/checkout@master
- name: Restore/cache tools folder
uses: actions/cache@v1
with:
path: tools
key: all-tools-${{ github.sha }}
restore-keys: |
all-tools-${{ github.sha }}-
all-tools-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
ini-values: memory_limit=2G, display_errors=On, error_reporting=-1
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: |
composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
- name: Run PHPUnit
continue-on-error: true
run: php tools/phpunit
codestyle:
runs-on: ubuntu-latest
needs: [setup, phpunit]
steps:
- uses: actions/checkout@master
- name: Restore/cache vendor folder
uses: actions/cache@v1
with:
path: vendor
key: all-build-${{ hashFiles('**/composer.lock') }}
restore-keys: |
all-build-${{ hashFiles('**/composer.lock') }}
all-build-
- name: Code style check
uses: phpDocumentor/coding-standard@master
with:
args: -s
phpstan:
runs-on: ubuntu-latest
needs: [setup, phpunit]
steps:
- uses: actions/checkout@master
- name: Restore/cache vendor folder
uses: actions/cache@v1
with:
path: vendor
key: all-build-${{ hashFiles('**/composer.lock') }}
restore-keys: |
all-build-${{ hashFiles('**/composer.lock') }}
all-build-
- name: PHPStan
uses: phpDocumentor/phpstan-ga@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: analyse src --configuration phpstan.neon
psalm:
runs-on: ubuntu-latest
needs: [setup, phpunit]
steps:
- uses: actions/checkout@master
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.2
ini-values: memory_limit=2G, display_errors=On, error_reporting=-1
tools: psalm
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: |
composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
- name: Psalm
run: psalm --output-format=github
bc_check:
name: BC Check
runs-on: ubuntu-latest
needs: [setup, phpunit]
steps:
- uses: actions/checkout@master
- name: fetch tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Restore/cache vendor folder
uses: actions/cache@v1
with:
path: vendor
key: all-build-${{ hashFiles('**/composer.lock') }}
restore-keys: |
all-build-${{ hashFiles('**/composer.lock') }}
all-build-
- name: Roave BC Check
uses: docker://nyholm/roave-bc-check-ga
language: php
php: [ 7.1, 7.2, nightly ]
sudo: false
env:
php: [ 7.1, 7.2, 7.3, 7.4 ]
matrix:
fast_finish: true
allow_failures:
- php: nightly
install:
- travis_retry composer install --no-interaction --prefer-dist --optimize-autoloader
......@@ -30,7 +26,7 @@ jobs:
php: 7.1
before_script:
- travis_retry wget --no-verbose https://phar.io/releases/phive.phar
- travis_retry php phive.phar --no-progress install --trust-gpg-keys 8E730BA25823D8B5 phpstan
- travis_retry php phive.phar --no-progress install --trust-gpg-keys CF1A108D0E7AE720 phpstan
script:
- ./tools/phpstan analyse src --level max --configuration phpstan.neon
......
Makefile 0 → 100644
.PHONY: install-phive
install-phive:
mkdir tools; \
wget -O tools/phive.phar https://github.com/phar-io/phive/releases/download/0.13.2/phive-0.13.2.phar; \
wget -O tools/phive.phar.asc https://github.com/phar-io/phive/releases/download/0.13.2/phive-0.13.2.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 -s
.PHONY: phpcbf
phpcbf:
docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpcs-ga:latest phpcbf
.PHONY: phpstan
phpstan:
docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpstan-ga:latest analyse src --no-progress --configuration phpstan.neon
.PHONY: psalm
psalm:
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.2 tools/psalm --show-info=true
.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
......@@ -19,7 +19,6 @@
}
},
"require-dev": {
"phpunit/phpunit": "~6"
},
"extra": {
"branch-alias": {
......
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpunit" version="^6.5.5" installed="6.5.5" location="./tools/phpunit"/>
<phar name="phpstan" version="^0.9.1" installed="0.9.1" location="./tools/phpstan"/>
<phar name="phpunit" version="^8.4" installed="8.4.3" location="./tools/phpunit" copy="true"/>
<phar name="psalm" version="^3.7.2" installed="3.11.2" location="./tools/psalm" copy="true"/>
</phive>
<?xml version="1.0"?>
<ruleset name="phpDocumentor">
<description>The coding standard for phpDocumentor.</description>
<file>src</file>
<file>tests/unit</file>
<arg value="p"/>
<rule ref="phpDocumentor">
</rule>
</ruleset>
parameters:
level: max
<?xml version="1.0" encoding="utf-8"?>
<phpunit bootstrap="tests/common/bootstrap.php" colors="true">
<phpunit bootstrap="vendor/autoload.php" colors="true">
<testsuites>
<testsuite name="unit">
<directory>./tests/unit/</directory>
......
<?xml version="1.0"?>
<psalm
totallyTyped="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config file:///composer/vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
<?php
declare(strict_types=1);
/**
......@@ -7,8 +8,6 @@ declare(strict_types=1);
* 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
*/
......@@ -22,10 +21,10 @@ interface Element
/**
* Returns the Fqsen of the element.
*/
public function getFqsen(): Fqsen;
public function getFqsen() : Fqsen;
/**
* Returns the name of the element.
*/
public function getName(): string;
public function getName() : string;
}
<?php
declare(strict_types=1);
/**
......@@ -7,8 +8,6 @@ declare(strict_types=1);
* 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
*/
......@@ -22,15 +21,15 @@ interface File
/**
* Returns the content of the file as a string.
*/
public function getContents(): string;
public function getContents() : string;
/**
* Returns md5 hash of the file.
*/
public function md5(): string;
public function md5() : string;
/**
* Returns an relative path to the file.
*/
public function path(): string;
public function path() : string;
}
<?php
declare(strict_types=1);
/**
......@@ -7,30 +8,33 @@ declare(strict_types=1);
* 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;
use InvalidArgumentException;
use function assert;
use function end;
use function explode;
use function is_string;
use function preg_match;
use function sprintf;
use function trim;
/**
* Value Object for Fqsen.
*
* @link https://github.com/phpDocumentor/fig-standards/blob/master/proposed/phpdoc-meta.md
*
* @psalm-immutable
*/
final class Fqsen
{
/**
* @var string full quallified class name
*/
/** @var string full quallified class name */
private $fqsen;
/**
* @var string name of the element without path.
*/
/** @var string name of the element without path. */
private $name;
/**
......@@ -41,7 +45,9 @@ final class Fqsen
public function __construct(string $fqsen)
{
$matches = [];
$result = preg_match(
//phpcs:ignore Generic.Files.LineLength.TooLong
'/^\\\\([a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff\\\\]*)?(?:[:]{2}\\$?([a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*))?(?:\\(\\))?$/',
$fqsen,
$matches
......@@ -59,14 +65,16 @@ final class Fqsen
$this->name = $matches[2];
} else {
$matches = explode('\\', $fqsen);
$this->name = trim(end($matches), '()');
$name = end($matches);
assert(is_string($name));
$this->name = trim($name, '()');
}
}
/**
* converts this class to string.
*/
public function __toString(): string
public function __toString() : string
{
return $this->fqsen;
}
......@@ -74,7 +82,7 @@ final class Fqsen
/**
* Returns the name of the element without path.
*/
public function getName(): string
public function getName() : string
{
return $this->name;
}
......
<?php
declare(strict_types=1);
/**
......@@ -7,8 +8,6 @@ declare(strict_types=1);
* 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
*/
......@@ -16,6 +15,8 @@ namespace phpDocumentor\Reflection;
/**
* The location where an element occurs within a file.
*
* @psalm-immutable
*/
final class Location
{
......@@ -37,7 +38,7 @@ final class Location
/**
* Returns the line number that is covered by this location.
*/
public function getLineNumber(): int
public function getLineNumber() : int
{
return $this->lineNumber;
}
......@@ -45,7 +46,7 @@ final class Location
/**
* Returns the column number (character position on a line) for this location object.
*/
public function getColumnNumber(): int
public function getColumnNumber() : int
{
return $this->columnNumber;
}
......
<?php
declare(strict_types=1);
/**
......@@ -7,8 +8,6 @@ declare(strict_types=1);
* 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
*/
......@@ -22,5 +21,5 @@ interface Project
/**
* Returns the name of the project.
*/
public function getName(): string;
public function getName() : string;
}
<?php
declare(strict_types=1);
/**
......@@ -7,8 +8,6 @@ declare(strict_types=1);
* 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
*/
......@@ -23,9 +22,7 @@ interface ProjectFactory
/**
* Creates a project from the set of files.
*
* @param string $name
* @param File[] $files
* @return Project
*/
public function create($name, array $files): Project;
public function create(string $name, array $files) : Project;
}
<?php
declare(strict_types=1);
/**
* phpDocumentor
*
* 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;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
/**
* Class FqsenTest
* @coversDefaultClass phpDocumentor\Reflection\Fqsen
* @coversDefaultClass \phpDocumentor\Reflection\Fqsen
*/
class FqsenTest extends TestCase
{
/**
* @param string $fqsen
* @covers ::__construct
* @dataProvider validFqsenProvider
*/
public function testValidFormats($fqsen, $name)
public function testValidFormats(string $fqsen, string $name) : void
{
$instance = new Fqsen($fqsen);
$this->assertEquals($name, $instance->getName());
......@@ -34,9 +34,9 @@ class FqsenTest extends TestCase
/**
* Data provider for ValidFormats tests. Contains a complete list from psr-5 draft.
*
* @return array
* @return array<array<string>>
*/
public function validFqsenProvider()
public function validFqsenProvider() : array
{
return [
['\\', ''],
......@@ -55,22 +55,21 @@ class FqsenTest extends TestCase
}
/**
* @param string $fqsen
* @covers ::__construct
* @dataProvider invalidFqsenProvider
* @expectedException \InvalidArgumentException
*/
public function testInValidFormats($fqsen)
public function testInValidFormats(string $fqsen) : void
{
$this->expectException(InvalidArgumentException::class);
new Fqsen($fqsen);
}
/**
* Data provider for invalidFormats tests. Contains a complete list from psr-5 draft.
*
* @return array
* @return array<array<string>>
*/
public function invalidFqsenProvider()
public function invalidFqsenProvider() : array
{
return [
['\My\*'],
......@@ -84,7 +83,7 @@ class FqsenTest extends TestCase
* @covers ::__construct
* @covers ::__toString
*/
public function testToString()
public function testToString() : void
{
$className = new Fqsen('\\phpDocumentor\\Application');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment