Skip to content

Instantly share code, notes, and snippets.

View vudaltsov's full-sized avatar
🐘

Valentin Udaltsov vudaltsov

🐘
View GitHub Profile
@vudaltsov
vudaltsov / FixPostgreSQLDefaultSchemaListener.php
Last active March 3, 2024 10:08
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
@vudaltsov
vudaltsov / php_point_interview_1.php
Last active February 24, 2024 18:54
Задачи и решения с собеседования https://youtu.be/ZPGjJDIZm4Y, https://youtu.be/Wa9hUi8NeTs
<?php
/**
* Дано: последовательность натуральных чисел (потенциально бесконечная).
*
* Требуется:
* 1. Написать функцию, которая принимает на вход эту последовательность
* и после обработки n элементов выдаёт не более m наибольших чисел
* среди уже обработанных отсортированных в порядке возрастания или убывания.
* 2. Оценить временную сложность алгоритма как O(f(n, m)).
<?php
declare(strict_types=1);
namespace HappyInc\Infrastructure\Migrations;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
<?php
declare(strict_types=1);
namespace App\Console;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
@vudaltsov
vudaltsov / benchmark.php
Last active November 18, 2023 22:50
Кэш через OPcache
<?php
use Typhoon\Exporter\Exporter;
require_once 'vendor/autoload.php';
final class City
{
public function __construct(
public string $name,
@vudaltsov
vudaltsov / src_Infrastructure_MessageBus_di.php
Last active October 20, 2023 01:07
Symfony PHP configurator ContainerBuilder injection example
<?php
declare(strict_types=1);
namespace HardcorePhpCourse2\Infrastructure\MessageBus;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use VUdaltsov\SymfonyCourse\Infrastructure\MessageBus\Handler;
@vudaltsov
vudaltsov / LoggerStub.php
Created September 28, 2023 22:06
LoggerStub
<?php
declare(strict_types=1);
namespace App;
use Psr\Log\AbstractLogger;
final class LoggerStub extends AbstractLogger
{
@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 ## Установить и запустить проект
<?php
declare(strict_types=1);
namespace ExtendedTypeSystem\Reflection\ClassLocator;
use Composer\Autoload\ClassLoader;
use ExtendedTypeSystem\Reflection\ClassLocator;
use ExtendedTypeSystem\Reflection\Source;
@vudaltsov
vudaltsov / domain_constraints_article_slug.php
Created December 12, 2018 21:26
Domain constraints for Symfony Validator: ArticleDto
<?php
use Symfony\Component\Validator\Constraints as Assert;
final class ArticleDto
{
/**
* @Assert\NotNull()
* @Assert\Type("string")
* @Assert\Length(min=5, max=50)