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

Commit 4ddeb6d

Browse files
committed
[zendframework/zendframework#2210] Remove error_get_last usage
- Removed two cases where error_get_last() was being used in Cache component; instead, captures the return from ErrorHandler::stop() and calls its getMessage() method.
1 parent 2987c09 commit 4ddeb6d

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/Pattern/CallbackCache.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,13 @@ protected function generateCallbackKey($callback, array $args)
155155
"Can't serialize callback: see previous exception", 0, $e
156156
);
157157
}
158-
ErrorHandler::stop();
158+
$error = ErrorHandler::stop();
159159

160160
if (!$serializedObject) {
161-
$lastErr = error_get_last();
162-
throw new Exception\RuntimeException(
163-
"Can't serialize callback: " . $lastErr['message']
164-
);
161+
throw new Exception\RuntimeException(sprintf(
162+
'Cannot serialize callback: %s',
163+
$error->getMessage()
164+
));
165165
}
166166
$callbackKey.= $serializedObject;
167167
}

src/Storage/Adapter/AdapterOptions.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,13 @@ public function setKeyPattern($keyPattern)
9696
if ($keyPattern !== '') {
9797
ErrorHandler::start(E_WARNING);
9898
$result = preg_match($keyPattern, '');
99-
ErrorHandler::stop();
99+
$error = ErrorHandler::stop();
100100
if ($result === false) {
101-
$err = error_get_last();
102-
throw new Exception\InvalidArgumentException("Invalid pattern '{$keyPattern}': {$err['message']}");
101+
throw new Exception\InvalidArgumentException(sprintf(
102+
'Invalid pattern "%s": %s',
103+
$keyPattern,
104+
$error->getMessage()
105+
));
103106
}
104107
}
105108

0 commit comments

Comments
 (0)