homebrew-core/Formula/phplint.rb
JCount 7249a9769f phplint: move to Formula directory (#26431)
Fix the case of the "Formula" parent directory so that the formula
is tracked correctly on case-insensitive filesystems.
2018-04-11 06:40:50 -07:00

60 lines
1.7 KiB
Ruby

class Phplint < Formula
desc "Validator and documentator for PHP 5 and 7 programs"
homepage "http://www.icosaedro.it/phplint/"
url "http://www.icosaedro.it/phplint/phplint-3.0_20160307.tar.gz"
version "3.0-20160307"
sha256 "7a361166d1a6de707e6728828a6002a6de69be886501853344601ab1da922e7b"
bottle :unneeded
depends_on "php@7.1"
def install
inreplace "php", "/opt/php/bin/php", Formula["php@7.1"].opt_bin/"php"
libexec.install "modules", "php", "phpl", "stdlib", "utils"
bin.install_symlink libexec/"phpl"
end
test do
(testpath/"Email.php").write <<~EOS
<?php
declare(strict_types=1);
final class Email
{
private $email;
private function __construct(string $email)
{
$this->ensureIsValidEmail($email);
$this->email = $email;
}
public static function fromString(string $email): self
{
return new self($email);
}
public function __toString(): string
{
return $this->email;
}
private function ensureIsValidEmail(string $email): void
{
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
throw new InvalidArgumentException(
sprintf(
'"%s" is not a valid email address',
$email
)
);
}
}
}
EOS
output = shell_output("#{bin}/phpl Email.php", 1)
assert_match "Overall test results: 20 errors, 0 warnings.", output
end
end