1{ mkDerivation, fetchurl, makeWrapper, lib, php }:
2let
3 pname = "phpstan";
4 version = "1.8.6";
5in
6mkDerivation {
7 inherit pname version;
8
9 src = fetchurl {
10 url = "https://github.com/phpstan/phpstan/releases/download/${version}/phpstan.phar";
11 sha256 = "sha256-8scUd8BT6u9rqBPoaXozkn6H9PIWF/MWNWT9y8RwPkg=";
12 };
13
14 dontUnpack = true;
15
16 nativeBuildInputs = [ makeWrapper ];
17
18 installPhase = ''
19 runHook preInstall
20 mkdir -p $out/bin
21 install -D $src $out/libexec/phpstan/phpstan.phar
22 makeWrapper ${php}/bin/php $out/bin/phpstan \
23 --add-flags "$out/libexec/phpstan/phpstan.phar"
24 runHook postInstall
25 '';
26
27 meta = with lib; {
28 description = "PHP Static Analysis Tool";
29 longDescription = ''
30 PHPStan focuses on finding errors in your code without actually
31 running it. It catches whole classes of bugs even before you write
32 tests for the code. It moves PHP closer to compiled languages in the
33 sense that the correctness of each line of the code can be checked
34 before you run the actual line.
35 '';
36 license = licenses.mit;
37 homepage = "https://github.com/phpstan/phpstan";
38 maintainers = teams.php.members;
39 };
40}