PHPackages                             cubicl/php-structure-check - 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. cubicl/php-structure-check

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

cubicl/php-structure-check
==========================

Structural check of arrays for PHP 7.4+

3.1.1(4y ago)57.5k4[1 issues](https://github.com/CubiclDev/php-structure-check/issues)MITPHPPHP ^7.4|^8.0

Since Jan 7Pushed 2y ago1 watchersCompare

[ Source](https://github.com/CubiclDev/php-structure-check)[ Packagist](https://packagist.org/packages/cubicl/php-structure-check)[ Docs](https://github.com/cubicldev/php-structure-check)[ RSS](/packages/cubicl-php-structure-check/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (6)Versions (16)Used By (0)

PHP Structure Check
===================

[](#php-structure-check)

[![Build Status](https://camo.githubusercontent.com/e2e7b8b9bd6f7191fa60d77e1fb44dc4156395378975179588cc62e7f3b216af/68747470733a2f2f7472617669732d63692e6f72672f43756269636c4465762f7068702d7374727563747572652d636865636b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/CubiclDev/php-structure-check)[![License](https://camo.githubusercontent.com/35e431d2c0067068585376fc7cffd11dd4d51ab99095653afc74eb33fe55b4d3/68747470733a2f2f706f7365722e707567782e6f72672f63756269636c2f7068702d7374727563747572652d636865636b2f6c6963656e7365)](https://packagist.org/packages/cubicl/php-structure-check)

This library can check a complex array structure against a given requirement. The purpose of this library is to create a better experience when testing a result set from an api or something similar.

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

[](#installation)

```
composer require cubicl/php-structure-check

```

Usage
-----

[](#usage)

Create a requirement:

```
$requirement = new ListType(
    new ObjectType([
        'foo' => new StringType(),
        'bar' => new IntType(),
        'buzz' => new AnyType(),
        'foobar' => new NullableType(new StringType()),
        'nested' => new ObjectType([
            'foobar' => new StringType(),
        ]),
    ])
);
```

Have some sort of external data you want to check.

```
$data = [
    [
        'foo' => 'foe',
        'bar' => 'baz',
        'buzz' => 'foe',
        'foobar' => null,
        'nested' => [
            'foobar' => 'buzz',
        ],
    ], [
        'foo' => 'foe',
        'bar' => 7,
        'buzz' => 'foe',
        'foobar' => 'baz',
        'nested' => [
            'foobar' => 'bozz',
        ],
    ], [
        'foo' => [],
        'bar' => 9.1,
        'foobar' => 'baz',
        'nested' => [
            'foobar' => 'bazz',
        ],
    ],
];
```

Check the data against the requirement.

```
$result = Checker::fulfills($data, $requirement);
```

The returned object holds information about the analysis. You can check the result by calling `isValid()` on the result object. To fetch the errors, simply call `getErrors`.

Supported Types
---------------

[](#supported-types)

Currently the following types are supported:

- Any
- Nullable
- Bool
- Numeric
- Float
- Int
- String
- Object
- List
- Datetime
- Regex
- Optional
- Enum

There are some open issues with ideas for more types. Feel free to send pull requests.

Additionally you can implement the `TypeInterface` and use your own type implementations.

Checks
------

[](#checks)

Checks are special types which can be used to add more rules to a field. So you can check the length of a string, the count of elements in an array or determine if a numeric value is in a given range.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~144 days

Recently: every ~269 days

Total

14

Last Release

1532d ago

Major Versions

0.2.0 → 1.0.02019-03-21

1.0.0 → 2.0.02020-09-25

2.0.0 → 3.0.02020-10-25

PHP version history (2 changes)3.0.0PHP ^7.4

3.1.0PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/d16a8c52ab128c90e586d96a87b8d0f3300a1f98ed2b07b4de628d03c255059f?d=identicon)[1blankz7](/maintainers/1blankz7)

---

Top Contributors

[![1blankz7](https://avatars.githubusercontent.com/u/5745388?v=4)](https://github.com/1blankz7 "1blankz7 (10 commits)")[![srmnq](https://avatars.githubusercontent.com/u/52739584?v=4)](https://github.com/srmnq "srmnq (7 commits)")[![func0der](https://avatars.githubusercontent.com/u/529819?v=4)](https://github.com/func0der "func0der (1 commits)")[![MariusRumpf](https://avatars.githubusercontent.com/u/2364426?v=4)](https://github.com/MariusRumpf "MariusRumpf (1 commits)")[![TuningYourCode](https://avatars.githubusercontent.com/u/18467288?v=4)](https://github.com/TuningYourCode "TuningYourCode (1 commits)")

---

Tags

hacktoberfestarraystructuretypes

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/cubicl-php-structure-check/health.svg)

```
[![Health](https://phpackages.com/badges/cubicl-php-structure-check/health.svg)](https://phpackages.com/packages/cubicl-php-structure-check)
```

###  Alternatives

[doctrine/collections

PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.

6.0k411.1M1.2k](/packages/doctrine-collections)[symfony/property-access

Provides functions to read and write from/to an object or array using a simple string notation

2.8k295.3M2.5k](/packages/symfony-property-access)[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k394.3M1.5k](/packages/nette-utils)[league/config

Define configuration arrays with strict schemas and access values with dot notation

564302.2M24](/packages/league-config)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[openlss/lib-array2xml

Array2XML conversion library credit to lalit.org

31052.5M47](/packages/openlss-lib-array2xml)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
