Critical impossibility for truthiness validation in PHP #48
Replies: 4 comments 3 replies
-
|
Full agreement this kind of thing should be brought up in our discussions; and why we need representation from the broader ecosystem! I was unaware of this quirk in PHP... that Is this... typical? Why does it do this? I'm sure there's a reason -- it's just surprising to me. If it would smooth things out, I could be open to potentially specifying that But I'm unsure if that fully resolves issues, what happens if you use |
Beta Was this translation helpful? Give feedback.
-
|
Also, one thing I'd like to clarify, this is why we have the phase system :) The arithmetic operator proposal is still in Phase 1, which tries to validate the proposal against multiple implementations. In Phase 1 / 2: This could be considered friction / a reasonable community concern, warranting an amendment to the proposal, or at a minimum, discussion around it. |
Beta Was this translation helpful? Give feedback.
-
|
@TotalTechGeek I guess I didn't fully understand the phases, thanks for pointing it out! Regarding php stuff; Same as you I've been trying to contact Jeremy with little success to ask for help on some stuff and also to collaborate in the php library but it has not been possible so ported my Ruby one. In PHP there's this thing about Arrays and objects being the same in its core, thus you can define This is a blocker for the invalid operation proposal in PHP since there's no way to fulfill it... Nonetheless, there's one important thing to keep in mind: Php also implements I don't know what to do here... I'd also prefer to throw an error but it just won't rub correctly with php. |
Beta Was this translation helpful? Give feedback.
-
|
You can provide an Array wrapper to ensable it, not as native but works and compensate langagues lcks |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello JSON Logic! Recently I found myself with a small detail while working on a PHP port of
shiny_json_logic_ruby:It was accepted that we would work with or without syntactic sugaring so both of these would work:
{ "+": 1 } => 1 { "+": [1] } => 1and it was also accepted that arithmetic operations with types different than numbers would throw a NaN
{ "+": {} } => NaNUnless we do Arrays where we understand absense of numbers:
{ "+": [] } => 0But PHP parses json with
json_decodeand he associative flag (set tofalseas a default) but when set totrueit renders hashes as the native php associative arrays, thus this happens:Aaaaaand because of this
Having agreements in place already I don't think there's too much we can do about it, but I want to report it because I think we didn't thought about the possibilities in all languages when accepting/rejecting proposals and this research should probably be part of the pipeline process.
I'd love to hear your opinions, thanks!!
Beta Was this translation helpful? Give feedback.
All reactions