homebrew-core/Formula/php-cs-fixer.rb

37 lines
990 B
Ruby

class PhpCsFixer < Formula
desc "Tool to automatically fix PHP coding standards issues"
homepage "https://cs.symfony.com/"
url "https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v3.5.0/php-cs-fixer.phar"
sha256 "0c29d2f89e4ddf339cdc8634394e0f98a98cbd0c3afcee6eeb8b5332cff374ee"
license "MIT"
bottle do
sha256 cellar: :any_skip_relocation, all: "46199394d927b44bc298fe719f8e6f13da9e0f5fb5bc412d9617dba54352d326"
end
depends_on "php"
def install
libexec.install "php-cs-fixer.phar"
(bin/"php-cs-fixer").write <<~EOS
#!#{Formula["php"].opt_bin}/php
<?php require '#{libexec}/php-cs-fixer.phar';
EOS
end
test do
(testpath/"test.php").write <<~EOS
<?php $this->foo( 'homebrew rox' );
EOS
(testpath/"correct_test.php").write <<~EOS
<?php
$this->foo('homebrew rox');
EOS
system "#{bin}/php-cs-fixer", "fix", "test.php"
assert compare_file("test.php", "correct_test.php")
end
end