Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2020/02/20/phpstorm-warn-symfony-dump #8

Open
romaricdrigon opened this issue Feb 21, 2020 · 3 comments
Open

2020/02/20/phpstorm-warn-symfony-dump #8

romaricdrigon opened this issue Feb 21, 2020 · 3 comments

Comments

@romaricdrigon
Copy link
Owner

Please comment below!
Comments will automatically be published on the blog, too.

@ktherage
Copy link

I usually put a precommit hook checking that kind of things and disallowing pushing.

Here's the hook :

#!/usr/bin/env bash
LC_ALL=C
​
# blacklist check
echo "Checking blacklisted words additions ..."
currentBranch=$(git rev-parse --abbrev-ref HEAD)
searchBlacklistedWords=$(git diff --diff-filter=ACMRT origin/$currentBranch | egrep '^\+' | egrep '(@wip|print\s{1}last|\s{1}dd\(|\s{1}dump\(|\s{1}var_dump\(|\s{1}exit|\s{1}die)+')
hasBlacklistedWord=$(echo "$searchBlacklistedWords" | tr -d '[:space:] ' | wc -w)if [[ $hasBlacklistedWord > 0 ]]; then
	echo "Blacklisted words were found ! Details :"
	echo "$searchBlacklistedWords"
	exit 1
fi
echo "Great job! No blacklisted words were found !"

@martijn80
Copy link

Awesome tips. Cheers both!

@nclavaud
Copy link

If you are using PHP-CS-Fixer, another option would be to use this (risky) fixer that removes all calls to dump() and other debug statements:
https://github.com/akovalyov/DebugStatementsFixers

I accidentally pushed a dump() statement to production once, and this fixer now runs in the CI pipeline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants