From c685f229378fa8b83942afce0e4ec830abcd5e1b Mon Sep 17 00:00:00 2001 From: Marco Date: Mon, 28 May 2018 21:28:00 +0200 Subject: [PATCH] Add note about scope of variables with regard to closures to README --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 26a49c5..db2b8ed 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,8 @@ catch (\Delight\Auth\TooManyRequestsException $e) { } ``` +**Note:** The anonymous callback function is a [closure](http://php.net/manual/en/functions.anonymous.php). Thus, besides its own parameters, only [superglobals](http://php.net/manual/en/language.variables.superglobals.php) like `$_GET`, `$_POST`, `$_COOKIE` and `$_SERVER` are available inside. For any other variable from the parent scope, you need to explicitly make a copy available inside by adding a `use` clause after the parameter list. + The username in the third parameter is optional. You can pass `null` there if you don’t want to manage usernames. If you want to enforce unique usernames, on the other hand, simply call `registerWithUniqueUsername` instead of `register`, and be prepared to catch the `DuplicateUsernameException`. @@ -261,6 +263,8 @@ catch (\Delight\Auth\TooManyRequestsException $e) { } ``` +**Note:** The anonymous callback function is a [closure](http://php.net/manual/en/functions.anonymous.php). Thus, besides its own parameters, only [superglobals](http://php.net/manual/en/language.variables.superglobals.php) like `$_GET`, `$_POST`, `$_COOKIE` and `$_SERVER` are available inside. For any other variable from the parent scope, you need to explicitly make a copy available inside by adding a `use` clause after the parameter list. + You should build an URL with the selector and token and send it to the user, e.g.: ```php @@ -395,6 +399,8 @@ catch (\Delight\Auth\TooManyRequestsException $e) { } ``` +**Note:** The anonymous callback function is a [closure](http://php.net/manual/en/functions.anonymous.php). Thus, besides its own parameters, only [superglobals](http://php.net/manual/en/language.variables.superglobals.php) like `$_GET`, `$_POST`, `$_COOKIE` and `$_SERVER` are available inside. For any other variable from the parent scope, you need to explicitly make a copy available inside by adding a `use` clause after the parameter list. + For email verification, you should build an URL with the selector and token and send it to the user, e.g.: ```php @@ -443,6 +449,8 @@ catch (\Delight\Auth\TooManyRequestsException $e) { } ``` +**Note:** The anonymous callback function is a [closure](http://php.net/manual/en/functions.anonymous.php). Thus, besides its own parameters, only [superglobals](http://php.net/manual/en/language.variables.superglobals.php) like `$_GET`, `$_POST`, `$_COOKIE` and `$_SERVER` are available inside. For any other variable from the parent scope, you need to explicitly make a copy available inside by adding a `use` clause after the parameter list. + Usually, you should build an URL with the selector and token and send it to the user, e.g. as follows: ```php