| Server IP : 127.0.1.1 / Your IP : 216.73.216.152 Web Server : Apache/2.4.52 (Ubuntu) System : Linux bahcrestlinepropertiesllc 5.15.0-113-generic #123-Ubuntu SMP Mon Jun 10 08:16:17 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/bahcrestline/core/vendor/hamcrest/hamcrest-php/generator/ |
Upload File : |
<?php
/*
Copyright (c) 2009 hamcrest.org
*/
class FactoryParameter
{
/**
* @var FactoryMethod
*/
private $method;
/**
* @var ReflectionParameter
*/
private $reflector;
public function __construct(FactoryMethod $method, ReflectionParameter $reflector)
{
$this->method = $method;
$this->reflector = $reflector;
}
public function getDeclaration()
{
if ($this->reflector->isArray()) {
$code = 'array ';
} else {
$class = $this->reflector->getClass();
if ($class !== null) {
$code = '\\' . $class->name . ' ';
} else {
$code = '';
}
}
$code .= '$' . $this->reflector->name;
if ($this->reflector->isOptional()) {
$default = $this->reflector->getDefaultValue();
if (is_null($default)) {
$default = 'null';
} elseif (is_bool($default)) {
$default = $default ? 'true' : 'false';
} elseif (is_string($default)) {
$default = "'" . $default . "'";
} elseif (is_numeric($default)) {
$default = strval($default);
} elseif (is_array($default)) {
$default = 'array()';
} else {
echo 'Warning: unknown default type for ' . $this->getMethod()->getFullName() . PHP_EOL;
var_dump($default);
$default = 'null';
}
$code .= ' = ' . $default;
}
return $code;
}
public function getInvocation()
{
return '$' . $this->reflector->name;
}
public function getMethod()
{
return $this->method;
}
}