1

我目前正在迁移到这个 PHP IDE,因为我真的很喜欢 phpstorm 的一些功能,但我遇到了问题。

让我们写一些代码:

索引.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.

身份验证.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)
    {
        /..
    }

}
?>

我已经检查了代码是否值得。任何人都知道如何解决这个问题?

提前谢谢各位!!

编辑:

不工作

不工作

在职的

在职的

4

1 回答 1

2

You have to "tell" IDE what is the type of variabe. Change

$registry->getObject('auth')->checkForAuthentication();

to

/** @var Authentication $auth */   
$auth = $registry->getObject('auth');
$auth->checkForAuthentication();

This is quit normal, because object is "generated" dynamically. If you used standard constructor, PhpStorm would have suggested auto-completion automatically.

There is an example:

enter image description here

于 2013-07-31T17:35:56.700 回答