我目前正在转向这个用于PHP的IDE,因为我非常喜欢一些phpstorm功能,但我遇到了问题。
让我们写一些代码:
的index.php:
require('app/registry/registry.class.php');
require('app/config.php');
$registry = new Registry();
$registry->createAndStoreObject('authentication', 'auth');
// $registry->getObject('auth')-> THE PROBLEM COMES HERE, the ide doesn't give me any suggestion and there are some.
$registry->getObject('auth')->checkForAuthentication(); // This is working, checkForAuthentication() should be a suggestion.
authentication.class.php:
<?php
/**
* @Description:..
* @author:..
* Authenticate Class.
*/
require_once('template.class.php');
class Authentication {
private $registry; // Registry Object
private $loggedIn; // Boolean
private $justProcessed; // Boolean
private $user; // User Object
private $loginFailureReason; // String. Toma valor en caso de que no sea posible el logeo.
/**
* Default constructor.
*/
public function __construct(Registry $registry)
{
$this->registry = $registry;
$this->loggedIn = false;
}
/**
* ..
* @internal param $null
* @return void ?
*/
public function checkForAuthentication()
{
//..
}
/**
* ..
* @param int $id
* @return void
*/
public function sessionAuthenticate($id)
{
//....
}
/**
* ..
* @param String $e The user.
* @param String $p The password.
* @return void
*/
private function postAuthenticate($e, $p)
{
/..
}
}
?>
我已经检查了代码是否值得。任何人都知道如何解决这个问题?
先谢谢你们!!
编辑:
无效
工作
答案 0 :(得分:2)
你必须告诉&#34; IDE什么是变量的类型。变化
$registry->getObject('auth')->checkForAuthentication();
到
/** @var Authentication $auth */
$auth = $registry->getObject('auth');
$auth->checkForAuthentication();
这是正常的,因为对象是&#34;生成&#34;动态。如果您使用标准构造函数,PhpStorm会自动建议自动完成。
有一个例子: