homebrew-core/Formula/php-code-sniffer.rb
2019-11-06 22:22:30 -05:00

37 lines
1.2 KiB
Ruby

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.5.2/phpcs.phar"
sha256 "15ad1fe73b3e972f666bf4d0e9b51548d4b50f780c9cf0c64999c78c9a4e644f"
bottle :unneeded
resource "phpcbf.phar" do
url "https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.5.2/phpcbf.phar"
sha256 "a632465994bb5e17de8722c855c539a45e6e6e1785caf644820144436afd167e"
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
<?php
/**
* PHP version 5
*
* @category Homebrew
* @package Homebrew_Test
* @author Homebrew <do.not@email.me>
* @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