File tree Expand file tree Collapse file tree 5 files changed +33
-5
lines changed Expand file tree Collapse file tree 5 files changed +33
-5
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ All Notable changes to `bakame/http-strucured-fields` will be documented in this
14
14
15
15
- ` InnerList::fromHttpValue ` accepts Optional White Spaces at the start of its textual representation.
16
16
- ` Parameters::fromHttpValue ` accepts Optional White Spaces at the start of its textual representation.
17
+ - ` Item::fromHttpValue ` bugfix parsing Token data type.
17
18
18
19
### Deprecated
19
20
Original file line number Diff line number Diff line change
1
+ # make install
2
+ install :
3
+ @docker run --rm -it -v$(PWD ) :/app composer install
4
+
5
+ # unit tests
6
+ phpunit :
7
+ @docker run --rm -it -v$(PWD ) :/app --workdir=/app php:8.1-cli-alpine vendor/bin/phpunit --coverage-text
8
+
9
+ # phpstan
10
+ phpstan :
11
+ @docker run --rm -it -v$(PWD ) :/app --workdir=/app php:8.1-cli-alpine vendor/bin/phpstan analyse -l max -c phpstan.neon src --ansi
12
+
13
+ # coding style fix
14
+ phpcs :
15
+ @docker run --rm -it -v$(PWD ) :/app --workdir=/app php:8.1-cli-alpine vendor/bin/php-cs-fixer fix -vvv --allow-risky=yes
16
+
17
+ # test
18
+ test :
19
+ @docker run --rm -it -v$(PWD ) :/app --workdir=/app php:8.1-cli-alpine php ./test.php
20
+
21
+ .PHONY : install phpunit phpstan phpcs test
Original file line number Diff line number Diff line change 13
13
if (is_readable ($ file )) {
14
14
require $ file ;
15
15
}
16
- });
16
+ });
Original file line number Diff line number Diff line change @@ -150,7 +150,9 @@ private static function parseToken(string $string): array
150
150
$ regexp .= '$ ' ;
151
151
}
152
152
153
- preg_match ('/ ' .$ regexp .'/i ' , $ string , $ found );
153
+ if (1 !== preg_match ('/ ' .$ regexp .'/i ' , $ string , $ found )) {
154
+ throw new SyntaxError ("The HTTP textual representation ` $ string` for a Token contains invalid characters. " );
155
+ }
154
156
155
157
return [
156
158
Token::fromString ($ found ['token ' ]),
@@ -193,7 +195,12 @@ private static function parseBytesSequence(string $string): array
193
195
*/
194
196
private static function parseNumber (string $ string ): array
195
197
{
196
- if (1 !== preg_match ('/^(?<number>-?\d+(?:\.\d+)?)(?:[^\d.]|$)/ ' , $ string , $ found )) {
198
+ $ regexp = '^(?<number>-?\d+(?:\.\d+)?)(?:[^\d.]|$) ' ;
199
+ if (!str_contains ($ string , '; ' )) {
200
+ $ regexp = '^(?<number>-?\d+(?:\.\d+)?)$ ' ;
201
+ }
202
+
203
+ if (1 !== preg_match ('/ ' .$ regexp .'/ ' , $ string , $ found )) {
197
204
throw new SyntaxError ("The HTTP textual representation ` $ string` for a number contains invalid characters. " );
198
205
}
199
206
Original file line number Diff line number Diff line change 4
4
5
5
namespace Bakame \Http \StructuredFields ;
6
6
7
- use PHPUnit \Framework \TestCase ;
8
7
use function var_export ;
9
8
10
9
/**
11
10
* @coversDefaultClass \Bakame\Http\StructuredFields\Token
12
11
*/
13
- final class TokenTest extends TestCase
12
+ final class TokenTest extends StructuredFieldTest
14
13
{
15
14
/** @var array|string[] */
16
15
protected array $ paths = [
You can’t perform that action at this time.
0 commit comments