We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit b3e61ce7 authored by mattl's avatar mattl

Stronger typing, require array where param array

parent fac73711
...@@ -113,7 +113,7 @@ class File extends Managed_DataObject ...@@ -113,7 +113,7 @@ class File extends Managed_DataObject
* @param string $given_url * @param string $given_url
* @return boolean success * @return boolean success
*/ */
public function saveOembed($redir_data, $given_url) public function saveOembed(array $redir_data, $given_url)
{ {
if (isset($redir_data['type']) if (isset($redir_data['type'])
&& (('text/html' === substr($redir_data['type'], 0, 9) || 'application/xhtml+xml' === substr($redir_data['type'], 0, 21))) && (('text/html' === substr($redir_data['type'], 0, 9) || 'application/xhtml+xml' === substr($redir_data['type'], 0, 21)))
......
...@@ -56,7 +56,7 @@ abstract class Managed_DataObject extends Memcached_DataObject ...@@ -56,7 +56,7 @@ abstract class Managed_DataObject extends Memcached_DataObject
* @return get_called_class() object if found, or null for no hits * @return get_called_class() object if found, or null for no hits
* *
*/ */
static function pkeyGet($kv) static function pkeyGet(array $kv)
{ {
return parent::pkeyGetClass(get_called_class(), $kv); return parent::pkeyGetClass(get_called_class(), $kv);
} }
...@@ -82,13 +82,13 @@ abstract class Managed_DataObject extends Memcached_DataObject ...@@ -82,13 +82,13 @@ abstract class Managed_DataObject extends Memcached_DataObject
* values for a specific key column. Usually used for the primary key when * values for a specific key column. Usually used for the primary key when
* multiple values are desired. * multiple values are desired.
* *
* @param array $keyCol key column name * @param string $keyCol key column name
* @param array $keyVals array of key values * @param array $keyVals array of key values
* *
* @return get_called_class() object with multiple instances if found, or null for no hits * @return get_called_class() object with multiple instances if found, or null for no hits
* *
*/ */
static function listGet($keyCol, $keyVals) static function listGet($keyCol, array $keyVals)
{ {
return parent::listGetClass(get_called_class(), $keyCol, $keyVals); return parent::listGetClass(get_called_class(), $keyCol, $keyVals);
} }
......
...@@ -74,7 +74,7 @@ class Memcached_DataObject extends Safe_DataObject ...@@ -74,7 +74,7 @@ class Memcached_DataObject extends Safe_DataObject
* *
* @return array Array of objects, in order * @return array Array of objects, in order
*/ */
function multiGet($cls, $keyCol, $keyVals, $skipNulls=true) function multiGet($cls, $keyCol, array $keyVals, $skipNulls=true)
{ {
$result = self::pivotGetClass($cls, $keyCol, $keyVals); $result = self::pivotGetClass($cls, $keyCol, $keyVals);
...@@ -264,7 +264,7 @@ class Memcached_DataObject extends Safe_DataObject ...@@ -264,7 +264,7 @@ class Memcached_DataObject extends Safe_DataObject
return $pkey; return $pkey;
} }
static function listGetClass($cls, $keyCol, $keyVals) static function listGetClass($cls, $keyCol, array $keyVals)
{ {
if (!is_a($cls, __CLASS__, true)) { if (!is_a($cls, __CLASS__, true)) {
throw new Exception('Trying to fetch ' . __CLASS__ . ' into a non-related class'); throw new Exception('Trying to fetch ' . __CLASS__ . ' into a non-related class');
...@@ -348,7 +348,7 @@ class Memcached_DataObject extends Safe_DataObject ...@@ -348,7 +348,7 @@ class Memcached_DataObject extends Safe_DataObject
/** /**
* @todo FIXME: Should this return false on lookup fail to match getKV? * @todo FIXME: Should this return false on lookup fail to match getKV?
*/ */
static function pkeyGetClass($cls, $kv) static function pkeyGetClass($cls, array $kv)
{ {
if (!is_a($cls, __CLASS__, true)) { if (!is_a($cls, __CLASS__, true)) {
throw new Exception('Trying to fetch ' . __CLASS__ . ' into a non-related class'); throw new Exception('Trying to fetch ' . __CLASS__ . ' into a non-related class');
......
...@@ -319,7 +319,7 @@ class Notice extends Managed_DataObject ...@@ -319,7 +319,7 @@ class Notice extends Managed_DataObject
* @return Notice * @return Notice
* @throws ClientException * @throws ClientException
*/ */
static function saveNew($profile_id, $content, $source, $options=null) { static function saveNew($profile_id, $content, $source, array $options=null) {
$defaults = array('uri' => null, $defaults = array('uri' => null,
'url' => null, 'url' => null,
'reply_to' => null, 'reply_to' => null,
...@@ -954,7 +954,7 @@ class Notice extends Managed_DataObject ...@@ -954,7 +954,7 @@ class Notice extends Managed_DataObject
* if left empty, will be loaded from reply records * if left empty, will be loaded from reply records
* @return array associating recipient user IDs with an inbox source constant * @return array associating recipient user IDs with an inbox source constant
*/ */
function whoGets($groups=null, $recipients=null) function whoGets(array $groups=null, array $recipients=null)
{ {
$c = self::memcache(); $c = self::memcache();
...@@ -1065,7 +1065,7 @@ class Notice extends Managed_DataObject ...@@ -1065,7 +1065,7 @@ class Notice extends Managed_DataObject
* @param array $recipient optional list of reply profile ids * @param array $recipient optional list of reply profile ids
* if left empty, will be loaded from reply records * if left empty, will be loaded from reply records
*/ */
function addToInboxes($groups=null, $recipients=null) function addToInboxes(array $groups=null, array $recipients=null)
{ {
$ni = $this->whoGets($groups, $recipients); $ni = $this->whoGets($groups, $recipients);
...@@ -1251,9 +1251,9 @@ class Notice extends Managed_DataObject ...@@ -1251,9 +1251,9 @@ class Notice extends Managed_DataObject
* *
* Mail notifications etc will be handled later. * Mail notifications etc will be handled later.
* *
* @param array of unique identifier URIs for recipients * @param array $uris Array of unique identifier URIs for recipients
*/ */
function saveKnownReplies($uris) function saveKnownReplies(array $uris)
{ {
if (empty($uris)) { if (empty($uris)) {
return; return;
......
...@@ -602,7 +602,7 @@ class Profile_list extends Managed_DataObject ...@@ -602,7 +602,7 @@ class Profile_list extends Managed_DataObject
* *
* @return mixed Profile_list on success, false on fail * @return mixed Profile_list on success, false on fail
*/ */
static function saveNew($fields) { static function saveNew(array $fields) {
extract($fields); extract($fields);
$ptag = new Profile_list(); $ptag = new Profile_list();
...@@ -713,7 +713,7 @@ class Profile_list extends Managed_DataObject ...@@ -713,7 +713,7 @@ class Profile_list extends Managed_DataObject
// XXX: This should be in Memcached_DataObject... eventually. // XXX: This should be in Memcached_DataObject... eventually.
static function getAtCursor($fn, $args, $cursor, $count=20) static function getAtCursor($fn, array $args, $cursor, $count=20)
{ {
$items = array(); $items = array();
...@@ -886,7 +886,7 @@ class Profile_list extends Managed_DataObject ...@@ -886,7 +886,7 @@ class Profile_list extends Managed_DataObject
* @return Profile_list results * @return Profile_list results
*/ */
static function getByKeys($keys) { static function getByKeys(array $keys) {
$cache = Cache::instance(); $cache = Cache::instance();
if (!empty($cache)) { if (!empty($cache)) {
......
...@@ -108,7 +108,7 @@ class Safe_DataObject extends DB_DataObject ...@@ -108,7 +108,7 @@ class Safe_DataObject extends DB_DataObject
* @return mixed * @return mixed
* @throws Exception * @throws Exception
*/ */
function __call($method, $params) function __call($method, array $params)
{ {
$return = null; $return = null;
// Yes, that's _call with one underscore, which does the // Yes, that's _call with one underscore, which does the
...@@ -259,7 +259,7 @@ class Safe_DataObject extends DB_DataObject ...@@ -259,7 +259,7 @@ class Safe_DataObject extends DB_DataObject
* @param array of .ini file names $schemas * @param array of .ini file names $schemas
* @return array * @return array
*/ */
protected function parseIniFiles($schemas) protected function parseIniFiles(array $schemas)
{ {
$key = implode("|", $schemas); $key = implode("|", $schemas);
if (!isset(Safe_DataObject::$iniCache[$key])) { if (!isset(Safe_DataObject::$iniCache[$key])) {
......
...@@ -70,7 +70,7 @@ class Status_network extends Safe_DataObject ...@@ -70,7 +70,7 @@ class Status_network extends Safe_DataObject
* @param string $dbname * @param string $dbname
* @param array $servers memcached servers to use for caching config info * @param array $servers memcached servers to use for caching config info
*/ */
static function setupDB($dbhost, $dbuser, $dbpass, $dbname, $servers) static function setupDB($dbhost, $dbuser, $dbpass, $dbname, array $servers)
{ {
global $config; global $config;
...@@ -333,7 +333,7 @@ class Status_network extends Safe_DataObject ...@@ -333,7 +333,7 @@ class Status_network extends Safe_DataObject
* @param array tags * @param array tags
* @fixme only add/remove differentials * @fixme only add/remove differentials
*/ */
function setTags($tags) function setTags(array $tags)
{ {
$this->clearTags(); $this->clearTags();
foreach ($tags as $tag) { foreach ($tags as $tag) {
......
...@@ -260,7 +260,7 @@ class User extends Managed_DataObject ...@@ -260,7 +260,7 @@ class User extends Managed_DataObject
* ?string 'uri' permalink to notice; defaults to local notice URL * ?string 'uri' permalink to notice; defaults to local notice URL
* @return mixed User object or false on failure * @return mixed User object or false on failure
*/ */
static function register($fields) { static function register(array $fields) {
// MAGICALLY put fields into current scope // MAGICALLY put fields into current scope
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment