Skip to content

Instantly share code, notes, and snippets.

View alcaeus's full-sized avatar

Andreas Braun alcaeus

View GitHub Profile
<?php
/** @generate-function-entries */
namespace Foo {
function baz(): void {}
}
namespace Bar {
function baz(): void {}
@alcaeus
alcaeus / Category.php
Last active July 22, 2020 08:47
DTO example
final class Category
{
private string $name;
public static function fromName(string $name): self
{
return new self($name);
}
private function __construct(string $name)
@alcaeus
alcaeus / composer.json
Last active May 20, 2020 15:06
Why composer hacks don't help when testing against PHP 8
{
"require": {
"php": "^7.2",
"vendor/extension": "^1 || ^2",
"vendor/restrictive": "^1 || ^2"
}
}
@alcaeus
alcaeus / changes.patch
Last active December 5, 2019 13:11
doctrine/mongodb-odm && doctrine/coding-standard 7.0
diff --git a/composer.json b/composer.json
index 166745af..57482d73 100644
--- a/composer.json
+++ b/composer.json
@@ -11,6 +11,9 @@
"mapping",
"object"
],
+ "repositories": [
+ {"type": "vcs", "url": "https://github.com/simPod/coding-standard"}
<?php
declare(strict_types=1);
namespace Doctrine\ODM\MongoDB\Tests\Functional\Ticket;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use Doctrine\ODM\MongoDB\Tests\BaseTest;
class GH2039Test extends BaseTest
@alcaeus
alcaeus / declare_vars.php
Created September 19, 2019 15:05
declare_vars examples
<?php
/*
* When enabled, forces all variables to be declared before read/write access.
* The feature can be turned on and off.
*/
declare(declare_vars=1);
var_dump($undeclaredVar); // Compile error
$undeclaredVar = 'something'; // Compile error
@alcaeus
alcaeus / release.md
Created August 29, 2019 11:24
ODM release docs

MongoDB ODM release docs

Prepare changelog

Clone jwage/changelog-generator, then run:

$ ./bin/changelog-generator generate --user=doctrine --repository=mongodb-odm --milestone=1.2.10

Clean up the changelog if necessary by checking milestone issues and differences from the last tag

@alcaeus
alcaeus / GH2028Test.php
Created June 4, 2019 15:40
Functional test for #2028
<?php
namespace Doctrine\ODM\MongoDB\Tests\Functional\Ticket;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use Doctrine\ODM\MongoDB\Tests\BaseTest;
class GH2028Test extends BaseTest
{
public function testStoreHashWithIntKeys()
@alcaeus
alcaeus / File.php
Last active April 24, 2018 18:33
GridFS in ODM 2.0
<?php
declare(strict_types = 1);
namespace Documents;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
/** @ODM\File */
class File
@alcaeus
alcaeus / childclass.php
Created October 4, 2017 13:19
Broken class aliases
<?php declare(strict_types = 1);
if (false) {
// Alias will never be used
class_alias('FakeParentClass', 'ParentClass');
}
class ChildClass extends ParentClass
{
public function bar(): void