State::__callStatic()
Calls a virtual method statically.
Description
State::__callStatic(string $kin, array $lot = []): mixed;
This method will first check if a virtual method is available, if it is available then this method will return the value of that virtual method. If it is not available, this method will check if a state with the same key name as the method name is available. If it is available then this method will return that state. If arguments are given to this method and the returned state is a closure or a class instance, then that closure or class instance will be invoked with the given arguments. Other than that, this method will try to return a state using dot notation access with the second access level being the first argument of this method.
State::_('test', function () {
return 'test';
});
new State([
'bar' => function (...$lot) {
return implode(', ', $lot);
},
'baz' => ['qux' => true],
'foo' => 1,
'test' => [1, 2, 3]
]);
test(State::foo()); // Returns `1`
test(State::baz()); // Returns `(object) ['qux' => true]`
test(State::baz('qux')); // Returns `true`
test(State::bar()); // Returns `function () { … }`
test(State::bar(1, 2, 3)); // Returns `'1, 2, 3'`
Method name will be normalized by function p2f()
, so when you try to call State::dateFormat()
for example, internally you are trying to get a state with name date-format
. This is also the same when you try to call State::{'date-format'}()
. If no state is available, this method returns null
.
State::_()
The dynamic method initiator.
State::__call()
Calls a virtual method.
State::__callStatic()
Calls a virtual method statically.
State::__construct()
The constructor.
State::__get()
Gets a state via property access.
State::__invoke()
Proxy for the current object, called as a function.
State::__isset()
Checks if a state returns non-null value.
State::__serialize()
Provides data to be serialized.
State::__set()
Sets a state via property access.
State::__toString()
Proxy for the current object, casted as a string.
State::__unserialize()
Converts the serialized data back to its object.
State::__unset()
Deletes a state via property access.
State::count()
Counts the number of states.
State::get()
Gets a state or states.
State::getIterator()
The external iterator receiver.
State::jsonSerialize()
Returns the data to be serialized as JSON.
State::let()
Deletes a state or states.
State::offsetExists()
Checks if a state with a certain key exists.
State::offsetGet()
Gets a state using its key.
State::offsetSet()
Sets a state to the specified key.
State::offsetUnset()
Deletes a state at the specified key.
State::set()
Sets a state or states.