Skip to content

Instantly share code, notes, and snippets.

Avatar
💥
breaking builds

Michael Moravec Majkl578

💥
breaking builds
View GitHub Profile
@Majkl578
Majkl578 / typed-property.php
Last active Jun 5, 2019
model example for typed properties
View typed-property.php
<?php
declare(strict_types=1);
final class Foo
{
var DateTimeImmutable $createdAt {
get;
private set(DateTimeImmutable $value) : void {
assert($this->createdAt === null, "Can't change time of creation.");
View ArbitraryRun.php
<?php
declare(strict_Types=1);
namespace Example;
(function () : void {
$requestFactory = new class implements ServerRequestFactory {
public function __invoke() : ServerRequest
{
View anon-class-use.php
<?php
$hello = 'Hello';
$world = 'World';
$speaker = new class use ($hello as public, $world as private $who) {
public function say() : void
{
echo $this->hello . ' ' $this->who, PHP_EOL;
}
@Majkl578
Majkl578 / Comparable.php
Last active Oct 30, 2018
Equatable + Comparable
View Comparable.php
<?php
declare(strict_types=1);
namespace Comparison;
/**
* This interface imposes a total ordering on the objects of each class that implements it.
* This ordering is referred to as the class's natural ordering, and the class's compareTo method
* is referred to as its natural comparison method.
View gist:2107492b128c35dff8d2007913d4cde8
$ vendor/bin/roave-backward-compatibility-check r:a --from=v1.7.2 --to=master -- lib
Comparing from 3e7656c5adfd9b7d0d8757aa1e9e8daf43a6f200 to bba2123d7d8ab43927ff2370a4785892b7c181d5...
Loading composer repositories with package information
Updating dependencies
Package operations: 13 installs, 0 updates, 0 removals
- Installing ocramius/package-versions (1.3.0): Loading from cache
- Installing zendframework/zend-eventmanager (3.2.1): Loading from cache
- Installing zendframework/zend-code (3.3.0): Loading from cache
- Installing ocramius/proxy-manager (2.2.0): Loading from cache
- Installing symfony/polyfill-mbstring (v1.8.0): Loading from cache
View annotation.ast
> Annotations
> > Annotation
> > > Reference {"identifier":"Annot","fully_qualified":false}
> > > Parameters
> > > > Parameter\NamedParameter
> > > > > Scalar\Identifier {"value":"v1"}
> > > > > Collection\ListCollection
> > > > > > Scalar\IntegerScalar {"value":1}
> > > > > > Scalar\IntegerScalar {"value":2}
> > > > > > Scalar\IntegerScalar {"value":3}
@Majkl578
Majkl578 / 100
Created Apr 27, 2018
Doctrine logo ASCII
View 100
+----------------------------------------------------------------------------------------------------+
|oooooooooooooooooooooooooo:: ...:ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooooooo.. .::oooooooooooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooooo:. .:oooooooooooooooooooooooooooooooooooooooooooooooooooooooo|
|ooooooooooooooooooooo: .:oooooooooooooooooooooooooooooooooooooooooooooooooooooo|
|ooooooooooooooooooooo ..oooooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooo: .:oooooooooooooooooooooooooooooooooooooooooooooooooo|
|oooooooooooooooooooo. ..oooooooooooooooooooooooooooooooooooooooooooooooo|
|ooooooooooooooooooooo :oooooooooooooooooooooooooooooooooooooooooooooo|
|ooooooooooooooooooooo: .oooooooooooooooooooooooooooooooooooooooo
View closures.php
<?php
new class
{
public function __construct()
{
$s = microtime(true);
for ($i = 0; $i < 100000000; $i++) {
(function () {})();
@Majkl578
Majkl578 / assert.php
Created Apr 11, 2018
signature misuse + func_get_args() vs. assert() + count() @ PHP 7.2
View assert.php
<?php
function foo(int ...$prices)
{
assert(count($prices) > 0);
}
$t = microtime(true);
for ($i = 0; $i < 10000000; $i++) {
View keybase.md

Keybase proof

I hereby claim:

  • I am majkl578 on github.
  • I am majkl (https://keybase.io/majkl) on keybase.
  • I have a public key ASBoeRpsENPXRp5PvnaxBaoeKzodCPdO3Q5JA5WA1hfT7wo

To claim this, I am signing this object: