Download the PHP
package yii2-extensions/phpstan without Composer
On this page you can find all versions of the php package
yii2-extensions/phpstan. It is possible to download/install
these versions without Composer. Possible dependencies are resolved
automatically.
After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.
Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.
In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories.
In this case some credentials are needed to access such packages.
Please use the auth.json textarea to insert credentials, if a package is coming from a private repository.
You can look here for more information.
Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
To use Composer is sometimes complicated. Especially for beginners.
Composer needs much resources. Sometimes they are not available on a simple webspace.
If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Enhanced static analysis for Yii2 applications with PHPStan Precise type inference, dynamic method resolution, and comprehensive property reflection
## Features
### Installation
### Quick start
Create `config/phpstan.php` with an analysis-only description of your application:
Create `phpstan.neon` in the project root, choosing paths that exist in your application:
Run PHPStan:
### Type inference examples
The snippets below assume an `app\models\Article` model with `id` and `title` property tags and a `published()` query
scope. The [usage guide](docs/examples.md) describes the analysis configuration for the components, params and behaviors
shown here.
#### Active Record
Yii supplies generic types for `findOne()`, `findAll()`, relations and the standard query methods. This extension adds
row shapes from model `@property` tags and precise `getAttribute()` types:
A custom query without generic PHPDoc, such as one generated by Gii, is bound to the model at the `find()` call site.
Use `static` or `$this` scope return types to preserve that binding. Row shapes include inherited property tags;
relation and read-only keys are optional and need guards such as `??`. See
[query limitations](docs/examples.md#custom-active-query-classes) when a query is reached through a typed parameter or a
widened relation getter.
#### Application components
`Yii::$app` uses `phpstan.application_type`, which defaults to `yii\web\Application`. Component classes come from the
analysis configuration:
Class names, class-key arrays, object instances and factories with a single class return type can provide precise types.
An untyped factory yields `object`; adding an accurate return type makes the result specific. Core components configured
without a class keep the application's annotated property type.
The built-in `user: identityClass` mapping also supplies the configured identity class to `yii\web\User`'s generic
parameter. Its `identity` property remains nullable. See [generic components](docs/configuration.md#generic-components)
and the separate [console application configuration](docs/configuration.md#web-console-and-custom-applications).
#### Application params
Params values become an array shape, including nested arrays and keys containing dots or other punctuation:
Scalars are widened to their types rather than retained as literal values. The same shape applies to inherited module
params, including `$this->module->params` in a controller. With no configured params, the type stays `array`.
#### Behaviors
The analysis-only `behaviors` map exposes members from attached behavior classes. In the example, `TaggedComponent` is
mapped to `TagBehavior`; the application must also attach that behavior at runtime:
Properties and methods are resolved from the behavior's native members and PHPDoc. See
[behavior configuration](docs/configuration.md#behaviors).
#### Dependency injection
Container service definitions and aliases are resolved by their IDs:
The example config maps `view.alias` to `view.real` and gives `sharedView` a typed factory. An unresolved definition
keeps the result as `object`. Container factories, invocable objects and aliases have distinct rules; see
[definition forms](docs/configuration.md#definition-forms).
#### Header collection
A non-null default removes `null` from the return type. The `$first` argument selects a single value or an array.
#### Logger messages
Logger and target message buffers have tuple types without local stubs or PHPDoc overrides:
Payload types follow the installed Yii version. Filtering preserves the input key and tuple types while allowing an
empty result. See the [logger examples](docs/examples.md#headers-and-logger-messages).
#### Service locator
A service locator resolves configured component IDs, while container-only IDs belong to the container:
Passing `false` or a non-constant boolean as `$throwException` makes a resolved component nullable. An `object` fallback
does not guarantee a successful runtime lookup: unknown component IDs can throw. Use
`Yii::$container->get('view.alias')` for the configured container alias.
## Documentation
Practical guides and complete examples for Yii type inference and application analysis.
- ๐ [Installation Guide](docs/installation.md)
- โ๏ธ [Configuration Guide](docs/configuration.md)
- ๐ก [Usage Examples](docs/examples.md)
- ๐ [Upgrade Guide](UPGRADE.md) and [Migration Guide](docs/migration.md)
- ๐งช [Testing Guide](docs/testing.md)
The guides and the [API reference](https://yii2-framework.github.io/docs/extensions/phpstan/reference/) generated from
the PHPDoc in `src/` are published at .
## AI assistance
AI agents: read the [documentation index](https://yii2-framework.github.io/docs/llms.txt) and fetch the Markdown version
of a page by appending `index.md` to its URL. The
[AI agents guide](https://yii2-framework.github.io/docs/project/ai-agents/) covers skill installation, client setup and
verification.
- ๐ค [`yii2-phpstan-analysis` skill](docs/agents.md): Static analysis.
- ๐งญ [`yii2-framework` skill](https://yii2-framework.github.io/docs/guide/skills/yii2-framework/): Yii 22.0 application
conventions.
The hosted documentation covers Yii 22.0. If it does not match the installed revision or is unavailable, use the
[repository guides](#documentation), the [skill source](skills/yii2-phpstan-analysis/SKILL.md), the source PHPDoc and
the [changelog](CHANGELOG.md).
## Package information
[](https://www.php.net/releases/8.3/en.php)
[](https://github.com/yiisoft/yii2/releases/tag/2.0.55)
[](https://github.com/yiisoft/yii2/tree/22.0)
[](https://packagist.org/packages/yii2-extensions/phpstan)
[](https://packagist.org/packages/yii2-extensions/phpstan)
## Project status
[](https://codecov.io/github/yii2-extensions/phpstan)
[](https://github.com/yii2-extensions/phpstan/actions/workflows/static.yml)
[](https://github.com/yii2-extensions/phpstan/actions/workflows/quality.yml)
[](https://github.styleci.io/repos/701347895?branch=main)
## Our social networks
[](https://x.com/Terabytesoftw)
[](https://www.facebook.com/wilmer.arambula.9)
[](https://www.reddit.com/r/Yii2/)
[](https://t.me/yii_framework_in_english)
## Built with AI
[](https://claude.com/claude-code)
[](https://openai.com/codex)
[](https://www.coderabbit.ai)
## License
[](LICENSE)
Composer command for our command line client (download client)This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free.Standard composer command
The package yii2-extensions/phpstan contains the following files
Loading the files please wait ...
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.