Skip to content

Instantly share code, notes, and snippets.

Patrik Lermon kler

View GitHub Profile
kler /
Created Apr 17, 2017
Proposal for restyResolver to handle nested paths
import logging
import re
from connexion.resolver import RestyResolver
logger = logging.getLogger('connexion.resolver')
class NestedRestyResolver(RestyResolver):
"""Overrider RestyResolver to support complex paths (/a/b/c/ => a.b.c)"""
kler / semi-static-context.php
Created Oct 2, 2012
It is possible to call functions from a static context
View semi-static-context.php
class SemiStaticClass {
public function echoWhoIAm() {
echo 'I\'m ' . __FUNCTION__ . ' in class ' . __CLASS__;
// If this doesn't exists, then this function is statically called
if (! isset($this)) {
echo '... and I\'m statically called! Nice!';
echo "\n";
kler / null-and-unset-are-unpredictable.php
Created Oct 2, 2012
NULL and unset has unpredictable behavior
View null-and-unset-are-unpredictable.php
// Conclusion: NULL and unset have unpredictable behavior
// === NULL are in some cases same as unset ===
// This code will assign a value, then assign NULL, and the result will show that
// PHP think this is same as unset()
$a = "test";
$a = NULL// will be same as unset()
echo (isset($a) ? "true" : "false") . "\n";
kler / circular-references-segfault.php
Created Oct 2, 2012
Circular references may cause segmentation fault
View circular-references-segfault.php
// Conclusion: This code will cause Segmentation fault, because
// of recursive calls to __clone(), but PHP should handle this.
// Bug filed here:
class Test {
public $previous, $next = NULL;
kler / null-is-overwritable.php
Created Oct 2, 2012
NULL is overwritable (scalars are not)
View null-is-overwritable.php
// Conclusion: NULL is in this case considered to be of no value, and PHP
// thinks that it is OK to overwrite, but integers are not treated the same
// This code will assign NULL and the ignore that NULL was assigned and create a stdClass:
$a = NULL;
$a->test = "apa"; // should warn in my oppinion
You can’t perform that action at this time.