diff --git a/Domain/Access/ScheduleRepository.php b/Domain/Access/ScheduleRepository.php index 4c39b3c29..693b20234 100644 --- a/Domain/Access/ScheduleRepository.php +++ b/Domain/Access/ScheduleRepository.php @@ -282,7 +282,6 @@ public function GetLayout($scheduleId, ILayoutFactory $layoutFactory) { $reader = ServiceLocator::GetDatabase()->Query(new GetLayoutCommand($scheduleId)); - /** @var ScheduleLayout $layout */ $layout = null; while ($row = $reader->GetRow()) { @@ -309,6 +308,10 @@ public function GetLayout($scheduleId, ILayoutFactory $layoutFactory) } $reader->Free(); + if ($layout == null) { + $layout = $layoutFactory->CreateLayout(); + } + $reader = ServiceLocator::GetDatabase()->Query(new GetPeakTimesCommand($scheduleId)); if ($row = $reader->GetRow()) { $layout->ChangePeakTimes(PeakTimes::FromRow($row)); diff --git a/Domain/PaymentGateway.php b/Domain/PaymentGateway.php index f4c33f933..ae228dc93 100644 --- a/Domain/PaymentGateway.php +++ b/Domain/PaymentGateway.php @@ -588,10 +588,12 @@ public function Charge(CreditCartSession $cart, $email, $token, IPaymentTransact Log::Debug('Stripe charge response %s', json_encode($charge)); } + $chargeData = $charge->toArray(); + $logger->LogPayment( $cart->UserId, $charge->status, - $charge->invoice, + $chargeData['invoice'] ?? null, $charge->id, $currency->FromStripe($charge->amount), $currency->FromStripe($charge->balance_transaction->fee), diff --git a/Domain/RepeatOptions.php b/Domain/RepeatOptions.php index 5e5b311f7..be4568cc5 100644 --- a/Domain/RepeatOptions.php +++ b/Domain/RepeatOptions.php @@ -301,6 +301,10 @@ public function ConfigurationString() public function HasSameConfigurationAs(IRepeatOptions $repeatOptions) { + if (!$repeatOptions instanceof self) { + return false; + } + return parent::HasSameConfigurationAs($repeatOptions) && $this->_daysOfWeek == $repeatOptions->_daysOfWeek; } } diff --git a/Domain/ReservationItemView.php b/Domain/ReservationItemView.php index 383c733b6..14f456729 100644 --- a/Domain/ReservationItemView.php +++ b/Domain/ReservationItemView.php @@ -120,6 +120,8 @@ public function GetLabel(); * @return int */ public function GetScheduleId(); + + public function IsUserParticipating(int $userId): bool; } class ReservationItemView implements IReservedItemView @@ -785,7 +787,7 @@ public function IsUserOwner($userId) * @param $userId int * @return bool */ - public function IsUserParticipating($userId) + public function IsUserParticipating(int $userId): bool { return in_array($userId, $this->ParticipantIds); } diff --git a/Domain/ScheduleLayout.php b/Domain/ScheduleLayout.php index d6fa27169..5aac8e4f0 100644 --- a/Domain/ScheduleLayout.php +++ b/Domain/ScheduleLayout.php @@ -979,9 +979,9 @@ class LayoutPeriod public $End; /** - * @var PeriodTypes + * @var int */ - public $PeriodType; + public int $PeriodType; /** * @var string diff --git a/Pages/SchedulePage.php b/Pages/SchedulePage.php index 8af67f853..b743294be 100644 --- a/Pages/SchedulePage.php +++ b/Pages/SchedulePage.php @@ -120,6 +120,8 @@ public function GetOwnerText(); */ public function GetParticipantId(); + public function GetGroupId(): int|null; + /** * @return string */ @@ -666,6 +668,16 @@ public function GetParticipantId() return intval($id); } + public function GetGroupId(): int|null + { + $id = $this->GetQuerystring(QueryStringKeys::GROUP_ID); + if (empty($id)) { + return null; + } + + return intval($id); + } + public function GetOwnerText() { return $this->GetQuerystring(FormKeys::OWNER_TEXT); diff --git a/Presenters/Admin/Import/ICalImportPresenter.php b/Presenters/Admin/Import/ICalImportPresenter.php index e99bae12d..978b0987c 100644 --- a/Presenters/Admin/Import/ICalImportPresenter.php +++ b/Presenters/Admin/Import/ICalImportPresenter.php @@ -93,7 +93,7 @@ public function Import() die('Invalid import file: ' . $e->getMessage()); } - $events = $vcalendar->VEVENT; + $events = $vcalendar->select('VEVENT'); Log::Debug('Found %s events in ics file', count($events)); foreach ($events as $event) { diff --git a/Presenters/ParticipationPresenter.php b/Presenters/ParticipationPresenter.php index 4407de38a..4466f8929 100644 --- a/Presenters/ParticipationPresenter.php +++ b/Presenters/ParticipationPresenter.php @@ -80,13 +80,15 @@ private function HandleInvitationAction($invitationAction) $series = $this->reservationRepository->LoadByReferenceNumber($referenceNumber); + /** @var IReservationValidationRule[] $rules */ + $rules = []; + if ($invitationAction == InvitationAction::Join || $invitationAction == InvitationAction::CancelInstance) { $rules = [new ReservationStartTimeRule(new ScheduleRepository()), new ResourceMinimumNoticeCurrentInstanceRuleUpdate($user), new ResourceMaximumNoticeCurrentInstanceRule($user)]; } else { $rules = [new ReservationStartTimeRule(new ScheduleRepository()), new ResourceMinimumNoticeRuleAdd($user), new ResourceMaximumNoticeRule($user)]; } - /** @var IReservationValidationRule $rule */ foreach ($rules as $rule) { $ruleResult = $rule->Validate($series, null); diff --git a/Presenters/ResourceDisplayPresenter.php b/Presenters/ResourceDisplayPresenter.php index 321e0008d..3b1422e9d 100644 --- a/Presenters/ResourceDisplayPresenter.php +++ b/Presenters/ResourceDisplayPresenter.php @@ -197,7 +197,7 @@ public function DisplayResource($resourcePublicId, $startDate) $reservationList = $reservations->OnDateForResource($reservationDate, $resource->GetId()); - /** @var ReservationListItem $next */ + /** @var ReservationListItem|null $next */ $next = null; /** @var ReservationListItem[] $upcoming */ diff --git a/Presenters/ViewSchedulesPresenter.php b/Presenters/ViewSchedulesPresenter.php index 6f9707e11..f4861adde 100644 --- a/Presenters/ViewSchedulesPresenter.php +++ b/Presenters/ViewSchedulesPresenter.php @@ -4,10 +4,7 @@ class ViewSchedulesPresenter { - /** - * @var ResourceViewerViewResourcesPage - */ - private $page; + private ScheduleViewerViewSchedulesPage $page; /** * @var IResourceRepository diff --git a/WebServices/SchedulesWebService.php b/WebServices/SchedulesWebService.php index 7a6615523..06bcc6119 100644 --- a/WebServices/SchedulesWebService.php +++ b/WebServices/SchedulesWebService.php @@ -317,7 +317,7 @@ public function SetScheduleStyle($direction) // no op } - public function GetGroupId() + public function GetGroupId(): int|null { return null; } diff --git a/WebServices/Validators/AccountRequestValidator.php b/WebServices/Validators/AccountRequestValidator.php index 5a76b4539..7ebd4acd6 100644 --- a/WebServices/Validators/AccountRequestValidator.php +++ b/WebServices/Validators/AccountRequestValidator.php @@ -76,11 +76,12 @@ public function ValidateUpdate($request, WebServiceUserSession $session) public function ValidatePasswordUpdate($request, WebServiceUserSession $session) { + /** @var IValidator[] $validators */ + $validators = []; $validators[] = new PasswordComplexityValidator($request->newPassword); $validators[] = new PasswordValidator($request->currentPassword, $this->userRepository->LoadById($session->UserId)); $errors = []; - /** @var IValidator $validator */ foreach ($validators as $validator) { $validator->Validate(); if (!$validator->IsValid()) { diff --git a/WebServices/Validators/ResourceRequestValidator.php b/WebServices/Validators/ResourceRequestValidator.php index 56bb7aa72..80903c259 100644 --- a/WebServices/Validators/ResourceRequestValidator.php +++ b/WebServices/Validators/ResourceRequestValidator.php @@ -56,6 +56,8 @@ private function ValidateCommon($request) } $errors = []; + /** @var IValidator[] $validators */ + $validators = []; $validators[] = new RequestRequiredValueValidator($request->name, 'name'); $validators[] = new RequestRequiredValueValidator($request->scheduleId, 'scheduleId'); $validators[] = new TimeIntervalValidator($request->minLength, 'minLength'); @@ -70,7 +72,6 @@ private function ValidateCommon($request) $validators[] = new AttributeValidator($this->attributeService, CustomAttributeCategory::RESOURCE, $attributes); - /** @var IValidator $validator */ foreach ($validators as $validator) { $validator->Validate(); if (!$validator->IsValid()) { diff --git a/composer.json b/composer.json index ea99adf2b..795e27b8d 100644 --- a/composer.json +++ b/composer.json @@ -8,12 +8,13 @@ "squizlabs/php_codesniffer": "^3.7.1", "phpcompatibility/php-compatibility": "^9.3.5", "phpunit/phpunit": "^11.3", - "phpstan/phpstan": "^2.1" + "phpstan/phpstan": "^2.1", + "phpstan/phpstan-phpunit": "^2.0" }, "require": { "php": ">=8.2", "smarty/smarty": "^5.5", - "stripe/stripe-php": "^10.2", + "stripe/stripe-php": "^19.3", "monolog/monolog": "^3.10", "google/recaptcha": "1.3.*", "gregwar/captcha": "^1.3", diff --git a/composer.lock b/composer.lock index 2c122bf70..c0287d992 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "fb7c0cc85feb0abaf8d0988e999da59d", + "content-hash": "397754ac2b60a9f6711eeec5879992b0", "packages": [ { "name": "bacon/bacon-qr-code", @@ -3933,16 +3933,16 @@ }, { "name": "stripe/stripe-php", - "version": "v10.21.0", + "version": "v19.3.0", "source": { "type": "git", "url": "https://github.com/stripe/stripe-php.git", - "reference": "b4ab319731958077227fad1874a3671458c5d593" + "reference": "462272ae7560ee29bb891763fd0967d5a77784e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/stripe/stripe-php/zipball/b4ab319731958077227fad1874a3671458c5d593", - "reference": "b4ab319731958077227fad1874a3671458c5d593", + "url": "https://api.github.com/repos/stripe/stripe-php/zipball/462272ae7560ee29bb891763fd0967d5a77784e5", + "reference": "462272ae7560ee29bb891763fd0967d5a77784e5", "shasum": "" }, "require": { @@ -3952,11 +3952,9 @@ "php": ">=5.6.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "3.5.0", - "php-coveralls/php-coveralls": "^2.5", + "friendsofphp/php-cs-fixer": "3.72.0", "phpstan/phpstan": "^1.2", - "phpunit/phpunit": "^5.7 || ^9.0", - "squizlabs/php_codesniffer": "^3.3" + "phpunit/phpunit": "^5.7 || ^9.0" }, "type": "library", "extra": { @@ -3988,9 +3986,9 @@ ], "support": { "issues": "https://github.com/stripe/stripe-php/issues", - "source": "https://github.com/stripe/stripe-php/tree/v10.21.0" + "source": "https://github.com/stripe/stripe-php/tree/v19.3.0" }, - "time": "2023-08-11T00:23:24+00:00" + "time": "2026-01-28T21:15:45+00:00" }, { "name": "symfony/deprecation-contracts", @@ -5541,6 +5539,62 @@ ], "time": "2026-02-11T14:48:56+00:00" }, + { + "name": "phpstan/phpstan-phpunit", + "version": "2.0.16", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-phpunit.git", + "reference": "6ab598e1bc106e6827fd346ae4a12b4a5d634c32" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/6ab598e1bc106e6827fd346ae4a12b4a5d634c32", + "reference": "6ab598e1bc106e6827fd346ae4a12b4a5d634c32", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.1.32" + }, + "conflict": { + "phpunit/phpunit": "<7.0" + }, + "require-dev": { + "nikic/php-parser": "^5", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-deprecation-rules": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.6" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "extension.neon", + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPUnit extensions and rules for PHPStan", + "keywords": [ + "static analysis" + ], + "support": { + "issues": "https://github.com/phpstan/phpstan-phpunit/issues", + "source": "https://github.com/phpstan/phpstan-phpunit/tree/2.0.16" + }, + "time": "2026-02-14T09:05:21+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "11.0.12", @@ -8758,5 +8812,5 @@ "platform-overrides": { "php": "8.2.0" }, - "plugin-api-version": "2.9.0" + "plugin-api-version": "2.6.0" } diff --git a/lib/Application/Reservation/ReservationComponentBinder.php b/lib/Application/Reservation/ReservationComponentBinder.php index 54f123e2d..f2bca6955 100644 --- a/lib/Application/Reservation/ReservationComponentBinder.php +++ b/lib/Application/Reservation/ReservationComponentBinder.php @@ -178,7 +178,7 @@ public function Bind(IReservationComponentInitializer $initializer) $resources = $groups->GetAllResources(); if (empty($requestedResourceId) && count($resources) > 0) { $first = reset($resources); - $requestedResourceId = $first->Id; + $requestedResourceId = $first->GetId(); } $bindableResourceData = $this->GetBindableResourceData($resources, $requestedResourceId); diff --git a/lib/Application/Reservation/ResourceTypeFilter.php b/lib/Application/Reservation/ResourceTypeFilter.php index 8d023ca55..d25ace705 100644 --- a/lib/Application/Reservation/ResourceTypeFilter.php +++ b/lib/Application/Reservation/ResourceTypeFilter.php @@ -25,6 +25,10 @@ public function __construct($resourcetypename) */ public function ShouldInclude($assignment) { + if (!$assignment instanceof IBookableResource) { + return false; + } + return in_array($assignment->GetResourceTypeId(), $this->resourcetypeids); } } diff --git a/lib/Application/Schedule/ReservationListItem.php b/lib/Application/Schedule/ReservationListItem.php index 6986bc7a3..96b7ebc76 100644 --- a/lib/Application/Schedule/ReservationListItem.php +++ b/lib/Application/Schedule/ReservationListItem.php @@ -12,6 +12,11 @@ public function __construct(IReservedItemView $reservedItem) $this->item = $reservedItem; } + public function ReservedItem(): IReservedItemView + { + return $this->item; + } + /** * @return Date */ @@ -311,6 +316,8 @@ class BufferItem extends ReservationListItem */ private $location; + private ReservationListItem $reservationItem; + /** * @var Date */ @@ -323,22 +330,22 @@ class BufferItem extends ReservationListItem public function __construct(ReservationListItem $item, $location) { - parent::__construct($item->item); - $this->item = $item; + parent::__construct($item->ReservedItem()); + $this->reservationItem = $item; $this->location = $location; if ($this->IsBefore()) { - $this->startDate = $this->item->StartDate()->SubtractInterval($this->item->BufferTime()); - $this->endDate = $this->item->StartDate(); + $this->startDate = $this->reservationItem->StartDate()->SubtractInterval($this->reservationItem->BufferTime()); + $this->endDate = $this->reservationItem->StartDate(); } else { - $this->startDate = $this->item->EndDate(); - $this->endDate = $this->item->EndDate()->AddInterval($this->item->BufferTime()); + $this->startDate = $this->reservationItem->EndDate(); + $this->endDate = $this->reservationItem->EndDate()->AddInterval($this->reservationItem->BufferTime()); } } public function BuildSlot(SchedulePeriod $start, SchedulePeriod $end, Date $displayDate, $span) { - return new BufferSlot($start, $end, $displayDate, $span, $this->item->item); + return new BufferSlot($start, $end, $displayDate, $span, $this->reservationItem->ReservedItem()); } /** @@ -364,7 +371,7 @@ private function IsBefore() public function OccursOn(Date $date) { - return $this->item->OccursOn($date); + return $this->reservationItem->OccursOn($date); } public function Id() diff --git a/lib/Application/Schedule/ReservationService.php b/lib/Application/Schedule/ReservationService.php index f5b27f27d..775797227 100644 --- a/lib/Application/Schedule/ReservationService.php +++ b/lib/Application/Schedule/ReservationService.php @@ -20,7 +20,10 @@ public function __construct(IReservationViewRepository $repository, IReservation public function GetReservations(DateRange $dateRangeUtc, $scheduleId, $targetTimezone, $resourceIds = null) { - $filterResourcesInCode = $resourceIds != null && is_array($resourceIds) && count($resourceIds) > 100; + $filterResourcesInCode = false; + if (is_array($resourceIds)) { + $filterResourcesInCode = count($resourceIds) > 100; + } $resourceKeys = []; if ($filterResourcesInCode) { $resourceKeys = array_combine($resourceIds, $resourceIds); @@ -44,9 +47,7 @@ public function GetReservations(DateRange $dateRangeUtc, $scheduleId, $targetTim ); foreach ($reservations as $reservation) { - if ($filterResourcesInCode && array_key_exists($reservation->ResourceId, $resourceKeys)) { - $reservationListing->Add($reservation); - } else { + if (!$filterResourcesInCode || array_key_exists($reservation->ResourceId, $resourceKeys)) { $reservationListing->Add($reservation); } } @@ -85,7 +86,7 @@ interface IReservationService * @param DateRange $dateRangeUtc range of dates to search against in UTC * @param int $scheduleId * @param string $targetTimezone timezone to convert the results to - * @param null|int $resourceIds + * @param null|int[] $resourceIds * @return IReservationListing */ public function GetReservations(DateRange $dateRangeUtc, $scheduleId, $targetTimezone, $resourceIds = null); diff --git a/lib/Application/Schedule/ResourceService.php b/lib/Application/Schedule/ResourceService.php index 6a4b6be25..93f3880b9 100644 --- a/lib/Application/Schedule/ResourceService.php +++ b/lib/Application/Schedule/ResourceService.php @@ -44,12 +44,12 @@ public function GetResourceGroups($scheduleId, UserSession $user); public function GetResourceTypes(); /** - * @return Attribute[] + * @return LBAttribute[] */ public function GetResourceAttributes(); /** - * @return Attribute[] + * @return LBAttribute[] */ public function GetResourceTypeAttributes(); @@ -222,7 +222,7 @@ public function GetResourceTypes() } /** - * @return Attribute[] + * @return LBAttribute[] */ public function GetResourceAttributes() { @@ -236,7 +236,7 @@ public function GetResourceAttributes() } /** - * @return Attribute[] + * @return LBAttribute[] */ public function GetResourceTypeAttributes() { diff --git a/lib/Application/Schedule/ScheduleResourceFilter.php b/lib/Application/Schedule/ScheduleResourceFilter.php index 7d364b3ca..76ddc854b 100644 --- a/lib/Application/Schedule/ScheduleResourceFilter.php +++ b/lib/Application/Schedule/ScheduleResourceFilter.php @@ -160,9 +160,9 @@ public function FilterResources($resources, IResourceRepository $resourceReposit } /** - * @param Attribute[] $attributes + * @param LBAttribute[] $attributes * @param int $attributeId - * @return null|Attribute + * @return null|LBAttribute */ private function GetAttribute($attributes, $attributeId) { @@ -176,7 +176,7 @@ private function GetAttribute($attributes, $attributeId) /** * @param AttributeValue $attribute - * @param Attribute $value + * @param LBAttribute|null $value * @return bool */ private function AttributeValueMatches($attribute, $value) diff --git a/lib/Common/ServiceLocator.php b/lib/Common/ServiceLocator.php index 7488db450..a7ec6e52b 100644 --- a/lib/Common/ServiceLocator.php +++ b/lib/Common/ServiceLocator.php @@ -46,7 +46,7 @@ public static function SetDatabase(Database $database) } /** - * @return Server + * @return IRestServer|null */ public static function GetApiServer(): IRestServer|null { diff --git a/lib/Database/MySQL/MySqlConnection.php b/lib/Database/MySQL/MySqlConnection.php index 30da6a958..5b106a601 100644 --- a/lib/Database/MySQL/MySqlConnection.php +++ b/lib/Database/MySQL/MySqlConnection.php @@ -87,6 +87,12 @@ public function Query(ISqlCommand $sqlCommand) public function LimitQuery(ISqlCommand $command, $limit, $offset = 0) { + if (!$command instanceof SqlCommand) { + throw new InvalidArgumentException( + sprintf('MySqlConnection::LimitQuery requires %s, got %s', SqlCommand::class, get_debug_type($command)) + ); + } + return $this->Query(new MySqlLimitCommand($command, $limit, $offset)); } @@ -132,21 +138,20 @@ private function _handleError($result) class MySqlLimitCommand extends SqlCommand { /** - * @var \ISqlCommand + * @var SqlCommand */ private $baseCommand; private $limit; private $offset; - public function __construct(ISqlCommand $baseCommand, $limit, $offset) + public function __construct(SqlCommand $baseCommand, $limit, $offset) { parent::__construct(); $this->baseCommand = $baseCommand; $this->limit = $limit; $this->offset = $offset; - $this->Parameters = $baseCommand->Parameters; } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon deleted file mode 100644 index aa376af4a..000000000 --- a/phpstan-baseline.neon +++ /dev/null @@ -1,536 +0,0 @@ -parameters: - ignoreErrors: - - - message: '#^PHPDoc tag @var with type ScheduleLayout is not subtype of native type null\.$#' - identifier: varTag.nativeType - count: 1 - path: Domain/Access/ScheduleRepository.php - - - - message: '#^Access to an undefined property IRepeatOptions\:\:\$_daysOfWeek\.$#' - identifier: property.notFound - count: 1 - path: Domain/RepeatOptions.php - - - - message: '#^Comparison operation "\=\=" between PeriodTypes and 1 results in an error\.$#' - identifier: equal.invalid - count: 2 - path: Domain/ScheduleLayout.php - - - - message: '#^Access to an undefined property Sabre\\VObject\\Document\:\:\$VEVENT\.$#' - identifier: property.notFound - count: 1 - path: Presenters/Admin/Import/ICalImportPresenter.php - - - - message: '#^PHPDoc tag @var with type IReservationValidationRule is not subtype of native type ReservationStartTimeRule\|ResourceMaximumNoticeCurrentInstanceRule\|ResourceMaximumNoticeRule\|ResourceMinimumNoticeCurrentInstanceRuleUpdate\|ResourceMinimumNoticeRuleAdd\.$#' - identifier: varTag.nativeType - count: 1 - path: Presenters/ParticipationPresenter.php - - - - message: '#^PHPDoc tag @var with type ReservationListItem is not subtype of native type null\.$#' - identifier: varTag.nativeType - count: 1 - path: Presenters/ResourceDisplayPresenter.php - - - - message: '#^Call to an undefined method ISchedulePage\:\:GetGroupId\(\)\.$#' - identifier: method.notFound - count: 1 - path: Presenters/Schedule/SchedulePageBuilder.php - - - - message: '#^Call to an undefined method ResourceViewerViewResourcesPage\:\:BindGroups\(\)\.$#' - identifier: method.notFound - count: 1 - path: Presenters/ViewSchedulesPresenter.php - - - - message: '#^Call to an undefined method ResourceViewerViewResourcesPage\:\:BindSchedules\(\)\.$#' - identifier: method.notFound - count: 1 - path: Presenters/ViewSchedulesPresenter.php - - - - message: '#^PHPDoc tag @var with type IValidator is not subtype of native type PasswordComplexityValidator\|PasswordValidator\.$#' - identifier: varTag.nativeType - count: 1 - path: WebServices/Validators/AccountRequestValidator.php - - - - message: '#^PHPDoc tag @var with type IValidator is not subtype of native type AttributeValidator\|RequestRequiredValueValidator\|TimeIntervalValidator\.$#' - identifier: varTag.nativeType - count: 1 - path: WebServices/Validators/ResourceRequestValidator.php - - - - message: '#^Access to an undefined property IBookableResource\:\:\$Id\.$#' - identifier: property.notFound - count: 1 - path: lib/Application/Reservation/ReservationComponentBinder.php - - - - message: '#^Call to an undefined method IResource\:\:GetResourceTypeId\(\)\.$#' - identifier: method.notFound - count: 1 - path: lib/Application/Reservation/ResourceTypeFilter.php - - - - message: '#^Access to an undefined property IReservedItemView\:\:\$item\.$#' - identifier: property.notFound - count: 1 - path: lib/Application/Schedule/ReservationListItem.php - - - - message: '#^Call to an undefined method IReservedItemView\:\:IsUserParticipating\(\)\.$#' - identifier: method.notFound - count: 1 - path: lib/Application/Schedule/ReservationListItem.php - - - - message: '#^Comparison operation "\>" between \*NEVER\* and 100 results in an error\.$#' - identifier: greater.invalid - count: 1 - path: lib/Application/Schedule/ReservationService.php - - - - message: '#^Call to an undefined method Attribute\:\:Id\(\)\.$#' - identifier: method.notFound - count: 1 - path: lib/Application/Schedule/ScheduleResourceFilter.php - - - - message: '#^Call to an undefined method Attribute\:\:Type\(\)\.$#' - identifier: method.notFound - count: 2 - path: lib/Application/Schedule/ScheduleResourceFilter.php - - - - message: '#^Call to an undefined method Attribute\:\:Value\(\)\.$#' - identifier: method.notFound - count: 4 - path: lib/Application/Schedule/ScheduleResourceFilter.php - - - - message: '#^PHPDoc tag @return with type Server is not subtype of native type IRestServer\|null\.$#' - identifier: return.phpDocType - count: 1 - path: lib/Common/ServiceLocator.php - - - - message: '#^Access to an undefined property ISqlCommand\:\:\$Parameters\.$#' - identifier: property.notFound - count: 1 - path: lib/Database/MySQL/MySqlConnection.php - - - - message: '#^Call to an undefined method Attribute\:\:Id\(\)\.$#' - identifier: method.notFound - count: 4 - path: tests/Application/Attributes/AttributeServiceTest.php - - - - message: '#^Access to an undefined property IPassword\:\:\$Encryption\.$#' - identifier: property.notFound - count: 1 - path: tests/Application/Authentication/PasswordMigrationTest.php - - - - message: '#^Call to an undefined method IUserRepository\:\:expects\(\)\.$#' - identifier: method.notFound - count: 10 - path: tests/Application/Authentication/RegistrationTest.php - - - - message: '#^Call to an undefined method IUserSessionRepository\:\:expects\(\)\.$#' - identifier: method.notFound - count: 7 - path: tests/Application/Authentication/WebServiceAuthenticationTest.php - - - - message: '#^Call to an undefined method IScheduleLayout\:\:expects\(\)\.$#' - identifier: method.notFound - count: 2 - path: tests/Application/Reservation/ReservationStartTimeRuleTest.php - - - - message: '#^Call to an undefined method IScheduleRepository\:\:expects\(\)\.$#' - identifier: method.notFound - count: 2 - path: tests/Application/Reservation/ReservationStartTimeRuleTest.php - - - - message: '#^Call to an undefined method IScheduleRepository\:\:expects\(\)\.$#' - identifier: method.notFound - count: 2 - path: tests/Application/Reservation/ResourceCrossDayRuleTest.php - - - - message: '#^Call to an undefined method IScheduleLayout\:\:expects\(\)\.$#' - identifier: method.notFound - count: 3 - path: tests/Application/Reservation/SchedulePeriodRuleTest.php - - - - message: '#^Call to an undefined method IScheduleRepository\:\:expects\(\)\.$#' - identifier: method.notFound - count: 3 - path: tests/Application/Reservation/SchedulePeriodRuleTest.php - - - - message: '#^Call to an undefined method Attribute\:\:Id\(\)\.$#' - identifier: method.notFound - count: 2 - path: tests/Application/Schedule/ResourceServiceTest.php - - - - message: '#^Call to an undefined method IAccessoryRepository\:\:expects\(\)\.$#' - identifier: method.notFound - count: 1 - path: tests/Application/Schedule/ResourceServiceTest.php - - - - message: '#^Binary operation "\." between non\-falsy\-string and IReservationSlot results in an error\.$#' - identifier: binaryOp.invalid - count: 1 - path: tests/Application/Schedule/ScheduleReservationListTest.php - - - - message: '#^Cannot call method __toString\(\) on string\.$#' - identifier: method.nonObject - count: 2 - path: tests/Application/Schedule/SlotLabelFactoryTest.php - - - - message: '#^Call to an undefined method IGroupRepository\:\:expects\(\)\.$#' - identifier: method.notFound - count: 1 - path: tests/Application/User/ManageUsersServiceTest.php - - - - message: '#^Call to an undefined method IRegistration\:\:expects\(\)\.$#' - identifier: method.notFound - count: 1 - path: tests/Application/User/ManageUsersServiceTest.php - - - - message: '#^Call to an undefined method IUserViewRepository\:\:expects\(\)\.$#' - identifier: method.notFound - count: 2 - path: tests/Application/User/ManageUsersServiceTest.php - - - - message: '#^PHPDoc tag @var with type InstanceAddedEvent is not subtype of native type InstanceUpdatedEvent\.$#' - identifier: varTag.nativeType - count: 1 - path: tests/Domain/Reservation/ExistingReservationTest.php - - - - message: '#^Call to an undefined method IReservationViewRepository\:\:expects\(\)\.$#' - identifier: method.notFound - count: 5 - path: tests/Domain/Reservation/QuotaTest.php - - - - message: '#^Call to an undefined method IReservationViewRepository\:\:expects\(\)\.$#' - identifier: method.notFound - count: 1 - path: tests/Domain/Reservation/QuotaWhenModifyingTest.php - - - - message: '#^Call to an undefined method IScheduleLayout\:\:GetPeakTimes\(\)\.$#' - identifier: method.notFound - count: 1 - path: tests/Domain/Schedule/ScheduleRepositoryTest.php - - - - message: '#^Access to an undefined property TestAdLdapEntry\:\:\$fooName\.$#' - identifier: property.notFound - count: 1 - path: tests/Plugins/Authentication/ActiveDirectory/ActiveDirectoryTest.php - - - - message: '#^PHPDoc tag @var with type array\ is not subtype of native type array\{LBAttribute\}\.$#' - identifier: varTag.nativeType - count: 1 - path: tests/Presenters/Admin/ManageReservationsPresenterTest.php - - - - message: '#^Call to an undefined method PasswordEncryption\:\:expects\(\)\.$#' - identifier: method.notFound - count: 2 - path: tests/Presenters/Admin/ManageUsersPresenterTest.php - - - - message: '#^Method CommonCalendarPresenter\:\:PageLoad\(\) invoked with 2 parameters, 1 required\.$#' - identifier: arguments.count - count: 1 - path: tests/Presenters/CalendarPresenterTest.php - - - - message: '#^Call to an undefined method IReservationViewRepository\:\:expects\(\)\.$#' - identifier: method.notFound - count: 2 - path: tests/Presenters/Dashboard/UpcomingReservationsPresenterTest.php - - - - message: '#^Call to an undefined method IUpcomingReservationsControl\:\:expects\(\)\.$#' - identifier: method.notFound - count: 9 - path: tests/Presenters/Dashboard/UpcomingReservationsPresenterTest.php - - - - message: '#^Method CommonCalendarPresenter\:\:PageLoad\(\) invoked with 2 parameters, 1 required\.$#' - identifier: arguments.count - count: 1 - path: tests/Presenters/PersonalCalendarPresenterTest.php - - - - message: '#^Call to an undefined method IAttributeService\:\:expects\(\)\.$#' - identifier: method.notFound - count: 1 - path: tests/Presenters/RegisterPresenterTest.php - - - - message: '#^Call to an undefined method ICaptchaService\:\:expects\(\)\.$#' - identifier: method.notFound - count: 1 - path: tests/Presenters/RegisterPresenterTest.php - - - - message: '#^Call to an undefined method IExistingReservationPage\:\:expects\(\)\.$#' - identifier: method.notFound - count: 1 - path: tests/Presenters/Reservation/EditReservationPresenterTest.php - - - - message: '#^Call to an undefined method IReservationInitializer\:\:expects\(\)\.$#' - identifier: method.notFound - count: 1 - path: tests/Presenters/Reservation/EditReservationPresenterTest.php - - - - message: '#^Call to an undefined method IReservationInitializerFactory\:\:expects\(\)\.$#' - identifier: method.notFound - count: 1 - path: tests/Presenters/Reservation/EditReservationPresenterTest.php - - - - message: '#^Call to an undefined method IReservationPreconditionService\:\:expects\(\)\.$#' - identifier: method.notFound - count: 1 - path: tests/Presenters/Reservation/EditReservationPresenterTest.php - - - - message: '#^Call to an undefined method IReservationViewRepository\:\:expects\(\)\.$#' - identifier: method.notFound - count: 1 - path: tests/Presenters/Reservation/EditReservationPresenterTest.php - - - - message: '#^Call to an undefined method IReservationInitializer\:\:expects\(\)\.$#' - identifier: method.notFound - count: 1 - path: tests/Presenters/Reservation/GuestReservationPresenterTest.php - - - - message: '#^Access to an undefined property FakeReservationAuthorization\:\:\$_CanReserveFor\.$#' - identifier: property.notFound - count: 3 - path: tests/Presenters/Reservation/ReservationAttributesPresenterTest.php - - - - message: '#^Call to an undefined method Attribute\:\:Id\(\)\.$#' - identifier: method.notFound - count: 5 - path: tests/Presenters/Reservation/ReservationAttributesPresenterTest.php - - - - message: '#^Call to an undefined method Attribute\:\:Value\(\)\.$#' - identifier: method.notFound - count: 2 - path: tests/Presenters/Reservation/ReservationAttributesPresenterTest.php - - - - message: '#^Call to an undefined method IDeleteReservationPersistenceService\:\:expects\(\)\.$#' - identifier: method.notFound - count: 1 - path: tests/Presenters/Reservation/ReservationDeletePresenterTest.php - - - - message: '#^Call to an undefined method IReservationDeletePage\:\:expects\(\)\.$#' - identifier: method.notFound - count: 3 - path: tests/Presenters/Reservation/ReservationDeletePresenterTest.php - - - - message: '#^Call to an undefined method IReservationHandler\:\:expects\(\)\.$#' - identifier: method.notFound - count: 1 - path: tests/Presenters/Reservation/ReservationDeletePresenterTest.php - - - - message: '#^Call to an undefined method IReservationHandler\:\:expects\(\)\.$#' - identifier: method.notFound - count: 1 - path: tests/Presenters/Reservation/ReservationMovePresenterTest.php - - - - message: '#^Call to an undefined method IUpdateReservationPersistenceService\:\:expects\(\)\.$#' - identifier: method.notFound - count: 3 - path: tests/Presenters/Reservation/ReservationMovePresenterTest.php - - - - message: '#^Access to an undefined property IReservationSavePage\:\:\$attachment\.$#' - identifier: property.notFound - count: 1 - path: tests/Presenters/Reservation/ReservationSavePresenterTest.php - - - - message: '#^Access to an undefined property IReservationSavePage\:\:\$invitedGuests\.$#' - identifier: property.notFound - count: 1 - path: tests/Presenters/Reservation/ReservationSavePresenterTest.php - - - - message: '#^Access to an undefined property IReservationSavePage\:\:\$participatingGuests\.$#' - identifier: property.notFound - count: 1 - path: tests/Presenters/Reservation/ReservationSavePresenterTest.php - - - - message: '#^Access to an undefined property IReservationSavePage\:\:\$referenceNumber\.$#' - identifier: property.notFound - count: 1 - path: tests/Presenters/Reservation/ReservationSavePresenterTest.php - - - - message: '#^Access to an undefined property IReservationSavePage\:\:\$requiresApproval\.$#' - identifier: property.notFound - count: 1 - path: tests/Presenters/Reservation/ReservationSavePresenterTest.php - - - - message: '#^Call to an undefined method IReservationHandler\:\:expects\(\)\.$#' - identifier: method.notFound - count: 1 - path: tests/Presenters/Reservation/ReservationUpdatePresenterTest.php - - - - message: '#^Call to an undefined method IResourceRepository\:\:expects\(\)\.$#' - identifier: method.notFound - count: 2 - path: tests/Presenters/Reservation/ReservationUpdatePresenterTest.php - - - - message: '#^Call to an undefined method IUpdateReservationPersistenceService\:\:expects\(\)\.$#' - identifier: method.notFound - count: 2 - path: tests/Presenters/Reservation/ReservationUpdatePresenterTest.php - - - - message: '#^Call to an undefined method IAccessoryRepository\:\:expects\(\)\.$#' - identifier: method.notFound - count: 2 - path: tests/WebServices/AccessoriesWebServiceTest.php - - - - message: '#^Call to an undefined method IResourceRepository\:\:expects\(\)\.$#' - identifier: method.notFound - count: 1 - path: tests/WebServices/AccessoriesWebServiceTest.php - - - - message: '#^Call to an undefined method IReservationPresenterFactory\:\:expects\(\)\.$#' - identifier: method.notFound - count: 4 - path: tests/WebServices/Controllers/ReservationSaveControllerTest.php - - - - message: '#^Call to an undefined method IResourceRepository\:\:expects\(\)\.$#' - identifier: method.notFound - count: 6 - path: tests/WebServices/Controllers/ResourceSaveControllerTest.php - - - - message: '#^Call to an undefined method IResourceRequestValidator\:\:expects\(\)\.$#' - identifier: method.notFound - count: 6 - path: tests/WebServices/Controllers/ResourceSaveControllerTest.php - - - - message: '#^Call to an undefined method IManageUsersService\:\:expects\(\)\.$#' - identifier: method.notFound - count: 4 - path: tests/WebServices/Controllers/UserSaveControllerTest.php - - - - message: '#^Call to an undefined method IManageUsersServiceFactory\:\:expects\(\)\.$#' - identifier: method.notFound - count: 4 - path: tests/WebServices/Controllers/UserSaveControllerTest.php - - - - message: '#^Call to an undefined method IUserRequestValidator\:\:expects\(\)\.$#' - identifier: method.notFound - count: 5 - path: tests/WebServices/Controllers/UserSaveControllerTest.php - - - - message: '#^Call to an undefined method IGroupViewRepository\:\:expects\(\)\.$#' - identifier: method.notFound - count: 1 - path: tests/WebServices/GroupsWebServiceTest.php - - - - message: '#^Call to an undefined method IAttributeService\:\:expects\(\)\.$#' - identifier: method.notFound - count: 1 - path: tests/WebServices/ReservationsWebServiceTest.php - - - - message: '#^Method ResourcesWebService\:\:GetAvailability\(\) invoked with 1 parameter, 0 required\.$#' - identifier: arguments.count - count: 2 - path: tests/WebServices/ResourcesWebServiceTest.php - - - - message: '#^Call to an undefined method IScheduleRepository\:\:expects\(\)\.$#' - identifier: method.notFound - count: 4 - path: tests/WebServices/SchedulesWebServiceTest.php - - - - message: '#^Call to an undefined method IAttributeService\:\:expects\(\)\.$#' - identifier: method.notFound - count: 1 - path: tests/WebServices/Validators/ResourceRequestValidatorTest.php - - - - message: '#^Call to an undefined method IAttributeService\:\:expects\(\)\.$#' - identifier: method.notFound - count: 3 - path: tests/WebServices/Validators/UserRequestValidatorTest.php - - - - message: '#^Call to an undefined method IUserViewRepository\:\:expects\(\)\.$#' - identifier: method.notFound - count: 3 - path: tests/WebServices/Validators/UserRequestValidatorTest.php - - - - message: '#^Method FakeMailer\:\:AddAddress\(\) should return bool but return statement is missing\.$#' - identifier: return.missing - count: 1 - path: tests/fakes/EmailFakes.php - - - - message: '#^Method FakeMailer\:\:Send\(\) should return bool but return statement is missing\.$#' - identifier: return.missing - count: 1 - path: tests/fakes/EmailFakes.php - diff --git a/phpstan.neon b/phpstan.neon index 8d9469785..6b9200d77 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,6 @@ includes: - - phpstan-baseline.neon + - vendor/phpstan/phpstan-phpunit/extension.neon + parameters: level: 2 errorFormat: prettyJson diff --git a/tests/Application/Attributes/AttributeServiceTest.php b/tests/Application/Attributes/AttributeServiceTest.php index d45caacb3..031a10ba8 100644 --- a/tests/Application/Attributes/AttributeServiceTest.php +++ b/tests/Application/Attributes/AttributeServiceTest.php @@ -175,7 +175,7 @@ public function testGetsAttributesForReservationUserAndResources() $this->attributeRepository->_CustomAttributes = [$unrestricted, $forUser, $notForUser, $forResource1, $resource2IsNotAllowed, $forOtherResource, $forResourceType1, $forOtherResourceType]; - /** @var Attribute[] $attributes */ + /** @var LBAttribute[] $attributes */ $attributes = $this->attributeService->GetReservationAttributes($this->fakeUser, new ReservationView(), $requestedUserId, [$resourceId1, $resourceId2, $resourceId3]); $this->assertEquals(4, count($attributes)); diff --git a/tests/Application/Authentication/PasswordMigrationTest.php b/tests/Application/Authentication/PasswordMigrationTest.php index 3a3d08847..c0d10a5a4 100644 --- a/tests/Application/Authentication/PasswordMigrationTest.php +++ b/tests/Application/Authentication/PasswordMigrationTest.php @@ -56,6 +56,7 @@ public function testOldPasswordValidatesWithOldValidatorAndMigrates() $migration = new PasswordMigration(); $password = $migration->Create($this->plaintext, $oldpassword, $newpassword); + $this->assertInstanceOf(Password::class, $password); $password->Encryption = $fakeEncryption; $isValid = $password->Validate(''); diff --git a/tests/Application/Authentication/RegistrationTest.php b/tests/Application/Authentication/RegistrationTest.php index 76804642d..d89509d4c 100644 --- a/tests/Application/Authentication/RegistrationTest.php +++ b/tests/Application/Authentication/RegistrationTest.php @@ -14,10 +14,7 @@ class RegistrationTest extends TestBase */ private $fakeEncryption; - /** - * @var IUserRepository - */ - private $userRepository; + private IUserRepository&\PHPUnit\Framework\MockObject\MockObject $userRepository; /** * @var FakeGroupViewRepository diff --git a/tests/Application/Authentication/WebServiceAuthenticationTest.php b/tests/Application/Authentication/WebServiceAuthenticationTest.php index b6e6b5c98..b22654b12 100644 --- a/tests/Application/Authentication/WebServiceAuthenticationTest.php +++ b/tests/Application/Authentication/WebServiceAuthenticationTest.php @@ -17,10 +17,7 @@ class WebServiceAuthenticationTest extends TestBase private $username = 'LoGInName'; private $password = 'password'; - /** - * @var IUserSessionRepository - */ - private $userSessionRepository; + private IUserSessionRepository&\PHPUnit\Framework\MockObject\MockObject $userSessionRepository; public function setUp(): void { diff --git a/tests/Application/Reservation/ReservationStartTimeRuleTest.php b/tests/Application/Reservation/ReservationStartTimeRuleTest.php index 73b35de3a..b090dc472 100644 --- a/tests/Application/Reservation/ReservationStartTimeRuleTest.php +++ b/tests/Application/Reservation/ReservationStartTimeRuleTest.php @@ -5,15 +5,9 @@ class ReservationStartTimeRuleTest extends TestBase { - /** - * @var IScheduleRepository - */ - private $scheduleRepository; - - /** - * @var IScheduleLayout - */ - private $layout; + private IScheduleRepository&\PHPUnit\Framework\MockObject\MockObject $scheduleRepository; + + private IScheduleLayout&\PHPUnit\Framework\MockObject\MockObject $layout; public function setUp(): void { diff --git a/tests/Application/Reservation/ResourceCrossDayRuleTest.php b/tests/Application/Reservation/ResourceCrossDayRuleTest.php index 55f0764b7..c57d8dff8 100644 --- a/tests/Application/Reservation/ResourceCrossDayRuleTest.php +++ b/tests/Application/Reservation/ResourceCrossDayRuleTest.php @@ -5,10 +5,7 @@ class ResourceCrossDayRuleTest extends TestBase { - /** - * @var IScheduleRepository - */ - private $scheduleRepository; + private IScheduleRepository&\PHPUnit\Framework\MockObject\MockObject $scheduleRepository; /** * @var Schedule diff --git a/tests/Application/Reservation/SchedulePeriodRuleTest.php b/tests/Application/Reservation/SchedulePeriodRuleTest.php index c8eba8ebb..c94b2c291 100644 --- a/tests/Application/Reservation/SchedulePeriodRuleTest.php +++ b/tests/Application/Reservation/SchedulePeriodRuleTest.php @@ -5,15 +5,9 @@ class SchedulePeriodRuleTest extends TestBase { - /** - * @var IScheduleRepository - */ - private $scheduleRepository; + private IScheduleRepository&\PHPUnit\Framework\MockObject\MockObject $scheduleRepository; - /** - * @var IScheduleLayout - */ - private $layout; + private IScheduleLayout&\PHPUnit\Framework\MockObject\MockObject $layout; /** * @var SchedulePeriodRule diff --git a/tests/Application/Schedule/ResourceServiceTest.php b/tests/Application/Schedule/ResourceServiceTest.php index 0483ccc20..9dbef6825 100644 --- a/tests/Application/Schedule/ResourceServiceTest.php +++ b/tests/Application/Schedule/ResourceServiceTest.php @@ -4,35 +4,20 @@ class ResourceServiceTest extends TestBase { - /** - * @var IPermissionService|PHPUnit\Framework\MockObject\MockObject - */ - private $permissionService; + private IPermissionService&\PHPUnit\Framework\MockObject\MockObject $permissionService; - /** - * @var IResourceRepository|PHPUnit\Framework\MockObject\MockObject - */ - private $resourceRepository; + private IResourceRepository&\PHPUnit\Framework\MockObject\MockObject $resourceRepository; - /** - * @var IAttributeService|PHPUnit\Framework\MockObject\MockObject - */ - private $attributeService; + private IAttributeService&\PHPUnit\Framework\MockObject\MockObject $attributeService; - /** - * @var IUserRepository|PHPUnit\Framework\MockObject\MockObject - */ - private $userRepository; + private IUserRepository&\PHPUnit\Framework\MockObject\MockObject $userRepository; /** * @var ResourceService */ private $resourceService; - /** - * @var IAccessoryRepository - */ - private $accessoryRepository; + private IAccessoryRepository&\PHPUnit\Framework\MockObject\MockObject $accessoryRepository; public function setUp(): void { diff --git a/tests/Application/Schedule/ScheduleReservationListTest.php b/tests/Application/Schedule/ScheduleReservationListTest.php index 99091c9e5..d3ab70061 100644 --- a/tests/Application/Schedule/ScheduleReservationListTest.php +++ b/tests/Application/Schedule/ScheduleReservationListTest.php @@ -309,7 +309,7 @@ public function testReservationEndingAfterLayoutPeriodAndStartingWithinIsCreated $this->assertEquals($slot9, $slots[8]); $this->assertEquals($slot10, $slots[9]); $this->assertEquals($slot11, $slots[10]); - $this->assertEquals($slot12, $slots[11], $slot12 . ' ' . $slots[11]); + $this->assertEquals($slot12, $slots[11]); } public function testReservationStartingBeforeLayoutPeriodAndEndingAfterLayoutPeriodIsCreatedProperly() diff --git a/tests/Application/Schedule/SlotLabelFactoryTest.php b/tests/Application/Schedule/SlotLabelFactoryTest.php index dd3dd8741..1cb39e3d7 100644 --- a/tests/Application/Schedule/SlotLabelFactoryTest.php +++ b/tests/Application/Schedule/SlotLabelFactoryTest.php @@ -121,7 +121,7 @@ public function testHidesUserDetails() $label = $factory->Format($this->reservation); - $fullName = $this->reservation->GetUserName()->__toString(); + $fullName = $this->reservation->GetUserName(); $this->assertStringNotContainsString($fullName, $label); } @@ -141,7 +141,7 @@ public function testShowsUserDetailsIfCanEditResource() $label = $factory->Format($this->reservation); - $fullName = $this->reservation->GetUserName()->__toString(); + $fullName = $this->reservation->GetUserName(); $this->assertStringContainsString($fullName, $label); } diff --git a/tests/Application/User/ManageUsersServiceTest.php b/tests/Application/User/ManageUsersServiceTest.php index 90db7f33a..10562badc 100644 --- a/tests/Application/User/ManageUsersServiceTest.php +++ b/tests/Application/User/ManageUsersServiceTest.php @@ -9,25 +9,16 @@ class ManageUsersServiceTest extends TestBase */ private $service; - /** - * @var IRegistration - */ - private $registration; + private IRegistration&\PHPUnit\Framework\MockObject\MockObject $registration; /** * @var FakeUserRepository */ private $userRepo; - /** - * @var IGroupRepository - */ - private $groupRepo; + private IGroupRepository&\PHPUnit\Framework\MockObject\MockObject $groupRepo; - /** - * @var IUserViewRepository - */ - private $userViewRepo; + private IUserViewRepository&\PHPUnit\Framework\MockObject\MockObject $userViewRepo; /** * @var FakePasswordEncryption diff --git a/tests/Domain/Reservation/ExistingReservationTest.php b/tests/Domain/Reservation/ExistingReservationTest.php index dd82f464f..9c6f78703 100644 --- a/tests/Domain/Reservation/ExistingReservationTest.php +++ b/tests/Domain/Reservation/ExistingReservationTest.php @@ -1153,7 +1153,7 @@ public function testChangingTimeOfExistingCustomRepeat() } if (is_a($e, 'InstanceUpdatedEvent')) { - /** @var InstanceAddedEvent $e */ + /** @var InstanceUpdatedEvent $e */ $updatedReferenceNumbers[] = $e->Instance()->ReferenceNumber(); } } diff --git a/tests/Domain/Reservation/QuotaTest.php b/tests/Domain/Reservation/QuotaTest.php index 7f39f6749..0d186b7e5 100644 --- a/tests/Domain/Reservation/QuotaTest.php +++ b/tests/Domain/Reservation/QuotaTest.php @@ -14,10 +14,7 @@ class QuotaTest extends TestBase */ public $schedule; - /** - * @var IReservationViewRepository - */ - public $reservationViewRepository; + public IReservationViewRepository&\PHPUnit\Framework\MockObject\MockObject $reservationViewRepository; /** * @var FakeUser diff --git a/tests/Domain/Reservation/QuotaWhenModifyingTest.php b/tests/Domain/Reservation/QuotaWhenModifyingTest.php index 72159d6a9..c17d13f9c 100644 --- a/tests/Domain/Reservation/QuotaWhenModifyingTest.php +++ b/tests/Domain/Reservation/QuotaWhenModifyingTest.php @@ -14,10 +14,7 @@ class QuotaWhenModifyingTest extends TestBase */ public $schedule; - /** - * @var IReservationViewRepository - */ - public $reservationViewRepository; + public IReservationViewRepository&\PHPUnit\Framework\MockObject\MockObject $reservationViewRepository; /** * @var FakeUser diff --git a/tests/Domain/Schedule/ScheduleRepositoryTest.php b/tests/Domain/Schedule/ScheduleRepositoryTest.php index dacee90e5..0f82c1b23 100644 --- a/tests/Domain/Schedule/ScheduleRepositoryTest.php +++ b/tests/Domain/Schedule/ScheduleRepositoryTest.php @@ -97,6 +97,7 @@ public function testCanGetLayoutForSchedule() ->method('CreateLayout') ->willReturn($expectedLayout); + /** @var ScheduleLayout $layout */ $layout = $this->scheduleRepository->GetLayout($scheduleId, $layoutFactory); $this->assertEquals(new GetLayoutCommand($scheduleId), $this->db->_Commands[0]); @@ -223,6 +224,7 @@ public function testLoadsPeakTimesWithLayout() $this->db->SetRow(1, [$peakTimeRows]); $layout = $this->scheduleRepository->GetLayout($scheduleId, $layoutFactory); + $this->assertInstanceOf(ScheduleLayout::class, $layout); $peakTimes = $layout->GetPeakTimes(); @@ -238,6 +240,37 @@ public function testLoadsPeakTimesWithLayout() $this->assertEquals(10, $peakTimes->GetEndDay()); } + public function testGetLayoutReturnsEmptyLayoutWhenNoRows() + { + $timezone = 'America/New_York'; + $scheduleId = 109; + + $this->db->SetRow(0, []); + $this->db->SetRow(1, []); + + $layoutFactory = $this->createMock('ILayoutFactory'); + $expectedLayout = new ScheduleLayout($timezone); + + $layoutFactory->expects($this->once()) + ->method('CreateLayout') + ->willReturn($expectedLayout); + + $layoutFactory->expects($this->never()) + ->method('CreateCustomLayout'); + + $layout = $this->scheduleRepository->GetLayout($scheduleId, $layoutFactory); + + $this->assertSame($expectedLayout, $layout); + $this->assertEquals(new GetLayoutCommand($scheduleId), $this->db->_Commands[0]); + $this->assertEquals(new GetPeakTimesCommand($scheduleId), $this->db->_Commands[1]); + $this->assertTrue($this->db->GetReader(0)->_FreeCalled); + $this->assertTrue($this->db->GetReader(1)->_FreeCalled); + + $this->expectException(Exception::class); + $this->expectExceptionMessage('No periods defined for date'); + $layout->GetLayout(Date::Parse('2010-01-01', $timezone)); + } + public function testCanGetScheduleById() { $id = 10; diff --git a/tests/Plugins/Authentication/ActiveDirectory/ActiveDirectoryTest.php b/tests/Plugins/Authentication/ActiveDirectory/ActiveDirectoryTest.php index 6dd043169..4c3364133 100644 --- a/tests/Plugins/Authentication/ActiveDirectory/ActiveDirectoryTest.php +++ b/tests/Plugins/Authentication/ActiveDirectory/ActiveDirectoryTest.php @@ -319,6 +319,7 @@ class TestAdLdapEntry { public $sn; public $givenname; + public $fooName; public $mail; public $telephonenumber; public $physicaldeliveryofficename; diff --git a/tests/Presenters/Admin/ManageReservationsPresenterTest.php b/tests/Presenters/Admin/ManageReservationsPresenterTest.php index 99174ad90..2543bb0d5 100644 --- a/tests/Presenters/Admin/ManageReservationsPresenterTest.php +++ b/tests/Presenters/Admin/ManageReservationsPresenterTest.php @@ -9,40 +9,19 @@ class ManageReservationsPresenterTest extends TestBase */ private $presenter; - /** - * @var IManageReservationsPage|PHPUnit\Framework\MockObject\MockObject - */ - private $page; + private IManageReservationsPage&\PHPUnit\Framework\MockObject\MockObject $page; - /** - * @var IManageReservationsService|PHPUnit\Framework\MockObject\MockObject - */ - private $reservationsService; + private IManageReservationsService&\PHPUnit\Framework\MockObject\MockObject $reservationsService; - /** - * @var IScheduleRepository|PHPUnit\Framework\MockObject\MockObject - */ - private $scheduleRepository; + private IScheduleRepository&\PHPUnit\Framework\MockObject\MockObject $scheduleRepository; - /** - * @var IResourceRepository|PHPUnit\Framework\MockObject\MockObject - */ - private $resourceRepository; + private IResourceRepository&\PHPUnit\Framework\MockObject\MockObject $resourceRepository; - /** - * @var IAttributeService|PHPUnit\Framework\MockObject\MockObject - */ - private $attributeService; + private IAttributeService&\PHPUnit\Framework\MockObject\MockObject $attributeService; - /** - * @var IUserRepository|PHPUnit\Framework\MockObject\MockObject - */ - private $userRepository; + private IUserRepository&\PHPUnit\Framework\MockObject\MockObject $userRepository; - /** - * @var ITermsOfServiceRepository|PHPUnit\Framework\MockObject\MockObject - */ - private $termsOfServiceRepository; + private ITermsOfServiceRepository&\PHPUnit\Framework\MockObject\MockObject $termsOfServiceRepository; public function setUp(): void { @@ -87,7 +66,7 @@ public function testUsesTwoWeekSpanWhenNoDateFilterProvided() $searchedResourceStatusReasonId = 4292; /** @var TestCustomAttribute[] $customAttributes */ $customAttributes = [new TestCustomAttribute(1, 'something')]; - /** @var Attribute[] $attributes */ + /** @var LBAttribute[] $attributes */ $attributes = [new LBAttribute($customAttributes[0], 'value')]; $this->resourceRepository->expects($this->once()) diff --git a/tests/Presenters/Admin/ManageUsersPresenterTest.php b/tests/Presenters/Admin/ManageUsersPresenterTest.php index e2ec01245..27d50698e 100644 --- a/tests/Presenters/Admin/ManageUsersPresenterTest.php +++ b/tests/Presenters/Admin/ManageUsersPresenterTest.php @@ -20,10 +20,7 @@ class ManageUsersPresenterTest extends TestBase */ public $resourceRepo; - /** - * @var IManageUsersService|PHPUnit\Framework\MockObject\MockObject - */ - public $manageUsersService; + public IManageUsersService&\PHPUnit\Framework\MockObject\MockObject $manageUsersService; /** * @var ManageUsersPresenter @@ -35,20 +32,11 @@ class ManageUsersPresenterTest extends TestBase */ public $attributeService; - /** - * @var PasswordEncryption - */ - public $encryption; + public PasswordEncryption&\PHPUnit\Framework\MockObject\MockObject $encryption; - /** - * @var IGroupRepository|PHPUnit\Framework\MockObject\MockObject - */ - public $groupRepository; + public IGroupRepository&\PHPUnit\Framework\MockObject\MockObject $groupRepository; - /** - * @var IGroupViewRepository|PHPUnit\Framework\MockObject\MockObject - */ - public $groupViewRepository; + public IGroupViewRepository&\PHPUnit\Framework\MockObject\MockObject $groupViewRepository; public function setUp(): void { diff --git a/tests/Presenters/CalendarPresenterTest.php b/tests/Presenters/CalendarPresenterTest.php index 59fcb3372..d533ab3b0 100644 --- a/tests/Presenters/CalendarPresenterTest.php +++ b/tests/Presenters/CalendarPresenterTest.php @@ -5,45 +5,27 @@ class CalendarPresenterTest extends TestBase { - /** - * @var ICommonCalendarPage|PHPUnit\Framework\MockObject\MockObject - */ - private $page; + private ICommonCalendarPage&\PHPUnit\Framework\MockObject\MockObject $page; /** * @var CalendarPresenter */ private $presenter; - /** - * @var IReservationViewRepository|PHPUnit\Framework\MockObject\MockObject - */ - private $repository; + private IReservationViewRepository&\PHPUnit\Framework\MockObject\MockObject $repository; - /** - * @var ICalendarFactory|PHPUnit\Framework\MockObject\MockObject - */ - private $calendarFactory; + private ICalendarFactory&\PHPUnit\Framework\MockObject\MockObject $calendarFactory; - /** - * @var IScheduleRepository|PHPUnit\Framework\MockObject\MockObject - */ - private $scheduleRepository; + private IScheduleRepository&\PHPUnit\Framework\MockObject\MockObject $scheduleRepository; /** * @var FakeUserRepository */ private $userRepository; - /** - * @var IResourceService|PHPUnit\Framework\MockObject\MockObject - */ - private $resourceService; + private IResourceService&\PHPUnit\Framework\MockObject\MockObject $resourceService; - /** - * @var ICalendarSubscriptionService|PHPUnit\Framework\MockObject\MockObject - */ - private $subscriptionService; + private ICalendarSubscriptionService&\PHPUnit\Framework\MockObject\MockObject $subscriptionService; /** * @var FakePrivacyFilter @@ -151,7 +133,7 @@ public function testBindsDefaultScheduleByMonthWhenNothingSelected() $calendarFilters = new CalendarFilters($schedules, $resources, $defaultScheduleId, null, new ResourceGroupTree()); $this->page->expects($this->atLeastOnce())->method('BindFilters')->with($this->equalTo($calendarFilters)); - $this->presenter->PageLoad($this->fakeUser, $userTimezone); + $this->presenter->PageLoad($this->fakeUser); } public function testSkipsReservationsForUnknownResources() diff --git a/tests/Presenters/Dashboard/UpcomingReservationsPresenterTest.php b/tests/Presenters/Dashboard/UpcomingReservationsPresenterTest.php index 3b4a32fab..82027f477 100644 --- a/tests/Presenters/Dashboard/UpcomingReservationsPresenterTest.php +++ b/tests/Presenters/Dashboard/UpcomingReservationsPresenterTest.php @@ -9,15 +9,9 @@ class UpcomingReservationsPresenterTest extends TestBase */ private $presenter; - /** - * @var IUpcomingReservationsControl - */ - private $control; + private IUpcomingReservationsControl&\PHPUnit\Framework\MockObject\MockObject $control; - /** - * @var IReservationViewRepository - */ - private $repository; + private IReservationViewRepository&\PHPUnit\Framework\MockObject\MockObject $repository; public function setUp(): void { diff --git a/tests/Presenters/PersonalCalendarPresenterTest.php b/tests/Presenters/PersonalCalendarPresenterTest.php index e0a8879d4..7c673d6b6 100644 --- a/tests/Presenters/PersonalCalendarPresenterTest.php +++ b/tests/Presenters/PersonalCalendarPresenterTest.php @@ -5,45 +5,24 @@ class PersonalCalendarPresenterTest extends TestBase { - /** - * @var ICommonCalendarPage|PHPUnit\Framework\MockObject\MockObject - */ - private $page; + private ICommonCalendarPage&\PHPUnit\Framework\MockObject\MockObject $page; /** * @var PersonalCalendarPresenter */ private $presenter; - /** - * @var IReservationViewRepository|PHPUnit\Framework\MockObject\MockObject - */ - private $repository; + private IReservationViewRepository&\PHPUnit\Framework\MockObject\MockObject $repository; - /** - * @var ICalendarFactory|PHPUnit\Framework\MockObject\MockObject - */ - private $calendarFactory; + private ICalendarFactory&\PHPUnit\Framework\MockObject\MockObject $calendarFactory; - /** - * @var ICalendarSubscriptionService|PHPUnit\Framework\MockObject\MockObject - */ - private $subscriptionService; + private ICalendarSubscriptionService&\PHPUnit\Framework\MockObject\MockObject $subscriptionService; - /** - * @var IUserRepository|PHPUnit\Framework\MockObject\MockObject - */ - private $userRepository; + private IUserRepository&\PHPUnit\Framework\MockObject\MockObject $userRepository; - /** - * @var IResourceService|PHPUnit\Framework\MockObject\MockObject - */ - private $resourceService; + private IResourceService&\PHPUnit\Framework\MockObject\MockObject $resourceService; - /** - * @var IScheduleRepository|PHPUnit\Framework\MockObject\MockObject - */ - private $scheduleRepository; + private IScheduleRepository&\PHPUnit\Framework\MockObject\MockObject $scheduleRepository; public function setUp(): void { @@ -144,6 +123,6 @@ public function testBindsEmptyCalendarToPageWhenNoReservationsAreFound() $calendarFilters = new CalendarFilters($schedules, $resources, $defaultScheduleId, null, $resourceGroupTree); $this->page->expects($this->atLeastOnce())->method('BindFilters')->with($this->equalTo($calendarFilters)); - $this->presenter->PageLoad($this->fakeUser, $userTimezone); + $this->presenter->PageLoad($this->fakeUser); } } diff --git a/tests/Presenters/RegisterPresenterTest.php b/tests/Presenters/RegisterPresenterTest.php index 0a92ead2a..6bb651874 100644 --- a/tests/Presenters/RegisterPresenterTest.php +++ b/tests/Presenters/RegisterPresenterTest.php @@ -27,20 +27,12 @@ class RegisterPresenterTest extends TestBase */ private $fakeAuth; - /** - * @var ICaptchaService - */ - private $captcha; + private ICaptchaService&\PHPUnit\Framework\MockObject\MockObject $captcha; - /** - * @var IAttributeService - */ - private $attributeService; + private IAttributeService&\PHPUnit\Framework\MockObject\MockObject $attributeService; - /** - * @var ITermsOfServiceRepository - */ - private $termsOfServiceRepository; + // Intentionally concrete fake in setUp(), not a PHPUnit mock. + private ITermsOfServiceRepository $termsOfServiceRepository; private $login = 'testlogin'; private $email = 'test@test.com'; diff --git a/tests/Presenters/Reservation/EditReservationPresenterTest.php b/tests/Presenters/Reservation/EditReservationPresenterTest.php index 245494447..23d67f830 100644 --- a/tests/Presenters/Reservation/EditReservationPresenterTest.php +++ b/tests/Presenters/Reservation/EditReservationPresenterTest.php @@ -9,30 +9,15 @@ class EditReservationPresenterTest extends TestBase private $userId; - /** - * @var IExistingReservationPage - */ - private $page; + private IExistingReservationPage&\PHPUnit\Framework\MockObject\MockObject $page; - /** - * @var IReservationViewRepository - */ - private $reservationViewRepository; + private IReservationViewRepository&\PHPUnit\Framework\MockObject\MockObject $reservationViewRepository; - /** - * @var IReservationPreconditionService - */ - private $preconditionService; + private EditReservationPreconditionService&\PHPUnit\Framework\MockObject\MockObject $preconditionService; - /** - * @var IReservationInitializerFactory - */ - private $initializerFactory; + private IReservationInitializerFactory&\PHPUnit\Framework\MockObject\MockObject $initializerFactory; - /** - * @var IReservationInitializer - */ - private $initializer; + private IReservationInitializer&\PHPUnit\Framework\MockObject\MockObject $initializer; public function setUp(): void { diff --git a/tests/Presenters/Reservation/GuestReservationPresenterTest.php b/tests/Presenters/Reservation/GuestReservationPresenterTest.php index 60207a451..8c6e8092a 100644 --- a/tests/Presenters/Reservation/GuestReservationPresenterTest.php +++ b/tests/Presenters/Reservation/GuestReservationPresenterTest.php @@ -13,23 +13,14 @@ class GuestReservationPresenterTest extends TestBase */ private $presenter; - /** - * @var IReservationInitializerFactory - */ - private $factory; + private IReservationInitializerFactory&\PHPUnit\Framework\MockObject\MockObject $factory; - /** - * @var INewReservationPreconditionService - */ - private $preconditionService; + private INewReservationPreconditionService&\PHPUnit\Framework\MockObject\MockObject $preconditionService; /** * @var FakeRegistration */ private $registration; - /** - * @var IReservationInitializer - */ - private $initializer; + private IReservationInitializer&\PHPUnit\Framework\MockObject\MockObject $initializer; /** * @var FakeWebAuthentication */ diff --git a/tests/Presenters/Reservation/ReservationAttributesPresenterTest.php b/tests/Presenters/Reservation/ReservationAttributesPresenterTest.php index bc9aba6ba..03321d595 100644 --- a/tests/Presenters/Reservation/ReservationAttributesPresenterTest.php +++ b/tests/Presenters/Reservation/ReservationAttributesPresenterTest.php @@ -4,13 +4,11 @@ class ReservationAttributesPresenterTest extends TestBase { - /** - * @var IAttributeService|PHPUnit\Framework\MockObject\MockObject - */ - private $attributeService; + // Intentionally concrete service in setUp(), not a PHPUnit mock. + private IAttributeService $attributeService; /** - * @var FakeReservationAuthorization + * @var FakeAuthorizationService */ private $authorizationService; @@ -34,10 +32,7 @@ class ReservationAttributesPresenterTest extends TestBase */ private $presenter; - /** - * @var IAttributeRepository|PHPUnit\Framework\MockObject\MockObject - */ - private $attributeRepository; + private IAttributeRepository&\PHPUnit\Framework\MockObject\MockObject $attributeRepository; public function setUp(): void { @@ -215,7 +210,7 @@ public function testIfTheAttributeIsPrivate_AndTheCurrentUserCanReserveForReques class FakeReservationAttributesPage implements IReservationAttributesPage { /** - * @var Attribute[] + * @var LBAttribute[] */ public $_Attributes; @@ -238,7 +233,7 @@ public function GetRequestedUserId() } /** - * @param Attribute[] $attributes + * @param LBAttribute[] $attributes */ public function SetAttributes($attributes) { diff --git a/tests/Presenters/Reservation/ReservationDeletePresenterTest.php b/tests/Presenters/Reservation/ReservationDeletePresenterTest.php index bea826b91..f79ae4605 100644 --- a/tests/Presenters/Reservation/ReservationDeletePresenterTest.php +++ b/tests/Presenters/Reservation/ReservationDeletePresenterTest.php @@ -13,20 +13,11 @@ class ReservationDeletePresenterTest extends TestBase */ private $user; - /** - * @var IReservationDeletePage - */ - private $page; + private IReservationDeletePage&\PHPUnit\Framework\MockObject\MockObject $page; - /** - * @var IDeleteReservationPersistenceService - */ - private $persistenceService; + private IDeleteReservationPersistenceService&\PHPUnit\Framework\MockObject\MockObject $persistenceService; - /** - * @var IReservationHandler - */ - private $handler; + private IReservationHandler&\PHPUnit\Framework\MockObject\MockObject $handler; /** * @var ReservationDeletePresenter diff --git a/tests/Presenters/Reservation/ReservationMovePresenterTest.php b/tests/Presenters/Reservation/ReservationMovePresenterTest.php index 69b718e46..a4392af9c 100644 --- a/tests/Presenters/Reservation/ReservationMovePresenterTest.php +++ b/tests/Presenters/Reservation/ReservationMovePresenterTest.php @@ -18,25 +18,16 @@ class ReservationMovePresenterTest extends TestBase */ private $page; - /** - * @var IUpdateReservationPersistenceService - */ - private $persistenceService; + private IUpdateReservationPersistenceService&\PHPUnit\Framework\MockObject\MockObject $persistenceService; - /** - * @var IReservationHandler - */ - private $handler; + private IReservationHandler&\PHPUnit\Framework\MockObject\MockObject $handler; /** * @var ReservationMovePresenter */ private $presenter; - /** - * @var IResourceRepository|PHPUnit\Framework\MockObject\MockObject - */ - private $resourceRepository; + private IResourceRepository&\PHPUnit\Framework\MockObject\MockObject $resourceRepository; public function setUp(): void { diff --git a/tests/Presenters/Reservation/ReservationSavePresenterTest.php b/tests/Presenters/Reservation/ReservationSavePresenterTest.php index 3587f2625..4e60f75b1 100644 --- a/tests/Presenters/Reservation/ReservationSavePresenterTest.php +++ b/tests/Presenters/Reservation/ReservationSavePresenterTest.php @@ -17,7 +17,7 @@ class ReservationSavePresenterTest extends TestBase private $userId; /** - * @var IReservationSavePage|FakeReservationSavePage + * @var FakeReservationSavePage */ private $page; @@ -26,20 +26,11 @@ class ReservationSavePresenterTest extends TestBase */ private $presenter; - /** - * @var IReservationPersistenceService|PHPUnit\Framework\MockObject\MockObject - */ - private $persistenceService; + private IReservationPersistenceService&\PHPUnit\Framework\MockObject\MockObject $persistenceService; - /** - * @var IReservationHandler|PHPUnit\Framework\MockObject\MockObject - */ - private $handler; + private IReservationHandler&\PHPUnit\Framework\MockObject\MockObject $handler; - /** - * @var IResourceRepository|PHPUnit\Framework\MockObject\MockObject - */ - private $resourceRepository; + private IResourceRepository&\PHPUnit\Framework\MockObject\MockObject $resourceRepository; /** * @var FakeScheduleRepository diff --git a/tests/Presenters/Reservation/ReservationUpdatePresenterTest.php b/tests/Presenters/Reservation/ReservationUpdatePresenterTest.php index 2642b4fa4..12376717f 100644 --- a/tests/Presenters/Reservation/ReservationUpdatePresenterTest.php +++ b/tests/Presenters/Reservation/ReservationUpdatePresenterTest.php @@ -18,20 +18,11 @@ class ReservationUpdatePresenterTest extends TestBase */ private $page; - /** - * @var IUpdateReservationPersistenceService - */ - private $persistenceService; + private IUpdateReservationPersistenceService&\PHPUnit\Framework\MockObject\MockObject $persistenceService; - /** - * @var IReservationHandler - */ - private $handler; + private IReservationHandler&\PHPUnit\Framework\MockObject\MockObject $handler; - /** - * @var IResourceRepository - */ - private $resourceRepository; + private IResourceRepository&\PHPUnit\Framework\MockObject\MockObject $resourceRepository; /** * @var FakeScheduleRepository diff --git a/tests/Presenters/SchedulePresenterTest.php b/tests/Presenters/SchedulePresenterTest.php index 31ca030f9..0714e2f66 100644 --- a/tests/Presenters/SchedulePresenterTest.php +++ b/tests/Presenters/SchedulePresenterTest.php @@ -1075,10 +1075,7 @@ public function SetScheduleStyle($direction) { } - /** - * @return int - */ - public function GetGroupId() + public function GetGroupId(): int|null { return null; } diff --git a/tests/WebServices/AccessoriesWebServiceTest.php b/tests/WebServices/AccessoriesWebServiceTest.php index 052f6a45b..7fc2a9e61 100644 --- a/tests/WebServices/AccessoriesWebServiceTest.php +++ b/tests/WebServices/AccessoriesWebServiceTest.php @@ -15,15 +15,9 @@ class AccessoriesWebServiceTest extends TestBase */ private $server; - /** - * @var IResourceRepository - */ - private $resourceRepository; + private IResourceRepository&\PHPUnit\Framework\MockObject\MockObject $resourceRepository; - /** - * @var IAccessoryRepository - */ - private $accessoryRepository; + private IAccessoryRepository&\PHPUnit\Framework\MockObject\MockObject $accessoryRepository; public function setUp(): void { diff --git a/tests/WebServices/Controllers/ReservationSaveControllerTest.php b/tests/WebServices/Controllers/ReservationSaveControllerTest.php index 7e8e33294..bc4972a8c 100644 --- a/tests/WebServices/Controllers/ReservationSaveControllerTest.php +++ b/tests/WebServices/Controllers/ReservationSaveControllerTest.php @@ -9,10 +9,7 @@ class ReservationSaveControllerTest extends TestBase */ private $controller; - /** - * @var IReservationPresenterFactory - */ - private $presenterFactory; + private IReservationPresenterFactory&\PHPUnit\Framework\MockObject\MockObject $presenterFactory; public function setUp(): void { diff --git a/tests/WebServices/Controllers/ResourceSaveControllerTest.php b/tests/WebServices/Controllers/ResourceSaveControllerTest.php index c5598d69d..36f39483a 100644 --- a/tests/WebServices/Controllers/ResourceSaveControllerTest.php +++ b/tests/WebServices/Controllers/ResourceSaveControllerTest.php @@ -14,15 +14,9 @@ class ResourceSaveControllerTest extends TestBase */ private $session; - /** - * @var IResourceRepository - */ - private $repository; + private IResourceRepository&\PHPUnit\Framework\MockObject\MockObject $repository; - /** - * @var IResourceRequestValidator - */ - private $validator; + private IResourceRequestValidator&\PHPUnit\Framework\MockObject\MockObject $validator; public function setUp(): void { diff --git a/tests/WebServices/Controllers/UserSaveControllerTest.php b/tests/WebServices/Controllers/UserSaveControllerTest.php index 81ae66955..f1d11c688 100644 --- a/tests/WebServices/Controllers/UserSaveControllerTest.php +++ b/tests/WebServices/Controllers/UserSaveControllerTest.php @@ -9,20 +9,11 @@ class UserSaveControllerTest extends TestBase */ private $controller; - /** - * @var IManageUsersServiceFactory - */ - private $manageUserServiceFactory; + private IManageUsersServiceFactory&\PHPUnit\Framework\MockObject\MockObject $manageUserServiceFactory; - /** - * @var IManageUsersService - */ - private $manageUsersService; + private IManageUsersService&\PHPUnit\Framework\MockObject\MockObject $manageUsersService; - /** - * @var IUserRequestValidator - */ - private $requestValidator; + private IUserRequestValidator&\PHPUnit\Framework\MockObject\MockObject $requestValidator; public function setUp(): void { diff --git a/tests/WebServices/GroupsWebServiceTest.php b/tests/WebServices/GroupsWebServiceTest.php index acf6e7a18..63c3f11e2 100644 --- a/tests/WebServices/GroupsWebServiceTest.php +++ b/tests/WebServices/GroupsWebServiceTest.php @@ -14,15 +14,9 @@ class GroupsWebServiceTest extends TestBase */ private $service; - /** - * @var IGroupRepository|PHPUnit\Framework\MockObject\MockObject - */ - private $groupRepository; + private IGroupRepository&\PHPUnit\Framework\MockObject\MockObject $groupRepository; - /** - * @var IGroupViewRepository - */ - private $groupViewRepository; + private IGroupViewRepository&\PHPUnit\Framework\MockObject\MockObject $groupViewRepository; public function setUp(): void { diff --git a/tests/WebServices/ReservationsWebServiceTest.php b/tests/WebServices/ReservationsWebServiceTest.php index f271ec05b..b6de22311 100644 --- a/tests/WebServices/ReservationsWebServiceTest.php +++ b/tests/WebServices/ReservationsWebServiceTest.php @@ -14,20 +14,11 @@ class ReservationsWebServiceTest extends TestBase */ private $service; - /** - * @var IReservationViewRepository|PHPUnit\Framework\MockObject\MockObject - */ - private $reservationViewRepository; + private IReservationViewRepository&\PHPUnit\Framework\MockObject\MockObject $reservationViewRepository; - /** - * @var IPrivacyFilter - */ - private $privacyFilter; + private IPrivacyFilter&\PHPUnit\Framework\MockObject\MockObject $privacyFilter; - /** - * @var IAttributeService - */ - private $attributeService; + private IAttributeService&\PHPUnit\Framework\MockObject\MockObject $attributeService; /** * @var WebServiceUserSession diff --git a/tests/WebServices/ResourcesWebServiceTest.php b/tests/WebServices/ResourcesWebServiceTest.php index 3d5c20be3..902b9c3ae 100644 --- a/tests/WebServices/ResourcesWebServiceTest.php +++ b/tests/WebServices/ResourcesWebServiceTest.php @@ -9,20 +9,11 @@ class ResourcesWebServiceTest extends TestBase */ private $server; - /** - * @var IResourceRepository|PHPUnit\Framework\MockObject\MockObject - */ - private $repository; + private IResourceRepository&\PHPUnit\Framework\MockObject\MockObject $repository; - /** - * @var IReservationViewRepository|PHPUnit\Framework\MockObject\MockObject - */ - private $reservationRepository; + private IReservationViewRepository&\PHPUnit\Framework\MockObject\MockObject $reservationRepository; - /** - * @var IAttributeService|PHPUnit\Framework\MockObject\MockObject - */ - private $attributeService; + private IAttributeService&\PHPUnit\Framework\MockObject\MockObject $attributeService; /** * @var ResourcesWebService @@ -227,7 +218,7 @@ public function testGetsSingleResourceAvailability() ) ->willReturn($reservations); - $this->service->GetAvailability($resourceId1); + $this->service->GetAvailability(); } public function testGetsSingleResourceAvailabilityForARequestTime() @@ -262,6 +253,6 @@ public function testGetsSingleResourceAvailabilityForARequestTime() ) ->willReturn($reservations); - $this->service->GetAvailability($resourceId1); + $this->service->GetAvailability(); } } diff --git a/tests/WebServices/SchedulesWebServiceTest.php b/tests/WebServices/SchedulesWebServiceTest.php index c4ce59be6..0fd8ef551 100644 --- a/tests/WebServices/SchedulesWebServiceTest.php +++ b/tests/WebServices/SchedulesWebServiceTest.php @@ -16,15 +16,9 @@ class SchedulesWebServiceTest extends TestBase */ private $server; - /** - * @var IScheduleRepository - */ - private $scheduleRepository; + private IScheduleRepository&\PHPUnit\Framework\MockObject\MockObject $scheduleRepository; - /** - * @var IPrivacyFilter - */ - private $privacyFilter; + private IPrivacyFilter&\PHPUnit\Framework\MockObject\MockObject $privacyFilter; public function setUp(): void { diff --git a/tests/WebServices/Validators/ResourceRequestValidatorTest.php b/tests/WebServices/Validators/ResourceRequestValidatorTest.php index 610370781..a7ab1e82f 100644 --- a/tests/WebServices/Validators/ResourceRequestValidatorTest.php +++ b/tests/WebServices/Validators/ResourceRequestValidatorTest.php @@ -9,10 +9,7 @@ class ResourceRequestValidatorTest extends TestBase */ private $validator; - /** - * @var IAttributeService - */ - private $attributeService; + private IAttributeService&\PHPUnit\Framework\MockObject\MockObject $attributeService; public function setUp(): void { diff --git a/tests/WebServices/Validators/UserRequestValidatorTest.php b/tests/WebServices/Validators/UserRequestValidatorTest.php index ee1953c3a..7b2aff2fe 100644 --- a/tests/WebServices/Validators/UserRequestValidatorTest.php +++ b/tests/WebServices/Validators/UserRequestValidatorTest.php @@ -4,20 +4,14 @@ class UserRequestValidatorTest extends TestBase { - /** - * @var IAttributeService - */ - private $attributeService; + private IAttributeService&\PHPUnit\Framework\MockObject\MockObject $attributeService; /** * @var UserRequestValidator */ private $validator; - /** - * @var IUserViewRepository - */ - private $userRepository; + private IUserViewRepository&\PHPUnit\Framework\MockObject\MockObject $userRepository; public function setUp(): void { diff --git a/tests/fakes/EmailFakes.php b/tests/fakes/EmailFakes.php index 6119ac2d6..ce448ba03 100644 --- a/tests/fakes/EmailFakes.php +++ b/tests/fakes/EmailFakes.php @@ -20,11 +20,13 @@ public function __construct() public function AddAddress($address, $name = '') { $this->addresses[] = $address; + return true; } public function Send() { $this->sendWasCalled = true; + return true; } public function IsHTML($bool = true)