Skip to content

Instantly share code, notes, and snippets.

@carnage
carnage / example.php
Created July 30, 2022 16:56
Custom collection in Doctrine
<?php
/**
* This is a bit messy but seems to work
*/
#[Entity]
class ParentEntity
{
#[Column]
#[Id]
<?php
function spl_push_error_handler(ErrorHandler $handler, int $level = \E_ALL, int $priority = 0): void
{
// this function would be built into PHP, possibly with the addition of some extra functions to inspect and remove
// existing error handlers
// pushed error handlers would take priority over an error handlers set with set_errorhandler(), which would only be called
// if the error is not handled by a handler in the stack.
<?php
use Psr\Http\Message\ServerRequestInterface;
use React\Http\Message\Response;
use React\Promise\Deferred;
require __DIR__ . '/vendor/autoload.php';
$loop = React\EventLoop\Factory::create();
@carnage
carnage / .phpstorm.meta.php
Created September 28, 2017 11:34
ZF2 autocomplete in phpstorm
<?php
/**
* PhpStorm code completion
*
* Add code completion for PSR-11 Container Interface and more...
*/
namespace PHPSTORM_META {
@carnage
carnage / DebugStack.php
Created September 5, 2017 15:52
Logging query source in Doctrine 2
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
<?php
class Repository
{
private $collection;
public function __construct(Collection $collection)
{
$this->collection = $collection;
}
@carnage
carnage / ciphertext.txt
Created June 13, 2016 09:15
Cipher challenge from my PHP south coast talk
7OXXERWG 1DLZ74UI UM9PX844 KNK5N2P2 VHG20NVT ZWST6WIL THVPQZ4L V8XBXCVA V270UEUK YLVTDRPR
49WW706V QQ9HU144 KNK5N2P2 VSTSYPVP 722E1WH1 TZS2TKAT 277VVFY9 MQ2NQD63 ZLXWB8IH O9LVR0ZQ
RVWTM2FR XKY5P02A DTTYV1KT ZS2VRWWP 428SWZ7O X3DZKKXS STDEASQN XVZ408WQ XSSP38VT CQWI284A
RQ6A0I2Z 9JQ1BOM6 0TYT202M QWTOTY55 U436L0ZW Y1TJATTO 7YWR09WQ 17OXRAUI OKGIMT8S IFNWKQ2F
5LVW3JWS 05VK3UHV Q0BWGN0U K38SMPKB PW2IZXJ5 SYQ3G90G LBLU47RX G2GZ1T89 0GLUVV80 4XOK5HOT
8VRV2GZ1 T8RRF6WI N6W3IYY9 R0436GQN WP09EBEN VGWZ3YVW UOVI6PBY TKXBLZ4D VXG10TX0 03IP3WKI
7W3SF43L Q2FYIYOT ZM6HVVQ1 SZIRA3QQ XYH1TIR2 KXBLZUWT IEQ0L5TY BXCL3L1W 0DID2WY3 TDTSOL0U
M7FYITOA 1T8E5JVR WPV808TT OBLLP9UI ZOU11TZ6 LRM6KMB3 ZGJWS5JT W42V87LW UZRXCS5J T9ZZRIS4
HOTEDMVR BOMV04IT KBLLB0ST CQWWP4Y5 HGWS5I0E 5FGOFLK9 FVHYSBOI RA3QCXVS Q20ZRVO9 MIR0TPKK
5KKP9SIW 2WK1343T NO4LV8EA EPNSSW20 XVCZZPKP 7RTRV0JI 845RU3ZL 08W4HC1V WP444XG1 7YM808TQ
@carnage
carnage / Filesystem.php
Created February 9, 2016 13:45
Create Temp files/dirs symfony filesystem
<?php
namespace Filesystem;
use Symfony\Component\Filesystem\Filesystem as BaseFileSystem;
use Symfony\Component\Filesystem\LockHandler;
/**
* Class Filesystem
*/

Keybase proof

I hereby claim:

  • I am carnage on github.
  • I am carnage (https://keybase.io/carnage) on keybase.
  • I have a public key whose fingerprint is 2BB0 D1DB D428 8112 D6BF 71A6 F02F 5759 93AF D6F7

To claim this, I am signing this object:

/**
* ProfilerEvent::EVENT_COLLECTED event callback.
*
* @param ProfilerEvent $event
*/
public function onCollected(ProfilerEvent $event)
{
$application = $event->getApplication();
$request = $application->getRequest();