Skip to content

Conversation

@susnux
Copy link
Contributor

@susnux susnux commented Mar 18, 2025

Summary

In PHP array keys that are integers are always kept as integer, meaning the type of the key of $a = ["1" => "one"] will be integer not string.
While are hacks to circumvent this (case std object with string keys to an assoc. array) those hacks are performance wise awefull and also not needed as in PHP you can always access that element with $a[1] or $a["1"].

So TL;DR;: do not lie about return types.

Checklist

@susnux susnux requested a review from a team as a code owner March 18, 2025 13:30
@susnux susnux requested review from ArtificialOwl, icewind1991 and yemkareems and removed request for a team March 18, 2025 13:30
@susnux susnux added bug 3. to review Waiting for reviews php Pull requests that update Php code labels Mar 18, 2025
@susnux susnux added this to the Nextcloud 32 milestone Mar 18, 2025
@susnux susnux requested a review from come-nc March 18, 2025 13:35
In PHP array keys that are integers are always kept as integer,
meaning the type of the key of `$a = ["1" => "one"]` will be integer not
string.
While are hacks to circumvent this (case std object with string keys to
an assoc. array) those hacks are performance wise awefull and also not
needed as in PHP you can always access that element with `$a[1]` or
`$a["1"]`.

So TL;DR;: do not lie about return types.

Signed-off-by: Ferdinand Thiessen <[email protected]>
@susnux susnux merged commit 9f95c5f into master Mar 18, 2025
203 of 215 checks passed
@susnux susnux deleted the fix/IMimeTypeDetector-types branch March 18, 2025 16:13
@nextcloud-bot nextcloud-bot mentioned this pull request Aug 19, 2025
@skjnldsv skjnldsv modified the milestones: Nextcloud 32, Nextcloud 33 Sep 28, 2025
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 php Pull requests that update Php code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants