Version 1
[yaffs-website] / vendor / symfony / serializer / Tests / Normalizer / GetSetMethodNormalizerTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
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\Component\Serializer\Tests\Normalizer;
13
14 use Doctrine\Common\Annotations\AnnotationReader;
15 use PHPUnit\Framework\TestCase;
16 use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter;
17 use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
18 use Symfony\Component\Serializer\Serializer;
19 use Symfony\Component\Serializer\SerializerInterface;
20 use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
21 use Symfony\Component\Serializer\Tests\Fixtures\CircularReferenceDummy;
22 use Symfony\Component\Serializer\Tests\Fixtures\SiblingHolder;
23 use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
24 use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
25 use Symfony\Component\Serializer\Tests\Fixtures\GroupDummy;
26
27 class GetSetMethodNormalizerTest extends TestCase
28 {
29     /**
30      * @var GetSetMethodNormalizer
31      */
32     private $normalizer;
33     /**
34      * @var SerializerInterface
35      */
36     private $serializer;
37
38     protected function setUp()
39     {
40         $this->serializer = $this->getMockBuilder(__NAMESPACE__.'\SerializerNormalizer')->getMock();
41         $this->normalizer = new GetSetMethodNormalizer();
42         $this->normalizer->setSerializer($this->serializer);
43     }
44
45     public function testInterface()
46     {
47         $this->assertInstanceOf('Symfony\Component\Serializer\Normalizer\NormalizerInterface', $this->normalizer);
48         $this->assertInstanceOf('Symfony\Component\Serializer\Normalizer\DenormalizerInterface', $this->normalizer);
49     }
50
51     public function testNormalize()
52     {
53         $obj = new GetSetDummy();
54         $object = new \stdClass();
55         $obj->setFoo('foo');
56         $obj->setBar('bar');
57         $obj->setBaz(true);
58         $obj->setCamelCase('camelcase');
59         $obj->setObject($object);
60
61         $this->serializer
62             ->expects($this->once())
63             ->method('normalize')
64             ->with($object, 'any')
65             ->will($this->returnValue('string_object'))
66         ;
67
68         $this->assertEquals(
69             array(
70                 'foo' => 'foo',
71                 'bar' => 'bar',
72                 'baz' => true,
73                 'fooBar' => 'foobar',
74                 'camelCase' => 'camelcase',
75                 'object' => 'string_object',
76             ),
77             $this->normalizer->normalize($obj, 'any')
78         );
79     }
80
81     public function testDenormalize()
82     {
83         $obj = $this->normalizer->denormalize(
84             array('foo' => 'foo', 'bar' => 'bar', 'baz' => true, 'fooBar' => 'foobar'),
85             __NAMESPACE__.'\GetSetDummy',
86             'any'
87         );
88         $this->assertEquals('foo', $obj->getFoo());
89         $this->assertEquals('bar', $obj->getBar());
90         $this->assertTrue($obj->isBaz());
91     }
92
93     public function testDenormalizeWithObject()
94     {
95         $data = new \stdClass();
96         $data->foo = 'foo';
97         $data->bar = 'bar';
98         $data->fooBar = 'foobar';
99         $obj = $this->normalizer->denormalize($data, __NAMESPACE__.'\GetSetDummy', 'any');
100         $this->assertEquals('foo', $obj->getFoo());
101         $this->assertEquals('bar', $obj->getBar());
102     }
103
104     /**
105      * @group legacy
106      */
107     public function testLegacyDenormalizeOnCamelCaseFormat()
108     {
109         $this->normalizer->setCamelizedAttributes(array('camel_case'));
110         $obj = $this->normalizer->denormalize(
111             array('camel_case' => 'camelCase'),
112             __NAMESPACE__.'\GetSetDummy'
113         );
114
115         $this->assertEquals('camelCase', $obj->getCamelCase());
116     }
117
118     public function testNameConverterSupport()
119     {
120         $this->normalizer = new GetSetMethodNormalizer(null, new CamelCaseToSnakeCaseNameConverter());
121         $obj = $this->normalizer->denormalize(
122             array('camel_case' => 'camelCase'),
123             __NAMESPACE__.'\GetSetDummy'
124         );
125         $this->assertEquals('camelCase', $obj->getCamelCase());
126     }
127
128     public function testDenormalizeNull()
129     {
130         $this->assertEquals(new GetSetDummy(), $this->normalizer->denormalize(null, __NAMESPACE__.'\GetSetDummy'));
131     }
132
133     /**
134      * @group legacy
135      */
136     public function testLegacyCamelizedAttributesNormalize()
137     {
138         $obj = new GetCamelizedDummy('dunglas.fr');
139         $obj->setFooBar('les-tilleuls.coop');
140         $obj->setBar_foo('lostinthesupermarket.fr');
141
142         $this->normalizer->setCamelizedAttributes(array('kevin_dunglas'));
143         $this->assertEquals($this->normalizer->normalize($obj), array(
144             'kevin_dunglas' => 'dunglas.fr',
145             'fooBar' => 'les-tilleuls.coop',
146             'bar_foo' => 'lostinthesupermarket.fr',
147         ));
148
149         $this->normalizer->setCamelizedAttributes(array('foo_bar'));
150         $this->assertEquals($this->normalizer->normalize($obj), array(
151             'kevinDunglas' => 'dunglas.fr',
152             'foo_bar' => 'les-tilleuls.coop',
153             'bar_foo' => 'lostinthesupermarket.fr',
154         ));
155     }
156
157     /**
158      * @group legacy
159      */
160     public function testLegacyCamelizedAttributesDenormalize()
161     {
162         $obj = new GetCamelizedDummy('dunglas.fr');
163         $obj->setFooBar('les-tilleuls.coop');
164         $obj->setBar_foo('lostinthesupermarket.fr');
165
166         $this->normalizer->setCamelizedAttributes(array('kevin_dunglas'));
167         $this->assertEquals($this->normalizer->denormalize(array(
168             'kevin_dunglas' => 'dunglas.fr',
169             'fooBar' => 'les-tilleuls.coop',
170             'bar_foo' => 'lostinthesupermarket.fr',
171         ), __NAMESPACE__.'\GetCamelizedDummy'), $obj);
172
173         $this->normalizer->setCamelizedAttributes(array('foo_bar'));
174         $this->assertEquals($this->normalizer->denormalize(array(
175             'kevinDunglas' => 'dunglas.fr',
176             'foo_bar' => 'les-tilleuls.coop',
177             'bar_foo' => 'lostinthesupermarket.fr',
178         ), __NAMESPACE__.'\GetCamelizedDummy'), $obj);
179     }
180
181     public function testConstructorDenormalize()
182     {
183         $obj = $this->normalizer->denormalize(
184             array('foo' => 'foo', 'bar' => 'bar', 'baz' => true, 'fooBar' => 'foobar'),
185             __NAMESPACE__.'\GetConstructorDummy', 'any');
186         $this->assertEquals('foo', $obj->getFoo());
187         $this->assertEquals('bar', $obj->getBar());
188         $this->assertTrue($obj->isBaz());
189     }
190
191     public function testConstructorDenormalizeWithNullArgument()
192     {
193         $obj = $this->normalizer->denormalize(
194             array('foo' => 'foo', 'bar' => null, 'baz' => true),
195             __NAMESPACE__.'\GetConstructorDummy', 'any');
196         $this->assertEquals('foo', $obj->getFoo());
197         $this->assertNull($obj->getBar());
198         $this->assertTrue($obj->isBaz());
199     }
200
201     public function testConstructorDenormalizeWithMissingOptionalArgument()
202     {
203         $obj = $this->normalizer->denormalize(
204             array('foo' => 'test', 'baz' => array(1, 2, 3)),
205             __NAMESPACE__.'\GetConstructorOptionalArgsDummy', 'any');
206         $this->assertEquals('test', $obj->getFoo());
207         $this->assertEquals(array(), $obj->getBar());
208         $this->assertEquals(array(1, 2, 3), $obj->getBaz());
209     }
210
211     /**
212      * @see https://bugs.php.net/62715
213      *
214      * @requires PHP 5.3.17
215      */
216     public function testConstructorDenormalizeWithOptionalDefaultArgument()
217     {
218         $obj = $this->normalizer->denormalize(
219             array('bar' => 'test'),
220             __NAMESPACE__.'\GetConstructorArgsWithDefaultValueDummy', 'any');
221         $this->assertEquals(array(), $obj->getFoo());
222         $this->assertEquals('test', $obj->getBar());
223     }
224
225     /**
226      * @requires PHP 5.6
227      */
228     public function testConstructorDenormalizeWithVariadicArgument()
229     {
230         $obj = $this->normalizer->denormalize(
231             array('foo' => array(1, 2, 3)),
232             'Symfony\Component\Serializer\Tests\Fixtures\VariadicConstructorArgsDummy', 'any');
233         $this->assertEquals(array(1, 2, 3), $obj->getFoo());
234     }
235
236     /**
237      * @requires PHP 5.6
238      */
239     public function testConstructorDenormalizeWithMissingVariadicArgument()
240     {
241         $obj = $this->normalizer->denormalize(
242             array(),
243             'Symfony\Component\Serializer\Tests\Fixtures\VariadicConstructorArgsDummy', 'any');
244         $this->assertEquals(array(), $obj->getFoo());
245     }
246
247     public function testConstructorWithObjectDenormalize()
248     {
249         $data = new \stdClass();
250         $data->foo = 'foo';
251         $data->bar = 'bar';
252         $data->baz = true;
253         $data->fooBar = 'foobar';
254         $obj = $this->normalizer->denormalize($data, __NAMESPACE__.'\GetConstructorDummy', 'any');
255         $this->assertEquals('foo', $obj->getFoo());
256         $this->assertEquals('bar', $obj->getBar());
257     }
258
259     public function testConstructorWArgWithPrivateMutator()
260     {
261         $obj = $this->normalizer->denormalize(array('foo' => 'bar'), __NAMESPACE__.'\ObjectConstructorArgsWithPrivateMutatorDummy', 'any');
262         $this->assertEquals('bar', $obj->getFoo());
263     }
264
265     public function testGroupsNormalize()
266     {
267         $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
268         $this->normalizer = new GetSetMethodNormalizer($classMetadataFactory);
269         $this->normalizer->setSerializer($this->serializer);
270
271         $obj = new GroupDummy();
272         $obj->setFoo('foo');
273         $obj->setBar('bar');
274         $obj->setFooBar('fooBar');
275         $obj->setSymfony('symfony');
276         $obj->setKevin('kevin');
277         $obj->setCoopTilleuls('coopTilleuls');
278
279         $this->assertEquals(array(
280             'bar' => 'bar',
281         ), $this->normalizer->normalize($obj, null, array(GetSetMethodNormalizer::GROUPS => array('c'))));
282
283         $this->assertEquals(array(
284             'symfony' => 'symfony',
285             'foo' => 'foo',
286             'fooBar' => 'fooBar',
287             'bar' => 'bar',
288             'kevin' => 'kevin',
289             'coopTilleuls' => 'coopTilleuls',
290         ), $this->normalizer->normalize($obj, null, array(GetSetMethodNormalizer::GROUPS => array('a', 'c'))));
291     }
292
293     public function testGroupsDenormalize()
294     {
295         $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
296         $this->normalizer = new GetSetMethodNormalizer($classMetadataFactory);
297         $this->normalizer->setSerializer($this->serializer);
298
299         $obj = new GroupDummy();
300         $obj->setFoo('foo');
301
302         $toNormalize = array('foo' => 'foo', 'bar' => 'bar');
303
304         $normalized = $this->normalizer->denormalize(
305             $toNormalize,
306             'Symfony\Component\Serializer\Tests\Fixtures\GroupDummy',
307             null,
308             array(GetSetMethodNormalizer::GROUPS => array('a'))
309         );
310         $this->assertEquals($obj, $normalized);
311
312         $obj->setBar('bar');
313
314         $normalized = $this->normalizer->denormalize(
315             $toNormalize,
316             'Symfony\Component\Serializer\Tests\Fixtures\GroupDummy',
317             null,
318             array(GetSetMethodNormalizer::GROUPS => array('a', 'b'))
319         );
320         $this->assertEquals($obj, $normalized);
321     }
322
323     public function testGroupsNormalizeWithNameConverter()
324     {
325         $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
326         $this->normalizer = new GetSetMethodNormalizer($classMetadataFactory, new CamelCaseToSnakeCaseNameConverter());
327         $this->normalizer->setSerializer($this->serializer);
328
329         $obj = new GroupDummy();
330         $obj->setFooBar('@dunglas');
331         $obj->setSymfony('@coopTilleuls');
332         $obj->setCoopTilleuls('les-tilleuls.coop');
333
334         $this->assertEquals(
335             array(
336                 'bar' => null,
337                 'foo_bar' => '@dunglas',
338                 'symfony' => '@coopTilleuls',
339             ),
340             $this->normalizer->normalize($obj, null, array(GetSetMethodNormalizer::GROUPS => array('name_converter')))
341         );
342     }
343
344     public function testGroupsDenormalizeWithNameConverter()
345     {
346         $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
347         $this->normalizer = new GetSetMethodNormalizer($classMetadataFactory, new CamelCaseToSnakeCaseNameConverter());
348         $this->normalizer->setSerializer($this->serializer);
349
350         $obj = new GroupDummy();
351         $obj->setFooBar('@dunglas');
352         $obj->setSymfony('@coopTilleuls');
353
354         $this->assertEquals(
355             $obj,
356             $this->normalizer->denormalize(array(
357                 'bar' => null,
358                 'foo_bar' => '@dunglas',
359                 'symfony' => '@coopTilleuls',
360                 'coop_tilleuls' => 'les-tilleuls.coop',
361             ), 'Symfony\Component\Serializer\Tests\Fixtures\GroupDummy', null, array(GetSetMethodNormalizer::GROUPS => array('name_converter')))
362         );
363     }
364
365     /**
366      * @dataProvider provideCallbacks
367      */
368     public function testCallbacks($callbacks, $value, $result, $message)
369     {
370         $this->normalizer->setCallbacks($callbacks);
371
372         $obj = new GetConstructorDummy('', $value, true);
373
374         $this->assertEquals(
375             $result,
376             $this->normalizer->normalize($obj, 'any'),
377             $message
378         );
379     }
380
381     /**
382      * @expectedException \InvalidArgumentException
383      */
384     public function testUncallableCallbacks()
385     {
386         $this->normalizer->setCallbacks(array('bar' => null));
387
388         $obj = new GetConstructorDummy('baz', 'quux', true);
389
390         $this->normalizer->normalize($obj, 'any');
391     }
392
393     public function testIgnoredAttributes()
394     {
395         $this->normalizer->setIgnoredAttributes(array('foo', 'bar', 'baz', 'camelCase', 'object'));
396
397         $obj = new GetSetDummy();
398         $obj->setFoo('foo');
399         $obj->setBar('bar');
400         $obj->setBaz(true);
401
402         $this->assertEquals(
403             array('fooBar' => 'foobar'),
404             $this->normalizer->normalize($obj, 'any')
405         );
406     }
407
408     public function provideCallbacks()
409     {
410         return array(
411             array(
412                 array(
413                     'bar' => function ($bar) {
414                         return 'baz';
415                     },
416                 ),
417                 'baz',
418                 array('foo' => '', 'bar' => 'baz', 'baz' => true),
419                 'Change a string',
420             ),
421             array(
422                 array(
423                     'bar' => function ($bar) {
424                     },
425                 ),
426                 'baz',
427                 array('foo' => '', 'bar' => null, 'baz' => true),
428                 'Null an item',
429             ),
430             array(
431                 array(
432                     'bar' => function ($bar) {
433                         return $bar->format('d-m-Y H:i:s');
434                     },
435                 ),
436                 new \DateTime('2011-09-10 06:30:00'),
437                 array('foo' => '', 'bar' => '10-09-2011 06:30:00', 'baz' => true),
438                 'Format a date',
439             ),
440             array(
441                 array(
442                     'bar' => function ($bars) {
443                         $foos = '';
444                         foreach ($bars as $bar) {
445                             $foos .= $bar->getFoo();
446                         }
447
448                         return $foos;
449                     },
450                 ),
451                 array(new GetConstructorDummy('baz', '', false), new GetConstructorDummy('quux', '', false)),
452                 array('foo' => '', 'bar' => 'bazquux', 'baz' => true),
453                 'Collect a property',
454             ),
455             array(
456                 array(
457                     'bar' => function ($bars) {
458                         return count($bars);
459                     },
460                 ),
461                 array(new GetConstructorDummy('baz', '', false), new GetConstructorDummy('quux', '', false)),
462                 array('foo' => '', 'bar' => 2, 'baz' => true),
463                 'Count a property',
464             ),
465         );
466     }
467
468     /**
469      * @expectedException \Symfony\Component\Serializer\Exception\LogicException
470      * @expectedExceptionMessage Cannot normalize attribute "object" because injected serializer is not a normalizer
471      */
472     public function testUnableToNormalizeObjectAttribute()
473     {
474         $serializer = $this->getMockBuilder('Symfony\Component\Serializer\SerializerInterface')->getMock();
475         $this->normalizer->setSerializer($serializer);
476
477         $obj = new GetSetDummy();
478         $object = new \stdClass();
479         $obj->setObject($object);
480
481         $this->normalizer->normalize($obj, 'any');
482     }
483
484     /**
485      * @expectedException \Symfony\Component\Serializer\Exception\CircularReferenceException
486      */
487     public function testUnableToNormalizeCircularReference()
488     {
489         $serializer = new Serializer(array($this->normalizer));
490         $this->normalizer->setSerializer($serializer);
491         $this->normalizer->setCircularReferenceLimit(2);
492
493         $obj = new CircularReferenceDummy();
494
495         $this->normalizer->normalize($obj);
496     }
497
498     public function testSiblingReference()
499     {
500         $serializer = new Serializer(array($this->normalizer));
501         $this->normalizer->setSerializer($serializer);
502
503         $siblingHolder = new SiblingHolder();
504
505         $expected = array(
506             'sibling0' => array('coopTilleuls' => 'Les-Tilleuls.coop'),
507             'sibling1' => array('coopTilleuls' => 'Les-Tilleuls.coop'),
508             'sibling2' => array('coopTilleuls' => 'Les-Tilleuls.coop'),
509         );
510         $this->assertEquals($expected, $this->normalizer->normalize($siblingHolder));
511     }
512
513     public function testCircularReferenceHandler()
514     {
515         $serializer = new Serializer(array($this->normalizer));
516         $this->normalizer->setSerializer($serializer);
517         $this->normalizer->setCircularReferenceHandler(function ($obj) {
518             return get_class($obj);
519         });
520
521         $obj = new CircularReferenceDummy();
522
523         $expected = array('me' => 'Symfony\Component\Serializer\Tests\Fixtures\CircularReferenceDummy');
524         $this->assertEquals($expected, $this->normalizer->normalize($obj));
525     }
526
527     public function testObjectToPopulate()
528     {
529         $dummy = new GetSetDummy();
530         $dummy->setFoo('foo');
531
532         $obj = $this->normalizer->denormalize(
533             array('bar' => 'bar'),
534             __NAMESPACE__.'\GetSetDummy',
535             null,
536             array(GetSetMethodNormalizer::OBJECT_TO_POPULATE => $dummy)
537         );
538
539         $this->assertEquals($dummy, $obj);
540         $this->assertEquals('foo', $obj->getFoo());
541         $this->assertEquals('bar', $obj->getBar());
542     }
543
544     public function testDenormalizeNonExistingAttribute()
545     {
546         $this->assertEquals(
547             new GetSetDummy(),
548             $this->normalizer->denormalize(array('non_existing' => true), __NAMESPACE__.'\GetSetDummy')
549         );
550     }
551
552     public function testDenormalizeShouldNotSetStaticAttribute()
553     {
554         $obj = $this->normalizer->denormalize(array('staticObject' => true), __NAMESPACE__.'\GetSetDummy');
555
556         $this->assertEquals(new GetSetDummy(), $obj);
557         $this->assertNull(GetSetDummy::getStaticObject());
558     }
559
560     public function testNoTraversableSupport()
561     {
562         $this->assertFalse($this->normalizer->supportsNormalization(new \ArrayObject()));
563     }
564
565     public function testNoStaticGetSetSupport()
566     {
567         $this->assertFalse($this->normalizer->supportsNormalization(new ObjectWithJustStaticSetterDummy()));
568     }
569
570     public function testPrivateSetter()
571     {
572         $obj = $this->normalizer->denormalize(array('foo' => 'foobar'), __NAMESPACE__.'\ObjectWithPrivateSetterDummy');
573         $this->assertEquals('bar', $obj->getFoo());
574     }
575 }
576
577 class GetSetDummy
578 {
579     protected $foo;
580     private $bar;
581     private $baz;
582     protected $camelCase;
583     protected $object;
584     private static $staticObject;
585
586     public function getFoo()
587     {
588         return $this->foo;
589     }
590
591     public function setFoo($foo)
592     {
593         $this->foo = $foo;
594     }
595
596     public function getBar()
597     {
598         return $this->bar;
599     }
600
601     public function setBar($bar)
602     {
603         $this->bar = $bar;
604     }
605
606     public function isBaz()
607     {
608         return $this->baz;
609     }
610
611     public function setBaz($baz)
612     {
613         $this->baz = $baz;
614     }
615
616     public function getFooBar()
617     {
618         return $this->foo.$this->bar;
619     }
620
621     public function getCamelCase()
622     {
623         return $this->camelCase;
624     }
625
626     public function setCamelCase($camelCase)
627     {
628         $this->camelCase = $camelCase;
629     }
630
631     public function otherMethod()
632     {
633         throw new \RuntimeException('Dummy::otherMethod() should not be called');
634     }
635
636     public function setObject($object)
637     {
638         $this->object = $object;
639     }
640
641     public function getObject()
642     {
643         return $this->object;
644     }
645
646     public static function getStaticObject()
647     {
648         return self::$staticObject;
649     }
650
651     public static function setStaticObject($object)
652     {
653         self::$staticObject = $object;
654     }
655
656     protected function getPrivate()
657     {
658         throw new \RuntimeException('Dummy::getPrivate() should not be called');
659     }
660 }
661
662 class GetConstructorDummy
663 {
664     protected $foo;
665     private $bar;
666     private $baz;
667
668     public function __construct($foo, $bar, $baz)
669     {
670         $this->foo = $foo;
671         $this->bar = $bar;
672         $this->baz = $baz;
673     }
674
675     public function getFoo()
676     {
677         return $this->foo;
678     }
679
680     public function getBar()
681     {
682         return $this->bar;
683     }
684
685     public function isBaz()
686     {
687         return $this->baz;
688     }
689
690     public function otherMethod()
691     {
692         throw new \RuntimeException('Dummy::otherMethod() should not be called');
693     }
694 }
695
696 abstract class SerializerNormalizer implements SerializerInterface, NormalizerInterface
697 {
698 }
699
700 class GetConstructorOptionalArgsDummy
701 {
702     protected $foo;
703     private $bar;
704     private $baz;
705
706     public function __construct($foo, $bar = array(), $baz = array())
707     {
708         $this->foo = $foo;
709         $this->bar = $bar;
710         $this->baz = $baz;
711     }
712
713     public function getFoo()
714     {
715         return $this->foo;
716     }
717
718     public function getBar()
719     {
720         return $this->bar;
721     }
722
723     public function getBaz()
724     {
725         return $this->baz;
726     }
727
728     public function otherMethod()
729     {
730         throw new \RuntimeException('Dummy::otherMethod() should not be called');
731     }
732 }
733
734 class GetConstructorArgsWithDefaultValueDummy
735 {
736     protected $foo;
737     protected $bar;
738
739     public function __construct($foo = array(), $bar)
740     {
741         $this->foo = $foo;
742         $this->bar = $bar;
743     }
744
745     public function getFoo()
746     {
747         return $this->foo;
748     }
749
750     public function getBar()
751     {
752         return $this->bar;
753     }
754
755     public function otherMethod()
756     {
757         throw new \RuntimeException('Dummy::otherMethod() should not be called');
758     }
759 }
760
761 class GetCamelizedDummy
762 {
763     private $kevinDunglas;
764     private $fooBar;
765     private $bar_foo;
766
767     public function __construct($kevinDunglas = null)
768     {
769         $this->kevinDunglas = $kevinDunglas;
770     }
771
772     public function getKevinDunglas()
773     {
774         return $this->kevinDunglas;
775     }
776
777     public function setFooBar($fooBar)
778     {
779         $this->fooBar = $fooBar;
780     }
781
782     public function getFooBar()
783     {
784         return $this->fooBar;
785     }
786
787     public function setBar_foo($bar_foo)
788     {
789         $this->bar_foo = $bar_foo;
790     }
791
792     public function getBar_foo()
793     {
794         return $this->bar_foo;
795     }
796 }
797
798 class ObjectConstructorArgsWithPrivateMutatorDummy
799 {
800     private $foo;
801
802     public function __construct($foo)
803     {
804         $this->setFoo($foo);
805     }
806
807     public function getFoo()
808     {
809         return $this->foo;
810     }
811
812     private function setFoo($foo)
813     {
814         $this->foo = $foo;
815     }
816 }
817
818 class ObjectWithPrivateSetterDummy
819 {
820     private $foo = 'bar';
821
822     public function getFoo()
823     {
824         return $this->foo;
825     }
826
827     private function setFoo($foo)
828     {
829     }
830 }
831
832 class ObjectWithJustStaticSetterDummy
833 {
834     private static $foo = 'bar';
835
836     public static function getFoo()
837     {
838         return self::$foo;
839     }
840
841     public static function setFoo($foo)
842     {
843         self::$foo = $foo;
844     }
845 }