Skip to content

Commit

Permalink
Restore / sync command, many improvements (#4)
Browse files Browse the repository at this point in the history
* Add DI and commands for restoring and syncing

* Remove the psalm direct dependency in favor of globally installing, fix dependencies to install on php 8

* Fix phpunit and psalm complaints

* Github actions for quality (#3)

* Test phpunit on 7.1

* Use different date format because of PHP support issue

* Specify phpunit version

* Keep trying to get 7.1 working

* Better phpunit workflow

* Try adding phpunit matcher

* add PHPCS
  • Loading branch information
KorvinSzanto authored Mar 23, 2021
1 parent e090b57 commit 9957d56
Show file tree
Hide file tree
Showing 114 changed files with 7,389 additions and 896 deletions.
18 changes: 18 additions & 0 deletions .concrete/index.maintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!doctype html>
<title>Site Maintenance</title>
<style>
html { overflow: hidden; background-color: #f1f1f1; }
body { text-align: center; display: flex; flex-direction: column; justify-content: center; height: 100vh; }
h1 { font-size: 50px; }
body > article { font: 20px Helvetica, sans-serif; color: #333; height: 300px; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>

<article>
<h1>We&rsquo;ll be back soon!</h1>
<div>
<p>We&rsquo;re performing some maintenance at the moment, please check back soon</p>
</div>
</article>
15 changes: 15 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

# Ignore unneeded stuff "export-ignore".
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.phpstorm.meta.php export-ignore
/.psalm export-ignore
/.github export-ignore
/ISSUE_TEMPLATE.md export-ignore
/psalm.xml.dist export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
/docs export-ignore
34 changes: 34 additions & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: PHPCS

on: [push, pull_request]

jobs:
phpcs:
name: PHPCS
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@releases/v2
with:
php-version: 8.0
extensions: mbstring

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --prefer-dist

- name: Run PHPCS
run: ./vendor/bin/phpcs --ignore=fixtures src tests
40 changes: 40 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: PHPUnit

on: [push, pull_request]

jobs:
phpunit:
name: PHPUnit
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.1', '8.0']
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP with specific version of PECL extension
uses: shivammathur/setup-php@releases/v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --prefer-dist

- name: Configure matchers
uses: mheap/phpunit-matcher-action@v1

- name: Run PHPUnit
run: ./vendor/bin/phpunit
22 changes: 22 additions & 0 deletions .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Psalm

on: [push, pull_request]

jobs:
psalm:
name: Psalm
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Psalm
uses: docker://vimeo/psalm-github-actions
with:
security_analysis: true
report_file: results.sarif

- name: Upload Security Analysis results to GitHub
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: results.sarif
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.DS_Store
.idea
vendor
vendor
build
composer.lock
.phpunit.result.cache
12 changes: 12 additions & 0 deletions .phpstorm.meta.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
namespace PHPSTORM_META;

use Concrete\Core\Application\Application;
use Psr\Container\ContainerInterface;

override(ContainerInterface::get(0), map([
'' => '@',
]));
override(Application::make(0), map([
'' => '@',
]));
68 changes: 68 additions & 0 deletions .psalm/plugins/PsrContainerChecker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

declare(strict_types=1);

use PhpParser\Node\Expr;
use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Expr\MethodCall;
use Psalm\Codebase;
use Psalm\Context;
use Psalm\Plugin\Hook\AfterMethodCallAnalysisInterface;
use Psalm\StatementsSource;
use Psalm\Type\Atomic\TNamedObject;
use Psalm\Type\Union;
use Psr\Container\ContainerInterface;

/**
* @internal
*/
final class PsrContainerChecker implements AfterMethodCallAnalysisInterface
{
/**
* @inheritDoc
*/
public static function afterMethodCallAnalysis(
Expr $expr,
string $method_id,
string $appearing_method_id,
string $declaring_method_id,
Context $context,
StatementsSource $statements_source,
Codebase $codebase,
array &$file_replacements = [],
?Union &$return_type_candidate = null
): void {
if (! $expr instanceof MethodCall || $return_type_candidate === null) {
return;
}

[$className, $methodName] = explode('::', $declaring_method_id);

if ($methodName !== 'get') {
return;
}

if (
$className !== ContainerInterface::class
&& ! $codebase->classImplements($className, ContainerInterface::class)
) {
return;
}

$arg = $expr->args[0] ?? null;
if ($arg === null || ! $arg->value instanceof ClassConstFetch) {
return;
}

$class = $arg->value->class;
if (! $class->hasAttribute('resolvedName')) {
return;
}

$return_type_candidate = new Union([
new TNamedObject(
(string) $class->getAttribute('resolvedName')
),
]);
}
}
107 changes: 107 additions & 0 deletions .psalm/stubs/Composer/Semver/Comparator.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?php

namespace Composer\Semver;

use Composer\Semver\Constraint\Constraint;

class Comparator
{
/**
* Evaluates the expression: $version1 > $version2.
*
* @param string $version1
* @param string $version2
*
* @return bool
*
* @psalm-pure
*/
public static function greaterThan($version1, $version2)
{
}

/**
* Evaluates the expression: $version1 >= $version2.
*
* @param string $version1
* @param string $version2
*
* @return bool
*
* @psalm-pure
*/
public static function greaterThanOrEqualTo($version1, $version2)
{
}

/**
* Evaluates the expression: $version1 < $version2.
*
* @param string $version1
* @param string $version2
*
* @return bool
*
* @psalm-pure
*/
public static function lessThan($version1, $version2)
{
}

/**
* Evaluates the expression: $version1 <= $version2.
*
* @param string $version1
* @param string $version2
*
* @return bool
*
* @psalm-pure
*/
public static function lessThanOrEqualTo($version1, $version2)
{
}

/**
* Evaluates the expression: $version1 == $version2.
*
* @param string $version1
* @param string $version2
*
* @return bool
*
* @psalm-pure
*/
public static function equalTo($version1, $version2)
{
}

/**
* Evaluates the expression: $version1 != $version2.
*
* @param string $version1
* @param string $version2
*
* @return bool
*
* @psalm-pure
*/
public static function notEqualTo($version1, $version2)
{
}

/**
* Evaluates the expression: $version1 $operator $version2.
*
* @param string $version1
* @param string $operator
* @param string $version2
*
* @return bool
*
* @psalm-pure
*/
public static function compare($version1, $operator, $version2)
{
}
}
6 changes: 6 additions & 0 deletions .psalm/stubs/Concrete/Core/Application.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

/**
* @method make(...$args): mixed
*/
class Application {}
20 changes: 20 additions & 0 deletions art/concrete-climate.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

<cyan> ncreteconcreteconcreteconcreteconcre
concreteconcreteconcreteconcreteconcrete
<blue>|</blue> concreteconcr--econc teconcreteconcrete
<blue>|</blue> concreteconc econ tecon.reteconcrete
<blue>|</blue> concreteconc. econ teco :eteconcrete
<blue>|</blue> concre- .oncr con tec. reteconcrete
<blue>|</blue> concret :ncr con. tec 'reteconcrete
<blue>|</blue> concret: ncr: conc .te. creteconcrete
<blue>|</blue> concrete. :cret conc ete ncreteconcrete
<blue>|</blue> concreteco re:. .:oncreteconcrete
<blue>|</blue> concretecon . . . .ncre..concrete
<blue>|</blue> concreteco .concreteconc. .oncrete
<blue>|</blue> concretec econcreteco. econcrete
<blue>|</blue> concretec: :concrete. :teconcrete
<blue>|</blue> concreteco: .ncr. :reteconcrete
<blue>|</blue> concreteconcr:. .oncreteconcrete
<blue>|</blue> concreteconcreteconcreteconcreteconcrete
<blue>\ </blue>oncreteconcreteconcreteconcreteconcre
<blue>----------------------------------</blue></cyan>
20 changes: 20 additions & 0 deletions art/concrete-symfony.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

<fg=cyan> ncreteconcreteconcreteconcreteconcre
concreteconcreteconcreteconcreteconcrete
<fg=blue>|</> concreteconcr--econc teconcreteconcrete
<fg=blue>|</> concreteconc econ tecon.reteconcrete
<fg=blue>|</> concreteconc. econ teco :eteconcrete
<fg=blue>|</> concre- .oncr con tec. reteconcrete
<fg=blue>|</> concret :ncr con. tec 'reteconcrete
<fg=blue>|</> concret: ncr: conc .te. creteconcrete
<fg=blue>|</> concrete. :cret conc ete ncreteconcrete
<fg=blue>|</> concreteco re:. .:oncreteconcrete
<fg=blue>|</> concretecon . . . .ncre..concrete
<fg=blue>|</> concreteco .concreteconc. .oncrete
<fg=blue>|</> concretec econcreteco. econcrete
<fg=blue>|</> concretec: :concrete. :teconcrete
<fg=blue>|</> concreteco: .ncr. :reteconcrete
<fg=blue>|</> concreteconcr:. .oncreteconcrete
<fg=blue>|</> concreteconcreteconcreteconcreteconcrete
<fg=blue>\ </>oncreteconcreteconcreteconcreteconcre
<fg=blue>----------------------------------</></>
Loading

0 comments on commit 9957d56

Please sign in to comment.