Skip to content

Commit

Permalink
remove annotation for 3.X release
Browse files Browse the repository at this point in the history
  • Loading branch information
John Quairia authored and john committed Dec 13, 2023
1 parent 5391f80 commit 8937f49
Show file tree
Hide file tree
Showing 26 changed files with 143 additions and 564 deletions.
23 changes: 8 additions & 15 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,18 @@ jobs:
matrix:
include:
# Test the latest stable release
- php-version: '7.3'
- php-version: '7.4'
- php-version: '8.0'
- php-version: '8.1'
dependencies: 'jean-beru/fos-http-cache-cloudfront'
- php-version: '7.4'
symfony-version: '4.*'
- php-version: '7.4'
symfony-version: '5.*'
- php-version: '8.0'
symfony-version: '6.*'
- php-version: '8.1'
symfony-version: '6.4'
- php-version: '8.2'
symfony-version: '7.*'
- php-version: '8.2'
symfony-version: '6.4'
# Minimum supported dependencies with the oldest PHP version
- php-version: '7.3'
- php-version: '8.1'
composer-flag: '--prefer-stable --prefer-lowest'
symfony-version: '4.4'
# Test latest unreleased versions
- php-version: '8.0'
symfony-version: '6.*'
stability: 'dev'
symfony-version: '6.4'
name: PHP ${{ matrix.php-version }} Test on Symfony ${{ matrix.symfony-version }} ${{ matrix.dependencies}} ${{ matrix.stability }} ${{ matrix.composer-flag }}
steps:

Expand Down
38 changes: 21 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
}
],
"require": {
"php": "^7.3 || ^8.0",
"friendsofsymfony/http-cache": "^2.15",
"symfony/framework-bundle": "^4.4.0 || ^5.0 || ^6.0",
"symfony/http-foundation": "^4.4.0 || ^5.0 || ^6.0",
"symfony/http-kernel": "^4.4.0 || ^5.0 || ^6.0"
"php": ">= 8.1",
"friendsofsymfony/http-cache": "^3.x-dev",
"symfony/framework-bundle": "^6.4 || ^7.0",
"symfony/http-foundation": "^6.4 || ^7.0",
"symfony/http-kernel": "^6.4 || ^7.0"
},
"require-dev": {
"php-http/guzzle7-adapter": "^0.1.1",
Expand All @@ -35,20 +35,19 @@
"guzzlehttp/guzzle": "^7.2",
"mockery/mockery": "^1.3.2",
"monolog/monolog": "*",
"sensio/framework-extra-bundle": "^4.0 || ^5.5.1 || ^6.0",
"doctrine/annotations": "^1.11",
"symfony/browser-kit": "^4.4 || ^5.0 || ^6.0",
"symfony/console": "^4.4 || ^5.0 || ^6.0",
"symfony/finder": "^4.4 || ^5.0 || ^6.0",
"symfony/phpunit-bridge": "v5.3.7",
"symfony/security-bundle": "^4.4 || ^5.0 || ^6.0",
"symfony/twig-bundle": "^4.4 || ^5.0 || ^6.0",
"twig/twig": "^2.13",
"symfony/yaml": "^4.4 || ^5.0 || ^6.0",
"symfony/css-selector": "^4.4 || ^5.0 || ^6.0",
"symfony/expression-language": "^4.4 || ^5.0 || ^6.0",
"symfony/browser-kit": "^6.4 || ^7.0",
"symfony/console": "^6.4 || ^7.0",
"symfony/finder": "^6.4 || ^7.0",
"symfony/phpunit-bridge": "^7.0",
"symfony/security-bundle": "^6.4 || ^7.0",
"symfony/twig-bundle": "^6.4 || ^7.0",
"twig/twig": "^v3.8",
"symfony/yaml": "^6.4 || ^7.0",
"symfony/css-selector": "^6.4 || ^7.0",
"symfony/expression-language": "^6.4 || ^7.0",
"symfony/monolog-bundle": "^3.0",
"symfony/routing": "^4.4 || ^5.0 || ^6.0",
"symfony/routing": "^6.4 || ^7.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.0",
"sebastian/exporter": "^2.0"
},
Expand All @@ -74,5 +73,10 @@
"classmap": [
"tests/Functional/Fixtures/app/AppKernel.php"
]
},
"config": {
"allow-plugins": {
"php-http/discovery": true
}
}
}
34 changes: 34 additions & 0 deletions src/Configuration/ConfigurationInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/*
* This file is part of the FOSHttpCacheBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace FOS\HttpCacheBundle\Configuration;

/**
* ConfigurationInterface.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
interface ConfigurationInterface
{
/**
* Returns the alias name for an annotated configuration.
*
* @return string
*/
public function getAliasName(): string;

/**
* Returns whether multiple annotations of this type are allowed.
*
* @return bool
*/
public function allowArray(): bool;
}
12 changes: 8 additions & 4 deletions src/Configuration/InvalidatePath.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@

namespace FOS\HttpCacheBundle\Configuration;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationAnnotation;

/**
* @Annotation
*/
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
class InvalidatePath extends ConfigurationAnnotation
class InvalidatePath implements ConfigurationInterface
{
/**
* @var array
Expand All @@ -34,7 +32,13 @@ public function __construct(
$values = $data;
}

parent::__construct($values);
foreach ($values as $k => $v) {
if (!method_exists($this, $name = 'set'.$k)) {
throw new \RuntimeException(sprintf('Unknown key "%s" for annotation "@%s".', $k, static::class));
}

$this->$name($v);
}
}

/**
Expand Down
11 changes: 8 additions & 3 deletions src/Configuration/InvalidateRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@

namespace FOS\HttpCacheBundle\Configuration;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationAnnotation;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;

/**
* @Annotation
*/
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
class InvalidateRoute extends ConfigurationAnnotation
class InvalidateRoute implements ConfigurationInterface
{
/**
* @var string
Expand All @@ -44,7 +43,13 @@ public function __construct(

$values['params'] = $values['params'] ?? $params;

parent::__construct($values);
foreach ($values as $k => $v) {
if (!method_exists($this, $name = 'set'.$k)) {
throw new \RuntimeException(sprintf('Unknown key "%s" for annotation "@%s".', $k, static::class));
}

$this->$name($v);
}
}

/**
Expand Down
11 changes: 8 additions & 3 deletions src/Configuration/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
namespace FOS\HttpCacheBundle\Configuration;

use FOS\HttpCacheBundle\Exception\InvalidTagException;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationAnnotation;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;

/**
* @Annotation
*/
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
class Tag extends ConfigurationAnnotation
class Tag implements ConfigurationInterface
{
private $tags;

Expand All @@ -39,7 +38,13 @@ public function __construct(

$values['expression'] = $values['expression'] ?? $expression;

parent::__construct($values);
foreach ($values as $k => $v) {
if (!method_exists($this, $name = 'set'.$k)) {
throw new \RuntimeException(sprintf('Unknown key "%s" for annotation "@%s".', $k, static::class));
}

$this->$name($v);
}
}

/**
Expand Down
45 changes: 0 additions & 45 deletions src/DependencyInjection/Compiler/TagListenerPass.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/EventListener/InvalidationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ private function invalidateRoutes(array $routes, Request $request)
$values['request'] = $request;

foreach ($routes as $route) {

$params = [];

if (null !== $route->getParams()) {
Expand All @@ -223,7 +224,6 @@ private function invalidateRoutes(array $routes, Request $request)
$params[$key] = $value;
}
}

$this->cacheManager->invalidateRoute($route->getName(), $params);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/Php8AttributesListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace FOS\HttpCacheBundle\EventListener;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationInterface;
use FOS\HttpCacheBundle\Configuration\ConfigurationInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/UserContextListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private function isAnonymous(Request $request)
*/
public function onKernelResponse(UserContextResponseEvent $event)
{
if (HttpKernelInterface::MASTER_REQUEST != $event->getRequestType()) {
if (HttpKernelInterface::MAIN_REQUEST != $event->getRequestType()) {
return;
}

Expand Down
2 changes: 0 additions & 2 deletions src/FOSHttpCacheBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use FOS\HttpCacheBundle\DependencyInjection\Compiler\HashGeneratorPass;
use FOS\HttpCacheBundle\DependencyInjection\Compiler\LoggerPass;
use FOS\HttpCacheBundle\DependencyInjection\Compiler\SessionListenerPass;
use FOS\HttpCacheBundle\DependencyInjection\Compiler\TagListenerPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

Expand All @@ -27,7 +26,6 @@ class FOSHttpCacheBundle extends Bundle
public function build(ContainerBuilder $container): void
{
$container->addCompilerPass(new LoggerPass());
$container->addCompilerPass(new TagListenerPass());
$container->addCompilerPass(new HashGeneratorPass());
$container->addCompilerPass(new SessionListenerPass());

Expand Down
13 changes: 7 additions & 6 deletions src/Http/RequestMatcher/QuerystringRequestMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,23 @@
namespace FOS\HttpCacheBundle\Http\RequestMatcher;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestMatcher as SymfonyRequestMatcher;
use Symfony\Component\HttpFoundation\RequestMatcherInterface;

/**
* Extend the Symfony RequestMatcher class to support query string matching.
*/
class QuerystringRequestMatcher extends SymfonyRequestMatcher
class QuerystringRequestMatcher implements RequestMatcherInterface
{
/**
* @var string Regular expression to match the query string part of the request url
*/
private $queryString;

public function __construct($queryString = null)
{
$this->queryString = $queryString;
}

/**
* @param string $queryString
*/
Expand All @@ -37,10 +42,6 @@ public function setQueryString($queryString)
*/
public function matches(Request $request): bool
{
if (!parent::matches($request)) {
return false;
}

if (null === $this->queryString) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/ResponseMatcher/ExpressionResponseMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace FOS\HttpCacheBundle\Http\ResponseMatcher;

use Sensio\Bundle\FrameworkExtraBundle\Security\ExpressionLanguage as SecurityExpressionLanguage;
use FOS\HttpCacheBundle\Security\ExpressionLanguage as SecurityExpressionLanguage;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
use Symfony\Component\HttpFoundation\Response;

Expand Down
33 changes: 33 additions & 0 deletions src/Security/ExpressionLanguage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/*
* This file is part of the FOSHttpCacheBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace FOS\HttpCacheBundle\Security;

use Symfony\Component\Security\Core\Authorization\ExpressionLanguage as BaseExpressionLanguage;

/**
* Adds some function to the default Symfony Security ExpressionLanguage.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class ExpressionLanguage extends BaseExpressionLanguage
{
protected function registerFunctions()
{
parent::registerFunctions();

$this->register('is_granted', function ($attributes, $object = 'null') {
return sprintf('$auth_checker->isGranted(%s, %s)', $attributes, $object);
}, function (array $variables, $attributes, $object = null) {
return $variables['auth_checker']->isGranted($attributes, $object);
});
}
}

0 comments on commit 8937f49

Please sign in to comment.