英語不是我的母語,請耐心等待。從PHP 7.3 開始棄用的功能命名空間斷言()不推薦在命名空間內聲明名為 assert() 的函數。assert() 函數受到引擎的特殊處理,這可能會導致在定義同名命名空間函數時出現不一致的行為。我正在開發 Drupal 7.72,我正在檢查遷移到 PHP 7.3 的過程,當涉及到已棄用的功能時,我發現assert()Drupal 核心在文件夾中的多個文件中使用了該功能\misc\typo3\。我確定的潛在風險如下:docroot\misc\typo3\drupal-security\PharExtensionInterceptor.phpdocroot\misc\typo3\phar-stream-wrapper\src\Interceptor\ConjunctionInterceptor.phpdocroot\misc\typo3\phar-stream-wrapper\src\Interceptor\PharExtensionInterceptor.phpdocroot\misc\typo3\phar-stream-wrapper\src\Interceptor\PharMetaDataInterceptor.phpdocroot\misc\typo3\phar-stream-wrapper\src\PharStreamWrapper.phpdocroot\misc\typo3\phar-stream-wrapper\src\Assertable.phpdocroot\misc\typo3\phar-stream-wrapper\src\Behavior.phpdocroot\misc\typo3\phar-stream-wrapper\src\Manager.php我真的很困惑 Drupal 如何聲明斷言函數,即使它們已被棄用,也許我誤讀了文檔?有某種方法可以測試這些文件以確保一切都可以在 PHP 7.3 上運行嗎?
1 回答

ibeautiful
TA貢獻1993條經驗 獲得超6個贊
這些文件不應導致有關已棄用的命名空間的任何問題assert()。
該棄用指的是命名空間assert()函數,但這些文件中包含的是類方法。
如果我的解釋不清楚,這里有一個基本的差異示例:
命名空間斷言函數(已棄用)
<?php
namespace Foo;
function assert() {}
這會導致:
已棄用:定義自定義的 assert() 函數已棄用,因為該函數具有特殊語義
類方法(未棄用)
<?php
namespace Foo;
class Something
{
public function assert() {}
}
沒問題,因為斷言函數包含在一個類中。
- 1 回答
- 0 關注
- 131 瀏覽
添加回答
舉報
0/150
提交
取消