Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added tool for scanning for global NS access

- Tool scans files to find "\Zend" in lines that are not part of comments.
  At time of writing, matches 1550 files (of 2568) in the ZF2 library. :-(
  • Loading branch information...
commit b1bca7e5f9e81a02610804da85f9c0fcf2d8c4ea 1 parent 1935509
Matthew Weier O'Phinney authored
Showing with 37 additions and 0 deletions.
  1. +37 −0 zf-utils/bin/scanForNSSeparators.php
37 zf-utils/bin/scanForNSSeparators.php
View
@@ -0,0 +1,37 @@
+<?php
+/**
+ * Simple script to scan PHP files for the string "\Zend" *not* occurring in a
+ * commented line.
+ */
+
+$dir = new RecursiveDirectoryIterator('/home/matthew/git/zf-standard/library/Zend');
+$found = 0;
+$scanned = 0;
+foreach (new RecursiveIteratorIterator($dir) as $file) {
+ if (!$file->isFile()) {
+ continue;
+ }
+
+ $path = $file->getRealPath();
+ if ('.php' != substr($path, -4)) {
+ continue;
+ }
+
+ ++$scanned;
+ $contents = file_get_contents($path);
+ $lines = preg_split('/(\r\n|\r|\n)/', $contents);
+ foreach ($lines as $line) {
+ if (strstr($line, '\\Zend')) {
+ if (preg_match('#^\s*(/\*)#', $line)) {
+ // It's a comment; ignore
+ continue;
+ }
+
+ // Otherwise, we found a match; echo the path and end the loop
+ ++$found;
+ echo $path, "\n";
+ break;
+ }
+ }
+}
+printf("Scanned %d files; matched %d\n", $scanned, $found);
Please sign in to comment.
Something went wrong with that request. Please try again.