From 72e3c10bd1a70edc8aaeebee5a623442f4aad9fa Mon Sep 17 00:00:00 2001 From: Umut Isik Date: Tue, 11 Dec 2018 14:59:21 +0300 Subject: [PATCH 01/27] Add --custom-function parameter to add custom functions to the list of functions to be checked --- README.md | 1 + src/Settings.php | 16 ++++++++++++++-- var-dump-check.php | 28 +++++++++++++++------------- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index db02abe..f40f4ed 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ Options for run - `--doctrine` - check dump: `Doctrine::dump`, `\Doctrine\Common\Util\Debug::dump` - `--symfony` - check dump: `dump`, `VarDumper::dump`, `VarDumper::setHandler` - `--laravel` - check dump: `dd`, `dump` +- `--custom-function` - comma separated custom function name(s) to check like "pre_echo" - `--no-colors` - disable colors from output - `--exclude folder/` - exclude *folder/* from check - `--extensions php,phpt,php7` - map file extensions for check diff --git a/src/Settings.php b/src/Settings.php index b7e7dbb..0074ecf 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -70,8 +70,9 @@ class Settings */ public static function parseArguments(array $arguments) { - $arguments = new ArrayIterator(array_slice($arguments, 1)); - $setting = new self; + $arguments = new ArrayIterator(array_slice($arguments, 1)); + $setting = new self; + $customFunctions = array(); foreach ($arguments as $argument) { if ($argument{0} !== '-') { @@ -120,6 +121,10 @@ public static function parseArguments(array $arguments) $setting->functionsToCheck[] = self::LARAVEL_DUMP; break; + case '--custom-function': + $customFunctions = array_map('trim', explode(',', $arguments->getNext())); + break; + case '--doctrine': $setting->functionsToCheck[] = self::DOCTRINE_DUMP; $setting->functionsToCheck[] = self::DOCTRINE_DUMP_2; @@ -131,6 +136,13 @@ public static function parseArguments(array $arguments) } } $setting->functionsToCheck = array_unique($setting->functionsToCheck); + + // Any custom function is given + if (count($customFunctions) > 0) { + $setting->functionsToCheck = array_merge($setting->functionsToCheck, $customFunctions); + $setting->functionsToCheck = array_unique($setting->functionsToCheck); + } + return $setting; } diff --git a/var-dump-check.php b/var-dump-check.php index 1ce52e2..357cd32 100644 --- a/var-dump-check.php +++ b/var-dump-check.php @@ -15,19 +15,21 @@ function showOptions() { ?> Options: - --tracy Enable support for Tracy (Debugger::dump) - --zend Enable support for Zend (Zend_Debug::dump and \Zend\Debug\Debug::dump) - --ladybug Enable support for Ladybug (ladybug_dump, ladybug_dump_die, ld, ldd) - --symfony Enable support for Symfony2 (dump, VarDumper::dump, VarDumper::setHandler) - --doctrine Enable support for Doctrine (Doctrine::dump, \Doctrine\Common\Util\Debug::dump) - --laravel Enable support for Laravel (dd, dump) - --extensions Check only files with selected extensions separated by comma - (default: php, php3, php4, php5, phtml) - --exclude Exclude directory. If you want exclude multiple directory, use - multiple exclude parameters. - --no-colors Disable colors in console output. - -V, --version Show version. - -h, --help Print this help. + --tracy Enable support for Tracy (Debugger::dump) + --zend Enable support for Zend (Zend_Debug::dump and \Zend\Debug\Debug::dump) + --ladybug Enable support for Ladybug (ladybug_dump, ladybug_dump_die, ld, ldd) + --symfony Enable support for Symfony2 (dump, VarDumper::dump, VarDumper::setHandler) + --doctrine Enable support for Doctrine (Doctrine::dump, \Doctrine\Common\Util\Debug::dump) + --laravel Enable support for Laravel (dd, dump) + --custom-function Comma separated custom function name(s) to check like "pre_echo". + The functions are appended to the array of functions to be checked + --extensions Check only files with selected extensions separated by comma + (default: php, php3, php4, php5, phtml) + --exclude Exclude directory. If you want exclude multiple directory, use + multiple exclude parameters. + --no-colors Disable colors in console output. + -V, --version Show version. + -h, --help Print this help. Date: Tue, 11 Dec 2018 15:15:42 +0300 Subject: [PATCH 02/27] Add test for custom function parameter and add .idea folder to gitignore --- .gitignore | 3 +- .../PhpVarDumpCheck/CustomFunctionTest.php | 65 +++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 tests/JakubOnderka/PhpVarDumpCheck/CustomFunctionTest.php diff --git a/.gitignore b/.gitignore index 94d6d75..3c401de 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /vendor/ -/composer.lock \ No newline at end of file +/composer.lock +.idea diff --git a/tests/JakubOnderka/PhpVarDumpCheck/CustomFunctionTest.php b/tests/JakubOnderka/PhpVarDumpCheck/CustomFunctionTest.php new file mode 100644 index 0000000..2d9370f --- /dev/null +++ b/tests/JakubOnderka/PhpVarDumpCheck/CustomFunctionTest.php @@ -0,0 +1,65 @@ +functionsToCheck = array_merge($settings->functionsToCheck, array( + 'functionName1' + )); + + $uut = new PhpVarDumpCheck\Checker($settings); + $content = <<check($content); + $this->assertCount(1, $result); + } + + + public function testCheck_multipleFunction() + { + $settings = new PhpVarDumpCheck\Settings(); + + $settings->functionsToCheck = array_merge($settings->functionsToCheck, array( + 'functionName1', + 'functionName2' + )); + + $uut = new PhpVarDumpCheck\Checker($settings); + + $content1 = <<check($content1); + $this->assertCount(1, $result); + + $result = $uut->check($content2); + $this->assertCount(1, $result); + + $result = $uut->check($content3); + $this->assertCount(2, $result); + } +} From a43368b975c99e7c998143a264fa29ef72dadfe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20I=C5=9F=C4=B1k?= Date: Sat, 5 Jan 2019 23:29:40 +0300 Subject: [PATCH 03/27] Revert the .idea folder --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3c401de..4fbb073 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ /vendor/ /composer.lock -.idea From 73dcc404a58d81f1dc25df7132b4caf1d6e312e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20I=C5=9F=C4=B1k?= Date: Sat, 5 Jan 2019 23:32:47 +0300 Subject: [PATCH 04/27] Implement the CR "Please use ` instead of " to match other parameters description" --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f40f4ed..9ea5562 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Options for run - `--doctrine` - check dump: `Doctrine::dump`, `\Doctrine\Common\Util\Debug::dump` - `--symfony` - check dump: `dump`, `VarDumper::dump`, `VarDumper::setHandler` - `--laravel` - check dump: `dd`, `dump` -- `--custom-function` - comma separated custom function name(s) to check like "pre_echo" +- `--custom-function` - comma separated custom function name(s) to check like `pre_echo` - `--no-colors` - disable colors from output - `--exclude folder/` - exclude *folder/* from check - `--extensions php,phpt,php7` - map file extensions for check From 5c74a7765bb67b7093ffa30435e5b75d15423db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20I=C5=9F=C4=B1k?= Date: Sat, 5 Jan 2019 23:41:44 +0300 Subject: [PATCH 05/27] Empty is used instead of count($customFunctions) > 0 --- src/Settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Settings.php b/src/Settings.php index 0074ecf..bffdd73 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -138,7 +138,7 @@ public static function parseArguments(array $arguments) $setting->functionsToCheck = array_unique($setting->functionsToCheck); // Any custom function is given - if (count($customFunctions) > 0) { + if (!empty($customFunctions)) { $setting->functionsToCheck = array_merge($setting->functionsToCheck, $customFunctions); $setting->functionsToCheck = array_unique($setting->functionsToCheck); } From 6e2a07205e3ca4c5dbcf3a0b2971117087b76695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20I=C5=9F=C4=B1k?= Date: Fri, 14 Aug 2020 17:51:28 +0300 Subject: [PATCH 06/27] Add test for none function founded Caused by the review message in the following link. https://github.com/php-parallel-lint/PHP-Var-Dump-Check/pull/6#discussion_r470564342 --- .../PhpVarDumpCheck/CustomFunctionTest.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/JakubOnderka/PhpVarDumpCheck/CustomFunctionTest.php b/tests/JakubOnderka/PhpVarDumpCheck/CustomFunctionTest.php index 2d9370f..75f1883 100644 --- a/tests/JakubOnderka/PhpVarDumpCheck/CustomFunctionTest.php +++ b/tests/JakubOnderka/PhpVarDumpCheck/CustomFunctionTest.php @@ -4,11 +4,25 @@ class CustomFunctionTest extends PHPUnit_Framework_TestCase { - public function __construct() + + public function testCheck_noDebugFunction() { + $settings = new PhpVarDumpCheck\Settings(); - } + $settings->functionsToCheck = array_merge($settings->functionsToCheck, array( + 'functionName1' + )); + $uut = new PhpVarDumpCheck\Checker($settings); + $content = <<check($content); + $this->assertCount(0, $result); + } public function testCheck_singleFunction() { From 38513d013464de93a3be4bdc05b4cc62b6bc67da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20I=C5=9F=C4=B1k?= Date: Fri, 14 Aug 2020 17:54:10 +0300 Subject: [PATCH 07/27] Remove horizontal align https://github.com/php-parallel-lint/PHP-Var-Dump-Check/pull/6#discussion_r470566935 --- src/Settings.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Settings.php b/src/Settings.php index 3f80de2..4aec3af 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -72,8 +72,8 @@ class Settings */ public static function parseArguments(array $arguments) { - $arguments = new ArrayIterator(array_slice($arguments, 1)); - $setting = new self; + $arguments = new ArrayIterator(array_slice($arguments, 1)); + $setting = new self; $customFunctions = array(); foreach ($arguments as $argument) { From 5495e3495ed2ca59fd821982b609502656437fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20I=C5=9F=C4=B1k?= Date: Fri, 14 Aug 2020 17:59:01 +0300 Subject: [PATCH 08/27] Remove unneccessary empty check https://github.com/php-parallel-lint/PHP-Var-Dump-Check/pull/6#discussion_r470562392 --- src/Settings.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Settings.php b/src/Settings.php index 4aec3af..8a61636 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -139,13 +139,10 @@ public static function parseArguments(array $arguments) } } } - $setting->functionsToCheck = array_unique($setting->functionsToCheck); - // Any custom function is given - if (!empty($customFunctions)) { - $setting->functionsToCheck = array_merge($setting->functionsToCheck, $customFunctions); - $setting->functionsToCheck = array_unique($setting->functionsToCheck); - } + // Merge if any custom function is given + $setting->functionsToCheck = array_merge($setting->functionsToCheck, $customFunctions); + $setting->functionsToCheck = array_unique($setting->functionsToCheck); return $setting; } From e537cda50e72f38c95c0b757539455c63acbd03a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20I=C5=9F=C4=B1k?= Date: Fri, 14 Aug 2020 18:57:57 +0300 Subject: [PATCH 09/27] Add the Symfony Vardumper dd() helper method introduced in 4.1 --- var-dump-check.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/var-dump-check.php b/var-dump-check.php index 566e999..8e18c63 100644 --- a/var-dump-check.php +++ b/var-dump-check.php @@ -18,11 +18,10 @@ function showOptions() { --tracy Enable support for Tracy (Debugger::dump) --zend Enable support for Zend (Zend_Debug::dump and \Zend\Debug\Debug::dump) --ladybug Enable support for Ladybug (ladybug_dump, ladybug_dump_die, ld, ldd) - --symfony Enable support for Symfony2 (dump, VarDumper::dump, VarDumper::setHandler) + --symfony Enable support for Symfony2 (dump, VarDumper::dump, VarDumper::setHandler, Vardumper::dd()) --doctrine Enable support for Doctrine (Doctrine::dump, \Doctrine\Common\Util\Debug::dump) --laravel Enable support for Laravel (dd, dump) --custom-function Comma separated custom function name(s) to check like "pre_echo". - The functions are appended to the array of functions to be checked --extensions Check only files with selected extensions separated by comma (default: php, php3, php4, php5, phtml) --exclude Exclude directory. If you want exclude multiple directory, use From 66a65a84197f76c5cf3cc435eb4640e0490c7963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Make=C5=A1?= Date: Wed, 12 Feb 2020 09:40:10 +0100 Subject: [PATCH 10/27] Changed package name - new organization From eee88577cf4fbd186b3381c4dd8945330ef2c9b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Make=C5=A1?= Date: Sun, 16 Feb 2020 17:47:33 +0100 Subject: [PATCH 11/27] Fixed Travis CI configuration From 417f9686098c45216350ecee68e3c5ff46c641fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Make=C5=A1?= Date: Sun, 15 Mar 2020 08:58:50 +0100 Subject: [PATCH 12/27] Added replace to composer for previous package From 95e01588302eb6527fd8bf5723b67d8b1bc1904c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Make=C5=A1?= Date: Sat, 25 Apr 2020 21:42:38 +0200 Subject: [PATCH 13/27] Added run CI with PHP 7.4 From f58fae35e7f157734103b5689a3437eb69fa49db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Make=C5=A1?= Date: Sat, 25 Apr 2020 21:47:08 +0200 Subject: [PATCH 14/27] Fixed vendor names in readme for install From 562b7aa209839d4cb20346760e976eb08caf39a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Make=C5=A1?= Date: Sat, 25 Apr 2020 21:49:03 +0200 Subject: [PATCH 15/27] Created version 0.4 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d69e9f..59dad14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +## [v0.4] - 2020-04-25 + ### Added - Added .gitattributes from [@reedy](https://github.com/reedy). From 5847d7e5870162abbba53d44bb7ffaab1f40ad77 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Mon, 27 Apr 2020 12:44:50 +0100 Subject: [PATCH 16/27] Create .gitattributes From a29a7eb4873e337464a57bb6b98461126e338608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Make=C5=A1?= Date: Thu, 14 May 2020 07:40:17 +0200 Subject: [PATCH 17/27] Added .gitattributes to changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59dad14..a08e8c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Added + +- Added .gitattributes from [@reedy](https://github.com/reedy). + ## [v0.4] - 2020-04-25 ### Added From f79cba3cc1bffafff3b53062d896064bd5759020 Mon Sep 17 00:00:00 2001 From: peter279k Date: Wed, 27 May 2020 00:19:45 +0800 Subject: [PATCH 18/27] Replace array syntax with short array syntax From f7886fdb859936e5e15886a78c7bb459aa07767f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Make=C5=A1?= Date: Wed, 27 May 2020 12:24:51 +0200 Subject: [PATCH 19/27] Added PHP array syntax to changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a08e8c4..4057656 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Added .gitattributes from [@reedy](https://github.com/reedy). +### Internal + +- Replaced array syntax with short array syntax from [@peter279k](https://github.com/peter279k). + ## [v0.4] - 2020-04-25 ### Added From d6cf4df9ffbff02500bec4a631142ee68fd75d9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Make=C5=A1?= Date: Wed, 27 May 2020 12:31:15 +0200 Subject: [PATCH 20/27] Added cleaning changes to changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4057656..f8f5e4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Internal - Replaced array syntax with short array syntax from [@peter279k](https://github.com/peter279k). +- Added EOF (end of file) for some PHP files from [@peter279k](https://github.com/peter279k). +- Removed $loader variable on bootstrap.php file because it's unused from [@peter279k](https://github.com/peter279k). +- To be compatible with future PHPUnit version, using the ^4.8.36 version at least from [@peter279k](https://github.com/peter279k). +- Changed namespace to PHPunit\Framework\TestCase class namesapce from [@peter279k](https://github.com/peter279k). ## [v0.4] - 2020-04-25 From e779ac48083b17ab935efb39ccacba981aa2aa5f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 28 Jun 2020 21:48:58 +0200 Subject: [PATCH 21/27] Composer: allow installation of more recent Parallel Lint Using the caret is the recommended manner of setting a version requirement. From 5941faee9119d9fdb02350c19e15d53a269b8fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Make=C5=A1?= Date: Fri, 14 Aug 2020 11:47:22 +0200 Subject: [PATCH 22/27] Added internal change to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8f5e4e..55887b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Removed $loader variable on bootstrap.php file because it's unused from [@peter279k](https://github.com/peter279k). - To be compatible with future PHPUnit version, using the ^4.8.36 version at least from [@peter279k](https://github.com/peter279k). - Changed namespace to PHPunit\Framework\TestCase class namesapce from [@peter279k](https://github.com/peter279k). +- Composer: allow installation of more recent Parallel Lint [#9](https://github.com/php-parallel-lint/PHP-Var-Dump-Check/pull/9) from [@jrfnl](https://github.com/jrfnl). ## [v0.4] - 2020-04-25 From 252cd39508c3441c8602ce36d2190a782e5ff9d6 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 28 Jun 2020 21:47:46 +0200 Subject: [PATCH 23/27] PHP 7.4: fix compatibility issue Array access using curly braces has been deprecated in PHP 7.4. Ref: https://www.php.net/manual/en/migration74.deprecated.php#migration74.deprecated.core.array-string-access-curly-brace From 0f7b9651044adf4076f0bfa2b97426b3a927c539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Make=C5=A1?= Date: Fri, 14 Aug 2020 11:50:41 +0200 Subject: [PATCH 24/27] Added fix for PHP 7.4 to changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55887b6..18952cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Added .gitattributes from [@reedy](https://github.com/reedy). +### Fixed + +- PHP 7.4: fix compatibility issue [#7](https://github.com/php-parallel-lint/PHP-Var-Dump-Check/pull/7) from [@jrfnl](https://github.com/jrfnl). + ### Internal - Replaced array syntax with short array syntax from [@peter279k](https://github.com/peter279k). From 52d9da77cad477c8bf57a6cf998075008781c58f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20I=C5=9F=C4=B1k?= Date: Fri, 14 Aug 2020 17:51:28 +0300 Subject: [PATCH 25/27] Add test for none function founded Caused by the review message in the following link. https://github.com/php-parallel-lint/PHP-Var-Dump-Check/pull/6#discussion_r470564342 From 6476f7b1b2ab0a05f11b89fc5f39de972f838862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20I=C5=9F=C4=B1k?= Date: Fri, 14 Aug 2020 17:54:10 +0300 Subject: [PATCH 26/27] Remove horizontal align https://github.com/php-parallel-lint/PHP-Var-Dump-Check/pull/6#discussion_r470566935 From 10fecd3cefd17b446f4d8af22effaa51b14d4180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Umut=20I=C5=9F=C4=B1k?= Date: Fri, 14 Aug 2020 17:59:01 +0300 Subject: [PATCH 27/27] Remove unneccessary empty check https://github.com/php-parallel-lint/PHP-Var-Dump-Check/pull/6#discussion_r470562392