Code Monkey home page Code Monkey logo

kphpstorm's Introduction

KPHPStorm plugin for PhpStorm

Build GitHub license Total Downloads Latest Version

PhpStorm plugin that makes IDE understand KPHP specifics. JetBrains repository

KPHP is a PHP compiler. Its goal is to execute PHP code much faster. It supports a strict subset of PHP and brings new types, functions, annotations and web server runtime.

Brief info

  • extended types in phpdoc: arbirtary nesting, ?nullable, tuples, shapes and other KPHP types

    phpdoc types
  • extended type inferring with per-key access completion and stdlib enhancements

    extended tinf
  • @kphp- doc tags autocomplete and validation

    @kphp doc tag
  • strict type checking in function calls, assignments, return statements, array access, etc

    strict typing
  • ... and much more!

Detailed info

Useful for plugin developers

Provided code can help IDEA/PhpStorm plugin developers in various aspects: how to provide extended type inferring, parse and colorize custom doc tags, traverse PSI structure, handle stubs metadata and lots of corner cases.

An interesting fact is that plugin disables lots of features in plain PHP projects (not KPHP-based).

Feel free to examine this code, it contains lots of necessary comments.

Questions and contribution

Please contact vk.com/kphp or VK Team.

kphpstorm's People

Contributors

danil42russia avatar hidanio avatar i582 avatar tsygankov-slava avatar unserialize avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kphpstorm's Issues

Disable native `PhpReturnDocTypeMismatchInspection` check

In one of the last versions of PhpStorm, a PhpReturnDocTypeMismatchInspection check was added, which sometimes gives false positive on our codebase. We already have a KphpReturnTypeMismatchInspection that checks for the same, so the native check needs to be disabled.

However, since when the plugin is updated by the user, new version of the plugin doesn't reinitialize enabled/disabled checks, a situation may arise when users will still have this check enabled.

Ideally, every plugin update, the plugin would run some function that would reinitialize the state of checks and turn off unnecessary ones.

See com.intellij.ide.util.RunOnceUtil

Support FFI types

The following types in doc types are valid for KPHP:

ffi_cdata<example, union Foo>
ffi_cdata<example, struct Foo>
ffi_cdata<C, void*>
ffi_cdata<C, const int32_t*>
ffi_cdata<vector, struct Vector2f**>

ffi_scope<vector>
ffi_scope<h3>

KPHPStorm should parse them somehow, not to be error-prone, without type hinting. The easiest way is to treat them as 'any'

Update required IDE build

Incompatible: requires IDE build 221.* or earlier

Latest stable IDE build: #IU-222.3345.118, built on July 26, 2022

Add a `null safety` check for instances when calling functions (`instances null problems`)

KPHPStorm already has a check for primitives. We need to expand it and add a check for instances of the class.
Sample code:

<?php

declare(strict_types = 1);

function primitive_types() {
  /** @var int|null $type */
  $type = null;

  primitive_fun($type); // error: Can't pass '?int' to 'int' $var

  function primitive_fun(int $var) {
  }
}

function instances_types() {
  class Cls {
  }

  /** @var Cls|null $type */
  $type = null;

  instances_fun($type); // no error or warning

  function instances_fun(Cls $var) {
  }
}

Current check for primitives in KphpParameterTypeMismatchInspection

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.