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

Cast string type for trim() #38910

Merged
merged 5 commits into from Jul 5, 2023
Merged

Conversation

dartcafe
Copy link
Contributor

@dartcafe dartcafe commented Jun 20, 2023

Summary

  • Remove PHP 8.1 deprecaition message
  • cast trim() parameter to string to avoid null as string parameter

@szaimen szaimen added bug 3. to review Waiting for reviews labels Jun 20, 2023
@szaimen szaimen requested review from a team, ArtificialOwl, icewind1991 and Fenn-CS and removed request for a team June 20, 2023 13:14
@dartcafe dartcafe force-pushed the fix/nullish-trim-deprecation-warning branch from 9b31680 to 28b0dd5 Compare June 20, 2023 13:17
Copy link
Contributor

@Fenn-CS Fenn-CS left a comment

Choose a reason for hiding this comment

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

I think trim($fromDefault ?? "", "()"); would you consider this syntax instead?

thank you!

@dartcafe dartcafe changed the title add type #38909 Cast string type for trim() Jun 20, 2023
CarlSchwan and others added 5 commits June 20, 2023 18:35
- Fix various psalm issues
- Add as much typing as possible while preserving stable API

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Signed-off-by: dartcafe <github@dartcafe.de>
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Signed-off-by: dartcafe <github@dartcafe.de>
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Signed-off-by: dartcafe <github@dartcafe.de>
Signed-off-by: dartcafe <github@dartcafe.de>
Signed-off-by: dartcafe <github@dartcafe.de>
@dartcafe dartcafe force-pushed the fix/nullish-trim-deprecation-warning branch from 213d396 to 2211721 Compare June 20, 2023 16:35
public function handle(Event $event): void {
if (!($event instanceof CommentsEntityEvent)) {
// Unrelated
return;
}

$event->addEntityCollection('files', function ($name) {
$nodes = \OC::$server->getUserFolder()->getById((int)$name);
$event->addEntityCollection('files', function ($name): bool {

Check notice

Code scanning / Psalm

MissingClosureParamType Note

Parameter $name has no provided type
$event->addEntityCollection('files', function ($name) {
$nodes = \OC::$server->getUserFolder()->getById((int)$name);
$event->addEntityCollection('files', function ($name): bool {
$nodes = $this->rootFolder->getUserFolder($this->userId)->getById((int)$name);

Check notice

Code scanning / Psalm

PossiblyNullArgument Note

Argument 1 of OCP\Files\IRootFolder::getUserFolder cannot be null, possibly null value provided
*
* @param array $mentions
* @return string[] containing the mentions, e.g. ['alice', 'bob']
* @return list<string> containing the mentions, e.g. ['alice', 'bob']

Check notice

Code scanning / Psalm

MoreSpecificReturnType Note

The declared return type 'list' for OCA\Comments\Notification\Listener::extractMentions is more specific than the inferred return type 'list'
Copy link
Contributor

@Fenn-CS Fenn-CS left a comment

Choose a reason for hiding this comment

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

Thank you!

Might be a good idea to fixup the last commit into the last but one commit.

@dartcafe
Copy link
Contributor Author

The last commits come from the master branch. I can open a clean PR if necessary.

@nickvergessen nickvergessen merged commit 21821d8 into master Jul 5, 2023
37 checks passed
@nickvergessen nickvergessen deleted the fix/nullish-trim-deprecation-warning branch July 5, 2023 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug
Projects
None yet
7 participants