From 379e9ab4403b849a8fda482f6cd8696c369ea51f Mon Sep 17 00:00:00 2001 From: Shawn Hooper Date: Wed, 5 Mar 2025 22:16:16 -0500 Subject: [PATCH 1/7] Replace abanonded larastan repository --- composer.json | 2 +- composer.lock | 189 +++++++++++++++++++++++++------------------------- 2 files changed, 95 insertions(+), 96 deletions(-) diff --git a/composer.json b/composer.json index 0d89e5d..090acb9 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "require-dev": { "laravel/pint": "^1.5", "nunomaduro/collision": "^6.4", - "nunomaduro/larastan": "^2.4.1", + "larastan/larastan": "^2.4.1", "orchestra/testbench": "^7.22", "pestphp/pest": "^1.22", "pestphp/pest-plugin-laravel": "^1.1", diff --git a/composer.lock b/composer.lock index c821620..fe045ba 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "fdeb48ede1748f898825a4a057aac1fc", + "content-hash": "ebb7367174dd56b3d387e77709193917", "packages": [ { "name": "brick/math", @@ -5372,6 +5372,99 @@ }, "time": "2024-11-18T16:19:46+00:00" }, + { + "name": "larastan/larastan", + "version": "v2.9.14", + "source": { + "type": "git", + "url": "https://github.com/larastan/larastan.git", + "reference": "78f7f8da613e54edb2ab4afa5bede045228fb843" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/larastan/larastan/zipball/78f7f8da613e54edb2ab4afa5bede045228fb843", + "reference": "78f7f8da613e54edb2ab4afa5bede045228fb843", + "shasum": "" + }, + "require": { + "ext-json": "*", + "illuminate/console": "^9.52.16 || ^10.28.0 || ^11.16", + "illuminate/container": "^9.52.16 || ^10.28.0 || ^11.16", + "illuminate/contracts": "^9.52.16 || ^10.28.0 || ^11.16", + "illuminate/database": "^9.52.16 || ^10.28.0 || ^11.16", + "illuminate/http": "^9.52.16 || ^10.28.0 || ^11.16", + "illuminate/pipeline": "^9.52.16 || ^10.28.0 || ^11.16", + "illuminate/support": "^9.52.16 || ^10.28.0 || ^11.16", + "php": "^8.0.2", + "phpmyadmin/sql-parser": "^5.9.0", + "phpstan/phpstan": "^1.12.17" + }, + "require-dev": { + "doctrine/coding-standard": "^12.0", + "laravel/framework": "^9.52.16 || ^10.28.0 || ^11.16", + "mockery/mockery": "^1.5.1", + "nikic/php-parser": "^4.19.1", + "orchestra/canvas": "^7.11.1 || ^8.11.0 || ^9.0.2", + "orchestra/testbench-core": "^7.33.0 || ^8.13.0 || ^9.0.9", + "phpstan/phpstan-deprecation-rules": "^1.2", + "phpunit/phpunit": "^9.6.13 || ^10.5.16" + }, + "suggest": { + "orchestra/testbench": "Using Larastan for analysing a package needs Testbench" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + }, + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "Larastan\\Larastan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Can Vural", + "email": "can9119@gmail.com" + }, + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "description": "Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel", + "keywords": [ + "PHPStan", + "code analyse", + "code analysis", + "larastan", + "laravel", + "package", + "php", + "static analysis" + ], + "support": { + "issues": "https://github.com/larastan/larastan/issues", + "source": "https://github.com/larastan/larastan/tree/v2.9.14" + }, + "funding": [ + { + "url": "https://github.com/canvural", + "type": "github" + } + ], + "time": "2025-02-06T21:03:14+00:00" + }, { "name": "laravel/pint", "version": "v1.21.0", @@ -5793,100 +5886,6 @@ ], "time": "2023-01-03T12:54:54+00:00" }, - { - "name": "nunomaduro/larastan", - "version": "v2.9.14", - "source": { - "type": "git", - "url": "https://github.com/larastan/larastan.git", - "reference": "78f7f8da613e54edb2ab4afa5bede045228fb843" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/larastan/larastan/zipball/78f7f8da613e54edb2ab4afa5bede045228fb843", - "reference": "78f7f8da613e54edb2ab4afa5bede045228fb843", - "shasum": "" - }, - "require": { - "ext-json": "*", - "illuminate/console": "^9.52.16 || ^10.28.0 || ^11.16", - "illuminate/container": "^9.52.16 || ^10.28.0 || ^11.16", - "illuminate/contracts": "^9.52.16 || ^10.28.0 || ^11.16", - "illuminate/database": "^9.52.16 || ^10.28.0 || ^11.16", - "illuminate/http": "^9.52.16 || ^10.28.0 || ^11.16", - "illuminate/pipeline": "^9.52.16 || ^10.28.0 || ^11.16", - "illuminate/support": "^9.52.16 || ^10.28.0 || ^11.16", - "php": "^8.0.2", - "phpmyadmin/sql-parser": "^5.9.0", - "phpstan/phpstan": "^1.12.17" - }, - "require-dev": { - "doctrine/coding-standard": "^12.0", - "laravel/framework": "^9.52.16 || ^10.28.0 || ^11.16", - "mockery/mockery": "^1.5.1", - "nikic/php-parser": "^4.19.1", - "orchestra/canvas": "^7.11.1 || ^8.11.0 || ^9.0.2", - "orchestra/testbench-core": "^7.33.0 || ^8.13.0 || ^9.0.9", - "phpstan/phpstan-deprecation-rules": "^1.2", - "phpunit/phpunit": "^9.6.13 || ^10.5.16" - }, - "suggest": { - "orchestra/testbench": "Using Larastan for analysing a package needs Testbench" - }, - "type": "phpstan-extension", - "extra": { - "phpstan": { - "includes": [ - "extension.neon" - ] - }, - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "psr-4": { - "Larastan\\Larastan\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Can Vural", - "email": "can9119@gmail.com" - }, - { - "name": "Nuno Maduro", - "email": "enunomaduro@gmail.com" - } - ], - "description": "Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel", - "keywords": [ - "PHPStan", - "code analyse", - "code analysis", - "larastan", - "laravel", - "package", - "php", - "static analysis" - ], - "support": { - "issues": "https://github.com/larastan/larastan/issues", - "source": "https://github.com/larastan/larastan/tree/v2.9.14" - }, - "funding": [ - { - "url": "https://github.com/canvural", - "type": "github" - } - ], - "abandoned": "larastan/larastan", - "time": "2025-02-06T21:03:14+00:00" - }, { "name": "orchestra/canvas", "version": "v7.12.0", From 220821b6bf73585a24bcef868ede0fbd2ddc6135 Mon Sep 17 00:00:00 2001 From: Shawn Hooper Date: Wed, 5 Mar 2025 22:31:30 -0500 Subject: [PATCH 2/7] Fix: Abandoned dependency, repo moved --- composer.json | 2 +- composer.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 090acb9..8bdad7d 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "require-dev": { "laravel/pint": "^1.5", "nunomaduro/collision": "^6.4", - "larastan/larastan": "^2.4.1", + "larastan/larastan": "^2.9.14", "orchestra/testbench": "^7.22", "pestphp/pest": "^1.22", "pestphp/pest-plugin-laravel": "^1.1", diff --git a/composer.lock b/composer.lock index fe045ba..1a365ca 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ebb7367174dd56b3d387e77709193917", + "content-hash": "edbd2c865c550a5d0a07c4fd3efa8ebc", "packages": [ { "name": "brick/math", From 9c94fe077cc052526fde77f0af3fa4f58369a8af Mon Sep 17 00:00:00 2001 From: Shawn Hooper Date: Wed, 5 Mar 2025 22:31:36 -0500 Subject: [PATCH 3/7] Fix: Unsafe usage of new static() --- src/Api/Collection.php | 2 +- src/Api/Interfaces/ModelInterface.php | 8 ++++++++ src/Api/Model.php | 5 +++-- 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 src/Api/Interfaces/ModelInterface.php diff --git a/src/Api/Collection.php b/src/Api/Collection.php index 9f9c54b..1b9a64f 100644 --- a/src/Api/Collection.php +++ b/src/Api/Collection.php @@ -10,7 +10,7 @@ class Collection extends \Illuminate\Support\Collection protected int $total = 0; protected $after; - public static function hydrate(array $response, string $className): static + public static function hydrate(array $response, string $className): self { $instance = new static($response['results']); $instance = $instance->map(fn($payload) => $className::hydrate($payload)); diff --git a/src/Api/Interfaces/ModelInterface.php b/src/Api/Interfaces/ModelInterface.php new file mode 100644 index 0000000..dd93465 --- /dev/null +++ b/src/Api/Interfaces/ModelInterface.php @@ -0,0 +1,8 @@ +fill($properties); } - public static function hydrate(array $payload = []): static + public static function hydrate(array $payload = []): self { $instance = new static; $instance->init($payload); From 7760576c20a3d2a43f66d50c459195a7eb224cdb Mon Sep 17 00:00:00 2001 From: Shawn Hooper Date: Wed, 5 Mar 2025 22:36:47 -0500 Subject: [PATCH 4/7] Fix: Roll back larastan version update --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8bdad7d..090acb9 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "require-dev": { "laravel/pint": "^1.5", "nunomaduro/collision": "^6.4", - "larastan/larastan": "^2.9.14", + "larastan/larastan": "^2.4.1", "orchestra/testbench": "^7.22", "pestphp/pest": "^1.22", "pestphp/pest-plugin-laravel": "^1.1", From 15c248096a0ae43f64dfae7072c65defb313075d Mon Sep 17 00:00:00 2001 From: Shawn Hooper Date: Wed, 5 Mar 2025 22:36:51 -0500 Subject: [PATCH 5/7] Fix: Roll back larastan version update --- composer.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.lock b/composer.lock index 1a365ca..fe045ba 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "edbd2c865c550a5d0a07c4fd3efa8ebc", + "content-hash": "ebb7367174dd56b3d387e77709193917", "packages": [ { "name": "brick/math", From c9dcef6fe5cc2eefff61e85c6642a4498a0056ab Mon Sep 17 00:00:00 2001 From: Shawn Hooper Date: Wed, 5 Mar 2025 22:48:13 -0500 Subject: [PATCH 6/7] Add missing implementation --- .github/workflows/phpstan.yml | 29 +++++++++++++++++++++++++++++ src/Api/Collection.php | 5 +++-- 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/phpstan.yml diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 0000000..96ab80b --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,29 @@ +name: PHPStan + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + phpstan: + name: phpstan + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + coverage: none + + - uses: "ramsey/composer-install@v2" + + - name: Install composer dependencies (need autoloader built) + run: | + composer install --no-scripts + + - name: Run PHPStan + run: ./vendor/bin/phpstan --error-format=github diff --git a/src/Api/Collection.php b/src/Api/Collection.php index 1b9a64f..6a0c994 100644 --- a/src/Api/Collection.php +++ b/src/Api/Collection.php @@ -3,14 +3,15 @@ namespace STS\HubSpot\Api; use Illuminate\Support\Arr; +use STS\HubSpot\Api\Interfaces\ModelInterface; -class Collection extends \Illuminate\Support\Collection +class Collection extends \Illuminate\Support\Collection implements ModelInterface { protected array $response = []; protected int $total = 0; protected $after; - public static function hydrate(array $response, string $className): self + public static function hydrate(array $response, string $className): static { $instance = new static($response['results']); $instance = $instance->map(fn($payload) => $className::hydrate($payload)); From 774fc3ae45e511945734d4eb0374e0bb4f86199d Mon Sep 17 00:00:00 2001 From: Shawn Hooper Date: Wed, 5 Mar 2025 22:55:35 -0500 Subject: [PATCH 7/7] Fix larastan errors up to level 2 --- phpstan.neon | 4 ++++ src/Api/Model.php | 2 ++ 2 files changed, 6 insertions(+) create mode 100644 phpstan.neon diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..83e9c62 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,4 @@ +parameters: + level: 2 + paths: + - src/ \ No newline at end of file diff --git a/src/Api/Model.php b/src/Api/Model.php index f759bd9..260b628 100644 --- a/src/Api/Model.php +++ b/src/Api/Model.php @@ -16,6 +16,8 @@ /** * @property-read Collection $definitions + * @property-read int $id + * @method array properties() */ abstract class Model implements ModelInterface {