WCF
WCF copied to clipboard
Double check the type casts
Some casts have been "mindlessly" added in ac81e92d0ee4202c6174bedd1319cddf7435d422 to fix issues with an earlier strict typing attempt and are not reasonable. As an example the one in StringUtil::encodeHTML() might hide legitimate type errors.
The casts should be double checked and useless casts removed.
The current list appears to be:
wcfsetup/install.php:
523 public function __construct($message = '', $code = 0, $description = '', \Exception $previous = null) {
524: parent::__construct((string) $message, (int) $code, $previous);
525 $this->description = $description;
wcfsetup/install/files/lib/acp/form/BBCodeAddForm.class.php:
149 $val['attributeNo'] = $attributeNo++;
150: $val['required'] = (int)isset($val['required']);
151: $val['useText'] = (int)isset($val['useText']);
152: $this->attributes[$key] = (object)$val;
153 }
wcfsetup/install/files/lib/acp/form/MenuItemAddForm.class.php:
170 if (isset($_POST['isInternalLink'])) {
171: $this->isInternalLink = (bool)$_POST['isInternalLink'];
172 }
wcfsetup/install/files/lib/acp/form/PackageUpdateServerAddForm.class.php:
92 $url = new Uri($this->serverURL);
93: $this->serverURL = (string)$url;
94
wcfsetup/install/files/lib/acp/form/StyleGlobalValuesForm.class.php:
68 if (empty($_POST)) {
69: $this->styles = (string)RegistryHandler::getInstance()->get(
70 'com.woltlab.wcf',
wcfsetup/install/files/lib/action/AbstractOauth2Action.class.php:
130 }
131: if (!\hash_equals($sessionState, (string)$_GET['state'])) {
132 throw new StateValidationException('Mismatching state');
177
178: $parsed = JSON::decode((string)$response->getBody());
179
wcfsetup/install/files/lib/action/FacebookAuthAction.class.php:
106 $response = $this->getHttpClient()->send($request);
107: $parsed = JSON::decode((string)$response->getBody());
108
wcfsetup/install/files/lib/action/GithubAuthAction.class.php:
101 $response = $this->getHttpClient()->send($request);
102: $parsed = JSON::decode((string)$response->getBody());
103
165 $response = $this->getHttpClient()->send($request);
166: $emails = JSON::decode((string)$response->getBody());
167
wcfsetup/install/files/lib/action/GoogleAuthAction.class.php:
48
49: $this->configuration = JSON::decode((string)$response->getBody());
50 }
120 $response = $this->getHttpClient()->send($request);
121: $parsed = JSON::decode((string)$response->getBody());
122
wcfsetup/install/files/lib/action/MessageQuoteAction.class.php:
157 {
158: $supportPaste = isset($_POST['supportPaste']) ? (bool)$_POST['supportPaste'] : false;
159
wcfsetup/install/files/lib/action/PaypalCallbackAction.class.php:
52 $response = $client->send($request);
53: $content = (string)$response->getBody();
54 } catch (ClientExceptionInterface $e) {
wcfsetup/install/files/lib/action/TwitterAuthAction.class.php:
208
209: $parsed = JSON::decode((string)$response->getBody());
210 $parsed['__id'] = $parsed['id'];
229
230: if (!\hash_equals((string)$initData['oauth_token'], $oauthToken)) {
231 throw new StateValidationException('oauth_token mismatch');
263
264: \parse_str((string)$response->getBody(), $data);
265
304
305: \parse_str((string)$response->getBody(), $data);
306
wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php:
522 * Reads a value and validates it. If you set $allowEmpty to true, no exception will
523: * be thrown if the variable evaluates to 0 (int) or '' (string). Furthermore the
524 * variable will be always created with a sane value if it does not exist.
619 if (\is_numeric($target[$variableName])) {
620: $target[$variableName] = (bool)$target[$variableName];
621 } else {
wcfsetup/install/files/lib/data/blacklist/entry/BlacklistEntryAction.class.php:
62
63: $data = JSON::decode((string)$response->getBody());
64 if (\is_array($data)) {
wcfsetup/install/files/lib/data/blacklist/status/BlacklistStatus.class.php:
116
117: $data = JSON::decode((string)$response->getBody());
118 if (\is_array($data)) {
wcfsetup/install/files/lib/data/like/object/LikeObject.class.php:
116 foreach ($this->getReactions() as $reactionID => $reaction) {
117: $returnValues[] = (object)[
118 'userID' => $reactionID,
124 if ($this->reactionTypeID) {
125: $returnValues[] = (object)[
126 'userID' => 'reactionTypeID',
wcfsetup/install/files/lib/data/package/PackageAction.class.php:
119 $response = $client->send($request);
120: $payload = JSON::decode((string)$response->getBody());
121
wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php:
282 if ($this->apiVersion == '2.0') {
283: return (string)$url;
284 }
285
286: return FileUtil::addTrailingSlash((string)$url) . 'list/' . WCF::getLanguage()->getFixedLanguageCode() . '.xml';
287 }
301
302: return (string)$url;
303 }
wcfsetup/install/files/lib/data/reaction/ReactionAction.class.php:
106 // we cast the reactionTypeID to a string, so that we can sort the array
107: if (!isset($data[(string)$item->getReactionType()->reactionTypeID])) {
108: $data[(string)$item->getReactionType()->reactionTypeID] = new GroupedUserList($item->getReactionType()->renderIcon() . ' ' . StringUtil::encodeHTML($item->getReactionType()->getTitle()));
109 }
110
111: $data[(string)$item->getReactionType()->reactionTypeID]->addUserIDs([$item->userID]);
112 }
wcfsetup/install/files/lib/data/user/group/UserGroup.class.php:
356 $groupIDs = \array_keys(self::getGroupsByType([], [self::OWNER]));
357: $accessibleGroupIDs = \explode(',', (string)$this->getGroupOption('admin.user.accessibleGroups'));
358
wcfsetup/install/files/lib/http/middleware/EnforceAcpAuthentication.class.php:
94 [
95: 'url' => (string)$request->getUri(),
96 ]
131 [
132: 'url' => (string)$request->getUri(),
133 ]
wcfsetup/install/files/lib/system/box/AbstractDatabaseObjectListBoxController.class.php:
468 if (isset($data[$field]) && $data[$field] !== $defaultValue) {
469: $newElement = $element->ownerDocument->createElement($field, (string)$data[$field]);
470
wcfsetup/install/files/lib/system/captcha/RecaptchaHandler.class.php:
135 $response = $this->getHttpClient()->send($request);
136: $data = JSON::decode((string)$response->getBody());
137
wcfsetup/install/files/lib/system/cli/command/WorkerCLICommand.class.php:
175 $output->write(JSON::encode([
176: 'error' => (string)$e,
177 ]));
wcfsetup/install/files/lib/system/condition/page/MultiPageCondition.class.php:
99 if (isset($_POST[$this->fieldName . '_reverseLogic'])) {
100: $this->reverseLogic = (bool)$this->fieldName . '_reverseLogic';
101 }
wcfsetup/install/files/lib/system/cronjob/RefreshSearchRobotsCronjob.class.php:
38 $xml = new XML();
39: $xml->loadXML('list.xml', (string)$response->getBody());
40
wcfsetup/install/files/lib/system/database/Redis.class.php:
84
85: if (!$this->redis->connect($host, (int)$port)) {
86 throw new \RuntimeException('Unable to connect to Redis server');
wcfsetup/install/files/lib/system/database/editor/MySQLDatabaseEditor.class.php:
79 default:
80: if ($typeMatches[2] == (int)$typeMatches[2]) {
81 $length = $typeMatches[2];
wcfsetup/install/files/lib/system/database/table/column/TLengthDatabaseTableColumn.class.php:
63 if ($length !== null) {
64: $length = (int)$length;
65
wcfsetup/install/files/lib/system/devtools/pip/TXmlGuiPackageInstallationPlugin.class.php:
132 $childName,
133: (string)$data[$childName]
134 );
wcfsetup/install/files/lib/system/email/Email.class.php:
514 }
515: $headers[] = ['from', (string)$this->getSender()];
516 if ($this->getReplyTo()->getAddress() !== $this->getSender()->getAddress()) {
517: $headers[] = ['reply-to', (string)$this->getReplyTo()];
518 }
wcfsetup/install/files/lib/system/exception/SystemException.class.php:
42 {
43: parent::__construct((string)$message, (int)$code, $previous);
44 $this->description = $description;
wcfsetup/install/files/lib/system/file/upload/UploadFile.class.php:
158
159: return (string)$url;
160 } else {
wcfsetup/install/files/lib/system/form/builder/field/TSelectionFormField.class.php:
183 if (\method_exists($option['label'], '__toString')) {
184: $option['label'] = (string)$option['label'];
185 } elseif (
203 $labelLanguageItems
204: && \preg_match('~^([a-zA-Z0-9-_]+\.){2,}[a-zA-Z0-9-_]+$~', (string)$option['label'])
205 ) {
252 if (\method_exists($label, '__toString')) {
253: $label = (string)$label;
254 } elseif (
276 // resolve language item for label
277: if ($labelLanguageItems && \preg_match('~^([a-zA-Z0-9-_]+\.){2,}[a-zA-Z0-9-_]+$~', (string)$label)) {
278 $label = WCF::getLanguage()->getDynamicVariable($label);
wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeImg.class.php:
227 if ($smiley->getHeight()) {
228: $element->setAttribute('height', (string)$smiley->getHeight());
229 } else {
wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeTextParser.class.php:
616 $element->setAttribute('alt', $smileyCode);
617: $element->setAttribute('height', (string)$smiley->getHeight());
618: $element->setAttribute('width', (string)$smiley->getWidth());
619 if ($smiley->getURL2x()) {
wcfsetup/install/files/lib/system/image/adapter/GDImageAdapter.class.php:
184 // resize image
185: $image = \imagecreatetruecolor((int)$width, (int)$height);
186 \imagealphablending($image, false);
191 0,
192: (int)$x,
193: (int)$y,
194: (int)$width,
195: (int)$height,
196: (int)$sourceWidth,
197: (int)$sourceHeight
198 );
211
212: \imagecopy($image, $this->image, 0, 0, (int)$originX, (int)$originY, (int)$width, (int)$height);
213 \imagesavealpha($image, true);
231 0,
232: (int)$originX,
233: (int)$originY,
234: (int)$targetWidth,
235: (int)$targetHeight,
236: (int)$originWidth,
237: (int)$originHeight
238 );
wcfsetup/install/files/lib/system/image/adapter/ImageAdapter.class.php:
394
395: return FileUtil::checkMemoryLimit((int)($width * $height * $channels * 2.1));
396 }
wcfsetup/install/files/lib/system/importer/AbstractAttachmentImporter.class.php:
63 // check existing attachment id
64: if (\ctype_digit((string)$oldID)) {
65 $attachment = new Attachment($oldID);
wcfsetup/install/files/lib/system/importer/ArticleImporter.class.php:
81 // check old id
82: if (\ctype_digit((string)$oldID)) {
83 $article = new Article($oldID);
wcfsetup/install/files/lib/system/importer/MediaImporter.class.php:
87 // check old id
88: if (\ctype_digit((string)$oldID)) {
89 $media = new Media($oldID);
wcfsetup/install/files/lib/system/importer/PageImporter.class.php:
63 // check old id
64: if (\ctype_digit((string)$oldID)) {
65 $page = new Page($oldID);
wcfsetup/install/files/lib/system/importer/UserImporter.class.php:
123 // check existing user id
124: if (\ctype_digit((string)$oldID)) {
125 $user = new User($oldID);
wcfsetup/install/files/lib/system/language/I18nPlural.class.php:
65 {
66: $n = (string)$n;
67 $pos = \strpos($n, '.');
82 {
83: return \strlen(\preg_replace('/^[^.]*\.?/', '', (string)$n));
84 }
wcfsetup/install/files/lib/system/package/PackageManifest.class.php:
68 $requirements = \array_map(static function (array $requirement): string {
69: $file = (string)$requirement['file'];
70
85
86: $file = (string)$optional['file'];
87
wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php:
122
123: $reply = JSON::decode((string)$response->getBody());
124
wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php:
1035 if (isset($formData[$field]) && $formData[$field] !== '') {
1036: $category->appendChild($document->createElement($field, (string)$formData[$field]));
1037 }
wcfsetup/install/files/lib/system/package/plugin/BBCodePackageInstallationPlugin.class.php:
578 $attribute = $document->createElement('attribute');
579: $attribute->setAttribute('name', (string)$attributeNumber);
580
wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php:
889 if (!empty($formData['visibilityExceptions'])) {
890: $box->appendChild($document->createElement('visibleEverywhere', (string)($data['visibleEverywhere'] ?? 0)));
891
900 } elseif (!empty($data['visibleEverywhere'])) {
901: $box->appendChild($document->createElement('visibleEverywhere', (string)$data['visibleEverywhere']));
902 }
wcfsetup/install/files/lib/system/package/plugin/MenuPackageInstallationPlugin.class.php:
594 if (isset($formData['data'][$index]) && $formData['data'][$index] !== $defaultValue) {
595: $box->appendChild($document->createElement($boxProperty, (string)$formData['data'][$index]));
596 }
wcfsetup/install/files/lib/system/request/LinkHandler.class.php:
124 if (isset($parameters['isEmail'])) {
125: if ((bool)$parameters['isEmail']) {
126 $parameters['forceFrontend'] = true;
139 if (isset($parameters['isACP'])) {
140: $isACP = (bool)$parameters['isACP'];
141 unset($parameters['isACP']);
wcfsetup/install/files/lib/system/request/route/DynamicRequestRoute.class.php:
257
258: if ($pattern && !\preg_match($pattern, (string)$components[$component])) {
259 return false;
wcfsetup/install/files/lib/system/template/TemplateScriptingCompiler.class.php:
824 $phpCode .= $sectionProp . " = [];\n";
825: $phpCode .= $sectionProp . "['loop'] = (is_array(" . $args['loop'] . ") ? count(" . $args['loop'] . ") : max(0, (int)" . $args['loop'] . "));\n";
826 $phpCode .= $sectionProp . "['show'] = " . $args['show'] . ";\n";
wcfsetup/install/files/lib/system/template/plugin/AnchorFunctionTemplatePlugin.class.php:
84 } elseif (\method_exists($tagArgs['content'], '__toString')) {
85: $content = (string)$tagArgs['content'];
86 } else {
wcfsetup/install/files/lib/system/user/authentication/event/UserLoggedIn.class.php:
28 {
29: $this->userID = (int)$user->userID;
30 }
wcfsetup/install/files/lib/system/user/authentication/password/algorithm/Wcf1e.class.php:
48 $this->encryptionMethod = $matches[1];
49: $this->enableSalting = (bool)$matches[2];
50 $this->saltPosition = $matches[3];
51: $this->encryptBeforeSalting = (bool)$matches[4];
52 }
wcfsetup/install/files/lib/system/user/multifactor/totp/Totp.class.php:
66
67: $otp = \str_pad((string)($binary % (10 ** self::CODE_LENGTH)), self::CODE_LENGTH, "0", \STR_PAD_LEFT);
68
wcfsetup/install/files/lib/util/CronjobUtil.class.php:
195 $date = \explode('.', \date("d.m.Y", $timeBase));
196: $timeBase = \mktime(0, 0, 1, (int)$date[1], (int)$date[0] + 1, (int)$date[2]);
197 }
wcfsetup/install/files/lib/util/DateUtil.class.php:
477 if (\preg_match('~^(?P<year>[0-9]{4})-(?P<month>[0-9]{2})-(?P<day>[0-9]{2})~', $date, $matches)) {
478: if (!\checkdate((int)$matches['month'], (int)$matches['day'], (int)$matches['year'])) {
479 throw new SystemException("Date '" . $date . "' is invalid");
wcfsetup/install/files/lib/util/DirectoryUtil.class.php:
139 foreach ($files as $filename => $value) {
140: if (((bool)$pattern->match($filename)) === $negativeMatch) {
141 unset($files[$filename]);
176 foreach ($objects as $filename => $value) {
177: if (((bool)$pattern->match($filename)) === $negativeMatch) {
178 unset($objects[$filename]);
wcfsetup/install/files/lib/util/ExifUtil.class.php:
267 if ($i == 0) {
268: $result = (float)$coordinateData[0];
269 } elseif ($coordinateData[$i]) {
270: $result /= (float)$coordinateData[$i];
271 }
wcfsetup/install/files/lib/util/FileUtil.class.php:
463
464: $tmpFilename = '__permissions_' . \sha1((string)\time()) . '.txt';
465 @\touch($tmpFilename);
wcfsetup/install/files/lib/util/HeaderUtil.class.php:
45 @\header(
46: 'Set-Cookie: ' . \rawurlencode(COOKIE_PREFIX . $name) . '=' . \rawurlencode((string)$value) . ($expire ? '; expires=' . \gmdate(
47 'D, d-M-Y H:i:s',
wcfsetup/install/files/lib/util/HTTPRequest.class.php:
186 $redirectHandler = function (RequestInterface $request, ResponseInterface $response, UriInterface $uri) {
187: $this->url = (string)$uri;
188 $this->response = $response;
247 "Received status code '" . $this->response->getStatusCode() . "' from server",
248: (string)$this->response->getStatusCode(),
249 $e
259 "Received status code '" . $this->response->getStatusCode() . "' from server",
260: (string)$this->response->getStatusCode(),
261 $e
272 "Received status code '" . $this->response->getStatusCode() . "' from server",
273: (string)$this->response->getStatusCode(),
274 $e
336 return [
337: 'statusCode' => (string)$this->response->getStatusCode(),
338 'headers' => $legacyHeaders,
wcfsetup/install/files/lib/util/IpAddress.class.php:
107
108: return new self(\inet_ntop(\inet_pton((string)$ipAddress) & $mask));
109 }
133 $replacement,
134: (string)$masked
135 );
139 // will contain an empty entry otherwise.
140: if ((string)$masked !== '::') {
141 $quadruplets = \explode(
142 ':',
143: \preg_replace('/::$/', '', (string)$masked)
144 );
wcfsetup/install/files/lib/util/StringUtil.class.php:
117 return @\htmlspecialchars(
118: (string)$string,
119 \ENT_QUOTES | \ENT_SUBSTITUTE | \ENT_HTML401,
176 } else {
177: if (\floatval($numeric) - (float)\intval($numeric)) {
178 return self::formatDouble($numeric);
209 // round
210: $double = (string)\round($double, ($maxDecimals > 0 ? $maxDecimals : 2));
211