DI containers are sorted alphabetically.
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
# Given | |
Given I am on [the] homepage | |
Given I am on "url" | |
# When | |
When I go to [the] homepage | |
When I go to "url" | |
When I reload the page |
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 | |
use A\Long\Namespace\User; | |
use Some\Namespace\ProductService; | |
// Doctrine: get entity | |
$user = $entityManager->find('A\Long\Namespace\User', 1234); | |
$user = $entityManager->find(User::class, 1234); | |
// Doctrine repositories |
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 UserController | |
{ | |
/** | |
* @Inject | |
* @var RouterInterface | |
*/ | |
private $router; | |
/** |
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 | |
// http://3v4l.org/e9RNO | |
class Foo { | |
private $bar = 'hello world'; | |
} | |
class FriendOfFoo { | |
public function doSomething($foo) { | |
return function() use ($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 | |
interface Updatable | |
{ | |
public function apply(Expression $e); | |
} | |
// Solution 1 | |
// More powerful, but needs to parse and evaluate the string | |
class Expression | |
{ |
The point of all this is that maybe YAML should be dropped altogether in favor of PHP definitions.
YAML is less verbose, but since PHP 5.4 (short arrays) and 5.5 (short class names) it's even.
Advantages of PHP:
- autocompletion
- refactoring support
- click to go to a class
- definitions using callbacks
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 MyTest extends PHPUnit_Framework_TestCase | |
{ | |
public function testSomeStuff() | |
{ | |
// Build my mock | |
$mock = new class extends CrawlerInterface { | |
public function crawl($url) { | |
return ['some', 'data']; |
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 | |
# Add the following to /etc/phpmyadmin/conf.d/export.inc.php | |
$cfg['Export']['sql_drop_database'] = true; | |
$cfg['Export']['sql_drop_table'] = true; | |
$cfg['Export']['compression'] = 'zip'; | |
$cfg['Export']['sql_disable_fk'] = true; | |
$cfg['Export']['sql_use_transaction'] = true; |
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 Image | |
{ | |
private $width; | |
private $height; | |
private $content; | |
public static function createEmpty($width, $height, $bgcolor = null) | |
{ |