Skip to content

Commit ce4209a

Browse files
committed
Problem file updates for cloud compat
1 parent a888a76 commit ce4209a

File tree

13 files changed

+63
-55
lines changed

13 files changed

+63
-55
lines changed

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)

exercises/the-attributes-of-success/problem/problem.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
You have been given a few pieces of code (look for `attributes.php`, `deserialize.php` & `the-attributes-of-success.php` in your working directory).
1+
You have been given a few pieces of code (look for `attributes.php`, `deserialize.php` & `the-attributes-of-success.php` in {{context cli 'your working directory'}} {{context cloud 'the editor'}}).
22

33
Your entry point is `the-attributes-of-success.php`. This is the file you should edit and work on. The other files should not be modified. However, they are included by `the-attributes-of-success.php`.
44

5+
{{ cli }}
56
You can run and verify your program like so:
67

78
```sh
89
$ {appname} run the-attributes-of-success.php
910
$ {appname} verify the-attributes-of-success.php
1011
```
12+
{{ cli }}
1113

12-
Your task is split into two sections. The overall task is to write a class using properties and attributes which describe how to map data to an instance of the class.
14+
Your task is split in to two sections. The overall task is to write a class using properties and attributes which describe how to map data to an instance of the class.
1315

1416
The data will be passed to you in a JSON encoded string via the first command line argument.
1517

@@ -68,13 +70,19 @@ Use the `Skip` attribute on the `id` property of our `Review` class to tell our
6870

6971
By now you should be able to call the `deserialize` function with the `JSON` data and your class name.
7072

73+
{{ cli }}
7174
When executing your program with
7275

7376
```sh
7477
$ {appname} run the-attributes-of-success.php
7578
```
7679

7780
You should see a dump of your `Review` instance.
81+
{{ cli }}
82+
83+
{{ cloud }}
84+
When you execute your program by pressing `Run` you should see a dump of your `Review` instance.
85+
{{ cloud }}
7886

7987
Here comes our problem: The reviewers name is not anonymous. We have to comply with strict privacy laws, we cannot display this data without the reviewer's permission.
8088

@@ -126,19 +134,18 @@ The last task is to dump your object instance out using the PHP function `var_du
126134
----------------------------------------------------------------------
127135
## HINTS
128136

129-
Documentation on the Attributes feature can be found by pointing your browser here:
130-
[https://www.php.net/manual/en/language.attributes.overview.php]()
137+
{{ doc 'Attributes' en language.attributes.overview.php }}
131138

132139
Remember, do not edit `attributes.php` or `deserialize.php` - verification will fail if you do. Feel free to read the files to get a better understanding of the deserialization process.
133140

134141
You must call the `deserialize` function and you must use the `var_dump` function to output your deserialized object.
135142

136143
If you want to see the `JSON` data - use `var_dump` to dump it out.
137144

138-
For verification purposes, the order the properties defined in your `Review` class is important. Define them in the same order they are described to you.
145+
For verification purposes, the order the properties are defined in your `Review` class is important. Define them in the same order they are described to you.
139146

140147
## Extra
141148

142-
If you're not sure how to access command line arguments - you should maybe try a different workshop which covers that topic. Try `learnyouphp`.
149+
If you're not sure how to access command line arguments - you should maybe try a different workshop which covers that topic. Try the Learn you PHP workshop.
143150

144151
`json_decode` can fail if it is passed a malformed string. Wrap the decode in a `try\catch` statement and pass the `JSON_THROW_ON_ERROR` flag to `json_decode`'s fourth parameter.

0 commit comments

Comments
 (0)