ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
07-to-new-method.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 if (!function_exists('toList')) {
22  function toList(): bool
23  {
24  class SomeClass
25  {
26  public function say(string $firstWord, string $secondWord): string
27  {
28  return $firstWord . $secondWord;
29  }
30  }
31 
32  global $DIC;
33 
34  $instance = new SomeClass();
35 
36  $refinery = $DIC->refinery();
37 
38  $transformation = $refinery->to()->toNew(
39  [$instance, 'say']
40  );
41 
42  $result = $transformation->transform(['Hello', ' World!']);
43 
44  return assert('Hello World!' === $result);
45  }
46 }
global $DIC
Definition: shib_login.php:22
toList()
Definition: 02-list.php:21