Last active
December 27, 2015 18:39
-
-
Save ircmaxell/7371299 to your computer and use it in GitHub Desktop.
Sturgeon Compat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); | |
} | |
} |
Well, That's supported now :-D
Ran this through CodeSniffer to bring it up to PSR-2 standards.
<?php
if (!function_exists('philsturgeon_said_so')) {
function philsturgeon_said_so($what)
{
return 0 !==
preg_match('(FIG
|PSR|
Pyro|
Cider|
doi
ng it wr
ong)i',
$what);
}
}
All good so far:
php > var_dump(philsturgeon_said_so('something about cheese'));
bool(false)
php > var_dump(philsturgeon_said_so('Use PyroCMS or shut the fuck up'));
bool(true)
php >
php > var_dump(philsturgeon_said_so('MongoDB is webscale'));
bool(false)
php >
php > var_dump(philsturgeon_said_so('The FIG is a shitshow but at least we\'re making progress on PSR-4 now.'));
bool(true)
<?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.
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
This is awesome!
In my dream it was something like this: