Psalm – static analysis of PHP

Once every blue moon, I dive into Github repositories to check for something useful for my everyday routines.

This time, I stumbled upon Psalm from Vimeo. 

Psalm is designed to understand that complexity, allowing it to quickly find common programmer errors like null references and misspelled variable names.

vimeo Psalm documentation

I’ve been using phpstan for basic code static analysis for a while. I was running it with various rule levels, depending on the complexity of the codebase.

So far, benchmarking an output from both varies on the same codebase. Psalm managed to find more inconsistencies in the code – looks like it’s worth giving a shot.

Chronos: CakePHP replacement for carbon

Chronos is a drop-in library replacement for nesbot/carbon.

It provides immutable date/datetime objects. Immutable objects help us to ensure, that DateTime objects aren’t accidentally modified.

require 'vendor/autoload.php';
use Cake\Chronos\Chronos;
printf("Now: %s", Chronos::now());

WHMCS Addons: Domain Blocker

After few trials, I finally decided to publish some information on a small add-on I’ve been working on a month ago for WHMCS platform.

Domain blocker settings panel

Domain Blocker add-on emerged from attempts of cutting down the number of phishing domain registrations, that’s been received on daily basis for the last couple of months.

Domain Blocker addon logs

It uses CartValidation hooks that prevent any domain registrations that use “offensive”/”blacklisted” words, and tiny eye-candy for the backend with Twitter Bootstrap v2. Unfortunately, Bootstrap v3 everts the admin page with  style overwrites, thus it’ll be used only when WHMCS reaches 6.x version. Of course, any feedback, bugs spotted will be highly appreciated on GitHub issue tracker.

Cassandra at Github: integration

John Nunemaker on implementation of Analytics at Github using Cassandra:

The collector became a Rails app with one purpose – to receive events and queue them in Kestrel, which I used on Gauges.

The processor pulled from the queue and stored the raw data in Cassandra. The other component of processing (Hadoop) then iterated the raw data on intervals and turned it into aggregated “indexes”.

The reporter became a Rails app with one purpose as well, to receive API requests from github.com and read the data required to fulfil the request from Cassandra.

GitHub: closing issues via commit messages

If anyone missed it (like I did), it’s worth noting due to my ultimate laziness:

When you enter “Fixes #45” into a commit message, issue #45 is closed once that commit is merged into your default branch. If the bug isn’t fixed in your default branch, the issue remains open. Once the commit with the fix is merged into your default branch, the issue is automatically closed.

If you make a commit in a non-default branch with the “Fixes #33” syntax, the issue is referenced with a tooltip.

You can use any of the following keywords to close an issue via commit message:

  • close
  • closes
  • closed
  • fixes
  • fixed
  • resolve
  • resolves
  • resolved