Skip to content

Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

  • I am mvriel on github.
  • I am mvriel (https://keybase.io/mvriel) on keybase.
  • I have a public key ASAnUnJLw_srf5T_ugZdOMrI_WEpcVfuF0_XisQ9DbClMQo

To claim this, I am signing this object:

View gist:687f7ebc145144db9f34
Verifying that +mvriel is my blockchain ID. https://onename.com/mvriel
View abstract_vs_interface
interface MapperInterface
{
public function map();
}
abstract class BaseUserMapper
{
public function __construct($userEntity)
{
$this->user = $userEntity;
@mvriel
mvriel / MyClass.php
Created Sep 4, 2014
Why does my test not fail on the second mockedMethod call?
View MyClass.php
<?php
class MyClass
{
public function test($dependency)
{
$dependency->mockedMethod('I have random arguments');
$dependency->mockedMethod(
array(
'choices' => array(
@mvriel
mvriel / gist:c811f7996ed28b478bf9
Created Sep 4, 2014
Mocking two invocations of one call with different arguments
View gist:c811f7996ed28b478bf9
<?php
$resolverMock = m::mock('Symfony\Component\OptionsResolver\OptionsResolver');
$resolverMock->shouldReceive('setNormalizers');
$resolverMock->shouldReceive('setAllowedTypes');
$resolverMock->shouldReceive('setDefaults')->atMost()->once()->withAnyArgs();
$resolverMock->shouldReceive('setDefaults')->atLeast()->once()->with(
array(
'label' => 'MyLabel',
'choices' => array(
'1' => 'Option1',
View media.php
<?php
/**
* Override default image downsize rules with a custom resizing service
*
* Defaults to false (no third-party downsizing), but can be overriden with an indexed
* array of image details to use in place of WP's default downsizing rules.
*
* @since 2.5.0
*
View gist:3981617
Class IpRange
{
public function setStartingAddress($startingAddress)
{
InputValidator::assertValidAddress($startingAddress);
$this->startingAddress = (int) $startingAddress;
return $this;
}
}
@mvriel
mvriel / gist:3823010
Created Oct 2, 2012
Generic notation in PHPDoc vs. plain array notation
View gist:3823010
<?php
/**
* @template <T> The type of the individual elements
*/
class ArrayCollection implements IteratorAggregate
{
private $elements;
/**
* @param array<T> $elements
@mvriel
mvriel / gist:3822861
Created Oct 2, 2012
Option arrays in PHPDoc
View gist:3822861
<?php
/*
This code sample demonstrates several style for representing an option array with
the following fields: name, label, type_id, visible, default.
When designing this we should keep in mind that the option key may be represented
by either a literal or a (class)constant. As such we mix and match those for
illustrative purposes.
*/
@mvriel
mvriel / gist:1548455
Created Jan 1, 2012
Extract dependency namespaces from DocBlox structure file and attempt to generate composer.json requires
View gist:1548455
<?php
if ($argc < 2) {
throw new Exception('Must provide location of DocBlox structure.xml file as argument');
}
$structure_file = $argv[1];
$packages = array();
$packagist = json_decode(file_get_contents('http://packagist.org/packages.json'));
foreach($packagist as $package_obj) {
You can’t perform that action at this time.