Le dimanche 1 mai 2016, 00:20:45 Dan Ackroyd a écrit : > However, it is not the proposed new syntax that makes the code more > readable - it is solely due to writing it in the correct order that > makes the code more readable. This can be done using current PHP > syntax, so that the code is: > > $dirEntries = scandir($arg); > $files = array_filter($filesAndDirectories, function($x) { return > $x !== '.' && $x != '..'; }); > $fullPaths = array_map(function ($x) use ($arg) { return $arg . '/' . > $x; }, $files) > $fileInfo = getFileArg($fullPaths); > $ret = array_merge($ret, $fileListInfo); > > Using the proposed new syntax to rewrite it without the intermediate > variables like this. > > $ret = scandir($arg) > |> array_filter($$, function($x) { return $x !== '.' && $x != '..'; }) > |> array_map(function ($x) use ($arg) { return $arg . '/' . $x; }, $$) > |> getFileArg($$) > |> array_merge($ret, $$); > > Does not now show a marked improvement in readability.
Yeah, then why is the first code you wrote containing errors and not the second one? I have to read carefully the first one to see that the variables used in the code are not the same one returned from the line above. There is no need for this in the second one which is much clearer, each call reuses the return from the function above. I had no opinion on this RFC until people started to explain using 100 variables for such simple things is the best solution. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php