Skip to content

Instantly share code, notes, and snippets.

<?php
declare(strict_types=1);
namespace Tests\Integration;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
use ReflectionProperty;
use Webmozart\Assert\Assert;
@keksa
keksa / IntervalType.php
Last active February 2, 2021 09:51
PostgreSQL interval type for Doctrine (PHP)
<?php
declare(strict_types=1);
namespace AppBundle\Database;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;
/**
* @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/cookbook/custom-mapping-types.html
@simPod
simPod / EnumHandler.php
Last active June 17, 2020 05:57
WIP: JMS Serializer EnumHandler for myclabs/php-enum
<?php
declare(strict_types=1);
namespace NS;
use NS\Enum;
use NS\Exception\FileDoesntContainClassDefinition;
use NS\Exception\NotSupported;
use NS\PathnameToClass;
@lyrixx
lyrixx / HardCoreDebugLogger.php
Last active April 27, 2024 14:09
Hardcore Debug Logger
<?php
const STREAM_OPEN_FOR_INCLUDE = 128;
final class HardCoreDebugLogger
{
public static function register(string $output = 'php://stdout')
{
register_tick_function(function () use ($output) {
$bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
Hi,
I'm afraid I'm not interested in this position right now.
I would like to know how you're getting my details and what you're storing though. Under my rights from the GDPR, can you please tell me:
* what personal data you have collected about me?
* the source of this data?
* who you've shared it with, and under what basis?
* how this data is being used?
@JanTvrdik
JanTvrdik / uuid.php
Last active February 14, 2018 14:11
PHP Fast and simple UUID v4 generator
<?php
function generateUuidWithoutDashes(): string
{
$uuidBin = random_bytes(16);
$uuidBin &= "\xFF\xFF\xFF\xFF\xFF\xFF\x0F\xFF\x3F\xFF\xFF\xFF\xFF\xFF\xFF\xFF";
$uuidBin |= "\x00\x00\x00\x00\x00\x00\x40\x00\x80\x00\x00\x00\x00\x00\x00\x00";
$uuidHex = bin2hex($uuidBin);
return $uuidHex;
@podhy
podhy / czkmoney.php
Created August 15, 2017 07:41
Doctrine CZK money type
<?php
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;
use Money\Currencies\ISOCurrencies;
use Money\Formatter\DecimalMoneyFormatter;
use Money\Money;
use Money\Parser\DecimalMoneyParser;
/**
@milo
milo / fid-remove.js
Created April 20, 2017 12:46
Flash message _fid parameter remove.
(function (w, timeout) {
setTimeout(function () {
var url = w.location.toString();
if (w.history && w.history.replaceState && url.indexOf('_fid=') !== -1) {
w.history.replaceState({}, null, /[?&]_fid=[^&]+$/.test(url)
? url.replace(/[?&]_fid=[^&]+/, '')
: url.replace(/([?&])_fid=[^&]+&/, '$1')
);
}
}, timeout || 2000);
{
"functionCalls": [
{
"function": "\\array_diff_assoc",
"position": 0
},
{
"function": "\\array_diff_key",
"position": 0
},
@fprochazka
fprochazka / RenderBlockHelperMacro.php
Created February 11, 2016 19:10
Vyrenderování jednoho bloku z latte šablony
<?php
use Latte;
use Latte\Compiler;
class RenderBlockHelperMacro extends \Latte\Macros\MacroSet
{
public function __construct(Compiler $compiler)
{