Skip to content
Permalink
Browse files

Add docs for optional ObjectLike (#1942)

* Add docs for optional ObjectLike

ref #634

* Update plugins_type_system.md

* Use better letters
  • Loading branch information...
ro0NL authored and muglug committed Jul 18, 2019
1 parent 74e1b52 commit e58660f38b304ed01d2832131283055aa1378587
Showing with 2 additions and 1 deletion.
  1. +2 −1 docs/running_psalm/plugins/plugins_type_system.md
@@ -124,7 +124,8 @@ if (true === $first) {
`ObjectLike` represents an 'object-like array' - an array with known keys.

``` php
$a = ["a" => 1, "b" => 2]; // is ObjectLike, array{a:int(1),b:int(2)}
$x = ["a" => 1, "b" => 2]; // is ObjectLike, array{a: int, b: int}
$y = rand(0, 1) ? ["a" => null] : ["a" => 1, "b" => "b"]; // is ObjectLike with optional keys/values, array{a: ?int, b?: string}
```

Note that not all associative arrays are considered object-like. If the keys are not known, the array is treated as a mapping between two types.

0 comments on commit e58660f

Please sign in to comment.
You can’t perform that action at this time.