declare(strict_types=1)
Në shqip përdoret i njëjti emër.
ShpjegimiSQ
Si parazgjedhje, PHP-ja e konverton vetë "5" në 5 kur një funksion pret int. Me declare(strict_types=1); në krye të skedarit, kjo s'lejohet më — merr gabim, dhe kodi bëhet më i parashikueshëm.
EnglishEN
By default, PHP converts "5" into 5 when a function expects an int. With declare(strict_types=1); at the top of the file, that's no longer allowed — you get an error, and code becomes more predictable.
Si ta mendosh
Si gjyqtari që zbaton rregullat e plota.
Lexoje në anglisht
Like a referee who applies the full rulebook.
Shembull kodiphp
<?php
declare(strict_types=1);
function dyfisho(int $x): int { return $x * 2; }
dyfisho("5"); // TypeError