Given yesterday's news that Honda can now connect thoughts to robotic actuators, we have been given permission to talk about the Solar PHP implementation of that interface: Solar_Mind_Read.

<?php
class Solar_Mind_Read extends Solar_Base {

    protected $_Solar_Mind_Read = array(
        'mind' => null,
    );

    protected $_mind;

    public function __construct($config = null)
    {
        parent::__construct($config);

        $this->_mind = Solar::dependency(
            'Honda_Thought_Interface',
            $this->_config['mind']
        );
    }

    public function fetchIntent($search)
    {
        return $this->_mind->recall($search);
    }

    public function doWhatIMean($subject, $callback)
    {
        $intent = $this->fetchIntent($subject);
        return call_user_func($callback, $intent);
    }

    public function fetchPhpCode($task)
    {
        throw $this->_exception('ERR_NOT_IMPLEMENTED', array(
            'task' => $task,
        ));
    }
}
?>

As you can see, we leverage Solar's base class and inherited configuration, along with its existing dependency injection functionality, to receive an existing Honda "thought" object at construction time. We can then see what the user's intent is given a particular subject using the fetchIntent() method.

Even better, we can pass a callback to the doWhatIMean() method. This means that the user will always get what he wants, not merely what he asks for.

Finally, as a developer tool, the fetchPhpCode() method will take a task description and generate PHP code for it. We are waiting on a related patch to the PHP RunKit extension for this to be fully implemented. In the mean time, the automatic exception system finds the right exception class and throws it, with localized translation, and information about the task.

Once Solar_Mind_Read is complete, we believe we will be able to move on to Solar_Mind_Write. Together, these tools should help the developer with convincing his clients that what they really need is something that's easier to implement, and then with actually implementing it.

Thanks for your attention; we hope this April Fool's Day article piques your interest in the power of the Solar Framework for PHP 5. Many thanks to Clay Loveless for the subject idea. :-)

Are you stuck with a legacy PHP application? You should buy my book because it gives you a step-by-step guide to improving you codebase, all while keeping it running the whole time.