Skip to content

Instantly share code, notes, and snippets.

@muglug
muglug / FailureTracker.php
Created June 9, 2020 22:09
Shepherd Failure tracker
<?php declare(strict_types=1);
namespace Vimeo\Test\Framework\Extension;
use PHPUnit\Runner\AfterLastTestHook;
use PHPUnit\Runner\AfterTestErrorHook;
use PHPUnit\Runner\AfterTestFailureHook;
use Psalm\SourceControl\Git\GitInfo;
final class FailureTracker implements AfterTestErrorHook, AfterTestFailureHook, AfterLastTestHook
@muglug
muglug / webmozart-assert-stub.php
Created July 31, 2019 14:34
Interim stubs for webmozart/assert
<?php
/*
* This file is part of the webmozart/assert package.
*
* (c) Bernhard Schussek <bschussek@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@muglug
muglug / NodeTypeTest.php
Last active June 24, 2019 00:31
Test for ways of storing node types
<?php
class Tree {
public $left = null;
public $right = null;
}
class Type {
/** @var int */
public $i = 0;
<?php
namespace Psalm\Example\Plugin;
use PhpParser;
use Psalm\Checker;
use Psalm\Checker\StatementsChecker;
use Psalm\Codebase;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\FileManipulation;
@muglug
muglug / anonymize.php
Last active November 15, 2018 02:37
String anonymisation
<?php
/**
* This tries to anonymise all letters in a string.
*
* @param string $s
* @return string
*/
function anonymize_letters($s) {
$tokens = str_split($s, 1);
@muglug
muglug / phpunit.php
Last active November 2, 2018 19:43
Stub class for common PHPUnit methods
<?php
namespace PHPUnit\Framework;
use PHPUnit\Framework\MockObject\MockObject;
abstract class TestCase extends Assert implements Test, SelfDescribing
{
/**
* @template T
<!doctype html>
<html>
<head>
<title>Full Screen Example</title>
<style type="text/css">
/* make the video stretch to fill the screen in WebKit */
:-webkit-full-screen #myvideo {
width: 100%;
height: 100%;
}