Skip to content
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
20 changes: 10 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ on: ['push', 'pull_request']

jobs:
testsuite:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.2', '8.3']
php-version: ['8.4', '8.5']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -22,14 +22,14 @@ jobs:

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Get date part for cache key
id: key-date
run: echo "::set-output name=date::$(date +'%Y-%m')"
run: echo "date=$(date +'%Y-%m')" >> "$GITHUB_OUTPUT"

- name: Cache composer dependencies
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}
Expand All @@ -39,12 +39,12 @@ jobs:

- name: Run tests
run: |
if [[ ${{ matrix.php-version }} == '8.1' ]]; then
export CODECOVERAGE=1 && vendor/bin/phpunit --verbose --coverage-clover=coverage.xml
if [[ ${{ matrix.php-version }} == '8.4' ]]; then
export CODECOVERAGE=1 && vendor/bin/phpunit --coverage-clover=coverage.xml
else
vendor/bin/phpunit
fi

- name: Submit code coverage
if: matrix.php-version == '8.1'
uses: codecov/codecov-action@v1
if: matrix.php-version == '8.4'
uses: codecov/codecov-action@v4
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

/.php-cs-fixer.cache
/.phpunit.result.cache
/.phpunit.cache

/tests/var/log/*.log
/tests/var/coverage
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
PHP?=php8.1
PHP?=php8.4
COMPOSER=/usr/local/bin/composer

php-info:
@echo "Default PHP version: $(PHP) (Run with custom PHP version: make install PHP=php8.2).\n";
@echo "Default PHP version: $(PHP) (Run with custom PHP version: make install PHP=php8.5).\n";

list: php-info ## List
@sed -rn 's/^([a-zA-Z_-]+):.*?## (.*)$$/"\1" "\2"/p' < $(MAKEFILE_LIST) | xargs printf "%-20s%s\n"

install: php-info ## Install dependencies (make install PHP=php8.0)
install: php-info ## Install dependencies (make install PHP=php8.5)
@if [ ! -d "vendor" ]; then $(PHP) $(COMPOSER) install; fi;

install-force: php-info ## Force install dependencies (make install PHP=php8.0)
install-force: php-info ## Force install dependencies (make install PHP=php8.5)
$(PHP) $(COMPOSER) install

update: php-info ## Update dependencies
@$(PHP) $(COMPOSER) update

test: php-info install ## Run PHPUnit tests
$(PHP) vendor/bin/phpunit --configuration=phpunit.xml.dist --verbose
$(PHP) vendor/bin/phpunit --configuration=phpunit.xml.dist

test-coverage: php-info install ## Run PHPUnit tests with coverage report
$(PHP) vendor/bin/phpunit --configuration=phpunit.xml.dist --verbose --coverage-text --coverage-html=tests/var/coverage
$(PHP) vendor/bin/phpunit --configuration=phpunit.xml.dist --coverage-text --coverage-html=tests/var/coverage

mutation-test: php-info install ## Run Infection mutation tests
$(PHP) vendor/bin/infection --threads=4 --show-mutations -vvv
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Versions
| Version | Branch | Latest | Description | PHP version |
|---------|---------------|---------|---------------------------------------------------------|-------------|
| `1.0` | `release-1.0` | `1.0.0` | Current stable version. Partial used in PHP Censor 2.0+ | `>= 7.4` |
| `2.0` | `master` | - | Feature major version for PHP Censor 3.0 (WIP) | `>= 8.1` |
| `2.0` | `master` | - | Feature major version for PHP Censor 3.0 (WIP) | `>= 8.4` |

Installation
------------
Expand Down
25 changes: 11 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,27 @@
}
},
"require": {
"php": ">=8.1.0",
"php": ">=8.4.0",
"ext-json": "*",
"psr/container": "^1.1",
"symfony/mailer": "^5.4"
"psr/container": "^1.1 || ^2.0",
"symfony/mailer": "^7.4 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"friendsofphp/php-cs-fixer": "^3.4",
"infection/infection": "^0.25",
"vimeo/psalm": "^4.16",
"phpmd/phpmd": "^1.5",
"sebastian/phpcpd": "^6.0",
"phploc/phploc": "^7.0",
"php-parallel-lint/php-parallel-lint": "^1.3",
"rector/rector": "^1.0"
"phpunit/phpunit": "^13.0",
"friendsofphp/php-cs-fixer": "^3.90",
"infection/infection": "^0.35",
"vimeo/psalm": "^6.0 || ^7.0",
"phpmd/phpmd": "^3.0",
"php-parallel-lint/php-parallel-lint": "^1.4",
"rector/rector": "^2.2"
},
"extra": {
"platform": {
"php": "8.1.*"
"php": "8.4.*"
}
},
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true,
"infection/extension-installer": true
}
}
Expand Down
36 changes: 11 additions & 25 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
colors="true"
processIsolation="false"
stopOnFailure="false"
executionOrder="random"
resolveDependencies="true"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="PHP Censor Common Test Suite">
<directory suffix="Test.php">./tests/src</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/13.4/phpunit.xsd" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" executionOrder="random" resolveDependencies="true" bootstrap="vendor/autoload.php" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="PHP Censor Common Test Suite">
<directory suffix="Test.php">./tests/src</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
3 changes: 3 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<psalm
errorLevel="2"
resolveFromConfigFile="true"
findUnusedCode="false"
findUnusedBaselineEntry="false"
ensureOverrideAttribute="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
Expand Down
31 changes: 10 additions & 21 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,16 @@

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
//use Rector\Set\ValueObject\SetList;
use Rector\Php84\Rector\Param\ExplicitNullableParamTypeRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
return RectorConfig::configure()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

$rectorConfig->skip([]);

$rectorConfig->importNames();
$rectorConfig->importShortClasses(false);

// register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);

$rectorConfig->sets([
LevelSetList::UP_TO_PHP_81,
/* SetList::PHP_81,
SetList::CODE_QUALITY,
SetList::DEAD_CODE,*/
]);
};
])
->withImportNames(importShortClasses: false)
->withRules([
InlineConstructorDefaultToPropertyRector::class,
ExplicitNullableParamTypeRector::class,
])
->withPhpSets(php81: true);
4 changes: 2 additions & 2 deletions src/Email/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Email implements EmailInterface
public function addEmailTo(string $email, ?string $name = null): self
{
$this->emailsTo[] = $name
? "${name} <${email}>"
? "{$name} <{$email}>"
: $email;

return $this;
Expand Down Expand Up @@ -51,7 +51,7 @@ public function setIsHtml(bool $isHtml = false): self
public function addCarbonCopyEmail(string $email, ?string $name = null): self
{
$this->carbonCopyEmails[] = $name
? "${name} <${email}>"
? "{$name} <{$email}>"
: $email;

return $this;
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/PathResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function resolveIgnores(array $pluginIgnores, bool $onlyInBuildPath = tru
if ($pluginIgnores) {
$ignores = \array_merge(
$ignores,
\array_filter($pluginIgnores, fn($item) => !empty($item))
\array_filter($pluginIgnores, fn ($item) => !empty($item))
);
}

Expand Down Expand Up @@ -219,7 +219,7 @@ private function getBuildIgnores(): array
if ($buildSettingsIgnores) {
$this->buildIgnores = \array_filter(
$buildSettingsIgnores,
fn(string $item) => !empty($item)
fn (string $item) => !empty($item)
);
}
}
Expand Down
14 changes: 7 additions & 7 deletions tests/src/Plugin/PathResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@
use PHPCensor\Common\Plugin\PathResolver;
use PHPCensor\Common\Plugin\PathResolverInterface;
use PHPCensor\Common\VariableInterpolatorInterface;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Stub;
use PHPUnit\Framework\TestCase;

class PathResolverTest extends TestCase
{
/**
* @var BuildInterface|MockObject
* @var BuildInterface|Stub
*/
private $build;

/**
* @var BuildLoggerInterface|MockObject
* @var BuildLoggerInterface|Stub
*/
private $buildLogger;

/**
* @var MockObject|VariableInterpolatorInterface
* @var Stub|VariableInterpolatorInterface
*/
private $variableInterpolator;

Expand Down Expand Up @@ -54,14 +54,14 @@ public function setUp(): void
'/\\'
) . '/';

$this->build = $this->createMock(BuildInterface::class);
$this->build = $this->createStub(BuildInterface::class);
$this->build
->method('getBuildPath')
->willReturn($this->buildPath);

$this->buildLogger = $this->createMock(BuildLoggerInterface::class);
$this->buildLogger = $this->createStub(BuildLoggerInterface::class);

$this->variableInterpolator = $this->createMock(VariableInterpolatorInterface::class);
$this->variableInterpolator = $this->createStub(VariableInterpolatorInterface::class);
$this->variableInterpolator
->method('interpolate')
->willReturnArgument(0);
Expand Down
Loading
Loading