Re-add syntax highlighting to daily emails and
...ATDC lessons
This commit is contained in:
parent
0d9bb37503
commit
5fbf48d9ac
48 changed files with 186 additions and 165 deletions
|
@ -19,7 +19,7 @@ Unfortunately, they're often overused and are outdated compared to the code they
|
|||
|
||||
For example, here's some PHP code:
|
||||
|
||||
```php
|
||||
```language-php
|
||||
function sayHello(string $name, array $options = ['shout' => false]): void {
|
||||
echo 'Hello, ' . $name;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ Then you'll get this error:
|
|||
|
||||
Now, we can use a docblock to provide more information to PHPStan to describe the structure of the `$options` array and that it has strings for keys and boolean values.
|
||||
|
||||
```php
|
||||
```language-php
|
||||
/**
|
||||
* @param array<string, bool> $options
|
||||
*/
|
||||
|
@ -61,7 +61,7 @@ Now, we can use a docblock to provide more information to PHPStan to describe th
|
|||
|
||||
Although it's not erroring, we can add the `$name` parameter and declare it as a `string`.
|
||||
|
||||
```php
|
||||
```language-php
|
||||
/**
|
||||
* @param string $name
|
||||
* @param array<string, bool> $options
|
||||
|
@ -78,7 +78,7 @@ We don't want an empty string for a name and want the correct options and values
|
|||
|
||||
Let's change the docblock to this:
|
||||
|
||||
```php
|
||||
```language-php
|
||||
/**
|
||||
* @param non-empty-string $name
|
||||
* @param array{shout: bool} $options
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue