Skip to content

Instantly share code, notes, and snippets.

@pifantastic
Created June 21, 2010 06:08
Show Gist options
  • Select an option

  • Save pifantastic/446480 to your computer and use it in GitHub Desktop.

Select an option

Save pifantastic/446480 to your computer and use it in GitHub Desktop.
<?php
$result = function_that_does_crazy_stuff($arg1, $arg2);
// becomes
$result = memoize('function_that_does_crazy_stuff', $arg1, $arg2);
$result = StaticClass::method($arg1, $arg2);
// becomes
$result = memoize(array('StaticClass', 'method'), $arg1, $arg2);
$object = new SomeClass;
$result = $object->method($arg1, $arg2);
// becomes
$result = memoize(array($object, 'method'), $arg1, $arg2);
@SlexAxton

Copy link
Copy Markdown

you might want to initialize your variables up at the top. Empty functions would probably be the logical choice. Maintaining type consistency is key. Certainly stay away from arrays.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment