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

Updating GH actions setup to include PHP 8.3 and switching them to newest LTS Ubuntu. #461

Merged
merged 3 commits into from
Jun 8, 2024
Merged
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
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ on: [push, pull_request]

jobs:
tests:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
php: ['8.2']
php: ['8.2', '8.3']
steps:
- uses: actions/checkout@v2
- name: Setup PHP with pecl and extensions
Expand All @@ -29,11 +29,11 @@ jobs:
- uses: codecov/codecov-action@v1

phpstan:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
php: ['8.2']
php: ['8.2', '8.3']
steps:
- uses: actions/checkout@v2
- name: Setup PHP with pecl and extensions
Expand All @@ -52,11 +52,11 @@ jobs:
- run: vendor/bin/phpstan analyse -c phpstan/phpstan.neon app

phpstan-tests:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
php: ['8.2']
php: ['8.2', '8.3']
steps:
- uses: actions/checkout@v2
- name: Setup PHP with pecl and extensions
Expand Down
9 changes: 4 additions & 5 deletions app/V1Module/presenters/SecurityPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ public function actionCheck()
$requestParams = $this->router->match(
new Http\Request(
new Http\UrlScript("https://foo.tld/" . ltrim($this->getRequest()->getPost("url"), "/"), "/"),
null,
null,
null,
null,
null,
[],
[],
[],
[],
$this->getRequest()->getPost("method")
)
);
Expand Down
29 changes: 17 additions & 12 deletions app/V1Module/presenters/base/ApiErrorPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
use App\Exceptions\FrontendErrorMappings;
use App\Helpers\UserActions;
use App\Presenters\BasePresenter;
use Exception;
use App\Security\UserStorage;
use Nette\Http\IResponse;
use Nette\Application\BadRequestException;
use Nette\Application\AbortException;
use Doctrine\DBAL\Exception\ConnectionException;
use Tracy\ILogger;
use Exception;
use Throwable;

/**
* The error presenter for the API module - all responses are served as JSONs with a fixed format.
Expand All @@ -32,7 +35,7 @@ class ApiErrorPresenter extends BasePresenter
/**
* @param Exception $exception
* @return void
* @throws \Nette\Application\AbortException
* @throws AbortException
*/
public function renderDefault($exception)
{
Expand All @@ -58,9 +61,9 @@ public function renderDefault($exception)
/**
* Send an error response based on a known type of exceptions - derived from ApiException
* @param ApiException $exception The exception which caused the error
* @throws \Nette\Application\AbortException
* @throws AbortException
*/
protected function handleAPIException(ApiException $exception)
public function handleAPIException(ApiException $exception)
{
$res = $this->getHttpResponse();
$additionalHeaders = $exception->getAdditionalHttpHeaders();
Expand All @@ -78,20 +81,20 @@ protected function handleAPIException(ApiException $exception)
/**
* Simply logs given exception into standard logger. Some filtering or
* further modifications can be engaged.
* @param \Throwable $exception Exception which should be logged
* @param Throwable $ex Exception which should be logged
*/
protected function handleLogging(\Throwable $exception)
public function handleLogging(Throwable $ex)
{
if ($exception instanceof BadRequestException) {
if ($ex instanceof BadRequestException) {
// nothing to log here
} else {
if ($exception instanceof ApiException && $exception->getCode() < 500) {
if ($ex instanceof ApiException && $ex->getCode() < 500) {
$this->logger->log(
"HTTP code {$exception->getCode()}: {$exception->getMessage()} in {$exception->getFile()}:{$exception->getLine()}",
"HTTP code {$ex->getCode()}: {$ex->getMessage()} in {$ex->getFile()}:{$ex->getLine()}",
'access'
);
} else {
$this->logger->log($exception, ILogger::EXCEPTION);
$this->logger->log($ex, ILogger::EXCEPTION);
}
}
}
Expand All @@ -103,7 +106,7 @@ protected function handleLogging(\Throwable $exception)
* @param string $frontendErrorCode custom defined, far more fine-grained exception code
* @param mixed $frontendErrorParams parameters belonging to error
* @return void
* @throws \Nette\Application\AbortException
* @throws AbortException
*/
protected function sendErrorResponse(
int $code,
Expand All @@ -114,7 +117,9 @@ protected function sendErrorResponse(
// calling user->isLoggedIn results in throwing exception in case of
// invalid token (after update to nette/security:v3.1), therefore we
// need to call our UserStorage directly
if ($this->getUser()->getStorage()->isAuthenticated()) {
/** @var UserStorage */
$storage = $this->getUser()->getStorage();
if ($storage->isAuthenticated()) {
// log the action done by the current user
// determine the action name from the application request
$req = $this->getRequest();
Expand Down
6 changes: 2 additions & 4 deletions app/V1Module/router/DeleteRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
*/
class DeleteRoute extends MethodRoute
{

/**
* @param string $mask Mask for the Nette\Application\Routers\Route
* @param string|array $metadata Metadata for the Nette\Application\Routers\Route
* @param int $flags Flags for the Nette\Application\Routers\Route
*/
public function __construct(string $mask, $metadata = [], int $flags = 0)
public function __construct(string $mask, $metadata = [])
{
parent::__construct("DELETE", $mask, $metadata, $flags);
parent::__construct("DELETE", $mask, $metadata);
}
}
6 changes: 2 additions & 4 deletions app/V1Module/router/GetRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
*/
class GetRoute extends MethodRoute
{

/**
* @param string $mask Mask for the Nette\Application\Routers\Route
* @param string|array $metadata Metadata for the Nette\Application\Routers\Route
* @param int $flags Flags for the Nette\Application\Routers\Route
*/
public function __construct(string $mask, $metadata = [], int $flags = 0)
public function __construct(string $mask, $metadata = [])
{
parent::__construct("GET", $mask, $metadata, $flags);
parent::__construct("GET", $mask, $metadata);
}
}
6 changes: 2 additions & 4 deletions app/V1Module/router/MethodRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/
class MethodRoute implements Router
{

/** @var string */
private $method;

Expand All @@ -25,12 +24,11 @@ class MethodRoute implements Router
* @param string $method The HTTP method which is accepted by this route
* @param string $mask Mask for the Nette\Application\Routers\Route
* @param string|array $metadata Metadata for the Nette\Application\Routers\Route
* @param int $flags Flags for the Nette\Application\Routers\Route
*/
public function __construct(string $method, string $mask, $metadata = [], int $flags = 0)
public function __construct(string $method, string $mask, $metadata = [])
{
$this->method = $method;
$this->route = new Route($mask, $metadata, $flags);
$this->route = new Route($mask, $metadata);
}

/**
Expand Down
6 changes: 2 additions & 4 deletions app/V1Module/router/PostRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
*/
class PostRoute extends MethodRoute
{

/**
* @param string $mask Mask for the Nette\Application\Routers\Route
* @param string|array $metadata Metadata for the Nette\Application\Routers\Route
* @param int $flags Flags for the Nette\Application\Routers\Route
*/
public function __construct(string $mask, $metadata = [], int $flags = 0)
public function __construct(string $mask, $metadata = [])
{
parent::__construct("POST", $mask, $metadata, $flags);
parent::__construct("POST", $mask, $metadata);
}
}
6 changes: 2 additions & 4 deletions app/V1Module/router/PutRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
*/
class PutRoute extends MethodRoute
{

/**
* @param string $mask Mask for the Nette\Application\Routers\Route
* @param string|array $metadata Metadata for the Nette\Application\Routers\Route
* @param int $flags Flags for the Nette\Application\Routers\Route
*/
public function __construct(string $mask, $metadata = [], int $flags = 0)
public function __construct(string $mask, $metadata = [])
{
parent::__construct("PUT", $mask, $metadata, $flags);
parent::__construct("PUT", $mask, $metadata);
}
}
5 changes: 3 additions & 2 deletions app/helpers/FileStorage/LocalStorage/LocalHashFileStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ public function storeFile(string $path, bool $move = true): string
}
}
}


// @phpstan-ignore booleanAnd.rightAlwaysTrue
if ($move && file_exists($path)) {
@unlink($path); // the file was copied or already exists, lets simulate move
}
Expand All @@ -123,7 +124,7 @@ public function storeContents($contents): string
if (file_put_contents($newPath, $contents) === false) {
throw new FileStorageException("Saving contents into hash store failed.", $newPath);
}

return $hash;
}

Expand Down
Loading
Loading