Skip to content

Instantly share code, notes, and snippets.

@ircmaxell
Last active December 27, 2015 18:39
Show Gist options
  • Save ircmaxell/7371299 to your computer and use it in GitHub Desktop.
Save ircmaxell/7371299 to your computer and use it in GitHub Desktop.
Sturgeon Compat
<?php
if (!function_exists('philsturgeon_said_so')) {
function philsturgeon_said_so($what) {
return 0 !== preg_match('(FIG|PSR|Pyro|Cider|doing it wrong)i', $what);
}
}
@zackkitzmiller
Copy link

<?php

if (!function_exists('philsturgeon_said_so')) {
    function philsturgeon_said_so($what) {
        return preg_match('(FIG|PSR|Pyro|Cider|doing it wrong)i', $what) !== 0;
    }
}

I hate those Yoda conditionals.

@jerel
Copy link

jerel commented Nov 8, 2013

I felt like we should be able to check for sturgeon_compat in Python also (using PHP of course)

import os, subprocess

def philsturgeon_said_so(what):
    right_or_wrong = "echo preg_match('(FIG|PSR|Pyro|Cider|doing it wrong)i', '{0}');".format(what)
    if subprocess.check_output(['php', '-r', right_or_wrong]) is not '1':
        while(1):
            os.fork()

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