Skip to content

Commit 893ab16

Browse files
authored
Merge pull request #21 from veewee/parse-method-special-chars
Parse special chars like - in method and type names
2 parents c1a195f + 995b7c5 commit 893ab16

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/Metadata/MethodsParser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ function (string $parameter): Parameter {
6868

6969
private function parseName(string $methodString): string
7070
{
71-
preg_match('/^\w+ (?P<name>\w+)/', $methodString, $matches);
71+
preg_match('/^[\w-]+ (?P<name>[\w-]+)/', $methodString, $matches);
7272

7373
return $matches['name'];
7474
}
7575

7676
private function parseReturnType(string $methodString): XsdType
7777
{
78-
preg_match('/^(?P<returnType>\w+)/', $methodString, $matches);
78+
preg_match('/^(?P<returnType>[\w-]+)/', $methodString, $matches);
7979

8080
return $this->xsdTypes->fetchByNameWithFallback($matches['returnType']);
8181
}

tests/Unit/Metadata/MethodsParserTest.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ public function test_it_can_parse_ext_soap_function_strings()
3333
'TestResponse Test0Param()',
3434
'TestResponse Test1Param(Test1 $parameter1)',
3535
'TestResponse Test2Param(Test1 $parameter1, Test2 $parameter2)',
36-
'list(Response1 $response1, Response2 $response2) TestReturnList()',
36+
'list(Response1 $response1, Response-2 $response2, Response_3 $response3) TestReturnList()',
3737
'list(Response1 $response1, Response2 $response2) TestReturnListWithParams(Test1 $parameter1, Test2 $parameter2)',
3838
'simpleType TestSimpleType(simpleType $parameter1)',
39+
'Test-Response Test-Method(Test-1 $parameter-1)',
40+
'Test_Response Test_Method(Test_1 $parameter_1)',
3941
]
4042
]);
4143

4244
$result = $this->parser->parse($client);
43-
4445
static::assertCount(count($methods), $result);
4546
static::assertEquals(
4647
new Method(
@@ -100,5 +101,25 @@ public function test_it_can_parse_ext_soap_function_strings()
100101
),
101102
$result->fetchByName('TestSimpleType')
102103
);
104+
static::assertEquals(
105+
new Method(
106+
'Test-Method',
107+
new ParameterCollection(
108+
new Parameter('parameter-1', XsdType::create('Test-1'))
109+
),
110+
XsdType::create('Test-Response')
111+
),
112+
$result->fetchByName('Test-Method')
113+
);
114+
static::assertEquals(
115+
new Method(
116+
'Test_Method',
117+
new ParameterCollection(
118+
new Parameter('parameter_1', XsdType::create('Test_1'))
119+
),
120+
XsdType::create('Test_Response')
121+
),
122+
$result->fetchByName('Test_Method')
123+
);
103124
}
104125
}

0 commit comments

Comments
 (0)