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

38 lines
1.0 KiB
Ruby

class PhpCsFixer < Formula
desc "Tool to automatically fix PHP coding standards issues"
homepage "https://cs.symfony.com/"
# Bump to php 8.2 on the next release, if possible.
url "https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v3.13.1/php-cs-fixer.phar"
sha256 "e1b42b0a3b9a58de036ecd6d924e26d56c526f9d74b9eec6e7d1c0fa0439db29"
license "MIT"
bottle do
sha256 cellar: :any_skip_relocation, all: "14cbefb5201f4ada0a790d46c9febf5943b9ff7a9e1f1eaeb41d9d7479d1c62a"
end
depends_on "php@8.1"
def install
libexec.install "php-cs-fixer.phar"
(bin/"php-cs-fixer").write <<~EOS
#!#{Formula["php@8.1"].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