# packeta/1.6.1/deps/nette/php-generator/src/PhpGenerator/GlobalFunction.php

Packeta, version 1.6.1. 44 lines.

- Page: https://pluginprobe.com/plugins/packeta/1.6.1/code/deps/nette/php-generator/src/PhpGenerator/GlobalFunction.php
- Raw: https://pluginprobe.com/plugins/packeta/1.6.1/raw/deps/nette/php-generator/src/PhpGenerator/GlobalFunction.php
- Modified: 2023-08-30T08:36:18+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/packeta/1.6.1/code/deps/nette/php-generator/src/PhpGenerator/GlobalFunction.php#L10-L20`.

```php
<?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 Packetery\Nette\PhpGenerator;

use Packetery\Nette;
/**
 * Global function.
 *
 * @property string $body
 */
final class GlobalFunction
{
    use \Packetery\Nette\SmartObject;
    use Traits\FunctionLike;
    use Traits\NameAware;
    use Traits\CommentAware;
    use Traits\AttributeAware;
    public static function from(string $function) : self
    {
        return (new Factory())->fromFunctionReflection(new \ReflectionFunction($function));
    }
    public static function withBodyFrom(string $function) : self
    {
        return (new Factory())->fromFunctionReflection(new \ReflectionFunction($function), \true);
    }
    public function __toString() : string
    {
        try {
            return (new Printer())->printFunction($this);
        } catch (\Throwable $e) {
            if (\PHP_VERSION_ID >= 70400) {
                throw $e;
            }
            \trigger_error('Exception in ' . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", \E_USER_ERROR);
            return '';
        }
    }
}

```
