是否有一种语法来记录采用单个配置数组的函数,而不是单个参数?
我正在考虑CodeIgniter样式的库,它使用类似于此的机制:
<?php
//
// Library definition
//
class MyLibrary {
var $foo;
var $bar;
var $baz;
// ... and many more vars...
/* Following is how CodeIgniter documents their built-in libraries,
* which is mostly useless. AFAIK they should be specifying a name
* and description for their @param (which they don't) and omitting
* @return for constructors
*/
/**
* @access public
* @param array
* @return void
*/
function MyLibrary($config = array()) {
foreach ($config as $key …Run Code Online (Sandbox Code Playgroud) 我有:
$myarr['DB'] = new DB();
$myarr['config'] = new config();
Run Code Online (Sandbox Code Playgroud)
我可以以某种方式让PHPStorm知道究竟是什么内部的钥匙?现在我只看到变量和类属性,但不是数组键.