Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Strict types, type declarations, and static analysis for type-safe PHP code.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | -6% | 0% |
| case-04 | ✗→✓ | ▲ Improved | -1% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 88% | 0% |
| case-14 | ✓→✗ | ▼ Worse | 117% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 4% | 0% |
php<?php declare(strict_types=1); // Now type coercion is disabled function add(int $a, int $b): int { return $a + $b; } add(1, 2); // OK // add('1', '2'); // TypeError in strict mode
php<?php declare(strict_types=1); class User { private int $id; private string $email; private ?string $phone = null; private array $roles = []; public function __construct(int $id, string $email) { $this->id = $id; $this->email = $email; } }
php<?php declare(strict_types=1); class UserService { public function getUser(int $id): ?User { $user = $this->repository->find($id); return $user; // Can be User or null } public function getAllUsers(): array { return $this->repository->findAll(); } public function createUser(array $data): User { // Must return User, not null return $this->repository->create($data); } }
php<?php declare(strict_types=1); class UserRepository { /** * @return array<User> */ public function findAll(): array { // PHPStan knows this returns array of User objects return []; } /** * @param array<int> $ids * @return array<User> */ public function findByIds(array $ids): array { return []; } }
bash# Install composer require --dev phpstan/phpstan # Run vendor/bin/phpstan analyse app
neon# phpstan.neon parameters: level: 8 paths: - app
Other measured skills in the registry, with their headline benchmark lift.