In Java it's possible to write some concise functional code by using method references, for example:
class Foo {
public void method1(List<String> foo) {
foo.stream().map(this::method2);
}
private String method2(String s) {
return s.toLowerCase() + " bar";
}
}
Is there a way to do something similar in PHP more concise than:
class Foo {
public function method1(array $foo) {
array_map(
function ($s) {
return $this->method2($s);
},
$foo
);
}
private function method2(string $s) {
return strtolower($s) . "bar";
}
}