Skip to content

Commit bc80395

Browse files
authored
Merge pull request #1 from CubiclDev/update8.2
Update dependencies
2 parents 2d46256 + 9697a73 commit bc80395

File tree

8 files changed

+72
-52
lines changed

8 files changed

+72
-52
lines changed

.github/workflows/ci.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: CI Tests
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
operating-system: [ ubuntu-latest ]
16+
php: [ '8.1', '8.2' ]
17+
18+
name: PHP ${{ matrix.php }}
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
23+
- name: Setup PHP
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: ${{ matrix.php }}
27+
tools: composer:v2
28+
coverage: none
29+
ini-values: expose_php=1
30+
31+
- name: Validate composer.json and composer.lock
32+
run: composer validate
33+
34+
- name: Get Composer Cache Directory
35+
id: composer-cache
36+
run: |
37+
echo "::set-output name=dir::$(composer config cache-files-dir)"
38+
39+
- name: Install dependencies
40+
run: composer install --prefer-dist --no-progress
41+
42+
- name: Run tests suite
43+
run: composer tests
44+
45+
- name: Run phpstan
46+
run: composer analyze
47+
48+
- uses: actions/cache@v1
49+
with:
50+
path: ${{ steps.composer-cache.outputs.dir }}
51+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
52+
restore-keys: |
53+
${{ runner.os }}-composer-

.travis.yml

-17
This file was deleted.

README.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
Cubicl\Sorting Module
2-
==============
3-
4-
[![Build Status](https://travis-ci.org/CubiclDev/php-sorting.svg?branch=master)](https://travis-ci.org/CubiclDev/php-sorting)
1+
# Cubicl\Sorting Module
52

63
Implementation of a generic sorting system with an interface definition compatible
74
to the [Comparable RFC](https://wiki.php.net/rfc/comparable).

composer.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
}
1414
],
1515
"scripts": {
16-
"check": ["@analyze", "@test"],
17-
"test": "phpunit tests",
16+
"check": ["@analyze", "@tests"],
17+
"tests": "phpunit tests",
1818
"analyze": "phpstan analyse --level max src"
1919
},
2020
"require-dev": {
21-
"phpunit/phpunit": "^7.5",
22-
"phpstan/phpstan": "^0.11.4"
21+
"phpunit/phpunit": "^9.6.8",
22+
"phpstan/phpstan": "^1.10.15",
23+
"phpspec/prophecy-phpunit": "^2.0.2"
2324
},
2425
"autoload": {
2526
"psr-4": {

src/Comparable.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
/**
88
* Interface for the natural ordering of objects.
9-
*
10-
* @package Cubicl\Sorting
119
*/
1210
interface Comparable {
1311

@@ -22,5 +20,5 @@ interface Comparable {
2220
* @return int
2321
* @throws InvalidComparisonException
2422
*/
25-
public function compareTo($other);
23+
public function compareTo(mixed $other): int;
2624
}

src/SortManager.php

+2-7
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,12 @@
22

33
namespace Cubicl\Sorting;
44

5-
/**
6-
* Class SortManager
7-
*
8-
* @package Cubicl\Sorting
9-
*/
105
class SortManager implements SortManagerInterface
116
{
127
/**
138
* @inheritdoc
149
*/
15-
public function sortWithComparator(ComparatorInterface $comparator, array $list)
10+
public function sortWithComparator(ComparatorInterface $comparator, array $list): array
1611
{
1712
usort($list, [$comparator, 'compare']);
1813

@@ -22,7 +17,7 @@ public function sortWithComparator(ComparatorInterface $comparator, array $list)
2217
/**
2318
* @inheritdoc
2419
*/
25-
public function sortComparable(array $list)
20+
public function sortComparable(array $list): array
2621
{
2722
usort(
2823
$list,

src/SortManagerInterface.php

+6-7
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,27 @@
66
* A sort manager handles user defined sorting of objects or value types. Make sure
77
* that the objects or the values you want to sort have a total ordering, otherwise
88
* the result of the methods is not specified.
9-
*
10-
* @package Cubicl\Sorting
119
*/
1210
interface SortManagerInterface
1311
{
1412
/**
1513
* Sort a list of values or objects by a given comparator.
1614
*
15+
* @phpstan-template T
1716
* @param ComparatorInterface $comparator
18-
* @param array $list a possible unsorted list
17+
* @param array<T> $list a possible unsorted list
1918
*
20-
* @return array the sorted list
19+
* @return array<T> the sorted list
2120
*/
22-
public function sortWithComparator(ComparatorInterface $comparator, array $list);
21+
public function sortWithComparator(ComparatorInterface $comparator, array $list): array;
2322

2423

2524
/**
2625
* Sort the list of objects by their natural order.
2726
*
2827
* @param Comparable[] $list
2928
*
30-
* @return array the sorted list
29+
* @return Comparable[] the sorted list
3130
*/
32-
public function sortComparable(array $list);
31+
public function sortComparable(array $list): array;
3332
}

tests/Unit/SortManagerTest.php

+4-10
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,21 @@
55
use PHPUnit\Framework\TestCase;
66
use Prophecy\Argument;
77
use Prophecy\Prophecy\ObjectProphecy;
8+
use Prophecy\PhpUnit\ProphecyTrait;
89
use Cubicl\Sorting\Comparable;
910
use Cubicl\Sorting\ComparatorInterface;
1011
use Cubicl\Sorting\SortManager;
1112
use Cubicl\Sorting\SortManagerInterface;
1213

13-
/**
14-
* Class SortManagerTest
15-
*
16-
* @package Cubicl\Sorting
17-
*/
1814
class SortManagerTest extends TestCase
1915
{
20-
/**
21-
* @var SortManagerInterface
22-
*/
23-
private $sortManager;
16+
use ProphecyTrait;
17+
private SortManagerInterface $sortManager;
2418

2519
/**
2620
*
2721
*/
28-
protected function setUp()
22+
protected function setUp(): void
2923
{
3024
parent::setUp();
3125
$this->sortManager = new SortManager();

0 commit comments

Comments
 (0)