亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

phpdoc:PHP 警告:count():參數必須是數組或實現 Countable 的對象

phpdoc:PHP 警告:count():參數必須是數組或實現 Countable 的對象

PHP
aluckdog 2022-01-14 16:07:13
安裝$ wget http://www.phpdoc.org/phpDocumentor.phar$ chmod +x phpdocumentor.phar讓我們試一堂課$ cat src/Classe.php<?php/** * Classe. */class Classe {}$ ./phpdocumentor.phar -f src/Classe.phpCollecting files .. OKInitializing parser .. OKParsing filesblablabla...好的。但是現在讓我們嘗試一個函數$ cat src/fun.php<?php/** * Summary fun.php *//** * Function. */function fun() {}$ ./phpdocumentor.phar -f src/fun.phpCollecting files .. OKInitializing parser .. OKParsing filesblablabla...PHP Warning:  count(): Parameter must be an array or an object that implements Countable in phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1293PHP Warning:  count(): Parameter must be an array or an object that implements Countable in phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1293  Execute transformation using writer "twig"PHP Warning:  count(): Parameter must be an array or an object that implements Countable in phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1293PHP Warning:  count(): Parameter must be an array or an object that implements Countable in phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1293  Execute transformation using writer "twig"  Execute transformation using writer "twig"  Execute transformation using writer "twig"  Execute transformation using writer "twig"PHP Warning:  count(): Parameter must be an array or an object that implements Countable in phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1293PHP Warning:  count(): Parameter must be an array or an object that implements Countable in phpDocumentor.phar/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1293blablabla...現在有錯誤(警告)。為什么?此時我想知道,這個 phpdoc 是一個有效的工具嗎?是我不能用嗎?怎么了?
查看完整描述

2 回答

?
忽然笑

TA貢獻1806條經驗 獲得超5個贊

++ composer require --dev phpdocumentor/phpdocumentor dev-master

./composer.json has been updated

Loading composer repositories with package information

Updating dependencies (including require-dev)

Nothing to install or update

Generating autoload files


++ php -v

PHP 7.2.19-0ubuntu0.19.04.2 (cli) (built: Aug 13 2019 11:45:23) ( NTS )

Copyright (c) 1997-2018 The PHP Group

Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

    with Zend OPcache v7.2.19-0ubuntu0.19.04.2, Copyright (c) 1999-2018, by Zend Technologies


++ cat src/Assembler.php

<?php

/**

 * File summary.

 */


namespace Xyz;


/**

 * @package Abc

 */

class Assembler {


    function assemble(?string $string) {


    }


}


++ php vendor/bin/phpdoc -f src/Assembler.php --template=responsive

Collecting files .. OK

Initializing parser .. OK

Parsing files

Parsing /mnt/shared-ntfs/Downloads/test-phpdoc/src/Assembler.php

Parse Error: Syntax error, unexpected '?', expecting T_VARIABLE on line 13  No summary was found for this file

Storing cache in "/mnt/shared-ntfs/Downloads/test-phpdoc/output/build" .. OK

Load cache                                                         ..    0.001s

Preparing template "responsive"                                    ..    0.006s

Preparing 13 transformations                                       ..    0.000s

Build "elements" index                                             ..    0.000s

Replace textual FQCNs with object aliases                          ..    0.000s

Resolve @link and @see tags in descriptions                        ..    0.000s

Enriches inline example tags with their sources                    ..    0.000s

Build "packages" index                                             ..    0.001s

Build "namespaces" index and add namespaces to "elements"          ..    0.000s

Collect all markers embedded in tags                               ..    0.000s

Transform analyzed project into artifacts                          .. 

Applying 13 transformations

  Initialize writer "phpDocumentor\Plugin\Core\Transformer\Writer\FileIo"

  Initialize writer "phpDocumentor\Plugin\Core\Transformer\Writer\Xml"

  Initialize writer "phpDocumentor\Plugin\Core\Transformer\Writer\Xsl"

  Initialize writer "phpDocumentor\Plugin\Graphs\Writer\Graph"

  Execute transformation using writer "FileIo"

  Execute transformation using writer "FileIo"

  Execute transformation using writer "FileIo"

  Execute transformation using writer "xml"

  Execute transformation using writer "xsl"

  Execute transformation using writer "xsl"

  Execute transformation using writer "xsl"

  Execute transformation using writer "xsl"

  Execute transformation using writer "xsl"

  Execute transformation using writer "xsl"

  Execute transformation using writer "xsl"

  Execute transformation using writer "xsl"

  Execute transformation using writer "Graph"

   0.133s

Analyze results and write report to log                            ..    0.000s

解析錯誤:語法錯誤,意外的“?”,第 13 行應為 T_VARIABLE 未找到此文件的摘要


php 7.2 和 phpdoc 有沒有可能真的不能達成一致?是否有任何與 php 7.2 兼容的 phpdoc 版本?


查看完整回答
反對 回復 2022-01-14
?
皈依舞

TA貢獻1851條經驗 獲得超3個贊

發生這些錯誤是因為您count使用不是數組或未實現Countable接口的參數調用該方法。在 PHP 7.2 之前,如果你調用count(null)了值 0 將被返回并且不會發出警告,在 PHP 7.2 之后(包括)count使用無效參數調用時會發出警告。正如您可以在此處檢查的那樣,第一個參數必須是:

一個數組或 Countable 對象。

這意味著phpdocumentor.phar有些代碼與 PHP 7.2+ 不完全兼容。您可以嘗試降級 php 版本或升級phpdocumentar(如果可能)。


查看完整回答
反對 回復 2022-01-14
  • 2 回答
  • 0 關注
  • 450 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號