• Stars
    star
    242
  • Rank 167,048 (Top 4 %)
  • Language
    Java
  • License
    MIT License
  • Created about 11 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Add PHP annotation support for PhpStorm and IntelliJ

IntelliJ IDEA - PhpStorm PHP Annotations / Attributes

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

Provides PHP annotation extended Attribute support and for PhpStorm / IntelliJ IDEA and references for "Code > Optimize Imports" action.

Key Value
Plugin url https://plugins.jetbrains.com/plugin/7320
Id de.espend.idea.php.annotation
Changelog CHANGELOG

Install

  • Download plugin or install directly out of PhpStorm
  • Force file reindex if necessary with: File -> Invalidate Cache

Settings

Languages & Framework > PHP > Annotations

Round brackets

/**
 * @Foo<caret>()
 * @Foo<caret>
 */
class NotBlank extends Constraint {}

Use / Import alias

Languages & Framework > PHP > Annotations -> Use Alias

Annotations
use Doctrine\ORM\Mapping as ORM;

/**
 * @Id() -> @ORM\Id()
 * @NotBlank() -> @Assert\NotBlank()
 */
class Foo {}
Attributes
use Doctrine\ORM\Mapping as ORM;

#[Id] -> #[ORM\Id()]
#[NotBlank] -> #[Assert\NotBlank()]
class Foo {}

Class LineMarker

LineMarker which provide navigation to annotation class usages

namespace Doctrine\ORM\Mapping;

/**
 * @Annotation
 */
final class Entity implements Annotation
{
}

Targeting

/**
 * @ORM\Entity()
 */

Annotation Class Detection

  • Every class with @Annotation inside class doc block is detected on file indexing
  • Annotation Properties on property names
  • Property value types
  • @ENUM Tags
/**
 * @Annotation
 */
class NotBlank extends Constraint {
    public $message = 'This value should not be blank.';
    public $groups = array();

    /**
     * @var bool|boolean
     */
    public $option = false;

    /**
     *
     * @Enum({"AUTO", "SEQUENCE", "TABLE", "IDENTITY", "NONE", "UUID", "CUSTOM"})
     */
    public $strategy = 'AUTO';

    /**
     * @var array<string>
     */
    public $cascade;
    
    /**
     * @var mixed|foobar|bool
     */
    public $mixed;
}

https://www.doctrine-project.org/projects/doctrine-annotations/en/latest/custom.html#attribute-types

/**
 * @Annotation
 *
 * @Attributes({
 *   @Attribute("stringProperty", type = "string"),
 *   @Attribute("annotProperty",  type = "bool"),
 * })
 */
 *
 * @Attributes(
 *   @Attribute("stringProperty", type = "string"),
 *   @Attribute("annotProperty",  type = "bool"),
 * )
 */
class Foobar {}

Annotation Target Detection

@Target is used to attach annotation, if non provided its added to "ALL list"

/**
 * @Annotation
 * @Target("PROPERTY", "METHOD", "CLASS", "ALL")
 */
class NotBlank extends Constraint {
    public $message = 'This value should not be blank.';
}

Extension Points

Plugins provides several extension points, which allows external plugins to provide additional. See some examples on Symfony2 Plugin

Example for extension points.

<extensionPoints>
      <extensionPoint name="PhpAnnotationCompletionProvider" interface="de.espend.idea.php.annotation.extension.PhpAnnotationCompletionProvider"/>
      <extensionPoint name="PhpAnnotationReferenceProvider" interface="de.espend.idea.php.annotation.extension.PhpAnnotationReferenceProvider"/>
      <extensionPoint name="PhpAnnotationDocTagGotoHandler" interface="de.espend.idea.php.annotation.extension.PhpAnnotationDocTagGotoHandler"/>
      <extensionPoint name="PhpAnnotationDocTagAnnotator" interface="de.espend.idea.php.annotation.extension.PhpAnnotationDocTagAnnotator"/>
      <extensionPoint name="PhpAnnotationGlobalNamespacesLoader" interface="de.espend.idea.php.annotation.extension.PhpAnnotationGlobalNamespacesLoader"/>
      <extensionPoint name="PhpAnnotationVirtualProperties" interface="de.espend.idea.php.annotation.extension.PhpAnnotationVirtualProperties"/>
      
      <!-- Custom class alias mapping: "ORM" => "Doctrine\\ORM\\Mapping" -->
      <extensionPoint name="PhpAnnotationUseAlias" interface="de.espend.idea.php.annotation.extension.PhpAnnotationUseAlias"/>
</extensionPoints>

Usage

<extensions defaultExtensionNs="de.espend.idea.php.annotation">
  <PhpAnnotationExtension implementation="de.espend.idea.php.annotation.completion.PhpAnnotationTypeCompletionProvider"/>
</extensions>

PHP Attributes Bridge

All extensions points providing support to DocBlock and PHP Attributes at the same time.

use Symfony\Component\Validator\Constraints\NotBlank;

#[NotBlank(message: 'An empty file is not allowed.')]
/* @NotBlank({message: "An empty file is not allowed."}) */
#[Template('foo.html.twig')]
/* @Template("foo.html.twig") */

Completion confidence

Annoying pressing completion shortcut? Plugin provides a nice completion confidence to open completion popover on several conditions

/**
 * @<caret>
 * <caret>
 */

Static values

    /**
     * @DI\Observe(SomethingEvents::PRE_UPDATE)
     */

Doctrine

ORM: Property generator

class Foo {
    /**
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     * @ORM\Column(type="integer")
     */
    public $id<caret>;
}
class Foo {
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: 'AUTO')]
    #[ORM\Column(type: 'integer')]
    public $id<caret>;
}

ORM: class entity generator

#[ORM\Entity(repositoryClass: \Foo::class)]
#[ORM\Table(name: 'bike')]
class Foo { }

ORM: repository class generator / intention

/**
 * @ORM\Entity(repositoryClass="UnknownClass")
 */
class Foo { }
/**
 * @ORM\Entity<caret>
 */
class Foo { }

ORM: repository class completion

/**
 * @ORM\Entity(repositoryClass="<caret>")
 */

PHP Toolbox

Provides integration for PHP Toolbox

Default and property values

use Symfony\Component\Routing\Annotation\Route;

/**
 * @Route("<caret>")
 * @Route(condition="<caret>")
 */
{
  "registrar":[
    {
      "signatures":[
        {
          "class": "Symfony\\Component\\Routing\\Annotation\\Route",
          "type": "annotation"
        },
        {
          "class": "Symfony\\Component\\Routing\\Annotation\\Route",
          "field": "condition",
          "type": "annotation"
        }
      ],
      "provider":"foo",
      "language":"php"
    }
  ],
}

Property array values

use Symfony\Component\Routing\Annotation\Route;

/**
 * @Route(methods={"<caret>"})
 */
{
  "registrar":[
    {
      "language":"php",
      "provider":"methods",
      "signatures":[
        {
          "class": "Symfony\\Component\\Routing\\Annotation\\Route",
          "type": "annotation_array",
          "field": "methods"
        }
      ]
    }
  ],
  "providers": [
    {
      "name": "methods",
      "items":[
        {
          "lookup_string": "POST"
        }
      ]
    }
  ]
}

More Repositories

1

crypto-trading-bot

Cryptocurrency trading bot in javascript for Bitfinex, Bitmex, Binance, Bybit ... (public edition)
JavaScript
2,787
star
2

idea-php-symfony2-plugin

IntelliJ IDEA / PhpStorm Symfony Plugin
Java
896
star
3

idea-php-laravel-plugin

Laravel Framework Plugin for PhpStorm / IntelliJ IDEA
Java
571
star
4

uniswap-arbitrage-flash-swap

Uniswap flash swap arbitrage solidity contracts
JavaScript
385
star
5

idea-android-studio-plugin

Android Studio Plugin
Java
291
star
6

idea-php-toolbox

Collections of tools and improvements to make PhpStorm a little bit better
Java
157
star
7

idea-php-generics-plugin

Support generics types in PhpStorm via psalm / phpstan docblock
Java
144
star
8

idea-php-shopware-plugin

Shopware Plugin for PhpStorm which extends Symfony Plugin
Java
55
star
9

idea-php-symfony2-plugin-doc

Documentation only !!! for idea-php-symfony2-plugin
Python
49
star
10

idea-php-drupal-symfony2-bridge

PhpStorm plugin to support Symfony components inside Drupal 8
Java
34
star
11

idea-php-toolbox-json-files

PHP
25
star
12

torrent-announcer

Can simulate torrent client requests to a tracker and returns client ips
PHP
17
star
13

idea-php-oxid-plugin

Oxid Plugin for PhpStorm
Java
14
star
14

node-js-crypto-technical-analysis-candlestick-webserver

Candlestick Technical Analysis Http Server based on node.js
JavaScript
10
star
15

drupal-packagist

Provides a Composer packagist page for Drupal projects
PHP
8
star
16

behat-placeholder-extension

Behat placeholder extension
PHP
5
star
17

bittorrent-tracker

Simple BitTorrent Tracker / Proxy
PHP
5
star
18

solidity-multicall-contract

Contract to aggregate multiple contract web3-rpc requests into single request chunks
Solidity
4
star
19

idea-php-behat-plugin

IntelliJ IDEA / PhpStorm Behat Enhancement
Java
4
star
20

ZendDbBundle

Bundle that wraps ZendDb to Symfony2 and Doctrine
PHP
3
star
21

tgudy

TYPO3 Template and Extension
JavaScript
3
star
22

idea-localization-plugin

Extended translation / localization support for PhpStorm / IntelliJ for formats like XLF, XLIFF
Java
3
star
23

espend.de--Delicous-Bookmarks

Main Drupal module that works on b.espend.de to export HTML from Delicous Bookmarks
PHP
2
star
24

e2-fb

Facebook client for Enigma2 / Dreambox
Python
2
star
25

vavoo-iptv-stream-proxy

JavaScript
2
star
26

idea-twig-plugin

PhpStorm / IntelliJ Twig Extended Plugin improvements extracted from Symfony Plugin
Kotlin
2
star
27

Onlinestreams-for-D-Box2

Mediaportal für Neutrino (D-Box2) mit Interface für Popcorn Hour Geräte: einfacher "OnlineStream Proxy" auf Basis des internen Movieplayers. Enthalten Scripts: Youtube, ZDFMediathek, MyVideo, Apple Trailer, Spiegel.TV, kino.de, Tv-Total.de alle in PHP
PHP
2
star
28

idea-badge

Provides badges support for statistics of IntelliJ IDEA / PhpStorm Plugin Repository
PHP
2
star
29

jquery.csspanel

A panel to manipulate simple CSS styles
PHP
1
star
30

http-segmenter

Stream video to your iPhone, iPad, iPod, iOS over http
C
1
star
31

autodesk-inventor-plot-class

This class does some plotting stuff for Autodesk Inventor
Visual Basic
1
star
32

jetbrains-enterprise-plugin-repository

XML API Project for a custom JetBrains Enterprise Plugin Repository
PHP
1
star
33

MyTubeExt

MyTubeExt - Devel fork of MyTube Enigma2 Extension
Python
1
star
34

idea-php-code-usage

Exports a PHP file structure to JSON
Java
1
star
35

vbnettools

Some VB.NET projects like HamachiBroadcastFixGUI
Visual Basic
1
star
36

autodesk-inventor-printbuttons

Configurable toolbar for Autodesk Inventor for plot and print on single button click
Visual Basic
1
star
37

sharemybox.net-enigma2-client

Python Client for sharemybox.net Dreambox and Enigma2 based receiver
Python
1
star
38

idea-php-symfony2-plugin-test

Symfony2 Standard Edition to reflect features and provide tests of PhpStorm Plugin
PHP
1
star