Static inheritance in PHP (and really any language) can get tricky sometimes, especially when you’re trying to figure out what self is currently referring to. In PHP, self is always applied to the class that has that declaration, not necessarily the child class. Hmm… that reads weird, let’s make an…
PHP: Unexpected behavior when using unset() on class properties
When you unset a non-dynamic class property you apparently enter a weird limbo state. Take the following simple anonymous class: //Simple anonymous class, nothing to special $c = new class { public $alpha = ‘alpha’; }; Perform a property exists test and show the value: //Do we have the property? echo…
Windows command line: assoc and ftype
I never knew these commands even existed, I always just want to the registry. I wonder which versions of Windows they shipped with, I only have 10 available to test here. assoc Displays or modifies file extension associations ASSOC [.ext[=[fileType]]] .ext Specifies the file extension to associate the file type…
Have bash remember your SSH private key’s password for the current session
(wow, that was a long title) ssh-agent bash ssh-add ~/.ssh/id_rsa EDIT Since I come here every day, here’s an updated version: eval $(ssh-agent -s) ssh-add ~/.ssh/id_ed25519
Composer and private GitHub repos
I fought this one for a while today. There’s lots of documentation out there for using Composer with private repos and I got everything to work except getting the autoloader wired up. What finally worked for me was setting “no-api”: true in the repositories key. { “repositories”: [ { “type”:…
Optimize composer’s autoloader
Most people write really simple autoloaders for their PHP projects that look at a class or namespace prefix, perform a file_exists and finally require_once the file. Something like: //Register an autoloader for our plugin’s actual code spl_autoload_register( function ( $class ) { //PSR-4 compliant autoloader //See http://www.php-fig.org/psr/psr-4/ $prefixes = array(…
Firefox “Containers”
As of Firefox version 50 (version 52 is the current one) you can now open tabs in different “contexts” such as “work”, “personal” or “banking”. These “containers” as Firefox calls them are each isolated from each other which means that things like cookies aren’t shared between them. This means that…
strcspn
Going on 10 years of PHP programming and I’m still finding functions that I never knew about. Today it was strcspn which is one of those functions that essentially maps directly to a C counterpart. int strcspn ( string $subject , string $mask [, int $start [, int $length ]] ) The formal description…
Yahoo search result – CCC in front of page titles
In Yahoo’s search result some of our page titles were being prefixed the “C C C” which, of course, was really weird. Charlie figured this one out. My money was on some corrupt HTML tag that was trying to set a color to hex #CCC but that wasn’t right. Let me show…