diff --git a/.gitignore b/.gitignore index 2991481..b1d0fca 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ *.sublime-workspace /reports/*.txt /reports/*.md +vendor +composer.lock diff --git a/README.md b/README.md index 453e107..7e04fd4 100644 --- a/README.md +++ b/README.md @@ -22,23 +22,23 @@ First, start by downloading or cloning this repository. It does not need to be To begin, type on the command line: - php mar.php + php bin/mar.php This will produce a list of available arguments and switches. Typical usage would appear as: - php mar.php -f="/path/to/file/example.php" + php bin/mar.php -f="/path/to/file/example.php" Or: - php mar.php -f="/path/to/folder/example/" + php bin/mar.php -f="/path/to/folder/example/" This would run against the example file or folder and save the resulting report into a reports folder inside the php7mar folder. When referencing the file or folder to run against it is recommend to use a fully qualified path. Relative paths are supported, but will be relative to the location of the php7mar folder. Give a try, use the included `testcases.php` to generate a report: - php mar.php -f="testcases.php" + php bin/mar.php -f="testcases.php" ##Available Options: **-f** @@ -77,4 +77,4 @@ Critical tests look for issues that will cause broken code, compilation errors, Nuance tests look for issues that might cause silent underisable code behavior. These tests can report many false positives as they can not determine the intent of the code being checked. ##Syntax -A basic command line based syntax checker that checks all files for standard syntax issues. This is useful for double checking work after making many mass find and replace operations. Please note that syntax checking adds a significant increase to processing time especially for large code bases. To run without syntax checking use the -t option and omit syntax; -t="critical,nuance" \ No newline at end of file +A basic command line based syntax checker that checks all files for standard syntax issues. This is useful for double checking work after making many mass find and replace operations. Please note that syntax checking adds a significant increase to processing time especially for large code bases. To run without syntax checking use the -t option and omit syntax; -t="critical,nuance" diff --git a/bin/mar.php b/bin/mar.php new file mode 100644 index 0000000..7bb2519 --- /dev/null +++ b/bin/mar.php @@ -0,0 +1,22 @@ +#!/usr/bin/env php +=5.4.0" - } + "name": "alexia/php7mar", + "type": "project", + "description": "PHP 7 MAR, or just \"php7mar\", is a command line utility to generate reports on existing PHP 5 code to assist developers in porting their code quickly to PHP 7.", + "keywords": [ + "php7", + "php5", + "migration", + "porting" + ], + "homepage": "https://github.com/Alexia/php7mar", + "license": "GPL-3.0", + "authors": [ + { + "name": "Alexia E. Smith", + "email": "washuu@gmail.com", + "role": "Developer" + } + ], + "require": { + "php": ">=5.4.0" + }, + + "autoload": { + "psr-4": { + "Alexia\\Mar\\": "src" + } + } } diff --git a/classes/options.php b/src/Option/options.php similarity index 99% rename from classes/options.php rename to src/Option/options.php index 90b35b3..be30914 100644 --- a/classes/options.php +++ b/src/Option/options.php @@ -8,7 +8,7 @@ * @link https://github.com/Alexia/php7mar */ -namespace mar; +namespace Alexia\Mar\Option; class options { /** diff --git a/classes/reporter.php b/src/Reporter/reporter.php similarity index 97% rename from classes/reporter.php rename to src/Reporter/reporter.php index d593ee2..1ac3ea2 100644 --- a/classes/reporter.php +++ b/src/Reporter/reporter.php @@ -8,7 +8,9 @@ * @link https://github.com/Alexia/php7mar */ -namespace mar; +namespace Alexia\Mar\Reporter; + +use Alexia\Mar\mar; class reporter { /** @@ -69,7 +71,7 @@ public function __construct($projectPath, $reportFolder = null) { } $this->projectPath = $projectPath; - $reportFolder = main::getRealPath($reportFolder); + $reportFolder = mar::getRealPath($reportFolder); if ($reportFolder !== false) { $this->reportFolder = $reportFolder; } else { @@ -171,4 +173,4 @@ public function onShutdown() { fclose($this->file); } } -?> \ No newline at end of file +?> diff --git a/classes/scanner.php b/src/Scanner/scanner.php similarity index 98% rename from classes/scanner.php rename to src/Scanner/scanner.php index 27dfe33..22526cb 100644 --- a/classes/scanner.php +++ b/src/Scanner/scanner.php @@ -8,7 +8,7 @@ * @link https://github.com/Alexia/php7mar */ -namespace mar; +namespace Alexia\Mar\Scanner; class scanner { /** @@ -101,4 +101,4 @@ public function getCurrentFilePath() { return current($this->files); } } -?> \ No newline at end of file +?> diff --git a/classes/tests/critical.php b/src/Tester/Type/critical.php similarity index 99% rename from classes/tests/critical.php rename to src/Tester/Type/critical.php index e60f9d5..0c52ce4 100644 --- a/classes/tests/critical.php +++ b/src/Tester/Type/critical.php @@ -8,7 +8,7 @@ * @link https://github.com/Alexia/php7mar */ -namespace mar\tests; +namespace Alexia\Mar\Tester\Type; class critical { /** @@ -117,4 +117,4 @@ public function _deprecatedFunctions($line) { return false; } } -?> \ No newline at end of file +?> diff --git a/classes/tests/nuance.php b/src/Tester/Type/nuance.php similarity index 98% rename from classes/tests/nuance.php rename to src/Tester/Type/nuance.php index e9dda99..d87bb68 100644 --- a/classes/tests/nuance.php +++ b/src/Tester/Type/nuance.php @@ -8,7 +8,7 @@ * @link https://github.com/Alexia/php7mar */ -namespace mar\tests; +namespace Alexia\Mar\Tester\Type; class nuance { /** @@ -164,4 +164,4 @@ public function _unicode($line) { return false; } } -?> \ No newline at end of file +?> diff --git a/classes/tests.php b/src/Tester/tests.php similarity index 97% rename from classes/tests.php rename to src/Tester/tests.php index 548781b..a54d052 100644 --- a/classes/tests.php +++ b/src/Tester/tests.php @@ -9,7 +9,7 @@ * @link https://github.com/Alexia/php7mar */ -namespace mar; +namespace Alexia\Mar\Tester; class tests { /** @@ -74,7 +74,7 @@ public function __construct($testTypes = []) { * @return string Test Class Name */ public function getTestClassName($testType) { - return "mar\\tests\\".$testType; + return "Alexia\\Mar\\Tester\\Type\\".$testType; } /** @@ -161,4 +161,4 @@ public function checkSyntax($filePath) { return $syntax; } } -?> \ No newline at end of file +?> diff --git a/mar.php b/src/mar.php similarity index 85% rename from mar.php rename to src/mar.php index c89e3b9..163f8d0 100644 --- a/mar.php +++ b/src/mar.php @@ -8,9 +8,14 @@ * @link https://github.com/Alexia/php7mar */ -namespace mar; +namespace Alexia\Mar; -class main { +use Alexia\Mar\Option\options; +use Alexia\Mar\Reporter\reporter; +use Alexia\Mar\Scanner\scanner; +use Alexia\Mar\Tester\tests; + +class mar { /** * Project File or Path * @@ -55,7 +60,6 @@ class main { public function __construct() { define('PHP7MAR_DIR', __DIR__); define('PHP7MAR_VERSION', '0.0.1'); - spl_autoload_register([$this, 'autoloader'], true, false); //Setup command line options/switches. $this->options = new options(); @@ -144,23 +148,6 @@ private function run() { $this->reporter->add("Processed {$totalLines} lines contained in {$totalFiles} files.", 0, 1); } - /** - * Autoloader - * - * @access public - * @param string Class name to load automatically. - * @return void - */ - static public function autoloader($className) { - $className = str_replace('mar\\', '', $className); - $file = PHP7MAR_DIR.DIRECTORY_SEPARATOR.'classes'.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $className).'.php'; - if (is_file($file)) { - require_once($file); - } else { - throw new \Exception(__CLASS__.": Class file for {$className} not found at {$file}."); - } - } - /** * Get a full real path name to a given path. * @@ -180,5 +167,5 @@ static public function getRealPath($path) { return false; } } -$mar = new \mar\main(); -?> \ No newline at end of file + +?>