Skip to content

Instantly share code, notes, and snippets.


Michał Marcin Brzuchalski brzuchal

View GitHub Profile
brzuchal /
Created Jul 9, 2020

Passionate PHP Developer focused on microservices and PHP internals.

Current RFC's

StackFrame class

It's an alternative to debug_backtrace() with stack-trace frames as objects using less memory than arrays. Introduced class include two static methods which allows collecting frames from stacktrace:

  • StackFrame::getTrace(?int $limit = null, ?int $offset = null): array - collects all or portion of stacktrace
  • StackFrame::getFrame(int $index): StackFrame - retrieves a single frame from the stacktrace
brzuchal /
Last active Jul 6, 2020
PHP Marco Candidates

PHP Macro

Call syntax

Macro call syntax in ABNF:

arg-name   = 1*ALPHA
arg        = [ arg-name ":" ] ( expr | statement )
arg-list   = [ arg [ "," ] ]
arg-list  /= arg "," arg-list
macro-name = 1*ALPHA
brzuchal / syntax.php
Created Jul 4, 2020
PHP Language Syntax Improvement
View syntax.php
# Proposal
// remove parens gives a clear sign that it's not a function
declare strict_types = 1;
// require parens in constructs allowed to be used like a function
false or print("always returns 1");
// exit and die never returns value like echo and __halt_compiler
View load.log
root@284352ebf2f3:/src# make install
/bin/bash /src/libtool --mode=install cp ./ /src/modules
cp ./.libs/ /src/modules/
cp ./.libs/stdng.lai /src/modules/
PATH="$PATH:/sbin" ldconfig -n /src/modules
Libraries have been installed in:
brzuchal /
Last active Mar 31, 2020
PHP delegates

PHP RFC: Delegates


To distinguish between classes and delegates a delegate keyword is used to precede delegate name. For FQN optimisations an additional use delegate clause should be placed in all imports and aliases block.

namespace MyApp;
brzuchal / reflection.php
Created Mar 25, 2020
PHP Reflection in PHP Namespace
View reflection.php
namespace {
class ReflectionClass extends \Php\ReflectionClass {}
class ReflectionType extends \Php\ReflectionTypeConstraint {}
class ReflectionNamedType extends \Php\ReflectionClassTypeConstraint {}
namespace Php {
abstract class ReflectionType implements Reflector {}
class ReflectionClass extends ReflectionType {}
class ReflectionTypeConstraint {}
brzuchal / php.rfc
Last active Mar 19, 2021
PHP Structs Example
View php.rfc
====== PHP RFC: Structs ======
* Version: 0.9
* Date: 2020-03-25
* Author: Michał Brzuchalski <>
* Status: Draft
* First Published at:
Structures as a complex type solution for programmers in functional programming appears in few programming languages but differs in a solution taken there. Some languages like **C#** have both **classes** and **scructs** living aside in harmony.
brzuchal / data.php
Last active Aug 26, 2019
Data type PHP
View data.php
data Foo {
var string $foo; // if not set then uninitialized
var bool $bar = false;
$foo = new Foo
foo: "baz",
brzuchal / package.ini
Last active Aug 14, 2019
PHP Package - Possible package definition declarations
View package.ini
name = MyVendor\MyLibrary
strict_types = 1
encoding = UTF-8

Sealed classes


A sealed type is one for which subclassing is restricted according to subclass names specified with the class’s declaration or to restrict to the same subclass namespace.

Sealed type is more like extended form of finality, where it is possible to list all class names allowed to extending from sealed class or permit only same namespace class to extend sealed class.