CakePHP will automatically attach this varialbe to your Controller and what you're essentially doing is redeclaring it.
I am not completely shure how this is done internally in Cake but have you tried declaring $Scan
before $uses
?
Another way would be to redeclare the Controller's constructor to hadnle this but that seems a bit too far-fetched.
Total refactoring capability is something we're still waiting for and it will come with total adoptance of the PSR standards and especially namespaces.
Edit: Here's a nifty (hack) way to add autoComplete for Helpers in Views. This will work for CakePHP >= 2 and only in Views. Also I've used this only in Eclipse but I suppose it should work in any IDE since it is OOP and PHPDoc based.
"All you need to do: is to create a file called "ThisHelper.php" in the app/View
directory (not in View/Helper
) with the following contents:
App::uses('AppHelper', 'Helper');
/**
* this Helper
*
* @property Html $Html
* @property Session $Session
* @property Form $Form
*/
class this extends AppHelper
{
var $Html;
var $Session;
var $Form;
public function __contruct()
{
$this->Html = new HtmlHelper($View);
$this->Session = new SessionHelper($View);
$this->Form = new FormHelper($View);
}
}
$this = new this();
To add support for other helpers (Cake core or not) just add them as variables to this class, for example if you want to add PaginatorHelper do:
@property Paginator $Paginator
....
var $Paginator;
.....
public function __contruct()
{
.............
$this->Paginator = new PaginatorHelper($View);
}
Probably the best thing to do is to add properties for all CoreHelpers available in CakePHP.
Of course it will work with any custom Helpers if you add them. You do not need to include this file in any PHP Script - just add it to the app/View/
directory.