Skip to content

Commit 7e93187

Browse files
authored
Merge pull request #22 from rtckit/v0.7.1
v0.7.1
2 parents f7bb13b + 171763f commit 7e93187

File tree

16 files changed

+134
-122
lines changed

16 files changed

+134
-122
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "composer"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"

.github/workflows/ci.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
StaticAnalysis:
9+
name: StaticAnalysis (PHP ${{ matrix.php }} on ${{ matrix.os }})
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
matrix:
13+
os:
14+
- ubuntu-20.04
15+
php:
16+
- 7.4
17+
- 8.0
18+
- 8.1
19+
- 8.2
20+
steps:
21+
- uses: actions/checkout@v2
22+
- uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php }}
25+
- run: composer install
26+
- run: composer phpstan
27+
- run: composer psalm -- --output-format=github --shepherd
28+
29+
Coverage:
30+
name: Coverage (PHP ${{ matrix.php }} on ${{ matrix.os }})
31+
runs-on: ${{ matrix.os }}
32+
strategy:
33+
matrix:
34+
os:
35+
- ubuntu-20.04
36+
php:
37+
- 7.4
38+
- 8.0
39+
- 8.1
40+
- 8.2
41+
steps:
42+
- uses: actions/checkout@v2
43+
- uses: shivammathur/setup-php@v2
44+
with:
45+
php-version: ${{ matrix.php }}
46+
- run: composer install
47+
- uses: paambaati/codeclimate-action@v4.0.0
48+
env:
49+
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
50+
with:
51+
coverageCommand: php -d memory_limit=-1 ./vendor/bin/phpunit -c ./etc/phpunit.xml.dist --coverage-clover clover.xml
52+
coverageLocations: clover.xml:clover
53+
debug: true

Makefile

Lines changed: 0 additions & 40 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
[RFC 3261](https://tools.ietf.org/html/rfc3261) compliant SIP parsing and rendering library for PHP 7.4.
88

9-
[![Build Status](https://travis-ci.com/rtckit/php-sip.svg?branch=main)](https://travis-ci.com/rtckit/php-sip)
9+
[![CI Status](https://github.com/rtckit/php-sip/workflows/CI/badge.svg)](https://github.com/rtckit/php-sip/actions/workflows/ci.yaml)
10+
[![Psalm Type Coverage](https://shepherd.dev/github/rtckit/php-sip/coverage.svg)](https://shepherd.dev/github/rtckit/php-sip)
1011
[![Latest Stable Version](https://poser.pugx.org/rtckit/sip/v/stable.png)](https://packagist.org/packages/rtckit/sip)
12+
[![Installs on Packagist](https://img.shields.io/packagist/dt/rtckit/sip?color=blue&label=Installs%20on%20Packagist)](https://packagist.org/packages/rtckit/sip)
1113
[![Test Coverage](https://api.codeclimate.com/v1/badges/aff5ee8e8ef3b51689c2/test_coverage)](https://codeclimate.com/github/rtckit/php-sip/test_coverage)
1214
[![Maintainability](https://api.codeclimate.com/v1/badges/aff5ee8e8ef3b51689c2/maintainability)](https://codeclimate.com/github/rtckit/php-sip/maintainability)
1315
[![License](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
@@ -193,7 +195,7 @@ In order to ensure high code quality, **RTCKit\SIP** uses [PHPStan](https://gith
193195

194196
```sh
195197
php -d memory_limit=-1 ./vendor/bin/phpstan analyse -c ./etc/phpstan.neon -n -vvv --ansi --level=max src
196-
php -d memory_limit=-1 ./vendor/bin/psalm --config=./etc/psalm.xml --show-info=true
198+
php -d memory_limit=-1 ./vendor/bin/psalm --config=./etc/psalm.xml
197199
```
198200

199201
## License

composer.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "rtckit/sip",
33
"description": "SIP protocol implementation written in PHP",
4-
"version": "0.7.0",
4+
"version": "0.7.1",
55
"type": "library",
66
"keywords": [
77
"sip",
@@ -27,10 +27,10 @@
2727
"ext-ctype": "*"
2828
},
2929
"require-dev": {
30-
"phpstan/phpstan": "^0.12",
30+
"phpstan/phpstan": "^1.10",
3131
"phpunit/phpunit": "^9.5",
3232
"symfony/yaml": "^5.3",
33-
"vimeo/psalm": "^4.10"
33+
"vimeo/psalm": "^5.11"
3434
},
3535
"suggest": {
3636
"ext-hash": "Enables RFC 8760 authentication via SHA(-512)-256 hashing"
@@ -44,5 +44,18 @@
4444
"psr-4": {
4545
"RTCKit\\SIP\\": "tests/"
4646
}
47+
},
48+
"config": {
49+
"allow-plugins": false,
50+
"platform": {
51+
"php": "7.4"
52+
}
53+
},
54+
"scripts": {
55+
"phpstan": "php -d memory_limit=-1 ./vendor/bin/phpstan analyse -c ./etc/phpstan.neon -n -vvv --ansi --level=max src",
56+
"psalm": "php -d memory_limit=-1 ./vendor/bin/psalm --config=./etc/psalm.xml",
57+
"test": "php -d memory_limit=-1 ./vendor/bin/phpunit -c ./etc/phpunit.xml.dist --debug",
58+
"coverage": "php -d extension=pcov -d memory_limit=-1 ./vendor/bin/phpunit -c ./etc/phpunit.xml.dist --coverage-text --coverage-html=reports/coverage",
59+
"profile": "php -d memory_limit=-1 ./examples/99-crude-benchmark.php"
4760
}
4861
}

etc/Dockerfile

Lines changed: 0 additions & 36 deletions
This file was deleted.

etc/Dockerfile.xdebug

Lines changed: 0 additions & 29 deletions
This file was deleted.

etc/psalm.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?xml version="1.0"?>
22
<psalm
3-
totallyTyped="false"
43
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
54
xmlns="https://getpsalm.org/schema/config"
65
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
6+
findUnusedCode="false"
7+
findUnusedBaselineEntry="false"
78
>
89
<projectFiles>
910
<directory name="../src" />

src/Auth/Digest/AbstractParams.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ public static function parse(string $input): ParamsInterface
142142

143143
default:
144144
if ($challenge) {
145-
/** @var ChallengeParams $params */
145+
assert($params instanceof ChallengeParams);
146+
146147
switch ($pk) {
147148
case 'domain':
148149
$params->domain = $pv;
@@ -165,7 +166,8 @@ public static function parse(string $input): ParamsInterface
165166
break 2;
166167
}
167168
} else {
168-
/** @var ResponseParams $params */
169+
assert($params instanceof ResponseParams);
170+
169171
switch ($pk) {
170172
case 'username':
171173
$params->username = $pv;

src/Header/ContactHeader.php

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,31 @@ public static function parse(array $hbody): ContactHeader
3737
{
3838
$ret = new static;
3939

40+
$input = $hbody;
41+
$hbody = [];
42+
43+
foreach ($input as $hline) {
44+
$segments = explode(',', $hline);
45+
$buffer = $comma = '';
46+
47+
foreach ($segments as $segment) {
48+
$buffer .= $comma . $segment;
49+
50+
if (!(substr_count($segment, '"') % 2) && (substr_count($segment, '<') === substr_count($segment, '>'))) {
51+
$hbody[] = $buffer;
52+
$buffer = $comma = '';
53+
54+
continue;
55+
}
56+
57+
$comma = ',';
58+
}
59+
60+
if (isset($buffer[0])) {
61+
$hbody[] = $buffer;
62+
}
63+
}
64+
4065
foreach ($hbody as $hline) {
4166
$val = new ContactValue;
4267

@@ -47,7 +72,7 @@ public static function parse(array $hbody): ContactHeader
4772
$qfrom = null;
4873
$afrom = null;
4974
$base = 0;
50-
$addr = null;
75+
$addr = false;
5176

5277
for ($i = 0; $i <= $len; $i++) {
5378
if (!$quoted) {
@@ -174,7 +199,7 @@ public static function parse(array $hbody): ContactHeader
174199
}
175200
}
176201

177-
if (!is_null($addr)) {
202+
if (is_string($addr)) {
178203
$val->uri = URI::parse($addr);
179204
$ret->values[] = $val;
180205
$addr = null;
@@ -200,7 +225,7 @@ public static function parse(array $hbody): ContactHeader
200225
}
201226
}
202227

203-
if (!is_null($addr)) {
228+
if (is_string($addr)) {
204229
$val->uri = URI::parse($addr);
205230
$ret->values[] = $val;
206231
}

0 commit comments

Comments
 (0)