mirror of
https://github.com/standardebooks/web.git
synced 2025-07-12 01:22:23 -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
70
vendor/nette/php-generator/src/PhpGenerator/Closure.php
vendored
Normal file
70
vendor/nette/php-generator/src/PhpGenerator/Closure.php
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?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;
|
||||
|
||||
|
||||
/**
|
||||
* Closure.
|
||||
*
|
||||
* @property string $body
|
||||
*/
|
||||
final class Closure
|
||||
{
|
||||
use Nette\SmartObject;
|
||||
use Traits\FunctionLike;
|
||||
|
||||
/** @var Parameter[] */
|
||||
private $uses = [];
|
||||
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public static function from(\Closure $closure): self
|
||||
{
|
||||
return (new Factory)->fromFunctionReflection(new \ReflectionFunction($closure));
|
||||
}
|
||||
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
try {
|
||||
return (new Printer)->printClosure($this);
|
||||
} catch (\Throwable $e) {
|
||||
trigger_error('Exception in ' . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Parameter[] $uses
|
||||
* @return static
|
||||
*/
|
||||
public function setUses(array $uses): self
|
||||
{
|
||||
(function (Parameter ...$uses) {})(...$uses);
|
||||
$this->uses = $uses;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function getUses(): array
|
||||
{
|
||||
return $this->uses;
|
||||
}
|
||||
|
||||
|
||||
public function addUse(string $name): Parameter
|
||||
{
|
||||
return $this->uses[] = new Parameter($name);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue