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 closureTest(callable $callback) { | |
printf("Look, I'm running callback! '%s'\n", $callback()); | |
} | |
closureTest(function() { return '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 dereference() { | |
$arr = ['php', '5.4', 'looks', 'nice']; | |
return $arr; | |
} | |
printf("%s - %s\n", dereference()[1], dereference()[3]); | |
// will echo: | |
// 5.4 - nice |
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 | |
trait Loggable { | |
public function log($event) { | |
printf("Event: '%s', source: '%s'\n", | |
event, get_class($this)); | |
} | |
} | |
class User { | |
use Loggable; |
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
FirstBundle | |
SecondBundle | |
AnotherBundle |
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 | |
if (is_array($limiters['organization_unit']) && !empty($limiters['organization_unit'])) | |
{ | |
$query->andWhere($query->expr()->in('si.organizationUnitCode', $limiters['organization_unit'])); | |
} |
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 | |
if (is_array($limiters['organization_unit'])) | |
{ | |
if (!empty($limiters['organization_unit'])) | |
{ | |
$units_conditions = ''; | |
$first = 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 AbstractManagerBase extends \PHPUnit_Framework_TestCase | |
{ | |
protected function getEmMock() | |
{ | |
$emMock = \Mockery::mock('\Doctrine\ORM\EntityManager', | |
array( | |
'getRepository' => new FakeRepository(), | |
'getClassMetadata' => (object)array('name' => 'aClass'), |
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 AbstractManagerBase extends \PHPUnit_Framework_TestCase | |
{ | |
protected function getEmMock() | |
{ | |
$emMock = $this->getMock('\Doctrine\ORM\EntityManager', | |
array('getRepository', 'getClassMetadata', 'persist', 'flush'), array(), '', false); | |
$emMock->expects($this->any()) | |
->method('getRepository') |
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
<phpunit> | |
<!-- snip... --> | |
<listeners> | |
<listener class="\Mockery\Adapter\Phpunit\TestListener" | |
file="Mockery/Adapter/Phpunit/TestListener.php"> | |
</listener> | |
</listeners> | |
</phpunit> |
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 | |
// [...] | |
// you can put it on bottom of the autoload.php | |
if (class_exists('PHPUnit_Runner_Version')) { | |
set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__.'/../vendor/mockery/library/'); | |
require_once('Mockery/Loader.php'); | |
$loader = new \Mockery\Loader; | |
$loader->register(); | |
} |