Skip to content

Instantly share code, notes, and snippets.

View vudaltsov's full-sized avatar
🐘

Valentin Udaltsov vudaltsov

🐘
View GitHub Profile
@vudaltsov
vudaltsov / domain_constraints_news_slug.php
Last active December 12, 2018 21:27
Domain constraints for Symfony Validator
<?php
use Symfony\Component\Validator\Constraints as Assert;
final class NewsDto
{
/**
* @Assert\NotNull()
* @Assert\Type("string")
* @Assert\Length(min=5, max=50)
@vudaltsov
vudaltsov / Currency.orm.xml
Last active April 23, 2019 11:31
PHP Money Doctrine XML Mapping
<!-- config/doctrine/money/Currency.orm.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<embeddable name="Money\Currency">
<field name="code" length="3"/>
</embeddable>
@vudaltsov
vudaltsov / statistics.md
Last active May 7, 2019 11:10
EU-FOSSA Statistics
Код Документация Diversity API Platform
Новые Issue 143 3 3 4
Закрытые Issue 79 11 3 87
Предложенные PR 181 17 12 10
Смердженные PR 107 35 17 20
@vudaltsov
vudaltsov / install.sh
Created July 25, 2019 12:26
phpenv Mac install script
CONFIGURE_OPTS="\
--with-zlib-dir=$(brew --prefix zlib)\
--with-bz2=$(brew --prefix bzip2)\
--with-iconv=$(brew --prefix libiconv)\
--with-readline=$(brew --prefix readline)\
--with-libedit=$(brew --prefix libedit)\
--with-tidy=$(brew --prefix tidy-html5)\
--with-curl=$(brew --prefix curl)\
--with-jpeg-dir=$(brew --prefix jpeg)\
--with-png-dir=$(brew --prefix libpng)\
@vudaltsov
vudaltsov / Makefile
Created December 10, 2019 14:55
Self-documenting Makefile with categories and aliases
##
## Tools
## -----
ls: list-files
list-files: ## List files
ls -lah
.PHONY: ls list-files
@vudaltsov
vudaltsov / Php74ReflectionExtractor.php
Created May 3, 2020 19:49
Symfony <5.1 PHP 7.4 property types support
<?php
declare(strict_types=1);
namespace App\PropertyInfo;
use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
use Symfony\Component\PropertyInfo\Type;
final class Php74ReflectionExtractor implements PropertyTypeExtractorInterface
@vudaltsov
vudaltsov / A.php
Last active June 23, 2020 09:45
Symfony decorator
<?php
declare(strict_types=1);
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
final class A implements I, LoggerAwareInterface
{
use LoggerAwareTrait;
<?php
declare(strict_types=1);
namespace Infrastructure\Messaging;
use Doctrine\Persistence\ManagerRegistry;
use Psr\Log\LoggerInterface;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Middleware\MiddlewareInterface;
@vudaltsov
vudaltsov / AppKernel.php
Last active July 19, 2020 19:56
Removing unnecessary Symfony services via a compiler pass
<?php
declare(strict_types=1);
namespace Application;
use Application\DependencyInjection\RemoveObjectNormalizerPass;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@vudaltsov
vudaltsov / PostgreSQLUpsertBuilder.php
Created July 14, 2019 21:24
PostgreSQLUpsertBuilder
<?php
declare(strict_types=1);
namespace App\Doctrine\DBAL\Builder;
use Countable;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Statement;
use Webmozart\Assert\Assert;