Posts tagged php

Using PHP_CodeSniffer for automated code migrations

PHP_CodeSniffer is a command line tool allowing to check php, js and css. The main use case is to check code styles like the popular PSR-2. Beside checking coding styles, some communities are already using this tool for further checks like direct access to global variables like $_POST instead of using the provided API, e.g. take a look at Magento PHP_CodeSniffer Coding Standard. Also there is a standard to check compatibility of the code with PHP versions.

Beside this use cases and huge benefits, there is another use case: automated code migrations that can be achieved using PHP_CodeSniffer. In this blog post I will provide the necessary basics and an example how to auto migrate your PHP code using PHP_CodeSniffer.

Read more ...

Sorting a multidimensional array with array_multisort

We first need the array we want to sort (here called arrayToSort). Secondly we need a second array containing the values we want to sort. In this case our names. I called the array arrayWithNamesToSort.

Read more ...