Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readme #12

Merged
merged 1 commit into from
Mar 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading