Conversation
| if ($binaryOperationNode->operator === BinaryOperator::PLUS | ||
| && $binaryOperationTypeResolver->resolveTypeOf($binaryOperationNode)->is(StringType::get()) | ||
| ) { | ||
| $operator = ' . '; |
There was a problem hiding this comment.
Yes this is partially weird, i initially had the logic checkIfAnyOfBinaryOperandNodesIsOfTypeString in this class, but then rembered the BinaryOperationTypeResolver should implement it.
This way we make indirectly use of it
transpiling |
|
We've been talking about this already, but for documentation purposes: I think, we ought not implement string concatenation via
The ComponentEngine has a way of doing string concatenation via template literals: I would assume that a legitimate intention behind adding string concatenation via console.log('what is the meaning of ' + 40 + 2);
console.log('what is the meaning of ' + (40 + 2));
console.log([] + []);
console.log(new Array(10).join(Number('String concatenation is a wonderful thing') + 'a')+' Batman!');Therefore, I'd like to argue to leave out this ambiguity and let template literals be the only way string concatenation can be done in the ComponentEngine. |
|
okay you win ^^ and nice one referencing the "Zen of Python" ^^ Also i think the history of js plays a role to why they have multiple ways: template strings are a newer feature and they need to stay backwards compatible with the old |
Was a fun thing to do :D Thanks to your great type system
Happy Easter!
is currently transpiled to
which is not valid php (should be
.)Also if we trigger a typecheck (e.g.) when using it directly as return like:
an expression will be thrown:
now it transpiles correctly:
i thought of the spec: if any of the operands is a string and the operator + is then well use string concatenation and resolve a string as return type