Search by

thesis / phpstan-extension

vudaltsov

PHPStan extension for thesis packages: precise types where PHPDoc generics cannot express them.

Package info

github.com/thesis-php/phpstan-extension

Type:phpstan-extension

pkg:composer/thesis/phpstan-extension

Fund package maintenance!

www.tinkoff.ru/cf/5MqZQas2dk7

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

dev-main / 0.1.x-dev 2026-11-17 08:47 UTC

This package is auto-updated.

Last update: 2026-11-17 08:51:09 UTC


README

PHP Version Requirement GitHub Release

A PHPStan extension for the thesis packages: precise types where the generics of PHPDoc cannot express them. One extension for all packages: it does nothing for a package you do not use.

Installation

composer require --dev thesis/phpstan-extension

With phpstan/extension-installer that is all. Otherwise include the config:

includes:
    - vendor/thesis/phpstan-extension/extension.neon

Requires PHPStan 2.3+.

thesis/async

all() and allSettled() of an array shape of callables return the shape of their results, a type per key:

use function PHPStan\Testing\assertType;
use function Thesis\Async\all;
use function Thesis\Async\allSettled;

$report = all([
    'sales' => loadSales(...),
    'costs' => loadCosts(...),
]);
assertType('array{sales: Sales, costs: Costs}', $report);
// without the extension: array<'sales'|'costs', Sales|Costs>

[$results, $errors] = allSettled(['sales' => loadSales(...), 'costs' => loadCosts(...)]);
assertType('array{sales?: Sales, costs?: Costs}', $results);
assertType('array{sales?: Throwable, costs?: Throwable}', $errors);

all() and map() keep what is known of the keys of their input: a shape gives a shape, a list gives a list, a non-empty array a non-empty one.

use function Thesis\Async\map;

/** @var non-empty-list<string> $urls */
assertType('non-empty-list<Response>', map($urls, 10, fetch(...)));
// without the extension: array<int<0, max>, Response>

assertType('array{sales: Report, costs: Report}', map(['sales' => $sales, 'costs' => $costs], 2, report(...)));
// without the extension: array<'sales'|'costs', Report>

Without such a key or for a generator, the type of the PHPDoc stays. race(), timeout(), group() and the others need no extension: their generics are precise.