Skip to content

Commit

Permalink
feat: support PHP 8.4 (#34)
Browse files Browse the repository at this point in the history
* test: add test for PHP 8.4

* run psalm only on highest dep

* bump phpstan & psalm

* fix implicit nullable
  • Loading branch information
priyadi authored Sep 16, 2024
1 parent 8ca99a9 commit 8732b2f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php: [ '8.2', '8.3' ]
php: [ '8.2', '8.3', '8.4' ]
symfony: [ '6.4.*', '7.*' ]
dep: [highest,lowest]

Expand Down Expand Up @@ -54,6 +54,7 @@ jobs:

- name: Run psalm
run: make psalm
if: matrix.dep == 'highest'

- name: Run phpstan
run: make phpstan
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 0.7.6

* test: add test for PHP 8.4

## 0.7.5

* deps: bump rekapager
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"ekino/phpstan-banned-code": "^2.1",
"fakerphp/faker": "^1.23",
"pagerfanta/core": "^4.3",
"phpstan/phpstan": "^1.10.50",
"phpstan/phpstan": "^1.12",
"phpstan/phpstan-deprecation-rules": "^1.1",
"phpstan/phpstan-phpunit": "^1.3",
"phpunit/phpunit": "^10.5",
Expand Down Expand Up @@ -69,7 +69,7 @@
"symfony/web-profiler-bundle": "^6.4 || ^7.0",
"symfony/yaml": "^6.4 || ^7.0",
"twig/twig": "^3.8",
"vimeo/psalm": "^5.18",
"vimeo/psalm": "^5.26",
"zenstruck/foundry": "1.37.*"
},
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/NotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#[WithHttpStatus(404)]
class NotFoundException extends RuntimeException
{
public function __construct(string $message = 'Not Found', \Throwable $previous = null)
public function __construct(string $message = 'Not Found', ?\Throwable $previous = null)
{
parent::__construct($message, 404, $previous);
}
Expand Down
19 changes: 13 additions & 6 deletions src/State/AbstractState.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,11 @@ protected function isGranted(mixed $attribute, mixed $subject = null): bool
*
* @throws AccessDeniedException
*/
protected function denyAccessUnlessGranted(mixed $attribute, mixed $subject = null, string $message = 'Access Denied.'): void
{
protected function denyAccessUnlessGranted(
mixed $attribute,
mixed $subject = null,
string $message = 'Access Denied.'
): void {
if (!$this->isGranted($attribute, $subject)) {
$exception = $this->createAccessDeniedException($message);
$exception->setAttributes([$attribute]);
Expand All @@ -153,8 +156,10 @@ protected function denyAccessUnlessGranted(mixed $attribute, mixed $subject = nu
*
* throw $this->createNotFoundException('Page not found!');
*/
protected function createNotFoundException(string $message = 'Not Found', \Throwable $previous = null): NotFoundException
{
protected function createNotFoundException(
string $message = 'Not Found',
?\Throwable $previous = null
): NotFoundException {
return new NotFoundException($message, $previous);
}

Expand All @@ -167,8 +172,10 @@ protected function createNotFoundException(string $message = 'Not Found', \Throw
*
* @throws \LogicException If the Security component is not available
*/
protected function createAccessDeniedException(string $message = 'Access Denied.', \Throwable $previous = null): AccessDeniedException
{
protected function createAccessDeniedException(
string $message = 'Access Denied.',
?\Throwable $previous = null
): AccessDeniedException {
if (!class_exists(AccessDeniedException::class)) {
throw new \LogicException('You cannot use the "createAccessDeniedException" method if the Security component is not available. Try running "composer require symfony/security-bundle".');
}
Expand Down

0 comments on commit 8732b2f

Please sign in to comment.