This repository has been archived by the owner on Mar 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Consistency.php
1107 lines (962 loc) · 28.5 KB
/
Consistency.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Hoa
*
*
* @license
*
* New BSD License
*
* Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Hoa nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
namespace Hoa\Core\Consistency {
use Hoa\Core;
use Hoa\Stream;
/**
* Hard-preload.
*/
define('PATH_EVENT', __DIR__ . DIRECTORY_SEPARATOR . 'Event.php');
define('PATH_EXCEPTION', __DIR__ . DIRECTORY_SEPARATOR . 'Exception.php');
define('PATH_DATA', __DIR__ . DIRECTORY_SEPARATOR . 'Data.php');
/**
* Class Hoa\Core\Consistency.
*
* This class manages all classes, importations etc.
*
* @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
class Consistency
{
/**
* One singleton by library family.
*
* @var array
*/
private static $_multiton = [];
/**
* Libraries to considere.
*
* @var array
*/
protected $_from = null;
/**
* Library's roots to considere.
*
* @var array
*/
protected $_roots = [];
/**
* Cache all imports.
*
* @var array
*/
protected static $_cache = [];
/**
* Cache all classes informations: path, alias and imported.
*
* @var array
*/
protected static $_class = [
// Hard-preload.
'Hoa\Core\Event' => [
'path' => PATH_EVENT,
'alias' => null
],
'Hoa\Core\Exception' => [
'path' => PATH_EXCEPTION,
'alias' => null
],
'Hoa\Core\Data' => [
'path' => PATH_DATA,
'alias' => null
]
];
/**
* Cache all classes from the current library family.
* It contains references to self:$_class.
*
* @var array
*/
protected $__class = [];
/**
* Singleton to manage a library family.
*
* @param string $from Library family's name.
* @return void
*/
private function __construct($from)
{
$this->_from = preg_split('#\s*(,|or)\s*#', trim($from, '()'));
$parameters = Core::getInstance()->getParameters();
$wildcard = $parameters->getFormattedParameter('namespace.prefix.*');
foreach ($this->_from as $f) {
$this->setRoot(
$parameters->getFormattedParameter('namespace.prefix.' . $f)
?: $wildcard,
$f
);
}
return;
}
/**
* Get the library family's singleton.
*
* @param string $namespace Library family's name.
* @return \Hoa\Core\Consistency
*/
public static function from($namespace)
{
if (!isset(static::$_multiton[$namespace])) {
static::$_multiton[$namespace] = new static($namespace);
}
return static::$_multiton[$namespace];
}
/**
* Import a class, an interface or a trait.
*
* @param string $pattern Pattern.
* @param bool $load Whether loading directly or not.
* @return \Hoa\Core\Consistency
*/
public function import($pattern, $load = false)
{
foreach ($this->_from as $from) {
$this->_import($from . '.' . $pattern, $load);
}
return $this;
}
/**
* Iterate over each solution found by an import.
*
* @param string $pattern Pattern.
* @param callable $callback Callback (also disable cache).
* @return \Hoa\Core\Consistency
*/
public function foreachImport($pattern, $callback)
{
foreach ($this->_from as $from) {
$this->_import($from . '.' . $pattern, false, $callback);
}
return $this;
}
/**
* Real import implementation.
*
* @param string $pattern Pattern.
* @param bool $load Whether loading directly or not.
* @param callable $callback Callback.
* @return bool
*/
protected function _import($pattern, $load, $callback = null)
{
$parts = explode('.', $pattern);
if (!isset($parts[1])) {
return false;
}
if (false !== strpos($pattern, '~')) {
$handle = null;
foreach ($parts as &$part) {
if (null !== $handle && '*' !== $handle) {
$part = str_replace('~', $handle, $part);
}
$handle = $part;
}
}
if (false !== strpos($pattern, '*')) {
if ('Hoa' !== $parts[0] && 'Hoathis' !== $parts[0]) {
return false;
}
$glob = new \AppendIterator();
$ds = preg_quote(DS);
$_pattern = '#' . $ds . $parts[0] . $ds . $parts[1] . $ds . '?$#i';
foreach (resolve('hoa://Library/' . $parts[1], true, true) as $path) {
if (0 !== preg_match($_pattern, $path)) {
$glob->append(new \CallbackFilterIterator(
new \GlobIterator(
$path . DS . implode(DS, array_slice($parts, 2)) . '.php',
\GlobIterator::KEY_AS_PATHNAME
| \GlobIterator::CURRENT_AS_SELF
| \GlobIterator::SKIP_DOTS
),
function ($current, $key) use ($path, $parts) {
$current->__hoa_pattern =
$parts[0] .
'.' .
$parts[1] .
'.' .
str_replace(
DS,
'.',
substr($key, strlen($path) + 1, -4)
);
return true;
}
));
}
}
$out = true;
foreach ($glob as $filesystem) {
$out &= $this->_import($filesystem->__hoa_pattern, $load, $callback);
}
return (bool) $out;
}
$classname = implode('\\', $parts);
$imported = array_key_exists($classname, static::$_class);
if (false === $imported) {
static::$_class[$classname] = [
'path' => null,
'alias' => null
];
$count = count($parts);
if ($parts[$count - 2] === $parts[$count - 1]) {
$alias = implode('\\', array_slice($parts, 0, -1));
static::$_class[$classname]['alias'] = $alias;
static::$_class[$alias] = $classname;
$this->__class[$alias] = &static::$_class[$alias];
}
}
$this->__class[$classname] = &static::$_class[$classname];
if (true === $load &&
false === static::entityExists($classname, false)) {
spl_autoload_call($classname);
if (null !== $callback &&
true === static::entityExists($classname, false)) {
$callback($classname);
}
return true;
}
if (null !== $callback) {
$callback($classname);
}
return true;
}
/**
* Autoloader.
*
* @param string $classname Classname.
* @return bool
*/
public static function autoload($classname)
{
if (false === strpos($classname, '\\')) {
return false;
}
$classname = ltrim($classname, '\\');
// Hard-preload.
if ('Hoa\Core' === substr($classname, 0, 8) &&
false !== ($pos = strpos($classname, '\\', 10)) &&
'Bin\\' !== substr($classname, 9, 4)) {
require static::$_class[substr($classname, 0, $pos)]['path'];
return true;
}
$head = substr($classname, 0, strpos($classname, '\\'));
if (false === array_key_exists($classname, static::$_class)) {
$_classname = str_replace('\\', '.', $classname);
$out = from($head)->_import($_classname, true);
if (false === static::entityExists($classname)) {
$out = from($head)->_import($_classname . '.~', true);
}
return $out;
} elseif (is_string($original = static::$_class[$classname])) {
spl_autoload_call($original);
return true;
}
$roots = from($head)->getRoot();
$classpath = str_replace('\\', DS, $classname) . '.php';
$classpathExtended = str_replace(
'\\',
DS,
$classname . substr($classname, strrpos('\\', $classname, 1))
) . '.php';
$gotcha = false;
foreach ($roots as $vendor => $_roots) {
foreach ($_roots as $root) {
if (true === file_exists($path = $root . $classpath) ||
true === file_exists($path = $root . $classpathExtended)) {
$gotcha = true;
require $path;
static::$_class[$classname]['path'] = $path;
break 2;
}
}
}
return $gotcha;
}
/**
* Dynamic new, i.e. a native factory (import + load + instance).
*
* @param string $classname Classname.
* @param array $arguments Constructor's arguments.
* @return object
* @throws \Hoa\Core\Exception
*/
public static function dnew($classname, Array $arguments = [])
{
$classname = ltrim($classname, '\\');
if (!class_exists($classname, false)) {
$head = substr($classname, 0, $pos = strpos($classname, '\\'));
$tail = str_replace('\\', '.', substr($classname, $pos + 1));
$from = from($head);
foreach ([$tail, $tail . '.~'] as $_tail) {
foreach ($from->getFroms() as $_from) {
$break = false;
$from->_import(
$_from . '.' . $_tail,
true,
function ($_classname) use (&$break, &$classname) {
$classname = $_classname;
$break = true;
}
);
if (true === $break) {
break 2;
}
}
}
}
$class = new \ReflectionClass($classname);
if (empty($arguments) || false === $class->hasMethod('__construct')) {
return $class->newInstance();
}
return $class->newInstanceArgs($arguments);
}
/**
* Set the root of the current library family.
*
* @param bool $root Root.
* @param string $from Library family's name (if null, first family
* will be choosen).
* @return \Hoa\Core\Consistency
*/
public function setRoot($root, $from = null)
{
if (null === $from) {
$from = $this->_from[0];
}
if (!isset($this->_roots[$from])) {
$this->_roots[$from] = [];
}
foreach (explode(RS, $root) as $r) {
$this->_roots[$from][] = rtrim($r, '/\\') . DS;
}
return $this;
}
/**
* Get roots of the current library family.
*
* @return array
*/
public function getRoot()
{
return $this->_roots;
}
/**
* Get froms.
*
* @return array
*/
public function getFroms()
{
return $this->_from;
}
/**
* Get imported classes from the current library family.
*
* @return array
*/
public function getImportedClasses()
{
return $this->__class;
}
/**
* Get imported classes from all library families.
*
* @return array
*/
public static function getAllImportedClasses()
{
return static::$_class;
}
/**
* Get the shortest name for an entity.
*
* @param string $entityName Entity name.
* @return string
*/
public static function getEntityShortestName($entityName)
{
$parts = explode('\\', $entityName);
$count = count($parts);
if ($parts[$count - 2] === $parts[$count - 1]) {
return implode('\\', array_slice($parts, 0, -1));
}
return $entityName;
}
/**
* Check if an entity exists (class, interface, trait…).
*
* @param string $entityName Entity name.
* @param bool $autoloader Run autoloader if necessary.
* @return bool
*/
public static function entityExists($entityName, $autoloader = false)
{
return
class_exists($entityName, $autoloader) ||
interface_exists($entityName, false) ||
trait_exists($entityName, false);
}
/**
* Declare a flex entity (for nested library).
*
* @param string $entityName Entity name.
* @return bool
*/
public static function flexEntity($entityName)
{
return class_alias(
$entityName,
static::getEntityShortestName($entityName)
);
}
/**
* Whether a word is reserved or not.
*
* @param string $word Word.
* @return void
*/
public static function isKeyword($word)
{
static $_list = [
// PHP keywords.
'__halt_compiler',
'abstract',
'and',
'array',
'as',
'bool',
'break',
'callable',
'case',
'catch',
'class',
'clone',
'const',
'continue',
'declare',
'default',
'die',
'do',
'echo',
'else',
'elseif',
'empty',
'enddeclare',
'endfor',
'endforeach',
'endif',
'endswitch',
'endwhile',
'eval',
'exit',
'extends',
'false',
'final',
'float',
'for',
'foreach',
'function',
'global',
'goto',
'if',
'implements',
'include',
'include_once',
'instanceof',
'insteadof',
'int',
'interface',
'isset',
'list',
'mixed',
'namespace',
'new',
'null',
'numeric',
'object',
'or',
'print',
'private',
'protected',
'public',
'require',
'require_once',
'resource',
'return',
'static',
'string',
'switch',
'throw',
'trait',
'true',
'try',
'unset',
'use',
'var',
'while',
'xor',
'yield',
// Compile-time constants.
'__class__',
'__dir__',
'__file__',
'__function__',
'__line__',
'__method__',
'__namespace__',
'__trait__'
];
return in_array(strtolower($word), $_list);
}
/**
* Whether an ID is a valid PHP identifier.
*
* @param string $id ID.
* @return bool
*/
public static function isIdentifier($id)
{
return 0 !== preg_match(
'#^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$#',
$id
);
}
}
/**
* Class Hoa\Core\Consistency\Xcallable.
*
* Build a callable object, i.e. function, class::method, object->method or
* closure, they all have the same behaviour. This callable is an extension of
* native PHP callable (aka callback) to integrate Hoa's structures.
*
* @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
class Xcallable
{
/**
* Callback, with the PHP format.
*
* @var mixed
*/
protected $_callback = null;
/**
* Callable hash.
*
* @var string
*/
protected $_hash = null;
/**
* Build a callback.
* Accepted forms:
* • 'function';
* • 'class::method';
* • 'class', 'method';
* • $object, 'method';
* • $object, '';
* • function ( … ) { … };
* • ['class', 'method'];
* • [$object, 'method'].
*
* @param mixed $call First callable part.
* @param mixed $able Second callable part (if needed).
* @return mixed
*/
public function __construct($call, $able = '')
{
if (null === $call) {
return null;
}
if ($call instanceof \Closure) {
$this->_callback = $call;
return;
}
if (!is_string($able)) {
throw new Core\Exception(
'Bad callback form.',
0
);
}
if ('' === $able) {
if (is_string($call)) {
if (false === strpos($call, '::')) {
if (!function_exists($call)) {
throw new Core\Exception(
'Bad callback form.',
1
);
}
$this->_callback = $call;
return;
}
list($call, $able) = explode('::', $call);
} elseif (is_object($call)) {
if ($call instanceof Stream\IStream\Out) {
$able = null;
} elseif (method_exists($call, '__invoke')) {
$able = '__invoke';
} else {
throw new Core\Exception(
'Bad callback form.',
2
);
}
} elseif (is_array($call) && isset($call[0])) {
if (!isset($call[1])) {
return $this->__construct($call[0]);
}
return $this->__construct($call[0], $call[1]);
} else {
throw new Core\Exception(
'Bad callback form.',
3
);
}
}
$this->_callback = [$call, $able];
return;
}
/**
* Call the callable.
*
* @param ...
* @return mixed
*/
public function __invoke()
{
$arguments = func_get_args();
$valid = $this->getValidCallback($arguments);
return call_user_func_array($valid, $arguments);
}
/**
* Distribute arguments according to an array.
*
* @param array $arguments Arguments.
* @return mixed
*/
public function distributeArguments(Array $arguments)
{
return call_user_func_array([$this, '__invoke'], $arguments);
}
/**
* Get a valid callback in the PHP meaning.
*
* @param array &$arguments Arguments (could determine method on an
* object if not precised).
* @return mixed
*/
public function getValidCallback(Array &$arguments = [])
{
$callback = $this->_callback;
$head = null;
if (isset($arguments[0])) {
$head = &$arguments[0];
}
// If method is undetermined, we find it (we understand event bucket and
// stream).
if (null !== $head &&
is_array($callback) &&
null === $callback[1]) {
if ($head instanceof Core\Event\Bucket) {
$head = $head->getData();
}
switch ($type = gettype($head)) {
case 'string':
if (1 === strlen($head)) {
$method = 'writeCharacter';
} else {
$method = 'writeString';
}
break;
case 'boolean':
case 'integer':
case 'array':
$method = 'write' . ucfirst($type);
break;
case 'double':
$method = 'writeFloat';
break;
default:
$method = 'writeAll';
$head = $head . "\n";
}
$callback[1] = $method;
}
return $callback;
}
/**
* Get hash.
* Will produce:
* * function#…;
* * class#…::…;
* * object(…)#…::…;
* * closure(…).
*
* @return string
*/
public function getHash()
{
if (null !== $this->_hash) {
return $this->_hash;
}
$_ = &$this->_callback;
if (is_string($_)) {
return $this->_hash = 'function#' . $_;
}
if (is_array($_)) {
return
$this->_hash =
(is_object($_[0])
? 'object(' . spl_object_hash($_[0]) . ')' .
'#' . get_class($_[0])
: 'class#' . $_[0]) .
'::' .
(null !== $_[1]
? $_[1]
: '???');
}
return $this->_hash = 'closure(' . spl_object_hash($_) . ')';
}
/**
* Get appropriated reflection instance.
*
* @param ...
* @return \Reflector
*/
public function getReflection()
{
$arguments = func_get_args();
$valid = $this->getValidCallback($arguments);
if (is_string($valid)) {
return new \ReflectionFunction($valid);
}
if ($valid instanceof \Closure) {
return new \ReflectionFunction($valid);
}
if (is_array($valid)) {
if (is_string($valid[0])) {
if (false === method_exists($valid[0], $valid[1])) {
return new \ReflectionClass($valid[0]);
}
return new \ReflectionMethod($valid[0], $valid[1]);
}
$object = new \ReflectionObject($valid[0]);
if (null === $valid[1]) {
return $object;
}
return $object->getMethod($valid[1]);
}
}
/**
* Return the hash.
*
* @return string
*/
public function __toString()
{
return $this->getHash();
}
}
}
namespace {
/**
* Implement a fake trait_exists function.
*
* @param string $traitname Traitname.
* @param bool $autoload Autoload.
* @return bool
*/
if (!function_exists('trait_exists')) {
function trait_exists($traitname, $autoload = true)
{
if (true == $autoload) {
class_exists($traitname, true);
}
return false;
}
}
if (70000 > PHP_VERSION_ID && false === interface_exists('Throwable', false)) {
/**
* Implement a fake Throwable class, introduced in PHP7.0.
*/
interface Throwable
{
public function getMessage();
public function getCode();
public function getFile();
public function getLine();
public function getTrace();
public function getPrevious();
public function getTraceAsString();
public function __toString();
}
}
/**
* Alias for \Hoa\Core\Consistency::from().
*
* @param string $namespace Library family's name.
* @return \Hoa\Core\Consistency
*/
if (!function_exists('from')) {
function from($namespace)
{
return Hoa\Core\Consistency::from($namespace);
}
}
/**
* Alias of \Hoa\Core\Consistency::dnew().
*
* @param string $classname Classname.
* @param array $arguments Constructor's arguments.
* @return object
*/
if (!function_exists('dnew')) {
function dnew($classname, Array $arguments = [])
{
return Hoa\Core\Consistency::dnew($classname, $arguments);
}
}
/**
* Alias of \Hoa\Core\Consistency\Xcallable.
*
* @param mixed $call First callable part.
* @param mixed $able Second callable part (if needed).
* @return mixed
*/
if (!function_exists('xcallable')) {
function xcallable($call, $able = '')
{
if ($call instanceof Hoa\Core\Consistency\Xcallable) {
return $call;
}