revert scalar type hints to retain support for PHP < 7.0
This commit is contained in:
parent
0f42bd818f
commit
632d70412a
@ -72,7 +72,7 @@ abstract class AbstractData
|
||||
* @param array $paste
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function create(string $pasteid, array $paste);
|
||||
abstract public function create($pasteid, array $paste);
|
||||
|
||||
/**
|
||||
* Read a paste.
|
||||
@ -81,7 +81,7 @@ abstract class AbstractData
|
||||
* @param string $pasteid
|
||||
* @return stdClass|false
|
||||
*/
|
||||
abstract public function read(string $pasteid);
|
||||
abstract public function read($pasteid);
|
||||
|
||||
/**
|
||||
* Delete a paste and its discussion.
|
||||
@ -89,7 +89,7 @@ abstract class AbstractData
|
||||
* @access public
|
||||
* @param string $pasteid
|
||||
*/
|
||||
abstract public function delete(string $pasteid);
|
||||
abstract public function delete($pasteid);
|
||||
|
||||
/**
|
||||
* Test if a paste exists.
|
||||
@ -98,7 +98,7 @@ abstract class AbstractData
|
||||
* @param string $pasteid
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function exists(string $pasteid);
|
||||
abstract public function exists($pasteid);
|
||||
|
||||
/**
|
||||
* Create a comment in a paste.
|
||||
@ -110,7 +110,7 @@ abstract class AbstractData
|
||||
* @param array $comment
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function createComment(string $pasteid, string $parentid, string $commentid, array $comment);
|
||||
abstract public function createComment($pasteid, $parentid, $commentid, array $comment);
|
||||
|
||||
/**
|
||||
* Read all comments of paste.
|
||||
@ -119,7 +119,7 @@ abstract class AbstractData
|
||||
* @param string $pasteid
|
||||
* @return array
|
||||
*/
|
||||
abstract public function readComments(string $pasteid);
|
||||
abstract public function readComments($pasteid);
|
||||
|
||||
/**
|
||||
* Test if a comment exists.
|
||||
@ -130,7 +130,7 @@ abstract class AbstractData
|
||||
* @param string $commentid
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function existsComment(string $pasteid, string $parentid, string $commentid);
|
||||
abstract public function existsComment($pasteid, $parentid, $commentid);
|
||||
|
||||
/**
|
||||
* Returns up to batch size number of paste ids that have expired
|
||||
@ -139,7 +139,7 @@ abstract class AbstractData
|
||||
* @param int $batchsize
|
||||
* @return array
|
||||
*/
|
||||
abstract protected function _getExpiredPastes(int $batchsize);
|
||||
abstract protected function _getExpiredPastes($batchsize);
|
||||
|
||||
/**
|
||||
* Perform a purge of old pastes, at most the given batchsize is deleted.
|
||||
|
@ -154,7 +154,7 @@ class Database extends AbstractData
|
||||
* @param array $paste
|
||||
* @return bool
|
||||
*/
|
||||
public function create(string $pasteid, array $paste)
|
||||
public function create($pasteid, array $paste)
|
||||
{
|
||||
if (
|
||||
array_key_exists($pasteid, self::$_cache)
|
||||
@ -223,7 +223,7 @@ class Database extends AbstractData
|
||||
* @param string $pasteid
|
||||
* @return array|false
|
||||
*/
|
||||
public function read(string $pasteid)
|
||||
public function read($pasteid)
|
||||
{
|
||||
if (array_key_exists($pasteid, self::$_cache)) {
|
||||
return self::$_cache[$pasteid];
|
||||
@ -287,7 +287,7 @@ class Database extends AbstractData
|
||||
* @access public
|
||||
* @param string $pasteid
|
||||
*/
|
||||
public function delete(string $pasteid)
|
||||
public function delete($pasteid)
|
||||
{
|
||||
self::_exec(
|
||||
'DELETE FROM ' . self::_sanitizeIdentifier('paste') .
|
||||
@ -311,7 +311,7 @@ class Database extends AbstractData
|
||||
* @param string $pasteid
|
||||
* @return bool
|
||||
*/
|
||||
public function exists(string $pasteid)
|
||||
public function exists($pasteid)
|
||||
{
|
||||
if (
|
||||
!array_key_exists($pasteid, self::$_cache)
|
||||
@ -331,7 +331,7 @@ class Database extends AbstractData
|
||||
* @param array $comment
|
||||
* @return bool
|
||||
*/
|
||||
public function createComment(string $pasteid, string $parentid, string $commentid, array $comment)
|
||||
public function createComment($pasteid, $parentid, $commentid, array $comment)
|
||||
{
|
||||
if (array_key_exists('data', $comment)) {
|
||||
$version = 1;
|
||||
@ -370,7 +370,7 @@ class Database extends AbstractData
|
||||
* @param string $pasteid
|
||||
* @return array
|
||||
*/
|
||||
public function readComments(string $pasteid)
|
||||
public function readComments($pasteid)
|
||||
{
|
||||
$rows = self::_select(
|
||||
'SELECT * FROM ' . self::_sanitizeIdentifier('comment') .
|
||||
@ -414,7 +414,7 @@ class Database extends AbstractData
|
||||
* @param string $commentid
|
||||
* @return bool
|
||||
*/
|
||||
public function existsComment(string $pasteid, string $parentid, string $commentid)
|
||||
public function existsComment($pasteid, $parentid, $commentid)
|
||||
{
|
||||
return (bool) self::_select(
|
||||
'SELECT dataid FROM ' . self::_sanitizeIdentifier('comment') .
|
||||
@ -456,7 +456,7 @@ class Database extends AbstractData
|
||||
* @throws PDOException
|
||||
* @return bool
|
||||
*/
|
||||
private static function _exec(string $sql, array $params)
|
||||
private static function _exec($sql, array $params)
|
||||
{
|
||||
$statement = self::$_db->prepare($sql);
|
||||
$result = $statement->execute($params);
|
||||
@ -475,7 +475,7 @@ class Database extends AbstractData
|
||||
* @throws PDOException
|
||||
* @return array
|
||||
*/
|
||||
private static function _select(string $sql, array $params, bool $firstOnly = false)
|
||||
private static function _select($sql, array $params, bool $firstOnly = false)
|
||||
{
|
||||
$statement = self::$_db->prepare($sql);
|
||||
$statement->execute($params);
|
||||
|
@ -29,7 +29,7 @@ class Filesystem extends AbstractData
|
||||
* @param array $options
|
||||
* @return Filesystem
|
||||
*/
|
||||
public static function getInstance($options = null)
|
||||
public static function getInstance(array $options)
|
||||
{
|
||||
// if needed initialize the singleton
|
||||
if (!(self::$_instance instanceof self)) {
|
||||
@ -53,7 +53,7 @@ class Filesystem extends AbstractData
|
||||
* @param array $paste
|
||||
* @return bool
|
||||
*/
|
||||
public function create($pasteid, $paste)
|
||||
public function create($pasteid, array $paste)
|
||||
{
|
||||
$storagedir = self::_dataid2path($pasteid);
|
||||
$file = $storagedir . $pasteid . '.php';
|
||||
@ -121,7 +121,7 @@ class Filesystem extends AbstractData
|
||||
* @param string $pasteid
|
||||
* @return bool
|
||||
*/
|
||||
public function exists($pasteid)
|
||||
public functio(($pasteid)
|
||||
{
|
||||
$basePath = self::_dataid2path($pasteid) . $pasteid;
|
||||
$pastePath = $basePath . '.php';
|
||||
@ -155,7 +155,7 @@ class Filesystem extends AbstractData
|
||||
* @param array $comment
|
||||
* @return bool
|
||||
*/
|
||||
public function createComment($pasteid, $parentid, $commentid, $comment)
|
||||
public function createComment($pasteid, $parentid, $commentid, array $comment)
|
||||
{
|
||||
$storagedir = self::_dataid2discussionpath($pasteid);
|
||||
$file = $storagedir . $pasteid . '.' . $commentid . '.' . $parentid . '.php';
|
||||
@ -230,7 +230,7 @@ class Filesystem extends AbstractData
|
||||
* @param int $batchsize
|
||||
* @return array
|
||||
*/
|
||||
protected function _getExpiredPastes($batchsize)
|
||||
protected function _getExpiredPastes(int $batchsize)
|
||||
{
|
||||
$pastes = array();
|
||||
$mainpath = DataStore::getPath();
|
||||
|
@ -3,6 +3,7 @@
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
// change this, if your php files and data is outside of your webservers document root
|
||||
if (!defined('PUBLIC_PATH')) {
|
||||
@ -120,7 +121,7 @@ class Helper
|
||||
* @param array $meta
|
||||
* @return array
|
||||
*/
|
||||
public static function getPaste(int $version = 2, array $meta = array())
|
||||
public static function getPaste($version = 2, array $meta = array())
|
||||
{
|
||||
$example = self::getPasteWithAttachment($version, $meta);
|
||||
// v1 has the attachment stored in a separate property
|
||||
@ -137,7 +138,7 @@ class Helper
|
||||
* @param array $meta
|
||||
* @return array
|
||||
*/
|
||||
public static function getPasteWithAttachment(int $version = 2, array $meta = array())
|
||||
public static function getPasteWithAttachment($version = 2, array $meta = array())
|
||||
{
|
||||
$example = $version === 1 ? self::$pasteV1 : self::$pasteV2;
|
||||
$example['meta']['salt'] = ServerSalt::generate();
|
||||
@ -152,7 +153,7 @@ class Helper
|
||||
* @param array $meta
|
||||
* @return array
|
||||
*/
|
||||
public static function getPastePost(int $version = 2, array $meta = array())
|
||||
public static function getPastePost($version = 2, array $meta = array())
|
||||
{
|
||||
$example = self::getPaste($version, $meta);
|
||||
$example['meta'] = array('expire' => $example['meta']['expire']);
|
||||
@ -165,7 +166,7 @@ class Helper
|
||||
* @param array $meta
|
||||
* @return array
|
||||
*/
|
||||
public static function getPastePostJson(int $version = 2, array $meta = array())
|
||||
public static function getPastePostJson($version = 2, array $meta = array())
|
||||
{
|
||||
$example = self::getPastePost($version, $meta);
|
||||
$example['adata'] = json_encode($example['adata']);
|
||||
@ -190,7 +191,7 @@ class Helper
|
||||
* @param array $meta
|
||||
* @return array
|
||||
*/
|
||||
public static function getComment(int $version = 2, array $meta = array())
|
||||
public static function getComment($version = 2, array $meta = array())
|
||||
{
|
||||
$example = $version === 1 ? self::$commentV1 : self::$pasteV2;
|
||||
if ($version === 2) {
|
||||
|
Loading…
Reference in New Issue
Block a user