Skip to content

Commit

Permalink
Closes #277: serialize(): "comment" is returned …
Browse files Browse the repository at this point in the history
… from __sleep multiple times in store in FileCacheDriver.php
  • Loading branch information
Manuel Pichler committed Nov 23, 2016
1 parent cc609c8 commit 31cf053
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/php/PDepend/Source/AST/ASTAnonymousClass.php
Expand Up @@ -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());
}

/**
Expand Down
34 changes: 34 additions & 0 deletions src/test/php/PDepend/Source/AST/ASTAnonymousClassTest.php
Expand Up @@ -42,6 +42,8 @@

namespace PDepend\Source\AST;

use PDepend\Util\Cache\Driver\MemoryCacheDriver;

/**
* Test case for the {@link \PDepend\Source\AST\ASTCatchStatement} class.
*
Expand Down Expand Up @@ -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
*/
Expand Down

0 comments on commit 31cf053

Please sign in to comment.