I'm currently moving to this IDE for PHP because I really like some phpstorm features but I'm having problems.
Let's write some code:
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)
{
/..
}
}
?>
I've already inspect the code if that's worth something. Anyone knows how to fix this?
Thanks in advance guys!!
EDIT:
Not working
Working
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: