Skip to content

Commit 0d35b75

Browse files
committed
fix: partially revert dbec32c
This fixes a fatal error condition that occurs in some cases because Symfony's Question::getQuestion() method was not compatible with StarterKitQuestion::getQuestion(). Rather than attempt to specify the full Symfony Question interface as the StarterKitQuestion interface, this simply ignores the PHPStan errors in the QuestionTestCase test class.
1 parent 3a2608e commit 0d35b75

File tree

2 files changed

+12
-54
lines changed

2 files changed

+12
-54
lines changed

src/LibraryStarterKit/Console/Question/StarterKitQuestion.php

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -12,63 +12,10 @@
1212
namespace Ramsey\Dev\LibraryStarterKit\Console\Question;
1313

1414
use Ramsey\Dev\LibraryStarterKit\Answers;
15-
use Symfony\Component\Console\Question\Question;
1615

17-
/**
18-
* A starter kit question
19-
*
20-
* Except {@see self::getAnswers()} and {@see self::getName()}, all methods on
21-
* this interface are from {@see \Symfony\Component\Console\Question\Question}.
22-
*/
2316
interface StarterKitQuestion
2417
{
2518
public function getAnswers(): Answers;
2619

2720
public function getName(): string;
28-
29-
public function getQuestion(): string;
30-
31-
public function getDefault(): string | bool | int | float | null;
32-
33-
public function isMultiline(): bool;
34-
35-
public function setMultiline(bool $multiline): Question;
36-
37-
public function isHidden(): bool;
38-
39-
public function setHidden(bool $hidden): Question;
40-
41-
public function isHiddenFallback(): bool;
42-
43-
public function setHiddenFallback(bool $fallback): Question;
44-
45-
/**
46-
* @return iterable<string> | null
47-
*/
48-
public function getAutocompleterValues(): ?iterable;
49-
50-
/**
51-
* @param iterable<string> | null $values
52-
*/
53-
public function setAutocompleterValues(?iterable $values): Question;
54-
55-
public function getAutocompleterCallback(): ?callable;
56-
57-
public function setAutocompleterCallback(?callable $callback): Question;
58-
59-
public function setValidator(?callable $validator): Question;
60-
61-
public function getValidator(): ?callable;
62-
63-
public function setMaxAttempts(?int $attempts): Question;
64-
65-
public function getMaxAttempts(): ?int;
66-
67-
public function setNormalizer(callable $normalizer): Question;
68-
69-
public function getNormalizer(): ?callable;
70-
71-
public function isTrimmable(): bool;
72-
73-
public function setTrimmable(bool $trimmable): Question;
7421
}

tests/LibraryStarterKit/Console/Question/QuestionTestCase.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66

77
use Ramsey\Dev\LibraryStarterKit\Console\Question\StarterKitQuestion;
88
use Ramsey\Test\Dev\LibraryStarterKit\TestCase;
9+
use Symfony\Component\Console\Question\Question;
910

1011
abstract class QuestionTestCase extends TestCase
1112
{
1213
/**
13-
* @return class-string<StarterKitQuestion>
14+
* @return class-string<StarterKitQuestion & Question>
1415
*/
1516
abstract protected function getTestClass(): string;
1617

@@ -26,6 +27,8 @@ protected function getQuestionDefault(): mixed
2627
public function testGetName(): void
2728
{
2829
$questionClass = $this->getTestClass();
30+
31+
/** @phpstan-ignore-next-line */
2932
$question = new $questionClass($this->answers);
3033

3134
$this->assertSame($this->getQuestionName(), $question->getName());
@@ -34,6 +37,8 @@ public function testGetName(): void
3437
public function testGetQuestion(): void
3538
{
3639
$questionClass = $this->getTestClass();
40+
41+
/** @phpstan-ignore-next-line */
3742
$question = new $questionClass($this->answers);
3843

3944
$this->assertSame($this->getQuestionText(), $question->getQuestion());
@@ -42,6 +47,8 @@ public function testGetQuestion(): void
4247
public function testGetAnswers(): void
4348
{
4449
$questionClass = $this->getTestClass();
50+
51+
/** @phpstan-ignore-next-line */
4552
$question = new $questionClass($this->answers);
4653

4754
$this->assertSame($this->answers, $question->getAnswers());
@@ -50,6 +57,8 @@ public function testGetAnswers(): void
5057
public function testGetDefault(): void
5158
{
5259
$questionClass = $this->getTestClass();
60+
61+
/** @phpstan-ignore-next-line */
5362
$question = new $questionClass($this->answers);
5463

5564
$this->assertSame($this->getQuestionDefault(), $question->getDefault());
@@ -60,6 +69,8 @@ public function testGetDefaultWhenAnswerAlreadySet(): void
6069
$this->answers->{$this->getQuestionName()} = 'foobar';
6170

6271
$questionClass = $this->getTestClass();
72+
73+
/** @phpstan-ignore-next-line */
6374
$question = new $questionClass($this->answers);
6475

6576
$this->assertSame('foobar', $question->getDefault());

0 commit comments

Comments
 (0)