Packages

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Config
      • Adapters
      • Extensions
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Diagnostics
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
      • PhpGenerator
  • NetteModule
  • None
  • PHP

Classes

  • NArrays
  • NFinder
  • NHtml
  • NJson
  • NLimitedScope
  • NMimeTypeDetector
  • NNeon
  • NNeonEntity
  • NPaginator
  • NStrings
  • NTokenizer
  • NValidators

Exceptions

  • NAssertionException
  • NJsonException
  • NNeonException
  • NRegexpException
  • NTokenizerException
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Framework (http://nette.org)
 5:  *
 6:  * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
 7:  *
 8:  * For the full copyright and license information, please view
 9:  * the file license.txt that was distributed with this source code.
10:  * @package Nette\Utils
11:  */
12: 
13: 
14: 
15: /**
16:  * Limited scope for PHP code evaluation and script including.
17:  *
18:  * @author     David Grudl
19:  * @package Nette\Utils
20:  */
21: final class NLimitedScope
22: {
23:     private static $vars;
24: 
25:     /**
26:      * Static class - cannot be instantiated.
27:      */
28:     final public function __construct()
29:     {
30:         throw new NStaticClassException;
31:     }
32: 
33: 
34:     /**
35:      * Evaluates code in limited scope.
36:      * @param  string  PHP code
37:      * @param  array   local variables
38:      * @return mixed   the return value of the evaluated code
39:      */
40:     public static function evaluate(/*$code, array $vars = NULL*/)
41:     {
42:         if (func_num_args() > 1) {
43:             self::$vars = func_get_arg(1);
44:             extract(self::$vars);
45:         }
46:         $res = eval('?>' . func_get_arg(0));
47:         if ($res === FALSE && ($error = error_get_last()) && $error['type'] === E_PARSE) {
48:             throw new FatalErrorException($error['message'], 0, $error['type'], $error['file'], $error['line'], NULL);
49:         }
50:         return $res;
51:     }
52: 
53: 
54:     /**
55:      * Includes script in a limited scope.
56:      * @param  string  file to include
57:      * @param  array   local variables or TRUE meaning include once
58:      * @return mixed   the return value of the included file
59:      */
60:     public static function load(/*$file, array $vars = NULL*/)
61:     {
62:         if (func_num_args() > 1) {
63:             self::$vars = func_get_arg(1);
64:             if (self::$vars === TRUE) {
65:                 return require func_get_arg(0);
66:             }
67:             extract(self::$vars);
68:         }
69:         return require func_get_arg(0);
70:     }
71: 
72: }
73: 
Nette Framework 2.0.12 (for PHP 5.2, prefixed) API API documentation generated by ApiGen 2.8.0