Skip to content

Instantly share code, notes, and snippets.

View lstrojny's full-sized avatar

Lars Strojny lstrojny

View GitHub Profile
#! /usr/bin/env php
<?php
if ($_SERVER['argc'] != 2) {
printf("%s: Converts assertType() into assertInternalType() or assertInstanceOf()\n\n", basename(__FILE__));
printf("Usage: %s <tests directory>\n", basename(__FILE__));
exit(11);
}
$directories = new RegexIterator(
new RecursiveIteratorIterator(
<?php
namespace Jarlssen\Doctrine2\DBAL;
use Doctrine\DBAL\Connection,
Doctrine\DBAL\Driver,
Doctrine\ORM\Configuration,
Doctrine\Common\EventManager,
Doctrine\DBAL\Events;
class MasterSlaveConnection extends Connection
@lstrojny
lstrojny / entity.php
Created November 14, 2011 14:14
EntityExample
<?php
class User
{
}
class ActivityGroup
{
}
interface UserFactory
@lstrojny
lstrojny / execute-drupal-updates.php
Created January 15, 2012 13:00
Execute Drupal Updates without User Interaction
<?php
header("Content-Type: text/plain");
define('DRUPAL_ROOT', getcwd());
define('MAINTENANCE_MODE', 'update');
ini_set('display_errors', TRUE);
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
require_once DRUPAL_ROOT . '/includes/update.inc';
@lstrojny
lstrojny / DateTime.php
Created February 5, 2012 20:42
Immutable DateTime
<?php
namespace InterNations\Component\Date\Value;
use DateTime as DateTimeBase;
use DateTimeZone;
use DateInterval;
class DateTime extends DateTimeBase
{
<?php
class Base
{
public $property;
}
class Proxy extends Base
{
private $interceptedProperties = array();
{# layout.html.twig #}
<html>
<head>
{% block head %}{% endblock head %}
</head>
<body>
{% block body %}{% endblock body %}
</body>
</html>
--TEST--
Multibyte characters shouldn't be split by soft line break added by quoted_printable_encode - 4 byte character test
--INI--
default_charset=ISO-8859-1
--FILE--
<?php
var_dump(explode("\r\n", quoted_printable_encode(str_repeat("a", 74) . "\xf0\x9f\x84\x90")));
?>
==DONE==
--EXPECT--
<?php
trait PrototypeContainerTrait
{
    public function __call($method, array $args)
    {
        if (is_callable($this->$method)) {
            return call_user_func_array($this->$method, $args);
        }
    }
}
<?php
$list = array(new stdClass(), array(new stdClass()));
$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($list));
foreach ($it as $e) {
var_dump($e);
}