Skip to content
This repository was archived by the owner on Dec 22, 2025. It is now read-only.

Commit 58ca086

Browse files
authored
PHP 7.3+ compatibility (#12)
PHP 7.3+ compatibility
2 parents 3341cfd + c588e20 commit 58ca086

File tree

19 files changed

+41
-34
lines changed

19 files changed

+41
-34
lines changed

.travis.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
language: php
22

33
php:
4-
- '7.0'
5-
- '7.1'
6-
- '7.2'
4+
- 7.3
75

86
env:
97
- COMPOSER_UPDATE=

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ dashboards to track activity and problems.
1616

1717
## Supported PHP versions
1818

19-
`stats-php` version `1.x` supports the following PHP version: `7.0`, `7.1`, `7.2`. If you going to use the library with newer PHP versions - consider using version `2.x+`.
19+
`stats-php` version `1.x` supports the following PHP version: `7.0`, `7.1`, `7.2`. If you going to use the library with newer PHP versions - consider using version `2.x+`.
20+
21+
Since version `2.x`, this library start using the built-in `intl` PHP extension instead of `behat/transliterator`
2022

2123
## Key Features
2224

@@ -29,6 +31,18 @@ dashboards to track activity and problems.
2931
* Easy to build HTTP requests metrics - timing and count
3032
* Generalise or modify HTTP Requests metric - e.g. skip ID part
3133

34+
## Dependencies
35+
36+
### Version `1.x`
37+
38+
- `php: >= 7.0`
39+
- `behat/transliterator: ^1.2`
40+
41+
### Version `2.x`
42+
43+
- `php: >= 7.3`
44+
- `ext-intl: >= 2.0`
45+
3246
## Installation
3347

3448
```sh

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
}
2222
},
2323
"require": {
24-
"php": ">= 5.6",
24+
"php": ">= 7.3",
25+
"ext-intl": ">= 2.0",
2526
"psr/http-message": "^1.0",
26-
"behat/transliterator": "^1.2",
2727
"psr/log": "^1.0"
2828
},
2929
"require-dev": {
30-
"friendsofphp/php-cs-fixer": "^2.3",
31-
"phpunit/phpunit": "^6.5",
30+
"friendsofphp/php-cs-fixer": "^2.16",
31+
"phpunit/phpunit": "^8.4",
3232
"league/statsd": "^1.5"
3333
},
3434
"suggest": {

phpunit.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
convertWarningsToExceptions="true"
99
processIsolation="true"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
1211
verbose="true"
1312
>
1413
<logging>

src/Bucket/Plain.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22
namespace HelloFresh\Stats\Bucket;
33

4-
use Behat\Transliterator\Transliterator;
54
use HelloFresh\Stats\Bucket;
65

76
class Plain implements Bucket
@@ -78,7 +77,7 @@ public static function sanitizeMetricName($metric)
7877
}
7978

8079
// convert unicode symbols to ASCII
81-
$asciiMetric = Transliterator::utf8ToAscii($metric);
80+
$asciiMetric = transliterator_transliterate('Any-Latin; Latin-ASCII;', $metric);
8281
if ($asciiMetric != $metric) {
8382
$metric = Bucket::PREFIX_UNICODE . $asciiMetric;
8483
}

tests/Bucket/PlainTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testSanitizeMetricName()
3737
{
3838
$this->assertEquals('-', Plain::sanitizeMetricName(''));
3939

40-
$this->assertEquals('-u-iunikod', Plain::sanitizeMetricName('юникод'));
40+
$this->assertEquals('-u-unikod', Plain::sanitizeMetricName('юникод'));
4141
$this->assertEquals('-u-Apollon', Plain::sanitizeMetricName('Ἀπόλλων'));
4242
$this->assertEquals('-u-acougue', Plain::sanitizeMetricName('açougue'));
4343

@@ -49,7 +49,7 @@ public function testSanitizeMetricName()
4949
Plain::sanitizeMetricName('metric.with.dots_and_underscores')
5050
);
5151

52-
$this->assertEquals('-u-iunikod_metrika', Plain::sanitizeMetricName('юникод.метрика'));
52+
$this->assertEquals('-u-unikod_metrika', Plain::sanitizeMetricName('юникод.метрика'));
5353
}
5454

5555
public function metrics()

tests/Client/LogTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class LogTest extends TestCase
1111
{
12-
public function setUp()
12+
protected function setUp(): void
1313
{
1414
mt_srand(time());
1515
}

tests/Client/MemoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class MemoryTest extends TestCase
99
{
10-
public function setUp()
10+
protected function setUp(): void
1111
{
1212
mt_srand(time());
1313
}

tests/FactoryTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,14 @@ public function testBuildStatsD()
2727
$this->assertInstanceOf(Client\StatsD::class, Factory::build('statsd://qwe:1234/asd', $logger));
2828
}
2929

30-
/**
31-
* @expectedException \RuntimeException
32-
* @expectedExceptionMessage Unknown client type
33-
*/
3430
public function testUnknownClient()
3531
{
3632
/** @var \PHPUnit_Framework_MockObject_MockObject|\Psr\Log\LoggerInterface $logger */
3733
$logger = $this->getMockBuilder('\Psr\Log\LoggerInterface')->getMock();
3834

35+
$this->expectException(\RuntimeException::class);
36+
$this->expectExceptionMessage('Unknown client type');
37+
3938
Factory::build(uniqid(), $logger);
4039
}
4140
}

tests/HTTPMetricAlterCallback/HasIDAtSecondLevelTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,20 @@ public function testRegisterSectionTest()
6464

6565
/**
6666
* @dataProvider createFromStringMapProvider
67-
* @expectedException \InvalidArgumentException
68-
* @expectedExceptionMessage Invalid sections format
6967
*
7068
* @param string $map
7169
*/
7270
public function testCreateFromStringMap_InvalidFormat($map)
7371
{
72+
$this->expectException(\InvalidArgumentException::class);
73+
$this->expectExceptionMessage('Invalid sections format');
7474
HasIDAtSecondLevel::createFromStringMap($map);
7575
}
7676

77-
/**
78-
* @expectedException \InvalidArgumentException
79-
* @expectedExceptionMessage Unknown section test callback name: foo
80-
*/
8177
public function testCreateFromStringMap_UnknownSectionTest()
8278
{
79+
$this->expectException(\InvalidArgumentException::class);
80+
$this->expectExceptionMessage('Unknown section test callback name: foo');
8381
HasIDAtSecondLevel::createFromStringMap('users:foo');
8482
}
8583

0 commit comments

Comments
 (0)