class PhpCodeSniffer < Formula desc "Check coding standards in PHP, JavaScript and CSS" homepage "https://github.com/squizlabs/PHP_CodeSniffer/" url "https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.4.1/phpcs.phar" sha256 "805e214829bb79139c1fa260c0fbce5e26a9178dec8d5d79b65c01af2b92fc1f" bottle :unneeded resource "phpcbf.phar" do url "https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.4.1/phpcbf.phar" sha256 "9bb55fe7bf231535e046d7711484d7d7c3d7b0b831ec4a8697aea6c1fed34e14" end def install bin.install "phpcs.phar" => "phpcs" resource("phpcbf.phar").stage { bin.install "phpcbf.phar" => "phpcbf" } end test do (testpath/"test.php").write <<~EOS * @license BSD Licence * @link https://brew.sh/ */ EOS assert_match /FOUND 13 ERRORS/, shell_output("#{bin}/phpcs --runtime-set ignore_errors_on_exit true test.php") assert_match /13 ERRORS WERE FIXED/, shell_output("#{bin}/phpcbf test.php", 1) system "#{bin}/phpcs", "test.php" end end