Skip to content

Commit 90f6a87

Browse files
authored
Merge pull request #83 from alexpott/symfony-console-6-and-psr-log-3
Allow symfony console 6 and psr log 3
2 parents cd3912e + 51bf259 commit 90f6a87

16 files changed

+238
-24
lines changed

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
"require": {
3030
"php": ">=7.4",
3131
"ext-json": "*",
32-
"psr/log": "^1.1 || ^2.0",
33-
"symfony/console": "^4.4.15 || ^5.1",
32+
"psr/log": "^1.1 || ^2.0 || ^3.0",
33+
"symfony/console": "^4.4.15 || ^5.1 || ^6.0",
3434
"symfony/filesystem": "^4.4 || ^5.1 || ^6",
3535
"symfony/polyfill-php80": "^1.23",
3636
"symfony/string": "^5.1 || ^6",
@@ -39,12 +39,12 @@
3939
"require-dev": {
4040
"chi-teck/drupal-coder-extension": "^1.2",
4141
"drupal/coder": "^8.3.14",
42-
"friendsoftwig/twigcs": "^5.0",
42+
"friendsoftwig/twigcs": "dev-master",
4343
"phpspec/prophecy-phpunit": "^2.0",
4444
"phpunit/phpunit": "^9.4",
4545
"squizlabs/php_codesniffer": "^3.5",
46-
"symfony/var-dumper": "^5.2",
47-
"symfony/yaml": "^5.2"
46+
"symfony/var-dumper": "^5.2 || ^6.0",
47+
"symfony/yaml": "^5.2 || ^6.0"
4848
},
4949
"conflict": {
5050
"squizlabs/php_codesniffer": "<3.6"

phpcs.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
<!-- Conflicts with PHP attributes. -->
1111
<exclude name="Drupal.Commenting.InlineComment.DocBlock"/>
1212
<exclude name="Drupal.Commenting.FunctionComment.Missing"/>
13+
<!-- Conflicts with BC layer. -->
14+
<exclude name="Drupal.Commenting.FileComment.Missing"/>
1315
</rule>
1416
<rule ref="vendor/drupal/coder/coder_sniffer/DrupalPractice">
1517
<exclude name="Drupal.Commenting.VariableComment.Missing"/>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace DrupalCodeGenerator\Compatibility;
4+
5+
if (\PHP_VERSION_ID >= 80000) {
6+
\class_alias(
7+
'\DrupalCodeGenerator\Compatibility\Php8\AskQuestionTrait',
8+
'\DrupalCodeGenerator\Compatibility\AskQuestionTrait'
9+
);
10+
}
11+
else {
12+
\class_alias(
13+
'\DrupalCodeGenerator\Compatibility\Php7\AskQuestionTrait',
14+
'\DrupalCodeGenerator\Compatibility\AskQuestionTrait'
15+
);
16+
}

src/Compatibility/AskTrait.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php declare(strict_types=1);
2+
3+
/**
4+
* @file
5+
* Compatibility shim.
6+
*/
7+
8+
namespace DrupalCodeGenerator\Compatibility;
9+
10+
if (\PHP_VERSION_ID >= 80000) {
11+
\class_alias(
12+
'\DrupalCodeGenerator\Compatibility\Php8\AskTrait',
13+
'\DrupalCodeGenerator\Compatibility\AskTrait'
14+
);
15+
}
16+
else {
17+
\class_alias(
18+
'\DrupalCodeGenerator\Compatibility\Php7\AskTrait',
19+
'\DrupalCodeGenerator\Compatibility\AskTrait'
20+
);
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php declare(strict_types=1);
2+
3+
/**
4+
* @file
5+
* Compatibility shim.
6+
*/
7+
8+
namespace DrupalCodeGenerator\Compatibility;
9+
10+
if (\PHP_VERSION_ID >= 80000) {
11+
\class_alias(
12+
'\DrupalCodeGenerator\Compatibility\Php8\GeneratorStyleInterface',
13+
'\DrupalCodeGenerator\Compatibility\GeneratorStyleCompatibilityInterface'
14+
);
15+
}
16+
else {
17+
\class_alias(
18+
'\DrupalCodeGenerator\Compatibility\Php7\GeneratorStyleInterface',
19+
'\DrupalCodeGenerator\Compatibility\GeneratorStyleCompatibilityInterface'
20+
);
21+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace DrupalCodeGenerator\Compatibility\Php7;
4+
5+
use Symfony\Component\Console\Question\Question;
6+
7+
/**
8+
* PHP 7 compatibility.
9+
*/
10+
trait AskQuestionTrait {
11+
12+
/**
13+
* Asks a question.
14+
*
15+
* @return mixed
16+
* The answer.
17+
*/
18+
public function askQuestion(Question $question) {
19+
return $this->compatAskQuestion($question);
20+
}
21+
22+
/**
23+
* Asks a question.
24+
*
25+
* @return mixed
26+
* The answer.
27+
*/
28+
abstract protected function compatAskQuestion(Question $question);
29+
30+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace DrupalCodeGenerator\Compatibility\Php7;
4+
5+
use Symfony\Component\Console\Input\InputInterface;
6+
use Symfony\Component\Console\Output\OutputInterface;
7+
use Symfony\Component\Console\Question\Question;
8+
9+
/**
10+
* PHP 7 compatibility.
11+
*/
12+
trait AskTrait {
13+
14+
/**
15+
* Asks a question.
16+
*
17+
* @return mixed
18+
* The answer.
19+
*/
20+
public function ask(InputInterface $input, OutputInterface $output, Question $question) {
21+
return $this->compatAsk($input, $output, $question);
22+
}
23+
24+
/**
25+
* Asks a question.
26+
*
27+
* @return mixed
28+
* The answer.
29+
*/
30+
abstract protected function compatAsk(InputInterface $input, OutputInterface $output, Question $question);
31+
32+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace DrupalCodeGenerator\Compatibility\Php7;
4+
5+
use Symfony\Component\Console\Question\Question;
6+
7+
/**
8+
* PHP 7 compatibility.
9+
*/
10+
interface GeneratorStyleInterface {
11+
12+
/**
13+
* Asks a question to the user.
14+
*
15+
* @return mixed
16+
* The answer.
17+
*/
18+
public function askQuestion(Question $question);
19+
20+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace DrupalCodeGenerator\Compatibility\Php8;
4+
5+
use Symfony\Component\Console\Question\Question;
6+
7+
/**
8+
* PHP 8 compatibility.
9+
*/
10+
trait AskQuestionTrait {
11+
12+
public function askQuestion(Question $question): mixed {
13+
return $this->compatAskQuestion($question);
14+
}
15+
16+
/**
17+
* Asks a question.
18+
*
19+
* @return mixed
20+
* The answer.
21+
*/
22+
abstract protected function compatAskQuestion(Question $question);
23+
24+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace DrupalCodeGenerator\Compatibility\Php8;
4+
5+
use Symfony\Component\Console\Input\InputInterface;
6+
use Symfony\Component\Console\Output\OutputInterface;
7+
use Symfony\Component\Console\Question\Question;
8+
9+
/**
10+
* PHP 8 compatibility.
11+
*/
12+
trait AskTrait {
13+
14+
public function ask(InputInterface $input, OutputInterface $output, Question $question): mixed {
15+
return $this->compatAsk($input, $output, $question);
16+
}
17+
18+
/**
19+
* Asks a question.
20+
*
21+
* @return mixed
22+
* The answer.
23+
*/
24+
abstract protected function compatAsk(InputInterface $input, OutputInterface $output, Question $question);
25+
26+
}

0 commit comments

Comments
 (0)