Skip to content

Commit

Permalink
Upgrade project
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed May 25, 2021
1 parent e56191f commit c817a61
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 57 deletions.
29 changes: 0 additions & 29 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,42 +1,13 @@
root = true

[*]
# Change these settings to your own preference
indent_style = space
indent_size = 4

# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true


[*.json]
indent_style = space
indent_size = 2

[*.md]
indent_style = space
indent_size = 4
trim_trailing_whitespace = false

[*.neon]
indent_style = tab
indent_size = 4

[*.php]
indent_style = space
indent_size = 4

[composer.json]
indent_style = space
indent_size = 4

[phpstan.neon]
indent_style = tab
indent_size = 4

[phpunit.xml{,.dist}]
indent_style = space
indent_size = 4
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/easy-coding-standard.yaml export-ignore
/phpstan.neon export-ignore
/ecs.php export-ignore
/psalm.xml export-ignore
/phpunit.xml.dist export-ignore
/README.md export-ignore
/tests export-ignore
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:

steps:
- name: "Checkout"
uses: "actions/checkout@v2.3.3"
uses: "actions/checkout@v2"

- name: "Install PHP with extensions"
uses: "shivammathur/setup-php@2.7.0"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
extensions: "${{ env.PHP_EXTENSIONS }}"
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Setono
Copyright (c) 2021 Setono

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
}
],
"require": {
"php": "^7.4",
"php": ">=7.4",
"deployer/deployer": "^6.8",
"symfony/console": "^4.4 || ^5.0",
"symfony/dotenv": "^4.4 || ^5.0",
"thecodingmachine/safe": "^1.2"
"webmozart/assert": "^1.10"
},
"require-dev": {
"phpunit/phpunit": "^9.4",
"setono/code-quality-pack": "^1.4"
"phpunit/phpunit": "^9.5",
"setono/code-quality-pack": "^2.1"
},
"config": {
"sort-packages": true
Expand All @@ -43,9 +43,9 @@
},
"prefer-stable": true,
"scripts": {
"analyse": "phpstan analyse -c phpstan.neon",
"check-style": "ecs check --ansi src/ tests/",
"fix-style": "ecs check --fix --ansi src/ tests/",
"analyse": "psalm",
"check-style": "ecs check",
"fix-style": "ecs check --fix",
"phpunit": "phpunit"
}
}
2 changes: 0 additions & 2 deletions easy-coding-standard.yaml

This file was deleted.

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

declare(strict_types=1);

use PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import('vendor/sylius-labs/coding-standard/ecs.php');
$containerConfigurator->parameters()->set(Option::PATHS, [
'src', 'tests',
]);

/**
* Was added to fix this exception:
*
* PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException: [binary_operator_spaces] Invalid configuration:
* The options "align_double_arrow", "align_equals" do not exist. Defined options are: "default", "operators".
* in vendor/friendsofphp/php-cs-fixer/src/AbstractFixer.php on line 155
*/
$containerConfigurator->services()->set(BinaryOperatorSpacesFixer::class);
};
7 changes: 0 additions & 7 deletions phpstan.neon

This file was deleted.

13 changes: 13 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.7.3@38c452ae584467e939d55377aaf83b5a26f19dd1">
<file src="src/autoload.php">
<UnusedFunctionCall occurrences="1">
<code>set_include_path</code>
</UnusedFunctionCall>
</file>
<file src="src/recipe/dotenv.php">
<PossiblyInvalidMethodCall occurrences="1">
<code>has</code>
</PossiblyInvalidMethodCall>
</file>
</files>
16 changes: 16 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<psalm
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
totallyTyped="true"
errorLevel="1"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm-baseline.xml"
>
<projectFiles>
<directory name="src"/>
<ignoreFiles>
<directory name="vendor"/>
</ignoreFiles>
</projectFiles>
</psalm>
2 changes: 1 addition & 1 deletion src/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

declare(strict_types=1);

\Safe\set_include_path(get_include_path() . \PATH_SEPARATOR . __DIR__);
set_include_path(get_include_path() . \PATH_SEPARATOR . __DIR__);
29 changes: 24 additions & 5 deletions src/task/dotenv.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
use function Deployer\set;
use function Deployer\task;
use function Deployer\test;
use function Safe\ksort;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Helper\TableSeparator;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Dotenv\Dotenv;
use Webmozart\Assert\Assert;

/**
* This step has to come AFTER the deploy:update_code step because
Expand Down Expand Up @@ -66,6 +66,10 @@
new TableSeparator(),
]);

/**
* @var string $key
* @var string $val
*/
foreach ($variables as $key => $val) {
$table->addRow([$key, $val]);
}
Expand All @@ -76,10 +80,8 @@
/**
* We want two arrays to begin with. This allows us to easily compare the two arrays later on
* when the $variables may have been changed by the user
*
* @var array<string, string> $variables
*/
$variables = $initialVariables = eval('?>' . run('cat {{release_path}}/.env.local.php'));
$variables = $initialVariables = evalEnv(run('cat {{release_path}}/.env.local.php'));

while (true) {
$outputVariablesFunction($output, $variables);
Expand Down Expand Up @@ -107,7 +109,11 @@
* See https://www.php.net/manual/en/language.operators.array.php
*/
if ($initialVariables != $variables) {
// This array contains the environment variables already overridden
/**
* This array contains the environment variables already overridden
*
* @var array<string, string> $overriddenValues
*/
$overriddenValues = (new Dotenv())->parse(run('cat {{release_path}}/.env.{{stage}}.local'));

/**
Expand Down Expand Up @@ -137,3 +143,16 @@
invoke('dotenv:generate');
}
})->desc('Allows the user to update environment variables');

/**
* @return array<string, scalar>
*/
function evalEnv(string $envContents): array
{
/** @var array<string, scalar> $res */
$res = eval('?>' . $envContents);
Assert::isArray($res);
Assert::allScalar($res);

return $res;
}
2 changes: 1 addition & 1 deletion tests/recipe/DeployTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class DeployTest extends TestCase

public static function setUpBeforeClass(): void
{
\Safe\set_include_path(get_include_path() . \PATH_SEPARATOR . __DIR__ . '/../../vendor/deployer/deployer');
set_include_path(get_include_path() . \PATH_SEPARATOR . __DIR__ . '/../../vendor/deployer/deployer');

// init repository
$repository = __DIR__ . '/repository';
Expand Down

0 comments on commit c817a61

Please sign in to comment.