Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Mar 29, 2024. It is now read-only.

Commit f893e81

Browse files
committed
Reflect groupping and short array syntax in property spec
1 parent e49f0ed commit f893e81

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

‎src/Specs/Builder/PropertySpecBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ protected function getSpecMethodsOrType(PropertySpecPrototype $proto, string $de
100100
return;
101101
}
102102

103-
if (preg_match('/^(?<type>\w+(?:\(.*\))?)$/', $definition, $matches)) {
103+
if (preg_match('/^(?<type>([\w\-]*(?:\(.*\))?(?:\[\s*\])?)(?:\s*\|\s*(?-1))*)$/', $definition, $matches)) {
104104
$proto->definition = $this->builder->build($matches['type']);
105105

106106
return;

‎tests/Specs/Builder/PropertySpecBuilderTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,34 @@ public function testBuildingTyped()
8787
$this->assertNull($spec->getSetterName());
8888
}
8989

90+
public function testBuildingTypedArray()
91+
{
92+
$this->extractorDefinitionShouldBuildOn('[]');
93+
94+
$spec = $this->builder->build('[]');
95+
96+
$this->assertInstanceOf(PropertySpecInterface::class, $spec);
97+
98+
$this->assertInstanceOf(ExtractorDefinitionInterface::class, $spec->getExtractorDefinition());
99+
$this->assertFalse($spec->isReadonly());
100+
$this->assertNull($spec->getGetterName());
101+
$this->assertNull($spec->getSetterName());
102+
}
103+
104+
public function testBuildingTypedAndGroupedArray()
105+
{
106+
$this->extractorDefinitionShouldBuildOn('(foo|bar[])[]');
107+
108+
$spec = $this->builder->build('(foo|bar[])[]');
109+
110+
$this->assertInstanceOf(PropertySpecInterface::class, $spec);
111+
112+
$this->assertInstanceOf(ExtractorDefinitionInterface::class, $spec->getExtractorDefinition());
113+
$this->assertFalse($spec->isReadonly());
114+
$this->assertNull($spec->getGetterName());
115+
$this->assertNull($spec->getSetterName());
116+
}
117+
90118
public function testBuildingReadonlyTyped()
91119
{
92120
$this->extractorDefinitionShouldBuildOn('test');

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /