Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
hermy1 committed Mar 30, 2024
1 parent adf9c36 commit 0c2946c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

> This library is a **work in progress**. Please, do not use it in production.
Type Guard module is part of the [PHP's Standard Library](https://github.com/std-library), and allows you to **narrow down the type** of an variable to a more specific type. Using the `type` function, you can perform specific checks to determine the type of an object and then use that object in a way that is **type-safe** according to the [PHPStan](https://phpstan.org/) and [Psalm](https://psalm.dev/) static analyzers.
Type Guard module is part of the [PHP's Standard Library](https://github.com/std-library), and allows you to **narrow down the type** of a variable to a more specific type. Using the `type` function, you can perform specific checks to determine the type of an object and then use that object in a way that is **type-safe** according to the [PHPStan](https://phpstan.org/) and [Psalm](https://psalm.dev/) static analyzers.

Here is an example, where we use the `type` function to narrow down the type of a variable that previously had a `mixed` type:

Expand All @@ -36,7 +36,7 @@ $users = getUsers();
$users = type($users)->not()->null();
```

And one more example, where narrow down the type of a variable to a Collection, does not lose the type information:
And one more example, where we narrow down the type of a variable to a Collection without loosing the type information:

```php
/** @var Collection<int, User>|null $users */
Expand Down

0 comments on commit 0c2946c

Please sign in to comment.