@@ -31,6 +31,8 @@ class FacebookApiException extends Exception
3131{
3232 /**
3333 * The result from the API server that represents the exception information.
34+ *
35+ * @var mixed
3436 */
3537 protected $ result ;
3638
@@ -132,6 +134,8 @@ abstract class BaseFacebook
132134
133135 /**
134136 * Default options for curl.
137+ *
138+ * @var array
135139 */
136140 public static $ CURL_OPTS = array (
137141 CURLOPT_CONNECTTIMEOUT => 10 ,
@@ -143,6 +147,8 @@ abstract class BaseFacebook
143147 /**
144148 * List of query parameters that get automatically dropped when rebuilding
145149 * the current URL.
150+ *
151+ * @var array
146152 */
147153 protected static $ DROP_QUERY_PARAMS = array (
148154 'code ' ,
@@ -152,6 +158,8 @@ abstract class BaseFacebook
152158
153159 /**
154160 * Maps aliases to Facebook domains.
161+ *
162+ * @var array
155163 */
156164 public static $ DOMAIN_MAP = array (
157165 'api ' => 'https://api.facebook.com/ ' ,
@@ -185,11 +193,15 @@ abstract class BaseFacebook
185193
186194 /**
187195 * The data from the signed_request token.
196+ *
197+ * @var string
188198 */
189199 protected $ signedRequest ;
190200
191201 /**
192202 * A CSRF state variable to assist in the defense against CSRF attacks.
203+ *
204+ * @var string
193205 */
194206 protected $ state ;
195207
@@ -258,6 +270,7 @@ public function __construct($config) {
258270 * Set the Application ID.
259271 *
260272 * @param string $appId The Application ID
273+ *
261274 * @return BaseFacebook
262275 */
263276 public function setAppId ($ appId ) {
@@ -278,8 +291,10 @@ public function getAppId() {
278291 * Set the App Secret.
279292 *
280293 * @param string $apiSecret The App Secret
294+ *
281295 * @return BaseFacebook
282296 * @deprecated Use setAppSecret instead.
297+ * @see setAppSecret()
283298 */
284299 public function setApiSecret ($ apiSecret ) {
285300 $ this ->setAppSecret ($ apiSecret );
@@ -290,6 +305,7 @@ public function setApiSecret($apiSecret) {
290305 * Set the App Secret.
291306 *
292307 * @param string $appSecret The App Secret
308+ *
293309 * @return BaseFacebook
294310 */
295311 public function setAppSecret ($ appSecret ) {
@@ -301,7 +317,9 @@ public function setAppSecret($appSecret) {
301317 * Get the App Secret.
302318 *
303319 * @return string the App Secret
320+ *
304321 * @deprecated Use getAppSecret instead.
322+ * @see getAppSecret()
305323 */
306324 public function getApiSecret () {
307325 return $ this ->getAppSecret ();
@@ -320,6 +338,7 @@ public function getAppSecret() {
320338 * Set the file upload support status.
321339 *
322340 * @param boolean $fileUploadSupport The file upload support status.
341+ *
323342 * @return BaseFacebook
324343 */
325344 public function setFileUploadSupport ($ fileUploadSupport ) {
@@ -340,7 +359,9 @@ public function getFileUploadSupport() {
340359 * Get the file upload support status.
341360 *
342361 * @return boolean true if and only if the server supports file upload.
362+ *
343363 * @deprecated Use getFileUploadSupport instead.
364+ * @see getFileUploadSupport()
344365 */
345366 public function useFileUploadSupport () {
346367 return $ this ->getFileUploadSupport ();
@@ -352,6 +373,7 @@ public function useFileUploadSupport() {
352373 * to use it.
353374 *
354375 * @param string $access_token an access token.
376+ *
355377 * @return BaseFacebook
356378 */
357379 public function setAccessToken ($ access_token ) {
@@ -680,7 +702,7 @@ protected function getSignedRequestCookieName() {
680702 }
681703
682704 /**
683- * Constructs and returns the name of the coookie that potentially contain
705+ * Constructs and returns the name of the cookie that potentially contain
684706 * metadata. The cookie is not set by the BaseFacebook class, but it may be
685707 * set by the JavaScript SDK.
686708 *
@@ -768,6 +790,8 @@ protected function establishCSRFTokenState() {
768790 * either logged in to Facebook or has granted an offline access permission.
769791 *
770792 * @param string $code An authorization code.
793+ * @param string $redirect_uri Optional redirect URI. Default null
794+ *
771795 * @return mixed An access token exchanged for the authorization code, or
772796 * false if an access token could not be generated.
773797 */
@@ -1022,6 +1046,7 @@ protected function makeRequest($url, $params, $ch=null) {
10221046 * Parses a signed_request and validates the signature.
10231047 *
10241048 * @param string $signed_request A signed token
1049+ *
10251050 * @return array The payload inside it or null if the sig is wrong
10261051 */
10271052 protected function parseSignedRequest ($ signed_request ) {
@@ -1062,7 +1087,8 @@ protected function parseSignedRequest($signed_request) {
10621087 /**
10631088 * Makes a signed_request blob using the given data.
10641089 *
1065- * @param array The data array.
1090+ * @param array $data The data array.
1091+ *
10661092 * @return string The signed request.
10671093 */
10681094 protected function makeSignedRequest ($ data ) {
@@ -1082,7 +1108,8 @@ protected function makeSignedRequest($data) {
10821108 /**
10831109 * Build the URL for api given parameters.
10841110 *
1085- * @param $method String the method name.
1111+ * @param string $method The method name.
1112+ *
10861113 * @return string The URL for the given parameters
10871114 */
10881115 protected function getApiUrl ($ method ) {
@@ -1159,9 +1186,9 @@ protected function getApiUrl($method) {
11591186 /**
11601187 * Build the URL for given domain alias, path and parameters.
11611188 *
1162- * @param $name string The name of the domain
1163- * @param $path string Optional path (without a leading slash)
1164- * @param $params array Optional query parameters
1189+ * @param string $name The name of the domain
1190+ * @param string $path Optional path (without a leading slash)
1191+ * @param array $params Optional query parameters
11651192 *
11661193 * @return string The URL for the given parameters
11671194 */
@@ -1180,6 +1207,11 @@ protected function getUrl($name, $path='', $params=array()) {
11801207 return $ url ;
11811208 }
11821209
1210+ /**
1211+ * Returns the HTTP Host
1212+ *
1213+ * @return string The HTTP Host
1214+ */
11831215 protected function getHttpHost () {
11841216 if ($ this ->trustForwarded && isset ($ _SERVER ['HTTP_X_FORWARDED_HOST ' ])) {
11851217 $ forwardProxies = explode (', ' , $ _SERVER ['HTTP_X_FORWARDED_HOST ' ]);
@@ -1190,6 +1222,11 @@ protected function getHttpHost() {
11901222 return $ _SERVER ['HTTP_HOST ' ];
11911223 }
11921224
1225+ /**
1226+ * Returns the HTTP Protocol
1227+ *
1228+ * @return string The HTTP Protocol
1229+ */
11931230 protected function getHttpProtocol () {
11941231 if ($ this ->trustForwarded && isset ($ _SERVER ['HTTP_X_FORWARDED_PROTO ' ])) {
11951232 if ($ _SERVER ['HTTP_X_FORWARDED_PROTO ' ] === 'https ' ) {
@@ -1211,7 +1248,9 @@ protected function getHttpProtocol() {
12111248 }
12121249
12131250 /**
1214- * Get the base domain used for the cookie.
1251+ * Returns the base domain used for the cookie.
1252+ *
1253+ * @return string The base domain
12151254 */
12161255 protected function getBaseDomain () {
12171256 // The base domain is stored in the metadata cookie if not we fallback
@@ -1270,7 +1309,7 @@ protected function getCurrentUrl() {
12701309 * params that should be stripped out.
12711310 *
12721311 * @param string $param A key or key/value pair within a URL's query (e.g.
1273- * 'foo=a', 'foo=', or 'foo'.
1312+ * 'foo=a', 'foo=', or 'foo'.
12741313 *
12751314 * @return boolean
12761315 */
@@ -1290,7 +1329,7 @@ protected function shouldRetainParam($param) {
12901329 * because the access token is no longer valid. If that is
12911330 * the case, then we destroy the session.
12921331 *
1293- * @param $result array A record storing the error message returned
1332+ * @param array $result A record storing the error message returned
12941333 * by a failed API call.
12951334 */
12961335 protected function throwAPIException ($ result ) {
@@ -1339,8 +1378,9 @@ protected static function errorLog($msg) {
13391378 * _ instead of /
13401379 * No padded =
13411380 *
1342- * @param string $input base64UrlEncoded string
1343- * @return string
1381+ * @param string $input base64UrlEncoded input
1382+ *
1383+ * @return string The decoded string
13441384 */
13451385 protected static function base64UrlDecode ($ input ) {
13461386 return base64_decode (strtr ($ input , '-_ ' , '+/ ' ));
@@ -1352,8 +1392,8 @@ protected static function base64UrlDecode($input) {
13521392 * - instead of +
13531393 * _ instead of /
13541394 *
1355- * @param string $input string
1356- * @return string base64Url encoded string
1395+ * @param string $input The input to encode
1396+ * @return string The base64Url encoded input, as a string.
13571397 */
13581398 protected static function base64UrlEncode ($ input ) {
13591399 $ str = strtr (base64_encode ($ input ), '+/ ' , '-_ ' );
@@ -1393,7 +1433,7 @@ public function destroySession() {
13931433 /**
13941434 * Parses the metadata cookie that our Javascript API set
13951435 *
1396- * @return an array mapping key to value
1436+ * @return array an array mapping key to value
13971437 */
13981438 protected function getMetadataCookie () {
13991439 $ cookie_name = $ this ->getMetadataCookieName ();
@@ -1421,13 +1461,29 @@ protected function getMetadataCookie() {
14211461 return $ metadata ;
14221462 }
14231463
1464+ /**
1465+ * Finds whether the given domain is allowed or not
1466+ *
1467+ * @param string $big The value to be checked against $small
1468+ * @param string $small The input string
1469+ *
1470+ * @return boolean Returns TRUE if $big matches $small
1471+ */
14241472 protected static function isAllowedDomain ($ big , $ small ) {
14251473 if ($ big === $ small ) {
14261474 return true ;
14271475 }
14281476 return self ::endsWith ($ big , '. ' .$ small );
14291477 }
14301478
1479+ /**
1480+ * Checks if $big string ends with $small string
1481+ *
1482+ * @param string $big The value to be checked against $small
1483+ * @param string $small The input string
1484+ *
1485+ * @return boolean TRUE if $big ends with $small
1486+ */
14311487 protected static function endsWith ($ big , $ small ) {
14321488 $ len = strlen ($ small );
14331489 if ($ len === 0 ) {
@@ -1471,6 +1527,7 @@ abstract protected function getPersistentData($key, $default = false);
14711527 * Clear the data with $key from the persistent storage
14721528 *
14731529 * @param string $key
1530+ *
14741531 * @return void
14751532 */
14761533 abstract protected function clearPersistentData ($ key );
0 commit comments