PluginProbe
Packeta / 1.6.1
Packeta v1.6.1
2.3.2 2.3.1 trunk 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 All 56 releases
packeta / deps / nette / php-generator / src / PhpGenerator / GlobalFunction.php

GlobalFunction.php in Packeta 1.6.1, at deps/nette/php-generator/src/PhpGenerator/GlobalFunction.php

44 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * This file is part of the Nette Framework (https://nette.org)
5 * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6 */
7 declare (strict_types=1);
8 namespace Packetery\Nette\PhpGenerator;
9
10 use Packetery\Nette;
11 /**
12 * Global function.
13 *
14 * @property string $body
15 */
16 final class GlobalFunction
17 {
18 use \Packetery\Nette\SmartObject;
19 use Traits\FunctionLike;
20 use Traits\NameAware;
21 use Traits\CommentAware;
22 use Traits\AttributeAware;
23 public static function from(string $function) : self
24 {
25 return (new Factory())->fromFunctionReflection(new \ReflectionFunction($function));
26 }
27 public static function withBodyFrom(string $function) : self
28 {
29 return (new Factory())->fromFunctionReflection(new \ReflectionFunction($function), \true);
30 }
31 public function __toString() : string
32 {
33 try {
34 return (new Printer())->printFunction($this);
35 } catch (\Throwable $e) {
36 if (\PHP_VERSION_ID >= 70400) {
37 throw $e;
38 }
39 \trigger_error('Exception in ' . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", \E_USER_ERROR);
40 return '';
41 }
42 }
43 }
44