TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   Issue handling object types (http://www.talkphp.com/advanced-php-programming/5286-issue-handling-object-types.html)

captainmerton 02-24-2010 07:56 PM

Issue handling object types
 
I'm using an MVC framework i've created but cant seem to get the following class to instantiate as it errors saying the objevt being passed is not of the correct type. Any ideas what is going wrong?

Here's the calling function from a registry class:

PHP Code:

        static function appController($map) {
            if (
$map instanceof ControllerMap) {print "controllermap2";}

            if (! isset(
self::$appController)) {
                print 
"new app controller";
                
self::$appController = new appController($map);
            }
            return 
self::$appController;
        } 

Here's the relevant part of the accepting class:

PHP Code:

class AppController {
    private static 
$base_cmd;
    private static 
$default_cmd;
    private 
$controllerMap;
    private 
$invoked = array();

    public function 
__construct(ContollerMap $map) {
        
$this->controllerMap $map;
        if (! 
self::$base_cmd) {
            
self::$base_cmd = new RelflectionClass("Command");
            
self::$default_cmd = new DefaultCommand();
        }
    } 

Here's the error i get:

Quote:

Catchable fatal error: Argument 1 passed to AppController::__construct() must be an instance of ContollerMap, instance of ControllerMap given, called in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\framework2\framework.c lasses\Registry.class.php on line 132 and defined in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\framework2\framework.c lasses\AppController.class.php on line 9
The print statements are just to confirm I am passing through the parts of the code i think I am.

sketchMedia 02-24-2010 10:48 PM

must be an instance of ContollerMap, instance of ControllerMap given
You have misspelt your type hint on your constructor.

captainmerton 02-25-2010 07:45 PM

Cheers SketchMedia. Feel like a right bozo haha. Its amazing when you are learning something new and it doesnt work you assume the reason must be something complicated. Thanks.

sketchMedia 02-26-2010 01:07 AM

No probs, an easy mistake to make.
Glad its all sorted!


All times are GMT. The time now is 06:37 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0