Skip to content

Instantly share code, notes, and snippets.

View Girgias's full-sized avatar
🐘

Gina Peter Banyard Girgias

🐘
View GitHub Profile
@Girgias
Girgias / example.php
Last active February 23, 2024 12:38
Moving away from Monads to handle errors
<?php
function generateFunctionsAndClass(int $i)
{
$i1 = $i - 1;
return <<<TEMPLATE
enum E{$i} { case Error; }
class R{$i} {}
function f{$i}(R{$i1} \$input): R{$i}|E{$i} { return new R{$i}; }
function e{$i}(R{$i1} \$input): R{$i}|E{$i} { return E{$i}::Error; }
@Girgias
Girgias / Classes.txt
Created August 14, 2023 19:54
Minimum number of class types in a PHP build
NB: 148
InternalIterator
Exception
ErrorException
Error
CompileError
ParseError
TypeError
ArgumentCountError
ValueError
@Girgias
Girgias / prepare-release.php
Created February 22, 2021 21:58
Snipper to prepare PECL releases
<?php
$iter = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__ . '/tests/', FilesystemIterator::CURRENT_AS_PATHNAME | FilesystemIterator::SKIP_DOTS));
$paths = str_replace(__DIR__ . '/', '', iterator_to_array($iter));
natsort($paths);
@Girgias
Girgias / update-en-revision.php
Created December 4, 2020 18:35
Update EN-Revision tag for PHP Doc translations after applying a patch
<?php
$folder = __DIR__ . '/reference/imagick/';
$en_revision = 351852;
$files = glob($folder . '*/?*.xml.orig');
foreach ($files as $fileOrig) {
$file = substr($fileOrig, 0, -5);
// Check if there is a reject file, in which case do not update revision
if (file_exists($file . '.rej')) {
@Girgias
Girgias / steps.md
Last active December 5, 2020 12:47
How to commit a Git patch to SVN for the PHP Documentation

This assumes 2 copies of the PHP documentation repo, one "official" SVN which is meant to be kept clean, and a fork of php/doc-en

After the doc PR has been reviewed/approved/decided to merge, squash it into one commit (make sure the branch is up to date with upstream).

Assumed file structure

For the purpose of this tutorial, the following file structure is assumed:

|
|-- doc-en the Git fork
| |(content of English documentation)
@Girgias
Girgias / disgusting.php
Created November 17, 2020 19:07
Weirdly found a way to use variable variables...
<?php
/***
* This only generates a draft from which to work on as Academic and Wellbeing reps are not available
* from the union eActivity API
***/
const EACTIVITY_API_KEY = 'API KEY';
/** CSP id number */
const RCSU_EACTIVITY_ID = 'RCSUID';
@Girgias
Girgias / commands.md
Last active November 3, 2020 08:32
Commands to update French docs canonical type and sync with EN revision

Changes to be made:

  • <type>integer</type> into <type>int</type>
  • <type>boolean</type> into <type>bool</type>
  • <type>entier</type> into &integer;

Example for <type>integer</type>:

Find and update the SVN Revision first:

@Girgias
Girgias / appveyor-compiler-error.txt
Created February 27, 2020 12:54
Appveyor compiler errors.
---------------------------------------
Type 'nmake snap' to build a PHP snapshot
Recreating build dirs
Recreating build dirs
bison.exe --output=Zend/zend_ini_parser.c -v -d Zend/zend_ini_parser.y
bison.exe --output=Zend/zend_language_parser.c -v -d Zend/zend_language_parser.y
"re2c.exe" --no-generation-date --case-inverted -cbdFt Zend/zend_ini_scanner_defs.h -oZend/zend_ini_scanner.c Zend/zend_ini_scanner.l
"re2c.exe" --no-generation-date --case-inverted -cbdFt Zend/zend_language_scanner_defs.h -oZend/zend_language_scanner.c Zend/zend_language_scanner.l
bison.exe --output=sapi/phpdbg/phpdbg_parser.c -v -d sapi/phpdbg/phpdbg_parser.y
"re2c.exe" --no-generation-date -cbdFo sapi/phpdbg/phpdbg_lexer.c sapi/phpdbg/phpdbg_lexer.l
@Girgias
Girgias / compiler-output
Created February 3, 2020 11:40
php-src compiled with -Wall -Wpedantic -Wextra at commit ref 4cbffd89d9e82d81a26746aadca27ad061cab43a
This file has been truncated, but you can view the full file.
/bin/bash /mnt/c/Dev/php-src/libtool --silent --preserve-dup-deps --mode=compile cc -Iext/date/lib -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DHAVE_TIMELIB_CONFIG_H=1 -Iext/date/ -I/mnt/c/Dev/php-src/ext/date/ -DPHP_ATOM_INC -I/mnt/c/Dev/php-src/include -I/mnt/c/Dev/php-src/main -I/mnt/c/Dev/php-src -I/usr/include/valgrind -I/mnt/c/Dev/php-src/ext/date/lib -I/mnt/c/Dev/php-src/TSRM -I/mnt/c/Dev/php-src/Zend -Wall -Wpedantic -Wextra -fvisibility=hidden -O0 -Wall -Wno-strict-aliasing -g -DZEND_SIGNALS -c /mnt/c/Dev/php-src/ext/date/php_date.c -o ext/date/php_date.lo
In file included from /mnt/c/Dev/php-src/Zend/zend_API.h:25:0,
from /mnt/c/Dev/php-src/main/php.h:35,
from /mnt/c/Dev/php-src/ext/date/php_date.c:17:
/mnt/c/Dev/php-src/ext/date/php_date.c: In function ‘zm_activate_date’:
/mnt/c/Dev/php-src/Zend/zend_modules.h:27:29: warning: unused parameter ‘type’ [-Wunused-parameter]
#define INIT_FUNC_ARGS int type, int module_number
^
/mnt/c/Dev/ph
@Girgias
Girgias / output.txt
Created January 23, 2020 11:56
spprintf custom format grep
george@DESKTOP-GEORGE-P:/mnt/c/Dev/php-src$ grep -rPbnH "(v)?s(tr)?pprintf\(.*%(\+|-| |#|0)?(\d+|\*)?(\.(\d+|\*))?(h|H|k|v|t|j|z|Z|l|L|I).*\)"
ext/ffi/ffi.c:798:21768: return strpprintf(0, "@%s@%zu", ZSTR_VAL(name), zend_ffi_arg_size(type));
ext/ffi/ffi.c:802:21898: return strpprintf(0, "_%s@%zu", ZSTR_VAL(name), zend_ffi_arg_size(type));
ext/ffi/ffi.c:806:22050: return strpprintf(0, "%s@@%zu", ZSTR_VAL(name), zend_ffi_arg_size(type));
ext/pdo_odbc/odbc_driver.c:42:1567: message = strpprintf(0, "%s (%s[%ld] at %s:%d)",
ext/phar/phar.c:2467:69708: spprintf(error, 0, "Illegal filename passed in for stub creation, was %zd characters long, and only 400 or less is allowed", index_len);
ext/phar/phar.c:2475:69976: spprintf(error, 0, "Illegal web filename passed in for stub creation, was %zd characters long, and only 400 or less is allowed", web_len);
ext/spl/php_spl.c:849:27082: return strpprintf(32,