Style fixes.
This commit is contained in:
parent
a7a59b690a
commit
be4950ff88
43 changed files with 187 additions and 149 deletions
|
|
@ -18,7 +18,7 @@ class Base extends Model
|
|||
* @param boolean $allFields
|
||||
* @return bool
|
||||
*/
|
||||
public function hasChanged($fieldName = null, bool $allFields = false) : bool
|
||||
public function hasChanged($fieldName = null, bool $allFields = false): bool
|
||||
{
|
||||
return $this->hasSnapshotData() === false
|
||||
|| parent::hasChanged($fieldName, $allFields);
|
||||
|
|
|
|||
|
|
@ -216,8 +216,8 @@ class Callback extends Model
|
|||
*/
|
||||
public function initialize()
|
||||
{
|
||||
// Set table name mapped in the model.
|
||||
$this->setSource('callback');
|
||||
// Set table name mapped in the model.
|
||||
$this->setSource('callback');
|
||||
|
||||
$this->useDynamicUpdate(true);
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class Request extends Model
|
|||
*/
|
||||
public function setHeaders($headers)
|
||||
{
|
||||
foreach($headers as $k => $v) {
|
||||
foreach ($headers as $k => $v) {
|
||||
|
||||
if (strlen($v) < 1) {
|
||||
unset($headers[$k]);
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ class RequestMeta extends Model
|
|||
$query = (string) parse_url($this->getUri(), PHP_URL_QUERY);
|
||||
|
||||
$ret = array();
|
||||
foreach(explode('&', $query) as $v) {
|
||||
foreach (explode('&', $query) as $v) {
|
||||
@list($k, $v) = explode('=', $v, 2);
|
||||
if (strlen($k) > 0) {
|
||||
$ret[$k] = $v;
|
||||
|
|
@ -211,7 +211,7 @@ class RequestMeta extends Model
|
|||
{
|
||||
$headers = $this->getHeaders();
|
||||
|
||||
foreach($headers as $k => $v) {
|
||||
foreach ($headers as $k => $v) {
|
||||
|
||||
if ($k == 'Content-Length') {
|
||||
return $v;
|
||||
|
|
@ -224,7 +224,7 @@ class RequestMeta extends Model
|
|||
{
|
||||
$headers = $this->getHeaders();
|
||||
|
||||
foreach($headers as $k => $v) {
|
||||
foreach ($headers as $k => $v) {
|
||||
|
||||
if ($k == 'Content-Type') {
|
||||
return substr($v, strrpos($v, '/') + 1);
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class User extends Base
|
|||
'message' => 'The username already exists.'
|
||||
]),
|
||||
'email' => new CallbackValidator([
|
||||
'callback' => function() {
|
||||
'callback' => function () {
|
||||
return $this->findFirstByEmail($this->getEmail()) === false;
|
||||
},
|
||||
'message' => 'The email address already exists.'
|
||||
|
|
@ -69,7 +69,7 @@ class User extends Base
|
|||
];
|
||||
|
||||
$validation = new Validation();
|
||||
foreach($rules as $field => $validator) {
|
||||
foreach ($rules as $field => $validator) {
|
||||
|
||||
// Only validate changed fields.
|
||||
if ($this->hasChanged($field)) {
|
||||
|
|
@ -414,7 +414,7 @@ class User extends Base
|
|||
{
|
||||
return self::findFirst([
|
||||
"(email = :v: OR username = :v:) AND status != :s:",
|
||||
"bind" => [ 'v' => $value, 's' => self::STATUS_DELETED ]
|
||||
"bind" => ['v' => $value, 's' => self::STATUS_DELETED]
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -422,7 +422,7 @@ class User extends Base
|
|||
{
|
||||
return self::findFirst([
|
||||
"email = :email: AND status != :s:",
|
||||
"bind" => [ 'email' => $email, 's' => self::STATUS_DELETED ]
|
||||
"bind" => ['email' => $email, 's' => self::STATUS_DELETED]
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -430,7 +430,7 @@ class User extends Base
|
|||
{
|
||||
return self::findFirst([
|
||||
"username = :username: AND status != :s:",
|
||||
"bind" => [ 'username' => $username, 's' => self::STATUS_DELETED ]
|
||||
"bind" => ['username' => $username, 's' => self::STATUS_DELETED]
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -440,7 +440,7 @@ class User extends Base
|
|||
|
||||
return self::findFirst([
|
||||
"{$column}_id = :id: AND status != :s:",
|
||||
"bind" => [ 'id' => $oauth->getId(), 's' => self::STATUS_DELETED ]
|
||||
"bind" => ['id' => $oauth->getId(), 's' => self::STATUS_DELETED]
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class UserActivation extends Base
|
|||
* @param int $id
|
||||
* @return PasswordLink
|
||||
*/
|
||||
public function setId(int $id) : UserActivation
|
||||
public function setId(int $id): UserActivation
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
|
|
@ -97,7 +97,7 @@ class UserActivation extends Base
|
|||
* @param string $public_id
|
||||
* @return UserActivation
|
||||
*/
|
||||
public function setActivationKey(string $key) : UserActivation
|
||||
public function setActivationKey(string $key): UserActivation
|
||||
{
|
||||
$this->activation_key = $key;
|
||||
return $this;
|
||||
|
|
@ -115,7 +115,7 @@ class UserActivation extends Base
|
|||
* @param int $user_id
|
||||
* @return UserActivation
|
||||
*/
|
||||
public function setUserId(int $user_id) : UserActivation
|
||||
public function setUserId(int $user_id): UserActivation
|
||||
{
|
||||
$this->user_id = $user_id;
|
||||
return $this;
|
||||
|
|
@ -133,7 +133,7 @@ class UserActivation extends Base
|
|||
* @param string $password
|
||||
* @return UserActivation
|
||||
*/
|
||||
public function setPassword(string $password) : UserActivation
|
||||
public function setPassword(string $password): UserActivation
|
||||
{
|
||||
$this->password = $password;
|
||||
return $this;
|
||||
|
|
@ -144,7 +144,7 @@ class UserActivation extends Base
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isUsed() : bool
|
||||
public function isUsed(): bool
|
||||
{
|
||||
return (bool) $this->used;
|
||||
}
|
||||
|
|
@ -154,7 +154,7 @@ class UserActivation extends Base
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid() : bool
|
||||
public function isValid(): bool
|
||||
{
|
||||
// Used links are not valid.
|
||||
if ($this->isUsed()) {
|
||||
|
|
@ -175,9 +175,9 @@ class UserActivation extends Base
|
|||
public function beforeCreate()
|
||||
{
|
||||
// Creating a new link automatically removes old ones.
|
||||
$links = self::find(["user_id = ?0", 'bind' => [ $this->user_id ]]);
|
||||
$links = self::find(["user_id = ?0", 'bind' => [$this->user_id]]);
|
||||
|
||||
foreach($links as $link) {
|
||||
foreach ($links as $link) {
|
||||
$link->delete();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue