homebrew-core/Formula/php-code-sniffer.rb

44 lines
1.4 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.6.2/phpcs.phar"
sha256 "c0832cdce3e419c337011640ddebd08b7daac32344250ac7cfbc799309506f77"
license "BSD-3-Clause"
revision 1
bottle do
sha256 cellar: :any_skip_relocation, all: "1c388b007f52b91ad254adf7621a613946e0d64203e41946e34d00b19a5bc604"
end
depends_on "php"
resource "phpcbf.phar" do
url "https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.6.2/phpcbf.phar"
sha256 "28d74aaaa7ad251c4ed23481e7fa18b755450ee57872d22be0ecb8fe21f50dc8"
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