All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
61 lines
650 B
PHP
61 lines
650 B
PHP
<?php
|
|
|
|
namespace Safe;
|
|
|
|
use Safe\Exceptions\VarException;
|
|
|
|
/**
|
|
* Set the type of variable var to
|
|
* type.
|
|
*
|
|
* @param mixed $var The variable being converted.
|
|
* @param string $type Possibles values of type are:
|
|
*
|
|
*
|
|
*
|
|
* "boolean" or "bool"
|
|
*
|
|
*
|
|
*
|
|
*
|
|
* "integer" or "int"
|
|
*
|
|
*
|
|
*
|
|
*
|
|
* "float" or "double"
|
|
*
|
|
*
|
|
*
|
|
*
|
|
* "string"
|
|
*
|
|
*
|
|
*
|
|
*
|
|
* "array"
|
|
*
|
|
*
|
|
*
|
|
*
|
|
* "object"
|
|
*
|
|
*
|
|
*
|
|
*
|
|
* "null"
|
|
*
|
|
*
|
|
*
|
|
* @throws VarException
|
|
*
|
|
*/
|
|
function settype(&$var, string $type): void
|
|
{
|
|
error_clear_last();
|
|
$safeResult = \settype($var, $type);
|
|
if ($safeResult === false) {
|
|
throw VarException::createFromPhpError();
|
|
}
|
|
}
|