Skip to content

Instantly share code, notes, and snippets.

Anthony Ferrara ircmaxell

Block or report user

Report or block ircmaxell

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ircmaxell
ircmaxell / php_errors.txt
Created Jul 27, 2011
All errors in the 5.3 source code tree (zend_error|php_error_docref)
View php_errors.txt
./ext/bcmath/bcmath.c: php_error_docref(NULL TSRMLS_CC, E_WARNING, "Division by zero");
./ext/bcmath/bcmath.c: php_error_docref(NULL TSRMLS_CC, E_WARNING, "Division by zero");
./ext/bcmath/bcmath.c: php_error_docref(NULL TSRMLS_CC, E_WARNING, "Square root of negative number");
./ext/bz2/bz2.c: php_error_docref(NULL TSRMLS_CC, E_WARNING, "length may not be negative");
./ext/bz2/bz2.c: php_error_docref(NULL TSRMLS_CC, E_WARNING, "could not read valid bz2 data from stream");
./ext/bz2/bz2.c: php_error_docref(NULL TSRMLS_CC, E_WARNING, "'%s' is not a valid mode for bzopen(). Only 'w' and 'r' are supported.", mode);
./ext/bz2/bz2.c: php_error_docref(NULL TSRMLS_CC, E_WARNING, "filename cannot be empty");
./ext/bz2/bz2.c: php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot use stream opened in mode '%s'", stream->mode);
./ext/bz2/bz2.c: php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot use stream opened in mode '%s'", stream->mode);
@ircmaxell
ircmaxell / gist:1188649
Created Sep 2, 2011 — forked from anonymous/gist:1188637
PHP example on variable variables - without needing them
View gist:1188649
<?php
function bar($a, $b, $c) {
$r = new ReflectionFunction(__FUNCTION__);
$params = func_get_args();
$form = array();
foreach ($r->getParameters() as $param) {
$form[$param->getName()] = array(
'#type' => 'hidden',
'#value' => $params[$param->getPosition()],
@ircmaxell
ircmaxell / Expressions.php
Created Sep 21, 2011
A math parser and evaluator implementation
View Expressions.php
<?php
class Parenthesis extends TerminalExpression {
protected $precidence = 6;
public function operate(Stack $stack) {
}
public function getPrecidence() {
return $this->precidence;
@ircmaxell
ircmaxell / Brainfuck.php
Created Sep 23, 2011
Brainfuck PHP Interpreter
View Brainfuck.php
<?php
require_once 'Memory.php';
require_once 'Stack.php';
require_once 'Expressions.php';
class Brainfuck {
public function run($code, $input, $eof = 0) {
$memory = new Memory(array_map('ord', str_split($input)), $eof);
@ircmaxell
ircmaxell / hash_pbkdf2.patch
Created Jan 19, 2012
hash_pbkdf2() addition patch
View hash_pbkdf2.patch
Index: ext/hash/php_hash.h
===================================================================
--- ext/hash/php_hash.h (revision 322459)
+++ ext/hash/php_hash.h (working copy)
@@ -127,6 +127,7 @@
PHP_FUNCTION(hash_update_file);
PHP_FUNCTION(hash_final);
PHP_FUNCTION(hash_algos);
+PHP_FUNCTION(hash_pbkdf2);
@ircmaxell
ircmaxell / decorator.php
Created Jan 26, 2012
Decorator Implementation
View decorator.php
<?php
class Ruler {
// Returns in meters
public function measure(Point $a, Point $b) {
}
}
class SAEDecorator {
protected $ruler;
View flyweight.php
<?php
abstract class MyEnum {
private static $initialized = false;
private static $values = array();
public static function initialize() {
self::$values['MyFirstValue'] = new MyFirstValue(1);
self::$values['MySecondValue'] = new MySecondValue(2);
@ircmaxell
ircmaxell / gist:1929587
Created Feb 28, 2012
POC for __castTo and __assign, NOTE: UNSTABLE
View gist:1929587
Index: Zend/zend.h
===================================================================
--- Zend/zend.h (revision 322430)
+++ Zend/zend.h (working copy)
@@ -486,6 +486,8 @@
union _zend_function *__call;
union _zend_function *__callstatic;
union _zend_function *__tostring;
+ union _zend_function *__castto;
+ union _zend_function *__assign;
@ircmaxell
ircmaxell / gist:1947259
Created Mar 1, 2012
Scalar Casting Patch POC, version 2
View gist:1947259
Index: Zend/zend.h
===================================================================
--- Zend/zend.h (revision 322430)
+++ Zend/zend.h (working copy)
@@ -486,6 +486,11 @@
union _zend_function *__call;
union _zend_function *__callstatic;
union _zend_function *__tostring;
+ union _zend_function *__toint;
+ union _zend_function *__tofloat;
@ircmaxell
ircmaxell / gist:1955338
Created Mar 2, 2012
POC for type casting (same rules as internal variables)
View gist:1955338
Index: Zend/zend_execute.c
===================================================================
--- Zend/zend_execute.c (revision 322430)
+++ Zend/zend_execute.c (working copy)
@@ -646,7 +646,39 @@
return zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be callable", "", zend_zval_type_name(arg), "" TSRMLS_CC);
}
break;
-
+ case IS_DOUBLE:
You can’t perform that action at this time.