Skip to content

Instantly share code, notes, and snippets.

View Ocramius's full-sized 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 / check-source-baseline-size.sh
Last active February 24, 2023 10:25
Script to check whether `psalm-baseline.xml` improved/worsened over time
#!/usr/bin/env bash
export TARGET_REF=${TARGET_REF:-HEAD}
git show "$TARGET_REF:psalm-baseline.xml" | xmllint --xpath 'count(//file[not(starts-with(@src, "test"))]/*/code)' -
@Ocramius
Ocramius / .gitignore
Last active January 10, 2023 16:34
`Zend\EventManager` examples
vendor
composer.lock
@Ocramius
Ocramius / healthy-git-flow.sh
Created October 7, 2022 08:31
A healthy git-flow (if you can call git-flow healthy at all), in which `master` is correctly merged back to `develop`
git checkout -b master
git log -1
# commit 65345471c1040ceb90b1817d7427d58d7b09fdca (HEAD -> master)
git checkout -b develop
git log -1
# both branches are at the same ref:
# commit 65345471c1040ceb90b1817d7427d58d7b09fdca (HEAD -> develop, master)
echo "a feature" > feature.txt
@Ocramius
Ocramius / Day.php
Created April 3, 2020 14:13
Example abstraction that only allows a resolution of "day" for time inside a specific business domain
<?php
declare(strict_types=1);
namespace Core\Domain\Time;
use DateTimeImmutable;
use DateTimeZone;
use Generator;
use Iterator;
<?php
declare(strict_types=1);
namespace Tests\Integration;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
use ReflectionProperty;
use Webmozart\Assert\Assert;
There are a lot of complaints going around about Laravel these days, but a lot
of the important ones seem to be missing from the spotlight.
Bugfixes, issues and pull requests being left open for months with no
clarification of intent:
- https://github.com/laravel/framework/pull/1799
- https://github.com/laravel/framework/issues/1963
- https://github.com/laravel/framework/issues/2089
- https://github.com/laravel/framework/issues/2234
#!/usr/bin/env php
<?php
declare(strict_types=1);
namespace WaitForElasticsearch;
use InvalidArgumentException;
use UnexpectedValueException;
use function curl_close;
@Ocramius
Ocramius / .gitignore
Last active December 3, 2021 09:30
`Zend\ServiceManager` examples
vendor
composer.lock
@Ocramius
Ocramius / quick-doctrine-orm-zf2-sql-logging.local.php
Last active October 19, 2021 05:48
SQL Logger in Doctrine 2 ORM and ZF2
<?php
use Zend\ServiceManager\ServiceLocatorInterface;
return [
'service_manager' => [
'delegator' => [
'doctrine.entitymanager.orm_default' => [
function (ServiceLocatorInterface $sl, $name, $requestedName, $callback) {
/* @var $em \Doctrine\ORM\EntityManager */
@Ocramius
Ocramius / Foo.php
Last active March 12, 2021 14:14
Self hydrating object proxy in PHP Provides faster hydration by removing the need for reflection.
<?php
class Foo
{
protected $foo;
protected $bar;
protected $baz;
}