Skip to content

Instantly share code, notes, and snippets.

View deshack's full-sized avatar

Mattia Migliorini deshack

View GitHub Profile
@deshack
deshack / php7-return-type-declarations-usage.php
Created June 6, 2016 15:47
PHP7 usage of return type declarations
<?php
class User {}
function getUserWrong() : User {
return [];
}
getUserWrong();
// PHP Warning: Uncaught TypeError: Return value of getUserWrong() must be an instance of User, array returned
@deshack
deshack / php7-return-type-declarations-interface.php
Created June 6, 2016 15:55
PHP7 Return Type Declarations with interfaces
<?php
class User {}
interface UserFactoryContract {
public static function generate() : User;
}
class UserFactory implements UserFactoryContract {
public static function generate() {