Skip to content

Instantly share code, notes, and snippets.

View vudaltsov's full-sized avatar
🐘

Valentin Udaltsov vudaltsov

🐘
View GitHub Profile
@vudaltsov
vudaltsov / 0.mutable.php
Last active July 13, 2026 19:47
Middleware Pipeline Designs
<?php
declare(strict_types=1);
interface Context {}
interface Handler
{
public function handle(object $message, Context $context): void;
}
<?php
#[Attribute(Attribute::TARGET_FUNCTION | Attribute::TARGET_METHOD)]
final readonly class Handler
{
/**
* @param ?class-string $messageClass
*/
public function __construct(
public ?string $messageClass = null
<?php
declare(strict_types=1);
final readonly class Comparator
{
public static function compare(mixed $a, mixed $b): bool
{
/** @var \WeakMap<object, \WeakMap<object, bool>> */
$comparedObjects = new \WeakMap();
@vudaltsov
vudaltsov / FixPostgreSQLDefaultSchemaListener.php
Last active November 25, 2025 12:52
Doctrine PostgreSQL Default Schema Fix For Symfony
<?php
declare(strict_types=1);
namespace App\Doctrine\EventListener;
use Doctrine\DBAL\Schema\PostgreSQLSchemaManager;
use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
final class FixPostgreSQLDefaultSchemaListener
<?php
declare(strict_types=1);
/**
* @return numeric-string
*/
function floatToString(float $float): string
{
$string = (string) $float;
<?php
declare(strict_types=1);
namespace HappyInc\Infrastructure;
/**
* @psalm-pure
*/
function mb_ucfirst(string $string): string
<?php
declare(strict_types=1);
use HappyInc\Tool\Rector\ReadOnlyPublicPropertyRector;
use HappyInc\Tool\Rector\UuidTRector;
use Rector\Config\RectorConfig;
use Rector\Core\Configuration\Option;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\Php71\Rector\FuncCall\CountOnNullRector;
<?php
declare(strict_types=1);
/**
* @template T
* @param T $x
* @return T
*/
function id(mixed $x): mixed
@vudaltsov
vudaltsov / Migrator.php
Last active May 18, 2025 18:35
Simplest PHP migrator in the world
<?php
declare(strict_types=1);
namespace PHPyh\Server\ItOps\Migrations;
use Amp\Postgres\PostgresLink;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
@vudaltsov
vudaltsov / Makefile
Created September 26, 2019 19:29
Makefile for a Symfony project
DOCKER_COMPOSE = docker-compose
EXEC_PHP = $(DOCKER_COMPOSE) exec -T php
SYMFONY = $(EXEC_PHP) bin/console
COMPOSER = $(EXEC_PHP) composer
##
## Проект
## ------
install: start db ## Установить и запустить проект