for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace LeKoala\DevToolkit\Helpers;
/**
* Helper class to find spaces in your current scope that break everything in ajax requests...
*/
class EmptySpaceFinder
{
const REGEX_OPENING = '/^[\s]+<\?php/';
const REGEX_CLOSING = '/\?>[\s]+$/';
public static function findSpacesInFiles($files)
echo '<pre>';
echo "Finding opened or closed tags ...\n\n";
$openings = [];
$closings = [];
foreach ($files as $file) {
$content = file_get_contents($file);
$matches = null;
preg_match_all(self::REGEX_OPENING, $content, $matches);
if (!empty($matches[0])) {
$openings[] = $file;
}
preg_match_all(self::REGEX_CLOSING, $content, $matches);
$closings[] = $file;
if (!empty($openings)) {
echo "Files with opening tags that may need fixing\n";
foreach ($openings as $file) {
echo "$file\n";
echo "***\n";
if (!empty($closings)) {
echo "Files with closing tags that may need fixing\n";
foreach ($closings as $file) {
echo "\nDone!";
echo '</pre>';
die();
exit
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.
public static function findSpacesInIncludedFiles()
$files = get_included_files();
self::findSpacesInFiles($files);
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.