ReflectionClosurePhp81Test.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. <?php
  2. use Foo\Baz\Qux\Forest;
  3. use Some\ClassName as ClassAlias;
  4. use Tests\Fixtures\Model;
  5. use Tests\Fixtures\RegularClass;
  6. use function Tests\Fixtures\{makeModel};
  7. enum GlobalEnum {
  8. case Admin;
  9. case Guest;
  10. case Moderator;
  11. }
  12. test('named arguments', function () {
  13. $variable = new RegularClass();
  14. $f1 = function (string $a1) use ($variable) {
  15. return new RegularClass(
  16. a1: $a1,
  17. a2: 'string',
  18. a3: 1,
  19. a4: 1.1,
  20. a5: true,
  21. a6: null,
  22. a7: ['string'],
  23. a8: ['string', $a1, 1, null, true],
  24. a9: [[[[['string', $a1, 1, null, true]]]]],
  25. a10: new RegularClass(
  26. a1: $a1,
  27. a2: 'string',
  28. a3: 1,
  29. a4: 1.1,
  30. a5: true,
  31. a6: null,
  32. a7: ['string'],
  33. a8: ['string', $a1, 1, null, true],
  34. a9: [[[[['string', $a1, 1, null, true]]]]],
  35. a10: new RegularClass(),
  36. a11: RegularClass::C,
  37. a12: RegularClass::staticMethod(),
  38. a13: (new RegularClass())->instanceMethod(),
  39. a14: [new RegularClass(), RegularClass::C, RegularClass::staticMethod(), (new RegularClass())->instanceMethod()],
  40. ),
  41. a11: RegularClass::C,
  42. a12: [new RegularClass(), RegularClass::C],
  43. a13: RegularClass::staticMethod(),
  44. a14: (new RegularClass())->instanceMethod(),
  45. a15: fn () => new RegularClass(
  46. a1: $a1,
  47. a2: 'string',
  48. a3: 1,
  49. a4: 1.1,
  50. a5: true,
  51. a6: null,
  52. a7: ['string'],
  53. a8: ['string', $a1, 1, null, true],
  54. a9: [[[[['string', $a1, 1, null, true]]]]],
  55. a10: new RegularClass(
  56. a1: $a1,
  57. a2: 'string',
  58. a3: 1,
  59. a4: 1.1,
  60. a5: true,
  61. a6: null,
  62. a7: ['string'],
  63. a8: ['string', $a1, 1, null, true],
  64. a9: [[[[['string', $a1, 1, null, true]]]]],
  65. a10: new RegularClass(),
  66. a11: RegularClass::C,
  67. a12: RegularClass::staticMethod(),
  68. a13: (new RegularClass())->instanceMethod(),
  69. a14: [new RegularClass(), RegularClass::C, RegularClass::staticMethod(), (new RegularClass())->instanceMethod()],
  70. ),
  71. a11: RegularClass::C,
  72. a12: [new RegularClass(), RegularClass::C],
  73. a13: RegularClass::staticMethod(),
  74. a14: (new RegularClass())->instanceMethod(),
  75. ),
  76. a16: fn () => fn () => new RegularClass(
  77. a1: $a1,
  78. a2: 'string',
  79. a3: 1,
  80. a4: 1.1,
  81. a5: true,
  82. a6: null,
  83. a7: ['string'],
  84. a8: ['string', $a1, 1, null, true],
  85. a9: [[[[['string', $a1, 1, null, true]]]]],
  86. a10: new RegularClass(
  87. a1: $a1,
  88. a2: 'string',
  89. a3: 1,
  90. a4: 1.1,
  91. a5: true,
  92. a6: null,
  93. a7: ['string'],
  94. a8: ['string', $a1, 1, null, true],
  95. a9: [[[[['string', $a1, 1, null, true]]]]],
  96. a10: new RegularClass(),
  97. a11: RegularClass::C,
  98. a12: RegularClass::staticMethod(),
  99. a13: (new RegularClass())->instanceMethod(),
  100. a14: [new RegularClass(), RegularClass::C, RegularClass::staticMethod(), (new RegularClass())->instanceMethod()],
  101. ),
  102. a11: RegularClass::C,
  103. a12: [new RegularClass(), RegularClass::C],
  104. a13: RegularClass::staticMethod(),
  105. a14: (new RegularClass())->instanceMethod(),
  106. ),
  107. a17: function () use ($variable) {
  108. return new RegularClass(
  109. a1: $a1,
  110. a2: 'string',
  111. a3: 1,
  112. a4: 1.1,
  113. a5: true,
  114. a6: null,
  115. a7: ['string'],
  116. a8: ['string', $a1, 1, null, true],
  117. a9: [[[[['string', $a1, 1, null, true]]]]],
  118. a10: new RegularClass(
  119. a1: $a1,
  120. a2: 'string',
  121. a3: 1,
  122. a4: 1.1,
  123. a5: true,
  124. a6: null,
  125. a7: ['string'],
  126. a8: ['string', $a1, 1, null, true],
  127. a9: [[[[['string', $a1, 1, null, true]]]]],
  128. a10: new RegularClass(),
  129. a11: RegularClass::C,
  130. a12: RegularClass::staticMethod(),
  131. a13: (new RegularClass())->instanceMethod(),
  132. a14: [new RegularClass(), RegularClass::C, RegularClass::staticMethod(), (new RegularClass())->instanceMethod()],
  133. ),
  134. a11: RegularClass::C,
  135. a12: [new RegularClass(), RegularClass::C],
  136. a13: RegularClass::staticMethod(),
  137. a14: (new RegularClass())->instanceMethod(),
  138. );
  139. },
  140. a18: reflection_closure_my_function(),
  141. a19: reflection_closure_my_function(ReflectionClosureGlobalEnum::Guest),
  142. a20: reflection_closure_my_function(enum: ReflectionClosureGlobalEnum::Guest),
  143. a21: match (true) {
  144. true => new RegularClass(),
  145. false => (new RegularClass()) instanceof RegularClass,
  146. default => reflection_closure_my_function(enum: ReflectionClosureGlobalEnum::Guest),
  147. },
  148. );
  149. };
  150. $e1 = "function (string \$a1) use (\$variable) {
  151. return new \Tests\Fixtures\RegularClass(
  152. a1: \$a1,
  153. a2: 'string',
  154. a3: 1,
  155. a4: 1.1,
  156. a5: true,
  157. a6: null,
  158. a7: ['string'],
  159. a8: ['string', \$a1, 1, null, true],
  160. a9: [[[[['string', \$a1, 1, null, true]]]]],
  161. a10: new \Tests\Fixtures\RegularClass(
  162. a1: \$a1,
  163. a2: 'string',
  164. a3: 1,
  165. a4: 1.1,
  166. a5: true,
  167. a6: null,
  168. a7: ['string'],
  169. a8: ['string', \$a1, 1, null, true],
  170. a9: [[[[['string', \$a1, 1, null, true]]]]],
  171. a10: new \Tests\Fixtures\RegularClass(),
  172. a11: \Tests\Fixtures\RegularClass::C,
  173. a12: \Tests\Fixtures\RegularClass::staticMethod(),
  174. a13: (new \Tests\Fixtures\RegularClass())->instanceMethod(),
  175. a14: [new \Tests\Fixtures\RegularClass(), \Tests\Fixtures\RegularClass::C, \Tests\Fixtures\RegularClass::staticMethod(), (new \Tests\Fixtures\RegularClass())->instanceMethod()],
  176. ),
  177. a11: \Tests\Fixtures\RegularClass::C,
  178. a12: [new \Tests\Fixtures\RegularClass(), \Tests\Fixtures\RegularClass::C],
  179. a13: \Tests\Fixtures\RegularClass::staticMethod(),
  180. a14: (new \Tests\Fixtures\RegularClass())->instanceMethod(),
  181. a15: fn () => new \Tests\Fixtures\RegularClass(
  182. a1: \$a1,
  183. a2: 'string',
  184. a3: 1,
  185. a4: 1.1,
  186. a5: true,
  187. a6: null,
  188. a7: ['string'],
  189. a8: ['string', \$a1, 1, null, true],
  190. a9: [[[[['string', \$a1, 1, null, true]]]]],
  191. a10: new \Tests\Fixtures\RegularClass(
  192. a1: \$a1,
  193. a2: 'string',
  194. a3: 1,
  195. a4: 1.1,
  196. a5: true,
  197. a6: null,
  198. a7: ['string'],
  199. a8: ['string', \$a1, 1, null, true],
  200. a9: [[[[['string', \$a1, 1, null, true]]]]],
  201. a10: new \Tests\Fixtures\RegularClass(),
  202. a11: \Tests\Fixtures\RegularClass::C,
  203. a12: \Tests\Fixtures\RegularClass::staticMethod(),
  204. a13: (new \Tests\Fixtures\RegularClass())->instanceMethod(),
  205. a14: [new \Tests\Fixtures\RegularClass(), \Tests\Fixtures\RegularClass::C, \Tests\Fixtures\RegularClass::staticMethod(), (new \Tests\Fixtures\RegularClass())->instanceMethod()],
  206. ),
  207. a11: \Tests\Fixtures\RegularClass::C,
  208. a12: [new \Tests\Fixtures\RegularClass(), \Tests\Fixtures\RegularClass::C],
  209. a13: \Tests\Fixtures\RegularClass::staticMethod(),
  210. a14: (new \Tests\Fixtures\RegularClass())->instanceMethod(),
  211. ),
  212. a16: fn () => fn () => new \Tests\Fixtures\RegularClass(
  213. a1: \$a1,
  214. a2: 'string',
  215. a3: 1,
  216. a4: 1.1,
  217. a5: true,
  218. a6: null,
  219. a7: ['string'],
  220. a8: ['string', \$a1, 1, null, true],
  221. a9: [[[[['string', \$a1, 1, null, true]]]]],
  222. a10: new \Tests\Fixtures\RegularClass(
  223. a1: \$a1,
  224. a2: 'string',
  225. a3: 1,
  226. a4: 1.1,
  227. a5: true,
  228. a6: null,
  229. a7: ['string'],
  230. a8: ['string', \$a1, 1, null, true],
  231. a9: [[[[['string', \$a1, 1, null, true]]]]],
  232. a10: new \Tests\Fixtures\RegularClass(),
  233. a11: \Tests\Fixtures\RegularClass::C,
  234. a12: \Tests\Fixtures\RegularClass::staticMethod(),
  235. a13: (new \Tests\Fixtures\RegularClass())->instanceMethod(),
  236. a14: [new \Tests\Fixtures\RegularClass(), \Tests\Fixtures\RegularClass::C, \Tests\Fixtures\RegularClass::staticMethod(), (new \Tests\Fixtures\RegularClass())->instanceMethod()],
  237. ),
  238. a11: \Tests\Fixtures\RegularClass::C,
  239. a12: [new \Tests\Fixtures\RegularClass(), \Tests\Fixtures\RegularClass::C],
  240. a13: \Tests\Fixtures\RegularClass::staticMethod(),
  241. a14: (new \Tests\Fixtures\RegularClass())->instanceMethod(),
  242. ),
  243. a17: function () use (\$variable) {
  244. return new \Tests\Fixtures\RegularClass(
  245. a1: \$a1,
  246. a2: 'string',
  247. a3: 1,
  248. a4: 1.1,
  249. a5: true,
  250. a6: null,
  251. a7: ['string'],
  252. a8: ['string', \$a1, 1, null, true],
  253. a9: [[[[['string', \$a1, 1, null, true]]]]],
  254. a10: new \Tests\Fixtures\RegularClass(
  255. a1: \$a1,
  256. a2: 'string',
  257. a3: 1,
  258. a4: 1.1,
  259. a5: true,
  260. a6: null,
  261. a7: ['string'],
  262. a8: ['string', \$a1, 1, null, true],
  263. a9: [[[[['string', \$a1, 1, null, true]]]]],
  264. a10: new \Tests\Fixtures\RegularClass(),
  265. a11: \Tests\Fixtures\RegularClass::C,
  266. a12: \Tests\Fixtures\RegularClass::staticMethod(),
  267. a13: (new \Tests\Fixtures\RegularClass())->instanceMethod(),
  268. a14: [new \Tests\Fixtures\RegularClass(), \Tests\Fixtures\RegularClass::C, \Tests\Fixtures\RegularClass::staticMethod(), (new \Tests\Fixtures\RegularClass())->instanceMethod()],
  269. ),
  270. a11: \Tests\Fixtures\RegularClass::C,
  271. a12: [new \Tests\Fixtures\RegularClass(), \Tests\Fixtures\RegularClass::C],
  272. a13: \Tests\Fixtures\RegularClass::staticMethod(),
  273. a14: (new \Tests\Fixtures\RegularClass())->instanceMethod(),
  274. );
  275. },
  276. a18: \\reflection_closure_my_function(),
  277. a19: \\reflection_closure_my_function(\ReflectionClosureGlobalEnum::Guest),
  278. a20: \\reflection_closure_my_function(enum: \ReflectionClosureGlobalEnum::Guest),
  279. a21: match (true) {
  280. true => new \Tests\Fixtures\RegularClass(),
  281. false => (new \Tests\Fixtures\RegularClass()) instanceof \Tests\Fixtures\RegularClass,
  282. default => \\reflection_closure_my_function(enum: \ReflectionClosureGlobalEnum::Guest),
  283. },
  284. );
  285. }";
  286. expect($f1)->toBeCode($e1);
  287. })->with('serializers');
  288. test('enums', function () {
  289. $f = function (GlobalEnum $role) {
  290. return $role;
  291. };
  292. $e = 'function (\GlobalEnum $role) {
  293. return $role;
  294. }';
  295. expect($f)->toBeCode($e);
  296. enum ScopedEnum {
  297. case Admin;
  298. case Guest;
  299. case Moderator;
  300. }
  301. $f = function (ScopedEnum $role) {
  302. return $role;
  303. };
  304. $e = 'function (\ScopedEnum $role) {
  305. return $role;
  306. }';
  307. expect($f)->toBeCode($e);
  308. });
  309. enum GlobalBackedEnum: string {
  310. case Admin = 'Administrator';
  311. case Guest = 'Guest';
  312. case Moderator = 'Moderator';
  313. }
  314. test('backed enums', function () {
  315. $f = function (GlobalBackedEnum $role) {
  316. return $role;
  317. };
  318. $e = 'function (\GlobalBackedEnum $role) {
  319. return $role;
  320. }';
  321. expect($f)->toBeCode($e);
  322. enum ScopedBackedEnum: string {
  323. case Admin = 'Administrator';
  324. case Guest = 'Guest';
  325. case Moderator = 'Moderator';
  326. }
  327. $f = function (ScopedBackedEnum $role) {
  328. return $role;
  329. };
  330. $e = 'function (\ScopedBackedEnum $role) {
  331. return $role;
  332. }';
  333. expect($f)->toBeCode($e);
  334. });
  335. test('array unpacking', function () {
  336. $f = function () {
  337. $array1 = ['a' => 1];
  338. $array2 = ['b' => 2];
  339. return ['a' => 0, ...$array1, ...$array2];
  340. };
  341. $e = "function () {
  342. \$array1 = ['a' => 1];
  343. \$array2 = ['b' => 2];
  344. return ['a' => 0, ...\$array1, ...\$array2];
  345. }";
  346. expect($f)->toBeCode($e);
  347. });
  348. test('new in initializers', function () {
  349. $f = function () {
  350. return new ReflectionClosurePhp81Controller();
  351. };
  352. $e = 'function () {
  353. return new \ReflectionClosurePhp81Controller();
  354. }';
  355. expect($f)->toBeCode($e);
  356. });
  357. test('readonly properties', function () {
  358. $f = function () {
  359. $controller = new ReflectionClosurePhp81Controller();
  360. $controller->service = 'foo';
  361. };
  362. $e = 'function () {
  363. $controller = new \ReflectionClosurePhp81Controller();
  364. $controller->service = \'foo\';
  365. }';
  366. expect($f)->toBeCode($e);
  367. });
  368. test('first-class callable with closures', function () {
  369. $f = function ($a) {
  370. $f = fn ($b) => $a + $b + 1;
  371. return $f(...);
  372. };
  373. $e = 'function ($a) {
  374. $f = fn ($b) => $a + $b + 1;
  375. return $f(...);
  376. }';
  377. expect($f)->toBeCode($e);
  378. });
  379. test('first-class callable with methods', function () {
  380. $f = (new ReflectionClosurePhp81Controller())->publicGetter(...);
  381. $e = 'function ()
  382. {
  383. return $this->privateGetter();
  384. }';
  385. expect($f)->toBeCode($e);
  386. $f = (new ReflectionClosurePhp81Controller())->publicGetterResolver(...);
  387. $e = 'function ()
  388. {
  389. return $this->privateGetterResolver(...);
  390. }';
  391. expect($f)->toBeCode($e);
  392. });
  393. test('first-class callable with static methods', function () {
  394. $f = ReflectionClosurePhp81Controller::publicStaticGetter(...);
  395. $e = 'static function ()
  396. {
  397. return static::privateStaticGetter();
  398. }';
  399. expect($f)->toBeCode($e);
  400. $f = ReflectionClosurePhp81Controller::publicStaticGetterResolver(...);
  401. $e = 'static function ()
  402. {
  403. return static::privateStaticGetterResolver(...);
  404. }';
  405. expect($f)->toBeCode($e);
  406. });
  407. test('first-class callable final method', function () {
  408. $f = (new ReflectionClosurePhp81Controller())->finalPublicGetterResolver(...);
  409. $e = 'function ()
  410. {
  411. return $this->privateGetterResolver(...);
  412. }';
  413. expect($f)->toBeCode($e);
  414. $f = ReflectionClosurePhp81Controller::finalPublicStaticGetterResolver(...);
  415. $e = 'static function ()
  416. {
  417. return static::privateStaticGetterResolver(...);
  418. }';
  419. expect($f)->toBeCode($e);
  420. });
  421. test('first-class callable self return type', function () {
  422. $f = (new ReflectionClosurePhp81Controller())->getSelf(...);
  423. $e = 'function (self $instance): self
  424. {
  425. return $instance;
  426. }';
  427. expect($f)->toBeCode($e);
  428. });
  429. test('intersection types', function () {
  430. $f = function (ClassAlias&Forest $service): ClassAlias&Forest {
  431. return $service;
  432. };
  433. $e = 'function (\Some\ClassName&\Foo\Baz\Qux\Forest $service): \Some\ClassName&\Foo\Baz\Qux\Forest {
  434. return $service;
  435. }';
  436. expect($f)->toBeCode($e);
  437. });
  438. test('never type', function () {
  439. $f = function (): never {
  440. throw new RuntimeException('Something wrong happened.');
  441. };
  442. $e = 'function (): never {
  443. throw new \RuntimeException(\'Something wrong happened.\');
  444. }';
  445. expect($f)->toBeCode($e);
  446. });
  447. test('array_is_list', function () {
  448. $f = function () {
  449. return array_is_list([]);
  450. };
  451. $e = 'function () {
  452. return \array_is_list([]);
  453. }';
  454. expect($f)->toBeCode($e);
  455. });
  456. test('final class constants', function () {
  457. $f = function () {
  458. return ReflectionClosurePhp81Service::X;
  459. };
  460. $e = 'function () {
  461. return ReflectionClosurePhp81Service::X;
  462. };';
  463. expect($f)->toBeCode($e);
  464. })->skip('Constants in anonymous classes is not supported.');
  465. test('first-class callable namespaces', function () {
  466. $model = new Model();
  467. $f = $model->make(...);
  468. $e = 'function (\Tests\Fixtures\Model $model): \Tests\Fixtures\Model
  469. {
  470. return new \Tests\Fixtures\Model();
  471. }';
  472. expect($f)->toBeCode($e);
  473. });
  474. test('static first-class callable namespaces', function () {
  475. $model = new Model();
  476. $f = $model->staticMake(...);
  477. $e = 'static function (\Tests\Fixtures\Model $model): \Tests\Fixtures\Model
  478. {
  479. return new \Tests\Fixtures\Model();
  480. }';
  481. expect($f)->toBeCode($e);
  482. });
  483. test('function attributes without arguments', function () {
  484. $model = new Model();
  485. $f = #[MyAttribute] function () {
  486. return true;
  487. };
  488. $e = <<<EOF
  489. #[MyAttribute()]
  490. function () {
  491. return true;
  492. }
  493. EOF;
  494. expect($f)->toBeCode($e);
  495. });
  496. test('function attributes with arguments', function () {
  497. $model = new Model();
  498. $f = #[MyAttribute('My " \' Argument 1', Model::class)] function () {
  499. return true;
  500. };
  501. $e = <<<EOF
  502. #[MyAttribute('My " \' Argument 1', 'Tests\Fixtures\Model')]
  503. function () {
  504. return true;
  505. }
  506. EOF;
  507. expect($f)->toBeCode($e);
  508. });
  509. test('function attributes with named arguments', function () {
  510. $model = new Model();
  511. $f = #[MyAttribute(string: 'My " \' Argument 1', model:Model::class)] function () {
  512. return false;
  513. };
  514. $e = <<<EOF
  515. #[MyAttribute(string: 'My " \' Argument 1', model: 'Tests\Fixtures\Model')]
  516. function () {
  517. return false;
  518. }
  519. EOF;
  520. expect($f)->toBeCode($e);
  521. });
  522. test('function attributes with first-class callable with methods', function () {
  523. $model = new Model();
  524. $f = (new SerializerPhp81Controller())->publicGetter(...);
  525. $e = <<<EOF
  526. #[Tests\Fixtures\ModelAttribute()]
  527. #[MyAttribute('My " \' Argument 1', 'Tests\Fixtures\Model')]
  528. function ()
  529. {
  530. return \$this->privateGetter();
  531. }
  532. EOF;
  533. expect($f)->toBeCode($e);
  534. });
  535. class ReflectionClosurePhp81Service
  536. {
  537. }
  538. class ReflectionClosurePhp81Controller
  539. {
  540. public function __construct(
  541. public readonly ReflectionClosurePhp81Service $service = new ReflectionClosurePhp81Service(),
  542. ) {
  543. // ..
  544. }
  545. public function publicGetter()
  546. {
  547. return $this->privateGetter();
  548. }
  549. private function privateGetter()
  550. {
  551. return $this->service;
  552. }
  553. public static function publicStaticGetter()
  554. {
  555. return static::privateStaticGetter();
  556. }
  557. public static function privateStaticGetter()
  558. {
  559. return (new ReflectionClosurePhp81Controller())->service;
  560. }
  561. public function publicGetterResolver()
  562. {
  563. return $this->privateGetterResolver(...);
  564. }
  565. private function privateGetterResolver()
  566. {
  567. return fn () => $this->service;
  568. }
  569. public static function publicStaticGetterResolver()
  570. {
  571. return static::privateStaticGetterResolver(...);
  572. }
  573. public static function privateStaticGetterResolver()
  574. {
  575. return fn () => (new ReflectionClosurePhp81Controller())->service;
  576. }
  577. final public function finalPublicGetterResolver()
  578. {
  579. return $this->privateGetterResolver(...);
  580. }
  581. final public static function finalPublicStaticGetterResolver()
  582. {
  583. return static::privateStaticGetterResolver(...);
  584. }
  585. public function getSelf(self $instance): self
  586. {
  587. return $instance;
  588. }
  589. }
  590. enum ReflectionClosureGlobalEnum {
  591. case Admin;
  592. case Guest;
  593. case Moderator;
  594. }
  595. function reflection_closure_my_function(SerializerGlobalEnum $enum = SerializerGlobalEnum::Admin)
  596. {
  597. return $enum;
  598. }