Skip to content

Instantly share code, notes, and snippets.

View tomphp's full-sized avatar

Tom Oram tomphp

View GitHub Profile
@tomphp
tomphp / example.php
Last active December 19, 2015 10:29
How to set up the annotation builder so it can use the hydrator manager
<?php
/*
* This is the setup required to make an annotation builder able to load
* a hydrator from annotation via the HydratorManager.
*/
$annotationBuilder = new \Zend\Form\Annotation\AnnotationBuilder();
$factory = new \Zend\Form\Factory($serviceLocator->get('FormElementManager'));
$annotationBuilder->setFormFactory($factory);
<?php
class BaseClass
{
private $var;
public function __construct($injector)
{
$this->var = $injector;
}
<?php
public function getFileScanner($fileName)
{
if ($this->fileScanner && $this->fileScanner->getFile() == $fileName) {
return $this->fileScanner;
}
$this->fileScanner = new FileScanner($fileName);
<?php
namespace Test;
class MyClass
{
public function someFunction(
MyType $param1,
LongTypeName $param2,
array $param3
<?php
trait MyTrait
{
public function theFunc()
{
echo 'Trait func';
}
}
<?php
class TreeNode
{
private $place;
private $children = [];
public function __construct($place)
{
<?php
class TreeNode
{
private $place;
private $children = [];
public function __construct($place)
{
@tomphp
tomphp / FeatureContext.php
Last active March 3, 2016 07:19
Waiting for a certain page to load in using Mink & Behat
<?php
private function waitForPageToLoad($pageName, $timeout = 10)
{
$count = 10;
while (0 !== stripos($this->getSession()->getCurrentUrl(), $pageName)) {
sleep(1);
if (0 === $count--) {
<?php
/*
* Consider the following, fully tested and everything works,
*/
class BaseAdder
{
public function add($a, $b)
{
<?php
class BaseAdder
{
public function add($a, $b)
{
return $a + $b;
}
}