An extension for PHPStan for adding analysis for PHP Language Extensions.

Overview

PHPStan PHP Language Extensions (currently in BETA)

This is an extension for PHPStan for adding analysis for PHP Language Extensions.

Language feature added:

Installation

To make the attributes available for your codebase use:

composer require dave-liddament/php-language-extensions

To use install PHPStan extension use:

composer require --dev dave-liddament/phpstan-php-language-extensions

If you are using phpstan/extension-installer you're ready to go (but you might want to check out the configuration options)

Manual installation

If you don't want to use phpstan/extension-installer, include rules.neon in your project's PHPStan config:

includes:
    - vendor/dave-liddament/phpstan-php-language-extensions/extension.neon

Configuring

Some attributes, e.g. #[package], might make testing difficult. It is possible to disable the checks for test code in one of two ways:

Exclude checks on class names ending with Test:

To exclude any checks from classes that where the name ends with Test add the following to the parameters section of your phpstan.neon file:

parameters:
  phpLanguageExtensions:
    mode: className

Exclude checks based on test namespace

To exclude any checks from classes that are in the test namespace (e.g. Acme\Test) add the following to the parameters section of your phpstan.neon file:

parameters:
  phpLanguageExtensions:
    mode: namespace
    testNamespace: 'Acme\Test'

Contributing

See Contributing.

Demo project

See PHP language extensions PHPStan demo project.

You might also like...
PHPStan extension to support #[Readonly] constructor properties

icanhazstring/phpstan-readonly-property Support #[Readonly] promoted constructor properties for PHPStan. This library is used to have a full transitio

Magento specific extension for phpstan

bitexpert/phpstan-magento This package provides some additional features for PHPStan to make it work for Magento 2 projects. Installation The preferre

The main scope of this extension is to help phpstan to detect the type of object after the Assert\Assertion validation.

PHPStan beberlei/assert extension PHPStan beberlei/assert Description The main scope of this extension is to help phpstan to detect the type of object

PHPStan extension for webmozart/assert

PHPStan webmozart/assert extension PHPStan webmozart/assert Description The main scope of this extension is to help phpstan to detect the type of obje

PHPStan extension for sealed classes and interfaces.

Sealed classes with PHPStan This extension adds support for sealed classes and interfaces to PHPStan. Installation To use this extension, require it v

Zephir is a compiled high level language aimed to the creation of C-extensions for PHP.

Zephir - is a high level programming language that eases the creation and maintainability of extensions for PHP. Zephir extensions are exported to C c

A repository for showcasing my knowledge of the PHP programming language, and continuing to learn the language.

Learning PHP (programming language) I know very little about PHP. This document will list all my knowledge of the PHP programming language. Basic synt

Magento 2 Finnish Language Pack is the perfect guide so that you can enable Finnish on your magento 2 store. This translation is really necessary for everyone who are living in the Finland. Here is a step-by-step guide to install Finnish package and use it as the default language. A package for adding more type safety to your PHP projects.
A package for adding more type safety to your PHP projects.

Table of Contents Overview Installation Usage Simple Checks Advanced Checks Custom Checks Skipping Checks Testing Security Contribution Credits Change

Comments
  • ADD NamespaceVisibility and CallableFrom

    ADD NamespaceVisibility and CallableFrom

    Mirrors work done in https://github.com/DaveLiddament/php-language-extensions/pull/8

    Adds attributes:

    • CallableFrom
    • NamespaceVisibility

    Deprecates:

    • Friend (replace with CallableFrom)
    • Package (use NamespaceVisibility)
    opened by DaveLiddament 0
  • Implement namespace visibility rules

    Implement namespace visibility rules

    This implements the necessary rules for validating namespace visibility semantics for interfaces, classes, and traits.

    • [x] Create a test scenario for class instantiation
    • [x] Create a test scenario for interface implementation
    • [ ] Create a test scenario for class/interface inheritance
    • [x] Create a test scenario for trait usage
    • [x] Create a test scenario for type references
    • [ ] Create a test scenario for declaration inconsistencies
    • [ ] Get feedback
    • [ ] Implement rules
    opened by lcobucci 4
Releases(0.2.0)
Owner
Dave Liddament
Dave Liddament
Extension for PHPStan to allow analysis of Drupal code.

phpstan-drupal Extension for PHPStan to allow analysis of Drupal code. Sponsors Would you like to sponsor? Usage When you are using phpstan/extension-

Matt Glaman 154 Jan 2, 2023
Attributes to define PHP language extensions (to be enforced by static analysis)

PHP Language Extensions (currently in BETA) This library provides attributes for extending the PHP language (e.g. adding package visibility). The inte

Dave Liddament 70 Dec 19, 2022
PHP Text Analysis is a library for performing Information Retrieval (IR) and Natural Language Processing (NLP) tasks using the PHP language

php-text-analysis PHP Text Analysis is a library for performing Information Retrieval (IR) and Natural Language Processing (NLP) tasks using the PHP l

null 464 Dec 28, 2022
Silverstripe-searchable - Adds to the default Silverstripe search by adding a custom results controller and allowing properly adding custom data objects and custom fields for searching

SilverStripe Searchable Module UPDATE - Full Text Search This module now uses Full Text Support for MySQL/MariaDB databases in version 3.* Adds more c

ilateral 13 Apr 14, 2022
Perform static analysis of Drupal PHP code with phpstan-drupal.

Perform static analysis of Drupal PHP code with PHPStan and PHPStan-Drupal on Drupal using PHP 8. For example: docker run --rm \ -v $(pwd)/example01

Dcycle 0 Dec 10, 2021
Doctrine extensions for PHPStan

Doctrine extensions for PHPStan PHPStan Doctrine This extension provides following features: DQL validation for parse errors, unknown entity classes a

PHPStan 478 Jan 3, 2023
WordPress extensions for PHPStan ⛏️

WordPress extensions for PHPStan Static analysis for the WordPress ecosystem. PHPStan WordPress Installation Add this package to your project. compose

Viktor Szépe 183 Dec 30, 2022
A pure PHP implementation of the open Language Server Protocol. Provides static code analysis for PHP for any IDE.

A pure PHP implementation of the open Language Server Protocol. Provides static code analysis for PHP for any IDE.

Felix Becker 1.1k Jan 4, 2023