Skip to content

Instantly share code, notes, and snippets.

@matthewstokeley
Last active June 17, 2019 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewstokeley/182876c47f0b8e40ae61fc2f33080635 to your computer and use it in GitHub Desktop.
Save matthewstokeley/182876c47f0b8e40ae61fc2f33080635 to your computer and use it in GitHub Desktop.
resolvers, discriminators and comparators in php

WIP

Resolvers, Comparators and Discrimimators

These are three callables that are often used as arguments in methods that are built to accept callbacks, like array_filter, usort, or call_user_func_array (similiar to javascript's apply array method).

It's a really interesting set of functions for many reasons - for one, like map and reduce, the semantics of the methods provide for a discrete and specific role, which makes thinking about code clearer. In any case, let's review.

Comparator

usort, uksort and other sorting methods accepts a comparator function, a subset of filters.


Resolvers

vue.js uses a resolver to determine the status of a cached object, and in php, resolvers work similarly.

Discriminators

Discriminators are another subset of filters, and are described in the Slim documentation.

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