Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  update badges
  allow php 8
  simplify jobs name
  update actions version
  publish type coverage
  add coding standard
  use phpunit 9
  replace eris by blackbox
  use psalm 4
  • Loading branch information
Baptouuuu committed Feb 7, 2021
2 parents 7057c1e + 4588ee4 commit df75f04
Show file tree
Hide file tree
Showing 40 changed files with 158 additions and 229 deletions.
49 changes: 38 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
php-version: ['7.4']
name: 'PHPUnit - PHP/${{ matrix.php-version }} - OS/${{ matrix.os }}'
php-version: ['7.4', '8.0']
name: 'PHPUnit'
steps:
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v1
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
Expand All @@ -23,7 +23,7 @@ jobs:
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
Expand All @@ -39,26 +39,53 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['7.4']
name: 'Psalm - PHP/${{ matrix.php-version }}'
php-version: ['7.4', '8.0']
name: 'Psalm'
steps:
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v1
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
- 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@v1
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
- name: Psalm
run: vendor/bin/psalm
run: vendor/bin/psalm --shepherd
cs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['7.4']
name: 'CS'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
- 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 }}-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-${{ matrix.php-version }}-composer-
- name: Install Dependencies
run: composer install --no-progress
- name: CS
run: vendor/bin/php-cs-fixer fix --diff --dry-run --diff-format udiff
6 changes: 6 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

return Innmind\CodingStandard\CodingStandard::config([
'tests',
'src',
]);
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# UrlTemplate

| `develop` |
|-----------|
| [![codecov](https://codecov.io/gh/Innmind/UrlTemplate/branch/develop/graph/badge.svg)](https://codecov.io/gh/Innmind/UrlTemplate) |
| [![Build Status](https://github.com/Innmind/UrlTemplate/workflows/CI/badge.svg)](https://github.com/Innmind/UrlTemplate/actions?query=workflow%3ACI) |
[![Build Status](https://github.com/innmind/urltemplate/workflows/CI/badge.svg?branch=master)](https://github.com/innmind/urltemplate/actions?query=workflow%3ACI)
[![codecov](https://codecov.io/gh/innmind/urltemplate/branch/develop/graph/badge.svg)](https://codecov.io/gh/innmind/urltemplate)
[![Type Coverage](https://shepherd.dev/github/innmind/urltemplate/coverage.svg)](https://shepherd.dev/github/innmind/urltemplate)

[RFC6570](https://tools.ietf.org/html/rfc6570) implementation.

Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"issues": "http://github.com/Innmind/UrlTemplate/issues"
},
"require": {
"php": "~7.4",
"php": "~7.4|~8.0",
"innmind/url": "~3.0",
"innmind/immutable": "~3.1"
},
Expand All @@ -30,8 +30,9 @@
}
},
"require-dev": {
"phpunit/phpunit": "~8.0",
"giorgiosironi/eris": "^0.11.0",
"vimeo/psalm": "~3.7.0"
"phpunit/phpunit": "~9.0",
"vimeo/psalm": "~4.4",
"innmind/black-box": "^4.16",
"innmind/coding-standard": "^1.1"
}
}
32 changes: 15 additions & 17 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit colors="true" bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="Test suite">
<directory>./tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>.</directory>
<exclude>
<directory>./tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" printerClass="Innmind\BlackBox\PHPUnit\ResultPrinterV9" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>.</directory>
</include>
<exclude>
<directory>./tests</directory>
<directory>./vendor</directory>
</exclude>
</coverage>
<testsuites>
<testsuite name="Test suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
</phpunit>
6 changes: 1 addition & 5 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<psalm
totallyTyped="true"
errorLevel="1"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
Expand All @@ -12,8 +12,4 @@
<directory name="vendor" />
</ignoreFiles>
</projectFiles>

<issueHandlers>
<LessSpecificReturnType errorLevel="info" />
</issueHandlers>
</psalm>
6 changes: 0 additions & 6 deletions src/Expression/Level1.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ public function __construct(Name $name)
$this->encode = new UrlEncode;
}

/**
* {@inheritdoc}
*/
public static function of(Str $string): Expression
{
if (!$string->matches('~^\{[a-zA-Z0-9_]+\}$~')) {
Expand All @@ -39,9 +36,6 @@ public static function of(Str $string): Expression
return new self(new Name($string->trim('{}')->toString()));
}

/**
* {@inheritdoc}
*/
public function expand(Map $variables): string
{
if (!$variables->contains($this->name->toString())) {
Expand Down
6 changes: 0 additions & 6 deletions src/Expression/Level2/Fragment.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ public function __construct(Name $name)
$this->encode = UrlEncode::allowReservedCharacters();
}

/**
* {@inheritdoc}
*/
public static function of(Str $string): Expression
{
if (!$string->matches('~^\{#[a-zA-Z0-9_]+\}$~')) {
Expand All @@ -40,9 +37,6 @@ public static function of(Str $string): Expression
return new self(new Name($string->trim('{#}')->toString()));
}

/**
* {@inheritdoc}
*/
public function expand(Map $variables): string
{
if (!$variables->contains($this->name->toString())) {
Expand Down
6 changes: 0 additions & 6 deletions src/Expression/Level2/Reserved.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ public function __construct(Name $name)
$this->encode = UrlEncode::allowReservedCharacters();
}

/**
* {@inheritdoc}
*/
public static function of(Str $string): Expression
{
if (!$string->matches('~^\{\+[a-zA-Z0-9_]+\}$~')) {
Expand All @@ -40,9 +37,6 @@ public static function of(Str $string): Expression
return new self(new Name($string->trim('{+}')->toString()));
}

/**
* {@inheritdoc}
*/
public function expand(Map $variables): string
{
if (!$variables->contains($this->name->toString())) {
Expand Down
7 changes: 1 addition & 6 deletions src/Expression/Level3.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ public function __construct(Name ...$names)
);
}

/**
* {@inheritdoc}
*/
public static function of(Str $string): Expression
{
if (!$string->matches('~^\{[a-zA-Z0-9_]+(,[a-zA-Z0-9_]+)+\}$~')) {
Expand All @@ -58,9 +55,6 @@ public static function of(Str $string): Expression
return new self(...unwrap($names));
}

/**
* {@inheritdoc}
*/
public function expand(Map $variables): string
{
$expanded = $this->expressions->mapTo(
Expand All @@ -73,6 +67,7 @@ public function expand(Map $variables): string

public function regex(): string
{
/** @psalm-suppress InvalidArgument */
return $this->regex ?? $this->regex = join(
',',
$this->names->mapTo(
Expand Down
6 changes: 0 additions & 6 deletions src/Expression/Level3/Fragment.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ public function __construct(Name ...$names)
);
}

/**
* {@inheritdoc}
*/
public static function of(Str $string): Expression
{
if (!$string->matches('~^\{#[a-zA-Z0-9_]+(,[a-zA-Z0-9_]+)+\}$~')) {
Expand All @@ -60,9 +57,6 @@ public static function of(Str $string): Expression
return new self(...unwrap($names));
}

/**
* {@inheritdoc}
*/
public function expand(Map $variables): string
{
$expanded = $this->expressions->mapTo(
Expand Down
6 changes: 0 additions & 6 deletions src/Expression/Level3/Label.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ public function __construct(Name ...$names)
);
}

/**
* {@inheritdoc}
*/
public static function of(Str $string): Expression
{
if (!$string->matches('~^\{\.[a-zA-Z0-9_]+(,[a-zA-Z0-9_]+)+\}$~')) {
Expand All @@ -60,9 +57,6 @@ public static function of(Str $string): Expression
return new self(...unwrap($names));
}

/**
* {@inheritdoc}
*/
public function expand(Map $variables): string
{
$expanded = $this->expressions->mapTo(
Expand Down
6 changes: 0 additions & 6 deletions src/Expression/Level3/NamedValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ public function __construct(string $lead, string $separator, Name ...$names)
);
}

/**
* {@inheritdoc}
*/
public static function of(Str $string): Expression
{
throw new \LogicException('should not be used directly');
Expand All @@ -57,9 +54,6 @@ public static function keyOnlyWhenEmpty(string $lead, string $separator, Name ..
return $self;
}

/**
* {@inheritdoc}
*/
public function expand(Map $variables): string
{
/** @var Sequence<string> */
Expand Down
6 changes: 0 additions & 6 deletions src/Expression/Level3/Parameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ public function __construct(Name ...$names)
$this->expression = NamedValues::keyOnlyWhenEmpty(';', ';', ...$names);
}

/**
* {@inheritdoc}
*/
public static function of(Str $string): Expression
{
if (!$string->matches('~^\{;[a-zA-Z0-9_]+(,[a-zA-Z0-9_]+)+\}$~')) {
Expand All @@ -45,9 +42,6 @@ public static function of(Str $string): Expression
return new self(...unwrap($names));
}

/**
* {@inheritdoc}
*/
public function expand(Map $variables): string
{
return $this->expression->expand($variables);
Expand Down
6 changes: 0 additions & 6 deletions src/Expression/Level3/Path.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ public function __construct(Name ...$names)
);
}

/**
* {@inheritdoc}
*/
public static function of(Str $string): Expression
{
if (!$string->matches('~^\{/[a-zA-Z0-9_]+(,[a-zA-Z0-9_]+)+\}$~')) {
Expand All @@ -60,9 +57,6 @@ public static function of(Str $string): Expression
return new self(...unwrap($names));
}

/**
* {@inheritdoc}
*/
public function expand(Map $variables): string
{
return join(
Expand Down
6 changes: 0 additions & 6 deletions src/Expression/Level3/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ public function __construct(Name ...$names)
$this->expression = new NamedValues('?', '&', ...$names);
}

/**
* {@inheritdoc}
*/
public static function of(Str $string): Expression
{
if (!$string->matches('~^\{\?[a-zA-Z0-9_]+(,[a-zA-Z0-9_]+)+\}$~')) {
Expand All @@ -45,9 +42,6 @@ public static function of(Str $string): Expression
return new self(...unwrap($names));
}

/**
* {@inheritdoc}
*/
public function expand(Map $variables): string
{
return $this->expression->expand($variables);
Expand Down
Loading

0 comments on commit df75f04

Please sign in to comment.