php autoload静态,Composer 中自动加载 autoload_static 问题
看來不是我一個人遇到這個問題。
IDE 報語法錯誤,$loader 在別的類里面使用了私有成員。
但是這個代碼可以運行。
先說一下為什么會有autoload_static.php 這個文件,代碼里面其實有說明。
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION');
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit8a7582a76d95760eed90a5b1afa5a110::getInitializer($loader));
}
// ...
composer的releases的說明中有寫到
Optimized the autoloader initialization using static loading on PHP 5.6 and above, this reduces the load time for large classmaps to almost nothing
在composer 1.1.0 版本開始如果php的版本大于5.6 ,composer 會進行加載優化。
那么問題來了,IDE報這個語法錯誤其實是誤報了,關鍵在這個Closure::bind 方法上。
可以看一下手冊的解釋,bind方法手冊 。 手冊上說的一堆bulabula,我也不是看很明白~
寫了demo模擬下這個getInitializer方法,結果是確實閉包里面可以訪問和修改它use 的那個對象的私有屬性,代碼是可以正常運行的。
總結:
活到老學到老。。。。
總結
以上是生活随笔為你收集整理的php autoload静态,Composer 中自动加载 autoload_static 问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用matlab仿真函数在空间分布,1.3
- 下一篇: vs2010调用matlab2010b,