Skip to content

Commit

Permalink
Merge pull request #27 from owenvoke/feature/php-8.2
Browse files Browse the repository at this point in the history
feat: require PHP 8.2 or later
  • Loading branch information
owenvoke authored Jan 13, 2023
2 parents be8a53e + 1ad70d7 commit 83c9738
Show file tree
Hide file tree
Showing 29 changed files with 139 additions and 105 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
coverage: none

- name: Install composer dependencies
Expand Down
14 changes: 2 additions & 12 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,9 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.0, 8.1]
laravel: [8.*, 9.*]
php: [8.2]
laravel: [9.*]
stability: [prefer-stable]
include:
- laravel: 8.*
testbench: ^6.23
- laravel: 9.*
testbench: ^7.0
exclude:
- os: windows-latest
laravel: 9.*


name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand All @@ -46,7 +37,6 @@ jobs:
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Execute tests
Expand Down
30 changes: 15 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
}
],
"require": {
"php": "^8.0|^8.1",
"illuminate/contracts": "^8.80 || ^9.0",
"nikic/php-parser": "^4.13",
"nunomaduro/termwind": "^1.10",
"spatie/laravel-package-tools": "^1.9.2",
"thecodingmachine/safe": "^2.1"
"php": "^8.2",
"illuminate/contracts": "^9.46",
"nikic/php-parser": "^4.15",
"nunomaduro/termwind": "^1.15",
"spatie/laravel-package-tools": "^1.13.8",
"thecodingmachine/safe": "^2.4"
},
"require-dev": {
"nunomaduro/collision": "^5.10 || ^6.0",
"nunomaduro/larastan": "^1.0 || ^2.0",
"orchestra/testbench": "^6.24 || ^7.0",
"pestphp/pest": "^1.21",
"pestphp/pest-plugin-laravel": "^1.2",
"spatie/laravel-ray": "^1.26",
"worksome/coding-style": "^0.11.0"
"nunomaduro/collision": "^6.4",
"nunomaduro/larastan": "^2.3.4",
"orchestra/testbench": "^7.17",
"pestphp/pest": "^1.22",
"pestphp/pest-plugin-laravel": "^1.3",
"spatie/laravel-ray": "^1.31",
"worksome/coding-style": "^2.3.2"
},
"autoload": {
"psr-4": {
Expand All @@ -44,11 +44,11 @@
}
},
"scripts": {
"lint": "vendor/bin/phpcbf",
"lint": "vendor/bin/ecs --fix",
"test:unit": "vendor/bin/pest",
"test:coverage": "vendor/bin/pest --coverage --min=95",
"test:types": "vendor/bin/phpstan analyse",
"test:style": "vendor/bin/phpcs -n",
"test:style": "vendor/bin/ecs",
"test": [
"@test:style",
"@test:types",
Expand Down
17 changes: 17 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

use Symplify\EasyCodingStandard\Config\ECSConfig;
use Worksome\CodingStyle\WorksomeEcsConfig;


return static function (ECSConfig $ecsConfig): void {
$ecsConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
__DIR__ . '/config',
]);

WorksomeEcsConfig::setup($ecsConfig);
};
32 changes: 0 additions & 32 deletions phpcs.xml

This file was deleted.

23 changes: 23 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Worksome\CodingStyle\WorksomeRectorConfig;

return static function (RectorConfig $rectorConfig): void {
WorksomeRectorConfig::setup($rectorConfig);

$rectorConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

// Define extra rule sets to be applied
$rectorConfig->sets([
// SetList::DEAD_CODE,
]);

// Register extra a single rules
// $rectorConfig->rule(ClassOnObjectRector::class);
};
2 changes: 1 addition & 1 deletion src/Actions/AddEnvironmentVariablesToList.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use Worksome\Envy\Exceptions\ConfigFileNotFoundException;
use Worksome\Envy\Support\PhpParser\AppendEnvironmentVariablesNodeVisitor;

use function Safe\file_put_contents;
use function Safe\file_get_contents;
use function Safe\file_put_contents;

final class AddEnvironmentVariablesToList implements AddsEnvironmentVariablesToList
{
Expand Down
4 changes: 3 additions & 1 deletion src/Actions/FilterEnvironmentCalls.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ public function __construct(

public function __invoke(string $filePath, Collection $environmentCalls): Collection
{
$existingKeys = ($this->readEnvironmentFile)($filePath)->map(fn(EnvironmentVariable $variable) => $variable->getKey());
$existingKeys = ($this->readEnvironmentFile)($filePath)->map(
fn(EnvironmentVariable $variable) => $variable->getKey()
);

return $environmentCalls
->unique(fn(EnvironmentCall $call) => $call->getKey())
Expand Down
4 changes: 3 additions & 1 deletion src/Actions/FindEnvironmentCalls.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public function __invoke(string $filePath, bool $excludeVariablesWithDefaults =
->getEnvironmentVariables()
->when(
$excludeVariablesWithDefaults,
fn (Collection $variables) => $variables->reject(fn (EnvironmentCall $variable) => $variable->getDefault() !== null)
fn (Collection $variables) => $variables->reject(
fn (EnvironmentCall $variable) => $variable->getDefault() !== null
)
);
}
}
4 changes: 3 additions & 1 deletion src/Actions/FindEnvironmentVariablesToPrune.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ public function __construct(

public function __invoke(string $filePath, Collection $environmentCalls): Collection
{
$variablesInEnvironmentCalls = $environmentCalls->map(fn(EnvironmentCall $environmentCall) => $environmentCall->getKey());
$variablesInEnvironmentCalls = $environmentCalls->map(
fn(EnvironmentCall $environmentCall) => $environmentCall->getKey()
);

return $this->environmentVariables($filePath)
->diff($variablesInEnvironmentCalls)
Expand Down
2 changes: 1 addition & 1 deletion src/Actions/PruneEnvironmentFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use Worksome\Envy\Contracts\Actions\PrunesEnvironmentFile;

use function Safe\file_get_contents;
use function Safe\preg_replace;
use function Safe\file_put_contents;
use function Safe\preg_replace;

final class PruneEnvironmentFile implements PrunesEnvironmentFile
{
Expand Down
4 changes: 3 additions & 1 deletion src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ public function handle(): int
{
$this->call('vendor:publish', ['--tag' => 'envy-config']);

$this->information('Alright, Envy is ready to rock! Get started with either `php artisan envy:sync` or `php artisan envy:prune`.');
$this->information(
'Alright, Envy is ready to rock! Get started with either `php artisan envy:sync` or `php artisan envy:prune`.'
);

return self::SUCCESS;
}
Expand Down
1 change: 1 addition & 0 deletions src/Commands/PruneCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function handle(Envy $envy): int

/**
* @return Collection<string, Collection<int, string>>
*
* @throws EnvironmentFileNotFoundException
*/
private function getPendingPrunes(Envy $envy): Collection
Expand Down
1 change: 1 addition & 0 deletions src/Commands/SyncCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public function handle(Envy $envy, Repository $config): int

/**
* @return Collection<string, Collection<int, EnvironmentCall>>
*
* @throws EnvironmentFileNotFoundException
*/
private function getPendingPrunes(Envy $envy, Repository $config): Collection
Expand Down
3 changes: 2 additions & 1 deletion src/Contracts/Actions/AddsEnvironmentVariablesToList.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ interface AddsEnvironmentVariablesToList
* Add all given environment variables to the given list key in the envy config.
*
* @param Collection<int, EnvironmentVariable> $updates
*
* @throws ConfigFileNotFoundException Thrown when the envy config file hasn't been published.
* @throws InvalidArgumentException Thrown when the envy config file doesn't contain the given key.
* @throws InvalidArgumentException Thrown when the envy config file doesn't contain the given key.
*/
public function __invoke(Collection $updates, string $listKey): void;
}
2 changes: 2 additions & 0 deletions src/Contracts/Actions/FiltersEnvironmentCalls.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ interface FiltersEnvironmentCalls
{
/**
* @param Collection<int, EnvironmentCall> $environmentCalls
*
* @return Collection<int, EnvironmentCall>
*
* @throws EnvironmentFileNotFoundException
*/
public function __invoke(string $filePath, Collection $environmentCalls): Collection;
Expand Down
2 changes: 2 additions & 0 deletions src/Contracts/Actions/FindsEnvironmentVariablesToPrune.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ interface FindsEnvironmentVariablesToPrune
{
/**
* @param Collection<int, EnvironmentCall> $environmentCalls
*
* @return Collection<int, string>
*
* @throws EnvironmentFileNotFoundException
*/
public function __invoke(string $filePath, Collection $environmentCalls): Collection;
Expand Down
1 change: 1 addition & 0 deletions src/Contracts/Actions/ParsesFilterList.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface ParsesFilterList
{
/**
* @param array<int, string|Filter> $list
*
* @return array<int, Filter>
*/
public function __invoke(array $list): array;
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/Actions/UpdatesEnvironmentFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
interface UpdatesEnvironmentFile
{
/**
* @param string $filePath
* @param string $filePath
* @param Collection<int, EnvironmentCall> $environmentCalls
*/
public function __invoke(string $filePath, Collection $environmentCalls): void;
Expand Down
12 changes: 9 additions & 3 deletions src/Envy.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
namespace Worksome\Envy;

use Illuminate\Support\Collection;
use Worksome\Envy\Contracts\Actions\AddsEnvironmentVariablesToList;
use Worksome\Envy\Contracts\Actions\FiltersEnvironmentCalls;
use Worksome\Envy\Contracts\Actions\FindsEnvironmentCalls;
use Worksome\Envy\Contracts\Actions\AddsEnvironmentVariablesToList;
use Worksome\Envy\Contracts\Actions\FindsEnvironmentVariablesToPrune;
use Worksome\Envy\Contracts\Actions\PrunesEnvironmentFile;
use Worksome\Envy\Contracts\Actions\UpdatesEnvironmentFile;
Expand Down Expand Up @@ -49,8 +49,10 @@ public function environmentCalls(bool $excludeCallsWithDefaults = false): Collec
* @see Envy::environmentCalls()
*
* @param Collection<int, EnvironmentCall> $environmentCalls
* @param array<int, string>|null $environmentFilePaths
* @param array<int, string>|null $environmentFilePaths
*
* @return Collection<string, Collection<int, EnvironmentCall>>
*
* @throws EnvironmentFileNotFoundException
*/
public function pendingUpdates(Collection $environmentCalls, array|null $environmentFilePaths = null): Collection
Expand Down Expand Up @@ -81,6 +83,7 @@ public function updateEnvironmentFiles(Collection $pendingUpdates): void
* environment variables and update the config exclusions.
*
* @param Collection<string, Collection<int, EnvironmentCall>> $pendingUpdates
*
* @throws Exceptions\ConfigFileNotFoundException
*/
public function updateExclusionsWithPendingUpdates(Collection $pendingUpdates): void
Expand Down Expand Up @@ -113,8 +116,10 @@ public function hasPublishedConfigFile(): bool
* @see Envy::environmentCalls()
*
* @param Collection<int, EnvironmentCall> $environmentCalls
* @param array<int, string>|null $environmentFilePaths
* @param array<int, string>|null $environmentFilePaths
*
* @return Collection<string, Collection<int, string>>
*
* @throws EnvironmentFileNotFoundException
*/
public function pendingPrunes(Collection $environmentCalls, array|null $environmentFilePaths = null): Collection
Expand Down Expand Up @@ -147,6 +152,7 @@ public function pruneEnvironmentFiles(Collection $pendingPrunes): void
* @see Envy::pendingPrunes()
*
* @param Collection<string, Collection<int, string>> $pendingPrunes
*
* @throws Exceptions\ConfigFileNotFoundException
*/
public function updateInclusionsWithPendingPrunes(Collection $pendingPrunes): void
Expand Down
Loading

0 comments on commit 83c9738

Please sign in to comment.