PHPackages                             xactsystems/cast - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. xactsystems/cast

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

xactsystems/cast
================

Safely cast PHP mixed values to scalar types or null.

v1.0.0(1y ago)0471MITPHPPHP &gt;=7.1

Since Aug 29Pushed 1y ago1 watchersCompare

[ Source](https://github.com/XactSystems/cast)[ Packagist](https://packagist.org/packages/xactsystems/cast)[ RSS](/packages/xactsystems-cast/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (1)

cast
====

[](#cast)

Safely cast mixed values to scalar types or null.

Used to provide safe casts of scalar values and DateTime in PHP, avoiding PHPSTAN issues when casting 'mixed' values that do not convert as expected.

For a better understanding of the problem, take a look at the PHPSTAN issue 9295: [phpstan/phpstan#9295](https://github.com/phpstan/phpstan/issues/9295)

Documentation
-------------

[](#documentation)

---

### Installation

[](#installation)

```
composer require xactsystems/cast
```

### Usage

[](#usage)

```
