Fix PHPStan level 6 errors from CI
- Remove unused AvailabilityRepository/BookingRepository from BookingPage and ShortcodeRegistrar (template is a JS shell; no PHP data needed yet) - Add @param array<string, string> to shortcode render() signatures - Add @return array<string, mixed> to model toArray() methods - Fix get_permalink() ?? '' — returns string|false not nullable, use cast - Remove unused ignoreErrors pattern from phpstan.neon Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,5 +7,3 @@ parameters:
|
|||||||
- src
|
- src
|
||||||
bootstrapFiles:
|
bootstrapFiles:
|
||||||
- tests/bootstrap.php
|
- tests/bootstrap.php
|
||||||
ignoreErrors:
|
|
||||||
- '#Unsafe usage of new static\(\)#'
|
|
||||||
|
|||||||
@@ -3,17 +3,13 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Unsupervised\Schedular\Frontend;
|
namespace Unsupervised\Schedular\Frontend;
|
||||||
|
|
||||||
use Unsupervised\Schedular\Data\AvailabilityRepository;
|
|
||||||
use Unsupervised\Schedular\Data\BookingRepository;
|
|
||||||
use Unsupervised\Schedular\Roles\RoleManager;
|
use Unsupervised\Schedular\Roles\RoleManager;
|
||||||
|
|
||||||
class BookingPage
|
class BookingPage
|
||||||
{
|
{
|
||||||
public function __construct(
|
/**
|
||||||
private AvailabilityRepository $availability,
|
* @param array<string, string> $atts
|
||||||
private BookingRepository $bookings,
|
*/
|
||||||
) {}
|
|
||||||
|
|
||||||
public function render(array $atts): string
|
public function render(array $atts): string
|
||||||
{
|
{
|
||||||
if (! is_user_logged_in()) {
|
if (! is_user_logged_in()) {
|
||||||
|
|||||||
@@ -5,10 +5,13 @@ namespace Unsupervised\Schedular\Frontend;
|
|||||||
|
|
||||||
class LoginPage
|
class LoginPage
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @param array<string, string> $atts
|
||||||
|
*/
|
||||||
public function render(array $atts): string
|
public function render(array $atts): string
|
||||||
{
|
{
|
||||||
if (is_user_logged_in()) {
|
if (is_user_logged_in()) {
|
||||||
$redirect = esc_url(get_permalink());
|
$redirect = esc_url((string) get_permalink());
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'<p>%s <a href="%s">%s</a>.</p>',
|
'<p>%s <a href="%s">%s</a>.</p>',
|
||||||
esc_html__('You are already logged in.', 'unsupervised-schedular'),
|
esc_html__('You are already logged in.', 'unsupervised-schedular'),
|
||||||
@@ -18,7 +21,7 @@ class LoginPage
|
|||||||
}
|
}
|
||||||
|
|
||||||
$error = '';
|
$error = '';
|
||||||
$redirect = sanitize_url(get_permalink() ?? '');
|
$redirect = sanitize_url((string) get_permalink());
|
||||||
|
|
||||||
if (isset($_POST['us_login']) && check_admin_referer('us_student_login')) {
|
if (isset($_POST['us_login']) && check_admin_referer('us_student_login')) {
|
||||||
$credentials = [
|
$credentials = [
|
||||||
|
|||||||
@@ -3,17 +3,14 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Unsupervised\Schedular\Frontend;
|
namespace Unsupervised\Schedular\Frontend;
|
||||||
|
|
||||||
use Unsupervised\Schedular\Data\AvailabilityRepository;
|
|
||||||
use Unsupervised\Schedular\Data\BookingRepository;
|
|
||||||
|
|
||||||
class ShortcodeRegistrar
|
class ShortcodeRegistrar
|
||||||
{
|
{
|
||||||
private BookingPage $bookingPage;
|
private BookingPage $bookingPage;
|
||||||
private LoginPage $loginPage;
|
private LoginPage $loginPage;
|
||||||
|
|
||||||
public function __construct(AvailabilityRepository $availability, BookingRepository $bookings)
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->bookingPage = new BookingPage($availability, $bookings);
|
$this->bookingPage = new BookingPage();
|
||||||
$this->loginPage = new LoginPage();
|
$this->loginPage = new LoginPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ class AvailabilitySlot
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
public function toArray(): array
|
public function toArray(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ class Lesson
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
public function toArray(): array
|
public function toArray(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -23,6 +23,6 @@ class Plugin
|
|||||||
(new RoleManager())->register();
|
(new RoleManager())->register();
|
||||||
(new AdminMenu($availability, $bookings))->register();
|
(new AdminMenu($availability, $bookings))->register();
|
||||||
(new RestRegistrar($availability, $bookings))->register();
|
(new RestRegistrar($availability, $bookings))->register();
|
||||||
(new ShortcodeRegistrar($availability, $bookings))->register();
|
(new ShortcodeRegistrar())->register();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user