This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Include Roboto Condensed font in your project | |
* | |
* Download Roboto Condensed ttf files from Google Fonts and place it in the same directory of this CSS file | |
* You can then use this font in your project by setting | |
* font-face: "Roboto Condensed", Helvetica, Arial, sans-serif; | |
* | |
* @author Mattia Migliorini (deshack) | |
* @license MIT | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class User {} | |
interface UserFactoryContract { | |
public static function generate() : User; | |
} | |
class UserFactory implements UserFactoryContract { | |
public static function generate() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class User {} | |
function getUserWrong() : User { | |
return []; | |
} | |
getUserWrong(); | |
// PHP Warning: Uncaught TypeError: Return value of getUserWrong() must be an instance of User, array returned |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function maybeGetUser() { | |
return []; | |
} | |
var_dump(maybeGetUser()); | |
// array(0) { | |
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getUser() { | |
return array(); | |
} | |
var_dump(getUser()); | |
// array(0) { | |
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Return type in PHP5. | |
* | |
* @copyright 2016 SqueezyWeb | |
* @author Mattia Migliorini <mattia@squeezyweb.com> | |
*/ | |
/** | |
* Get User instance. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function setBool(bool $bool) { | |
var_dump($bool); | |
} | |
setBool(true); // bool(true) | |
setBool('foo'); // bool(true) | |
setBool(''); // bool(false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Force Type Hinting to do a strict type check (the same as ===). | |
declare(strict_types=1); | |
function setBool(bool $bool) { | |
var_dump($bool); | |
} | |
setBool('foo'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function setOptions(array $options) { | |
var_dump($options); | |
} | |
setOptions(array()); | |
// array(0) { | |
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function setValue(string $value) { | |
var_dump($value); | |
} | |
setValue('foo'); | |
// string(3) "foo" | |
setValue([]); |
NewerOlder