Skip to content

Instantly share code, notes, and snippets.

@illifw
Created June 21, 2025 11:53
Show Gist options
  • Select an option

  • Save illifw/e51460311ae0c2ebc2c1399bd4a26e4d to your computer and use it in GitHub Desktop.

Select an option

Save illifw/e51460311ae0c2ebc2c1399bd4a26e4d to your computer and use it in GitHub Desktop.
<?php
print Op::make(
name: 'add_i',
operator: '(int) +',
formula: '(int) ($a + $b)',
aType: 'int|float',
rType: 'int'
);
________________________________________________________________________
<?php
declare(strict_types=1);
# auto-generated://ILLI/System/Op/OP_add_i/IProto.php
# op-stream: ~i 8, flag(145897)
namespace be\ILLI\System\Op\OP_add_i;
use be\ILLI\System\Op\IProtoDefault;
use be\ILLI\System\Op\IOpAddI;
use be\ILLI\System\Op\OP_add_i\Proto;
interface IProto extends
IProtoDefault,
IOpAddI
{
/**
* @return Proto
*/
public const string Default = Proto::class;
public static function proto(
int|float $a,
int|float $b
): int;
/**
* Invoke operates `(int) +` on `(int) ($a + $b)`
* @param int|float $a value
* @param int|float $b value
* @return int
*/
public function __invoke(
int|float $a,
int|float $b
): int;
}
________________________________________________________________________
<?php
declare(strict_types=1);
# auto-generated://ILLI/System/Op/OP_add_i/Proto.php
# op-stream: ~i 8, flag(145897)
namespace be\ILLI\System\Op\OP_add_i;
use be\ILLI\System\Op\OP_add_i\IProto;
final readonly class Proto implements
IProto
{
public static function proto(
int|float $a,
int|float $b
): int {
return (int) ($a + $b);
}
public function __invoke(
int|float $a,
int|float $b
): int {
return static::proto(
$a,
$b
);
}
}
________________________________________________________________________
<?php
declare(strict_types=1);
# auto-generated://ILLI/System/Op/OP_add_i/IConstant.php
# op-stream: ~i 8, flag(145897)
namespace be\ILLI\System\Op\OP_add_i;
use be\ILLI\System\Op\IConstantDefault;
use be\ILLI\System\Op\IOpAddI;
use be\ILLI\System\Op\OP_add_i\Constant;
use be\ILLI\System\Op\OP_add_i\IProto;
interface IConstant extends
IConstantDefault,
IOpAddI
{
/**
* @return Constant
*/
public const string Default = Constant::class;
/**
* @return IProto
*/
public const string Proto = IProto::Default;
/**
* Invoke operates `(int) +` on `(int) ($this->fix + $dyn)`
* @param int|float $dyn value
* @return int
*/
public function __invoke(
int|float $dyn
): int;
}
________________________________________________________________________
<?php
declare(strict_types=1);
# auto-generated://ILLI/System/Op/OP_add_i/Constant.php
# op-stream: ~i 8, flag(145897)
namespace be\ILLI\System\Op\OP_add_i;
use be\ILLI\System\Op\OP_add_i\IConstant;
final readonly class Constant implements
IConstant
{
public function __construct(
private int|float $fix
) {
}
public function __invoke(
int|float $dyn
): int {
return static::Proto::proto(
$this->fix,
$dyn
);
}
}
________________________________________________________________________
<?php
declare(strict_types=1);
# auto-generated://ILLI/System/Op/IOpAddI.php
# op-stream: ~i 8, flag(145897)
namespace be\ILLI\System\Op;
use be\ILLI\System\Op\IOp;
/**
* Operator (int) (int|float $a + int|float $b)
*/
interface IOpAddI extends
IOp
{
final public const string OP = '(int) +';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment