Completed
Push — 2.1 ( 4d9204...3e6f8b )
by
unknown
11:56
created

BaseYii::debug()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 2
crap 2
1
<?php
2
/**
3
 * @link http://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license http://www.yiiframework.com/license/
6
 */
7
8
namespace yii;
9
10
use Psr\Log\LoggerInterface;
11
use Psr\Log\LogLevel;
12
use yii\base\InvalidConfigException;
13
use yii\base\InvalidArgumentException;
14
use yii\base\UnknownClassException;
15
use yii\di\Container;
16
use yii\di\Instance;
17
use yii\helpers\VarDumper;
18
use yii\log\Logger;
19
use yii\profile\Profiler;
20
use yii\profile\ProfilerInterface;
21
22
/**
23
 * Gets the application start timestamp.
24
 */
25
defined('YII_BEGIN_TIME') or define('YII_BEGIN_TIME', microtime(true));
26
/**
27
 * This constant defines the framework installation directory.
28
 */
29
defined('YII2_PATH') or define('YII2_PATH', __DIR__);
30
/**
31
 * This constant defines whether the application should be in debug mode or not. Defaults to false.
32
 */
33
defined('YII_DEBUG') or define('YII_DEBUG', false);
34
/**
35
 * This constant defines in which environment the application is running. Defaults to 'prod', meaning production environment.
36
 * You may define this constant in the bootstrap script. The value could be 'prod' (production), 'dev' (development), 'test', 'staging', etc.
37
 */
38
defined('YII_ENV') or define('YII_ENV', 'prod');
39
/**
40
 * Whether the the application is running in production environment
41
 */
42
defined('YII_ENV_PROD') or define('YII_ENV_PROD', YII_ENV === 'prod');
43
/**
44
 * Whether the the application is running in development environment
45
 */
46
defined('YII_ENV_DEV') or define('YII_ENV_DEV', YII_ENV === 'dev');
47
/**
48
 * Whether the the application is running in testing environment
49
 */
50
defined('YII_ENV_TEST') or define('YII_ENV_TEST', YII_ENV === 'test');
51
52
/**
53
 * This constant defines whether error handling should be enabled. Defaults to true.
54
 */
55
defined('YII_ENABLE_ERROR_HANDLER') or define('YII_ENABLE_ERROR_HANDLER', true);
56
57
/**
58
 * BaseYii is the core helper class for the Yii framework.
59
 *
60
 * Do not use BaseYii directly. Instead, use its child class [[\Yii]] which you can replace to
61
 * customize methods of BaseYii.
62
 *
63
 * @author Qiang Xue <[email protected]>
64
 * @since 2.0
65
 */
66
class BaseYii
67
{
68
    /**
69
     * @var array class map used by the Yii autoloading mechanism.
70
     * The array keys are the class names (without leading backslashes), and the array values
71
     * are the corresponding class file paths (or [path aliases](guide:concept-aliases)). This property mainly affects
72
     * how [[autoload()]] works.
73
     * @see autoload()
74
     */
75
    public static $classMap = [];
76
    /**
77
     * @var \yii\console\Application|\yii\web\Application the application instance
78
     */
79
    public static $app;
80
    /**
81
     * @var array registered path aliases
82
     * @see getAlias()
83
     * @see setAlias()
84
     */
85
    public static $aliases = ['@yii' => __DIR__];
86
    /**
87
     * @var Container the dependency injection (DI) container used by [[createObject()]].
88
     * You may use [[Container::set()]] to set up the needed dependencies of classes and
89
     * their initial property values.
90
     * @see createObject()
91
     * @see Container
92
     */
93
    public static $container;
94
95
96
    /**
97
     * Returns a string representing the current version of the Yii framework.
98
     * @return string the version of Yii framework
99
     */
100 43
    public static function getVersion()
101
    {
102 43
        return '2.0.13-dev';
103
    }
104
105
    /**
106
     * Translates a path alias into an actual path.
107
     *
108
     * The translation is done according to the following procedure:
109
     *
110
     * 1. If the given alias does not start with '@', it is returned back without change;
111
     * 2. Otherwise, look for the longest registered alias that matches the beginning part
112
     *    of the given alias. If it exists, replace the matching part of the given alias with
113
     *    the corresponding registered path.
114
     * 3. Throw an exception or return false, depending on the `$throwException` parameter.
115
     *
116
     * For example, by default '@yii' is registered as the alias to the Yii framework directory,
117
     * say '/path/to/yii'. The alias '@yii/web' would then be translated into '/path/to/yii/web'.
118
     *
119
     * If you have registered two aliases '@foo' and '@foo/bar'. Then translating '@foo/bar/config'
120
     * would replace the part '@foo/bar' (instead of '@foo') with the corresponding registered path.
121
     * This is because the longest alias takes precedence.
122
     *
123
     * However, if the alias to be translated is '@foo/barbar/config', then '@foo' will be replaced
124
     * instead of '@foo/bar', because '/' serves as the boundary character.
125
     *
126
     * Note, this method does not check if the returned path exists or not.
127
     *
128
     * See the [guide article on aliases](guide:concept-aliases) for more information.
129
     *
130
     * @param string $alias the alias to be translated.
131
     * @param bool $throwException whether to throw an exception if the given alias is invalid.
132
     * If this is false and an invalid alias is given, false will be returned by this method.
133
     * @return string|bool the path corresponding to the alias, false if the root alias is not previously registered.
134
     * @throws InvalidArgumentException if the alias is invalid while $throwException is true.
135
     * @see setAlias()
136
     */
137 2921
    public static function getAlias($alias, $throwException = true)
138
    {
139 2921
        if (strncmp($alias, '@', 1)) {
140
            // not an alias
141 2786
            return $alias;
142
        }
143
144 2918
        $pos = strpos($alias, '/');
145 2918
        $root = $pos === false ? $alias : substr($alias, 0, $pos);
146
147 2918
        if (isset(static::$aliases[$root])) {
148 2912
            if (is_string(static::$aliases[$root])) {
149 2912
                return $pos === false ? static::$aliases[$root] : static::$aliases[$root] . substr($alias, $pos);
150
            }
151
152 1
            foreach (static::$aliases[$root] as $name => $path) {
153 1
                if (strpos($alias . '/', $name . '/') === 0) {
154 1
                    return $path . substr($alias, strlen($name));
155
                }
156
            }
157
        }
158
159 26
        if ($throwException) {
160
            throw new InvalidArgumentException("Invalid path alias: $alias");
161
        }
162
163 26
        return false;
164
    }
165
166
    /**
167
     * Returns the root alias part of a given alias.
168
     * A root alias is an alias that has been registered via [[setAlias()]] previously.
169
     * If a given alias matches multiple root aliases, the longest one will be returned.
170
     * @param string $alias the alias
171
     * @return string|bool the root alias, or false if no root alias is found
172
     */
173
    public static function getRootAlias($alias)
174
    {
175
        $pos = strpos($alias, '/');
176
        $root = $pos === false ? $alias : substr($alias, 0, $pos);
177
178
        if (isset(static::$aliases[$root])) {
179
            if (is_string(static::$aliases[$root])) {
180
                return $root;
181
            }
182
183
            foreach (static::$aliases[$root] as $name => $path) {
184
                if (strpos($alias . '/', $name . '/') === 0) {
185
                    return $name;
186
                }
187
            }
188
        }
189
190
        return false;
191
    }
192
193
    /**
194
     * Registers a path alias.
195
     *
196
     * A path alias is a short name representing a long path (a file path, a URL, etc.)
197
     * For example, we use '@yii' as the alias of the path to the Yii framework directory.
198
     *
199
     * A path alias must start with the character '@' so that it can be easily differentiated
200
     * from non-alias paths.
201
     *
202
     * Note that this method does not check if the given path exists or not. All it does is
203
     * to associate the alias with the path.
204
     *
205
     * Any trailing '/' and '\' characters in the given path will be trimmed.
206
     *
207
     * See the [guide article on aliases](guide:concept-aliases) for more information.
208
     *
209
     * @param string $alias the alias name (e.g. "@yii"). It must start with a '@' character.
210
     * It may contain the forward slash '/' which serves as boundary character when performing
211
     * alias translation by [[getAlias()]].
212
     * @param string $path the path corresponding to the alias. If this is null, the alias will
213
     * be removed. Trailing '/' and '\' characters will be trimmed. This can be
214
     *
215
     * - a directory or a file path (e.g. `/tmp`, `/tmp/main.txt`)
216
     * - a URL (e.g. `http://www.yiiframework.com`)
217
     * - a path alias (e.g. `@yii/base`). In this case, the path alias will be converted into the
218
     *   actual path first by calling [[getAlias()]].
219
     *
220
     * @throws InvalidArgumentException if $path is an invalid alias.
221
     * @see getAlias()
222
     */
223 2773
    public static function setAlias($alias, $path)
224
    {
225 2773
        if (strncmp($alias, '@', 1)) {
226
            $alias = '@' . $alias;
227
        }
228 2773
        $pos = strpos($alias, '/');
229 2773
        $root = $pos === false ? $alias : substr($alias, 0, $pos);
230 2773
        if ($path !== null) {
231 2773
            $path = strncmp($path, '@', 1) ? rtrim($path, '\\/') : static::getAlias($path);
232 2773
            if (!isset(static::$aliases[$root])) {
233 7
                if ($pos === false) {
234 7
                    static::$aliases[$root] = $path;
235
                } else {
236 7
                    static::$aliases[$root] = [$alias => $path];
237
                }
238 2772
            } elseif (is_string(static::$aliases[$root])) {
239 2772
                if ($pos === false) {
240 2771
                    static::$aliases[$root] = $path;
241
                } else {
242 1
                    static::$aliases[$root] = [
243 1
                        $alias => $path,
244 2772
                        $root => static::$aliases[$root],
245
                    ];
246
                }
247
            } else {
248
                static::$aliases[$root][$alias] = $path;
249 2773
                krsort(static::$aliases[$root]);
250
            }
251 3
        } elseif (isset(static::$aliases[$root])) {
252 3
            if (is_array(static::$aliases[$root])) {
253 1
                unset(static::$aliases[$root][$alias]);
254 2
            } elseif ($pos === false) {
255 2
                unset(static::$aliases[$root]);
256
            }
257
        }
258 2773
    }
259
260
    /**
261
     * Class autoload loader.
262
     * This method is invoked automatically when PHP sees an unknown class.
263
     * The method will attempt to include the class file according to the following procedure:
264
     *
265
     * 1. Search in [[classMap]];
266
     * 2. If the class is namespaced (e.g. `yii\base\Component`), it will attempt
267
     *    to include the file associated with the corresponding path alias
268
     *    (e.g. `@yii/base/Component.php`);
269
     *
270
     * This autoloader allows loading classes that follow the [PSR-4 standard](http://www.php-fig.org/psr/psr-4/)
271
     * and have its top-level namespace or sub-namespaces defined as path aliases.
272
     *
273
     * Example: When aliases `@yii` and `@yii/bootstrap` are defined, classes in the `yii\bootstrap` namespace
274
     * will be loaded using the `@yii/bootstrap` alias which points to the directory where bootstrap extension
275
     * files are installed and all classes from other `yii` namespaces will be loaded from the yii framework directory.
276
     *
277
     * Also the [guide section on autoloading](guide:concept-autoloading).
278
     *
279
     * @param string $className the fully qualified class name without a leading backslash "\"
280
     * @throws UnknownClassException if the class does not exist in the class file
281
     */
282 185
    public static function autoload($className)
283
    {
284 185
        if (isset(static::$classMap[$className])) {
285 115
            $classFile = static::$classMap[$className];
286 115
            if ($classFile[0] === '@') {
287 115
                $classFile = static::getAlias($classFile);
288
            }
289 91
        } elseif (strpos($className, '\\') !== false) {
290 85
            $classFile = static::getAlias('@' . str_replace('\\', '/', $className) . '.php', false);
291 85
            if ($classFile === false || !is_file($classFile)) {
292 85
                return;
293
            }
294
        } else {
295 9
            return;
296
        }
297
298 161
        include $classFile;
299
300 161
        if (YII_DEBUG && !class_exists($className, false) && !interface_exists($className, false) && !trait_exists($className, false)) {
301
            throw new UnknownClassException("Unable to find '$className' in file: $classFile. Namespace missing?");
302
        }
303 161
    }
304
305
    /**
306
     * Creates a new object using the given configuration.
307
     *
308
     * You may view this method as an enhanced version of the `new` operator.
309
     * The method supports creating an object based on a class name, a configuration array or
310
     * an anonymous function.
311
     *
312
     * Below are some usage examples:
313
     *
314
     * ```php
315
     * // create an object using a class name
316
     * $object = Yii::createObject(\yii\db\Connection::class);
317
     *
318
     * // create an object using a configuration array
319
     * $object = Yii::createObject([
320
     *     'class' => \yii\db\Connection::class,
321
     *     'dsn' => 'mysql:host=127.0.0.1;dbname=demo',
322
     *     'username' => 'root',
323
     *     'password' => '',
324
     *     'charset' => 'utf8',
325
     * ]);
326
     *
327
     * // create an object with two constructor parameters
328
     * $object = \Yii::createObject('MyClass', [$param1, $param2]);
329
     * ```
330
     *
331
     * Using [[\yii\di\Container|dependency injection container]], this method can also identify
332
     * dependent objects, instantiate them and inject them into the newly created object.
333
     *
334
     * @param string|array|callable $type the object type. This can be specified in one of the following forms:
335
     *
336
     * - a string: representing the class name of the object to be created
337
     * - a configuration array: the array must contain a `class` element which is treated as the object class,
338
     *   and the rest of the name-value pairs will be used to initialize the corresponding object properties
339
     * - a PHP callable: either an anonymous function or an array representing a class method (`[$class or $object, $method]`).
340
     *   The callable should return a new instance of the object being created.
341
     *
342
     * @param array $params the constructor parameters
343
     * @return object the created object
344
     * @throws InvalidConfigException if the configuration is invalid.
345
     * @see \yii\di\Container
346
     */
347 2568
    public static function createObject($type, array $params = [])
348
    {
349 2568
        if (is_string($type)) {
350 815
            return static::$container->get($type, $params);
351 2533
        } elseif (is_array($type) && isset($type['class'])) {
352 2531
            $class = $type['class'];
353 2531
            unset($type['class']);
354 2531
            return static::$container->get($class, $params, $type);
355 2
        } elseif (is_callable($type, true)) {
356 2
            return static::$container->invoke($type, $params);
357
        } elseif (is_array($type)) {
358
            throw new InvalidConfigException('Object configuration must be an array containing a "class" element.');
359
        }
360
361
        throw new InvalidConfigException('Unsupported configuration type: ' . gettype($type));
362
    }
363
364
    /**
365
     * @var LoggerInterface logger instance.
366
     */
367
    private static $_logger;
368
369
    /**
370
     * @return LoggerInterface message logger
371
     */
372 1517
    public static function getLogger()
373
    {
374 1517
        if (self::$_logger !== null) {
375 1517
            return self::$_logger;
376
        }
377
378 1
        return self::$_logger = Instance::ensure(['class' => Logger::class], LoggerInterface::class);
379
    }
380
381
    /**
382
     * Sets the logger object.
383
     * @param LoggerInterface|\Closure|array|null $logger the logger object or its DI compatible configuration.
384
     */
385 22
    public static function setLogger($logger)
386
    {
387 22
        if ($logger === null) {
388 16
            self::$_logger = null;
389 16
            return;
390
        }
391
392 18
        if (is_array($logger)) {
393 7
            if (!isset($logger['class']) && is_object(self::$_logger)) {
394 7
                static::configure(self::$_logger, $logger);
395 7
                return;
396
            }
397 1
            $logger = array_merge(['class' => Logger::class], $logger);
398 12
        } elseif ($logger instanceof \Closure) {
399 1
            $logger = call_user_func($logger);
400
        }
401
402 12
        self::$_logger = Instance::ensure($logger, LoggerInterface::class);
403 12
    }
404
405
    /**
406
     * @var ProfilerInterface profiler instance.
407
     * @since 2.1
408
     */
409
    private static $_profiler;
410
411
    /**
412
     * @return ProfilerInterface profiler instance.
413
     * @since 2.1
414
     */
415 1301
    public static function getProfiler()
416
    {
417 1301
        if (self::$_profiler !== null) {
418 1301
            return self::$_profiler;
419
        }
420 2
        return self::$_profiler = Instance::ensure(['class' => Profiler::class], ProfilerInterface::class);
421
    }
422
423
    /**
424
     * @param ProfilerInterface|\Closure|array|null $profiler profiler instance or its DI compatible configuration.
425
     * @since 2.1
426
     */
427 5
    public static function setProfiler($profiler)
428
    {
429 5
        if ($profiler === null) {
430 5
            self::$_profiler = null;
431 5
            return;
432
        }
433
434 1
        if (is_array($profiler)) {
435 1
            if (!isset($profiler['class']) && is_object(self::$_profiler)) {
436
                static::configure(self::$_profiler, $profiler);
437
                return;
438
            }
439 1
            $profiler = array_merge(['class' => Profiler::class], $profiler);
440 1
        } elseif ($profiler instanceof \Closure) {
441 1
            $profiler = call_user_func($profiler);
442
        }
443
444 1
        self::$_profiler = Instance::ensure($profiler, ProfilerInterface::class);
445 1
    }
446
447
    /**
448
     * Logs a message with category.
449
     * @param string $level log level.
450
     * @param mixed $message the message to be logged. This can be a simple string or a more
451
     * complex data structure, such as array.
452
     * @param string $category the category of the message.
453
     * @since 2.1.0
454
     */
455 1516
    public static function log($level, $message, $category = 'application')
456
    {
457 1516
        $context = ['category' => $category];
458 1516
        if (!is_string($message)) {
459 11
            if ($message instanceof \Throwable) {
460
                // exceptions are string-convertable, thus should be passed as it is to the logger
461
                // if exception instance is given to produce a stack trace, it MUST be in a key named "exception".
462
                $context['exception'] = $message;
463
            } else {
464
                // exceptions may not be serializable if in the call stack somewhere is a Closure
465 11
                $message = VarDumper::export($message);
466
            }
467
        }
468 1516
        static::getLogger()->log($level, $message, $context);
0 ignored issues
show
Bug introduced by
It seems like $message defined by parameter $message on line 455 can also be of type object<Throwable>; however, Psr\Log\LoggerInterface::log() does only seem to accept string, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
469 1516
    }
470
471
    /**
472
     * Logs a debug message.
473
     * Trace messages are logged mainly for development purpose to see
474
     * the execution work flow of some code.
475
     * @param string|array $message the message to be logged. This can be a simple string or a more
476
     * complex data structure, such as array.
477
     * @param string $category the category of the message.
478
     */
479 1400
    public static function debug($message, $category = 'application')
480
    {
481 1400
        if (YII_DEBUG) {
482 1400
            static::log(LogLevel::DEBUG, $message, $category);
483
        }
484 1400
    }
485
486
    /**
487
     * Logs an error message.
488
     * An error message is typically logged when an unrecoverable error occurs
489
     * during the execution of an application.
490
     * @param string|array $message the message to be logged. This can be a simple string or a more
491
     * complex data structure, such as array.
492
     * @param string $category the category of the message.
493
     */
494 7
    public static function error($message, $category = 'application')
495
    {
496 7
        static::log(LogLevel::ERROR, $message, $category);
497 7
    }
498
499
    /**
500
     * Logs a warning message.
501
     * A warning message is typically logged when an error occurs while the execution
502
     * can still continue.
503
     * @param string|array $message the message to be logged. This can be a simple string or a more
504
     * complex data structure, such as array.
505
     * @param string $category the category of the message.
506
     */
507 15
    public static function warning($message, $category = 'application')
508
    {
509 15
        static::log(LogLevel::WARNING, $message, $category);
510 15
    }
511
512
    /**
513
     * Logs an informative message.
514
     * An informative message is typically logged by an application to keep record of
515
     * something important (e.g. an administrator logs in).
516
     * @param string|array $message the message to be logged. This can be a simple string or a more
517
     * complex data structure, such as array.
518
     * @param string $category the category of the message.
519
     */
520 1334
    public static function info($message, $category = 'application')
521
    {
522 1334
        static::log(LogLevel::INFO, $message, $category);
523 1334
    }
524
525
    /**
526
     * Marks the beginning of a code block for profiling.
527
     * This has to be matched with a call to [[endProfile]] with the same category name.
528
     * The begin- and end- calls must also be properly nested. For example,
529
     *
530
     * ```php
531
     * \Yii::beginProfile('block1');
532
     * // some code to be profiled
533
     *     \Yii::beginProfile('block2');
534
     *     // some other code to be profiled
535
     *     \Yii::endProfile('block2');
536
     * \Yii::endProfile('block1');
537
     * ```
538
     * @param string $token token for the code block
539
     * @param string $category the category of this log message
540
     * @see endProfile()
541
     */
542 1301
    public static function beginProfile($token, $category = 'application')
543
    {
544 1301
        static::getProfiler()->begin($token, ['category' => $category]);
545 1301
    }
546
547
    /**
548
     * Marks the end of a code block for profiling.
549
     * This has to be matched with a previous call to [[beginProfile]] with the same category name.
550
     * @param string $token token for the code block
551
     * @param string $category the category of this log message
552
     * @see beginProfile()
553
     */
554 1301
    public static function endProfile($token, $category = 'application')
555
    {
556 1301
        static::getProfiler()->end($token, ['category' => $category]);
557 1301
    }
558
559
    /**
560
     * Returns an HTML hyperlink that can be displayed on your Web page showing "Powered by Yii Framework" information.
561
     * @return string an HTML hyperlink that can be displayed on your Web page showing "Powered by Yii Framework" information
562
     */
563 1
    public static function powered()
564
    {
565 1
        return \Yii::t('yii', 'Powered by {yii}', [
566 1
            'yii' => '<a href="http://www.yiiframework.com/" rel="external">' . \Yii::t('yii',
567 1
                    'Yii Framework') . '</a>',
568
        ]);
569
    }
570
571
    /**
572
     * Translates a message to the specified language.
573
     *
574
     * This is a shortcut method of [[\yii\i18n\I18N::translate()]].
575
     *
576
     * The translation will be conducted according to the message category and the target language will be used.
577
     *
578
     * You can add parameters to a translation message that will be substituted with the corresponding value after
579
     * translation. The format for this is to use curly brackets around the parameter name as you can see in the following example:
580
     *
581
     * ```php
582
     * $username = 'Alexander';
583
     * echo \Yii::t('app', 'Hello, {username}!', ['username' => $username]);
584
     * ```
585
     *
586
     * Further formatting of message parameters is supported using the [PHP intl extensions](http://www.php.net/manual/en/intro.intl.php)
587
     * message formatter. See [[\yii\i18n\I18N::translate()]] for more details.
588
     *
589
     * @param string $category the message category.
590
     * @param string $message the message to be translated.
591
     * @param array $params the parameters that will be used to replace the corresponding placeholders in the message.
592
     * @param string $language the language code (e.g. `en-US`, `en`). If this is null, the current
593
     * [[\yii\base\Application::language|application language]] will be used.
594
     * @return string the translated message.
595
     */
596 661
    public static function t($category, $message, $params = [], $language = null)
597
    {
598 661
        if (static::$app !== null) {
599 482
            return static::$app->getI18n()->translate($category, $message, $params, $language ?: static::$app->language);
600
        }
601
602 179
        $placeholders = [];
603 179
        foreach ((array) $params as $name => $value) {
604 4
            $placeholders['{' . $name . '}'] = $value;
605
        }
606
607 179
        return ($placeholders === []) ? $message : strtr($message, $placeholders);
608
    }
609
610
    /**
611
     * Configures an object with the initial property values.
612
     * @param object $object the object to be configured
613
     * @param array $properties the property initial values given in terms of name-value pairs.
614
     * @return object the object itself
615
     */
616 3187
    public static function configure($object, $properties)
617
    {
618 3187
        foreach ($properties as $name => $value) {
619 3187
            $object->$name = $value;
620
        }
621
622 3187
        return $object;
623
    }
624
625
    /**
626
     * Returns the public member variables of an object.
627
     * This method is provided such that we can get the public member variables of an object.
628
     * It is different from "get_object_vars()" because the latter will return private
629
     * and protected variables if it is called within the object itself.
630
     * @param object $object the object to be handled
631
     * @return array the public member variables of the object
632
     */
633 3
    public static function getObjectVars($object)
634
    {
635 3
        return get_object_vars($object);
636
    }
637
}
638