mirror of
https://github.com/standardebooks/web.git
synced 2025-07-18 12:26:39 -04:00
Add Composer autoloading functions and PHPStan for testing
This commit is contained in:
parent
e198c4db65
commit
f5d7d4e02a
1518 changed files with 169063 additions and 30 deletions
134
vendor/nette/php-generator/src/PhpGenerator/Method.php
vendored
Normal file
134
vendor/nette/php-generator/src/PhpGenerator/Method.php
vendored
Normal file
|
@ -0,0 +1,134 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Nette Framework (https://nette.org)
|
||||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Nette\PhpGenerator;
|
||||
|
||||
use Nette;
|
||||
|
||||
|
||||
/**
|
||||
* Class method.
|
||||
*
|
||||
* @property string|null $body
|
||||
*/
|
||||
final class Method
|
||||
{
|
||||
use Nette\SmartObject;
|
||||
use Traits\FunctionLike;
|
||||
use Traits\NameAware;
|
||||
use Traits\VisibilityAware;
|
||||
use Traits\CommentAware;
|
||||
|
||||
/** @var string|null */
|
||||
private $body = '';
|
||||
|
||||
/** @var bool */
|
||||
private $static = false;
|
||||
|
||||
/** @var bool */
|
||||
private $final = false;
|
||||
|
||||
/** @var bool */
|
||||
private $abstract = false;
|
||||
|
||||
|
||||
/**
|
||||
* @param string|array $method
|
||||
* @return static
|
||||
*/
|
||||
public static function from($method): self
|
||||
{
|
||||
return (new Factory)->fromMethodReflection(Nette\Utils\Callback::toReflection($method));
|
||||
}
|
||||
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
try {
|
||||
return (new Printer)->printMethod($this);
|
||||
} catch (\Throwable $e) {
|
||||
trigger_error('Exception in ' . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function setBody(?string $code, array $args = null): self
|
||||
{
|
||||
$this->body = $args === null || $code === null ? $code : Helpers::formatArgs($code, $args);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function getBody(): ?string
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function setStatic(bool $state = true): self
|
||||
{
|
||||
$this->static = $state;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function isStatic(): bool
|
||||
{
|
||||
return $this->static;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function setFinal(bool $state = true): self
|
||||
{
|
||||
$this->final = $state;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function isFinal(): bool
|
||||
{
|
||||
return $this->final;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function setAbstract(bool $state = true): self
|
||||
{
|
||||
$this->abstract = $state;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function isAbstract(): bool
|
||||
{
|
||||
return $this->abstract;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @throws Nette\InvalidStateException
|
||||
*/
|
||||
public function validate(): void
|
||||
{
|
||||
if ($this->abstract && ($this->final || $this->visibility === ClassType::VISIBILITY_PRIVATE)) {
|
||||
throw new Nette\InvalidStateException('Method cannot be abstract and final or private.');
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue