File tree Expand file tree Collapse file tree 2 files changed +165
-0
lines changed Expand file tree Collapse file tree 2 files changed +165
-0
lines changed Original file line number Diff line number Diff line change @@ -1832,3 +1832,150 @@ Program {
1832
1832
" kind" : " program" ,
1833
1833
}
1834
1834
` ;
1835
+
1836
+ exports [` Parse Attributes parses this complicated edge case 1` ] = `
1837
+ Program {
1838
+ " children" : Array [
1839
+ UseGroup {
1840
+ " items" : Array [
1841
+ UseItem {
1842
+ " alias" : Identifier {
1843
+ " kind" : " identifier" ,
1844
+ " name" : " Assert" ,
1845
+ },
1846
+ " kind" : " useitem" ,
1847
+ " name" : " Symfony\\\\ Component\\\\ Validator\\\\ Constraints" ,
1848
+ " type" : null ,
1849
+ },
1850
+ ],
1851
+ " kind" : " usegroup" ,
1852
+ " name" : null ,
1853
+ " type" : null ,
1854
+ },
1855
+ Class {
1856
+ " attrGroups" : Array [],
1857
+ " body" : Array [
1858
+ PropertyStatement {
1859
+ " isStatic" : false ,
1860
+ " kind" : " propertystatement" ,
1861
+ " properties" : Array [
1862
+ Property {
1863
+ " attrGroups" : Array [
1864
+ AttrGroup {
1865
+ " attrs" : Array [
1866
+ Attribute {
1867
+ " args" : Array [
1868
+ namedargument {
1869
+ " kind" : " namedargument" ,
1870
+ " name" : " allowNull" ,
1871
+ " value" : Boolean {
1872
+ " kind" : " boolean" ,
1873
+ " raw" : " false" ,
1874
+ " value" : false ,
1875
+ },
1876
+ },
1877
+ namedargument {
1878
+ " kind" : " namedargument" ,
1879
+ " name" : " groups" ,
1880
+ " value" : Array {
1881
+ " items" : Array [
1882
+ Entry {
1883
+ " byRef" : false ,
1884
+ " key" : null ,
1885
+ " kind" : " entry" ,
1886
+ " unpack" : false ,
1887
+ " value" : String {
1888
+ " isDoubleQuote" : false ,
1889
+ " kind" : " string" ,
1890
+ " raw" : " 'foo'" ,
1891
+ " unicode" : false ,
1892
+ " value" : " foo" ,
1893
+ },
1894
+ },
1895
+ ],
1896
+ " kind" : " array" ,
1897
+ " shortForm" : true ,
1898
+ },
1899
+ },
1900
+ ],
1901
+ " kind" : " attribute" ,
1902
+ " name" : " Assert\\\\ NotBlank" ,
1903
+ },
1904
+ Attribute {
1905
+ " args" : Array [
1906
+ namedargument {
1907
+ " kind" : " namedargument" ,
1908
+ " name" : " max" ,
1909
+ " value" : Number {
1910
+ " kind" : " number" ,
1911
+ " value" : " 255" ,
1912
+ },
1913
+ },
1914
+ namedargument {
1915
+ " kind" : " namedargument" ,
1916
+ " name" : " groups" ,
1917
+ " value" : Array {
1918
+ " items" : Array [
1919
+ Entry {
1920
+ " byRef" : false ,
1921
+ " key" : null ,
1922
+ " kind" : " entry" ,
1923
+ " unpack" : false ,
1924
+ " value" : String {
1925
+ " isDoubleQuote" : false ,
1926
+ " kind" : " string" ,
1927
+ " raw" : " 'foo'" ,
1928
+ " unicode" : false ,
1929
+ " value" : " foo" ,
1930
+ },
1931
+ },
1932
+ ],
1933
+ " kind" : " array" ,
1934
+ " shortForm" : true ,
1935
+ },
1936
+ },
1937
+ ],
1938
+ " kind" : " attribute" ,
1939
+ " name" : " Assert\\\\ Length" ,
1940
+ },
1941
+ ],
1942
+ " kind" : " attrgroup" ,
1943
+ },
1944
+ ],
1945
+ " kind" : " property" ,
1946
+ " name" : Identifier {
1947
+ " kind" : " identifier" ,
1948
+ " name" : " value" ,
1949
+ },
1950
+ " nullable" : true ,
1951
+ " readonly" : false ,
1952
+ " type" : TypeReference {
1953
+ " kind" : " typereference" ,
1954
+ " name" : " string" ,
1955
+ " raw" : " string" ,
1956
+ },
1957
+ " value" : NullKeyword {
1958
+ " kind" : " nullkeyword" ,
1959
+ " raw" : " null" ,
1960
+ },
1961
+ },
1962
+ ],
1963
+ " visibility" : " public" ,
1964
+ },
1965
+ ],
1966
+ " extends" : null ,
1967
+ " implements" : null ,
1968
+ " isAbstract" : false ,
1969
+ " isAnonymous" : false ,
1970
+ " isFinal" : false ,
1971
+ " kind" : " class" ,
1972
+ " name" : Identifier {
1973
+ " kind" : " identifier" ,
1974
+ " name" : " ValueModel" ,
1975
+ },
1976
+ },
1977
+ ],
1978
+ " errors" : Array [],
1979
+ " kind" : " program" ,
1980
+ }
1981
+ ` ;
Original file line number Diff line number Diff line change @@ -252,6 +252,24 @@ describe("Parse Attributes", () => {
252
252
) . toMatchSnapshot ( ) ;
253
253
} ) ;
254
254
255
+ it ( "parses this complicated edge case" , ( ) => {
256
+ expect (
257
+ parser . parseEval (
258
+ `
259
+ use Symfony\\Component\\Validator\\Constraints as Assert;
260
+
261
+ class ValueModel
262
+ {
263
+ #[
264
+ Assert\\NotBlank(allowNull: false, groups: ['foo']),
265
+ Assert\\Length(max: 255, groups: ['foo']),
266
+ ]
267
+ public ?string $value = null;
268
+ }`
269
+ )
270
+ ) . toMatchSnapshot ( ) ;
271
+ } ) ;
272
+
255
273
it ( "doesnt parse attributes for assignments" , ( ) => {
256
274
expect (
257
275
parser . parseEval (
You can’t perform that action at this time.
0 commit comments