Skip to content

Instantly share code, notes, and snippets.

View Golpha's full-sized avatar

Matthias Kaschubowski Golpha

  • Germany
View GitHub Profile
@Golpha
Golpha / Readme.md
Last active December 17, 2022 16:48
PHP Object-hacks without Reflections: Injectors and Closure Binding References

PHP Object-hacks without Reflections

Sometimes it is needed to manipulate private and protected properties of instances. The common way to do this is to manipule the visibility of the targeted properties using class reflection, but there is a more memory and performance efficient way to accomplish this task.

Reading and writing private and protected properties using injectors

At first injectors are not standardized nor described along design patterns, i choose Injectors as the name for this mechanic because of their major usage. The explicit technical name could be: IO-Adapters for invisible properties. Injectors do use closure binding with a explicit class scope. So, whatever you want to modify does require knowledge about the implementation details of the targeted parameters, as you should have when directly using closure binding.

The Injector class
@Golpha
Golpha / IP-Guide.md
Created August 23, 2014 02:25
The PHP IP Guide

The PHP IP Guide

This guide shows you common practices to convert IPv4- and IPv6-Addresses into their binary representation.

Who is responsible for this ?

This guide has been written by Matthias Kaschubowski, a autodidactical software developer from germany with about 14 years of practice converting coffee to code. He works in his free time as a php evangelist on a lot of platforms ( last shown as tr0y on php.de, a german PHP related forum and as himself as an adminstrator at the largest PHP-related facebook group ).

Basics

@Golpha
Golpha / MySQLiAdapter.php
Created January 15, 2014 22:32
Default Implementation of a MySQLi-Adapter Requirements: PHP 5.4 or higher
<?php
/**
* MySQLiAdapter Class
* Implements instance incubation of MySQLi
*/
class MySQLiAdapter
{
/**
* @var string
@Golpha
Golpha / redirects.md
Last active December 28, 2015 16:49
Hypertext-Transfer-Protocol: Redirects

Hypertext Transfer Protocol Redirect Methods

Redirecting with PHP

The most common way to execute redirects with PHP is to send headers to the client. This can be easily done with the header-Method of PHP.

<?php

header('location: http://www.example.org/foo/bar');