1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-03 10:07:52 +01:00

Fix formatting for mkdocs

This commit is contained in:
Matthew Brown 2018-04-15 10:51:21 -04:00 committed by GitHub
parent d07644191e
commit 3dad2ecb97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -96,22 +96,25 @@ This tells Psalm to assume that `$a` is a string (though it will still throw an
### Typing arrays ### Typing arrays
In PHP, the `array` type is commonly used to represent three different data structures: In PHP, the `array` type is commonly used to represent three different data structures:
- a [List](https://en.wikipedia.org/wiki/List_(abstract_data_type))
```php **[List](https://en.wikipedia.org/wiki/List_(abstract_data_type))**:
$a = [1, 2, 3, 4, 5];
```
- an [Associative array](https://en.wikipedia.org/wiki/Associative_array)
```php ```php
$a = [0 => 'hello', 5 => 'goodbye']; $a = [1, 2, 3, 4, 5];
$b = ['a' => 'AA', 'b' => 'BB', 'c' => 'CC'] ```
```
- makeshift [Structs](https://en.wikipedia.org/wiki/Struct_(C_programming_language))
```php **[Associative array](https://en.wikipedia.org/wiki/Associative_array)**
$a = ['name' => 'Psalm', 'type' => 'tool'];
``` ```php
$a = [0 => 'hello', 5 => 'goodbye'];
$b = ['a' => 'AA', 'b' => 'BB', 'c' => 'CC']
```
**Makeshift [Structs](https://en.wikipedia.org/wiki/Struct_(C_programming_language))**
```php
$a = ['name' => 'Psalm', 'type' => 'tool'];
```
PHP treats all these arrays the same, essentially (though there are some optimisations under the hood for the first case). PHP treats all these arrays the same, essentially (though there are some optimisations under the hood for the first case).