Skip to content

Commit 01dd62a

Browse files
committed
review fixes
1 parent fe2c734 commit 01dd62a

File tree

4 files changed

+10
-22
lines changed

4 files changed

+10
-22
lines changed

exercises/stringify-to-demystify/problem/problem.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
`__toString()` a class magic method long-standing in PHP but never truly something you could rely on unless you rolled your own interface. All that has changed with the simple introduction of the `Stringable` interface in PHP 8.
1+
`__toString()` a magic class method long-standing in PHP but never truly something you could rely on unless you rolled your own interface. All that has changed with the simple introduction of the `Stringable` interface in PHP 8.
22

3-
A simple interface that requires the implementation of `__toString(): string`
3+
`Stringable` is a simple interface that requires the implementation of `__toString(): string`
44

55
----------------------------------------------------------------------
66

7-
Create a program that reads JSON body of the request input stream (mimicking an API response). The body will need to be JSON decoded and will be a variation of the example below:
7+
Create a program that reads the JSON body of the request input stream (mimicking an API response). The body will need to be JSON decoded and will be a variation of the example below:
88

99
```json
1010
{
@@ -14,7 +14,7 @@ Create a program that reads JSON body of the request input stream (mimicking an
1414
}
1515
```
1616

17-
You will need to define a new class that implements `Stringable` and it's requirements. This class should take enough information from the request so that the `__toString` method can return a string like below:
17+
You will need to define a new class that implements `Stringable` and it's method requirements. This class should take enough information from the request so that the `__toString` method can return a string like below:
1818

1919
```
2020
Status: 401
@@ -37,11 +37,11 @@ To easily read the request body you can use `file_get_contents('php://input')`
3737

3838
For more details look at the docs for...
3939

40-
**Stringable** - [https://www.php.net/manual/en/class.stringable.php)
40+
**Stringable** - [https://www.php.net/manual/en/class.stringable.php]()
4141

42-
Note that while the `Stringable` interface isn't required to pass the type hint check, but it should be used if not only to show intent.
42+
Note that while the `Stringable` interface isn't required to pass the type hint check, however, it should be used if not only to show intent.
4343

4444
Oh, and don't forget about the basics for classes and interfaces :)
4545

46-
**class** - [https://www.php.net/manual/en/language.oop5.basic.php)
47-
**interfaces** - [https://www.php.net/manual/en/language.oop5.interfaces.php)
46+
**class** - [https://www.php.net/manual/en/language.oop5.basic.php]()
47+
**interfaces** - [https://www.php.net/manual/en/language.oop5.interfaces.php]()

src/Exercise/StringifyToDemystify.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use GuzzleHttp\Psr7\Request;
88
use PhpParser\Node\Name;
9+
use PhpParser\Node\Stmt;
910
use PhpParser\Node\Stmt\Class_;
1011
use PhpParser\Node\Stmt\TryCatch;
1112
use PhpParser\NodeFinder;
@@ -133,12 +134,9 @@ public function getBannedFunctions(): array
133134

134135
public function check(Input $input): ResultInterface
135136
{
137+
/** @var Stmt[] $statements */
136138
$statements = $this->parser->parse((string) file_get_contents($input->getRequiredArgument('program')));
137139

138-
if (null === $statements) {
139-
return new Failure($this->getName(), 'No code statements found');
140-
}
141-
142140
/** @var Class_|null $classStmt */
143141
$classStmt = (new NodeFinder())->findFirstInstanceOf($statements, Class_::class);
144142

test/Exercise/StringifyToDemystifyTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,6 @@ public function getApplication(): Application
2222
return require __DIR__ . '/../../app/bootstrap.php';
2323
}
2424

25-
public function testWithNoCode(): void
26-
{
27-
$this->runExercise('solution-no-code.php');
28-
29-
$this->assertVerifyWasNotSuccessful();
30-
31-
$this->assertResultsHasFailure(Failure::class, 'No code was found');
32-
}
33-
3425
public function testWithNoClass(): void
3526
{
3627
$this->runExercise('solution-no-class.php');

test/solutions/stringify-to-demystify/solution-no-code.php

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)