diff options
author | Devian <devianleong@gmail.com> | 2021-04-22 17:11:12 +0800 |
---|---|---|
committer | Devian <devianleong@gmail.com> | 2021-04-22 17:11:12 +0800 |
commit | bf68fa166afb95d682007e7671c2b0692227bec5 (patch) | |
tree | 26091a1e5a821905b8bdba73fd1ddb95e12f887e /vendor/doctrine/annotations/docs/en/index.rst | |
parent | 745cf2431a71d0e6c5f08f8605839279b2f7496e (diff) |
Initial
Diffstat (limited to 'vendor/doctrine/annotations/docs/en/index.rst')
-rw-r--r-- | vendor/doctrine/annotations/docs/en/index.rst | 101 |
1 files changed, 0 insertions, 101 deletions
diff --git a/vendor/doctrine/annotations/docs/en/index.rst b/vendor/doctrine/annotations/docs/en/index.rst deleted file mode 100644 index fd001f4..0000000 --- a/vendor/doctrine/annotations/docs/en/index.rst +++ /dev/null @@ -1,101 +0,0 @@ -Introduction -============ - -Doctrine Annotations allows to implement custom annotation -functionality for PHP classes and functions. - -.. code-block:: php - - class Foo - { - /** - * @MyAnnotation(myProperty="value") - */ - private $bar; - } - -Annotations aren't implemented in PHP itself which is why this component -offers a way to use the PHP doc-blocks as a place for the well known -annotation syntax using the ``@`` char. - -Annotations in Doctrine are used for the ORM configuration to build the -class mapping, but it can be used in other projects for other purposes -too. - -Installation -============ - -You can install the Annotation component with composer: - -.. code-block:: - - $ composer require doctrine/annotations - -Create an annotation class -========================== - -An annotation class is a representation of the later used annotation -configuration in classes. The annotation class of the previous example -looks like this: - -.. code-block:: php - - /** - * @Annotation - */ - final class MyAnnotation - { - public $myProperty; - } - -The annotation class is declared as an annotation by ``@Annotation``. - -:ref:`Read more about custom annotations. <custom>` - -Reading annotations -=================== - -The access to the annotations happens by reflection of the class or function -containing them. There are multiple reader-classes implementing the -``Doctrine\Common\Annotations\Reader`` interface, that can access the -annotations of a class. A common one is -``Doctrine\Common\Annotations\AnnotationReader``: - -.. code-block:: php - - use Doctrine\Common\Annotations\AnnotationReader; - use Doctrine\Common\Annotations\AnnotationRegistry; - - // Deprecated and will be removed in 2.0 but currently needed - AnnotationRegistry::registerLoader('class_exists'); - - $reflectionClass = new ReflectionClass(Foo::class); - $property = $reflectionClass->getProperty('bar'); - - $reader = new AnnotationReader(); - $myAnnotation = $reader->getPropertyAnnotation( - $property, - MyAnnotation::class - ); - - echo $myAnnotation->myProperty; // result: "value" - -Note that ``AnnotationRegistry::registerLoader('class_exists')`` only works -if you already have an autoloader configured (i.e. composer autoloader). -Otherwise, :ref:`please take a look to the other annotation autoload mechanisms <annotations>`. - -A reader has multiple methods to access the annotations of a class or -function. - -:ref:`Read more about handling annotations. <annotations>` - -IDE Support ------------ - -Some IDEs already provide support for annotations: - -- Eclipse via the `Symfony2 Plugin <http://symfony.dubture.com/>`_ -- PhpStorm via the `PHP Annotations Plugin <https://plugins.jetbrains.com/plugin/7320-php-annotations>`_ or the `Symfony Plugin <https://plugins.jetbrains.com/plugin/7219-symfony-support>`_ - -.. _Read more about handling annotations.: annotations -.. _Read more about custom annotations.: custom |