Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/vendor
/composer.lock
.phpunit.result.cache
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: php
php:
- 8.0
- 7.4
- 7.1
- 7.0
- 5.6

install: composer install
script: php vendor/bin/phpunit
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
},
"autoload-dev": {
"psr-4": {
"PhpCsFixer\\Tests\\": "vendor/friendsofphp/php-cs-fixer/tests/"
"Drew\\RemoveDebugStatements\\Tests\\": "tests/"
}
},
"require": {
"friendsofphp/php-cs-fixer": "^2.0"
"php": "^7.1 || ^8.0",
"friendsofphp/php-cs-fixer": "^3.0"
},
"require-dev": {
"gecko-packages/gecko-php-unit": "^2.0 || ^3.0",
"phpunit/phpunit": "^4.5|^5|^6",
"satooshi/php-coveralls": "^1.0 || ^2.0"
"phpunit/phpunit": "^8.5",
"php-coveralls/php-coveralls": "^2.4"
}
}
13 changes: 8 additions & 5 deletions src/Dump.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use PhpCsFixer\AbstractFunctionReferenceFixer;
use PhpCsFixer\FixerDefinition\CodeSample;
use PhpCsFixer\FixerDefinition\FixerDefinition;
use PhpCsFixer\FixerDefinition\FixerDefinitionInterface;
use PhpCsFixer\Tokenizer\Tokens;

/**
Expand All @@ -20,34 +21,36 @@ final class Dump extends AbstractFunctionReferenceFixer
/**
* {@inheritdoc}
*/
public function isCandidate(Tokens $tokens)
public function isCandidate(Tokens $tokens): bool
{
return $tokens->isTokenKindFound(T_STRING);
}

/**
* {@inheritdoc}
*/
public function getName()
public function getName(): string
{
return 'RemoveDebugStatements/dump';
}

/**
* {@inheritdoc}
*/
public function getDefinition()
public function getDefinition(): FixerDefinitionInterface
{
return new FixerDefinition(
'Removes dump/var_dump statements, which shouldn\'t be in production ever.',
array(new CodeSample("<?php\nvar_dump(false);"))
array(new CodeSample("<?php\nvar_dump(false);\n")),
null,
'Risky when functions ' . implode(', ', $this->functions) . ' are redefined.'
);
}

/**
* {@inheritdoc}
*/
protected function applyFix(\SplFileInfo $file, Tokens $tokens)
protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
{
foreach ($this->functions as $function) {
$currIndex = 0;
Expand Down
Loading