Skip to content

Instantly share code, notes, and snippets.

Nikita Popov nikic

Block or report user

Report or block nikic

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
View coalesce.diff
diff --git a/Zend/zend_ast.h b/Zend/zend_ast.h
index 2a1582c..b571ee1 100644
--- a/Zend/zend_ast.h
+++ b/Zend/zend_ast.h
@@ -115,6 +115,7 @@ enum _zend_ast_kind {
ZEND_AST_NEW,
ZEND_AST_INSTANCEOF,
ZEND_AST_YIELD,
+ ZEND_AST_COALESCE,
@nikic
nikic / portAlternativeTags.php
Created Sep 12, 2014
Tool for porting alternative PHP tags to <?php, <?= and ?>
View portAlternativeTags.php
<?php
/*
* Note: This script will directly modify the .php files in the given directory.
* It is assumed that the code is under version control, so you can easily review
* the changes using `git diff` or similar.
*/
function usageError() {
die("Usage: php -d asp_tags=1 portAlternativeTags.php dir/\n");
@nikic
nikic / benchCompiler.php
Last active Sep 5, 2018
Scripts for measuring compile time
View benchCompiler.php
<?php ini_set('memory_limit', -1);
if ($argc != 3) die("error\n");
$file = $argv[1];
$num = $argv[2];
$startTime = microtime(true);
for ($i = 0; $i < $num; ++$i) {
require $file;
@nikic
nikic / varVar.php
Created Jun 9, 2014
Script for finding variable-variable usages potentially affected by uniform variable syntax
View varVar.php
<?php
use PhpParser\Node;
use PhpParser\Node\Expr;
error_reporting(E_ALL);
ini_set('memory_limit', -1);
//$dir = __DIR__ . '/../../Symfony_2.3';
View compress.php
<?php
use PhpParser\Node;
$IN_DIR = __DIR__ . '/in_dir';
$OUT_FILE = __DIR__ . '/out_file.php';
require __DIR__ . '/../lib/bootstrap.php';
class CompressVisitor extends PhpParser\NodeVisitorAbstract {
@nikic
nikic / routing_bench.php
Created Feb 17, 2014
Microbenchmark between Pux and FastRoute
View routing_bench.php
<?php
error_reporting(E_ALL);
require __DIR__ . '/FastRoute/src/bootstrap.php';
spl_autoload_register(function ($class) {
require __DIR__ . '/Pux/src/' . strtr($class, '\\', '/') . '.php';
});
View small_regex
~^(?|/a/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)|/b/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)()|/c/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)()()|/d/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)()()()|/e/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)()()()()|/f/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)()()()()()|/g/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)()()()()()()|/h/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)()()()()()()()|/i/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)()()()()()()()()|/j/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)()()()()()()()()()|/k/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)()()()()()()()()()()|/l/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)()()()()()
View no_foreach_lock.diff
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 25a604c..4dba71b 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -1737,7 +1737,6 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n
zend_op dummy_opline;
dummy_opline.result_type = IS_UNUSED;
- dummy_opline.op1_type = IS_UNUSED;
@nikic
nikic / php_evaluation_order.md
Last active Apr 15, 2019
Analysis of some weird evaluation order in PHP
View php_evaluation_order.md

Order of evaluation in PHP

Yesterday I found some people on my [favorite reddit][lolphp] wonder about the output of the following code:

<?php

$a = 1;
$c = $a + $a++;
View zts.diff
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 63ecbe4..c79a551 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -94,7 +94,7 @@ static zend_always_inline void zend_pzval_unlock_free_func(zval *z TSRMLS_DC)
}
#undef zval_ptr_dtor
-#define zval_ptr_dtor(pzv) i_zval_ptr_dtor(*(pzv) ZEND_FILE_LINE_CC)
+#define zval_ptr_dtor(pzv) i_zval_ptr_dtor(*(pzv) ZEND_FILE_LINE_CC TSRMLS_CC)
You can’t perform that action at this time.