File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php 
2+ 
3+ /* 
4+  * This file is part of the Symfony package. 
5+  * 
6+  * (c) Fabien Potencier <[email protected] > 7+  * 
8+  * For the full copyright and license information, please view the LICENSE 
9+  * file that was distributed with this source code. 
10+  */ 
11+ 
12+ namespace  Symfony \UX \LiveComponent \Tests \Fixtures \Component ;
13+ 
14+ use  Symfony \UX \LiveComponent \Attribute \AsLiveComponent ;
15+ use  Symfony \UX \LiveComponent \Attribute \LiveProp ;
16+ use  Symfony \UX \LiveComponent \DefaultActionTrait ;
17+ 
18+ #[AsLiveComponent('with_union_type ' )]
19+ final  class  WithUnionType
20+ {
21+     use  DefaultActionTrait;
22+ 
23+     #[LiveProp]
24+     public  int |float |null  $ unionProp  = null ;
25+ }
Original file line number Diff line number Diff line change 1212namespace  Symfony \UX \LiveComponent \Tests \Functional \Metadata ;
1313
1414use  Symfony \Bundle \FrameworkBundle \Test \KernelTestCase ;
15+ use  Symfony \Component \TypeInfo \Type ;
1516use  Symfony \UX \LiveComponent \Metadata \LiveComponentMetadataFactory ;
1617use  Symfony \UX \LiveComponent \Metadata \UrlMapping ;
1718use  Symfony \UX \LiveComponent \Tests \Fixtures \Component \ComponentWithUrlBoundProps ;
19+ use  Symfony \UX \LiveComponent \Tests \Fixtures \Component \WithUnionType ;
1820
1921class  LiveComponentMetadataFactoryTest extends  KernelTestCase
2022{
@@ -42,4 +44,20 @@ public function testQueryStringMapping()
4244        $ this  ->assertEquals (new  UrlMapping (as: 'q ' ), $ propsMetadataByName ['boundPropWithAlias ' ]->urlMapping ());
4345        $ this  ->assertNotNull ($ propsMetadataByName ['boundPropWithCustomAlias ' ]);
4446    }
47+ 
48+     public  function  testLivePropUnionType ()
49+     {
50+         /** @var LiveComponentMetadataFactory $metadataFactory */ 
51+         $ metadataFactory  = self ::getContainer ()->get ('ux.live_component.metadata_factory ' );
52+ 
53+         $ class  = new  \ReflectionClass (WithUnionType::class);
54+         $ propsMetadata  = $ metadataFactory ->createPropMetadatas ($ class );
55+ 
56+         $ propsMetadataByName  = [];
57+         foreach  ($ propsMetadata  as  $ propMetadata ) {
58+             $ propsMetadataByName [$ propMetadata ->getName ()] = $ propMetadata ;
59+         }
60+ 
61+         $ this  ->assertEquals (Type::mixed (), $ propsMetadataByName ['unionProp ' ]->getType ());
62+     }
4563}
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments