1
0
mirror of https://github.com/delight-im/PHP-Auth.git synced 2025-07-30 21:00:13 +02:00

Add note about scope of variables with regard to closures to README

This commit is contained in:
Marco
2018-05-28 21:28:00 +02:00
parent 9d08c939a0
commit c685f22937

View File

@@ -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 dont 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