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 | |
namespace wctrn\realloc; | |
trait Logger { | |
public function log_error( string $msg ) : bool { | |
return error_log( $msg ); | |
} | |
} |
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 | |
abstract class aFoo { | |
abstract function baz( int $foobar ); | |
} | |
abstract class aBar extends aFoo { | |
// expected type of foobar is still int | |
abstract function baz( $foobar ) : int; | |
} |
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 variadic_sum( int ... $args ) { | |
return array_sum( $args ); | |
} | |
// echoes 6 | |
echo variadic_sum( 1, 2, 3 ), PHP_EOL; | |
$a = [ 1, 2, 3 ]; |
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 xrange( $start, $limit, $step = 1 ) { | |
for ( $i = $start; $i <= $limit; $i += $step ) { | |
yield $i; | |
} | |
} | |
/* | |
* An array is never created or 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 | |
// Sort an array of objects by name | |
usort( $arr, function ( $a, $b ) { | |
return strcmp( $a->name, $b->name ); | |
} ); | |
function callback_function_name() { | |
// do something | |
} |
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
nvm ls-remote | |
nvm install --lts |
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
sudo apt update | |
sudo apt install build-essential libssl-dev | |
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash |
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
sudo apt update | |
sudo apt install nodejs nodejs-legacy npm |
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 | |
namespace lloc\changelog; | |
exec( 'git fetch --tags' ); | |
$cmd = 'git tag -l --format="%(creatordate:iso8601)|%(refname:short)" | sort -r'; | |
$arr = ( new ArrayOutput( $cmd ) )->get(); | |
$tags = new Tags( $arr ); |
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 | |
namespace lloc\changelog; | |
class Logs { | |
/** | |
* @var array | |
*/ | |
protected $logs = []; |