From cfd99e97bcd18fd4d0e70f43410b581a10216d5a Mon Sep 17 00:00:00 2001 From: Benjamin Friedman Date: Tue, 27 Jun 2017 12:18:07 -0700 Subject: [PATCH 1/2] Corrects and updates phpdoc references/errors --- .gitignore | 3 + composer.json | 2 +- package.json | 3 +- src/Parse/HttpClients/ParseCurl.php | 9 +-- src/Parse/HttpClients/ParseCurlHttpClient.php | 20 ++++-- src/Parse/HttpClients/ParseHttpable.php | 10 ++- src/Parse/HttpClients/ParseStream.php | 12 ++-- .../HttpClients/ParseStreamHttpClient.php | 40 ++++++++++- src/Parse/Internal/AddOperation.php | 4 ++ src/Parse/Internal/AddUniqueOperation.php | 11 +++ src/Parse/Internal/DeleteOperation.php | 4 ++ src/Parse/Internal/Encodable.php | 4 ++ src/Parse/Internal/FieldOperation.php | 4 ++ src/Parse/Internal/IncrementOperation.php | 4 ++ src/Parse/Internal/ParseRelationOperation.php | 18 ++++- src/Parse/Internal/RemoveOperation.php | 4 ++ src/Parse/Internal/SetOperation.php | 4 ++ src/Parse/ParseACL.php | 23 +++++- src/Parse/ParseAggregateException.php | 11 ++- src/Parse/ParseAnalytics.php | 12 +++- src/Parse/ParseApp.php | 47 ++++++++++-- src/Parse/ParseBytes.php | 16 ++++- src/Parse/ParseClient.php | 15 +++- src/Parse/ParseCloud.php | 6 +- src/Parse/ParseConfig.php | 35 ++++++++- src/Parse/ParseException.php | 6 +- src/Parse/ParseFile.php | 18 ++++- src/Parse/ParseGeoPoint.php | 6 +- src/Parse/ParseHooks.php | 6 +- src/Parse/ParseInstallation.php | 11 ++- src/Parse/ParseMemoryStorage.php | 48 ++++++++++++- src/Parse/ParseObject.php | 43 ++++++++++- src/Parse/ParsePush.php | 6 +- src/Parse/ParsePushStatus.php | 11 ++- src/Parse/ParseQuery.php | 6 +- src/Parse/ParseRelation.php | 7 +- src/Parse/ParseRole.php | 11 ++- src/Parse/ParseSchema.php | 71 +++++++++++++++++-- src/Parse/ParseSession.php | 16 ++++- src/Parse/ParseSessionStorage.php | 50 ++++++++++++- src/Parse/ParseStorageInterface.php | 6 +- src/Parse/ParseUser.php | 19 ++++- tests/Parse/ParseSchemaTest.php | 2 +- 43 files changed, 603 insertions(+), 61 deletions(-) diff --git a/.gitignore b/.gitignore index e03a3294..2862a05b 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,6 @@ phpunit-test-results *.log coverage.xml + +# ignore phpdoc +output/ diff --git a/composer.json b/composer.json index 6c21134a..12ede17e 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "require-dev": { "phpunit/phpunit": "~4.0", "squizlabs/php_codesniffer": "^3.0.1", - "phpdocumentor/phpdocumentor": "~2.5" + "phpdocumentor/phpdocumentor": "~2.9" }, "autoload": { "psr-4": { diff --git a/package.json b/package.json index 8cea34da..d800185a 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "lint": "./vendor/bin/phpcs --standard=./phpcs.xml.dist ./src/Parse ./tests/Parse", "lint:fix": "./vendor/bin/phpcbf --standard=./phpcs.xml.dist ./src/Parse ./tests/Parse", "start" : "./node_modules/parse-server-test/run-server", - "stop" : "./node_modules/parse-server-test/stop-server" + "stop" : "./node_modules/parse-server-test/stop-server", + "document" : "./vendor/bin/phpdoc -d ./src/ --title 'Parse PHP SDK API Reference' --template='responsive-twig'" }, "repository": { "type": "git", diff --git a/src/Parse/HttpClients/ParseCurl.php b/src/Parse/HttpClients/ParseCurl.php index 2835c4b6..3b850f37 100644 --- a/src/Parse/HttpClients/ParseCurl.php +++ b/src/Parse/HttpClients/ParseCurl.php @@ -1,8 +1,6 @@ + * Class ParseCurl | Parse/HttpClients/ParseCurl.php */ namespace Parse\HttpClients; @@ -10,13 +8,16 @@ use Parse\ParseException; /** - * Class ParseCurl + * Class ParseCurl - Wrapper for abstracted curl usage + * + * @author Ben Friedman * @package Parse\HttpClients */ class ParseCurl { /** * Curl handle + * * @var resource */ private $curl; diff --git a/src/Parse/HttpClients/ParseCurlHttpClient.php b/src/Parse/HttpClients/ParseCurlHttpClient.php index 49eef081..93f1be7a 100644 --- a/src/Parse/HttpClients/ParseCurlHttpClient.php +++ b/src/Parse/HttpClients/ParseCurlHttpClient.php @@ -1,8 +1,6 @@ + * Class ParseCurlHttpClient | Parse/HttpClients/ParseCurlHttpClient.php */ namespace Parse\HttpClients; @@ -10,49 +8,58 @@ use Parse\ParseException; /** - * Class ParseCurlHttpClient + * Class ParseCurlHttpClient - Curl http client + * + * @author Ben Friedman * @package Parse\HttpClients */ class ParseCurlHttpClient implements ParseHttpable { /** * Curl handle + * * @var ParseCurl */ private $parseCurl; /** * Request Headers + * * @var array */ private $headers = array(); /** * Response headers + * * @var array */ private $responseHeaders = array(); /** * Response code + * * @var int */ private $responseCode = 0; /** * Content type of our response + * * @var string|null */ private $responseContentType; /** * cURL error code + * * @var int */ private $curlErrorCode; /** * cURL error message + * * @var string */ private $curlErrorMessage; @@ -69,11 +76,14 @@ class ParseCurlHttpClient implements ParseHttpable /** * Response from our request + * * @var string */ private $response; - + /** + * ParseCurlHttpClient constructor. + */ public function __construct() { if (!isset($this->parseCurl)) { diff --git a/src/Parse/HttpClients/ParseHttpable.php b/src/Parse/HttpClients/ParseHttpable.php index e66e26c5..79c6404f 100644 --- a/src/Parse/HttpClients/ParseHttpable.php +++ b/src/Parse/HttpClients/ParseHttpable.php @@ -1,12 +1,16 @@ + * Class ParseHttpable | Parse/HttpClients/ParseHttpable.php */ namespace Parse\HttpClients; +/** + * Class ParseHttpable - Interface for an HTTPable client + * + * @author Ben Friedman + * @package Parse\HttpClients + */ interface ParseHttpable { /** diff --git a/src/Parse/HttpClients/ParseStream.php b/src/Parse/HttpClients/ParseStream.php index 4f16df0a..1d4faa0f 100644 --- a/src/Parse/HttpClients/ParseStream.php +++ b/src/Parse/HttpClients/ParseStream.php @@ -1,19 +1,20 @@ + * Class ParseStream | Parse/HttpClients/ParseStream.php */ namespace Parse\HttpClients; /** - * Class ParseStream + * Class ParseStream - Wrapper for abstracted stream usage + * + * @author Ben Friedman * @package Parse\HttpClients */ class ParseStream { /** + * Stream context * * @var resource */ @@ -21,18 +22,21 @@ class ParseStream /** * Response headers + * * @var array|null */ private $responseHeaders; /** * Error message + * * @var string */ private $errorMessage; /** * Error code + * * @var int */ private $errorCode; diff --git a/src/Parse/HttpClients/ParseStreamHttpClient.php b/src/Parse/HttpClients/ParseStreamHttpClient.php index 3adb5383..8ac30fdf 100644 --- a/src/Parse/HttpClients/ParseStreamHttpClient.php +++ b/src/Parse/HttpClients/ParseStreamHttpClient.php @@ -1,76 +1,93 @@ + * Class ParseStreamHttpClient | Parse/HttpClients/ParseStreamHttpClient.php */ namespace Parse\HttpClients; use Parse\ParseException; +/** + * Class ParseStreamHttpClient - Stream http client + * + * @author Ben Friedman + * @package Parse\HttpClients + */ class ParseStreamHttpClient implements ParseHttpable { /** * Stream handle + * * @var ParseStream */ private $parseStream; /** * Request Headers + * * @var array */ private $headers = array(); /** * Response headers + * * @var array */ private $responseHeaders = array(); /** * Response code + * * @var int */ private $responseCode = 0; /** * Content type of our response + * * @var string|null */ private $responseContentType; /** * Stream error code + * * @var int */ private $streamErrorCode; /** * Stream error message + * * @var string */ private $streamErrorMessage; /** * Options to pass to our stream + * * @var array */ private $options = array(); /** * Optional CA file to verify our peers with + * * @var string */ private $caFile; /** * Response from our request + * * @var string */ private $response; + /** + * ParseStreamHttpClient constructor. + */ public function __construct() { if (!isset($this->parseStream)) { @@ -143,6 +160,9 @@ private function buildRequestHeaders() return implode("\r\n", $headers); } + /** + * Sets up ssl related options for the stream context + */ public function setup() { // setup ssl options @@ -154,6 +174,15 @@ public function setup() ); } + /** + * Sends an HTTP request + * + * @param string $url Url to send this request to + * @param string $method Method to send this request via + * @param array $data Data to send in this request + * @return string + * @throws ParseException + */ public function send($url, $method = 'GET', $data = array()) { @@ -287,6 +316,11 @@ public function getErrorMessage() return $this->streamErrorMessage; } + /** + * Sets a connection timeout. UNUSED in the stream client. + * + * @param int $timeout Timeout to set + */ public function setConnectionTimeout($timeout) { // do nothing diff --git a/src/Parse/Internal/AddOperation.php b/src/Parse/Internal/AddOperation.php index 1be9c7bb..43787ca8 100755 --- a/src/Parse/Internal/AddOperation.php +++ b/src/Parse/Internal/AddOperation.php @@ -1,4 +1,7 @@ + * @package Parse\Internal */ class AddOperation implements FieldOperation { diff --git a/src/Parse/Internal/AddUniqueOperation.php b/src/Parse/Internal/AddUniqueOperation.php index 64b1fef7..4311f6e1 100755 --- a/src/Parse/Internal/AddUniqueOperation.php +++ b/src/Parse/Internal/AddUniqueOperation.php @@ -1,4 +1,7 @@ + * @package Parse\Internal */ class AddUniqueOperation implements FieldOperation { @@ -126,6 +130,13 @@ public function _apply($oldValue, $obj, $key) return $oldValue; } + /** + * Checks if a parse object is contained in a given array of values + * + * @param ParseObject $parseObject ParseObject to check for existence of + * @param array $oldValue Array to check if ParseObject is present in + * @return bool + */ private function isParseObjectInArray($parseObject, $oldValue) { foreach ($oldValue as $object) { diff --git a/src/Parse/Internal/DeleteOperation.php b/src/Parse/Internal/DeleteOperation.php index 4bf14e97..670ac0b9 100755 --- a/src/Parse/Internal/DeleteOperation.php +++ b/src/Parse/Internal/DeleteOperation.php @@ -1,4 +1,7 @@ + * @package Parse\Internal */ class DeleteOperation implements FieldOperation { diff --git a/src/Parse/Internal/Encodable.php b/src/Parse/Internal/Encodable.php index 5264aa97..c3ccc0f5 100644 --- a/src/Parse/Internal/Encodable.php +++ b/src/Parse/Internal/Encodable.php @@ -1,4 +1,7 @@ + * @package Parse\Internal */ interface Encodable { diff --git a/src/Parse/Internal/FieldOperation.php b/src/Parse/Internal/FieldOperation.php index e70b542d..9b396b46 100755 --- a/src/Parse/Internal/FieldOperation.php +++ b/src/Parse/Internal/FieldOperation.php @@ -1,4 +1,7 @@ + * @package Parse\Internal */ interface FieldOperation extends Encodable { diff --git a/src/Parse/Internal/IncrementOperation.php b/src/Parse/Internal/IncrementOperation.php index c9f553d4..ab03d781 100755 --- a/src/Parse/Internal/IncrementOperation.php +++ b/src/Parse/Internal/IncrementOperation.php @@ -1,4 +1,7 @@ + * @package Parse\Internal */ class IncrementOperation implements FieldOperation { diff --git a/src/Parse/Internal/ParseRelationOperation.php b/src/Parse/Internal/ParseRelationOperation.php index b0676333..3d8e434c 100644 --- a/src/Parse/Internal/ParseRelationOperation.php +++ b/src/Parse/Internal/ParseRelationOperation.php @@ -1,4 +1,7 @@ + * @package Parse\Internal */ class ParseRelationOperation implements FieldOperation { @@ -35,6 +39,13 @@ class ParseRelationOperation implements FieldOperation */ private $relationsToRemove = []; + /** + * ParseRelationOperation constructor. + * + * @param ParseObject[] $objectsToAdd ParseObjects to add + * @param ParseObject[] $objectsToRemove ParseObjects to remove + * @throws Exception + */ public function __construct($objectsToAdd, $objectsToRemove) { $this->targetClassName = null; @@ -258,6 +269,11 @@ public function _encode() return empty($addRelation['objects']) ? $removeRelation : $addRelation; } + /** + * Gets the className of the target objects. + * + * @return null|string + */ public function _getTargetClass() { return $this->targetClassName; diff --git a/src/Parse/Internal/RemoveOperation.php b/src/Parse/Internal/RemoveOperation.php index 7a06f2f1..bee46f58 100644 --- a/src/Parse/Internal/RemoveOperation.php +++ b/src/Parse/Internal/RemoveOperation.php @@ -1,4 +1,7 @@ + * @package Parse\Internal */ class RemoveOperation implements FieldOperation { diff --git a/src/Parse/Internal/SetOperation.php b/src/Parse/Internal/SetOperation.php index 994242b3..27caae48 100755 --- a/src/Parse/Internal/SetOperation.php +++ b/src/Parse/Internal/SetOperation.php @@ -1,4 +1,7 @@ + * @package Parse\Internal */ class SetOperation implements FieldOperation { diff --git a/src/Parse/ParseACL.php b/src/Parse/ParseACL.php index 48d7a276..500bbb91 100644 --- a/src/Parse/ParseACL.php +++ b/src/Parse/ParseACL.php @@ -1,4 +1,7 @@ + * @package Parse */ class ParseACL implements Encodable { const PUBLIC_KEY = '*'; /** + * Array of permissions by id + * * @var array */ private $permissionsById = []; /** + * Whether this ACL is shared + * * @var bool */ private $shared = false; /** + * The last known current user + * * @var ParseUser */ private static $lastCurrentUser = null; /** + * An ACL with defaults set with the current user + * * @var ParseACL */ private static $defaultACLWithCurrentUser = null; /** + * An ACL with defaults set + * * @var ParseACL */ private static $defaultACL = null; /** + * Whether the default acl uses the current user or not + * * @var bool */ private static $defaultACLUsesCurrentUser = false; @@ -119,6 +135,11 @@ public function _setShared($shared) $this->shared = $shared; } + /** + * Returns an associate array encoding of this ParseACL instance. + * + * @return mixed + */ public function _encode() { if (empty($this->permissionsById)) { diff --git a/src/Parse/ParseAggregateException.php b/src/Parse/ParseAggregateException.php index 543468a0..3b3e235a 100644 --- a/src/Parse/ParseAggregateException.php +++ b/src/Parse/ParseAggregateException.php @@ -1,14 +1,23 @@ + * @package Parse */ class ParseAggregateException extends ParseException { + /** + * Collection of error values + * + * @var array + */ private $errors; /** diff --git a/src/Parse/ParseAnalytics.php b/src/Parse/ParseAnalytics.php index 7b9a43bb..72c19a1c 100644 --- a/src/Parse/ParseAnalytics.php +++ b/src/Parse/ParseAnalytics.php @@ -1,13 +1,17 @@ + * @package Parse */ class ParseAnalytics { @@ -62,6 +66,12 @@ public static function track($name, $dimensions = []) ); } + /** + * Encodes and returns the given data as a json object + * + * @param array $data Data to encode + * @return string + */ public static function _toSaveJSON($data) { return json_encode( diff --git a/src/Parse/ParseApp.php b/src/Parse/ParseApp.php index 8117c10f..12ac6736 100644 --- a/src/Parse/ParseApp.php +++ b/src/Parse/ParseApp.php @@ -1,20 +1,59 @@ + * @package Parse */ class ParseBytes implements Encodable { @@ -48,12 +52,22 @@ public static function createFromBase64Data($base64Data) return $bytes; } + /** + * Decodes and unpacks a given base64 encoded array of data + * + * @param $base64Data + */ private function setBase64Data($base64Data) { $byteArray = unpack('C*', base64_decode($base64Data)); $this->setByteArray($byteArray); } + /** + * Sets a new byte array + * + * @param array $byteArray Byte array to set + */ private function setByteArray(array $byteArray) { $this->byteArray = $byteArray; diff --git a/src/Parse/ParseClient.php b/src/Parse/ParseClient.php index c2ba5b7f..174dbca3 100755 --- a/src/Parse/ParseClient.php +++ b/src/Parse/ParseClient.php @@ -1,4 +1,7 @@ + * @package Parse */ final class ParseClient { @@ -107,7 +111,7 @@ final class ParseClient private static $caFile; /** - * Constant for version string to include with requests. + * Constant for version string to include with requests. Currently 1.2.9. * * @var string */ @@ -566,6 +570,11 @@ public static function _unsetStorage() self::$storage = null; } + /** + * Asserts that the sdk has been initialized with a valid application id + * + * @throws Exception + */ private static function assertParseInitialized() { if (self::$applicationId === null) { @@ -576,6 +585,8 @@ private static function assertParseInitialized() } /** + * Asserts that the sdk has been initialized with a valid account key + * * @throws Exception */ private static function assertAppInitialized() diff --git a/src/Parse/ParseCloud.php b/src/Parse/ParseCloud.php index 6170cbd5..c6805892 100644 --- a/src/Parse/ParseCloud.php +++ b/src/Parse/ParseCloud.php @@ -1,11 +1,15 @@ + * @package Parse */ class ParseCloud { diff --git a/src/Parse/ParseConfig.php b/src/Parse/ParseConfig.php index 45a0336f..dd089ace 100644 --- a/src/Parse/ParseConfig.php +++ b/src/Parse/ParseConfig.php @@ -1,18 +1,27 @@ + * @package Parse */ class ParseConfig { + /** + * Current configuration data + * + * @var array + */ private $currentConfig; /** - * Creates. + * ParseConfig constructor. */ public function __construct() { @@ -20,6 +29,12 @@ public function __construct() $this->setConfig($result['params']); } + /** + * Gets a config value + * + * @param string $key Key of value to get + * @return mixed + */ public function get($key) { if (isset($this->currentConfig[$key])) { @@ -27,6 +42,12 @@ public function get($key) } } + /** + * Gets a config value with html characters encoded + * + * @param string $key Key of value to get + * @return string + */ public function escape($key) { if (isset($this->currentConfig[$key])) { @@ -34,11 +55,21 @@ public function escape($key) } } + /** + * Sets the config + * + * @param array $config Config to set + */ protected function setConfig($config) { $this->currentConfig = $config; } + /** + * Gets the current config + * + * @return array + */ public function getConfig() { return $this->currentConfig; diff --git a/src/Parse/ParseException.php b/src/Parse/ParseException.php index 35ce91e2..2f46c886 100644 --- a/src/Parse/ParseException.php +++ b/src/Parse/ParseException.php @@ -1,13 +1,17 @@ + * @package Parse */ class ParseException extends Exception { diff --git a/src/Parse/ParseFile.php b/src/Parse/ParseFile.php index ccb81a09..9c455b07 100755 --- a/src/Parse/ParseFile.php +++ b/src/Parse/ParseFile.php @@ -1,13 +1,17 @@ + * @package Parse */ class ParseFile implements Encodable { @@ -230,6 +234,12 @@ private function upload($useMasterKey = false) ); } + /** + * Attempts to download and return the contents of a ParseFile's url + * + * @return mixed + * @throws ParseException + */ private function download() { $rest = curl_init(); @@ -251,6 +261,12 @@ private function download() return $response; } + /** + * Returns the mimetype for a given extension + * + * @param string $extension Extension to return type for + * @return string + */ private function getMimeTypeForExtension($extension) { $knownTypes = [ diff --git a/src/Parse/ParseGeoPoint.php b/src/Parse/ParseGeoPoint.php index 0cb1aba2..50a8ca8e 100755 --- a/src/Parse/ParseGeoPoint.php +++ b/src/Parse/ParseGeoPoint.php @@ -1,13 +1,17 @@ + * @package Parse */ class ParseGeoPoint implements Encodable { diff --git a/src/Parse/ParseHooks.php b/src/Parse/ParseHooks.php index 650a19f4..a15b5265 100644 --- a/src/Parse/ParseHooks.php +++ b/src/Parse/ParseHooks.php @@ -1,11 +1,15 @@ + * @package Parse */ class ParseHooks { diff --git a/src/Parse/ParseInstallation.php b/src/Parse/ParseInstallation.php index 4d25107d..82705795 100644 --- a/src/Parse/ParseInstallation.php +++ b/src/Parse/ParseInstallation.php @@ -1,14 +1,23 @@ + * @package Parse */ class ParseInstallation extends ParseObject { + /** + * Parse Class name + * + * @var string + */ public static $parseClassName = '_Installation'; /** diff --git a/src/Parse/ParseMemoryStorage.php b/src/Parse/ParseMemoryStorage.php index 1dd096e7..e4694f0e 100644 --- a/src/Parse/ParseMemoryStorage.php +++ b/src/Parse/ParseMemoryStorage.php @@ -1,30 +1,58 @@ + * @package Parse */ class ParseMemoryStorage implements ParseStorageInterface { /** + * Memory storage + * * @var array */ private $storage = []; + /** + * Sets a key-value pair in storage. + * + * @param string $key The key to set + * @param mixed $value The value to set + * + * @return void + */ public function set($key, $value) { $this->storage[$key] = $value; } + /** + * Remove a key from storage. + * + * @param string $key The key to remove. + * + * @return void + */ public function remove($key) { unset($this->storage[$key]); } + /** + * Gets the value for a key from storage. + * + * @param string $key The key to get the value for + * + * @return mixed + */ public function get($key) { if (isset($this->storage[$key])) { @@ -34,22 +62,40 @@ public function get($key) return; } + /** + * Clear all the values in storage. + * + * @return null + */ public function clear() { $this->storage = []; } + /** + * Save the data, if necessary. Not implemented. + */ public function save() { // No action required. return; } + /** + * Get all keys in storage. + * + * @return array + */ public function getKeys() { return array_keys($this->storage); } + /** + * Get all key-value pairs from storage. + * + * @return array + */ public function getAll() { return $this->storage; diff --git a/src/Parse/ParseObject.php b/src/Parse/ParseObject.php index fbb22f7d..2affa7d6 100644 --- a/src/Parse/ParseObject.php +++ b/src/Parse/ParseObject.php @@ -1,4 +1,7 @@ + * @package Parse */ class ParseObject implements Encodable { @@ -259,7 +263,7 @@ public function isDirty() * Detects if the object (and optionally the child objects) has unsaved * changes. * - * @param $considerChildren + * @param bool $considerChildren Whether to consider children when checking for dirty state * * @return bool */ @@ -270,6 +274,11 @@ protected function _isDirty($considerChildren) ($considerChildren && $this->hasDirtyChildren()); } + /** + * Determines whether this object has child objects that are dirty + * + * @return bool + */ private function hasDirtyChildren() { $result = false; @@ -459,6 +468,12 @@ public function isDataAvailable() return $this->hasBeenFetched; } + /** + * Returns whether or not data is available for a given key + * + * @param string $key Key to check availability of + * @return bool + */ private function _isDataAvailable($key) { return $this->isDataAvailable() || isset($this->dataAvailability[$key]); @@ -543,6 +558,13 @@ public static function fetchAll(array $objects, $useMasterKey = false) return static::updateWithFetchedResults($objects, $results); } + /** + * Creates an array of object ids from a given array of ParseObjects + * + * @param array $objects Objects to create id array from + * @return array + * @throws ParseException + */ private static function toObjectIdArray(array $objects) { $objectIds = []; @@ -564,6 +586,14 @@ private static function toObjectIdArray(array $objects) return $objectIds; } + /** + * Merges an existing array of objects with their fetched counterparts + * + * @param array $objects Original objects to update + * @param array $fetched Fetched object data to update with + * @return array + * @throws ParseException + */ private static function updateWithFetchedResults(array $objects, array $fetched) { $fetchedObjectsById = []; @@ -1269,7 +1299,7 @@ public function setACL($acl) } /** - * Get ACL assigned to the object. + * Get the ACL assigned to the object. * * @return ParseACL */ @@ -1278,6 +1308,12 @@ public function getACL() return $this->getACLWithCopy(true); } + /** + * Internally retrieves the ACL assigned to this object, conditionally returning a copy of the existing one + * + * @param bool $mayCopy Whether to return a copy of this acl or not + * @return ParseACL + */ private function getACLWithCopy($mayCopy) { if (!isset($this->estimatedData['ACL'])) { @@ -1289,6 +1325,7 @@ private function getACLWithCopy($mayCopy) } return $acl; + } /** diff --git a/src/Parse/ParsePush.php b/src/Parse/ParsePush.php index 81e8b2ef..f6000364 100644 --- a/src/Parse/ParsePush.php +++ b/src/Parse/ParsePush.php @@ -1,13 +1,17 @@ + * @package Parse */ class ParsePush { diff --git a/src/Parse/ParsePushStatus.php b/src/Parse/ParsePushStatus.php index b2ea9278..17662fbe 100644 --- a/src/Parse/ParsePushStatus.php +++ b/src/Parse/ParsePushStatus.php @@ -1,14 +1,23 @@ + * @package Parse */ class ParsePushStatus extends ParseObject { + /** + * Parse Class name + * + * @var string + */ public static $parseClassName = '_PushStatus'; // possible push status values from parse server diff --git a/src/Parse/ParseQuery.php b/src/Parse/ParseQuery.php index 1f55b662..07a23705 100755 --- a/src/Parse/ParseQuery.php +++ b/src/Parse/ParseQuery.php @@ -1,13 +1,17 @@ + * @package Parse */ class ParseQuery { diff --git a/src/Parse/ParseRelation.php b/src/Parse/ParseRelation.php index 6cb24f3e..e03ee5b9 100644 --- a/src/Parse/ParseRelation.php +++ b/src/Parse/ParseRelation.php @@ -1,15 +1,18 @@ + * @package Parse */ class ParseRelation { diff --git a/src/Parse/ParseRole.php b/src/Parse/ParseRole.php index 5702933d..6b22c8fb 100644 --- a/src/Parse/ParseRole.php +++ b/src/Parse/ParseRole.php @@ -1,14 +1,23 @@ + * @package Parse */ class ParseRole extends ParseObject { + /** + * Parse Class name + * + * @var string + */ public static $parseClassName = '_Role'; /** diff --git a/src/Parse/ParseSchema.php b/src/Parse/ParseSchema.php index 1bbbdba2..4e801142 100644 --- a/src/Parse/ParseSchema.php +++ b/src/Parse/ParseSchema.php @@ -1,4 +1,7 @@ + * @package Parse */ class ParseSchema { + /** + * String data type + * + * @var string + */ public static $STRING = 'String'; + + /** + * Number data type + * + * @var string + */ public static $NUMBER = 'Number'; + + /** + * Boolean data type + * + * @var string + */ public static $BOOLEAN = 'Boolean'; + + /** + * Date data type + * + * @var string + */ public static $DATE = 'Date'; + + /** + * File data type + * + * @var string + */ public static $FILE = 'File'; + + /** + * GeoPoint data type + * + * @var string + */ public static $GEO_POINT = 'GeoPoint'; + + /** + * Array data type + * + * @var string + */ public static $ARRAY = 'Array'; + + /** + * Object data type + * + * @var string + */ public static $OBJECT = 'Object'; + + /** + * Pointer data type + * + * @var string + */ public static $POINTER = 'Pointer'; + + /** + * Relation data type + * + * @var string + */ public static $RELATION = 'Relation'; /** @@ -43,7 +106,7 @@ class ParseSchema /** * Force to use master key in Schema Methods. * - * @see https://parse.com/docs/rest/guide#schemas + * @see http://docs.parseplatform.org/rest/guide/#schema * * @var bool */ diff --git a/src/Parse/ParseSession.php b/src/Parse/ParseSession.php index d16a920a..974d7afa 100644 --- a/src/Parse/ParseSession.php +++ b/src/Parse/ParseSession.php @@ -1,16 +1,30 @@ + * @package Parse */ class ParseSession extends ParseObject { + /** + * Parse Class name + * + * @var string + */ public static $parseClassName = '_Session'; + /** + * Session token string + * + * @var null|string + */ private $_sessionToken = null; /** diff --git a/src/Parse/ParseSessionStorage.php b/src/Parse/ParseSessionStorage.php index 36e1255a..cb9844d7 100644 --- a/src/Parse/ParseSessionStorage.php +++ b/src/Parse/ParseSessionStorage.php @@ -1,11 +1,15 @@ + * @package Parse */ class ParseSessionStorage implements ParseStorageInterface { @@ -16,6 +20,10 @@ class ParseSessionStorage implements ParseStorageInterface */ private $storageKey = 'parseData'; + /** + * ParseSessionStorage constructor. + * @throws ParseException + */ public function __construct() { if (session_status() !== PHP_SESSION_ACTIVE) { @@ -28,16 +36,38 @@ public function __construct() } } + /** + * Sets a key-value pair in storage. + * + * @param string $key The key to set + * @param mixed $value The value to set + * + * @return void + */ public function set($key, $value) { $_SESSION[$this->storageKey][$key] = $value; } + /** + * Remove a key from storage. + * + * @param string $key The key to remove. + * + * @return void + */ public function remove($key) { unset($_SESSION[$this->storageKey][$key]); } + /** + * Gets the value for a key from storage. + * + * @param string $key The key to get the value for + * + * @return mixed + */ public function get($key) { if (isset($_SESSION[$this->storageKey][$key])) { @@ -47,22 +77,40 @@ public function get($key) return; } + /** + * Clear all the values in storage. + * + * @return void + */ public function clear() { $_SESSION[$this->storageKey] = []; } + /** + * Save the data, if necessary. Not implemented. + */ public function save() { // No action required. PHP handles persistence for $_SESSION. return; } + /** + * Get all keys in storage. + * + * @return array + */ public function getKeys() { return array_keys($_SESSION[$this->storageKey]); } + /** + * Get all key-value pairs from storage. + * + * @return array + */ public function getAll() { return $_SESSION[$this->storageKey]; diff --git a/src/Parse/ParseStorageInterface.php b/src/Parse/ParseStorageInterface.php index 1578762a..ffbc2e04 100644 --- a/src/Parse/ParseStorageInterface.php +++ b/src/Parse/ParseStorageInterface.php @@ -1,11 +1,15 @@ + * @package Parse */ interface ParseStorageInterface { diff --git a/src/Parse/ParseUser.php b/src/Parse/ParseUser.php index cfb655c6..01579940 100644 --- a/src/Parse/ParseUser.php +++ b/src/Parse/ParseUser.php @@ -1,14 +1,23 @@ + * @package Parse */ class ParseUser extends ParseObject { + /** + * Parse Class name + * + * @var string + */ public static $parseClassName = '_User'; /** @@ -395,8 +404,9 @@ public function linkWithTwitter( /** * Link the user with a service. * - * @param string $serviceName the name of the service - * @param array $authData the array of auth data for $serviceName + * @param string $serviceName the name of the service + * @param array $authData the array of auth data for $serviceName + * @param bool $useMasterKey Whether or not to use the master key, default is false * * @return ParseUser */ @@ -578,6 +588,9 @@ public static function requestPasswordReset($email) ParseClient::_request('POST', 'requestPasswordReset', null, $json); } + /** + * Sets the current user to null. Used internally for testing purposes. + */ public static function _clearCurrentUserVariable() { static::$currentUser = null; diff --git a/tests/Parse/ParseSchemaTest.php b/tests/Parse/ParseSchemaTest.php index a7d1f06d..004f699d 100644 --- a/tests/Parse/ParseSchemaTest.php +++ b/tests/Parse/ParseSchemaTest.php @@ -4,7 +4,7 @@ /** * ParseSchema Tests. * - * @see https://parse.com/docs/rest/guide#schemas + * @see http://docs.parseplatform.org/rest/guide/#schema * * @author Júlio César Gonçalves de Oliveira */ From b356197554ca2f9270b3d1519ccdf1e8ae1d0f2e Mon Sep 17 00:00:00 2001 From: Benjamin Friedman Date: Tue, 27 Jun 2017 12:37:01 -0700 Subject: [PATCH 2/2] Lint fixes --- src/Parse/ParseObject.php | 1 - src/Parse/ParseRelation.php | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Parse/ParseObject.php b/src/Parse/ParseObject.php index 2affa7d6..c2811394 100644 --- a/src/Parse/ParseObject.php +++ b/src/Parse/ParseObject.php @@ -1325,7 +1325,6 @@ private function getACLWithCopy($mayCopy) } return $acl; - } /** diff --git a/src/Parse/ParseRelation.php b/src/Parse/ParseRelation.php index e03ee5b9..90fd2bb4 100644 --- a/src/Parse/ParseRelation.php +++ b/src/Parse/ParseRelation.php @@ -8,8 +8,8 @@ use Parse\Internal\ParseRelationOperation; /** - * Class ParseRelation - A class that is used to access all of the children of a many-to-many relationship. Each instance - * of ParseRelation is associated with a particular parent object and key. + * Class ParseRelation - A class that is used to access all of the children of a many-to-many relationship. + * Each instance of ParseRelation is associated with a particular parent object and key. * * @author Mohamed Madbouli * @package Parse