warnings - PhpDoc 生成警告
问题描述
以下文档中生成的警告消息是在文档内所有方法中看到的消息。
警告:count():参数必须是在 C:\php72\pear\phpDocumentor\vendor\twig\twig\lib\Twig\Extension\Core.php 中实现 Countable 的数组或对象,第 1198 行警告:count() : 参数必须是在 C:\php72\pear\phpDocumentor\vendor\twig\twig\lib\Twig\Extension\Core.php 中实现 Countable 的数组或对象,第 1198 行在此处输入图像描述
解决方案
我为纠正同样的错误付出了很多努力,所以我希望在这里分享完整的解决方案:要更改什么以及如何编辑 phar 文件:
将此脚本复制到您的 phar 文件夹中的文件中,并使用 php 命令行运行它,并在代码中指定选项:
<?php
//to be run with php -d phar.readonly=Off -f thisFileName
if (ini_get('phar.readonly')==1){
die("\n\nThis script must be run with option -d phar.readonly=Off so that it can write the .phar file\n\n");
}
//the file you want to change
$file = 'vendor/twig/twig/lib/Twig/Extension/Core.php';
//the function in the file you want to change
$oldFunction = '#function twig_length_filter[^{]*[^}]*}#'; //assuming it's still the actual one line function, regex might need updates in the furure
//the replacement function
$newFunction = <<<'funct'
function twig_length_filter(Twig_Environment $env, $thing)
{
if (null === $thing) {
return 0;
}
if (is_scalar($thing)) {
return mb_strlen($thing, $env->getCharset());
}
if (is_object($thing) && method_exists($thing, '__toString') && !$thing instanceof \Countable) {
return mb_strlen((string) $thing, $env->getCharset());
}
if ($thing instanceof \Countable || is_array($thing)) {
return count($thing);
}
return 1;
}
funct;
//access the phar
$p = new Phar('phpDocumentor.phar', FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME);
//extract the file
$p->extractTo('./', $file, true);
//return here if you want to check the file first
//return;
//change the function
file_put_contents($file,
$newFile = preg_replace(
$oldFunction,
$newFunction,
file_get_contents($file)
)
);
//update the file
$p[$file] = $file;
//done
echo 'Done. Don\'t forget to delete the "vendor" folder extracted from the phar !';
推荐阅读
- flutter - 颤振升级不适用于提供不正确网址的 vs 代码?
- java - OpenUI/Swagger java 到 API
- r - 如何分配R中色带上显示的最大值
- postgresql - 如何使用 jdbcTemplate 在对象数组中插入 10 个间隔“10 分钟”
- c++ - 为什么这个例程返回一个长度为 0 的数组?
- automated-tests - 如何使用 Robot Framework 清除文本字段?
- go - 查询数据 influxdb now() - 1s
- angular - 错误类型错误:无法在 t.ngOnInit 处读取 null 的属性“删除”
- http - asp.net core 2.1 Web 应用程序禁用 https 并仅启用 http
- r - 使用 R 解压缩 .tif.gz 文件