Skip to content

Instantly share code, notes, and snippets.

Avatar
🔬
In your repositories, watching your code. Always watching.

Marco Pivetta Ocramius

🔬
In your repositories, watching your code. Always watching.
View GitHub Profile
@Ocramius
Ocramius / Day.php
Created Apr 3, 2020
Example abstraction that only allows a resolution of "day" for time inside a specific business domain
View Day.php
<?php
declare(strict_types=1);
namespace Core\Domain\Time;
use DateTimeImmutable;
use DateTimeZone;
use Generator;
use Iterator;
@Ocramius
Ocramius / psalm-compendium.php
Last active Sep 7, 2020
A small compendium of what is possible with `vimeo/psalm` 3.9.x to add some decent type system features to PHP
View psalm-compendium.php
<?php
// -- types are a compile-time propagated concept
// https://psalm.dev/r/338f74a96c
class TheType
{
/** @var string */
public $foo = 'bar';
}
View wait-for-elasticsearch.php
#!/usr/bin/env php
<?php
declare(strict_types=1);
namespace WaitForElasticsearch;
use InvalidArgumentException;
use UnexpectedValueException;
use function curl_close;
View EventSourcedAggregateContext.php
<?php
declare(strict_types=1);
namespace Test\Feature;
use Shared\Domain\DomainEvent;
use Shared\Domain\EventSourcedAggregateRoot;
use Webmozart\Assert\Assert;
use function array_shift;
@Ocramius
Ocramius / compiler-pass.php
Last active Mar 16, 2020
Compiler pass to declare a repository as service for each declared doctrine entity in a symfony application
View compiler-pass.php
<?php
final class RegisterRepositoriesForAllEntitiesPass implements CompilerPassInterface
{
/** {@inheritdoc} */
public function process(ContainerBuilder $container)
{
/** @var MappingDriver $metadata */
$metadata = $container->get($this->mappingDriverServiceName());
$entityManagerReference = new Reference('doctrine.orm.entity_manager');
@Ocramius
Ocramius / proposed-dql-inspections.php
Created Sep 21, 2018
DQL inspections example/proposal for JetBrains PHPStorm EAP
View proposed-dql-inspections.php
<?php
class Foo {
private $bar = 'baz';
/** @var Baz @ORM\ManyToOne(targetEntity=Baz::class) */
private $baz;
}
class Baz {
private $tab = 'taz';
@Ocramius
Ocramius / DOCTRINE-ORM-3.x-BC-BREAKS-2018-09-12.txt
Last active Sep 12, 2018
Doctrine ORM 3.x BC breaks as per 2018-09-12
View DOCTRINE-ORM-3.x-BC-BREAKS-2018-09-12.txt
[BC] REMOVED: Property Doctrine\ORM\AbstractQuery#$_resultSetMapping was removed
[BC] REMOVED: Property Doctrine\ORM\AbstractQuery#$_em was removed
[BC] REMOVED: Property Doctrine\ORM\AbstractQuery#$_hints was removed
[BC] REMOVED: Property Doctrine\ORM\AbstractQuery#$_hydrationMode was removed
[BC] REMOVED: Property Doctrine\ORM\AbstractQuery#$_queryCacheProfile was removed
[BC] REMOVED: Property Doctrine\ORM\AbstractQuery#$_expireResultCache was removed
[BC] REMOVED: Property Doctrine\ORM\AbstractQuery#$_hydrationCacheProfile was removed
[BC] REMOVED: Method Doctrine\ORM\AbstractQuery#_doExecute() was removed
[BC] REMOVED: Method Doctrine\ORM\ORMInvalidArgumentException::invalidEntityName() was removed
[BC] CHANGED: The parameter $associationMapping of Doctrine\ORM\ORMInvalidArgumentException::newEntityFoundThroughRelationship() changed from array to a non-contravariant Doctrine\ORM\Mapping\AssociationMetadata
@Ocramius
Ocramius / BC-BREAKS.txt
Created Aug 20, 2018
doctrine/dbal 2.7.2 -> 2.8.0 Backwards Compatibility (BC) breaks
View BC-BREAKS.txt
[BC] CHANGED: Type documentation for property Doctrine\DBAL\Connection#$_conn changed from \Doctrine\DBAL\Driver\Connection to \Doctrine\DBAL\Driver\Connection|null
[BC] CHANGED: Type documentation for property Doctrine\DBAL\Connections\MasterSlaveConnection#$connections changed from \Doctrine\DBAL\Driver\Connection[] to \Doctrine\DBAL\Driver\Connection[]|null[]
[BC] CHANGED: Type documentation for property Doctrine\DBAL\Connection#$_conn changed from \Doctrine\DBAL\Driver\Connection to \Doctrine\DBAL\Driver\Connection|null
[BC] CHANGED: Type documentation for property Doctrine\DBAL\Connection#$_conn changed from \Doctrine\DBAL\Driver\Connection to \Doctrine\DBAL\Driver\Connection|null
[BC] SKIPPED: Provided node "Symfony\Component\Console\Command\Command" is not class, but "interface"
[BC] SKIPPED: Provided node "Symfony\Component\Console\Command\Command" is not class, but "interface"
[BC] SKIPPED: Provided node "Symfony\Component\Console\Command\Command" is not class, but "interface"
[BC] SKIPPED: Provided
@Ocramius
Ocramius / Caddyfile
Last active Sep 18, 2020
Example docker + docker-compose + caddy + traefik setup that routes to multiple apps from one exposed HTTP port
View Caddyfile
:80 {
root /serve
}
View .gitlab-ci.yml
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay2
build-test-containers:
image: tiangolo/docker-with-compose
before_script:
- docker info
You can’t perform that action at this time.