Skip to content

Commit

Permalink
Fixed possible bugs introduced by fixing PHP bug
Browse files Browse the repository at this point in the history
  • Loading branch information
fprochazka committed Jun 7, 2014
1 parent dd5af1d commit c29d640
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Kdyby/Doctrine/Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,18 @@ public function getReflectionClass()
public function newInstance()
{
if ($this->_prototype === null) {
if (PHP_VERSION_ID >= 50400) {
$this->_prototype = $this->getReflectionClass()->newInstanceWithoutConstructor();
if (PHP_VERSION_ID === 50429 || PHP_VERSION_ID === 50513) {
if ($this->getReflectionClass()->implementsInterface('Serializable')) {
$this->_prototype = @unserialize(sprintf('C:%d:"%s":0:{}', strlen($this->name), $this->name));
}
}

if (!$this->_prototype) {
$this->_prototype = @unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
}

} else {
$this->_prototype = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
if (!$this->_prototype) {
throw new Kdyby\Doctrine\UnexpectedValueException("Prototype of class {$this->name} cannot be created, probably due to some PHP bug.");
}
}

Expand Down

0 comments on commit c29d640

Please sign in to comment.