You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A typical usecase is to load classes from a given package by a given name:
use lang\reflection\Package;
$type= (newPackage('xp.xar.instruction'))->type(ucfirst($name).'Instruction');
This loads e.g. the class ExtractInstruction, which extends an abstract base class called Instruction (or implements an interface of that name). However, the above does not guarantee this from a type perspective, a class NotInstruction may exist that does not fulfill this contract.
Instead of having to add a check (using isSubclassOf(), e.g.), a new API should encapsulate this:
use lang\reflection\Implementations;
use xp\xar\Instruction;
$type= (newPackage('xp.xar.instruction'))->implementationsOf(Instruction::class)->type(ucfirst($name).'Instruction');
$type= Implementations::of(Instruction::class)->type('xp.xar.instruction.'.ucfirst($name).'Instruction');
$type= Implementations::of(Instruction::class)->in('xp.xar.instruction')->type(ucfirst($name).'Instruction');
The text was updated successfully, but these errors were encountered:
A typical usecase is to load classes from a given package by a given name:
This loads e.g. the class ExtractInstruction, which extends an abstract base class called Instruction (or implements an interface of that name). However, the above does not guarantee this from a type perspective, a class NotInstruction may exist that does not fulfill this contract.
Instead of having to add a check (using
isSubclassOf()
, e.g.), a new API should encapsulate this:The text was updated successfully, but these errors were encountered: