PHPackages                             edgaralexanderfr/php-types - 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. edgaralexanderfr/php-types

ActiveLibrary

edgaralexanderfr/php-types
==========================

Library intended to expand PHP's data types and useful data structures as well as strong types consistency in the code of target projects.

1.8.1(1y ago)015[11 issues](https://github.com/edgaralexanderfr/php-types/issues)MITPHP

Since Jul 28Pushed 1y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (14)Used By (0)

PHP Types 🐘
===========

[](#php-types-)

[ ![View last release](https://camo.githubusercontent.com/c7ea2209b2680b1989a9f288f2fe7f82ba6cddb43d64d52b158d3d57f39636e3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d76312e382e312d696e666f726d6174696f6e616c2e737667 "View last release")](https://github.com/edgaralexanderfr/php-types/releases/latest)[ ![PHP 8.3.0](https://camo.githubusercontent.com/1d433757fa99a97b85d7c24150cbe357c84ee6e1e8d0d1bdce8c559b26bf3af8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d3e3d382e332e302d696e666f726d6174696f6e616c2e737667 "Requires PHP 8.3.0 or major")](https://www.php.net/releases/8.3/en.php)[ ![Composer](https://camo.githubusercontent.com/5b40bbf39fff9368fa7d2ddcf0c9ca00744e589ff2b24e0e36ab20aabe6fb6aa/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6d706f7365722d6f72616e67652e737667 "composer require edgaralexanderfr/php-types")](https://packagist.org/packages/edgaralexanderfr/php-types)**PHP Types** is a small library/framework aimed to improve and encourage strong typing across your project's codebase, consisting of *basic array-types*, useful *data structures* and more, that are not natively available by the language itself.

##### Table of contents 📖

[](#table-of-contents-)

1. [Requirements](#requirements)
2. [Installation](#installation)
3. [Usage](#usage)

- [3.1 Primitive types](#primitive-types)
- - [3.1.1 Extending PHP primitive types](#extending-php-primitive-types)
- - [3.1.2 `ObjectType`](#object-type)
- [3.2 Primitive arrays](#primitive-arrays)
- - [3.2.2 `BoolArray`](#bool-array)
- - [3.2.3 `IntArray`](#int-array)
- - [3.2.4 `FloatArray`](#float-array)
- - [3.2.5 `StringArray`](#string-array)
- - [3.2.6 `ObjectArray`](#object-array)
- - [3.2.7 Extra primitives arrays](#extra-primitives-arrays)
- [3.3 Standard types](#standard-types)
- - [3.3.1 Standard Ints](#standard-ints)
- - [3.3.2 `size_t`](#size-t)
- - [3.3.3 Standard Ints Arrays](#standard-ints-arrays)
- [3.4 Data structures](#data-structures)
- - [3.4.1 `HashSet`](#hash-set)
- - [3.4.2 `IntHashSet`](#int-hash-set)
- - [3.4.3 `StringHashSet`](#string-hash-set)
- [3.5 Type errors](#type-errors)
- [3.6 `hasAny()` and `isEmpty()` methods](#has-any-is-empty)
- [3.7 The `splice` method](#the-splice-method)
- [3.8 The `length` property](#the-length-property)
- [3.9 Defining custom types](#defining-custom-types)
- - [3.9.1 Defining custom arrays](#defining-custom-arrays)
- - [3.9.2 `typedef()`](#typedef)

Requirements
------------

[](#requirements)

1. **PHP 8.3.0 or major**
2. **Composer** *(optional)*
3. **Have an initted Composer project** *(optional)*

Installation
------------

[](#installation)

Install **PHP Types** via **Composer**:

```
composer require edgaralexanderfr/php-types
```

or:

You can always download the library as *.zip* file, decompress it, store it somewhere in your target project and include the *autoload.php* file from the library's project root:

```
curl -L -o php-types-master.zip https://github.com/edgaralexanderfr/php-types/archive/refs/heads/master.zip \
&& unzip php-types-master.zip \
&& rm php-types-master.zip
```

or:

You can download the packed *.phar* version of the library:

```
mkdir lib \
&& curl -L -o lib/php-types.phar https://github.com/edgaralexanderfr/php-types/raw/master/lib/php-types.phar
```

```
