Skip to content

Conversation

azjezz
Copy link
Contributor

@azjezz azjezz commented Jun 3, 2025

closes #11465
closes #11466
closes #11464

@azjezz azjezz force-pushed the better-string-handling branch 2 times, most recently from dc17232 to 875e8ab Compare June 3, 2025 21:26
Comment on lines +211 to 221
'resourceOrFalseToString' => [
'code' => '<?php
$a = fopen("php://memory", "r");
if (rand(0, 1)) {
$a = [];
}

// b = "Array"|""|"Resource id #1"
$b = (string) $a;',
],
];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

previously considered failing due to the assumpton plsam made that [] can't be cast to string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@danog should we emit a warning of some sort when casting arrays to strings? it will always result in Array and casting whatever array to string is most likely a mistake.

@azjezz azjezz force-pushed the better-string-handling branch from 875e8ab to 1fae6ec Compare June 3, 2025 21:34
@azjezz
Copy link
Contributor Author

azjezz commented Jun 3, 2025

Unrelated note, there seem to be too many classes to represent string currently, I think it would make sense to reduce all T*String classes into a single, TString class, with properties that act as flags + literal string that can be either null ( not a literal ), or an instance of LiteralString which can have a value or not ( specified literal vs unspecified ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant