Skip to content

Commit

Permalink
Merge pull request #380 from alies-dev/1.x-cleanup
Browse files Browse the repository at this point in the history
1.x cleanup
  • Loading branch information
alies-dev authored Mar 29, 2024
2 parents fbcf944 + 71d12c7 commit 3d13ea2
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 25 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
composer.phar
/laravel/
/lumen/

/vendor/
composer.lock

cache/*.stubphp
.DS_Store
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"illuminate/support": "^6.0 || ^8.0",
"illuminate/view": "^6.0 || ^8.0",
"vimeo/psalm": "^4.8.1",
"orchestra/testbench": "^3.8 || ^4.0 || ^5.0 || ^6.22 || ^7.0",
"orchestra/testbench": "^4.0 || ^6.0",
"barryvdh/laravel-ide-helper": ">=2.8.0"
},
"require-dev": {
Expand All @@ -45,9 +45,11 @@
}
},
"scripts": {
"analyze": "psalm",
"analyze": "@psalm",
"lint": "phpcs -n",
"lint-fix": "phpcbf -n",
"psalm": "psalm",
"psalm-set-baseline": "psalm --set-baseline=psalm-baseline.xml",
"test": "codecept run --skip-group skip",
"check": [
"@analyze",
Expand Down
13 changes: 9 additions & 4 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Throwable;

use function array_merge;
use function class_exists;
use function dirname;
use function explode;
use function glob;
Expand Down Expand Up @@ -57,10 +58,14 @@ protected function getStubsForVersion(string $version): array

private function registerStubs(RegistrationInterface $registration): void
{
$stubs = array_merge(
$this->getCommonStubs(),
$this->getStubsForVersion(Application::VERSION),
);
$stubs = $this->getCommonStubs();

if (class_exists(Application::class)) { // Ensure the class is loaded (for Lumen support
$stubs = array_merge(
$stubs,
$this->getStubsForVersion(Application::VERSION),
);
}

foreach ($stubs as $stubFilePath) {
$registration->addStubFile($stubFilePath);
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion tests/laravel-test-psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
findUnusedCode="true"
resolveFromConfigFile="false"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="../psalm-plugin-laravel/tests/laravel-test-baseline.xml"
errorBaseline="psalm-baseline.xml"
phpVersion="8.0"
>
<projectFiles>
Expand All @@ -17,6 +17,7 @@
<plugins>
<pluginClass class="Psalm\LaravelPlugin\Plugin"/>
</plugins>

<issueHandlers>
<ParamNameMismatch errorLevel="suppress" />
</issueHandlers>
Expand Down
21 changes: 12 additions & 9 deletions tests/laravel-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
set -e

echo "Cleaning Up"
rm -rf ../laravel/
rm -rf ./laravel/

echo "Installing Laravel"
composer create-project laravel/laravel ../laravel 8.6.* --quiet --prefer-dist
cd ../laravel/
composer create-project laravel/laravel ./laravel 8.6.* --quiet --prefer-dist
cd ./laravel/

echo "Adding package from source"
composer config repositories.0 '{"type": "path", "url": "../"}'
composer config minimum-stability 'dev'
COMPOSER_MEMORY_LIMIT=-1 composer require --dev "psalm/plugin-laravel:*" --update-with-all-dependencies

echo "Preparing Laravel"
./artisan make:cast ExampleCast
Expand All @@ -31,10 +36,8 @@ echo "Preparing Laravel"
./artisan make:rule ExampleRule
./artisan make:seeder ExampleSeeder

echo "Adding package from source"
composer config repositories.0 '{"type": "path", "url": "../../"}'
composer config minimum-stability 'dev'
COMPOSER_MEMORY_LIMIT=-1 composer require --dev "psalm/plugin-laravel:*" --update-with-all-dependencies
cp ../tests/laravel-test-psalm.xml ./psalm.xml
cp ../tests/laravel-test-psalm-baseline.xml ./psalm-baseline.xml

echo "Analyzing Laravel"
./vendor/bin/psalm -c ../psalm-plugin-laravel/tests/laravel-test-psalm.xml
echo "Laravel App Analyse"
./vendor/bin/psalm -c
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/lumen-test-psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
findUnusedCode="true"
resolveFromConfigFile="false"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="../psalm-plugin-laravel/tests/lumen-test-baseline.xml"
errorBaseline="psalm-baseline.xml"
phpVersion="8.0"
>
<projectFiles>
Expand Down
15 changes: 9 additions & 6 deletions tests/lumen-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
set -e

echo "Cleaning Up"
rm -rf ../lumen/
rm -rf ./lumen/

echo "Installing Lumen"
composer create-project laravel/lumen ../lumen 8.* --quiet --prefer-dist
cd ../lumen/
composer create-project laravel/lumen ./lumen 8.* --quiet --prefer-dist
cd ./lumen/

echo "Adding package from source"
composer config repositories.0 '{"type": "path", "url": "../../"}'
composer config repositories.0 '{"type": "path", "url": "../"}'
composer config minimum-stability 'dev'
COMPOSER_MEMORY_LIMIT=-1 composer require --dev "psalm/plugin-laravel:*" --update-with-all-dependencies

echo "Analyzing Lumen"
./vendor/bin/psalm -c ../psalm-plugin-laravel/tests/lumen-test-psalm.xml
cp ../tests/lumen-test-psalm.xml ./psalm.xml
cp ../tests/lumen-test-psalm-baseline.xml ./psalm-baseline.xml

echo "Lumen App Analyse"
./vendor/bin/psalm -c

0 comments on commit 3d13ea2

Please sign in to comment.