All Projects → Haehnchen → Idea Php Generics Plugin

Haehnchen / Idea Php Generics Plugin

Licence: mit
Support generics types in PhpStorm via psalm / phpstan docblock

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Idea Php Generics Plugin

Idea Php Laravel Plugin
Laravel Framework Plugin for PhpStorm / IntelliJ IDEA
Stars: ✭ 537 (+267.81%)
Mutual labels:  jetbrains, intellij, intellij-plugin, phpstorm
Runconfigurationasaction
Provides a way to use IntelliJ run configurations as buttons
Stars: ✭ 17 (-88.36%)
Mutual labels:  jetbrains, intellij, intellij-plugin, phpstorm
Magento2 Phpstorm Plugin
PHPStorm Plugin for Magento 2
Stars: ✭ 294 (+101.37%)
Mutual labels:  jetbrains, intellij, intellij-plugin, phpstorm
intellij-neos
Support for the Neos CMS in Intellij IDEA / PhpStorm
Stars: ✭ 37 (-74.66%)
Mutual labels:  intellij, jetbrains, phpstorm, intellij-plugin
Idea Php Symfony2 Plugin
IntelliJ IDEA / PhpStorm Symfony Plugin
Stars: ✭ 797 (+445.89%)
Mutual labels:  jetbrains, intellij, intellij-plugin, phpstorm
interstellar
Dark editor theme for JetBrains IDEs
Stars: ✭ 26 (-82.19%)
Mutual labels:  intellij, jetbrains, phpstorm, intellij-plugin
Intellij Idea Tutorial
IntelliJ IDEA 简体中文专题教程
Stars: ✭ 19,071 (+12962.33%)
Mutual labels:  jetbrains, intellij, phpstorm
Svelte Intellij
Svelte components in WebStorm and friends
Stars: ✭ 345 (+136.3%)
Mutual labels:  intellij, intellij-plugin, phpstorm
Texify Idea
LaTeX support for the IntelliJ platform by JetBrains.
Stars: ✭ 436 (+198.63%)
Mutual labels:  jetbrains, intellij, intellij-plugin
Night Owl Jetbrains
Night owl theme / colour scheme for IntelliJ and Webstorm (or other Jetbrains IDEs). Includes dark and light mode 🌓
Stars: ✭ 276 (+89.04%)
Mutual labels:  jetbrains, intellij, phpstorm
Intellij Plugin Save Actions
Supports configurable, Eclipse like, save actions, including "organize imports", "reformat code" and "rearrange code".
Stars: ✭ 440 (+201.37%)
Mutual labels:  jetbrains, intellij, phpstorm
Intellij Jvm Options Explained
Common JVM options used with Intellij and what they do
Stars: ✭ 636 (+335.62%)
Mutual labels:  jetbrains, intellij, phpstorm
Phpinspectionsea
A Static Code Analyzer for PHP (a PhpStorm/Idea Plugin)
Stars: ✭ 1,211 (+729.45%)
Mutual labels:  intellij, intellij-plugin, phpstorm
Yii2support
Yii2 Support for PhpStorm / IntelliJ IDEA
Stars: ✭ 280 (+91.78%)
Mutual labels:  intellij, intellij-plugin, phpstorm
Gradle Changelog Plugin
Plugin for parsing and managing the Changelog in a "keep a changelog" style.
Stars: ✭ 102 (-30.14%)
Mutual labels:  jetbrains, intellij, intellij-plugin
Jetbrains Helper
Jetbrains helper
Stars: ✭ 33 (-77.4%)
Mutual labels:  jetbrains, intellij, phpstorm
Collector Intellij
A PhpStorm plugin for refactoring to collections
Stars: ✭ 114 (-21.92%)
Mutual labels:  intellij, intellij-plugin, phpstorm
Pydantic Pycharm Plugin
PyCharm plugin for pydantic. This plugin provides autocompletion, inspection, type-checking, inserting unfilled argument, and more.
Stars: ✭ 116 (-20.55%)
Mutual labels:  jetbrains, intellij, intellij-plugin
idea-php-advanced-autocomplete
Plugin for PhpStorm IDE. Adds auto-completion support for various built-in PHP functions, where parameter is a string literal.
Stars: ✭ 57 (-60.96%)
Mutual labels:  intellij, phpstorm, intellij-plugin
idea-php-shopware-plugin
Shopware Plugin for PhpStorm which extends Symfony Plugin
Stars: ✭ 50 (-65.75%)
Mutual labels:  intellij, phpstorm, intellij-plugin

IntelliJ IDEA / PhpStorm PHPStan / Psalm / Generics

Use Replacements:

Build Status Version Downloads Downloads last month Donate to this project using Paypal

Key Value
Plugin url https://plugins.jetbrains.com/plugin/12754-php-generics
Id de.espend.idea.php.generics
Changelog CHANGELOG

!!! Work in progress !!!

Supported

types

/**
 * @[psalm-|phpstan-]template T
 * @[psalm-|phpstan-]param class-string<T> $class
 * @[psalm-|phpstan-]return T
 */
function instantiator(string $class) {
    return new $class();
}

class Foo {}

$a = instantiator(Foo::class); // Psalm knows the result is an object of type Foo

class-string

  • Inspections for not given wrong parameter
    /**
     * @[psalm-|phpstan-]template T as Exception
     * @[psalm-|phpstan-]param T::class $type
     * @return T
     */
    function a(string $type): Exception
    {
        return new $type;
    }

templates

    $collection = new FooCollection();
    
    // its now a type of "Foobar"
    $foobar = $collection->getValue();
    $foobar->get<caret>Foobar(); // method is clickable and autocompletes
    /**
     * @[psalm-|phpstan-]template T
     */
    class Collection
    {
        /**
         * @[psalm-|phpstan-]return T
         */
        public function getValue() {}
    }

    /**
     * @[psalm-|phpstan-]extends Collection<Foobar>
     */
    class FooCollection extends Collection {}

    class Foobar
    {
        public function getFoobar() {}
    }

Object-like arrays

https://psalm.dev/docs/annotating_code/type_syntax/array_types/

    a(['<caret>' => ''])

    /**
     * @[psalm-|phpstan-]param array{foo: string, bar: int} $type
     */
    function a(array $type): Exception
    {
    }

psalm-immutable and psalm-readonly

Inspection to show disallowed write access

class PsalmReadOnly {
    /**
     * @psalm-readonly
     */
    public string $readOnly;
}

/**
 * @psalm-immutable
 */
class PsalmImmutable {
    public string $readOnly;
}

Follows into errors hints

(new PsalmReadOnly())->readOnly = 'test';
(new PsalmImmutable())->readOnly = 'test';

Quality Tools

Provides support for quality tools inspection via directly call PHPStan or Psalm reporting via codestyle format

Limitation / Issues

Screenshots

class-string Object-like arrays Psalm Immutable Quality Tool Template Types

TODO

https://youtrack.jetbrains.com/issue/WI-47158

/**
 * @template T
 */
class Map
{
    /**
     * @param array<string, T>
     */
    public function __construct(array $data = []) {}
    /**
     * @return T
     */
    public function get(string $key) {}
    /**
     * @param T $value
     */
    public function set(string $key, $value): void {}
}
// Automatically inferred as Map<string>
$map = new Map([0 => 'Foo', 1 => 'Bar']);
$map->set(2, true); // Expected string

https://youtrack.jetbrains.com/issue/WI-45248

    class Assert
    {
        /**
         * @psalm-template ExpectedType of object
         * @psalm-param class-string<ExpectedType> $class
         * @psalm-assert ExpectedType $value
         */
        public static function isInstanceOf($value, $class, $message = '')
        {
        }
    }

https://github.com/phpstan/phpdoc-parser/pull/30

/**
* @param array{'foo': int, "bar": string} $a
* @param array{0: int, 1?: int} $a
* @param array{int, int} $a
* @param array{foo: int, bar: string} $a
* @param array{foo:string, bar:?int} $a
*/

Others

 /** @var array<int, string> */
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].