#Rules #RULES #rules #md001
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 | |
/** | |
* Check if a number is even by examining the bit for 1 (ie the odd number 'flag') | |
*/ | |
function isEvenBit(int $num): bool | |
{ | |
return !($num & 0b1); | |
} | |
/** |
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
% time seconds usecs/call calls errors syscall | |
------ ----------- ----------- --------- --------- ---------------- | |
29.16 0.034135 2 20437 9 open | |
19.65 0.022995 1 20456 close | |
14.39 0.016840 1 25138 10055 access | |
8.61 0.010082 1 14542 poll | |
6.81 0.007972 1 5622 45 stat | |
4.65 0.005440 1 10127 17 lstat | |
4.26 0.004985 0 11774 write | |
4.08 0.004771 1 3333 getdents |
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 | |
/** | |
* Password Hash Cost Calculator | |
* | |
* Set the ideal time that you want a password_hash() call to take and this | |
* script will keep testing until it finds the ideal cost value and let you | |
* know what to set it to when it has finished | |
*/ | |
// Milliseconds that a hash should take (ideally) |
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 Item { | |
private $id; | |
public function __construct(int $id) | |
{ | |
$this->id = $id; | |
} | |
public function id() : 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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# All Vagrant configuration is done below. The "2" in Vagrant.configure | |
# configures the configuration version (we support older styles for | |
# backwards compatibility). Please don't change it unless you know what | |
# you're doing. | |
Vagrant.configure(2) do |config| | |
# The most common configuration options are documented and commented below. | |
# For a complete reference, please see the online documentation at |
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 | |
/** | |
* Ideas for how I'd like to see structs implemented in PHP7 | |
* | |
* In this example, structs are more like lightweight objects that have no | |
* methods, just properties. They can be "instantiated" and all properties will be | |
* null until defined later, as per classes. It is however not possible to set a | |
* value to a property that was not defined in the struct originally. | |
* | |
* Structs can extend other structs, much like classes can. Properties can also |