Skip to content

Instantly share code, notes, and snippets.

tools:
php_code_sniffer:
enabled: true
filter:
excluded_paths: ['thirdparty/*', '*/jquery-changetracker/*', 'parsers/HTML/BBCodeParser/*', '*/SSTemplateParser.php']
config:
standard: tests/phpcs/ruleset.xml
tab_width: 4
@simonwelsh
simonwelsh / bot.php
Last active December 17, 2015 05:38
A bot for App.net that monitors its PMs and replies with a link to a "I'm feeling lucky" search for the text.
<?php
/**
* A bot for App.net that monitors its PMs and replies with a link to a
* "I'm feeling lucky" search for the text.
*
* @author Simon Welsh (@simon_w)
* @license WTFPL Version 2 (http://www.wtfpl.net/txt/copying/)
*/
require_once dirname(__FILE__) . '/AppDotNet.php';
<?php
// Tell mbstring to always use UTF-32, which is what the API uses.
mb_internal_encoding("UTF-32");
// These come from the API
$text = $object->text;
$pieces = []; // the pieces of the new text we're building
$offset = 0; // the amount of adjustment positive or negative we've seen so far
diff --git a/model/MySQLDatabase.php b/model/MySQLDatabase.php
index 7ec6d5b..02dc037 100644
--- a/model/MySQLDatabase.php
+++ b/model/MySQLDatabase.php
@@ -801,8 +801,10 @@ class MySQLDatabase extends SS_Database {
* NOTE: Experimental; introduced for db-abstraction and may changed before 2.4 is released.
*/
public function hasTable($table) {
- $SQL_table = Convert::raw2sql($table);
- return (bool)($this->query("SHOW TABLES LIKE '$SQL_table'")->value());
@simonwelsh
simonwelsh / gist:6442425
Created September 4, 2013 20:28
HHVM StaticFile.Extensions mapping based on the mime-types in a default Apache install.
StaticFile {
Extensions {
123 = application/vnd.lotus-1-2-3
3dml = text/vnd.in3d.3dml
3ds = image/x-3ds
3g2 = video/3gpp2
3gp = video/3gpp
7z = application/x-7z-compressed
aab = application/x-authorware-bin
aac = audio/x-aac
diff --git a/hphp/runtime/base/runtime-error.h b/hphp/runtime/base/runtime-error.h
index fb7d3a2..b8f57e7 100644
--- a/hphp/runtime/base/runtime-error.h
+++ b/hphp/runtime/base/runtime-error.h
@@ -57,7 +57,9 @@ public:
COMPILE_ERROR | COMPILE_WARNING | USER_ERROR | USER_WARNING |
USER_NOTICE | RECOVERABLE_ERROR | PHP_DEPRECATED | USER_DEPRECATED,
- HPHP_ALL = PHP_ALL | FATAL_ERROR
+ HPHP_ALL = PHP_ALL | FATAL_ERROR,
<?php
class A {
protected $i = 0;
public function __toString() {
$this->i++;
return "$this->i";
}
}
diff --git a/hphp/runtime/vm/member-operations.h b/hphp/runtime/vm/member-operations.h
index 806c6c6..fea0229 100644
--- a/hphp/runtime/vm/member-operations.h
+++ b/hphp/runtime/vm/member-operations.h
@@ -192,32 +192,35 @@
template <bool warn, KeyType keyType>
inline TypedValue* ElemArray(ArrayData* base, TypedValue* key) {
TypedValue* result;
if (keyType == KeyType::Any) {
DataType rtt = key->m_type;
diff --git a/hphp/test/frameworks/run.php b/hphp/test/frameworks/run.php
index 4c1f736..0a5f0d2 100755
--- a/hphp/test/frameworks/run.php
+++ b/hphp/test/frameworks/run.php
@@ -1563,6 +1563,74 @@ class PHPUnit extends Framework {
}
}
+class SilverStripe extends Framework {
+ public function __construct(string $name) { parent::__construct($name); }