Skip to content

Instantly share code, notes, and snippets.

@ramsey
ramsey / variadic-generics.php
Created October 13, 2016 17:38
You may type-hint on variadic functions in PHP to enforce type on elements in the array
<?php
class Foo {}
$f1 = new Foo();
$f2 = new Foo();
$bar = function (Foo ...$foo) {
foreach ($foo as $f) {
echo get_class($f) . "\n";
}
@martindilling
martindilling / 2015_09_03_142321_create_coupons_table.php
Created September 3, 2015 15:06
Polymorphic Coupons with Eloquent
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCouponsTable extends Migration
{
public function up()
{
Schema::create('coupons', function (Blueprint $table) {
@necolas
necolas / contain-floats.css
Created April 22, 2011 00:36
Cross-browser, consistent float-containment methods
/*
* Containing floats in a consistent manner
* By Jonathan Neal and Nicolas Gallagher
*/
/*
* New block formatting context method
* IE 6+, Firefox 2+, Safari 4+, Opera 9+, Chrome
*/
<?php
/**
* AutoHelperView
* Provides automatic helper loading for views.
*
* @author Joe Beeson <jbeeson@gmail.com>
*/
class AutoHelperView extends View {