Skip to content

Instantly share code, notes, and snippets.

View patrickallaert's full-sized avatar

Patrick Allaert patrickallaert

View GitHub Profile
@patrickallaert
patrickallaert / queue-vs-stack.sh
Created August 26, 2015 00:15
SplStack vs SplQueue
echo SplStack
echo ========
echo php 5.5
echo -------
for i in $(seq 10); do
time php5.5 -d memory_limit=-1 -n spl-stack.php
done
echo php 5.6
# Le format général d'un fichier Makefile est le suivant:
# targetDeDestination: premièreDépendance deuxièmeDépendance ...
# <TAB>première commande shell à exécuter
# <TAB>deuxième commande shell à exécuter
# <TAB>...
# Par défaut, 'make' réalise la toute première target trouvée, ici on la nomme: 'all'
# Sela signifie que lancer:
# $ make
# équivant donc à faire:
<figure class="ezimage-field">
<img src="http://www.lescheminsdeferengagent.be/var/jobs/storage/images/media/images/ingenieur13/6529746-1-dut-NL/ingenieur1.png" width="" height="" alt="" />
</figure>
<?php
function doSomeStuff($myArg) {
if (!is_string($myArg)) {
// Will break if it passes and $myArg is an array while not being business logic but pure logging
trigger_error("Wrong data passed: $myArg", E_USER_NOTICE);
}
// Rest of the function
}
<?php
$a = [1, 2];
$fd = fopen("/etc/hosts", "r");
echo "$a, $fd";
?>
Will produce:
Notice: Array to string conversion in php shell code on line 1
Array, Resource id #2
@patrickallaert
patrickallaert / php-5.6.8-r1.ebuild.patch
Created May 8, 2015 09:42
phpdbg support on Gentoo
--- php-5.6.8.ebuild 2015-04-18 12:56:15.000000000 +0200
+++ php-5.6.8-r1.ebuild 2015-05-08 10:23:39.000000000 +0200
@@ -49,14 +49,14 @@
SRC_URI="${PHP_SRC_URI}"
-DESCRIPTION="The PHP language runtime engine: CLI, CGI, FPM/FastCGI, Apache2 and embed SAPIs"
+DESCRIPTION="The PHP language runtime engine: CLI, CGI, FPM/FastCGI, Apache2, phpdbg and embed SAPIs"
HOMEPAGE="http://php.net/"
LICENSE="PHP-3"
stash:
caches:
default:
handlers:
- FileSystem
inMemory: true
registerDoctrineAdapter: false
Index: Zend/zend_builtin_functions.c
===================================================================
--- Zend/zend_builtin_functions.c (revision 309942)
+++ Zend/zend_builtin_functions.c (working copy)
@@ -227,6 +227,7 @@
ZEND_BEGIN_ARG_INFO_EX(arginfo_debug_backtrace, 0, 0, 0)
ZEND_ARG_INFO(0, options)
+ ZEND_ARG_INFO(0, limit)
ZEND_END_ARG_INFO()
Index: Zend/zend_builtin_functions.c
===================================================================
--- Zend/zend_builtin_functions.c (revision 309942)
+++ Zend/zend_builtin_functions.c (working copy)
@@ -2047,11 +2048,11 @@
}
}
-/* {{{ proto void debug_print_backtrace([int options]) */
+/* {{{ proto void debug_print_backtrace([int options[, int limit]]) */
@patrickallaert
patrickallaert / array-to-string-notice.patch.txt
Created June 2, 2011 10:07
Notice on array to string conversion
diff --git a/Zend/zend.c b/Zend/zend.c
index 07bdf98..bcc52f1 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -247,6 +247,7 @@ ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_cop
Z_STRLEN_P(expr_copy) = sprintf(Z_STRVAL_P(expr_copy), "Resource id #%ld", Z_LVAL_P(expr));
break;
case IS_ARRAY:
+ zend_error(E_NOTICE, "Array to string conversion");
Z_STRLEN_P(expr_copy) = sizeof("Array") - 1;