Skip to content

Instantly share code, notes, and snippets.

View brzuchal's full-sized avatar

Michał Marcin Brzuchalski brzuchal

View GitHub Profile
@brzuchal
brzuchal / short-closures.md
Last active July 27, 2017 12:36
Callable Dereference

Introduction

Callables syntactically have few ways of passing them around. This RFC is supposed to introduce unified short way of creating closures from callables and reduce callable type hint checks at runtime by using closures.

Callable syntax

Currently there are few ways of declaring callables and they differ while dereferencing function or method. Assuming given example we'll gonan discuss all available 6 ways passing callable.

As this is a language change, a 2/3 majority is required.
The vote is a straight Yes/No vote for accepting the RFC and merging the patch.
The additional vote is also a straight Yes/No vote for accepting variance behaviour on object type.
<doodle title="Accept the object typehint RFC for PHP 7.2?" auth="brzuchal" voteType="single" closed="false">
* Yes
* No
</doodle>
<doodle title="Object type should implement variance?" auth="brzuchal" voteType="single" closed="false">
@brzuchal
brzuchal / Makefile
Created April 18, 2017 08:03
Embeding PHP7
CC=gcc
CFLAGS=-c $(shell php-config --includes ) -Wall -g
LDFLAGS=$(shell php-config --ldflags )
all: embed.c
$(CC) -o embed.o embed.c $(CFLAGS)
$(CC) -o embed embed.o $(LDFLAGS)
PHP RFC: Ommit double-slash in user Stream Wrapper URI

  * Version: 1.0
  * Date: 2017-01-23
  * Author: Michał Brzuchalski <michal.brzuchalski@gmail.com>
  * Status: Draft
  * First Published at: http://wiki.php.net/rfc/ommit-double-slash-in-user-stream-wrapper-uri

Introduction

Regarding RFC 2396 defining URI Generic Syntax which specifies URI Syntactic Components:

@brzuchal
brzuchal / 01-index.php
Last active January 15, 2017 12:48
PHP Module
<?php
require 'module.php';
require 'doctrine-module.php';
$myClass = MyVendor\MyModulePackageBundle\Domain\MyClass();
echo $myClass::module; // MyVendor\MyModulePackageBundle
var_dump(file_exists('vendor+package:resources/config.yml')); // true
$driver = new Doctrine\DBAL\Driver\Mysql();
<?php
namespace Plumbok\Test;
/**
* @Value
*/
class Email
{
private $email = '';
<?php declare(strict_types=1);
namespace MyTest;
/**
* @ValueObject
*/
class MyClass {
/**
* @var int
* @Setter @Getter
*/
@brzuchal
brzuchal / person.php
Last active November 23, 2016 11:51
Nested/Inner classes playground
<?php
class Person
{
private interface Name
{
public function __construct(string $name);
public function __toString() : string;
}
@brzuchal
brzuchal / namespaces.diff
Created November 10, 2016 11:46
PHP Namespaces Struct
diff --git a/Zend/zend.c b/Zend/zend.c
index 44a73ba..60ff916 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -36,11 +36,13 @@
#ifdef ZTS
# define GLOBAL_FUNCTION_TABLE global_function_table
# define GLOBAL_CLASS_TABLE global_class_table
+# define GLOBAL_NAMESPACE_TABLE global_namespace_table
# define GLOBAL_CONSTANTS_TABLE global_constants_table
@brzuchal
brzuchal / object-variance.php
Created November 9, 2016 14:15
Object typehint & return type variance
<?php
class A {}
class B {
function foo(object $a) : object {
return $a;
}
}
class C extends B {