Skip to content

Commit

Permalink
Merge pull request #705 from ergebnis/feature/synchronize
Browse files Browse the repository at this point in the history
Enhancement: Synchronize with `ergebnis/php-package-template`
  • Loading branch information
localheinz authored Jun 28, 2023
2 parents c9815dc + d09aff5 commit ee0a1f7
Show file tree
Hide file tree
Showing 21 changed files with 129 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The following versions of `ergebnis/classy` have active support:

The following versions of `ergebnis/classy` have reached their end of life:

- `<=1.3.0`
- `<1.4.0`

## Reporting a Vulnerability

Expand Down
1 change: 1 addition & 0 deletions .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ repository:
has_pages: false
has_projects: false
has_wiki: false
is_template: false
name: "classy"
private: false

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ jobs:
uses: "shivammathur/setup-php@2.25.4"
with:
coverage: "none"
extensions: "none, ctype, curl, dom, intl, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
extensions: "none, ctype, curl, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
php-version: "${{ matrix.php-version }}"

- name: "Set up problem matchers for PHP"
Expand Down Expand Up @@ -323,7 +323,7 @@ jobs:
uses: "shivammathur/setup-php@2.25.4"
with:
coverage: "none"
extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
extensions: "none, ctype, curl, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
php-version: "${{ matrix.php-version }}"

- name: "Set up problem matchers for PHP"
Expand Down
2 changes: 1 addition & 1 deletion .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="composer-require-checker" version="^4.4.0" installed="4.4.0" location="./.phive/composer-require-checker" copy="false"/>
<phar name="composer-require-checker" version="^4.6.0" installed="4.6.0" location="./.phive/composer-require-checker" copy="false"/>
</phive>
3 changes: 1 addition & 2 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
'test/Fixture/',
])
->ignoreDotFiles(false)
->in(__DIR__)
->name('.php-cs-fixer.php');
->in(__DIR__);

$config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/.php-cs-fixer.cache');

Expand Down
4 changes: 1 addition & 3 deletions composer-require-checker.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"symbol-whitelist": [
"T_ENUM"
]
"symbol-whitelist": []
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"ergebnis/composer-normalize": "^2.31.0",
"ergebnis/license": "^2.1.0",
"ergebnis/php-cs-fixer-config": "^5.9.2",
"ergebnis/phpunit-slow-test-detector": "^2.3.0",
"fakerphp/faker": "^1.23.0",
"infection/infection": "~0.27.0",
"phpunit/phpunit": "^10.2.2",
Expand Down
70 changes: 69 additions & 1 deletion composer.lock

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

7 changes: 7 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
}]]></code>
</TooManyArguments>
</file>
<file src="test/Unit/ConstructsTest.php">
<PossiblyUnusedMethod>
<code>provideScenarioWithClassyConstructsBeforePhp81</code>
<code>provideScenarioWithClassyConstructsOnPhp81</code>
<code>provideScenarioWithoutClassyConstructs</code>
</PossiblyUnusedMethod>
</file>
<file src="test/Util/PhpVersion.php">
<PossiblyUnusedMethod>
<code>toInt</code>
Expand Down
7 changes: 6 additions & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Rector\Config;
use Rector\Core;
use Rector\Php81;
use Rector\PHPUnit;

return static function (Config\RectorConfig $rectorConfig): void {
Expand All @@ -27,7 +28,11 @@

$rectorConfig->phpVersion(Core\ValueObject\PhpVersion::PHP_81);

$rectorConfig->rules([
Php81\Rector\Property\ReadOnlyPropertyRector::class,
]);

$rectorConfig->sets([
PHPUnit\Set\PHPUnitSetList::PHPUNIT_91,
PHPUnit\Set\PHPUnitSetList::PHPUNIT_100,
]);
};
5 changes: 1 addition & 4 deletions src/Construct.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@
*/
final class Construct
{
private string $name;

/**
* @var array<int, string>
*/
private array $fileNames = [];

private function __construct(string $name)
private function __construct(private readonly string $name)
{
$this->name = $name;
}

/**
Expand Down
7 changes: 5 additions & 2 deletions src/Constructs.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,11 @@ public static function fromDirectory(string $directory): array
*
* @param array<int, array{0: int, 1: string, 2: int}|string> $sequence
*/
private static function significantAfter(int $index, array $sequence, int $count): int
{
private static function significantAfter(
int $index,
array $sequence,
int $count,
): int {
for ($current = $index + 1; $current < $count; ++$current) {
$token = $sequence[$current];

Expand Down
6 changes: 1 addition & 5 deletions test/Unit/ConstructTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
use Ergebnis\Classy\Test;
use PHPUnit\Framework;

/**
* @internal
*
* @covers \Ergebnis\Classy\Construct
*/
#[Framework\Attributes\CoversClass(Construct::class)]
final class ConstructTest extends Framework\TestCase
{
use Test\Util\Helper;
Expand Down
37 changes: 11 additions & 26 deletions test/Unit/ConstructsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,11 @@
use Ergebnis\Classy\Test;
use PHPUnit\Framework;

/**
* @internal
*
* @covers \Ergebnis\Classy\Constructs
*
* @uses \Ergebnis\Classy\Construct
* @uses \Ergebnis\Classy\Exception\DirectoryDoesNotExist
* @uses \Ergebnis\Classy\Exception\MultipleDefinitionsFound
* @uses \Ergebnis\Classy\Exception\ParseError
*/
#[Framework\Attributes\CoversClass(Constructs::class)]
#[Framework\Attributes\UsesClass(Construct::class)]
#[Framework\Attributes\UsesClass(Exception\DirectoryDoesNotExist::class)]
#[Framework\Attributes\UsesClass(Exception\MultipleDefinitionsFound::class)]
#[Framework\Attributes\UsesClass(Exception\ParseError::class)]
final class ConstructsTest extends Framework\TestCase
{
private string $fileWithParseError = __DIR__ . '/../Fixture/ParseError/MessedUp.php';
Expand All @@ -52,9 +47,7 @@ public function testFromSourceThrowsParseErrorWhenParseErrorIsThrownDuringParsin
Constructs::fromSource($source);
}

/**
* @dataProvider provideScenarioWithoutClassyConstructs
*/
#[Framework\Attributes\DataProvider('provideScenarioWithoutClassyConstructs')]
public function testFromSourceReturnsEmptyArrayWhenNoClassyConstructsHaveBeenFound(Test\Util\Scenario $scenario): void
{
$constructs = Constructs::fromSource($scenario->source());
Expand Down Expand Up @@ -112,9 +105,7 @@ public static function provideScenarioWithoutClassyConstructs(): \Generator
}
}

/**
* @dataProvider provideScenarioWithClassyConstructsBeforePhp81
*/
#[Framework\Attributes\DataProvider('provideScenarioWithClassyConstructsBeforePhp81')]
public function testFromSourceReturnsArrayOfClassyConstructsWithoutFileNamesWhenClassyConstructsHaveBeenFoundBeforePhp81(Test\Util\Scenario $scenario): void
{
$constructs = Constructs::fromSource($scenario->source());
Expand All @@ -128,9 +119,8 @@ public function testFromSourceReturnsArrayOfClassyConstructsWithoutFileNamesWhen

/**
* @requires PHP 8.1
*
* @dataProvider provideScenarioWithClassyConstructsOnPhp81
*/
#[Framework\Attributes\DataProvider('provideScenarioWithClassyConstructsOnPhp81')]
public function testFromSourceReturnsArrayOfClassyConstructsWithoutFileNamesWhenClassyConstructsHaveBeenFoundOnPhp81(Test\Util\Scenario $scenario): void
{
$constructs = Constructs::fromSource($scenario->source());
Expand All @@ -156,19 +146,15 @@ public function testFromDirectoryThrowsParseErrorIfParseErrorIsThrownDuringParsi
Constructs::fromDirectory(__DIR__ . '/../Fixture/ParseError');
}

/**
* @dataProvider provideScenarioWithoutClassyConstructs
*/
#[Framework\Attributes\DataProvider('provideScenarioWithoutClassyConstructs')]
public function testFromDirectoryReturnsEmptyArrayWhenNoClassyConstructsHaveBeenFound(Test\Util\Scenario $scenario): void
{
$constructs = Constructs::fromDirectory($scenario->directory());

self::assertSame([], $constructs);
}

/**
* @dataProvider provideScenarioWithClassyConstructsBeforePhp81
*/
#[Framework\Attributes\DataProvider('provideScenarioWithClassyConstructsBeforePhp81')]
public function testFromDirectoryReturnsArrayOfClassyConstructsSortedByNameWhenClassyConstructsHaveBeenFoundBeforePhp81(Test\Util\Scenario $scenario): void
{
$constructs = Constructs::fromDirectory($scenario->directory());
Expand Down Expand Up @@ -196,9 +182,8 @@ public static function provideScenarioWithClassyConstructsBeforePhp81(): \Genera

/**
* @requires PHP 8.1
*
* @dataProvider provideScenarioWithClassyConstructsOnPhp81
*/
#[Framework\Attributes\DataProvider('provideScenarioWithClassyConstructsOnPhp81')]
public function testFromDirectoryReturnsArrayOfClassyConstructsSortedByNameWhenClassyConstructsHaveBeenFoundOnPhp81(Test\Util\Scenario $scenario): void
{
$constructs = Constructs::fromDirectory($scenario->directory());
Expand Down
6 changes: 1 addition & 5 deletions test/Unit/Exception/DirectoryDoesNotExistTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
use Ergebnis\Classy\Test;
use PHPUnit\Framework;

/**
* @internal
*
* @covers \Ergebnis\Classy\Exception\DirectoryDoesNotExist
*/
#[Framework\Attributes\CoversClass(Exception\DirectoryDoesNotExist::class)]
final class DirectoryDoesNotExistTest extends Framework\TestCase
{
use Test\Util\Helper;
Expand Down
9 changes: 2 additions & 7 deletions test/Unit/Exception/MultipleDefinitionsFoundTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@
use Ergebnis\Classy\Test;
use PHPUnit\Framework;

/**
* @internal
*
* @covers \Ergebnis\Classy\Exception\MultipleDefinitionsFound
*
* @uses \Ergebnis\Classy\Construct
*/
#[Framework\Attributes\CoversClass(Exception\MultipleDefinitionsFound::class)]
#[Framework\Attributes\UsesClass(Construct::class)]
final class MultipleDefinitionsFoundTest extends Framework\TestCase
{
use Test\Util\Helper;
Expand Down
6 changes: 1 addition & 5 deletions test/Unit/Exception/ParseErrorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
use Ergebnis\Classy\Test;
use PHPUnit\Framework;

/**
* @internal
*
* @covers \Ergebnis\Classy\Exception\ParseError
*/
#[Framework\Attributes\CoversClass(Exception\ParseError::class)]
final class ParseErrorTest extends Framework\TestCase
{
use Test\Util\Helper;
Expand Down
6 changes: 1 addition & 5 deletions test/Unit/Exception/ShouldNotHappenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
use Ergebnis\Classy\Exception;
use PHPUnit\Framework;

/**
* @internal
*
* @covers \Ergebnis\Classy\Exception\ShouldNotHappen
*/
#[Framework\Attributes\CoversClass(Exception\ShouldNotHappen::class)]
final class ShouldNotHappenTest extends Framework\TestCase
{
public function testCreateReturnsException(): void
Expand Down
10 changes: 10 additions & 0 deletions test/Unit/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,23 @@
cacheResult="true"
colors="true"
columns="max"
displayDetailsOnIncompleteTests="true"
displayDetailsOnSkippedTests="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
executionOrder="random"
requireCoverageMetadata="true"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
>
<coverage includeUncoveredFiles="true"/>
<extensions>
<bootstrap class="Ergebnis\PHPUnit\SlowTestDetector\Extension"/>
</extensions>
<source>
<include>
<directory suffix=".php">../../src/</directory>
Expand Down
Loading

0 comments on commit ee0a1f7

Please sign in to comment.