Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump to Symfony 6.4||7, PHP 8 #35

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 12 additions & 21 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- "master"
- "tac"
tacman marked this conversation as resolved.
Show resolved Hide resolved
pull_request: ~
workflow_dispatch: ~

Expand All @@ -15,7 +16,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.1"

dependencies:
- "highest"
Expand Down Expand Up @@ -53,22 +54,15 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"

dependencies:
- "lowest"
- "highest"

symfony:
- "^4.4"
- "^5.4"
- "^6.0"

exclude:
- php-version: "7.4"
symfony: "^6.0"
- "^6.4"
- "^7.1"

steps:
- name: "Checkout"
Expand Down Expand Up @@ -103,21 +97,18 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
- "8.4"

dependencies:
- "highest"

symfony:
- "^4.4"
- "^5.4"
- "^6.0"

exclude:
- php-version: "7.4"
symfony: "^6.0"
- "~6.4.0"
- "~7.1.0"
- "~7.2.0"

steps:
- name: "Checkout"
Expand Down Expand Up @@ -160,11 +151,11 @@ jobs:
symfony:
- "^4.4"
- "^5.4"
- "^6.0"
- "^6.4 || ^7.1"

exclude:
- php-version: "7.4"
symfony: "^6.0"
symfony: "^6.4 || ^7.1"

steps:
- name: "Checkout"
Expand Down
20 changes: 10 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@
}
],
"require": {
"php": ">=7.4",
"setono/symfony-main-request-trait": "^1.0",
"symfony/config": "^4.4 || ^5.4 || ^6.0",
"symfony/dependency-injection": "^4.4 || ^5.4 || ^6.0",
"symfony/http-foundation": "^4.4 || ^5.4 || ^6.0",
"symfony/http-kernel": "^4.4 || ^5.4 || ^6.0",
"twig/twig": "^2.14 || ^3.4"
"php": "^8.2",
"symfony/config": "^6.4 || ^7.1",
tacman marked this conversation as resolved.
Show resolved Hide resolved
"symfony/dependency-injection": "^6.4 || ^7.1",
"symfony/http-foundation": "^6.4 || ^7.1",
"symfony/http-kernel": "^6.4 || ^7.1",
"twig/twig": "^3.4"
},
"require-dev": {
"infection/infection": "^0.26",
"matomo/device-detector": "^5.0 || ^6.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.3",
"nette/php-generator": "^3.6",
"nette/php-generator": "^4.1",
"phpbench/phpbench": "^1.2",
"phpspec/prophecy-phpunit": "^2.0",
"phpstan/phpstan": "^1.12",
"phpunit/phpunit": "^9.5",
"psalm/plugin-phpunit": "^0.18",
"psalm/plugin-symfony": "^4.0",
"roave/security-advisories": "dev-latest",
"setono/code-quality-pack": "^2.2",
"symfony/console": "^4.4 || ^5.4 || ^6.0",
"symfony/yaml": "^4.4 || ^5.4 || ^6.0",
"symfony/console": "^6.4 || ^7.1",
"symfony/yaml": "^6.4 || ^7.1",
"webmozart/assert": "^1.11"
},
"prefer-stable": true,
Expand Down
38 changes: 38 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
parameters:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have Psalm already :)

level: 9
inferPrivatePropertyTypeFromConstructor: true
paths:
- ./src/

excludePaths:
# - 'src/Resources/skeleton'
# - */cache/*
analyse:
- ./vendor

reportUnmatchedIgnoredErrors: false
# checkMissingIterableValueType: false
# checkGenericClassInNonGenericObjectType: false
ignoreErrors:
- '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::children\(\)\.#'
- '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface::scalarNode\(\).#'
# Only available in ArrayNodeDefinition which is given
# False positive: clients are not dependencies of this project.
# -
# message: '#Call to an undefined method Symfony\Component\Config\Definition\Builder\NodeDefinition::children#'
# path: ./src/Client/Provider
# -
# message: '#Return typehint of method KnpU\\OAuth2ClientBundle\\Client\\Provider\\[a-zA-Z0-9\\_]+::fetchUser\(\) has invalid type [a-zA-Z0-9\\_]#'
# path: ./src/Client/Provider
# False positive: using `::class` is not an error for those providers `::getProviderClass()` method.
# -
# message: '#Class [a-zA-Z0-9\\_]+ not found#'
# path: ./src/DependencyInjection/Providers

# The DependencyInjection returns are very complex to deal with
# -
# message: '#.*NodeParentInterface\|null.*#'
# path: ./src/DependencyInjection/Providers
# -
# message: '#.*NodeDefinition::children.*#'
# path: ./src/DependencyInjection
14 changes: 4 additions & 10 deletions src/BotDetector/BotDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,16 @@

final class BotDetector implements BotDetectorInterface
{
use MainRequestTrait;

/** @var array<string, bool> */
private array $cache = [];

private RequestStack $requestStack;

/** @var list<string> */
private array $popular;

/**
* @param list<string>|null $popular
*/
public function __construct(RequestStack $requestStack, array $popular = null)
public function __construct(private readonly RequestStack $requestStack, array $popular = null)
{
$this->requestStack = $requestStack;
tacman marked this conversation as resolved.
Show resolved Hide resolved
if (null === $popular) {
Expand Down Expand Up @@ -56,13 +52,11 @@ public function isBot(string $userAgent): bool

public function isBotRequest(Request $request = null): bool
{
$request = $request ?? $this->requestStack->getCurrentRequest();
if (null === $request) {
$request = $this->getMainRequestFromRequestStack($this->requestStack);
if (null === $request) {
return false;
}
return false;
}

assert($request instanceof Request);
tacman marked this conversation as resolved.
Show resolved Hide resolved
$userAgent = $request->headers->get('user-agent');
if (null === $userAgent) {
return false;
Expand Down
1 change: 1 addition & 0 deletions tests/BotDetector/BotDetectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function it_returns_false_if_no_request_is_provided_and_the_request_does_
{
$requestStack = new RequestStack();
$requestStack->push(new Request());
assert($requestStack->getCurrentRequest());
tacman marked this conversation as resolved.
Show resolved Hide resolved
$botDetector = new BotDetector($requestStack);

self::assertFalse($botDetector->isBotRequest());
Expand Down
Loading