Skip to content

Commit d871ff8

Browse files
authored
Merge pull request #45 from php-school/problem-file-updates
Problem file updates for cloud compat
2 parents a888a76 + 0789d83 commit d871ff8

File tree

15 files changed

+197
-184
lines changed

15 files changed

+197
-184
lines changed

composer.lock

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

exercises/a-match-made-in-heaven/problem/problem.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
You have been given a piece of code (look for `a-match-made-in-heaven.php` in your working directory) which is full of bugs.
1+
You have been given a piece of code (look for `a-match-made-in-heaven.php` in {{context cli 'your working directory'}} {{context cloud 'the editor'}}) which is full of bugs.
22
The code has been implemented badly, using a `switch` statement. Your job is to fix the code, by using the newly introduced `match` expression in PHP 8.
33

44
The piece of code is supposed to take a string representing a keyboard keypress and convert it to its equivalent ANSI decimal code.
@@ -20,8 +20,7 @@ The key presses will be provided as strings via command line arguments. Only one
2020
----------------------------------------------------------------------
2121
## HINTS
2222

23-
Documentation on the `match` expression can be found by pointing your browser here:
24-
[https://www.php.net/manual/en/control-structures.match.php]()
23+
{{ doc match en control-structures.match.php }}
2524

2625
Remember the first argument will be a randomly picked supported keypress.
2726

exercises/a-safe-space-for-nulls/problem/problem.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ And finally, the most important part, all properties which may be `NULL` should
6363

6464
Remember your program will be passed no arguments. There will be a `User` object populated for you under the variable `$user`. It is available at the beginning of your script.
6565

66-
Documentation on the Null Safe Operator can be found by pointing your browser here:
67-
[https://www.php.net/manual/en/language.oop5.basic.php#language.oop5.basic.nullsafe]()
66+
{{ doc 'Null Safe Operator' en language.oop5.basic.php#language.oop5.basic.nullsafe }}
67+
6868

6969
----------------------------------------------------------------------
7070
## EXTRA

exercises/all-mixed-up/problem/problem.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,9 @@ We will call your function automatically with a bunch of different types to make
4040

4141
We will specifically check that you used the `mixed` type. Omitting the type will not pass.
4242

43-
Documentation on the `mixed` type can be found by pointing your browser here:
44-
[https://www.php.net/manual/en/language.types.declarations.php#language.types.declarations.mixed]()
43+
{{ doc 'mixed' en language.types.declarations.php#language.types.declarations.mixed }}
4544

46-
Documentation on `get_debug_type` can be found by pointing your browser here:
47-
[https://www.php.net/manual/en/function.get-debug-type.php]()
45+
{{ doc 'get_debug_type' en function.get-debug-type.php }}
4846

4947
----------------------------------------------------------------------
5048
## EXTRA

exercises/caution-with-catches/problem/problem.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ For this exercise this function will always throw an exception but unfortunately
1313

1414
To pass this exercise you will need to call the `verify_password` function with the password provided, handle the exception and output `"Given password is invalid, please try again"`.
1515

16-
PHP 8 allows you to handle the exception without capturing the exception itself which will ensure this message is not leaked further.
16+
PHP 8 allows you to handle the exception without capturing the exception itself in to a variable, which will ensure this message is not leaked further.
1717

1818
### The advantages of non capturing catches
1919

@@ -24,5 +24,5 @@ PHP 8 allows you to handle the exception without capturing the exception itself
2424
----------------------------------------------------------------------
2525
## HINTS
2626

27-
Documentation on the non-capturing catches feature is sparse without examples, so the RFC has the most amount of detail:
28-
[https://wiki.php.net/rfc/non-capturing_catches]()
27+
Documentation on the non-capturing catches feature is sparse and without examples, so the RFC has the most amount of detail:
28+
[https://wiki.php.net/rfc/non-capturing_catches](https://wiki.php.net/rfc/non-capturing_catches)

exercises/have-the-last-say/problem/problem.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ htmlspecialchars($string, ENT_COMPAT | ENT_HTML, 'UTF-8', false);
2727

2828
We only want to change the last argument (double_encode) of the function to false (the default is true). However, we are forced to specify all the other arguments, even though they have not changed from the defaults.
2929

30-
Named arguments allows to write the same, but in a more succinct fashion:
30+
Named arguments allows us to write the same, but in a more succinct fashion:
3131

3232
```php
3333
htmlspecialchars($string, double_encode: false);
@@ -51,14 +51,11 @@ You will most likely need a loop to process all the data in the file.
5151

5252
You will need to keep reading from the file until it has been fully read. `feof` is your friend here and will inform you whether there is any data left to read.
5353

54-
Documentation on the `fopen` function can be found by pointing your browser here:
55-
[https://www.php.net/manual/en/function.fopen.php]()
54+
{{ doc 'fopen' en function.fopen.php }}
5655

57-
Documentation on the `fgetcsv` function can be found by pointing your browser here:
58-
[https://www.php.net/manual/en/function.fgetcsv.php]()
56+
{{ doc 'fgetcsv' en function.fgetcsv.php }}
5957

60-
Documentation on the `feof` function can be found by pointing your browser here:
61-
[https://www.php.net/manual/en/function.feof.php]()
58+
{{ doc 'feof' en function.feof.php }}
6259

6360
----------------------------------------------------------------------
6461
## EXTRA

exercises/infinite-divisions/problem/problem.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ Based on those values you should print a specific message followed by a new line
2424
----------------------------------------------------------------------
2525
## HINTS
2626

27-
Documentation on the fdiv function can be found by pointing your browser here:
28-
[https://www.php.net/manual/en/function.fdiv.php]()
27+
{{ doc 'fdiv' en function.fdiv.php }}
28+
2929

exercises/lord-of-the-strings/problem/problem.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,23 @@ The result column should be `true` or `false` based on the result of the corresp
4444
----------------------------------------------------------------------
4545
## HINTS
4646

47+
{{ cli }}
4748
Point your browser to [https://getcomposer.org/doc/00-intro.md](https://getcomposer.org/doc/00-intro.md) which will walk you through **Installing Composer** if you haven't already!
4849

4950
Use `composer init` to create your `composer.json` file with interactive search.
51+
{{ cli }}
52+
53+
{{ cloud }}
54+
Composer is installed and ready to go on cloud, use the `Composer Deps` button in the editor to search for and install your dependencies. While you should read the documentation for [Composer](https://getcomposer.org/doc/00-intro.md), it's important to note that the way we manage dependencies on PHP School cloud, is not how you would manage them in your own projects. We abstract away the `composer.json` file to keep it simple.
55+
{{ cloud }}
5056

5157
For more details look at the docs for...
5258

53-
**Composer** - [https://getcomposer.org/doc/01-basic-usage.md](https://getcomposer.org/doc/01-basic-usage.md)
54-
**Symfony Console** - [https://symfony.com/doc/current/components/console.html](https://symfony.com/doc/current/components/console.html)
55-
**str_contains** - [https://www.php.net/manual/en/function.str-contains.php](https://www.php.net/manual/en/function.str-contains.php)
56-
**str_starts_with** - [https://www.php.net/manual/en/function.str-starts-with.php](https://www.php.net/manual/en/function.str-starts-with.php)
57-
**str_ends_with** - [https://www.php.net/manual/en/function.str-ends-with.php](https://www.php.net/manual/en/function.str-ends-with.php)
59+
* **Composer** - [https://getcomposer.org/doc/01-basic-usage.md](https://getcomposer.org/doc/01-basic-usage.md)
60+
* **Symfony Console** - [https://symfony.com/doc/current/components/console.html](https://symfony.com/doc/current/components/console.html)
61+
* **str_contains** - [https://www.php.net/manual/en/function.str-contains.php](https://www.php.net/manual/en/function.str-contains.php)
62+
* **str_starts_with** - [https://www.php.net/manual/en/function.str-starts-with.php](https://www.php.net/manual/en/function.str-starts-with.php)
63+
* **str_ends_with** - [https://www.php.net/manual/en/function.str-ends-with.php](https://www.php.net/manual/en/function.str-ends-with.php)
5864

5965
For Symfony Console you will want to look specifically for the Table Helper.
6066

exercises/php-gets-a-promotion/problem/problem.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
You have been given a piece of code (look for `php-gets-a-promotion.php` in your working directory) which provides a class written for PHP 7.
1+
You have been given a piece of code (look for `php-gets-a-promotion.php` in {{context cli 'your working directory'}} {{context cloud 'the editor'}}) which provides a class written for PHP 7.
22

33
The code itself works well, assigning constructor arguments to the class properties.
44

@@ -18,12 +18,11 @@ Focus on converting the constructor to a terse format using constructor property
1818
----------------------------------------------------------------------
1919
## HINTS
2020

21-
Documentation on the constructor property promotion feature can be found by pointing your browser here:
22-
[https://www.php.net/manual/en/language.oop5.decon.php#language.oop5.decon.constructor.promotion]()
21+
{{ doc 'Constructor Property Promotion' en language.oop5.decon.php#language.oop5.decon.constructor.promotion }}
2322

24-
Remember to keep the same visibility for the properties
23+
Remember to keep the same visibility for the properties.
2524

26-
You will be expected to make use of the constructor property promotion feature
25+
You will be expected to make use of the constructor property promotion feature.
2726

28-
You should have less code than the provided initial code
27+
You should have less code than the provided initial code.
2928

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
`__toString()` is 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-
`Stringable` is a simple interface that requires the implementation of `__toString(): string`
3+
`Stringable` is a simple interface that requires the implementation of the method `__toString(): string`
44

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

@@ -35,13 +35,11 @@ Your program may also receive successful payloads, which you should ignore for t
3535

3636
To easily read the request body you can use `file_get_contents('php://input')`
3737

38-
For more details look at the docs for...
38+
{{ doc 'Stringable' en class.stringable.php }}
3939

40-
**Stringable** - [https://www.php.net/manual/en/class.stringable.php]()
41-
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.
40+
Note that while the `Stringable` interface isn't required to pass the type hint check (simply implementing the method `__toString` is enough), it should be used if not only to signal intent.
4341

4442
Oh, and don't forget about the basics for classes and interfaces :)
4543

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

0 commit comments

Comments
 (0)