MonthOctober 2014

Class Ando_Regex for PHP

EDIT: https://github.com/aercolino/ando-php

This is an update on my Regex class of some days ago.

{[ .class-regex | 1.hilite(=php=) ]}

Now with a bunch of tests.

{[ .tests-regex | 1.hilite(=php=) ]}

Screen Shot 2014-10-29 at 3.27.45

(previous permalink: class-regex-for-php)

Class Ando_Function for PHP

EDIT: https://github.com/aercolino/ando-php

This is a simple class for creating generic callbacks in PHP. There are a couple of reasons for using this class instead of the usual ´array( $container, $function )´ method.

First, the usual method doesn’t allow you to run the called code with more arguments than those provided by the calling code.

Second, this class resolves to the usual method when no extra arguments are provided, thus making it transparent at run time. This could seem useless, but, for free, we get much easier to spot callback calling points.

{[ .class-func | 1.hilite(=php=) ]}

Here are some tests.

{[ .tests | 1.hilite(=php=) ]}

Screen Shot 2014-10-28 at 16.53.43

(previous permalink: class-func-for-php)

How to autocomplete PHPUnit in VVV using PHPStorm 8

First install phpunit.phar locally:

$ brew update
Updated Homebrew from b1001942 to 3a44ae38.
...

$ brew install phpunit
==> Installing phpunit from homebrew/homebrew-php
==> Downloading https://phar.phpunit.de/phpunit-4.3.4.phar
######################################################################## 100,0%
🍺  /usr/local/Cellar/phpunit/4.3.4: 3 files, 3,2M, built in 3 seconds

Then right-click on the External Libraries entry in the Project pane and choose Configure PHP include paths…

Then add an include path to the folder where phpunit.phar is installed:

Screen Shot 2014-10-27 at 1.11.25

And finally you get all completions:

Screen Shot 2014-10-27 at 1.18.02

 

How to run WordPress tests in VVV using PHPStorm 8

EDIT: You might also be interested in:
How to run WordPress tests in VVV using WP-CLI and PHPStorm 8.


I’ve been busy all day trying to make this work, and at last I got it.

(1) Start the virtual server: ´$ vagrant up´.

(2) Access PHPStorm preferences, look for PHP and select the leftmost PHP tab.

(3) On the right pane, at the right of the Interpreter select box, click on […].

(4) At the top of the Interpreters pop up, click on [+], and select [Remote…].

(5) On the Configure Remote PHP Interpreter pop up, select Vagrant.

(6) After connecting, click on [OK].

(7) When it stops doing stuff, rename the interpreter. Then click on [OK].

(8) On the PHP pane again, above the the Interpreter select box, select the PHP language level, then click on [Apply] and on [OK].

(9) Add a Remote Interpreter for PHPUnit, pointing to the VVV server like this:

Screen Shot 2014-10-26 at 22.18.06

(10) Create a Run/Debug configuration for PHPUnit like this:

Screen Shot 2014-10-26 at 21.49.06

Probably you will also need to restart PHPStorm.

I really wanted to get through it to be able to debug tests later, but to just run them all it’s not very convenient. It takes double the time. 15 minutes from the command line, 30 minutes from PHPStorm!!

Screen Shot 2014-10-26 at 22.25.34

Class RegularExpression for PHP

UPDATE

This is a small class for handling Regular Expressions in PHP. I often have to use backreferences and it’s very cumbersome to compose simple expressions with them into more complex ones, because I have to manually count all capturing groups many times in a row. This class basically solves that issue for me.

{[ .class | 1.hilite(=php=) ]}

 

© 2017 Notes Log

Theme by Anders NorenUp ↑