Slide 1

Slide 1 text

Usage of PHP Type Hinting @hashihama variable constant

Slide 2

Slide 2 text

function calculateSpeed(int $distance, int $time) { return $distance / $time; /* ex) 12.3 */ } With Argument function isAdminLoggedIn(): bool { return currentUser()->role === ‘admin’; /* ex) true */ } With Returned Value function sayHello(): void { echo ‘Hello’; } // returns nothing class { private Foo $foo; } With Property

Slide 3

Slide 3 text

function add(int $a, int $b): int { return $a + $b; } add(1.0, 2.0); // 3 Strict Type Union Type