Skip to content

Commit a5f606b

Browse files
authored
Merge pull request #28 from antograssiot/SF-vardumper-dd
Add the Symfony Vardumper dd() helper method introduced in 4.1
2 parents 1f62bf9 + 7b0fa5e commit a5f606b

File tree

4 files changed

+34
-4
lines changed

4 files changed

+34
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Options for run
4646
- `--tracy` - check dump: `dump`, `bdump`, `Debugger::dump`, `Debugger::barDump`
4747
- `--zend` - check dump: `Zend_Debug::dump`, `\Zend\Debug\Debug::dump`
4848
- `--doctrine` - check dump: `Doctrine::dump`, `\Doctrine\Common\Util\Debug::dump`
49-
- `--symfony` - check dump: `dump`, `VarDumper::dump`, `VarDumper::setHandler`
49+
- `--symfony` - check dump: `dump`, `VarDumper::dump`, `VarDumper::setHandler`, `VarDumper::dd`
5050
- `--laravel` - check dump: `dd`, `dump`
5151
- `--no-colors` - disable colors from output
5252
- `--exclude folder/` - exclude *folder/* from check

src/Settings.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class Settings
2323
SYMFONY_VARDUMPER_HANDLER = 'VarDumper::setHandler',
2424
SYMFONY_VARDUMPER_DUMP = 'VarDumper::dump',
2525
SYMFONY_VARDUMPER_DUMP_SHORTCUT = 'dump',
26+
SYMFONY_VARDUMPER_DD = 'VarDumper::dd',
27+
SYMFONY_VARDUMPER_DD_SHORTCUT = 'dd',
2628

2729
LARAVEL_DUMP_DD = 'dd',
2830
LARAVEL_DUMP = 'dump',
@@ -112,6 +114,8 @@ public static function parseArguments(array $arguments)
112114
case '--symfony':
113115
$setting->functionsToCheck[] = self::SYMFONY_VARDUMPER_DUMP;
114116
$setting->functionsToCheck[] = self::SYMFONY_VARDUMPER_DUMP_SHORTCUT;
117+
$setting->functionsToCheck[] = self::SYMFONY_VARDUMPER_DD;
118+
$setting->functionsToCheck[] = self::SYMFONY_VARDUMPER_DD_SHORTCUT;
115119
$setting->functionsToCheck[] = self::SYMFONY_VARDUMPER_HANDLER;
116120
break;
117121

tests/JakubOnderka/PhpVarDumpCheck/SymfonyTest.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public function __construct()
1414
PhpVarDumpCheck\Settings::SYMFONY_VARDUMPER_HANDLER,
1515
PhpVarDumpCheck\Settings::SYMFONY_VARDUMPER_DUMP,
1616
PhpVarDumpCheck\Settings::SYMFONY_VARDUMPER_DUMP_SHORTCUT,
17+
PhpVarDumpCheck\Settings::SYMFONY_VARDUMPER_DD,
18+
PhpVarDumpCheck\Settings::SYMFONY_VARDUMPER_DD_SHORTCUT,
1719
));
1820
$this->uut = new PhpVarDumpCheck\Checker($settings);
1921
}
@@ -29,6 +31,17 @@ public function testCheck_symfonyDebugDump()
2931
$this->assertCount(1, $result);
3032
}
3133

34+
public function testCheck_symfonyDD()
35+
{
36+
$content = <<<PHP
37+
<?php
38+
VarDumper::dd(\$var);
39+
PHP;
40+
$result = $this->uut->check($content);
41+
$this->assertCount(1, $result);
42+
}
43+
44+
3245
public function testCheck_symfonyDebugSetHandler()
3346
{
3447
$content = <<<PHP
@@ -63,18 +76,31 @@ public function testCheck_symfonyDebugShortcutDump()
6376
}
6477

6578

79+
public function testCheck_symfonyDDShortcut()
80+
{
81+
$content = <<<PHP
82+
<?php
83+
dd(\$var);
84+
PHP;
85+
$result = $this->uut->check($content);
86+
$this->assertCount(1, $result);
87+
}
88+
89+
6690
public function testCheck_symfonyDumpsWithNamespace()
6791
{
6892
$content = <<<PHP
6993
<?php
7094
\\dump(\$var);
7195
\\Symfony\\Component\\VarDumper\\VarDumper::dump(\$var);
96+
\\dd(\$var);
97+
\\Symfony\\Component\\VarDumper\\VarDumper::dd(\$var);
7298
\\Symfony\\Component\\VarDumper\\VarDumper::setHandler(\$var);
7399
\\Symfony\\Component\\VarDumper\\VarDumper::setHandler(function(){
74100
75101
});
76102
PHP;
77103
$result = $this->uut->check($content);
78-
$this->assertCount(4, $result);
104+
$this->assertCount(6, $result);
79105
}
80106
}

var-dump-check.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function showOptions() {
1818
--tracy Enable support for Tracy (Debugger::dump)
1919
--zend Enable support for Zend (Zend_Debug::dump and \Zend\Debug\Debug::dump)
2020
--ladybug Enable support for Ladybug (ladybug_dump, ladybug_dump_die, ld, ldd)
21-
--symfony Enable support for Symfony2 (dump, VarDumper::dump, VarDumper::setHandler)
21+
--symfony Enable support for Symfony2 (dump, VarDumper::dump, VarDumper::setHandler, Vardumper::dd())
2222
--doctrine Enable support for Doctrine (Doctrine::dump, \Doctrine\Common\Util\Debug::dump)
2323
--laravel Enable support for Laravel (dd, dump)
2424
--extensions Check only files with selected extensions separated by comma
@@ -87,4 +87,4 @@ function showOptions() {
8787
} catch (PhpVarDumpCheck\Exception\Exception $e) {
8888
fwrite(STDERR, $e->getMessage() . PHP_EOL);
8989
die(FAILED);
90-
}
90+
}

0 commit comments

Comments
 (0)