Skip to content

Instantly share code, notes, and snippets.

@xsist10
xsist10 / GreenlionTest.php
Last active November 30, 2023 21:15
Test case for a bug in the PHPSQLParser
<?php
declare(strict_types=1);
namespace Cadfael\Tests\Factory;
use PHPSQLParser\PHPSQLParser;
use PHPUnit\Framework\TestCase;
class GreenlionTest extends TestCase
@xsist10
xsist10 / ORM.php
Created October 6, 2014 20:11
An ORM in a tweet
<?php
// Minified
// class Orm{function s(&$c){$a=get_object_vars($this);$c[$a[$this->primary]]=$a;}function l($c,$p){foreach($c[$p] as$k=>$v)$this->$k=$v;}}
class Orm {
function s(&$c) {
$a = get_object_vars($this);
$c[$a[$this->primary]] = $a;
}
@xsist10
xsist10 / Kernel.php
Created October 6, 2014 19:33
A kernel in a tweet
<?php
// Event Dispatcher
function e($n,$p,$c=0){static $a;@krsort($a[$n]);if($c)$a[$n][$p][]=$c;else foreach($a[$n] as$q)foreach($q as$r)$r($p);}
// Minified Kernel
// function k($r){try{e('dispatch',[$r,&$p]);e('response',$p);}catch(Exception $x){e('error',$x);}}
function k($r) {
try {
@xsist10
xsist10 / Dispatch1.php
Last active January 21, 2017 17:28
An event dispatcher in a tweet
<?php
// Version 1
// Minified
// class Dispatch{function add($e,$l){$this->l[$e][]=$l;}function trigger($e,$d){foreach ($this->l[$e] as $l)call_user_func_array($l, $d);}}
class Dispatch{
function add($e, $l) {
$this->l[$e][] = $l;
@xsist10
xsist10 / PhpVulnerability.php
Last active December 30, 2015 20:08
CVE vulnerability check concept
<?php
namespace Psecio\Iniscan\Rule;
class PhpVulnerabilities extends \Psecio\Iniscan\Rule
{
public function __construct($config, $section)
{
parent::__construct($config, $section);
$this->setTest(array('key' => 'php.version'));