# PHPStan custom rules

DevFeed: [PHPStan custom rules](<https://devfeed.tech/articles/phpstan-custom-rules-39472.md>)

Original publisher: [Read original article](<https://akrabat.com/phpstan-custom-rules/>)

Author: Rob

Published: 2026-03-03T11:00:00Z

Content type: tutorial

Language: en

Sources: [Rob Allen](<https://devfeed.tech/sources/rob-allen.md>)

Topics: [PHP](<https://devfeed.tech/topics/php.md>), [Exception](<https://devfeed.tech/topics/exception.md>), [Code](<https://devfeed.tech/topics/code.md>), [phpstorm](<https://devfeed.tech/topics/phpstorm.md>)

Tags: [autocomplete](<https://devfeed.tech/tags/autocomplete.md>), [class](<https://devfeed.tech/tags/class.md>), [code](<https://devfeed.tech/tags/code.md>), [container](<https://devfeed.tech/tags/container.md>), [exception](<https://devfeed.tech/tags/exception.md>), [extension](<https://devfeed.tech/tags/extension.md>), [php](<https://devfeed.tech/tags/php.md>), [phpstorm](<https://devfeed.tech/tags/phpstorm.md>), [runtime](<https://devfeed.tech/tags/runtime.md>), [settings](<https://devfeed.tech/tags/settings.md>)

## AI overview

This tutorial explains how a PHPStan custom rule can detect references to unavailable PHP classes. It also describes configuring PhpStorm to limit autocomplete to extensions used by the application.

## Source excerpt

Recently I discovered that this code passed our PHPStan level 10 checks: use http\Exception\InvalidArgumentException; // ... throw new InvalidArgumentException; I was surprised as http\Exception\InvalidArgumentException is not a class in our system. While cooling, I discovered that there's an http PHP extension and it appears that PHPStan has a stub for this which means that it accepts it as existing even if it doesn't. What we think happened is that I wrote throw new InvalidArgumentException; and... continue reading.