1. Go to this page and download the library: Download donatj/php-dnf-solver library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
donatj / php-dnf-solver example snippets
namespace Examples;
use donatj\PhpDnfSolver\DNF;
use donatj\PhpDnfSolver\Types\UserDefinedType;
lements B, C {}
class Baz implements C, D {}
$qux = function ( A|(B&C) $aOrB ) : void {};
$quxParamType = (new \ReflectionFunction($qux))->getParameters()[0]->getType();
$quxDnf = DNF::getFromReflectionType($quxParamType);
var_dump($quxDnf->isSatisfiedBy(
new UserDefinedType(Foo::class)
)); // true
var_dump($quxDnf->isSatisfiedBy(
new UserDefinedType(Bar::class)
)); // true
var_dump($quxDnf->isSatisfiedBy(
new UserDefinedType(Baz::class)
)); // false
namespace Examples;
use donatj\PhpDnfSolver\Types\AndClause;
use donatj\PhpDnfSolver\Types\BuiltInType;
use donatj\PhpDnfSolver\Types\OrClause;
use donatj\PhpDnfSolver\Types\UserDefinedType;
ew OrClause(
new UserDefinedType(A::class),
new AndClause(
new UserDefinedType(B::class),
new UserDefinedType(C::class)
)
))->dnf()); // A|(B&C)
var_dump((new OrClause(
new AndClause(new UserDefinedType(A::class), new UserDefinedType(B::class)),
new AndClause(
new UserDefinedType(B::class),
new UserDefinedType(C::class)
),
new BuiltInType('null'),
))->dnf()); // (A&B)|(B&C)|null
function getFromReflectionType(\ReflectionType $type) : \donatj\PhpDnfSolver\SingularDnfTypeInterface|\donatj\PhpDnfSolver\NestedDnfTypeInterface
function reflectionTypeSatisfiesReflectionType(\ReflectionType $satisfyingType, \ReflectionType $satisfiedType) : bool
function getFromVarType(\ReflectionParameter|\ReflectionProperty $parameter) : \donatj\PhpDnfSolver\SingularDnfTypeInterface|\donatj\PhpDnfSolver\NestedDnfTypeInterface|null
function getFromReturnType(\ReflectionFunctionAbstract $func) : \donatj\PhpDnfSolver\SingularDnfTypeInterface|\donatj\PhpDnfSolver\NestedDnfTypeInterface|null
function __construct(\donatj\PhpDnfSolver\SingularDnfTypeInterface ...$types)
function dnf() : string
function isSatisfiedBy(\donatj\PhpDnfSolver\SingularDnfTypeInterface|\donatj\PhpDnfSolver\NestedDnfTypeInterface $value) : bool
function count() : int
function getTypes() : array
function __construct(string $name)
function dnf() : string
function getTypeName() : string
function isSatisfiedBy(\donatj\PhpDnfSolver\SingularDnfTypeInterface|\donatj\PhpDnfSolver\NestedDnfTypeInterface $value) : bool
function count() : int
function dnf() : string
function isSatisfiedBy(\donatj\PhpDnfSolver\SingularDnfTypeInterface|\donatj\PhpDnfSolver\NestedDnfTypeInterface $value) : bool
function getTypeName() : string
function count() : int
function __construct(\donatj\PhpDnfSolver\Types\AndClause|\donatj\PhpDnfSolver\SingularDnfTypeInterface ...$types)
function dnf() : string
function isSatisfiedBy(\donatj\PhpDnfSolver\SingularDnfTypeInterface|\donatj\PhpDnfSolver\NestedDnfTypeInterface $value) : bool
function count() : int
function getTypes() : array
namespace donatj\PhpDnfSolver\Types;
class UserDefinedType {
public $className;
}
function __construct(string $className)
function dnf() : string
function getTypeName() : string
function isSatisfiedBy(\donatj\PhpDnfSolver\SingularDnfTypeInterface|\donatj\PhpDnfSolver\NestedDnfTypeInterface $value) : bool
function count() : int
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.