Skip to content

Commit 312973a

Browse files
Merge pull request #17 from dayspring-tech/jrw-symfony_6
Compatibility with Symfony 6.0
2 parents 6d4cc3c + 8b2adf2 commit 312973a

File tree

94 files changed

+969
-945
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+969
-945
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,34 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
php:
14-
- '7.4'
1514
- '8.0'
1615
- '8.1'
1716
- '8.2'
18-
composer:
19-
- ''
20-
- '--prefer-lowest'
17+
- '8.3'
18+
- '8.4'
19+
symfony_version:
20+
- '5.4.*'
21+
- '6.0.*'
22+
- '6.1.*'
23+
- '6.2.*'
24+
- '6.3.*'
25+
- '6.4.*'
26+
exclude:
27+
# symfony 6.1+ requires PHP 8.1+
28+
- php: '8.0'
29+
symfony_version: '6.1.*'
30+
- php: '8.0'
31+
symfony_version: '6.2.*'
32+
- php: '8.0'
33+
symfony_version: '6.3.*'
34+
- php: '8.0'
35+
symfony_version: '6.4.*'
36+
# deps:
37+
# - 'highest'
38+
# - 'lowest'
2139

2240
steps:
23-
- uses: actions/checkout@v3
41+
- uses: actions/checkout@v4
2442

2543
- name: Use PHP
2644
uses: shivammathur/setup-php@v2
@@ -38,22 +56,27 @@ jobs:
3856

3957
- name: cache dependencies
4058
id: angular-dependencies
41-
uses: actions/cache@v3
59+
uses: actions/cache@v4
4260
with:
4361
path: ${{ steps.composer-cache.outputs.dir }}
4462
key: ${{ runner.os }}-${{ matrix.php }}-${{ matrix.composer }}-composer-${{ hashFiles('**/composer.lock') }}
4563
restore-keys: |
4664
${{ runner.os }}-${{ matrix.php }}-${{ matrix.composer }}-composer-
4765

66+
- name: Set Symfony minor version
67+
run: |
68+
sed -i 's|\("symfony/.*"\): ".*"|\1: "${{ matrix.symfony_version }}"|' composer.json
69+
working-directory: ./
70+
4871
- name: Validate composer.json and composer.lock
4972
run: composer validate
5073
working-directory: ./
5174

5275
- name: Install dependencies
53-
env:
54-
COMPOSER_FLAGS: ${{ matrix.composer }}
55-
run: composer update ${COMPOSER_FLAGS} --prefer-source
56-
working-directory: ./
76+
uses: ramsey/composer-install@v3
77+
with:
78+
# dependency-versions: '${{ matrix.deps }}'
79+
working-directory: ./
5780

5881
- name: Run Tests
5982
run: composer run-script ci-test

.github/workflows/qodana.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Qodana
2+
on:
3+
push:
4+
5+
jobs:
6+
qodana:
7+
runs-on: ubuntu-latest
8+
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
php:
13+
- '8.1'
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Use PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ matrix.php }}
24+
extensions: sqlite3, zip
25+
coverage: xdebug
26+
tools: composer:v2
27+
28+
- name: Get Composer Cache Directory
29+
id: composer-cache
30+
run: |
31+
echo "::set-output name=dir::$(composer config cache-dir)"
32+
working-directory: ./
33+
34+
- name: cache dependencies
35+
id: cache-dependencies
36+
uses: actions/cache@v3
37+
with:
38+
path: ${{ steps.composer-cache.outputs.dir }}
39+
key: ${{ runner.os }}-${{ matrix.php }}-${{ matrix.composer }}-composer-${{ hashFiles('**/composer.lock') }}
40+
restore-keys: |
41+
${{ runner.os }}-${{ matrix.php }}-${{ matrix.composer }}-composer-
42+
43+
- name: Validate composer.json and composer.lock
44+
run: composer validate
45+
working-directory: ./
46+
47+
- name: Install dependencies
48+
env:
49+
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
50+
COMPOSER_FLAGS: ${{ matrix.composer }}
51+
run: composer update ${COMPOSER_FLAGS} --prefer-source
52+
working-directory: ./
53+
54+
- name: 'Qodana Scan'
55+
uses: JetBrains/qodana-action@v2024.1
56+
with:
57+
args: --baseline,qodana.sarif.json
58+
env:
59+
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ Model/*/om
33
vendor
44
composer.lock
55
composer.phar
6+
7+
.phpunit.result.cache

.idea/.gitignore

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Command/AbstractCommand.php

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ abstract class AbstractCommand extends Command
3333
* Additional Phing args to add in specialized commands.
3434
* @var array
3535
*/
36-
protected $additionalPhingArgs = array();
36+
protected $additionalPhingArgs = [];
3737

3838
/**
3939
* Temporary XML schemas used on command execution.
4040
* @var array
4141
*/
42-
protected $tempSchemas = array();
42+
protected $tempSchemas = [];
4343

4444
/**
4545
* @var string
@@ -74,12 +74,8 @@ abstract class AbstractCommand extends Command
7474
*/
7575
protected $output;
7676

77-
private ContainerInterface $container;
78-
79-
public function __construct(ContainerInterface $container, $name = null)
77+
public function __construct(private ContainerInterface $container, $name = null)
8078
{
81-
$this->container = $container;
82-
8379
parent::__construct($name);
8480
}
8581

@@ -153,7 +149,7 @@ protected function initialize(InputInterface $input, OutputInterface $output)
153149

154150
if ($input->hasArgument('bundle') && $input->getArgument('bundle')) {
155151
$bundleName = $input->getArgument('bundle');
156-
if (0 === strpos($bundleName, '@')) {
152+
if (str_starts_with($bundleName, '@')) {
157153
$bundleName = substr($bundleName, 1);
158154
}
159155

@@ -167,7 +163,7 @@ protected function initialize(InputInterface $input, OutputInterface $output)
167163
* @param string $taskName A Propel task name.
168164
* @param array $properties An array of properties to pass to Phing.
169165
*/
170-
protected function callPhing($taskName, $properties = array())
166+
protected function callPhing($taskName, $properties = [])
171167
{
172168
$kernel = $this->getApplication()->getKernel();
173169

@@ -197,7 +193,7 @@ protected function callPhing($taskName, $properties = array())
197193

198194
// Add any arbitrary arguments last
199195
foreach ($this->additionalPhingArgs as $arg) {
200-
if (in_array($arg, array('verbose', 'debug'))) {
196+
if (in_array($arg, ['verbose', 'debug'])) {
201197
$bufferPhingOutput = false;
202198
}
203199

@@ -229,7 +225,7 @@ protected function callPhing($taskName, $properties = array())
229225
strstr($this->buffer, 'failed for the following reason:')) {
230226
$returnStatus = false;
231227
}
232-
} catch (\Exception $e) {
228+
} catch (\Exception) {
233229
$returnStatus = false;
234230
}
235231

@@ -254,7 +250,7 @@ protected function copySchemas(KernelInterface $kernel, $cacheDir)
254250
/** @var array<string, array{?BundleInterface, \SplFileInfo}> $finalSchemas */
255251
$finalSchemas = $this->getFinalSchemas($kernel, $this->bundle);
256252
foreach ($finalSchemas as $schema) {
257-
list($bundle, $finalSchema) = $schema;
253+
[$bundle, $finalSchema] = $schema;
258254

259255
if ($bundle) {
260256
$file = $cacheDir.DIRECTORY_SEPARATOR.'bundle-'.$bundle->getName().'-'.$finalSchema->getBaseName();
@@ -383,7 +379,7 @@ protected function createBuildTimeFile($file)
383379
<datasources default="%default_connection%">
384380

385381
EOT
386-
, array('%default_connection%' => $container->getParameter('propel.dbal.default_connection')));
382+
, ['%default_connection%' => $container->getParameter('propel.dbal.default_connection')]);
387383

388384
$propelConfiguration = $container->get('propel.configuration');
389385
foreach ($propelConfiguration['datasources'] as $name => $datasource) {
@@ -403,14 +399,14 @@ protected function createBuildTimeFile($file)
403399
</datasource>
404400

405401
EOT
406-
, array(
402+
, [
407403
'%name%' => $name,
408404
'%adapter%' => $datasource['adapter'],
409405
'%classname%'=> $datasource['connection']['classname'],
410406
'%dsn%' => $datasource['connection']['dsn'],
411407
'%username%' => $datasource['connection']['user'],
412-
'%password%' => isset($datasource['connection']['password']) ? $datasource['connection']['password'] : '',
413-
));
408+
'%password%' => $datasource['connection']['password'] ?? '',
409+
]);
414410
}
415411

416412
$xml .= <<<EOT
@@ -430,7 +426,7 @@ protected function createBuildTimeFile($file)
430426
*/
431427
protected function getProperties($file)
432428
{
433-
$properties = array();
429+
$properties = [];
434430

435431
if (false === $lines = @file($file)) {
436432
throw new \Exception(sprintf('Unable to parse contents of "%s".', $file));
@@ -439,7 +435,7 @@ protected function getProperties($file)
439435
foreach ($lines as $line) {
440436
$line = trim($line);
441437

442-
if ('' == $line || in_array($line[0], array('#', ';'))) {
438+
if ('' == $line || in_array($line[0], ['#', ';'])) {
443439
continue;
444440
}
445441

@@ -538,7 +534,7 @@ protected function getConnection(InputInterface $input, OutputInterface $output)
538534
$defaultConfig['connection']['password'] = null;
539535
}
540536

541-
return array($name, $defaultConfig);
537+
return [$name, $defaultConfig];
542538
}
543539

544540
/**
@@ -551,12 +547,8 @@ protected function parseDbName($dsn)
551547
{
552548
preg_match('#dbname=([a-zA-Z0-9\_]+)#', $dsn, $matches);
553549

554-
if (isset($matches[1])) {
555-
return $matches[1];
556-
}
557-
558550
// e.g. SQLite
559-
return null;
551+
return $matches[1] ?? null;
560552
}
561553

562554
/**
@@ -580,7 +572,7 @@ protected function checkConfiguration()
580572
protected function writeSummary(OutputInterface $output, $taskname)
581573
{
582574
foreach (explode("\n", $this->buffer) as $line) {
583-
if (false !== strpos($line, '[' . $taskname . ']')) {
575+
if (str_contains($line, '[' . $taskname . ']')) {
584576
$arr = preg_split('#\[' . $taskname . '\] #', $line);
585577
$info = $arr[1];
586578

@@ -603,11 +595,11 @@ protected function writeSummary(OutputInterface $output, $taskname)
603595
*/
604596
protected function writeSection(OutputInterface $output, $text, $style = 'bg=blue;fg=white')
605597
{
606-
$output->writeln(array(
598+
$output->writeln([
607599
'',
608600
$this->getHelperSet()->get('formatter')->formatBlock($text, $style, true),
609601
'',
610-
));
602+
]);
611603
}
612604

613605
/**
@@ -621,11 +613,11 @@ protected function writeTaskError($output, $taskName, $more = true)
621613
{
622614
$moreText = $more ? ' To get more details, run the command with the "--verbose" option.' : '';
623615

624-
return $this->writeSection($output, array(
616+
return $this->writeSection($output, [
625617
'[Propel] Error',
626618
'',
627619
'An error has occured during the "' . $taskName . '" task process.' . $moreText
628-
), 'fg=white;bg=red');
620+
], 'fg=white;bg=red');
629621
}
630622

631623
/**
@@ -680,10 +672,10 @@ protected function transformToLogicalName(\SplFileInfo $schema, BundleInterface
680672
*/
681673
private function getPhingArguments(KernelInterface $kernel, $workingDirectory, $properties)
682674
{
683-
$args = array();
675+
$args = [];
684676

685677
// Default properties
686-
$properties = array_merge(array(
678+
$properties = array_merge([
687679
'propel.database' => 'mysql',
688680
'project.dir' => $workingDirectory,
689681
'propel.output.dir' => $kernel->getProjectDir().'/app/propel',
@@ -696,7 +688,7 @@ private function getPhingArguments(KernelInterface $kernel, $workingDirectory, $
696688
'propel.addClassLevelComment' => false,
697689
'propel.defaultTimeStampFormat' => '',
698690
'propel.builder.pluralizer.class' => 'builder.util.StandardEnglishPluralizer',
699-
), $properties);
691+
], $properties);
700692

701693
// Adding user defined properties from the configuration
702694
$properties = array_merge(

0 commit comments

Comments
 (0)