diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000000..aff5edb4b3 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,51 @@ +name: Tests + +on: + push: + branches: + - develop + - master + - main + - 'feat/**' + - 'fix/**' + - 'chore/**' + pull_request: + branches: + - develop + - master + - main + +jobs: + tests: + name: PHP ${{ matrix.php-version }} + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php-version: + - '8.2' + - '8.4' + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: none + tools: composer:v2 + + - name: Validate composer.json + run: composer validate --no-check-publish --no-check-lock + + - name: Install dependencies + run: composer update --prefer-dist --no-interaction --no-progress + + - name: Lint PHP source + run: find src -name '*.php' -print0 | xargs -0 -n1 -P4 php -l + + - name: Check autoloader + run: php -r "require 'vendor/autoload.php'; class_exists('Okta\\\\Client') or exit(1);" diff --git a/composer.json b/composer.json index 09a71339e2..e762f4e236 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ } ], "require": { - "php": "^7.3 | ^8.0", + "php": "^8.2 || ^8.4", "psr/http-message": "^1.0", "php-http/client-common": "^2.2", "php-http/httplug": "^2.2", @@ -19,7 +19,7 @@ "php-http/curl-client": "^2.2", "symfony/yaml": "^3.2|^4.3|^5.0", "nesbot/carbon": "^2.0", - "illuminate/collections": "^8.29.0", + "illuminate/collections": "^10.0 || ^11.0 || ^12.0", "guzzlehttp/psr7": "^1.7.0", "psr/cache": "^1.0", "league/flysystem-memory": "^1.0", diff --git a/src/Cache/MemoryManager.php b/src/Cache/MemoryManager.php index acbbd907c2..ac508de51c 100644 --- a/src/Cache/MemoryManager.php +++ b/src/Cache/MemoryManager.php @@ -25,7 +25,7 @@ class MemoryManager extends CacheManager { - public function __construct(AbstractAdapter $adapter = null) + public function __construct(?AbstractAdapter $adapter = null) { if(null === $adapter) { $adapter = new MemoryAdapter(); diff --git a/src/Client.php b/src/Client.php index 6705ee8ba5..5a542bb549 100644 --- a/src/Client.php +++ b/src/Client.php @@ -81,10 +81,10 @@ class Client public function __construct( string $token, string $organizationUrl, - HttpClient $httpClient = null, + ?HttpClient $httpClient = null, string $integrationUserAgent = null, - CacheManager $cacheManager = null, - AuthorizationMode $authorizationMode = null + ?CacheManager $cacheManager = null, + ?AuthorizationMode $authorizationMode = null ) { $this->token = $token; $this->organizationUrl = $organizationUrl; diff --git a/src/DataStore/DefaultDataStore.php b/src/DataStore/DefaultDataStore.php index 72d6e20b15..4eab1f8eef 100644 --- a/src/DataStore/DefaultDataStore.php +++ b/src/DataStore/DefaultDataStore.php @@ -89,7 +89,7 @@ class DefaultDataStore * @param HttpClient|NULL $httpClient * @param AuthorizationMode|NULL $authorizationMode */ - public function __construct(string $token, string $organizationUrl, HttpClient $httpClient = null, AuthorizationMode $authorizationMode = null) + public function __construct(string $token, string $organizationUrl, ?HttpClient $httpClient = null, ?AuthorizationMode $authorizationMode = null) { $this->token = $token; $this->organizationUrl = $organizationUrl; @@ -121,7 +121,7 @@ public function __construct(string $token, string $organizationUrl, HttpClient $ * @param array $options Any options you want to set. * @return object */ - public function instantiate(string $class, \stdClass $properties = null, array $options = []) + public function instantiate(string $class, ?\stdClass $properties = null, array $options = []) { $propertiesArr = array($properties, $options); diff --git a/src/Exceptions/ResourceException.php b/src/Exceptions/ResourceException.php index 7069a9b386..4f79992194 100644 --- a/src/Exceptions/ResourceException.php +++ b/src/Exceptions/ResourceException.php @@ -23,7 +23,7 @@ class ResourceException extends GeneralException { private $error; - public function __construct(Error $error, Throwable $previous = null) + public function __construct(Error $error, ?Throwable $previous = null) { $this->error = $error; $message = $error->getErrorSummary() ?: ''; diff --git a/src/Okta.php b/src/Okta.php index 1bc7acb988..f253cc50f4 100644 --- a/src/Okta.php +++ b/src/Okta.php @@ -30,7 +30,7 @@ class Okta const VERSION = '1.3.0'; - public function __construct(Client $client = null, DefaultDataStore $dataStore = null) + public function __construct(?Client $client = null, ?DefaultDataStore $dataStore = null) { $this->client = $client ?: Client::getInstance(); $this->dataStore = $dataStore ?: $this->client->getDataStore(); diff --git a/src/Resource/AbstractResource.php b/src/Resource/AbstractResource.php index 7345329f8c..a4d88ca198 100644 --- a/src/Resource/AbstractResource.php +++ b/src/Resource/AbstractResource.php @@ -65,7 +65,7 @@ abstract class AbstractResource * @param \stdClass|NULL $properties Properties for the resource. * @param array $options Options to use on the resource. */ - public function __construct(DefaultDataStore $dataStore = null, \stdClass $properties = null, array $options = []) + public function __construct(?DefaultDataStore $dataStore = null, ?\stdClass $properties = null, array $options = []) { $this->dataStore = $dataStore ?: Client::getInstance()->getDataStore(); $this->setProperties($properties); @@ -90,7 +90,7 @@ public function getHref() * @param \stdClass|NULL $properties the properties to set. * @return self */ - public function setProperties(\stdClass $properties = null): self + public function setProperties(?\stdClass $properties = null): self { $this->dirty = false;