@@ -937,6 +937,24 @@ public function testObjectNormalizerWithAttributeLoaderAndObjectHasStaticPropert
937937 $ normalizer = new ObjectNormalizer (new ClassMetadataFactory (new AttributeLoader ()));
938938 $ this ->assertSame ([], $ normalizer ->normalize ($ class ));
939939 }
940+
941+ public function testNormalizeWithMethodNamesSimilarToAccessors ()
942+ {
943+ $ classMetadataFactory = new ClassMetadataFactory (new AttributeLoader ());
944+ $ normalizer = new ObjectNormalizer ($ classMetadataFactory );
945+
946+ $ object = new ObjectWithAccessorishMethods ();
947+ $ normalized = $ normalizer ->normalize ($ object );
948+
949+ $ this ->assertFalse ($ object ->isAccessorishCalled ());
950+ $ this ->assertSame ([
951+ 'accessorishCalled ' => false ,
952+ 'tell ' => true ,
953+ 'class ' => true ,
954+ 'responsibility ' => true ,
955+ 123 => 321
956+ ], $ normalized );
957+ }
940958}
941959
942960class ProxyObjectDummy extends ObjectDummy
@@ -1219,3 +1237,63 @@ class ObjectDummyWithIgnoreAttributeAndPrivateProperty
12191237
12201238 private $ private = 'private ' ;
12211239}
1240+
1241+ class ObjectWithAccessorishMethods
1242+ {
1243+ private $ accessorishCalled = false ;
1244+
1245+ public function isAccessorishCalled ()
1246+ {
1247+ return $ this ->accessorishCalled ;
1248+ }
1249+
1250+ public function cancel ()
1251+ {
1252+ $ this ->accessorishCalled = true ;
1253+ }
1254+
1255+ public function hash ()
1256+ {
1257+ $ this ->accessorishCalled = true ;
1258+ }
1259+
1260+ public function canTell ()
1261+ {
1262+ return true ;
1263+ }
1264+
1265+ public function getClass ()
1266+ {
1267+ return true ;
1268+ }
1269+
1270+ public function hasResponsibility ()
1271+ {
1272+ return true ;
1273+ }
1274+
1275+ public function get_foo ()
1276+ {
1277+ return 'bar ' ;
1278+ }
1279+
1280+ public function get123 ()
1281+ {
1282+ return 321 ;
1283+ }
1284+
1285+ public function gettings ()
1286+ {
1287+ $ this ->accessorishCalled = true ;
1288+ }
1289+
1290+ public function settings ()
1291+ {
1292+ $ this ->accessorishCalled = true ;
1293+ }
1294+
1295+ public function isolate ()
1296+ {
1297+ $ this ->accessorishCalled = true ;
1298+ }
1299+ }
0 commit comments