Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.2 compatibility + phpstan fixes #944

Merged
merged 143 commits into from
Apr 23, 2024
Merged

PHP 8.2 compatibility + phpstan fixes #944

merged 143 commits into from
Apr 23, 2024

Conversation

iansltx
Copy link
Contributor

@iansltx iansltx commented May 24, 2023

Since this is a big PR (+1889,-2089 on PHP files) that I expect we'll have multiple folks reviewing, here's a list of all of its PHP files so we can make sure everything gets reviewed by at least one person:

Misc

  • .php-cs-fixer.php
  • inc/nginx-helper.php
  • public/index.php
  • scripts/newConsumerKeyFunc.php
  • src/ContainerFactory.php
  • tools/dbgen/generate.php

Controllers

  • src/Controller/ApplicationsController.php
  • src/Controller/BaseApiController.php
  • src/Controller/BaseTalkController.php
  • src/Controller/ContactController.php
  • src/Controller/DefaultController.php
  • src/Controller/EmailsController.php
  • src/Controller/EventCommentsController.php
  • src/Controller/EventHostsController.php
  • src/Controller/EventImagesController.php
  • src/Controller/EventsController.php
  • src/Controller/FacebookController.php
  • src/Controller/LanguagesController.php
  • src/Controller/TalkCommentsController.php
  • src/Controller/TalkLinkController.php
  • src/Controller/TalkTypesController.php
  • src/Controller/TalksController.php
  • src/Controller/TokenController.php
  • src/Controller/TracksController.php
  • src/Controller/TwitterController.php
  • src/Controller/UsersController.php

Exceptions + Header

  • src/Exception/AuthenticationException.php
  • src/Exception/AuthorizationException.php
  • src/Exception/Comment/TalkCommentDeletionException.php
  • src/Header.php

Models

  • src/Model/ApiMapper.php
  • src/Model/BaseModel.php
  • src/Model/BaseModelCollection.php
  • src/Model/ClientMapper.php
  • src/Model/ClientModel.php
  • src/Model/ClientModelCollection.php
  • src/Model/EventCommentMapper.php
  • src/Model/EventCommentReportModel.php
  • src/Model/EventCommentReportModelCollection.php
  • src/Model/EventHostMapper.php
  • src/Model/EventMapper.php
  • src/Model/LanguageMapper.php
  • src/Model/OAuthModel.php
  • src/Model/PendingTalkClaimMapper.php
  • src/Model/PendingTalkClaimModel.php
  • src/Model/PendingTalkClaimModelCollection.php
  • src/Model/TalkCommentMapper.php
  • src/Model/TalkCommentReportModel.php
  • src/Model/TalkCommentReportModelCollection.php
  • src/Model/TalkMapper.php
  • src/Model/TalkModel.php
  • src/Model/TalkModelCollection.php
  • src/Model/TalkTypeMapper.php
  • src/Model/TokenMapper.php
  • src/Model/TokenModel.php
  • src/Model/TokenModelCollection.php
  • src/Model/TrackMapper.php
  • src/Model/TwitterRequestTokenMapper.php
  • src/Model/TwitterRequestTokenModel.php
  • src/Model/TwitterRequestTokenModelCollection.php
  • src/Model/UserMapper.php

Request + Router

  • src/Request.php
  • src/Router/ApiRouter.php
  • src/Router/BaseRouter.php
  • src/Router/DefaultRouter.php
  • src/Router/Route.php
  • src/Router/VersionedRouter.php

Services

  • src/Service/BaseEmailService.php
  • src/Service/CommentReportedEmailService.php
  • src/Service/ContactEmailService.php
  • src/Service/EventApprovedEmailService.php
  • src/Service/EventCommentReportedEmailService.php
  • src/Service/EventRejectedEmailService.php
  • src/Service/EventSubmissionEmailService.php
  • src/Service/NullSpamCheckService.php
  • src/Service/SpamCheckService.php
  • src/Service/SpamCheckServiceInterface.php
  • src/Service/TalkAssignEmailService.php
  • src/Service/TalkClaimApprovedEmailService.php
  • src/Service/TalkClaimEmailService.php
  • src/Service/TalkClaimRejectedEmailService.php
  • src/Service/TalkCommentEmailService.php
  • src/Service/UserPasswordResetEmailService.php
  • src/Service/UserRegistrationEmailService.php
  • src/Service/UserUsernameReminderEmailService.php

View

  • src/View/ApiView.php
  • src/View/HtmlView.php
  • src/View/JsonPView.php
  • src/View/JsonView.php

Tests for Controllers

  • tests/ContainerFactoryTest.php
  • tests/Controller/ContactControllerTest.php
  • tests/Controller/EventHostsControllerTest.php
  • tests/Controller/TalkBase.php
  • tests/Controller/TalkLinkControllerTest.php
  • tests/Controller/TalkTypesControllerTest.php
  • tests/Controller/TalksControllerDeleteTest.php
  • tests/Controller/TalksControllerTest.php
  • tests/Controller/TokenControllerTest.php
  • tests/Controller/UsersControllerTest.php

Tests for headers, model, request

  • tests/HeaderTest.php
  • tests/Model/ApiMapperTest.php
  • tests/Model/EventHostMapperTest.php
  • tests/Model/OauthModelTest.php
  • tests/Model/TalkMapperTest.php
  • tests/Model/TestApiMapper.php
  • tests/RequestTest.php

Tests for Router

  • tests/Router/ApiRouterTest.php
  • tests/Router/DefaultRouterTest.php
  • tests/Router/RouteTest.php
  • tests/Router/RouterTest.php
  • tests/Router/TestController3.php
  • tests/Router/TestRouter3.php
  • tests/Router/VersionedRouterTest.php

Tests for services, view

  • tests/Service/CommentReportedEmailServiceTest.php
  • tests/Service/NullSpamCheckServiceTest.php
  • tests/Service/SpamCheckServiceTest.php
  • tests/Service/TalkCommentEmailServiceTest.php
  • tests/View/ApiViewTest.php
  • tests/View/JsonViewTest.php

@iansltx
Copy link
Contributor Author

iansltx commented May 24, 2023

Figure we can just solve the Stan errors while we're at this, since there are "only" 676 of them across 90 files.

@iansltx iansltx marked this pull request as ready for review June 3, 2023 00:36
heiglandreas
heiglandreas previously approved these changes Jun 6, 2023
Copy link
Member

@heiglandreas heiglandreas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work! Looks good to me, so I definitely approve that.

There are some comments that should be addressed in one or more future PRs but that would not stop me from merging this!

Only in the EventCommentMapper there seems to be something missing! Before merging someone should have a look at that.

@@ -67,7 +64,7 @@ public static function build(array $config, $rebuild = false): ContainerInterfac
return new ContactEmailService($config);
};

$container[ContactController::class] = $container->factory(static function (Container $c) use ($config) {
$container[ContactController::class] = $container->factory(static function ($c) use ($config) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we no longer typehinting $c?

@@ -10,7 +10,7 @@

class ApplicationsController extends BaseApiController
{
public function getApplication(Request $request, PDO $db)
public function getApplication(Request $request, PDO $db): array
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not add a typehint as to the array-shape?

@@ -55,7 +55,7 @@ public function usernameReminder(Request $request, PDO $db)

$list = $user_mapper->getUserByEmail($email);

if (!is_array($list['users']) || !count($list['users'])) {
if (!is_array($list) || !count($list['users'])) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!is_array($list) || !count($list['users'])) {
if (!is_array($list) || $list['users'] === []) {

*/
$row = $stmt->fetch(PDO::FETCH_ASSOC);

while ($row) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Here something seems to be missing! I am not seeing an assignement to $row within the while loop! What am I missing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's a bug added in cba1ffa

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey, since I messed this up, feel free to ping me :) I'll fix it. this happens if you only look blindly at phpstan errors and mix some "tiny" refactoring in...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@herndlm PR in the fix and I'll happily take it :). I would've either fixed or reached out but, well, I'm still awake in UTC-5 for work reasons 🙃

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @herndlm. Didn't check who "messed that up" (was a team effort after all 🙈) but feel free to fix it 😁

Comment on lines +355 to +357
if (!$response) {
throw new \RuntimeException('Could not retrieve talks', Http::INTERNAL_SERVER_ERROR);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the early return!

*
* @return bool
*/
public function tokenBelongsToTrustedApplication($accessToken)
public function tokenBelongsToTrustedApplication(?string $accessToken)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public function tokenBelongsToTrustedApplication(?string $accessToken)
public function tokenBelongsToTrustedApplication(?string $accessToken): bool

@@ -55,7 +55,7 @@ public function buildOutput($content)
*
* @return null
*/
protected function printArray(array $content)
protected function printArray(array $content): null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find a place where the returned value of this method actually is used. So shouldn't this be rather void?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
protected function printArray(array $content): null
protected function printArray(array $content): void

Comment on lines +76 to +77

return null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return null;

…-mapper

Fix row handling in EventCommentMapper
@github-actions
Copy link

github-actions bot commented Aug 8, 2023

This PR has been hanging around a bit too long, please update/rebase or comment as needed.

@github-actions github-actions bot closed this Oct 7, 2023
@iansltx iansltx reopened this Oct 7, 2023
@github-actions github-actions bot closed this Dec 6, 2023
@iansltx iansltx reopened this Dec 6, 2023
@iansltx
Copy link
Contributor Author

iansltx commented Apr 23, 2024

Merging this now. Will deploy over lunch in a few hours...and then fix whatever breaks.

@iansltx iansltx merged commit 41d2331 into joindin:master Apr 23, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants