@@ -40,6 +40,26 @@ public function testExtract($property, array $type = null, $shortDescription, $l
40
40
$ this ->assertSame ($ longDescription , $ this ->extractor ->getLongDescription ('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy ' , $ property ));
41
41
}
42
42
43
+ /**
44
+ * @dataProvider typesWithCustomPrefixesProvider
45
+ */
46
+ public function testExtractTypesWithCustomPrefixes ($ property , array $ type = null )
47
+ {
48
+ $ customExtractor = new PhpDocExtractor (null , array ('add ' , 'remove ' ), array ('is ' , 'can ' ));
49
+
50
+ $ this ->assertEquals ($ type , $ customExtractor ->getTypes ('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy ' , $ property ));
51
+ }
52
+
53
+ /**
54
+ * @dataProvider typesWithNoPrefixesProvider
55
+ */
56
+ public function testExtractTypesWithNoPrefixes ($ property , array $ type = null )
57
+ {
58
+ $ noPrefixExtractor = new PhpDocExtractor (null , array (), array (), array ());
59
+
60
+ $ this ->assertEquals ($ type , $ noPrefixExtractor ->getTypes ('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy ' , $ property ));
61
+ }
62
+
43
63
public function typesProvider ()
44
64
{
45
65
return array (
@@ -75,6 +95,76 @@ public function typesProvider()
75
95
);
76
96
}
77
97
98
+ public function typesWithCustomPrefixesProvider ()
99
+ {
100
+ return array (
101
+ array ('foo ' , null , 'Short description. ' , 'Long description. ' ),
102
+ array ('bar ' , array (new Type (Type::BUILTIN_TYPE_STRING )), 'This is bar ' , null ),
103
+ array ('baz ' , array (new Type (Type::BUILTIN_TYPE_INT )), 'Should be used. ' , null ),
104
+ array ('foo2 ' , array (new Type (Type::BUILTIN_TYPE_FLOAT )), null , null ),
105
+ array ('foo3 ' , array (new Type (Type::BUILTIN_TYPE_CALLABLE )), null , null ),
106
+ array ('foo4 ' , array (new Type (Type::BUILTIN_TYPE_NULL )), null , null ),
107
+ array ('foo5 ' , null , null , null ),
108
+ array (
109
+ 'files ' ,
110
+ array (
111
+ new Type (Type::BUILTIN_TYPE_ARRAY , false , null , true , new Type (Type::BUILTIN_TYPE_INT ), new Type (Type::BUILTIN_TYPE_OBJECT , false , 'SplFileInfo ' )),
112
+ new Type (Type::BUILTIN_TYPE_RESOURCE ),
113
+ ),
114
+ null ,
115
+ null ,
116
+ ),
117
+ array ('bal ' , array (new Type (Type::BUILTIN_TYPE_OBJECT , false , 'DateTime ' )), null , null ),
118
+ array ('parent ' , array (new Type (Type::BUILTIN_TYPE_OBJECT , false , 'Symfony\Component\PropertyInfo\Tests\Fixtures\ParentDummy ' )), null , null ),
119
+ array ('collection ' , array (new Type (Type::BUILTIN_TYPE_ARRAY , false , null , true , new Type (Type::BUILTIN_TYPE_INT ), new Type (Type::BUILTIN_TYPE_OBJECT , false , 'DateTime ' ))), null , null ),
120
+ array ('a ' , null , 'A. ' , null ),
121
+ array ('b ' , null , 'B. ' , null ),
122
+ array ('c ' , array (new Type (Type::BUILTIN_TYPE_BOOL , true )), null , null ),
123
+ array ('d ' , array (new Type (Type::BUILTIN_TYPE_BOOL )), null , null ),
124
+ array ('e ' , array (new Type (Type::BUILTIN_TYPE_ARRAY , false , null , true , new Type (Type::BUILTIN_TYPE_INT ), new Type (Type::BUILTIN_TYPE_RESOURCE ))), null , null ),
125
+ array ('f ' , array (new Type (Type::BUILTIN_TYPE_ARRAY , false , null , true , new Type (Type::BUILTIN_TYPE_INT ), new Type (Type::BUILTIN_TYPE_OBJECT , false , 'DateTime ' ))), null , null ),
126
+ array ('g ' , array (new Type (Type::BUILTIN_TYPE_ARRAY , true , null , true )), 'Nullable array. ' , null ),
127
+ array ('donotexist ' , null , null , null ),
128
+ array ('staticGetter ' , null , null , null ),
129
+ array ('staticSetter ' , null , null , null ),
130
+ );
131
+ }
132
+
133
+ public function typesWithNoPrefixesProvider ()
134
+ {
135
+ return array (
136
+ array ('foo ' , null , 'Short description. ' , 'Long description. ' ),
137
+ array ('bar ' , array (new Type (Type::BUILTIN_TYPE_STRING )), 'This is bar ' , null ),
138
+ array ('baz ' , array (new Type (Type::BUILTIN_TYPE_INT )), 'Should be used. ' , null ),
139
+ array ('foo2 ' , array (new Type (Type::BUILTIN_TYPE_FLOAT )), null , null ),
140
+ array ('foo3 ' , array (new Type (Type::BUILTIN_TYPE_CALLABLE )), null , null ),
141
+ array ('foo4 ' , array (new Type (Type::BUILTIN_TYPE_NULL )), null , null ),
142
+ array ('foo5 ' , null , null , null ),
143
+ array (
144
+ 'files ' ,
145
+ array (
146
+ new Type (Type::BUILTIN_TYPE_ARRAY , false , null , true , new Type (Type::BUILTIN_TYPE_INT ), new Type (Type::BUILTIN_TYPE_OBJECT , false , 'SplFileInfo ' )),
147
+ new Type (Type::BUILTIN_TYPE_RESOURCE ),
148
+ ),
149
+ null ,
150
+ null ,
151
+ ),
152
+ array ('bal ' , array (new Type (Type::BUILTIN_TYPE_OBJECT , false , 'DateTime ' )), null , null ),
153
+ array ('parent ' , array (new Type (Type::BUILTIN_TYPE_OBJECT , false , 'Symfony\Component\PropertyInfo\Tests\Fixtures\ParentDummy ' )), null , null ),
154
+ array ('collection ' , array (new Type (Type::BUILTIN_TYPE_ARRAY , false , null , true , new Type (Type::BUILTIN_TYPE_INT ), new Type (Type::BUILTIN_TYPE_OBJECT , false , 'DateTime ' ))), null , null ),
155
+ array ('a ' , null , 'A. ' , null ),
156
+ array ('b ' , null , 'B. ' , null ),
157
+ array ('c ' , null , null , null ),
158
+ array ('d ' , null , null , null ),
159
+ array ('e ' , null , null , null ),
160
+ array ('f ' , null , null , null ),
161
+ array ('g ' , array (new Type (Type::BUILTIN_TYPE_ARRAY , true , null , true )), 'Nullable array. ' , null ),
162
+ array ('donotexist ' , null , null , null ),
163
+ array ('staticGetter ' , null , null , null ),
164
+ array ('staticSetter ' , null , null , null ),
165
+ );
166
+ }
167
+
78
168
public function testReturnNullOnEmptyDocBlock ()
79
169
{
80
170
$ this ->assertNull ($ this ->extractor ->getShortDescription (EmptyDocBlock::class, 'foo ' ));
0 commit comments