Skip to content

Commit cc35f21

Browse files
authored
Merge pull request #378 from greg0ire/maintenance-work
Maintenance work
2 parents 955077b + 673f347 commit cc35f21

25 files changed

+287
-5584
lines changed

.gitattributes

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
/Tests export-ignore
44
.doctrine-project.json export-ignore
55
.gitattributes export-ignore
6+
/.github export-ignore
67
.gitignore export-ignore
7-
.scrutinizer.yml export-ignore
8-
.travis.yml export-ignore
9-
composer.lock export-ignore
108
phpcs.xml.dist export-ignore
119
phpstan.neon export-ignore
1210
phpunit.xml.dist export-ignore
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
2+
name: "Continuous Integration"
3+
4+
on:
5+
pull_request:
6+
branches:
7+
- "*.x"
8+
- "master"
9+
push:
10+
branches:
11+
- "*.x"
12+
- "master"
13+
14+
env:
15+
fail-fast: true
16+
17+
jobs:
18+
phpunit:
19+
name: "PHPUnit"
20+
runs-on: "ubuntu-20.04"
21+
22+
strategy:
23+
matrix:
24+
php-version:
25+
- "7.1"
26+
- "7.2"
27+
- "7.3"
28+
- "7.4"
29+
deps:
30+
- "normal"
31+
include:
32+
- deps: "low"
33+
php-version: "7.1"
34+
35+
steps:
36+
- name: "Checkout"
37+
uses: "actions/checkout@v2"
38+
with:
39+
fetch-depth: 2
40+
41+
- name: "Install PHP with PCOV"
42+
uses: "shivammathur/setup-php@v2"
43+
if: "${{ matrix.php-version != '7.1' }}"
44+
with:
45+
php-version: "${{ matrix.php-version }}"
46+
coverage: "pcov"
47+
ini-values: "zend.assertions=1"
48+
49+
- name: "Install PHP with XDebug"
50+
uses: "shivammathur/setup-php@v2"
51+
if: "${{ matrix.php-version == '7.1' }}"
52+
with:
53+
php-version: "${{ matrix.php-version }}"
54+
coverage: "xdebug"
55+
ini-values: "zend.assertions=1"
56+
57+
- name: "Cache dependencies installed with composer"
58+
uses: "actions/cache@v2"
59+
with:
60+
path: "~/.composer/cache"
61+
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
62+
restore-keys: "php-${{ matrix.php-version }}-composer-locked-"
63+
64+
- name: "Install dependencies with composer"
65+
run: "composer update --no-interaction --prefer-dist"
66+
if: "${{ matrix.deps == 'normal' }}"
67+
68+
- name: "Install lowest possible dependencies with composer"
69+
run: "composer update --no-interaction --prefer-dist --prefer-lowest"
70+
if: "${{ matrix.deps == 'low' }}"
71+
72+
- name: "Run PHPUnit"
73+
run: "vendor/bin/phpunit --coverage-clover=coverage.xml"
74+
75+
- name: "Upload coverage file"
76+
uses: "actions/upload-artifact@v2"
77+
with:
78+
name: "phpunit-${{ matrix.deps }}-${{ matrix.php-version }}.coverage"
79+
path: "coverage.xml"
80+
81+
upload_coverage:
82+
name: "Upload coverage to Codecov"
83+
runs-on: "ubuntu-20.04"
84+
needs:
85+
- "phpunit"
86+
87+
steps:
88+
- name: "Checkout"
89+
uses: "actions/checkout@v2"
90+
with:
91+
fetch-depth: 2
92+
93+
- name: "Download coverage files"
94+
uses: "actions/download-artifact@v2"
95+
with:
96+
path: "reports"
97+
98+
- name: "Upload to Codecov"
99+
uses: "codecov/codecov-action@v1"
100+
with:
101+
directory: reports

.github/workflows/static-analysis.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
name: "Static Analysis"
3+
4+
on:
5+
pull_request:
6+
branches:
7+
- "*.x"
8+
- "master"
9+
push:
10+
branches:
11+
- "*.x"
12+
- "master"
13+
14+
jobs:
15+
static-analysis-phpstan:
16+
name: "Static Analysis with PHPStan"
17+
runs-on: "ubuntu-20.04"
18+
19+
strategy:
20+
matrix:
21+
php-version:
22+
- "7.4"
23+
24+
steps:
25+
- name: "Checkout code"
26+
uses: "actions/checkout@v2"
27+
28+
- name: "Install PHP"
29+
uses: "shivammathur/setup-php@v2"
30+
with:
31+
coverage: "none"
32+
php-version: "${{ matrix.php-version }}"
33+
tools: "cs2pr"
34+
35+
- name: "Cache dependencies installed with composer"
36+
uses: "actions/cache@v2"
37+
with:
38+
path: "~/.composer/cache"
39+
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
40+
restore-keys: "php-${{ matrix.php-version }}-composer-locked-"
41+
42+
- name: "Install dependencies with composer"
43+
run: "composer install --no-interaction --no-progress --no-suggest"
44+
45+
- name: "Run a static analysis with phpstan/phpstan"
46+
run: "vendor/bin/phpstan analyse --error-format=checkstyle | cs2pr"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/vendor/
2+
/composer.lock
23
/.phpcs-cache
4+
/.phpunit.result.cache
35

.travis.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

Command/DoctrineCommand.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
1313
use Symfony\Component\DependencyInjection\ContainerInterface;
1414
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
15+
1516
use function error_get_last;
1617
use function is_dir;
17-
use function method_exists;
1818
use function mkdir;
1919
use function preg_match;
2020
use function sprintf;
@@ -25,11 +25,11 @@
2525
*/
2626
abstract class DoctrineCommand extends BaseCommand
2727
{
28-
public static function configureMigrations(ContainerInterface $container, Configuration $configuration) : void
28+
public static function configureMigrations(ContainerInterface $container, Configuration $configuration): void
2929
{
3030
$dir = $configuration->getMigrationsDirectory();
3131

32-
if (empty($dir)) {
32+
if ($dir === null) {
3333
$dir = $container->getParameter('doctrine_migrations.dir_name');
3434

3535
if (! is_dir($dir) && ! @mkdir($dir, 0777, true) && ! is_dir($dir)) {
@@ -48,7 +48,7 @@ public static function configureMigrations(ContainerInterface $container, Config
4848
$pathPlaceholderArray = ['kernel.root_dir', 'kernel.cache_dir', 'kernel.logs_dir'];
4949

5050
foreach ($pathPlaceholderArray as $pathPlaceholder) {
51-
if (! $container->hasParameter($pathPlaceholder) || ! preg_match('/\%' . $pathPlaceholder . '\%/', $dir)) {
51+
if (! $container->hasParameter($pathPlaceholder) || preg_match('/\%' . $pathPlaceholder . '\%/', $dir) === 0) {
5252
continue;
5353
}
5454

@@ -68,16 +68,16 @@ public static function configureMigrations(ContainerInterface $container, Config
6868
$configuration->setMigrationsDirectory($dir);
6969
}
7070

71-
if (empty($configuration->getMigrationsNamespace())) {
71+
if ($configuration->getMigrationsNamespace() === null) {
7272
$configuration->setMigrationsNamespace($container->getParameter('doctrine_migrations.namespace'));
7373
}
7474

75-
if (empty($configuration->getName())) {
75+
if ($configuration->getName() === null) {
7676
$configuration->setName($container->getParameter('doctrine_migrations.name'));
7777
}
7878

7979
// For backward compatibility, need use a table from parameters for overwrite the default configuration
80-
if (! ($configuration instanceof AbstractFileConfiguration) || empty($configuration->getMigrationsTableName())) {
80+
if (! ($configuration instanceof AbstractFileConfiguration) || $configuration->getMigrationsTableName() === '') {
8181
$configuration->setMigrationsTableName($container->getParameter('doctrine_migrations.table_name'));
8282
}
8383

@@ -95,7 +95,7 @@ public static function configureMigrations(ContainerInterface $container, Config
9595
}
9696
}
9797

98-
if (method_exists($configuration, 'getCustomTemplate') && empty($configuration->getCustomTemplate())) {
98+
if ($configuration->getCustomTemplate() === null) {
9999
$configuration->setCustomTemplate($container->getParameter('doctrine_migrations.custom_template'));
100100
}
101101

@@ -125,7 +125,7 @@ public static function configureMigrations(ContainerInterface $container, Config
125125
*
126126
* Injects the container to migrations aware of it
127127
*/
128-
private static function injectContainerToMigrations(ContainerInterface $container, array $versions) : void
128+
private static function injectContainerToMigrations(ContainerInterface $container, array $versions): void
129129
{
130130
foreach ($versions as $version) {
131131
$migration = $version->getMigration();

Command/Helper/DoctrineCommandHelper.php

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
use LogicException;
1212
use Symfony\Bundle\FrameworkBundle\Console\Application;
1313
use Symfony\Component\Console\Input\InputInterface;
14-
use Symfony\Component\DependencyInjection\ContainerInterface;
14+
1515
use function assert;
1616
use function count;
17+
use function is_string;
1718
use function sprintf;
1819

1920
/**
@@ -22,13 +23,11 @@
2223
*/
2324
abstract class DoctrineCommandHelper extends BaseDoctrineCommandHelper
2425
{
25-
public static function setApplicationHelper(Application $application, InputInterface $input) : void
26+
public static function setApplicationHelper(Application $application, InputInterface $input): void
2627
{
2728
$container = $application->getKernel()->getContainer();
28-
assert($container instanceof ContainerInterface);
29-
30-
/** @var Registry $doctrine */
31-
$doctrine = $container->get('doctrine');
29+
$doctrine = $container->get('doctrine');
30+
assert($doctrine instanceof Registry);
3231

3332
$managerNames = $doctrine->getManagerNames();
3433

@@ -42,25 +41,34 @@ public static function setApplicationHelper(Application $application, InputInter
4241
return;
4342
}
4443

45-
/** @var ConnectionHelper $dbHelper */
4644
$dbHelper = $application->getHelperSet()->get('db');
45+
assert($dbHelper instanceof ConnectionHelper);
4746

4847
$connection = $dbHelper->getConnection();
4948

5049
if (! $connection instanceof PoolingShardConnection) {
5150
if (count($managerNames) === 0) {
51+
$db = $input->getOption('db');
52+
assert(is_string($db));
53+
5254
throw new LogicException(sprintf(
5355
"Connection '%s' must implement shards configuration.",
54-
$input->getOption('db')
56+
$db
5557
));
5658
}
5759

60+
$em = $input->getOption('em');
61+
assert(is_string($em));
62+
5863
throw new LogicException(sprintf(
5964
"Connection of EntityManager '%s' must implement shards configuration.",
60-
$input->getOption('em')
65+
$em
6166
));
6267
}
6368

64-
$connection->connect($input->getOption('shard'));
69+
$shard = $input->getOption('shard');
70+
assert(is_string($shard));
71+
72+
$connection->connect($shard);
6573
}
6674
}

Command/MigrationsDiffDoctrineCommand.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Symfony\Component\Console\Input\InputInterface;
1111
use Symfony\Component\Console\Input\InputOption;
1212
use Symfony\Component\Console\Output\OutputInterface;
13-
use Symfony\Component\DependencyInjection\ContainerInterface;
13+
1414
use function assert;
1515

1616
/**
@@ -22,7 +22,7 @@ class MigrationsDiffDoctrineCommand extends DiffCommand
2222
/** @var string */
2323
protected static $defaultName = 'doctrine:migrations:diff';
2424

25-
protected function configure() : void
25+
protected function configure(): void
2626
{
2727
parent::configure();
2828

@@ -32,22 +32,21 @@ protected function configure() : void
3232
->addOption('shard', null, InputOption::VALUE_REQUIRED, 'The shard connection to use for this command.');
3333
}
3434

35-
public function initialize(InputInterface $input, OutputInterface $output) : void
35+
public function initialize(InputInterface $input, OutputInterface $output): void
3636
{
37-
/** @var Application $application */
3837
$application = $this->getApplication();
38+
assert($application instanceof Application);
3939

4040
Helper\DoctrineCommandHelper::setApplicationHelper($application, $input);
4141

4242
$configuration = $this->getMigrationConfiguration($input, $output);
4343
$container = $application->getKernel()->getContainer();
44-
assert($container instanceof ContainerInterface);
4544
DoctrineCommand::configureMigrations($container, $configuration);
4645

4746
parent::initialize($input, $output);
4847
}
4948

50-
public function execute(InputInterface $input, OutputInterface $output) : ?int
49+
public function execute(InputInterface $input, OutputInterface $output): ?int
5150
{
5251
// EM and DB options cannot be set at same time
5352
if ($input->getOption('em') !== null && $input->getOption('db') !== null) {

0 commit comments

Comments
 (0)