diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 099eb55e7..fcd505587 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -7,7 +7,7 @@ on: pull_request: jobs: - phpstan: + phpstan-src: name: PHPStan src runs-on: ubuntu-latest @@ -44,3 +44,16 @@ jobs: uses: docker://oskarstark/phpstan-ga with: args: analyze --no-progress -c phpstan.tests.neon.dist + + php-cs-fixer: + name: PHP-CS-Fixer + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: PHP-CS-Fixer + uses: docker://oskarstark/php-cs-fixer-ga + with: + args: --dry-run --diff diff --git a/.gitignore b/.gitignore index f97c9fc51..ac24059ae 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ vendor/ composer.lock phpunit.xml doc/_build/ +.php-cs-fixer.cache puli.json .puli/ diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 000000000..92bc74842 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,18 @@ +in(__DIR__.'/src') + ->in(__DIR__.'/tests') + ->name('*.php') +; + +$config = new PhpCsFixer\Config(); + +return $config + ->setRiskyAllowed(true) + ->setRules([ + '@Symfony' => true, + 'single_line_throw' => false, + ]) + ->setFinder($finder) +; diff --git a/.styleci.yml b/.styleci.yml deleted file mode 100644 index ba4ba743a..000000000 --- a/.styleci.yml +++ /dev/null @@ -1,7 +0,0 @@ -preset: symfony - -enabled: - - alpha_ordered_imports - -disabled: - - single_line_throw diff --git a/CHANGELOG.md b/CHANGELOG.md index 00dee24cb..4f09c3aa9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ Changelog See also the [GitHub releases page](https://github.com/FriendsOfSymfony/FOSHttpCache/releases). +2.11.0 +------ + +### Fastly client + +- Marked the `@internal` constants in `FOS\HttpCache\ProxyClient\Fastly` as private + 2.10.1 ------ diff --git a/src/CacheInvalidator.php b/src/CacheInvalidator.php index e47b075a4..898bee5c1 100644 --- a/src/CacheInvalidator.php +++ b/src/CacheInvalidator.php @@ -40,27 +40,27 @@ class CacheInvalidator /** * Value to check support of invalidatePath operation. */ - const PATH = 'path'; + public const PATH = 'path'; /** * Value to check support of refreshPath operation. */ - const REFRESH = 'refresh'; + public const REFRESH = 'refresh'; /** * Value to check support of invalidate and invalidateRegex operations. */ - const INVALIDATE = 'invalidate'; + public const INVALIDATE = 'invalidate'; /** * Value to check support of invalidateTags operation. */ - const TAGS = 'tags'; + public const TAGS = 'tags'; /** * Value to check support of clearCache operation. */ - const CLEAR = 'clear'; + public const CLEAR = 'clear'; /** * @var ProxyClient diff --git a/src/Events.php b/src/Events.php index 44e3c0609..f9b564277 100644 --- a/src/Events.php +++ b/src/Events.php @@ -16,7 +16,7 @@ */ final class Events { - const PROXY_UNREACHABLE_ERROR = 'fos_http_cache.error.proxy_unreachable'; + public const PROXY_UNREACHABLE_ERROR = 'fos_http_cache.error.proxy_unreachable'; - const PROXY_RESPONSE_ERROR = 'fos_http_cache.error.response'; + public const PROXY_RESPONSE_ERROR = 'fos_http_cache.error.response'; } diff --git a/src/ProxyClient/Fastly.php b/src/ProxyClient/Fastly.php index b00c897cb..9c1188a2a 100644 --- a/src/ProxyClient/Fastly.php +++ b/src/ProxyClient/Fastly.php @@ -32,24 +32,17 @@ */ class Fastly extends HttpProxyClient implements ClearCapable, PurgeCapable, RefreshCapable, TagCapable { - /** - * @internal - */ - const HTTP_METHOD_PURGE = 'PURGE'; + private const HTTP_METHOD_PURGE = 'PURGE'; /** - * @internal - * * @see https://docs.fastly.com/api/purge#purge_db35b293f8a724717fcf25628d713583 Fastly's limit on batch tag purges. */ - const TAG_BATCH_PURGE_LIMIT = 256; + private const TAG_BATCH_PURGE_LIMIT = 256; /** - * @internal - * * @see https://docs.fastly.com/api/purge Base url endpoint used on anything but url PURGE/GET/HEAD. */ - const API_ENDPOINT = 'https://api.fastly.com'; + private const API_ENDPOINT = 'https://api.fastly.com'; /** * {@inheritdoc} diff --git a/src/ProxyClient/Invalidation/BanCapable.php b/src/ProxyClient/Invalidation/BanCapable.php index 3a395d244..f556d27b3 100644 --- a/src/ProxyClient/Invalidation/BanCapable.php +++ b/src/ProxyClient/Invalidation/BanCapable.php @@ -19,9 +19,9 @@ */ interface BanCapable extends ProxyClient { - const REGEX_MATCH_ALL = '.*'; + public const REGEX_MATCH_ALL = '.*'; - const CONTENT_TYPE_ALL = self::REGEX_MATCH_ALL; + public const CONTENT_TYPE_ALL = self::REGEX_MATCH_ALL; /** * Ban cached objects matching HTTP headers. diff --git a/src/ProxyClient/Nginx.php b/src/ProxyClient/Nginx.php index eb2687333..722fb706a 100644 --- a/src/ProxyClient/Nginx.php +++ b/src/ProxyClient/Nginx.php @@ -25,11 +25,11 @@ */ class Nginx extends HttpProxyClient implements PurgeCapable, RefreshCapable { - const HTTP_METHOD_PURGE = 'PURGE'; + public const HTTP_METHOD_PURGE = 'PURGE'; - const HTTP_METHOD_REFRESH = 'GET'; + public const HTTP_METHOD_REFRESH = 'GET'; - const HTTP_HEADER_REFRESH = 'X-Refresh'; + public const HTTP_HEADER_REFRESH = 'X-Refresh'; /** * {@inheritdoc} diff --git a/src/ProxyClient/Symfony.php b/src/ProxyClient/Symfony.php index 57b90bd49..68ca75def 100644 --- a/src/ProxyClient/Symfony.php +++ b/src/ProxyClient/Symfony.php @@ -29,7 +29,7 @@ */ class Symfony extends HttpProxyClient implements PurgeCapable, RefreshCapable, TagCapable, ClearCapable { - const HTTP_METHOD_REFRESH = 'GET'; + public const HTTP_METHOD_REFRESH = 'GET'; /** * {@inheritdoc} diff --git a/src/ProxyClient/Varnish.php b/src/ProxyClient/Varnish.php index fe1bc7c59..ffb854f1e 100644 --- a/src/ProxyClient/Varnish.php +++ b/src/ProxyClient/Varnish.php @@ -37,23 +37,23 @@ */ class Varnish extends HttpProxyClient implements BanCapable, PurgeCapable, RefreshCapable, TagCapable { - const HTTP_METHOD_BAN = 'BAN'; + public const HTTP_METHOD_BAN = 'BAN'; - const HTTP_METHOD_PURGE = 'PURGE'; + public const HTTP_METHOD_PURGE = 'PURGE'; - const HTTP_METHOD_PURGEKEYS = 'PURGEKEYS'; + public const HTTP_METHOD_PURGEKEYS = 'PURGEKEYS'; - const HTTP_METHOD_REFRESH = 'GET'; + public const HTTP_METHOD_REFRESH = 'GET'; - const HTTP_HEADER_HOST = 'X-Host'; + public const HTTP_HEADER_HOST = 'X-Host'; - const HTTP_HEADER_URL = 'X-Url'; + public const HTTP_HEADER_URL = 'X-Url'; - const HTTP_HEADER_CONTENT_TYPE = 'X-Content-Type'; + public const HTTP_HEADER_CONTENT_TYPE = 'X-Content-Type'; - const TAG_BAN = 'ban'; + public const TAG_BAN = 'ban'; - const TAG_XKEY = 'purgekeys'; + public const TAG_XKEY = 'purgekeys'; /** * Default name of the header used to invalidate content with specific tags. @@ -63,9 +63,9 @@ class Varnish extends HttpProxyClient implements BanCapable, PurgeCapable, Refre * * @var string */ - const DEFAULT_HTTP_HEADER_CACHE_TAGS = 'X-Cache-Tags'; + public const DEFAULT_HTTP_HEADER_CACHE_TAGS = 'X-Cache-Tags'; - const DEFAULT_HTTP_HEADER_CACHE_XKEY = 'xkey-softpurge'; + public const DEFAULT_HTTP_HEADER_CACHE_XKEY = 'xkey-softpurge'; /** * {@inheritdoc} diff --git a/src/SymfonyCache/CustomTtlListener.php b/src/SymfonyCache/CustomTtlListener.php index 37e0f2ea4..474439923 100644 --- a/src/SymfonyCache/CustomTtlListener.php +++ b/src/SymfonyCache/CustomTtlListener.php @@ -35,7 +35,7 @@ class CustomTtlListener implements EventSubscriberInterface * * @var string */ - const SMAXAGE_BACKUP = 'FOS-Smaxage-Backup'; + public const SMAXAGE_BACKUP = 'FOS-Smaxage-Backup'; /** * @param string $ttlHeader The header that is used to specify the TTL header diff --git a/src/SymfonyCache/Events.php b/src/SymfonyCache/Events.php index d2b23338f..cb81d9792 100644 --- a/src/SymfonyCache/Events.php +++ b/src/SymfonyCache/Events.php @@ -16,11 +16,11 @@ */ final class Events { - const PRE_HANDLE = 'fos_http_cache.pre_handle'; + public const PRE_HANDLE = 'fos_http_cache.pre_handle'; - const POST_HANDLE = 'fos_http_cache.post_handle'; + public const POST_HANDLE = 'fos_http_cache.post_handle'; - const PRE_INVALIDATE = 'fos_http_cache.pre_invalidate'; + public const PRE_INVALIDATE = 'fos_http_cache.pre_invalidate'; - const PRE_STORE = 'fos_http_cache.pre_store'; + public const PRE_STORE = 'fos_http_cache.pre_store'; } diff --git a/src/SymfonyCache/PurgeListener.php b/src/SymfonyCache/PurgeListener.php index ddb594f0c..28589ab10 100644 --- a/src/SymfonyCache/PurgeListener.php +++ b/src/SymfonyCache/PurgeListener.php @@ -25,9 +25,9 @@ */ class PurgeListener extends AccessControlledListener { - const DEFAULT_PURGE_METHOD = 'PURGE'; + public const DEFAULT_PURGE_METHOD = 'PURGE'; - const DEFAULT_CLEAR_CACHE_HEADER = 'Clear-Cache'; + public const DEFAULT_CLEAR_CACHE_HEADER = 'Clear-Cache'; /** * The purge method to use. diff --git a/src/SymfonyCache/PurgeTagsListener.php b/src/SymfonyCache/PurgeTagsListener.php index eb4d02f20..233c7d351 100644 --- a/src/SymfonyCache/PurgeTagsListener.php +++ b/src/SymfonyCache/PurgeTagsListener.php @@ -24,9 +24,9 @@ */ class PurgeTagsListener extends AccessControlledListener { - const DEFAULT_TAGS_METHOD = 'PURGETAGS'; + public const DEFAULT_TAGS_METHOD = 'PURGETAGS'; - const DEFAULT_TAGS_HEADER = 'X-Cache-Tags'; + public const DEFAULT_TAGS_HEADER = 'X-Cache-Tags'; /** * The purge tags method to use. diff --git a/src/TagHeaderFormatter/TagHeaderFormatter.php b/src/TagHeaderFormatter/TagHeaderFormatter.php index 93046e34a..83fe3be00 100644 --- a/src/TagHeaderFormatter/TagHeaderFormatter.php +++ b/src/TagHeaderFormatter/TagHeaderFormatter.php @@ -23,7 +23,7 @@ interface TagHeaderFormatter * * @var string */ - const DEFAULT_HEADER_NAME = 'X-Cache-Tags'; + public const DEFAULT_HEADER_NAME = 'X-Cache-Tags'; /** * Get the HTTP header name that will hold cache tags.