From 31cf053030310dcb1548c71968c1c127b585a2c7 Mon Sep 17 00:00:00 2001 From: Manuel Pichler Date: Wed, 23 Nov 2016 18:19:02 +0100 Subject: [PATCH] =?UTF-8?q?Closes=20#277:=20serialize():=20"comment"=20is?= =?UTF-8?q?=20returned=20=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … from __sleep multiple times in store in FileCacheDriver.php --- .../PDepend/Source/AST/ASTAnonymousClass.php | 2 +- .../Source/AST/ASTAnonymousClassTest.php | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/main/php/PDepend/Source/AST/ASTAnonymousClass.php b/src/main/php/PDepend/Source/AST/ASTAnonymousClass.php index abbf96af2..1e12a7286 100644 --- a/src/main/php/PDepend/Source/AST/ASTAnonymousClass.php +++ b/src/main/php/PDepend/Source/AST/ASTAnonymousClass.php @@ -236,7 +236,7 @@ public function accept(ASTVisitor $visitor, $data = null) */ public function __sleep() { - return array_merge(array('comment', 'metadata', 'nodes'), parent::__sleep()); + return array_merge(array('metadata'), parent::__sleep()); } /** diff --git a/src/test/php/PDepend/Source/AST/ASTAnonymousClassTest.php b/src/test/php/PDepend/Source/AST/ASTAnonymousClassTest.php index e97318ef6..cd8063300 100644 --- a/src/test/php/PDepend/Source/AST/ASTAnonymousClassTest.php +++ b/src/test/php/PDepend/Source/AST/ASTAnonymousClassTest.php @@ -42,6 +42,8 @@ namespace PDepend\Source\AST; +use PDepend\Util\Cache\Driver\MemoryCacheDriver; + /** * Test case for the {@link \PDepend\Source\AST\ASTCatchStatement} class. * @@ -91,6 +93,38 @@ public function testAnonymousClassHasExpectedEndColumn() $this->assertEquals(5, $expr->getEndColumn()); } + /** + * testMagicSleepMethodReturnsExpectedSetOfPropertyNames + * + * @return void + */ + public function testMagicSleepMethodReturnsExpectedSetOfPropertyNames() + { + $class = new ASTAnonymousClass(__CLASS__); + $class->setCache(new MemoryCacheDriver()); + + $this->assertEquals( + array( + 'metadata', + 'constants', + 'interfaceReferences', + 'parentClassReference', + 'cache', + 'context', + 'comment', + 'endLine', + 'modifiers', + 'name', + 'nodes', + 'namespaceName', + 'startLine', + 'userDefined', + 'id' + ), + $class->__sleep() + ); + } + /** * @return \PDepend\Source\AST\ASTAnonymousClass */