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.3.1/phpcs.phar" sha256 "5ce1bc0dfead797a02efdb0b01f99fc4b5bb4ef42757286e648b2364b273814f" bottle :unneeded resource "phpcbf.phar" do url "https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.3.1/phpcbf.phar" sha256 "353ec2717ae043917308de7c0dae4805356129c6df9638e0f7daaf4c3c82e560" 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