Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use property_exists instead of array_key_exists (continued) #515

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions _includes/includes/ui/keyboard-details.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static function get_tier_from_request($tier = 'stable') {

protected static function map_license($s) {
$license_map = ['mit' => 'MIT'];
return array_key_exists($s, $license_map) ? $license_map[$s] : $s;
return property_exists($license_map, $s) ? $license_map[$s] : $s;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect -- $license_map is an array not an object

}

protected static function download_box($platform) {
Expand Down Expand Up @@ -205,7 +205,7 @@ protected static function LoadData() {
self::$keyboardPlatforms = "<span class='platforms'>";
$vars = get_object_vars(self::$keyboard->platformSupport);
foreach ($vars as $var => $value) {
if ($value != 'none' && array_key_exists($var, $platformTitles)) {
if ($value != 'none' && property_exists($platformTitles, $var)) {
self::$keyboardPlatforms .= "<span class='platform-$var'>{$platformTitles[$var]}</span>";
}
}
Expand Down
6 changes: 3 additions & 3 deletions _includes/includes/ui/legacy-keyboard-details.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static function get_tier_from_request($tier = 'stable') {

protected static function map_license($s) {
$license_map = ['mit' => 'MIT'];
return array_key_exists($s, $license_map) ? $license_map[$s] : $s;
return property_exists($license_map, $s) ? $license_map[$s] : $s;
}

protected static function download_box($url, $title, $description, $class, $linktitle, $platform, $mode='standalone') {
Expand Down Expand Up @@ -323,7 +323,7 @@ protected static function LoadData() {
self::$keyboardPlatforms = '';
$vars = get_object_vars(self::$keyboard->platformSupport);
foreach ($vars as $var => $value) {
if ($value != 'none' && array_key_exists($var, $platformTitles)) {
if ($value != 'none' && property_exists($platformTitles, $var)) {
self::$keyboardPlatforms .= (self::$keyboardPlatforms == '' ? '' : ', ') . $platformTitles[$var];
}
}
Expand Down Expand Up @@ -441,7 +441,7 @@ protected static function WriteDownloadBoxes() {
"Android" => "self::WriteAndroidBoxes"
);

$text = (isset($pageDevice) && array_key_exists($pageDevice, $deviceboxfuncs)) ? $deviceboxfuncs[$pageDevice] : '';
$text = (isset($pageDevice) && property_exists($deviceboxfuncs, $pageDevice)) ? $deviceboxfuncs[$pageDevice] : '';
$webtext = self::WriteWebBoxes();

if ($text) {
Expand Down