Created
March 20, 2011 00:12
-
-
Save lstrojny/877933 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env php | |
<?php | |
if ($_SERVER['argc'] != 2) { | |
printf("%s: Converts assertType() into assertInternalType() or assertInstanceOf()\n\n", basename(__FILE__)); | |
printf("Usage: %s <tests directory>\n", basename(__FILE__)); | |
exit(11); | |
} | |
$directories = new RegexIterator( | |
new RecursiveIteratorIterator( | |
new RecursiveDirectoryIterator($_SERVER['argv'][1]) | |
), | |
'/^.*test(case)?\.php$/i' | |
); | |
foreach ($directories as $file) { | |
$contents = file_get_contents($file->getPathName()); | |
$contents = preg_replace( | |
'/assertType\s*\((\s*["\'](string|integer|float|array|object|resource))/im', | |
'assertInternalType(\1', | |
$contents | |
); | |
$contents = preg_replace( | |
"/assertType/", | |
"assertInstanceOf", | |
$contents | |
); | |
file_put_contents($file->getPathName(), $contents); | |
} |
Added "resource" to the list of internal types
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Removed the u modifier to do no harm to those without unicode enabled PCRE