Skip to content

Commit

Permalink
Test on PHP 8.2 (#607)
Browse files Browse the repository at this point in the history
* Test on PHP 8.2

* wip

* Update AbstractUser.php

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
driesvints and taylorotwell authored Nov 8, 2022
1 parent 20f076b commit 1cd1682
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: tests

on:
push:
branches:
- master
- '*.x'
pull_request:
schedule:
- cron: '0 0 * * *'
Expand All @@ -13,7 +16,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [7.2, 7.3, 7.4, 8.0, 8.1]
php: [7.2, 7.3, 7.4, 8.0, 8.1, 8.2]
laravel: [^6.0, ^7.0, ^8.0, ^9.0]
exclude:
- php: 7.2
Expand All @@ -28,6 +31,12 @@ jobs:
laravel: ^6.0
- php: 8.1
laravel: ^7.0
- php: 8.2
laravel: ^6.0
- php: 8.2
laravel: ^7.0
- php: 8.2
laravel: ^8.0

name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}

Expand Down
24 changes: 23 additions & 1 deletion src/AbstractUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ abstract class AbstractUser implements ArrayAccess, User
*/
public $user;

/**
* The user's other attributes.
*
* @var array
*/
public $attributes = [];

/**
* Get the unique identifier for the user.
*
Expand Down Expand Up @@ -130,8 +137,12 @@ public function setRaw(array $user)
*/
public function map(array $attributes)
{
$this->attributes = $attributes;

foreach ($attributes as $key => $value) {
$this->{$key} = $value;
if (property_exists($this, $key)) {
$this->{$key} = $value;
}
}

return $this;
Expand Down Expand Up @@ -185,4 +196,15 @@ public function offsetUnset($offset)
{
unset($this->user[$offset]);
}

/**
* Get a user attribute value dynamically.
*
* @param string $key
* @return void
*/
public function __get($key)
{
return $this->attributes[$key] ?? null;
}
}

0 comments on commit 1cd1682

Please sign in to comment.