Skip to content
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
4 changes: 4 additions & 0 deletions .github/workflows/build-and-publish-ci-image.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Build Docker CI image

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
branches:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/build-and-publish-franken-image.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Build Docker FrankenPHP image

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
tags:
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: "Coding standards"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
pull_request:
paths:
Expand Down Expand Up @@ -28,6 +32,9 @@ jobs:
matrix:
php-version:
- "8.2"
- "8.3"
- "8.4"
- "8.5"

steps:
- name: "Checkout code"
Expand All @@ -41,7 +48,7 @@ jobs:
tools: cs2pr

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"

- name: "Run a Code style analysis with friendsofphp/php-cs-fixer"
run: "vendor/bin/php-cs-fixer fix --format=checkstyle --allow-risky=yes --dry-run | cs2pr"
38 changes: 31 additions & 7 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: "Continuous Integration"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
pull_request:
paths:
Expand Down Expand Up @@ -29,10 +33,10 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
- "8.5"
postgres-version:
- "16"
extension:
Expand Down Expand Up @@ -64,6 +68,7 @@ jobs:
with:
php-version: "${{ matrix.php-version }}"
extensions: "pgsql pdo_pgsql"
cache: composer
ini-values: "zend.assertions=1"

- name: "Install dependencies with Composer"
Expand Down Expand Up @@ -95,7 +100,10 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
- "8.5"
postgres-version:
- "10"
- "15"
Expand Down Expand Up @@ -158,15 +166,27 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
- "8.5"
mariadb-version:
- "10.11.6" # LTS (Feb 2028)
- "11.4.5" # LTS (May 2029)
- "11.7.2" # STS
extension:
- "mysqli"
include:
- php-version: "8.1"
- php-version: "8.2"
mariadb-version: "11.4.5"
extension: "pdo_mysql"
- php-version: "8.3"
mariadb-version: "11.4.5"
extension: "pdo_mysql"
- php-version: "8.4"
mariadb-version: "11.4.5"
extension: "pdo_mysql"
- php-version: "8.5"
mariadb-version: "11.4.5"
extension: "pdo_mysql"

Expand Down Expand Up @@ -224,7 +244,10 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
- "8.5"
mysql-version:
- "5.7"
- "8.0"
Expand Down Expand Up @@ -289,7 +312,7 @@ jobs:
# strategy:
# matrix:
# php-version:
# - "8.1"
# - "8.2"
# mssql-version:
# - "2019"
# - "2022"
Expand Down Expand Up @@ -354,7 +377,7 @@ jobs:
os:
- "ubuntu-22.04"
php-version:
- "8.1"
- "8.2"
extension:
- "pdo_sqlite"
- "sqlite3"
Expand All @@ -375,6 +398,7 @@ jobs:
- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v3"
with:
dependency-versions: 'locked'
composer-options: "--ignore-platform-req=php+"

- name: "Run PHPUnit"
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/docs-build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Documentation build

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
pull_request:
paths:
Expand All @@ -19,9 +23,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js 18.12
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.12
cache: 'npm'
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: "Static Analysis"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
pull_request:
paths:
Expand All @@ -20,13 +24,16 @@ on:

jobs:
phpstan:
name: "Static Analysis"
name: "Static Analysis (PHP ${{ matrix.php-version }})"
runs-on: "ubuntu-22.04"

strategy:
matrix:
php-version:
- "8.2"
- "8.3"
- "8.4"
- "8.5"

steps:
- name: Checkout code
Expand All @@ -40,7 +47,7 @@ jobs:
tools: cs2pr

- name: Install dependencies with Composer
uses: ramsey/composer-install@v2
uses: ramsey/composer-install@v3

- name: Run static analysis with phpstan/phpstan
run: vendor/bin/phpstan --error-format=checkstyle | cs2pr
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
"doctrine/doctrine-bundle": "^2.10.0",
"doctrine/orm": "^2.15|^3.0",
"friendsofphp/php-cs-fixer": "^3.34",
"larastan/larastan": "^3.0",
"laravel/framework": "^10.0|^11.0",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan": "^2.1.33",
"phpunit/phpunit": "^10.4",
"symfony/dependency-injection": "^6.0|^7.0",
"symfony/framework-bundle": "^6.0|^7.0",
Expand Down
5 changes: 1 addition & 4 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ parameters:
paths:
- src
- tests
excludePaths:
- src/DependencyInjection/DbToolsConfiguration.php
checkMissingOverrideMethodAttribute: true
treatPhpDocTypesAsCertain: false
ignoreErrors:
- '#Instantiated class Seld\\PharUtils\\Timestamps not found.#'
- '#on an unknown class Seld\\PharUtils\\Timestamps.#'
1 change: 0 additions & 1 deletion src/Anonymization/Anonymizer/Core/DateAnonymizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ protected function validateOptions(): void
throw new \InvalidArgumentException("You must specify both 'min' and 'max' boundaries.");
}

// @phpstan-ignore-next-line False positive detected.
if ($min && $max) {
if ($max <= $min) {
throw new \InvalidArgumentException("'min' value must be less than 'max' value.");
Expand Down
5 changes: 2 additions & 3 deletions src/Anonymization/Config/Loader/AttributesLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function load(AnonymizationConfig $config): void
$metadatas = $metadataFactory->getAllMetadata();

foreach ($metadatas as $metadata) {
\assert($metadata instanceof ClassMetadata);
/** @var ClassMetadata $metadata */
if ($metadata->isMappedSuperclass || $metadata->isEmbeddedClass) {
continue;
}
Expand Down Expand Up @@ -87,7 +87,6 @@ public function load(AnonymizationConfig $config): void
$columnName = $metadata->getColumnName($fieldName);
if ($metadata->isInheritedField($fieldName)) {
$fieldMapping = $metadata->getFieldMapping($fieldName);
// @phpstan-ignore-next-line
if (\is_array($fieldMapping)) {
// Code for doctrine/orm:^2.0.
$ownerClass = $fieldMapping['inherited'];
Expand All @@ -96,7 +95,7 @@ public function load(AnonymizationConfig $config): void
$ownerClass = $fieldMapping->inherited;
}
$parentMetadata = $metadataFactory->getMetadataFor($ownerClass);
\assert($parentMetadata instanceof ClassMetadata);
/** @var ClassMetadata $parentMetadata */
$tableName = $parentMetadata->getTableName();
} else {
$tableName = $metadata->getTableName();
Expand Down
2 changes: 0 additions & 2 deletions src/Backupper/BackupperFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ public function create(?string $connectionName = null): AbstractBackupper
$this->configRegistry->getConnectionConfig($connectionName),
);

\assert($backupper instanceof AbstractBackupper);

if (isset($this->excludedTables[$connectionName])) {
$backupper->setExcludedTables($this->excludedTables[$connectionName]);
}
Expand Down
9 changes: 5 additions & 4 deletions src/Bridge/Standalone/PharCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Composer\Pcre\Preg;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Process\Process;
use Seld\PharUtils\Timestamps;

/**
* The Compiler class compiles composer into a phar.
Expand Down Expand Up @@ -157,9 +156,11 @@ public function compile(?string $pharFile = null): void
unset($phar);

// re-sign the phar with reproducible timestamp / signature
$util = new Timestamps($pharFile);
$util->updateTimestamps($this->versionDate);
$util->save($pharFile, \Phar::SHA512);
if (\class_exists('Seld\\PharUtils\\Timestamps')) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm dubious about this change, the code that is now within the if statement is not supposed to be optional, it's the whole goal of this method!

I think it should be a if (not ...) throw some exception instead. It will make PHPStan happy the same way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I add this, since seld/phar-utils was not declared implicit or transient dep in require-dev so the class was not found.

I modify now to add as require-dev dependency explicit. Fixed at e3bd809

$util = new \Seld\PharUtils\Timestamps($pharFile);
$util->updateTimestamps($this->versionDate);
$util->save($pharFile, \Phar::SHA512);
}
}

private function getRelativeFilePath(\SplFileInfo $file): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ public function getConfigTreeBuilder(): TreeBuilder
// For PHPStan.
\assert($rootNode instanceof ArrayNodeDefinition);

// @phpstan-ignore-next-line
$rootNode
->children()
->arrayNode('anonymization')
Expand All @@ -112,7 +111,6 @@ public function getConfigTreeBuilder(): TreeBuilder
$this->addConnectionConfigTreeBuilder($rootNode);

// Add "connections" children definition.
// @phpstan-ignore-next-line
$connectionsNode = $rootNode
->children()
->arrayNode('connections')
Expand All @@ -132,7 +130,6 @@ public function getConfigTreeBuilder(): TreeBuilder

if ($this->standalone) {
// Add extra options for standalone CLI app.
// @phpstan-ignore-next-line
$rootNode
->children()
->scalarNode('workdir')
Expand All @@ -149,7 +146,6 @@ public function getConfigTreeBuilder(): TreeBuilder

if ($this->withDeprecated) {
// Add deprecated options.
// @phpstan-ignore-next-line
$rootNode
->children()
->arrayNode('storage')
Expand Down Expand Up @@ -190,7 +186,6 @@ protected function addConnectionConfigTreeBuilder(ArrayNodeDefinition $node): vo
{
$intervalToInt = $this->getIntervalToInt();

// @phpstan-ignore-next-line
$node
->children()
->scalarNode('backup_binary')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function load(array $configs, ContainerBuilder $container): void
}

#[\Override]
public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface
public function getConfiguration(array $configs, ?ContainerBuilder $container = null): ConfigurationInterface
{
return new DbToolsConfiguration(true, false);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Helper/Iban.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private static function mod97(string $number): int
$parts = \str_split($number, 7);
$rest = 0;
foreach ($parts as $part) {
$rest = (int)($rest . $part) % 97;
$rest = \intval($rest . $part) % 97;
}
return (int)$rest;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Helper/LoremIpsum.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ private function punctuate(array $words): string
$commas = $this->gauss($mean, $std_dev);

for ($i = 1; $i <= $commas; $i++) {
$word = \round($i * $word_count / ($commas + 1));
$word = (int) \round($i * $word_count / ($commas + 1));

if ($word < ($word_count - 1) && $word > 0) {
$words[$word] .= ',';
Expand Down
2 changes: 0 additions & 2 deletions src/Restorer/RestorerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ public function create(?string $connectionName = null): AbstractRestorer
$this->configRegistry->getConnectionConfig($connectionName),
);

\assert($restorer instanceof AbstractRestorer);
Comment thread
pounard marked this conversation as resolved.

if ($this->logger) {
$restorer->setLogger($this->logger);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Storage/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function listBackups(
$age = $lastModified->diff(new \DateTimeImmutable(''));

if (!$onlyExpired || ($lastModified < $expirationDate)) {
if ($file !== $preserveFile) {
if ($preserveFile === null || $file->getFilename() !== $preserveFile) {
$list[] = [$age->format('%a days'), $file];
}
}
Expand Down
Loading
Loading