for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types = 1);
namespace Innmind\Compose\Definition;
use Innmind\Compose\{
Definition\Argument\Type,
Exception\InvalidArgument
};
final class Argument
{
private $name;
private $type;
private $optional = false;
private $default;
public function __construct(Name $name, Type $type)
$this->name = $name;
$this->type = $type;
}
public function name(): Name
return $this->name;
public function makeOptional(): self
$self = clone $this;
$self->optional = true;
return $self;
public function defaultsTo(Name $name): self
$self->default = $name;
public function optional(): bool
return $this->optional;
public function hasDefault(): bool
return $this->default instanceOf Name;
public function default(): Name
return $this->default;
$this
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
class A { var $property; }
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.
/**
* @param mixed $value
*
* @throws InvalidArgument
*/
public function validate($value): void
if (!$this->type->accepts($value)) {
throw new InvalidArgument((string) $this->name);