1<?php 2 3declare(strict_types=1); 4 5namespace JMS\Serializer\Tests\Fixtures; 6 7use JMS\Serializer\Annotation\AccessorOrder; 8use JMS\Serializer\Annotation\SerializedName; 9use JMS\Serializer\Annotation\SkipWhenEmpty; 10use JMS\Serializer\Annotation\Type; 11use JMS\Serializer\Annotation\VirtualProperty; 12 13/** 14 * @AccessorOrder("custom", custom = {"prop_name", "existField", "foo" }) 15 */ 16class ObjectWithVirtualProperties 17{ 18 /** 19 * @Type("string") 20 */ 21 protected $existField = 'value'; 22 23 /** 24 * @VirtualProperty 25 */ 26 public function getVirtualValue() 27 { 28 return 'value'; 29 } 30 31 /** 32 * @VirtualProperty 33 * @SerializedName("test") 34 */ 35 public function getVirtualSerializedValue() 36 { 37 return 'other-name'; 38 } 39 40 /** 41 * @VirtualProperty 42 * @Type("integer") 43 */ 44 public function getTypedVirtualProperty() 45 { 46 return '1'; 47 } 48 49 /** 50 * @VirtualProperty 51 * @SkipWhenEmpty() 52 */ 53 public function getEmptyArray() 54 { 55 return []; 56 } 57} 58