Skip to content
This repository has been archived by the owner on Jan 29, 2019. It is now read-only.

Commit

Permalink
Merge pull request #9 from salesupply/bugfix/type-setting-fix
Browse files Browse the repository at this point in the history
Fixed broken type setting, error was only to be thrown if type could …
  • Loading branch information
rkeet-salesupply authored Apr 6, 2018
2 parents e5f90ed + cf66e00 commit 9e9b61b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Subscriber/DoctrineEncryptSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,17 +236,17 @@ private function processFields($entity, EntityManager $em, $isEncryptOperation =

// If NOT encrypting, type know to PHP and the value does not match the type. Else error
if (
!$isEncryptOperation
$isEncryptOperation === false
// We're going to try a cast using settype. Array of types defined at: https://php.net/settype
&& in_array($type, ['boolean', 'bool', 'integer', 'int', 'float', 'double', 'string', 'array', 'object', 'null'])
&& gettype($value) !== $type
) {
settype($value, $type);
} else {
if (settype($value, $type) === false) {

throw new \Exception(
'Could not convert encrypted value back to mapped value in ' . __CLASS__ . '::' . __FUNCTION__ . PHP_EOL
);
throw new \Exception(
'Could not convert encrypted value back to mapped value in ' . __CLASS__ . '::' . __FUNCTION__ . PHP_EOL
);
}
}

$refProperty->setValue($entity, $value);
Expand Down

0 comments on commit 9e9b61b

Please sign in to comment.