Skip to content

Instantly share code, notes, and snippets.

@heiglandreas
heiglandreas / CallInPHP74.php
Last active Jan 24, 2021
Functions that take faulty parameters without notice in PHP7.4 but raise a type-error in PHP8
View CallInPHP74.php
<?php
/**
* This file reads the previously created file and executes the listed function calls via eval.
* As eval throws up when something goes south I needed to exclude some calls, where pass-by-reference is used
* This script will then check whether a warning is raised or not and if not, add the function call to the file
* "problematicFunctionCalls" and the function itself to the "problematicFunctions" file.
*/
$wasError = false;
function myErrorHandler(int $errno , string $errstr , ?string $errfile = null , ?int $errline = null , ?array $errcontext = [] ): bool
@heiglandreas
heiglandreas / example1.php
Created Jan 14, 2019
Different Scopes for reading and writing properties
View example1.php
<?php
class Foo
{
// when there are two visibility declarations following one another
// the first one describes reading, the second one writing.
// If it's only one declaration it is used for reading *and* writing
// So this can be read publicly but only this class can write to the property.
public private int $int;
@heiglandreas
heiglandreas / datetime.php
Created Sep 11, 2018
Add minutes to a datetime
View datetime.php
$dt = new DateTimeImmutable();
$minute = new DateInterval('PT1M');
$dt = $dt->add($minute);
@heiglandreas
heiglandreas / Date.php
Last active Jul 4, 2018
A plain Date-Object without time-information – somehow
View Date.php
<?php
/*
* Copyright (c) Andreas Heigl <andreas@heigl.org>
*
* Licensed under the MIT License. See LICENSE.md file in the project root
* for full license information.
*/
namespace Org_Heigl\Date;
View verifying a signature
heiglandreas ~ $ curl -LO https://api.getlatestassets.com/github/heiglandreas/junitdiff/junitdiff.phar
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 604 0 604 0 0 550 0 --:--:-- 0:00:01 --:--:-- 550
100 256k 100 256k 0 0 105k 0 0:00:02 0:00:02 --:--:-- 217k
heiglandreas ~ $ curl -LO https://api.getlatestassets.com/github/heiglandreas/junitdiff/junitdiff.phar.asc
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
@heiglandreas
heiglandreas / DevelopmentDependencies.php
Created Mar 11, 2018
Problems with extending Disco-Annotations
View DevelopmentDependencies.php
<?php
/**
* Class DevelopmentDependencies
*
* @Configuration
*/
class DevelopmentDependencies extends GlobalDependencies
{
/**
View peasoup.md

Ingredients

  • 250g dryed peas
  • some vegetables like carrots, onion, celery, choped
  • 1l water
  • 1 onion
  • 125g bacon

Preparation

@heiglandreas
heiglandreas / UUID1.php
Last active Sep 5, 2017
Different ways of a UUID-implementation
View UUID1.php
<?php
namespace Acme;
class UUID1
{
private $uuid;
public static function v4() { return new self(\UUID::v4())
private function __construct(\UUID $uuid) { $this->uuid = $uuid; }
@heiglandreas
heiglandreas / Ldap.php
Last active Jun 30, 2017
Use Zend-Ldap as authentication backend when you want to authenticate using different attributes
View Ldap.php
<?php
namespace Acme\Authentication\Adapter;
use Zend\Authentication\Adapter\Ldap as LdapAdapter;
class Ldap extends LdapAdpater
{
public function authenticate()
{
@heiglandreas
heiglandreas / ldap.php
Last active Sep 18, 2019
Disable Certificate-check for LDAPS/ldap_tls
View ldap.php
<?php
$con = ldap_connect('ldaps://ldap.example.com');
ldap_set_option($con, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($con, LDAP_OPT_X_TLS_REQUIRE_CERT, LDAP_OPT_X_TLS_NEVER);
/*
Possible values:
LDAP_OPT_X_TLS_NEVER
This is the default. slapd will not ask the client for a certificate.