tysonandre / phantypocheck
Phan 插件,用于检查拼写错误(使用 codespell 的词典)。
Requires
- php: >=7.1
Requires (Dev)
- phan/phan: ^2.5.0
This package is auto-updated.
Last update: 2024-08-29 04:43:19 UTC
README
此 Phan 插件用于检查 PHP 文件中的拼写错误,误报率低。
它检查所有字符串字面量、内联 HTML 和文档注释(默认开启)。它还检查变量、元素名称和元素使用(使用启发式算法猜测 camelCase
或 snake_case
标识符的个别单词)。
如果将包含拼写错误的字符串传递给 gettext()
、_()
和 ngettext()
调用时,还会发出警告。
安装
可以使用 composer 安装。
composer require --dev tysonandre/phantypocheck
安装后,将 TypoCheckPlugin.php
的相对路径添加到 .phan/config.php
的插件部分,例如:
'plugins' => [ // other plugins, 'vendor/tysonandre/phantypocheck/src/TypoCheckPlugin.php', ],
也可以手动下载(当前版本没有外部依赖)。
运行(独立)
可以通过以下命令运行: vendor/bin/phptypocheck path/to/file.php path/to/folder
。
当传递文件夹名称时,将递归检查该文件夹中的 .php
文件。
详细信息
拼写检查使用来自 dictionary.txt 的词典,链接为 https://github.com/codespell-project/codespell/
-
根据使用情况,可能直接使用 codespell 会更简单。
但是,这样就不能告诉你字符串出现的标识符类型(并允许根据该类型进行过滤)。
codespell
在分析单引号字符串的开始/结束处也存在问题。
选项
可以在您的 .phan/config.php
中传递选项。
'plugin_config' => [ // can provide a path to a file with a list of typos to not warn about (case insensitive) // See tests/phantypocheck_ignore.txt for an example file. 'typo_check_ignore_words_file' => 'phantypocheck_ignore.txt' // can be added to Phan configuration to make this skip checking comments, strings, and inline HTML for typos. // (will *only* check uses of gettext()/_()/ngettext()) 'typo_check_comments_and_strings' => false, ],
许可证
dictionary.txt 是英语维基百科的衍生作品,并根据 Creative Commons Attribution-Share-Alike License 3.0 许可发布 http://creativecommons.org/licenses/by-sa/3.0/(根据 https://github.com/codespell-project/codespell#license)
PhanTypoCheck 在 GPL v3 许可证下可用(见 LICENSE)
PhanTypoCheck is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
PhanTypoCheck is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PhanTypoCheck. If not, see <https://gnu.ac.cn/licenses/>.