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(1y ago)0307↓25%MITPHPCI passing

Since Jun 3Pushed 1y 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 1w 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

28

—

LowBetter than 51% of packages

Maintenance45

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

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

430d 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

[deptrac/deptrac

Deptrac is a static code analysis tool that helps to enforce rules for dependencies between software layers.

3.0k9.8M223](/packages/deptrac-deptrac)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

67375.0M1.5k](/packages/phpstan-phpstan-doctrine)[rector/rector-src

Instant Upgrade and Automated Refactoring of any PHP code

136411.0k14](/packages/rector-rector-src)[ticketswap/phpstan-error-formatter

A minimalistic error formatter for PHPStan

87766.6k59](/packages/ticketswap-phpstan-error-formatter)[ec-europa/toolkit

Toolkit packaged for Drupal projects based on Robo.

39255.4k37](/packages/ec-europa-toolkit)[worksome/coding-style

Worksomes coding style

49826.1k69](/packages/worksome-coding-style)

PHPackages © 2026

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