berry/extension-method-stub-generator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

berry/extension-method-stub-generator

Composer 安装命令:

composer require berry/extension-method-stub-generator

包简介

A composer plugin to generate berry extension method stubs

README 文档

README

A composer plugin to generate berry extension method stubs

How it works

This composer plugin will scan all your dependencies for a file called berry-method-extensions.json and generate stubs in your project to be used by your IDE and phpstan

How to create stubs

Here is an example we use at berry/htmx:

{
    "extensions": [
        {
            "namespace": "Berry\\Html",
            "class": [
                "HtmlTag",
                "HtmlVoidTag"
            ],
            "uses": [
                "Berry\\Htmx\\HxSwap",
                "Berry\\Htmx\\HxTarget"
            ],
            "methods": [
                {
                    "name": "hxGet",
                    "doc": "Issues a GET request to the specified URL",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string",
                            "name": "url"
                        }
                    ]
                },
                {
                    "name": "hxPost",
                    "doc": "Issues a POST request to the specified URL",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string",
                            "name": "url"
                        }
                    ]
                },
                {
                    "name": "hxPut",
                    "doc": "Issues a PUT request to the specified URL",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string",
                            "name": "url"
                        }
                    ]
                },
                {
                    "name": "hxPatch",
                    "doc": "Issues a PATCH request to the specified URL",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string",
                            "name": "url"
                        }
                    ]
                },
                {
                    "name": "hxDelete",
                    "doc": "Issues a DELETE request to the specified URL",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string",
                            "name": "url"
                        }
                    ]
                },
                {
                    "name": "hxBoost",
                    "doc": "Enables progressive enhancement",
                    "returns": "static",
                    "args": [
                        {
                            "type": "bool",
                            "name": "value"
                        }
                    ]
                },
                {
                    "name": "hxConfirm",
                    "doc": "Shows a confirm() dialog before issuing requests",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string",
                            "name": "message"
                        }
                    ]
                },
                {
                    "name": "hxDisable",
                    "doc": "Disables HTMX processing on this element and its children",
                    "returns": "static",
                    "args": []
                },
                {
                    "name": "hxEncoding",
                    "doc": "Changes encoding to multipart/form-data (\"multipart/form-data\")",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string",
                            "name": "type"
                        }
                    ]
                },
                {
                    "name": "hxExt",
                    "doc": "Extensions to include (comma-separated)",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string",
                            "name": "extensions"
                        }
                    ]
                },
                {
                    "name": "hxHistory",
                    "doc": "Prevents history snapshot for this element",
                    "returns": "static",
                    "args": [
                        {
                            "type": "bool",
                            "name": "history"
                        }
                    ]
                },
                {
                    "name": "hxInclude",
                    "doc": "Additional elements to include in requests",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string",
                            "name": "selector"
                        }
                    ]
                },
                {
                    "name": "hxIndicator",
                    "doc": "CSS selector for indicator element",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string",
                            "name": "selector"
                        }
                    ]
                },
                {
                    "name": "hxParams",
                    "doc": "Filters parameters sent with requests",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string",
                            "name": "filter"
                        }
                    ]
                },
                {
                    "name": "hxPreserve",
                    "doc": "Preserves element across swaps",
                    "returns": "static",
                    "args": []
                },
                {
                    "name": "hxPrompt",
                    "doc": "Shows a prompt() before issuing requests",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string",
                            "name": "message"
                        }
                    ]
                },
                {
                    "name": "hxPushUrl",
                    "doc": "Pushes URL into history (\"true\" for current, \"false\" to disable)",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string|bool",
                            "name": "url"
                        }
                    ]
                },
                {
                    "name": "hxReplaceUrl",
                    "doc": "Replaces current URL without push",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string|bool",
                            "name": "url"
                        }
                    ]
                },
                {
                    "name": "hxRequest",
                    "doc": "Configures requests (JSON string)",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string",
                            "name": "config"
                        }
                    ]
                },
                {
                    "name": "hxSelect",
                    "doc": "Selects content from response to swap",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string",
                            "name": "selector"
                        }
                    ]
                },
                {
                    "name": "hxSelectOob",
                    "doc": "Out-of-band swaps (comma-separated)",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string",
                            "name": "values"
                        }
                    ]
                },
                {
                    "name": "hxSwapOob",
                    "doc": "Marks element for out-of-band swap",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string|bool",
                            "name": "swap"
                        }
                    ]
                },
                {
                    "name": "hxSync",
                    "doc": "Synchronizes requests on this element",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string",
                            "name": "strategy"
                        }
                    ]
                },
                {
                    "name": "hxTarget",
                    "doc": "Target element for response",
                    "returns": "static",
                    "args": [
                        {
                            "type": "HxTarget|string",
                            "name": "target"
                        }
                    ]
                },
                {
                    "name": "hxTrigger",
                    "doc": "Specifies trigger events",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string",
                            "name": "spec"
                        }
                    ]
                },
                {
                    "name": "hxValidate",
                    "doc": "Validates before request (\"true\")",
                    "returns": "static",
                    "args": [
                        {
                            "type": "bool",
                            "name": "true"
                        }
                    ]
                },
                {
                    "name": "hxVals",
                    "doc": "Adds extra values to requests (JSON)",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string",
                            "name": "json"
                        }
                    ]
                },
                {
                    "name": "hxHeaders",
                    "doc": "Adds extra headers (JSON)",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string",
                            "name": "json"
                        }
                    ]
                },
                {
                    "name": "hxSwap",
                    "doc": "Swap strategy for response",
                    "returns": "static",
                    "args": [
                        {
                            "type": "HxSwap|string",
                            "name": "strategy"
                        }
                    ]
                },
                {
                    "name": "hxDisinherit",
                    "doc": "Prevents inheriting specified attributes",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string",
                            "name": "attrs"
                        }
                    ]
                },
                {
                    "name": "hxInherit",
                    "doc": "Forces inheritance of specified attributes",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string",
                            "name": "attrs"
                        }
                    ]
                },
                {
                    "name": "hxHistoryElt",
                    "doc": "Marks element as the one saved to history",
                    "returns": "static",
                    "args": []
                },
                {
                    "name": "hxDisabledElt",
                    "doc": "Adds the disabled attribute to the specified elements while a request is in flight",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string",
                            "name": "selector"
                        }
                    ]
                },
                {
                    "name": "hxOn",
                    "doc": "Handles any event with inline script (uses hx-on:* syntax)",
                    "returns": "static",
                    "args": [
                        {
                            "type": "string",
                            "name": "event"
                        },
                        {
                            "type": "string",
                            "name": "js"
                        }
                    ]
                }
            ]
        }
    ]
}

Integrate with PHPStan

This tool also creates an extension.neon file you can just include in your phpstan config like this:

includes:
    - .berry/extension.neon

parameters:
    level: 10
    paths:
        - src/

License

MIT

统计信息

  • 总下载量: 896
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固