homebrew-core/Formula/php-code-sniffer.rb
Oleksandr Turiak b5da0a4cd7 phpcs 3.3.2
2018-10-08 10:05:32 +02: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.3.2/phpcs.phar"
sha256 "692a281f40b0afa3120f25e195102d0d327efef5ef16ce18cb9e5731a45ee35a"
bottle :unneeded
resource "phpcbf.phar" do
url "https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.3.2/phpcbf.phar"
sha256 "c43e2e924bf28eb48f825df12a9031ad4a96bf2e2e609ce78ad2653ce969ace3"
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