Conversation
|
Hi, introducing new types has a lot of implications. I don't think we need a new type for >constant strings<, because we can read from the current ConstantStringType if its value is numeric or not. I'm thinking about introducing general NumericStringType for Can you please rework this PR without the new type class, and jus asking about whether |
|
Thanks for the quick reply! I guess it was confusing that ConstantNumericStringType is inherited from ConstantIntegerType. Let me explain my current understanding. We can't check is_numeric inside ConstantArrayType::hasOffsetValueType() as the key type would be ConstantIntegerType and it doesn't know if its value was string. $mappings = [
'21021200' => 'value', // key type would be ConstantIntegerType
];I was trying to return [
'1' => 'one', // if we treat '1' as ConstantStringType,
'two', // nextAutoIndex needs to be fixed
'three',
]I feel like it'd have many side effects. I wasn't aware of |
|
Hi, it doesn't matter whether some value was a string or not. You simply have an array of We can simply change |
|
I'm closing this pull request in favor of #214. Thanks! |
Attempt to fix phpstan/phpstan#3170.
While php treats
[1] === ['0' => 1]true and we can always use numeric string offset$array['0'], the below warning sounds reasonable to me:To keep this current behavior and handle arrays (intentionally) constructed with numeric string differently, this pull request introduces ConstantNumericStringType.