Skip to content

Commit

Permalink
Drop PHP <8 support
Browse files Browse the repository at this point in the history
  • Loading branch information
xificurk committed May 14, 2022
1 parent 4d84a2f commit 88264db
Show file tree
Hide file tree
Showing 14 changed files with 12 additions and 47 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
fail-fast: false
matrix:
php:
- 7.4
- 8.0
- 8.1
composer_args:
Expand Down Expand Up @@ -53,7 +52,7 @@ jobs:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.0
coverage: none
- name: Build
run: composer update --no-interaction --no-progress --prefer-dist --prefer-stable
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
],
"require": {
"php": ">=7.4.0 <8.2",
"php": ">=8.0.0 <8.2",
"nette/utils": "^3.2@dev",
"nette/component-model": "^3.0.2@dev",
"nette/application": "^3.1.4@dev",
Expand Down
1 change: 0 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ includes:
- vendor/spaze/phpstan-disallowed-calls/disallowed-insecure-calls.neon
- vendor/spaze/phpstan-disallowed-calls/disallowed-loose-calls.neon
- tests/PHPStan/disallowedCalls.neon
- tests/PHPStan/conditional.config.php

parameters:
level: max
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,14 @@ public function loadConfiguration(): void
$container = $this->getContainerBuilder();

$readers = [];
if (PHP_VERSION_ID >= 8_00_00) {
$readers[] = $container->addDefinition($this->prefix('attributesReader'), new ServiceDefinition())
->setType(AttributesReader::class)
->setAutowired(AttributesReader::class);
}
$readers[] = $container->addDefinition($this->prefix('attributesReader'), new ServiceDefinition())
->setType(AttributesReader::class)
->setAutowired(AttributesReader::class);
if ($this->config->enableDoctrineAnnotations) {
$readers[] = $container->addDefinition($this->prefix('doctrineAnnotationsReader'), new ServiceDefinition())
->setType(DoctrineAnnotationsReader::class)
->setAutowired(DoctrineAnnotationsReader::class);
}
if ($readers === []) {
throw new \LogicException('You must either use PHP >= 8.0 for attributes support, or enable doctrine annotations.');
}

$container->addDefinition($this->prefix('annotationsReader'), new ServiceDefinition())
->setType(AnnotationsReader::class)
Expand Down
2 changes: 1 addition & 1 deletion src/SecurityAnnotations/Annotations/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class Role implements NamedArgumentConstructorAnnotation
/**
* @param string|array<string> $value
*/
public function __construct($value)
public function __construct(string|array $value)
{
$this->roles = is_string($value) ? [$value] : $value;
}
Expand Down
2 changes: 1 addition & 1 deletion src/SecurityAnnotations/RequirementsChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function protectElement(\Reflector $element): void
{
$annotations = $this->annotationReader->getAll($element);
foreach ($annotations as $annotation) {
$annotationName = get_class($annotation);
$annotationName = $annotation::class;
if (isset($this->accessValidators[$annotationName])) {
$this->accessValidators[$annotationName]->validateAccess($annotation);
}
Expand Down
2 changes: 1 addition & 1 deletion src/SecurityAnnotations/SecuredComponents.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ trait SecuredComponents
* @param mixed $element
* @throws Nette\Application\ForbiddenRequestException;
*/
abstract public function checkRequirements($element): void;
abstract public function checkRequirements(mixed $element): void;

protected function createComponent(string $name): ?IComponent
{
Expand Down
2 changes: 1 addition & 1 deletion src/SecurityAnnotations/SecurityAnnotations.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function injectRequirementsChecker(RequirementsChecker $requirementsCheck
* @param mixed $element
* @throws Nette\Application\ForbiddenRequestException
*/
public function checkRequirements($element): void
public function checkRequirements(mixed $element): void
{
parent::checkRequirements($element);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function getSupportedAnnotationName(): string
/**
* @param mixed $annotation parsed value of annotation
*/
public function validateAccess($annotation): void
public function validateAccess(mixed $annotation): void
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function getSupportedAnnotationName(): string
/**
* @param mixed $annotation parsed value of annotation
*/
public function validateAccess($annotation): void
public function validateAccess(mixed $annotation): void
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function getSupportedAnnotationName(): string
/**
* @param mixed $annotation parsed value of annotation
*/
public function validateAccess($annotation): void
public function validateAccess(mixed $annotation): void
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ class SecurityAnnotationsExtensionTest extends TestCase
new SecurityAnnotations\Annotations\Role('attribute'),
new SecurityAnnotations\Annotations\Role('annotation'),
];
if (PHP_VERSION_ID < 8_00_00) {
array_shift($expected);
}
/** @var SecurityAnnotations\AnnotationReaders\AnnotationsReader $reader */
$reader = $this->configurator->createContainer()->getByType(SecurityAnnotations\AnnotationReaders\AnnotationsReader::class);
Assert::equal($expected, $reader->getAll(new \ReflectionClass(LoremIpsum::class)));
Expand All @@ -115,15 +112,6 @@ class SecurityAnnotationsExtensionTest extends TestCase
{
$this->configurator->addConfig(__DIR__ . '/Fixtures/config.doctrine-annotations-disabled.neon');

if (PHP_VERSION_ID < 8_00_00) {
Assert::exception(
fn () => $this->configurator->createContainer()->getByType(SecurityAnnotations\AnnotationReaders\AnnotationsReader::class),
\LogicException::class,
'You must either use PHP >= 8.0 for attributes support, or enable doctrine annotations.',
);
return;
}

/** @var SecurityAnnotations\AnnotationReaders\AnnotationsReader $reader */
$reader = $this->configurator->createContainer()->getByType(SecurityAnnotations\AnnotationReaders\AnnotationsReader::class);
Assert::equal(
Expand Down
15 changes: 0 additions & 15 deletions tests/PHPStan/conditional.config.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ require_once __DIR__ . '/../../bootstrap.php';


/**
* @phpVersion >= 8.0
* @testCase
*/
class AttributesReaderTest extends TestCase
Expand Down

0 comments on commit 88264db

Please sign in to comment.