Preventing SessionTrait memorize from using call_user_func?

I’ve been adding wizards to my ATK UI - based application, and using the memorize function to store data between steps. I’ve come across a nasty “feature” that I’m trying to get around. The problem strikes when I want to store the string ‘Date’. Since memorize uses call_user_func, what actually gets stored is the current date. When reading it back with recall, this is not desirable – especially because I’m trying to read it back into an enum field, where ‘Date’ is a valid value, but the current date as of the time I called memorize almost certainly is not.

I could get around this, I suppose, by creating a Wizard class of my own, that replaces the memorize method with my own version that doesn’t uses call_user_func. However, if I don’t replace the entire
SessionTrait, which seems like overkill, I’d run the risk of something breaking if SessionTrait gets adjusted in a future release. Is there a better way to get this done?

Thanks in advance for your thoughts.

If it’s a bug with SessionTrait, could you provide a very basic proof of concept (

Also please come to our Wednesday meeting or join our chat.

I’ll put something together to demonstrate it. It will be very obvious once I do. How do I come to the Wednesday meeting?

Here’s the quick & dirty code I wrote to demonstrate the issue:

require 'vendor/autoload.php';

$app = new App();

$w = $app->add('Wizard');
$w->addStep('Demo', function ($w) {
    $w->memorize('demo', 'date');
    $msg = $w->recall('demo');
    $f = $w->add(['Form']);

The intent would be to have the form come up with a field with “date” in it. But instead, I get a form with a field with “09UTC012020”.

And I’m not sure that it’s entirely a bug in SessionTrait. The memorize method explicitly has the code:

if (is_callable($value)) {
    $value = call_user_func($value, $key);

So SessionTrait clearly wants to be able to call functions if their name is passed as a value. I’m not sure what use that has, but I could certainly imagine one for it.

But “date” is a callable function – so there’s just no way to store the string “date” using the memorize method, nor could you store any other string that happens to be a callable function.