Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/php
<?php
if (empty($argv[1]) || preg_match('#help#', $argv[1])) {
echo <<<END
Magically rename php4 style constructors to php5 style and add a deprecated stub for BC.
Recommended usage:
time git grep -lP '^\s*((abstract|final)\s+)*class [\w\d]+(\s*\{.*|\s*|\s+extends.*)$' -- '*.php' | sort -R | xargs -rn200 -P8 replace_deprecated_constructors.php
@tlevi
tlevi / accesslib_roledefs_benchmark.php
Created January 19, 2015 10:46
accesslib_roledefs_benchmark
<?php
define('CLI_SCRIPT', true);
require_once __DIR__.'/config.php';
$t = microtime(true);
$size = 0;
for ($i = 1; $i <= 1000; $i++) {
$user = $DB->get_record_sql("SELECT * FROM {user} WHERE id = :id", array('id' => $i));
@tlevi
tlevi / hhvm-include-problem
Last active January 3, 2016 18:39
This test demonstrates a problem with HHVM not seeing when included files have been updated. hhvm#1595
<?php
# This test demonstrates a problem with HHVM not seeing when included files have been updated.
# hhvm#1595
# Expected output:
# $ php test.php
# $included has value: [a]
# $included has value: [b]