Skip to content
This repository has been archived by the owner on Apr 17, 2024. It is now read-only.

Commit

Permalink
update: remove support for php 7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
darkalchemy committed Jan 24, 2022
1 parent df35dc0 commit 2acbaa4
Show file tree
Hide file tree
Showing 35 changed files with 601 additions and 504 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A Slim 4 Skeleton.

This is a simple skeleton to quickly ramp up a slim 4 project.

PHP 7.4, 8.0 or 8.1 is required
PHP 8 is required
Composer is required
npm/npx is required

Expand Down
2 changes: 1 addition & 1 deletion app/Controller/Account/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ public function __construct(
/**
* @param ResponseInterface $response
*
* @throws SyntaxError
* @throws LoaderError
* @throws RuntimeError
* @throws SyntaxError
*
* @return ResponseInterface
*/
Expand Down
2 changes: 1 addition & 1 deletion app/Controller/Account/AccountPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ public function __construct(
/**
* @param ResponseInterface $response
*
* @throws SyntaxError
* @throws LoaderError
* @throws RuntimeError
* @throws SyntaxError
*
* @return ResponseInterface
*/
Expand Down
4 changes: 2 additions & 2 deletions app/Controller/Auth/Password/PasswordRecoverController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public function __construct(
/**
* @param ResponseInterface $response
*
* @throws SyntaxError
* @throws LoaderError
* @throws RuntimeError
* @throws SyntaxError
*
* @return ResponseInterface
*/
Expand All @@ -80,10 +80,10 @@ public function index(ResponseInterface $response): ResponseInterface
* @param ServerRequestInterface $request
* @param ResponseInterface $response
*
* @throws SyntaxError
* @throws ValidationException
* @throws LoaderError
* @throws RuntimeError
* @throws SyntaxError
*
* @return ResponseInterface
*/
Expand Down
7 changes: 4 additions & 3 deletions app/Controller/Auth/Password/PasswordResetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Cartalyst\Sentinel\Native\Facades\Sentinel;
use Delight\I18n\I18n;
use Exception;
use Monolog\Logger;
use Odan\Session\SessionInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand Down Expand Up @@ -62,7 +63,7 @@ public function __construct(
$this->view = $view;
$this->flash = $flash;
$this->routeParser = $routeParser;
$this->logger = $loggerFactory->addFileHandler('password_reset_controller.log')
$this->logger = $loggerFactory->addFileHandler('password_reset_controller.log', Logger::DEBUG)
->createInstance('password_reset_controller');
$this->rules = $rules;
}
Expand All @@ -71,9 +72,9 @@ public function __construct(
* @param ServerRequestInterface $request
* @param ResponseInterface $response
*
* @throws SyntaxError
* @throws LoaderError
* @throws RuntimeError
* @throws SyntaxError
*
* @return ResponseInterface
*/
Expand Down Expand Up @@ -103,7 +104,7 @@ public function index(ServerRequestInterface $request, ResponseInterface $respon
*/
public function reset(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
{
$data = $this->validate($request, array_merge_recursive(
$data = (array) $this->validate($request, array_merge_recursive(
$this->rules->required('email'),
$this->rules->required('code'),
$this->rules->password(),
Expand Down
7 changes: 4 additions & 3 deletions app/Controller/Auth/SignInController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Cartalyst\Sentinel\Native\Facades\Sentinel;
use Delight\I18n\I18n;
use Exception;
use Monolog\Logger;
use Odan\Session\SessionInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand Down Expand Up @@ -61,7 +62,7 @@ public function __construct(
$this->view = $view;
$this->flash = $flash;
$this->routeParser = $routeParser;
$this->logger = $loggerFactory->addFileHandler('signin_controller.log')
$this->logger = $loggerFactory->addFileHandler('signin_controller.log', Logger::DEBUG)
->createInstance('signin_controller');
$this->rules = $rules;
$this->session->set('current_url', 'auth.signin');
Expand All @@ -71,9 +72,9 @@ public function __construct(
* @param ServerRequestInterface $request The request
* @param ResponseInterface $response The response
*
* @throws SyntaxError
* @throws LoaderError
* @throws RuntimeError
* @throws SyntaxError
*
* @return ResponseInterface
*/
Expand All @@ -94,7 +95,7 @@ public function index(ServerRequestInterface $request, ResponseInterface $respon
*/
public function signin(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
{
$data = $this->validate($request, array_merge_recursive(
$data = (array) $this->validate($request, array_merge_recursive(
$this->rules->email(),
$this->rules->required('password')
));
Expand Down
7 changes: 4 additions & 3 deletions app/Controller/Auth/SignUpController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Cartalyst\Sentinel\Native\Facades\Sentinel;
use Delight\I18n\I18n;
use Exception;
use Monolog\Logger;
use Odan\Session\SessionInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand Down Expand Up @@ -65,7 +66,7 @@ public function __construct(
$this->view = $view;
$this->flash = $flash;
$this->routeParser = $routeParser;
$this->logger = $loggerFactory->addFileHandler('signup_controller.log')
$this->logger = $loggerFactory->addFileHandler('signup_controller.log', Logger::DEBUG)
->createInstance('signup_controller');
$this->rules = $rules;
$this->storeMail = $storeMail;
Expand All @@ -75,9 +76,9 @@ public function __construct(
/**
* @param ResponseInterface $response The response
*
* @throws LoaderError
* @throws RuntimeError
* @throws SyntaxError
* @throws LoaderError
*
* @return ResponseInterface
*/
Expand All @@ -96,7 +97,7 @@ public function index(ResponseInterface $response): ResponseInterface
*/
public function signup(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
{
$data = $this->validate($request, array_merge_recursive(
$data = (array) $this->validate($request, array_merge_recursive(
$this->rules->email(),
$this->rules->email_unique(),
$this->rules->username(),
Expand Down
3 changes: 2 additions & 1 deletion app/Controller/Auth/UserActivateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Cartalyst\Sentinel\Native\Facades\Sentinel;
use Delight\I18n\I18n;
use Exception;
use Monolog\Logger;
use Odan\Session\SessionInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand Down Expand Up @@ -49,7 +50,7 @@ public function __construct(
parent::__construct($session, $i18n);
$this->flash = $flash;
$this->routeParser = $routeParser;
$this->logger = $loggerFactory->addFileHandler('activate_controller.log')
$this->logger = $loggerFactory->addFileHandler('activate_controller.log', Logger::DEBUG)
->createInstance('activate_controller');
}

Expand Down
7 changes: 4 additions & 3 deletions app/Controller/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class Controller
/**
* Controller constructor.
*
* @param I18n $i18n
* @param SessionInterface $session
* @param I18n $i18n
*/
public function __construct(SessionInterface $session, I18n $i18n)
{
Expand All @@ -39,11 +40,11 @@ public function __construct(SessionInterface $session, I18n $i18n)
*
* @return null|array|object
*/
public function validate(ServerRequestInterface $request, array $rules = [])
public function validate(ServerRequestInterface $request, array $rules = []): object|array|null
{
Validator::langDir(VENDOR_DIR . 'vlucas/valitron/lang/');
Validator::lang(substr($this->locale, 0, 2));
$params = $request->getParsedBody();
$params = (array) $request->getParsedBody();
$validator = new Validator($params);
$validator->mapFieldsRules($rules);
if (!$validator->validate()) {
Expand Down
2 changes: 1 addition & 1 deletion app/Controller/Dashboard/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public function __construct(Twig $view)
/**
* @param ResponseInterface $response
*
* @throws LoaderError
* @throws RuntimeError
* @throws SyntaxError
* @throws LoaderError
*
* @return ResponseInterface
*/
Expand Down
2 changes: 1 addition & 1 deletion app/Controller/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public function __construct(Twig $view)
/**
* @param ResponseInterface $response
*
* @throws LoaderError
* @throws RuntimeError
* @throws SyntaxError
* @throws LoaderError
*
* @return ResponseInterface
*/
Expand Down
5 changes: 3 additions & 2 deletions app/Exception/ExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Factory\LoggerFactory;
use Exception;
use Monolog\Logger;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand Down Expand Up @@ -47,7 +48,7 @@ public function __construct(
$this->flash = $flash;
$this->responseFactory = $responseFactory;
$this->view = $view;
$this->logger = $loggerFactory->addFileHandler('exception_handler.log')
$this->logger = $loggerFactory->addFileHandler('exception_handler.log', Logger::DEBUG)
->createInstance('exception_handler');
}

Expand All @@ -59,7 +60,7 @@ public function __construct(
*
* @return mixed
*/
public function __invoke(ServerRequestInterface $request, Throwable $exception)
public function __invoke(ServerRequestInterface $request, Throwable $exception): mixed
{
if (method_exists($this, $handle = 'handle' . (new ReflectionClass($exception))->getShortName())) {
return $this->{$handle}($exception);
Expand Down
25 changes: 7 additions & 18 deletions app/Factory/LoggerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace App\Factory;

use Exception;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Handler\StreamHandler;
Expand All @@ -21,11 +20,6 @@ class LoggerFactory
*/
private string $path;

/**
* @var int
*/
private int $level;

/**
* @var array Handler
*/
Expand All @@ -38,8 +32,7 @@ class LoggerFactory
*/
public function __construct(array $settings)
{
$this->path = (string) $settings['path'];
$this->level = (int) $settings['level'];
$this->path = (string) $settings['path'];
}

/**
Expand All @@ -63,14 +56,12 @@ public function createInstance(string $name): LoggerInterface
}

/**
* @param string $filename
* @param null|int $level
*
* @throws Exception
* @param string $filename
* @param int $level
*
* @return $this
*/
public function addFileHandler(string $filename, int $level = null): self
public function addFileHandler(string $filename, int $level): self
{
if (!is_writeable($this->path)) {
exit(_fe(
Expand All @@ -79,7 +70,7 @@ public function addFileHandler(string $filename, int $level = null): self
));
}
$filename = sprintf('%s/%s', $this->path, $filename);
$rotatingFileHandler = new RotatingFileHandler($filename, 0, $level ?? $this->level, true, 0755);
$rotatingFileHandler = new RotatingFileHandler($filename, 0, $level, true, 0755);

// The last "true" here tells monolog to remove empty []'s
$rotatingFileHandler->setFormatter(new LineFormatter(null, null, false, true));
Expand All @@ -92,13 +83,11 @@ public function addFileHandler(string $filename, int $level = null): self
/**
* Add a console logger.
*
* @param null|int $level The level (optional)
*
* @return self The instance
*/
public function addConsoleHandler(int $level = null): self
public function addConsoleHandler(int $level): self
{
$streamHandler = new StreamHandler('php://stdout', $level ?? $this->level);
$streamHandler = new StreamHandler('php://stdout', $level);
$streamHandler->setFormatter(new LineFormatter(null, null, false, true));

$this->handler[] = $streamHandler;
Expand Down
3 changes: 2 additions & 1 deletion app/Middleware/CheckSettingsMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Factory\LoggerFactory;
use Exception;
use Monolog\Logger;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
Expand Down Expand Up @@ -34,7 +35,7 @@ class CheckSettingsMiddleware implements MiddlewareInterface
public function __construct(array $settings, LoggerFactory $loggerFactory, Messages $flash)
{
$this->settings = $settings;
$this->logger = $loggerFactory->addFileHandler('settings.log')->createInstance('settings');
$this->logger = $loggerFactory->addFileHandler('settings.log', Logger::DEBUG)->createInstance('settings');
$this->flash = $flash;
}

Expand Down
7 changes: 5 additions & 2 deletions app/Middleware/RedirectIfAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ class RedirectIfAuthenticated
* @param Messages $flash The flash
* @param RouteParserInterface $routeParser The routeParser
*/
public function __construct(Messages $flash, RouteParserInterface $routeParser, ResponseFactoryInterface $responseFactory)
{
public function __construct(
Messages $flash,
RouteParserInterface $routeParser,
ResponseFactoryInterface $responseFactory
) {
$this->flash = $flash;
$this->routeParser = $routeParser;
$this->responseFactory = $responseFactory;
Expand Down
7 changes: 5 additions & 2 deletions app/Middleware/RedirectIfNotAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ class RedirectIfNotAuthenticated
* @param Messages $flash The flash
* @param RouteParserInterface $routeParser The routeParser
*/
public function __construct(Messages $flash, RouteParserInterface $routeParser, ResponseFactoryInterface $responseFactory)
{
public function __construct(
Messages $flash,
RouteParserInterface $routeParser,
ResponseFactoryInterface $responseFactory
) {
$this->flash = $flash;
$this->routeParser = $routeParser;
$this->responseFactory = $responseFactory;
Expand Down
2 changes: 1 addition & 1 deletion app/Migration/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Migration extends AbstractMigration
{
protected Builder $schema;

public function init()
public function init(): void
{
$this->schema = Capsule::schema();
}
Expand Down
5 changes: 4 additions & 1 deletion app/Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
use Illuminate\Database\Eloquent\Relations\HasMany;

/**
* Class User.
* @property string email
* @property string username
* @property string password
* @property string permissions
*/
class User extends EloquentUser
{
Expand Down
Loading

0 comments on commit 2acbaa4

Please sign in to comment.