aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-registry/index/phpstan/init.lua
blob: 60395e75524c9253c14a92ee04c7039108c2310c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
local Pkg = require "mason-core.package"
local _ = require "mason-core.functional"
local github = require "mason-core.managers.github"
local path = require "mason-core.path"
local platform = require "mason-core.platform"
local std = require "mason-core.managers.std"

return Pkg.new {
    name = "phpstan",
    desc = _.dedent [[
        PHP Static Analysis Tool - discover bugs in your code without running it!
    ]],
    homepage = "https://github.com/phpstan/phpstan",
    languages = { Pkg.Lang.PHP },
    categories = { Pkg.Cat.Linter },
    ---@async
    ---@param ctx InstallContext
    install = function(ctx)
        github
            .download_release_file({
                repo = "phpstan/phpstan",
                asset_file = "phpstan.phar",
                out_file = platform.is.win and "phpstan.phar" or "phpstan",
            })
            .with_receipt()
        platform.when {
            unix = function()
                std.chmod("+x", { "phpstan" })
                ctx:link_bin("phpstan", "phpstan")
            end,
            win = function()
                ctx:link_bin("phpstan", ctx:write_php_exec_wrapper("phpstan", "phpstan.phar"))
            end,
        }
    end,
}