Skip to content

Navigation Menu

Sign in
Sign up

refactor(Helper,TokenManager): migrate guest cookie access to IRequest add typing throughout - #5602

Open
joshtrichards wants to merge 12 commits into
main from
jtr/Helper-class-cleanup
Open

refactor(Helper,TokenManager): migrate guest cookie access to IRequest add typing throughout #5602
joshtrichards wants to merge 12 commits into
main from
jtr/Helper-class-cleanup

Conversation

@joshtrichards

@joshtrichards joshtrichards commented Apr 29, 2026
edited
Loading

Copy link
Copy Markdown
Member
  • Target version: main

Summary

Moves guest-name cookie access off the $_COOKIE superglobal and onto the injected IRequest service, and modernizes Helper and TokenManager with new typing/docs/etc.

Changes

lib/Helper.php

  • Add declare(strict_types=1)
  • Add type hints to constructor (?string $userId) and all method signatures
  • Refactor parseFileId(): cleaner logic, throw \InvalidArgumentException instead of \Exception (all call sites either already capture this via "catch-all" \Exception handling or already let it bubble up so should be a non-issue) , add explode limit for correctness, add typed array shape to @return
  • Null-check preg_replace result in getNewFileName() to avoid silent failure
  • Remove getGuestNameFromCookie() (moved to TokenManager which was the only caller anyway)
  • Add/improve docblocks throughout

lib/TokenManager.php

  • Inject IRequest via constructor
  • Move getGuestNameFromCookie() here as a private method using IRequest::getCookie() instead of $_COOKIE
  • Add missing return types (Wopi, string, void)
  • Reformat long method signatures (one parameter per line)
  • Clean up redundant docblock tags where type hints are now explicit

TODO

  • Test / see what I broke

Checklist

  • Code is properly formatted
  • Sign-off message is added to all commits
  • Documentation (manuals or wiki) has been updated or is not required

Eliminates two unnecessary/undesirable things: (1) a external static helper method that was only called here and only once; (2) accessing global state and `$_COOKIE` directly.
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
...ookies
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
@joshtrichards joshtrichards changed the title (削除) refactor: ... (削除ここまで) (追記) refactor(Helper,TokenManager): add strict types, type hints, and migrate guest cookie access to IRequest (追記ここまで) Apr 29, 2026
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
@joshtrichards joshtrichards changed the title (削除) refactor(Helper,TokenManager): add strict types, type hints, and migrate guest cookie access to IRequest (削除ここまで) (追記) refactor(Helper,TokenManager): migrate guest cookie access to IRequest + light refactoring (追記ここまで) Apr 30, 2026
joshtrichards marked this pull request as ready for review April 30, 2026 01:46
@joshtrichards joshtrichards changed the title (削除) refactor(Helper,TokenManager): migrate guest cookie access to IRequest + light refactoring (削除ここまで) (追記) refactor(Helper,TokenManager): migrate guest cookie access to IRequest add typing throughout (追記ここまで) May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@elzody elzody Awaiting requested review from elzody elzody is a code owner
@juliusknorr juliusknorr Awaiting requested review from juliusknorr juliusknorr is a code owner

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

3. to review Ready to be reviewed technical debt

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /