diff --git a/.github/smoke-test.php b/.github/smoke-test.php new file mode 100644 index 0000000..6ff3ad8 --- /dev/null +++ b/.github/smoke-test.php @@ -0,0 +1,46 @@ +getMessage() . "\n"); + exit(1); + } + echo " [OK] $class\n"; +} + +echo "\nChecking service provider registration:\n"; +try { + $app = new \Illuminate\Container\Container(); + $provider = new \Vimeo\Laravel\VimeoServiceProvider($app); + $provider->register(); +} catch (\Throwable $e) { + fwrite(STDERR, "FAIL: error registering service provider: " . $e->getMessage() . "\n"); + exit(1); +} + +foreach (['vimeo', 'vimeo.factory', 'vimeo.connection'] as $binding) { + if (!$app->bound($binding)) { + fwrite(STDERR, "FAIL: '$binding' not bound in container\n"); + exit(1); + } + echo " [OK] '$binding' registered\n"; +} + +echo "\nAll smoke tests passed!\n"; diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml new file mode 100644 index 0000000..5abec09 --- /dev/null +++ b/.github/workflows/integration.yml @@ -0,0 +1,40 @@ +name: PHP Compatibility + +on: + push: + branches: [master] + pull_request: + +jobs: + integration: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php: ['7.4', '8.0', '8.2', '8.4'] + + name: PHP ${{ matrix.php }} (integration) + + steps: + - uses: actions/checkout@v4 + with: + path: package + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + + - name: Create test app + run: | + mkdir test-app + echo '{"minimum-stability":"dev","prefer-stable":true,"require":{"vimeo/laravel":"*","illuminate/container":"*"},"repositories":[{"type":"path","url":"../package","options":{"symlink":false}}]}' > test-app/composer.json + + - name: Install dependencies + working-directory: test-app + run: composer install --no-dev --no-interaction --prefer-dist + + - name: Run smoke test + working-directory: test-app + run: php ../package/.github/smoke-test.php diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..f7078e3 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,34 @@ +name: Tests + +on: + push: + branches: [master] + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php: ['8.2', '8.3', '8.4'] + + name: PHP ${{ matrix.php }} + + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + + - name: Install dependencies + run: composer install --no-interaction + + - name: Run tests + run: vendor/bin/phpunit + + - name: Run Psalm + run: vendor/bin/psalm diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4775116..0000000 --- a/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: php - -php: - - 7.2 - - 7.3 - -sudo: false - -install: - - travis_retry composer install --no-interaction - -script: - - vendor/bin/phpunit --coverage-clover clover.xml - - vendor/bin/psalm --shepherd - -after_script: - - bash <(curl -s https://codecov.io/bash) diff --git a/composer.json b/composer.json index 176f018..b99751c 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ } ], "require": { - "php": "^7.2|^8.0", + "php": "^7.4|^8.0", "illuminate/contracts": "^5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0", "illuminate/support": "^5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0", "graham-campbell/manager": "^5.0", @@ -32,7 +32,7 @@ "mockery/mockery": "^1.0", "phpunit/phpunit": "^7.0|^9.5.10|^10.5|^11.0", "psalm/plugin-laravel": "^1.4.0|^1.1|^2.7|^3.0", - "laravel/lumen-framework": "^5.7", + "laravel/lumen-framework": "^5.7|^9.0|^10.0|^11.0", "vimeo/psalm": "^3.17|^4.19|^5.6|^6.8" }, "autoload": { diff --git a/src/Facades/Vimeo.php b/src/Facades/Vimeo.php index c2adeb8..4227788 100644 --- a/src/Facades/Vimeo.php +++ b/src/Facades/Vimeo.php @@ -25,6 +25,8 @@ * This is the Vimeo facade class. * * @author Vincent Klaiber + * + * @psalm-api */ class Vimeo extends Facade { @@ -33,6 +35,7 @@ class Vimeo extends Facade * * @return string */ + #[\Override] protected static function getFacadeAccessor(): string { return 'vimeo'; diff --git a/src/VimeoFactory.php b/src/VimeoFactory.php index b40ad2c..e9b70cf 100644 --- a/src/VimeoFactory.php +++ b/src/VimeoFactory.php @@ -27,6 +27,8 @@ * The is the Vimeo factory class. * * @author Vincent Klaiber + * + * @psalm-api */ class VimeoFactory { diff --git a/src/VimeoManager.php b/src/VimeoManager.php index 5aebb16..671da75 100644 --- a/src/VimeoManager.php +++ b/src/VimeoManager.php @@ -27,6 +27,8 @@ * This is the Vimeo manager class. * * @author Vincent Klaiber + * + * @psalm-api */ class VimeoManager extends AbstractManager { @@ -57,8 +59,11 @@ public function __construct(Repository $config, VimeoFactory $factory) * * @param array $config * + * @psalm-suppress MethodSignatureMismatch + * * @return \Vimeo\Vimeo */ + #[\Override] protected function createConnection(array $config): Vimeo { /** @var string[] $config */ @@ -70,16 +75,13 @@ protected function createConnection(array $config): Vimeo * * @return string */ + #[\Override] protected function getConfigName(): string { return 'vimeo'; } - /** - * Get the factory instance. - * - * @return \Vimeo\Laravel\VimeoFactory - */ + /** @psalm-api */ public function getFactory(): VimeoFactory { return $this->factory; diff --git a/src/VimeoServiceProvider.php b/src/VimeoServiceProvider.php index 8e3d37a..950d395 100644 --- a/src/VimeoServiceProvider.php +++ b/src/VimeoServiceProvider.php @@ -29,6 +29,8 @@ * This is the Vimeo service provider class. * * @author Vincent Klaiber + * + * @psalm-api */ class VimeoServiceProvider extends ServiceProvider { @@ -51,7 +53,7 @@ protected function setupConfig() { $source = realpath(__DIR__.'/../config/vimeo.php'); - if (!$source) { + if ($source === false) { throw new \UnexpectedValueException('Could not locate config'); } @@ -69,6 +71,7 @@ protected function setupConfig() * * @return void */ + #[\Override] public function register() { $this->registerFactory(); @@ -99,9 +102,9 @@ protected function registerManager() { $this->app->singleton('vimeo', function (Container $app) : VimeoManager { /** @var \Illuminate\Contracts\Config\Repository */ - $config = $app['config']; + $config = $app->make('config'); /** @var \Vimeo\Laravel\VimeoFactory */ - $factory = $app['vimeo.factory']; + $factory = $app->make('vimeo.factory'); return new VimeoManager($config, $factory); }); @@ -118,7 +121,7 @@ protected function registerBindings() { $this->app->bind('vimeo.connection', function (Container $app) : Vimeo { /** @var VimeoManager */ - $manager = $app['vimeo']; + $manager = $app->make('vimeo'); /** @var Vimeo */ return $manager->connection(); @@ -132,6 +135,7 @@ protected function registerBindings() * * @return string[] */ + #[\Override] public function provides(): array { return [ diff --git a/tests/AbstractTestCase.php b/tests/AbstractTestCase.php index 95a415f..2496384 100644 --- a/tests/AbstractTestCase.php +++ b/tests/AbstractTestCase.php @@ -36,7 +36,7 @@ abstract class AbstractTestCase extends AbstractPackageTestCase * * @return string */ - protected function getServiceProviderClass($app) + protected static function getServiceProviderClass(): string { return VimeoServiceProvider::class; } diff --git a/tests/AnalysisTest.php b/tests/AnalysisTest.php index d193cea..b0994f7 100644 --- a/tests/AnalysisTest.php +++ b/tests/AnalysisTest.php @@ -37,7 +37,7 @@ class AnalysisTest extends TestCase * * @return string[] */ - protected function getPaths() + protected static function getPaths(): array { return [ realpath(__DIR__.'/../config'), @@ -51,7 +51,7 @@ protected function getPaths() * * @return string[] */ - protected function getIgnored() + protected static function getIgnored() { return [Application::class]; } diff --git a/tests/Facades/VimeoTest.php b/tests/Facades/VimeoTest.php index 8cb47c4..78cdbba 100644 --- a/tests/Facades/VimeoTest.php +++ b/tests/Facades/VimeoTest.php @@ -38,7 +38,7 @@ class VimeoTest extends AbstractTestCase * * @return string */ - protected function getFacadeAccessor() + protected static function getFacadeAccessor(): string { return 'vimeo'; } @@ -48,7 +48,7 @@ protected function getFacadeAccessor() * * @return string */ - protected function getFacadeClass() + protected static function getFacadeClass(): string { return Vimeo::class; } @@ -58,7 +58,7 @@ protected function getFacadeClass() * * @return string */ - protected function getFacadeRoot() + protected static function getFacadeRoot(): string { return VimeoManager::class; } diff --git a/tests/VimeoFactoryTest.php b/tests/VimeoFactoryTest.php index 4d97f51..2398ea4 100644 --- a/tests/VimeoFactoryTest.php +++ b/tests/VimeoFactoryTest.php @@ -42,11 +42,10 @@ public function testMakeStandard() $this->assertInstanceOf(Vimeo::class, $return); } - /** - * @expectedException \InvalidArgumentException - */ public function testMakeWithoutClientId() { + $this->expectException(\InvalidArgumentException::class); + $factory = $this->getVimeoFactory(); $factory->make([ @@ -54,11 +53,10 @@ public function testMakeWithoutClientId() ]); } - /** - * @expectedException \InvalidArgumentException - */ public function testMakeWithoutClientSecret() { + $this->expectException(\InvalidArgumentException::class); + $factory = $this->getVimeoFactory(); $factory->make([