#TypeHint
Bu sınıf php de desteklenmeyen
string
,integer
,float
,double
,resource
tip tanımlamarını desteklenmesini sağlar.
#Kullanım
include 'src/TypeHint.php';
use Gem\Components\Security\TypeHint;
TypeHint::setErrorHandler();
####string`
function test(string $test)
{
echo $test;
}
####integer
function test(integer $test)
{
echo $test;
}
####float
function test(float $test)
{
echo $test;
}
####double
function test(double $test)
{
echo $test;
}
####resource
function test(resource $test){
echo $test;
}
#Dikkat
Bu şekilde tip tanımlaması yaptıktan sonra fonksiyonlarda ön tanımlı değer olarak sadece null ataması yapabilirsiniz Eğer farklı bir değer atarsanız
Fatal Error
hatasıyla karşılaşırız
function test(string $test = null){
echo $test;
}