summaryrefslogtreecommitdiff
path: root/vendor/thecodingmachine/safe/generated/spl.php
blob: 08c679dc217503c9d7459dc27df711c6bc30d3a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php

namespace Safe;

use Safe\Exceptions\SplException;

/**
 * This function returns an array with the names of the interfaces that the
 * given object_or_class and its parents implement.
 *
 * @param object|string $object_or_class An object (class instance) or a string (class or interface name).
 * @param bool $autoload Whether to call __autoload by default.
 * @return array An array on success, or FALSE when the given class doesn't exist.
 * @throws SplException
 *
 */
function class_implements($object_or_class, bool $autoload = true): array
{
    error_clear_last();
    $result = \class_implements($object_or_class, $autoload);
    if ($result === false) {
        throw SplException::createFromPhpError();
    }
    return $result;
}


/**
 * This function returns an array with the name of the parent classes of
 * the given object_or_class.
 *
 * @param object|string $object_or_class An object (class instance) or a string (class name).
 * @param bool $autoload Whether to call __autoload by default.
 * @return array An array on success, or FALSE when the given class doesn't exist.
 * @throws SplException
 *
 */
function class_parents($object_or_class, bool $autoload = true): array
{
    error_clear_last();
    $result = \class_parents($object_or_class, $autoload);
    if ($result === false) {
        throw SplException::createFromPhpError();
    }
    return $result;
}


/**
 * This function returns an array with the names of the traits that the
 * given object_or_class uses. This does however not include
 * any traits used by a parent class.
 *
 * @param object|string $object_or_class An object (class instance) or a string (class name).
 * @param bool $autoload Whether to call __autoload by default.
 * @return array An array on success, or FALSE when the given class doesn't exist.
 * @throws SplException
 *
 */
function class_uses($object_or_class, bool $autoload = true): array
{
    error_clear_last();
    $result = \class_uses($object_or_class, $autoload);
    if ($result === false) {
        throw SplException::createFromPhpError();
    }
    return $result;
}


/**
 * Register a function with the spl provided __autoload queue. If the queue
 * is not yet activated it will be activated.
 *
 * If your code has an existing __autoload function then
 * this function must be explicitly registered on the __autoload queue. This
 * is because spl_autoload_register will effectively
 * replace the engine cache for the __autoload function
 * by either spl_autoload or
 * spl_autoload_call.
 *
 * If there must be multiple autoload functions, spl_autoload_register
 * allows for this. It effectively creates a queue of autoload functions, and
 * runs through each of them in the order they are defined. By contrast,
 * __autoload may only be defined once.
 *
 * @param callable(string):void $callback The autoload function being registered.
 * If NULL, then the default implementation of
 * spl_autoload will be registered.
 * @param bool $throw This parameter specifies whether
 * spl_autoload_register should throw
 * exceptions when the callback
 * cannot be registered.
 * @param bool $prepend If true, spl_autoload_register will prepend
 * the autoloader on the autoload queue instead of appending it.
 * @throws SplException
 *
 */
function spl_autoload_register(callable $callback = null, bool $throw = true, bool $prepend = false): void
{
    error_clear_last();
    if ($prepend !== false) {
        $result = \spl_autoload_register($callback, $throw, $prepend);
    } elseif ($throw !== true) {
        $result = \spl_autoload_register($callback, $throw);
    } elseif ($callback !== null) {
        $result = \spl_autoload_register($callback);
    } else {
        $result = \spl_autoload_register();
    }
    if ($result === false) {
        throw SplException::createFromPhpError();
    }
}


/**
 * Removes a function from the autoload queue. If the queue
 * is activated and empty after removing the given function then it will
 * be deactivated.
 *
 * When this function results in the queue being deactivated, any
 * __autoload function that previously existed will not be reactivated.
 *
 * @param mixed $callback The autoload function being unregistered.
 * @throws SplException
 *
 */
function spl_autoload_unregister($callback): void
{
    error_clear_last();
    $result = \spl_autoload_unregister($callback);
    if ($result === false) {
        throw SplException::createFromPhpError();
    }
}