Skip to content

Commit 95a8624

Browse files
committed
remove more annotation things
1 parent 545658e commit 95a8624

37 files changed

+246
-553
lines changed

.github/workflows/php.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,18 @@ jobs:
2323
symfony-version: '6.4'
2424
- php-version: '8.2'
2525
symfony-version: '7.*'
26+
- php-version: '8.3'
27+
symfony-version: '7.*'
2628
- php-version: '8.2'
2729
symfony-version: '6.4'
2830
# Minimum supported dependencies with the oldest PHP version
2931
- php-version: '8.1'
3032
composer-flag: '--prefer-stable --prefer-lowest'
3133
symfony-version: '6.4'
34+
# Test latest unreleased versions
35+
- php-version: '8.3'
36+
stability: 'dev'
37+
3238
name: PHP ${{ matrix.php-version }} Test on Symfony ${{ matrix.symfony-version }} ${{ matrix.dependencies}} ${{ matrix.stability }} ${{ matrix.composer-flag }}
3339
steps:
3440

Resources/doc/features/headers.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Caching Headers
55

66
You can configure HTTP caching headers based on request and response properties.
77
This configuration approach is more convenient than `manually setting cache headers`_
8-
and an alternative to `setting caching headers through annotations`_.
8+
and an alternative to `setting caching headers through attributes`_.
99

1010
Set caching headers under the ``cache_control`` configuration section,
1111
which consists of a set of rules. When the request matches all criteria under
@@ -70,4 +70,4 @@ This is an example configuration. For more, see the
7070
etag: "strong"
7171
7272
.. _manually setting cache headers: https://symfony.com/doc/current/http_cache.html#the-cache-control-header
73-
.. _setting caching headers through annotations: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/cache.html
73+
.. _setting caching headers through attributes: https://symfony.com/doc/current/http_cache.html#making-your-responses-http-cacheable

Resources/doc/features/invalidation.rst

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,24 @@ returns a successful response, both routes ``villains_index`` and
9494
``villain_details`` will be purged. See the
9595
:doc:`/reference/configuration/invalidation` configuration reference.
9696

97-
Annotations
98-
-----------
97+
Attributes
98+
----------
9999

100-
Set the ``@InvalidatePath`` and ``@InvalidateRoute`` annotations to trigger
100+
Set the ``InvalidatePath`` and ``InvalidateRoute`` attributes to trigger
101101
invalidation from your controllers::
102102

103103
use FOS\HttpCacheBundle\Configuration\InvalidatePath;
104+
use Symfony\Component\ExpressionLanguage\Expression;
104105

105-
/**
106-
* @InvalidatePath("/articles")
107-
* @InvalidatePath("/articles/latest")
108-
* @InvalidateRoute("overview", params={"type" = "latest"})")
109-
* @InvalidateRoute("detail", params={"id" = {"expression"="id"}})")
110-
*/
106+
#[InvalidatePath('/articles')]
107+
#[InvalidatePath('/articles/latest')]
108+
#[InvalidateRoute('overview', params: ['type' => 'latest'])]
109+
#[InvalidateRoute("detail", params: ['id' => new Expression('my-expression="id"')])]
111110
public function editAction($id)
112111
{
113112
}
114113

115-
See the :doc:`/reference/annotations` reference.
114+
See the :doc:`/reference/attributes` reference.
116115

117116
Console Commands
118117
----------------

Resources/doc/features/tagging.rst

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ You can tag responses in different ways:
4949
* From PHP code by using the response tagger to set tags and the cache manager
5050
to invalidate tags;
5151
* Set tags from twig templates with a function;
52-
* In project configuration or using annotations on controller actions.
52+
* In project configuration or using attributes on controller actions.
5353

5454
You can add tags before the response object exists. The tags are automatically
5555
added to the response by a listener. The listener also detects pending tag
@@ -149,19 +149,18 @@ Now if a :term:`safe` request matches the criteria under ``match``, the response
149149
will be tagged with ``news``. When an unsafe request matches, the tag ``news``
150150
will be invalidated.
151151

152-
Tagging and Invalidating with Controller Annotations
153-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
152+
Tagging and Invalidating with Controller Attributes
153+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
154154

155-
Add the ``@Tag`` annotations to your controllers to set and invalidate tags::
155+
Add the ``Tag`` attribute to your controllers to set and invalidate tags::
156156

157157
use FOS\HttpCacheBundle\Configuration\Tag;
158+
use Symfony\Component\ExpressionLanguage\Expression;
158159

159160
class NewsController
160161
{
161-
/**
162-
* @Tag("news", expression="'news-'~id")
163-
*/
164-
public function articleAction($id)
162+
#[Tag('news', expression: new Expression('"news-"~id'))]
163+
public function articleAction(string $id)
165164
{
166165
// Assume $id equals 123
167166
}
@@ -172,7 +171,7 @@ on the response. If a client tries to update or delete news article 123 with an
172171
unsafe request to ``articleAction``, such as POST or DELETE, tag ``news-123``
173172
is invalidated.
174173

175-
See the :ref:`@Tag reference <tag>` for full details.
174+
See the :ref:`Tag reference <tag>` for full details.
176175

177176
.. _Tagged Cache Invalidation: http://blog.kevburnsjr.com/tagged-cache-invalidation
178177
.. _Linked Cache Invalidation: http://tools.ietf.org/html/draft-nottingham-linked-cache-inv-03

Resources/doc/overview.rst

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -39,41 +39,14 @@ For most features, you also need to :ref:`configure a caching proxy <foshttpcach
3939

4040
.. _requirements:
4141

42-
Requirements
43-
------------
44-
45-
SensioFrameworkExtraBundle
46-
~~~~~~~~~~~~~~~~~~~~~~~~~~
47-
48-
If you want to use this bundle’s annotations, install the
49-
SensioFrameworkExtraBundle_:
50-
51-
.. code-block:: bash
52-
53-
$ composer require sensio/framework-extra-bundle
54-
55-
And , if you don't use a recent version of Symfony, include it in your project::
56-
57-
<?php
58-
// app/AppKernel.php
59-
60-
public function registerBundles()
61-
{
62-
$bundles = array(
63-
// ...
64-
new FOS\HttpCacheBundle\FOSHttpCacheBundle(),
65-
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
66-
// ...
67-
);
68-
69-
.. _expression language requirement:
42+
Optional Dependencies
43+
---------------------
7044

7145
ExpressionLanguage
7246
~~~~~~~~~~~~~~~~~~
7347

74-
If you wish to use expressions_ in your annotations , you also need Symfony’s
75-
ExpressionLanguage_ component. If you’re not using full-stack Symfony 2.4 or
76-
later, you need to explicitly add the component:
48+
If you wish to use expressions_ in your :ref:`attributes <reference/attributes.rst>`,
49+
you need Symfony’s ExpressionLanguage_ component. Make sure it is part of your application with:
7750

7851
.. code-block:: bash
7952
@@ -92,10 +65,10 @@ Functionality
9265
This table shows where you can find specific functions.
9366

9467
========================= ==================================== ==================================================== ==============================================
95-
Functionality Annotations Configuration Manually
68+
Functionality Attributes Configuration Manually
9669
========================= ==================================== ==================================================== ==============================================
97-
Set Cache-Control headers (SensioFrameworkExtraBundle_) :doc:`rules <reference/configuration/headers>` (Symfony_)
98-
Tag and invalidate :doc:`@Tag </features/tagging>` :doc:`rules <reference/configuration/headers>` :doc:`cache manager <reference/cache-manager>`
70+
Set Cache-Control headers (`Symfony cache attributes`_) :doc:`rules <reference/configuration/headers>` (`Symfony cache control`_)
71+
Tag and invalidate :doc:`#[Tag] </features/tagging>` :doc:`rules <reference/configuration/tags>` :doc:`cache manager <reference/cache-manager>`
9972
Invalidate routes :ref:`invalidateroute` :ref:`invalidators <invalidation configuration>` :doc:`cache manager <reference/cache-manager>`
10073
Invalidate paths :ref:`invalidatepath` :ref:`invalidators <invalidation configuration>` :doc:`cache manager <reference/cache-manager>`
10174
========================= ==================================== ==================================================== ==============================================
@@ -109,7 +82,7 @@ This bundle is released under the MIT license.
10982
:language: none
11083

11184
.. _Packagist: https://packagist.org/packages/friendsofsymfony/http-cache-bundle
112-
.. _SensioFrameworkExtraBundle: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/index.html
11385
.. _ExpressionLanguage: https://symfony.com/doc/current/components/expression_language.html
114-
.. _Symfony: https://symfony.com/doc/current/http_cache.html#the-cache-control-header
86+
.. _Symfony cache attributes: https://symfony.com/doc/current/http_cache.html#making-your-responses-http-cacheable
87+
.. _Symfony cache control: https://symfony.com/doc/current/http_cache.html#the-cache-control-header
11588
.. _client implementations: https://packagist.org/providers/php-http/client-implementation

Resources/doc/reference.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ Reference
22
=========
33

44
This part is a full description of all available configuration options,
5-
annotations and public methods.
5+
attributes and public methods.
66

77
.. toctree::
88
:maxdepth: 2
99

1010
reference/configuration
11-
reference/annotations
11+
reference/attributes
1212
reference/cache-manager
1313
reference/glossary

Resources/doc/reference/attributes.rst

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Attributes
22
===========
33

4-
Add attribute on your controller actions to invalidate routes and paths when those actions are executed.
4+
Add attributes on your controller actions to invalidate routes and paths when those actions are executed.
55

66
.. _invalidatepath:
77

8-
``@InvalidatePath``
9-
-------------------
8+
``InvalidatePath``
9+
------------------
1010

1111
Invalidate a path::
1212

@@ -26,8 +26,8 @@ See :doc:`/features/invalidation` for more information.
2626

2727
.. _invalidateroute:
2828

29-
``@InvalidateRoute``
30-
--------------------
29+
``InvalidateRoute``
30+
-------------------
3131

3232
Invalidate a route with parameters::
3333

@@ -39,11 +39,11 @@ Invalidate a route with parameters::
3939
{
4040
}
4141

42-
Similarly to ``@InvalidatePath`` above, any successful response to an
42+
Similarly to ``InvalidatePath`` above, any successful response to an
4343
:term:`unsafe <safe>` request will invalidate the two routes.
4444

45-
You can also use expressions_ in the route parameter values. This obviously
46-
:ref:`requires the ExpressionLanguage component <requirements>`. To invalidate
45+
You can also use expressions_ in the route parameter values. To enable expression support, configure the
46+
:ref:`ExpressionLanguage component <requirements>` of this bundle. To invalidate
4747
route ``articles`` with the ``number`` parameter set to ``123``, do::
4848

4949
use FOS\HttpCacheBundle\Configuration\InvalidateRoute;
@@ -61,11 +61,11 @@ See :doc:`/features/invalidation` for more information.
6161

6262
.. _tag:
6363

64-
``@Tag``
65-
--------
64+
``Tag``
65+
-------
6666

67-
You can make this bundle tag your response automatically using the ``@Tag``
68-
annotation. :term:`Safe <safe>` operations like GET that produce a successful
67+
You can make this bundle tag your response automatically using the ``Tag``
68+
attribute. :term:`Safe <safe>` operations like GET that produce a successful
6969
response will lead to that response being tagged; modifying operations like
7070
POST, PUT, or DELETE will lead to the tags being invalidated.
7171

@@ -76,8 +76,6 @@ HTTP header (``X-Cache-Tags``, by default).
7676
Any non-safe request to the ``editAction`` that returns a successful response
7777
will trigger invalidation of both the ``news`` and the ``news-123`` tags.
7878

79-
Like InvalidatePath annotations, you can use PHP attributes instead if you are using PHP 8
80-
8179
Set/invalidate a tag::
8280

8381
use FOS\HttpCacheBundle\Configuration\Tag;
@@ -102,12 +100,12 @@ Multiple tags are possible::
102100
}
103101

104102

105-
If you prefer, you can combine tags in one annotation::
103+
If you prefer, you can combine tags in one attribute::
106104

107105
#[Tag(['news-article', 'news-list'])]
108106

109-
You can also use expressions_ in tags. This obviously
110-
:ref:`requires the ExpressionLanguage component <requirements>`. The following
107+
You can also use expressions_ in tags. To enable expression support, configure the
108+
:ref:`ExpressionLanguage component <requirements>` of this bundle. The following
111109
example sets the tag ``news-123`` on the Response::
112110

113111
use FOS\HttpCacheBundle\Configuration\Tag;
@@ -118,7 +116,7 @@ example sets the tag ``news-123`` on the Response::
118116
// Assume request parameter $id equals 123
119117
}
120118

121-
Or, using a `param converter`_::
119+
Or, when using a `value resolver`_::
122120

123121
use FOS\HttpCacheBundle\Configuration\Tag;
124122

@@ -132,4 +130,4 @@ See :doc:`/features/tagging` for an introduction to tagging.
132130
If you wish to change the HTTP header used for storing tags, see
133131
:doc:`/reference/configuration/tags`.
134132

135-
.. _param converter: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html
133+
.. _value resolver: https://symfony.com/doc/current/controller/value_resolver.html

Resources/doc/reference/configuration/headers.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,11 @@ the request was matched.
122122
Headers are **merged**. If the response already has certain cache directives
123123
set, they are not overwritten. The configuration can thus specify defaults
124124
that may be changed by controllers or services that handle the response, or
125-
``@Cache`` annotations.
125+
``Cache`` attributes.
126126

127127
The listener that applies the rules is triggered at priority 10, which
128-
makes it handle before the ``@Cache`` annotations from the
129-
SensioFrameworkExtraBundle are evaluated. Those annotations unconditionally
130-
overwrite cache directives.
128+
makes it handle before the ``Cache`` attributes from Symfony are evaluated.
129+
Those attributes unconditionally overwrite cache directives.
131130

132131
The only exception is responses that *only* have the ``no-cache``
133132
directive. This is the default value for the cache control and there is no

Resources/doc/reference/configuration/invalidation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Configure invalidation to invalidate routes when some other routes are requested
2323

2424
.. include:: /includes/expression-language.rst
2525

26-
Your custom expression functions can then be used in the ``@InvalidateRoute`` :ref:`annotations<invalidateroute>`.
26+
Your custom expression functions can then be used in the ``InvalidateRoute`` :ref:`attribute <invalidateroute>`.
2727

2828
.. code-block:: yaml
2929

Resources/doc/reference/configuration/tags.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ for an introduction. Also have a look at :doc:`configuring the proxy client for
1919
lead to tagging being disabled. If you want to use tagging in one of those
2020
cases, you need to explicitly enable tagging.
2121

22-
Enables tag annotations and rules. If you want to use tagging, it is recommended
22+
Enables tag attributes and rules. If you want to use tagging, it is recommended
2323
that you set this to ``true`` so you are notified of missing dependencies and
2424
incompatible proxies:
2525

@@ -47,7 +47,7 @@ HTTP header that tags are stored in.
4747
.. include:: /includes/expression-language.rst
4848

4949
Your custom expression functions can then be used in both the ``tag_expressions``
50-
section of the tag configuration and ``@tag`` :ref:`annotations<tag>`.
50+
section of the tag configuration and ``Tag`` :ref:`attributes <tag>`.
5151

5252
.. code-block:: yaml
5353

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"guzzlehttp/guzzle": "^7.2",
3636
"mockery/mockery": "^1.6.9",
3737
"monolog/monolog": "*",
38-
"doctrine/annotations": "^1.11",
3938
"symfony/browser-kit": "^6.4 || ^7.0",
4039
"symfony/console": "^6.4 || ^7.0",
4140
"symfony/finder": "^6.4 || ^7.0",

0 commit comments

Comments
 (0)