Skip to content

Commit

Permalink
Revamp repository
Browse files Browse the repository at this point in the history
It has been four years since I've changed anything in this library, and
this commit will make the code more up-to-date.

- Configure GitHub actions
- Configure integration with Codecov
- Configure PHPStan
- Remove integration with Scrutinizer
- Remove integration with Travis
- Upgrade Composer scripts
- Upgrade PHPUnit's version
- Upgrade Respect's coding standard
- Upgrade LICENSE file
- Upgrade license headers

Because of the new coding standards, there have been some backward
compatibility changes, but that's not a problem because it won't change
much of the final API.

Because of the upgraded packages, I had to drop the support PHP versions
before 8.1.

Signed-off-by: Henrique Moody <[email protected]>
  • Loading branch information
henriquemoody committed Apr 12, 2023
1 parent 868216d commit e88515f
Show file tree
Hide file tree
Showing 48 changed files with 449 additions and 884 deletions.
7 changes: 2 additions & 5 deletions .docheader
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
/*
* This file is part of Respect/Stringifier.
*
* (c) Henrique Moody <[email protected]>
*
* For the full copyright and license information, please view the "LICENSE.md"
* file that was distributed with this source code.
* Copyright (c) Henrique Moody <[email protected]>
* SPDX-License-Identifier: MIT
*/
87 changes: 87 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Continuous Integration

on:
push: ~
pull_request: ~

jobs:
tests:
name: Tests

runs-on: ubuntu-latest

strategy:
matrix:
php-version:
- "8.1"
- "8.2"

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: none

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

- name: Run Unit Tests
run: ./vendor/bin/phpunit --testsuite=unit

- name: Run Integration Tests
run: ./vendor/bin/phpunit --testsuite=integration

code-coverage:
name: Code coverage

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
coverage: pcov

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

- name: Generating Code Coverage Report
run: ./vendor/bin/phpunit --testsuite=unit --coverage-clover=coverage.xml

- name: Send Code Coverage Report to Codecov.io
uses: codecov/codecov-action@v3

static-analysis:
name: Static Analysis

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
coverage: none

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

- name: Run DocHeader
run: vendor/bin/docheader check src/ tests/

- name: Run PHP_CodeSniffer
run: vendor/bin/phpcs

- name: Run PHPStan
run: vendor/bin/phpstan
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.phpcs.cache
.phpunit.cache
composer.lock
phpcs.xml
phpunit.xml
Expand Down
25 changes: 0 additions & 25 deletions .scrutinizer.yml

This file was deleted.

45 changes: 0 additions & 45 deletions .travis.yml

This file was deleted.

12 changes: 6 additions & 6 deletions LICENSE.md → LICENSE
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# License
MIT License

Copyright (c) [Henrique Moody](http://github.com/henriquemoody).
Copyright (c) Henrique Moody

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
Expand All @@ -17,5 +17,5 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Respect\Stringifier

[![Build Status](https://img.shields.io/travis/Respect/Stringifier/master.svg?style=flat-square)](http://travis-ci.org/Respect/Stringifier)
[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/Respect/Stringifier/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/Respect/Stringifier/?branch=master)
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/Respect/Stringifier/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/Respect/Stringifier/?branch=master)
[![Build Status](https://img.shields.io/github/actions/workflow/status/Respect/Stringifier/continuous-integration.yml?branch=master&style=flat-square)](https://github.com/Respect/Stringifier/actions/workflows/continuous-integration.yml)
[![Code Coverage](https://img.shields.io/codecov/c/github/Respect/Stringifier?style=flat-square)](https://codecov.io/gh/Respect/Stringifier)
[![Latest Stable Version](https://img.shields.io/packagist/v/respect/stringifier.svg?style=flat-square)](https://packagist.org/packages/respect/stringifier)
[![Total Downloads](https://img.shields.io/packagist/dt/respect/stringifier.svg?style=flat-square)](https://packagist.org/packages/respect/stringifier)
[![License](https://img.shields.io/packagist/l/respect/stringifier.svg?style=flat-square)](https://packagist.org/packages/respect/stringifier)
Expand All @@ -18,7 +17,7 @@ using [Composer](http://getcomposer.org).
composer require respect/stringifier
```

This library requires PHP >= 7.1.
This library requires PHP >= 8.1.

## Feature Guide

Expand Down
35 changes: 25 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"description": "Converts any value to a string",
"keywords": ["respect", "stringifier", "stringify"],
"type": "library",
"homepage": "http://respect.github.io/Stringifier/",
"license": "MIT",
"authors": [
{
Expand All @@ -12,30 +11,46 @@
}
],
"require": {
"php": ">=7.1"
"php": "^8.1"
},
"require-dev": {
"malukenho/docheader": "^0.1.7",
"phpunit/phpunit": "^6.4",
"respect/coding-standard": "^1.0",
"squizlabs/php_codesniffer": "^3.4"
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-deprecation-rules": "^1.1",
"phpstan/phpstan-phpunit": "^1.3",
"phpstan/phpstan-strict-rules": "^1.5",
"phpunit/phpunit": "^10.0",
"respect/coding-standard": "^4.0",
"squizlabs/php_codesniffer": "^3.7"
},
"autoload": {
"psr-4": {
"Respect\\Stringifier\\": "src/",
"Respect\\Stringifier\\Test\\": "tests/src/"
"Respect\\Stringifier\\Test\\": "tests/src/",
"Respect\\Stringifier\\Test\\Unit\\": "tests/unit"
},
"files": [
"src/stringify.php"
]
},
"scripts": {
"docheader": "vendor/bin/docheader check src/ tests/",
"test": "vendor/bin/phpunit",
"test-unit": "vendor/bin/phpunit --testsuite=unit",
"test-integration": "vendor/bin/phpunit --testsuite=integration"
"phpcs": "vendor/bin/phpcs",
"phpstan": "vendor/bin/phpstan",
"phpunit": "vendor/bin/phpunit",
"phpunit-integration": "vendor/bin/phpunit --testsuite=integration",
"phpunit-unit": "vendor/bin/phpunit --testsuite=unit",
"qa": [
"@docheader",
"@phpcs",
"@phpstan",
"@phpunit"
]
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
8 changes: 8 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
parameters:
level: max
paths:
- src/
- tests/
fileExtensions:
- php
- phpt
43 changes: 18 additions & 25 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
cacheTokens="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
colors="true"
verbose="true">
<testsuites>
<testsuite name="unit">
<directory suffix="Test.php">tests/unit/</directory>
</testsuite>
<testsuite name="integration">
<directory suffix=".phpt">tests/integration/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory>src/</directory>
</whitelist>
</filter>
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="vendor/autoload.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
cacheDirectory=".phpunit.cache">
<coverage>
<include>
<directory>src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="integration">
<directory suffix="Test.php">tests/integration/</directory>
</testsuite>
<testsuite name="unit">
<directory suffix="Test.php">tests/unit/</directory>
</testsuite>
</testsuites>
</phpunit>
14 changes: 2 additions & 12 deletions src/Quoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

/*
* This file is part of Respect/Stringifier.
*
* (c) Henrique Moody <[email protected]>
*
* For the full copyright and license information, please view the "LICENSE.md"
* file that was distributed with this source code.
* Copyright (c) Henrique Moody <[email protected]>
* SPDX-License-Identifier: MIT
*/

declare(strict_types=1);
Expand All @@ -15,12 +12,5 @@

interface Quoter
{
/**
* Should add quotes to the given string.
*
* @param string $string The string to add quotes to
* @param int $depth The current depth
*
*/
public function quote(string $string, int $depth): string;
}
Loading

0 comments on commit e88515f

Please sign in to comment.