-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
214 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Soap\WsdlReader\Metadata\Predicate; | ||
|
||
use Soap\Engine\Metadata\Model\TypeMeta; | ||
|
||
final class IsConsideredNullableType | ||
{ | ||
public function __invoke(TypeMeta $meta): bool | ||
{ | ||
if ($meta->isNullable()->unwrapOr(false)) { | ||
return true; | ||
} | ||
|
||
if ($meta->isNil()->unwrapOr(false)) { | ||
return true; | ||
} | ||
|
||
if ($meta->isAttribute()->unwrapOr(false)) { | ||
// If no 'use' is defined, XSD attributes get an implicit default "optional" value | ||
if ($meta->use()->unwrapOr('optional') === 'optional') { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Soap\WsdlReader\Metadata\Predicate; | ||
|
||
use Soap\Engine\Metadata\Model\TypeMeta; | ||
|
||
final class IsConsideredScalarType | ||
{ | ||
public function __invoke(TypeMeta $meta): bool | ||
{ | ||
return $meta->isSimple()->unwrapOr(false) | ||
|| $meta->isAttribute()->unwrapOr(false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,5 +20,5 @@ Methods: | |
Types: | ||
> http://test-uri/:testType { | ||
string $str | ||
@int $int | ||
@?int $int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,5 +21,5 @@ Methods: | |
Types: | ||
> http://test-uri/:testType { | ||
string $str | ||
@int $int | ||
@?int $int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,5 +23,5 @@ Methods: | |
Types: | ||
> http://test-uri/:testType { | ||
string $str | ||
@int $int | ||
@?int $int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,5 +24,5 @@ Methods: | |
Types: | ||
> http://test-uri/:testType { | ||
string $str | ||
@int $int | ||
@?int $int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,5 +21,5 @@ Methods: | |
Types: | ||
> http://test-uri/:testType extends int { | ||
int $_ | ||
@int $int | ||
@?int $int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,5 +21,5 @@ Methods: | |
Types: | ||
> http://test-uri/:testType extends int { | ||
int $_ | ||
@int $int | ||
@?int $int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,5 +29,5 @@ Types: | |
} | ||
> http://test-uri/:testType extends testType2 { | ||
int $int | ||
@int $int2 | ||
@?int $int2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,5 +21,5 @@ Methods: | |
Types: | ||
> http://test-uri/:testType extends int { | ||
int $_ | ||
@int $int | ||
@?int $int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,6 @@ Methods: | |
|
||
Types: | ||
> http://test-uri/:testType { | ||
@string $str | ||
@int $int | ||
@?string $str | ||
@?int $int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,6 @@ Methods: | |
|
||
Types: | ||
> http://test-uri/:testType { | ||
@string $str | ||
@int $int | ||
@?string $str | ||
@?int $int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,6 @@ Methods: | |
|
||
Types: | ||
> http://test-uri/:testType { | ||
@string $str | ||
@int $int | ||
@?string $str | ||
@?int $int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,6 @@ Methods: | |
|
||
Types: | ||
> http://test-uri/:testType { | ||
@string $str | ||
@int $int | ||
@?string $str | ||
@?int $int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,6 @@ Methods: | |
|
||
Types: | ||
> http://test-uri/:testType { | ||
@string $str | ||
@int $int | ||
@?string $str | ||
@?int $int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,6 @@ Methods: | |
|
||
Types: | ||
> http://test-uri/:testType { | ||
@string $str | ||
@int $int | ||
@?string $str | ||
@?int $int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,5 +21,5 @@ Methods: | |
Types: | ||
> http://test-uri/:testType { | ||
string $str | ||
@int $int | ||
@?int $int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--TEST-- | ||
SOAP XML Schema 66: Required Attribute | ||
--FILE-- | ||
<?php | ||
include __DIR__."/test_schema.inc"; | ||
$schema = <<<EOF | ||
<complexType name="testType"> | ||
<attribute name="optional" type="string" use="optional" /> | ||
<attribute name="required" type="string" use="required" /> | ||
</complexType> | ||
EOF; | ||
test_schema($schema,'type="tns:testType"'); | ||
?> | ||
--EXPECTF-- | ||
Methods: | ||
> test(testType $testParam): void | ||
|
||
Types: | ||
> http://test-uri/:testType { | ||
@?string $optional | ||
@string $required | ||
} |
60 changes: 60 additions & 0 deletions
60
tests/Unit/Metadata/Predicate/IsConsideredNullableTypeTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Soap\WsdlReader\Test\Unit\Metadata\Predicate; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Soap\Engine\Metadata\Model\TypeMeta; | ||
use Soap\WsdlReader\Metadata\Predicate\IsConsideredNullableType; | ||
|
||
final class IsConsideredNullableTypeTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider provideTests | ||
* | ||
*/ | ||
public function test_it_knows_if_a_type_is_considered_nullable(TypeMeta $meta, bool $expected): void | ||
{ | ||
static::assertSame($expected, (new IsConsideredNullableType())($meta)); | ||
} | ||
|
||
public static function provideTests() | ||
{ | ||
yield 'empty' => [ | ||
(new TypeMeta()), | ||
false, | ||
]; | ||
yield 'nullable' => [ | ||
(new TypeMeta())->withIsNullable(true), | ||
true, | ||
]; | ||
yield 'not-nullable' => [ | ||
(new TypeMeta())->withIsNullable(false), | ||
false, | ||
]; | ||
yield 'nillable' => [ | ||
(new TypeMeta())->withIsNil(true), | ||
true, | ||
]; | ||
yield 'not-nillable' => [ | ||
(new TypeMeta())->withIsNil(false), | ||
false, | ||
]; | ||
yield 'default-attribute' => [ | ||
(new TypeMeta())->withIsAttribute(true), | ||
true, | ||
]; | ||
yield 'optional-attribute' => [ | ||
(new TypeMeta())->withIsAttribute(true)->withUse('optional'), | ||
true, | ||
]; | ||
yield 'required-attribute' => [ | ||
(new TypeMeta())->withIsAttribute(true)->withUse('required'), | ||
false, | ||
]; | ||
yield 'prohibit-attribute' => [ | ||
(new TypeMeta())->withIsAttribute(true)->withUse('prohibit'), | ||
false, | ||
]; | ||
} | ||
} |
Oops, something went wrong.