PHPackages                             vixducis/phpstan-utilities - 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. vixducis/phpstan-utilities

ActivePhpstan-extension[Utility &amp; Helpers](/categories/utility)

vixducis/phpstan-utilities
==========================

A collection of useful utilities to transform or create types.

1.1.2(11mo ago)0227—0%MITPHPCI passing

Since Jun 3Pushed 11mo agoCompare

[ Source](https://github.com/vixducis/phpstan-utilities)[ Packagist](https://packagist.org/packages/vixducis/phpstan-utilities)[ RSS](/packages/vixducis-phpstan-utilities/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (1)Versions (5)Used By (0)

PHPStan Utilities
=================

[](#phpstan-utilities)

This is a collection of PHPStan utilities you can use to transform types.

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

[](#installation)

```
composer require vixducis/phpstan-utilities
```

Afterwards, add the following section to your `phpstan.neon` configuration file:

```
includes:
- vendor/vixducis/phpstan-utilities/extension.neon

```

Utilities
---------

[](#utilities)

This package provides several type transformation utilities for use with PHPStan. Each utility can be used as a generic type in your PHPDoc or PHPStan configuration.

### ArrayValues

[](#arrayvalues)

Sometimes, you'll have a template type that contains a template, but you still want to extract the values from it.

**Usage:**

```
/** @var ArrayValues */
```

This utility extracts the value types from an array type `T`. If `T` is an array, it returns the type of its values. Otherwise, it returns an error type.

This differs from `value-of`: `value-of` will return `int|string`. `ArrayValues` will return `array{int,string}`.

---

### UnwrapSingletonArray

[](#unwrapsingletonarray)

This utility unwraps a singleton array type, i.e., if the type is an array containing exactly one element, it yields both the original array type and the value type as a union. Otherwise, it returns the original type.

**Usage:**

```
/** @var UnwrapSingletonArray */
```

- If `T` is an array of exactly one element, returns `T|V` (where `V` is the value type).
- Otherwise, returns `T`.

---

### UnionToIntersection

[](#uniontointersection)

This utility converts a union type into an intersection type.

**Usage:**

```
/** @var UnionToIntersection */
```

If `T` is a union type (e.g., `A|B`), `UnionToIntersection` produces an intersection (e.g., `A&B`). If `T` is not a union, returns an error type.

###  Health Score

30

—

LowBetter than 65% of packages

Maintenance52

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

4

Last Release

339d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5e50bedd9c2359a19f43f752de219d1cf27f312e039f7062710e7e6966dcaec7?d=identicon)[vixducis](/maintainers/vixducis)

---

Top Contributors

[![vixducis](https://avatars.githubusercontent.com/u/378998?v=4)](https://github.com/vixducis "vixducis (5 commits)")

### Embed Badge

![Health badge](/badges/vixducis-phpstan-utilities/health.svg)

```
[![Health](https://phpackages.com/badges/vixducis-phpstan-utilities/health.svg)](https://phpackages.com/packages/vixducis-phpstan-utilities)
```

###  Alternatives

[ticketswap/phpstan-error-formatter

A minimalistic error formatter for PHPStan

87578.8k35](/packages/ticketswap-phpstan-error-formatter)[timeweb/phpstan-enum

Enum class reflection extension for PHPStan

443.2M21](/packages/timeweb-phpstan-enum)[shopsys/coding-standards

Coding standards definition compatible with PSR-2

20269.1k12](/packages/shopsys-coding-standards)

PHPackages © 2026

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