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:
2026-03-30 12:59:16 -03:00
parent 0fbafc9d18
commit e24c3ce850
7 changed files with 17 additions and 17 deletions

View File

@@ -7,5 +7,3 @@ parameters:
- src
bootstrapFiles:
- tests/bootstrap.php
ignoreErrors:
- '#Unsafe usage of new static\(\)#'

View File

@@ -3,17 +3,13 @@ declare(strict_types=1);
namespace Unsupervised\Schedular\Frontend;
use Unsupervised\Schedular\Data\AvailabilityRepository;
use Unsupervised\Schedular\Data\BookingRepository;
use Unsupervised\Schedular\Roles\RoleManager;
class BookingPage
{
public function __construct(
private AvailabilityRepository $availability,
private BookingRepository $bookings,
) {}
/**
* @param array<string, string> $atts
*/
public function render(array $atts): string
{
if (! is_user_logged_in()) {

View File

@@ -5,10 +5,13 @@ namespace Unsupervised\Schedular\Frontend;
class LoginPage
{
/**
* @param array<string, string> $atts
*/
public function render(array $atts): string
{
if (is_user_logged_in()) {
$redirect = esc_url(get_permalink());
$redirect = esc_url((string) get_permalink());
return sprintf(
'<p>%s <a href="%s">%s</a>.</p>',
esc_html__('You are already logged in.', 'unsupervised-schedular'),
@@ -18,7 +21,7 @@ class LoginPage
}
$error = '';
$redirect = sanitize_url(get_permalink() ?? '');
$redirect = sanitize_url((string) get_permalink());
if (isset($_POST['us_login']) && check_admin_referer('us_student_login')) {
$credentials = [

View File

@@ -3,17 +3,14 @@ declare(strict_types=1);
namespace Unsupervised\Schedular\Frontend;
use Unsupervised\Schedular\Data\AvailabilityRepository;
use Unsupervised\Schedular\Data\BookingRepository;
class ShortcodeRegistrar
{
private BookingPage $bookingPage;
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();
}

View File

@@ -24,6 +24,9 @@ class AvailabilitySlot
);
}
/**
* @return array<string, mixed>
*/
public function toArray(): array
{
return [

View File

@@ -33,6 +33,9 @@ class Lesson
);
}
/**
* @return array<string, mixed>
*/
public function toArray(): array
{
return [

View File

@@ -23,6 +23,6 @@ class Plugin
(new RoleManager())->register();
(new AdminMenu($availability, $bookings))->register();
(new RestRegistrar($availability, $bookings))->register();
(new ShortcodeRegistrar($availability, $bookings))->register();
(new ShortcodeRegistrar())->register();
}
}