(php) Anonymous functions without {} block not highlighted correctly
See original GitHub issueDescribe the issue
Highlighter seems to expect a title in PHP arrow functions, even though they are intentionally anonymous.
Which language seems to have the issue?
php
Sample Code to Reproduce
<?php
$fn1 = fn($x) => $x + $y;
Expected behavior
Additional context Found in an Code-Golf answer, but also reproduces in the ungolfed version:
fn( $s ) =>
( $l = strlen( $s ) ) > 1 ? // is input longer than one char?
max( count_chars( $s ) ) > 1 ? // has more than 1 of any single char?
'Bunny' // if so, contains dupes so... Bunny it is
: // else, no dupes
[
'T' => [ 'Ka', 'Hu' ], // two dimensional associative
'C' => [ 'Rai', 'Do' ], // array containing handsign
'J' => [ 'Hyo', 'Sui' ] // and length as indexes
]
[ $s[-1] ] // access array by last letter and
[ $l % 2 ] // length mod 2 (2 == 0, 3 == 1)
. 'ton' // and append "ton"
: // finally...
'Fuma Shuriken' // input length was only one char
The comments are colored orange because they are considered
title
.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Anonymous functions - Manual - PHP
Anonymous functions, also known as closures , allow the creation of functions which have no specified name. They are most useful as the...
Read more >php - Anonymous Function/Closure and using self:: or static
Show activity on this post. I am working with anonymous functions where I am creating anonymous function outside of the object, and then...
Read more >PHP return type declaration not highlighted on anonymous ...
In PHP, the return type declaration on an anonymous function (closure) is not highlighted in the same colour as the same type declaration...
Read more >How To Write Conditional Statements in PHP - DigitalOcean
The first argument is the $products array. The second is an anonymous function which tells the usort function what to do with each...
Read more >Functions — reusable blocks of code - Learn web development
Bear in mind that some built-in browser functions are not part of the core ... This is called an anonymous function, because it...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oh, title will match it… so you’d just need a special case rule inside
contains
to explicitly handleuse
and mark it as a keyword… I’m assuming use is not a valid function name.Perhaps:
This does it.