Skip to content

Instantly share code, notes, and snippets.

View bcremer's full-sized avatar

Benjamin Cremer bcremer

View GitHub Profile
@ruudk
ruudk / README.md
Created December 8, 2022 15:35
How to find the files that are the slowest to analyze with PHPStan?

How to find the files that are the slowest to analyze with PHPStan?

For us, PHPStan became a bit slower with every release. We have a very large codebase with 10.000+ classes. There seem to be a few known issues related to big arrays.

See: phpstan/phpstan#8353 phpstan/phpstan#8146

To understand which files are problematic we run the following command:

@Ocramius
Ocramius / handling-optional-input-fields-with-type-safe-abstractions.md
Last active March 17, 2023 12:06
Handling optional input parameters in PHP with `vimeo/psalm` and `azjezz/psl`

Handling optional input parameters in PHP with vimeo/psalm and azjezz/psl

I had an interesting use-case with a customer for which I provide consulting services: they needed multiple fields to be marked as "optional".

Example: updating a user

We will take a CRUD-ish example, for the sake of simplicity.

For example, in the following scenario, does a null $description mean "remove the description",

{
"registrar": [
{
"provider": "class",
"language": "php",
"signatures": [
{
"class": "FooClass",
"method": "foo",
"type": "type"
@shyim
shyim / Gulpfile.js
Last active November 27, 2018 11:05
Gulp Shopware with browser-sync
function basename(path) {
return path.split('/').reverse()[0];
}
var gulp = require('gulp'),
less = require('gulp-less'),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
path = require('path'),
fs = require('fs'),
@mtdowling
mtdowling / gist:3877616
Last active September 30, 2021 06:34
Recursive XML to array function
<?php
function xml2array($xml)
{
$arr = array();
foreach ($xml->getNamespaces() + array(null) as $prefix => $namespace) {
foreach ($xml->attributes($namespace) as $key => $value) {
// Add prefixes to prefixed attributes
if (is_string($prefix)) {