diff --git a/core/includes/ajax.inc b/core/includes/ajax.inc index cb85967..4cc126a 100644 --- a/core/includes/ajax.inc +++ b/core/includes/ajax.inc @@ -279,7 +279,7 @@ function ajax_pre_render_element($element) { ); // @todo Legacy support. Remove in Drupal 8. - if (isset($settings['method']) && $settings['method'] == 'replace') { + if (isset($settings['method']) && $settings['method'] === 'replace') { $settings['method'] = 'replaceWith'; } diff --git a/core/includes/batch.inc b/core/includes/batch.inc index 47f85ed..0e2cedd 100644 --- a/core/includes/batch.inc +++ b/core/includes/batch.inc @@ -144,7 +144,7 @@ function _batch_progress_page() { // Perform actual processing. list($percentage, $message, $label) = _batch_process($batch); - if ($percentage == 100) { + if ($percentage === 100) { $new_op = 'finished'; } diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 35959e0..6aa1c43 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -313,7 +313,7 @@ function drupal_get_filename($type, $name, $filename = NULL) { // Profiles are converted into modules in system_rebuild_module_data(). // @todo Remove false-exposure of profiles as modules. $original_type = $type; - if ($type == 'profile') { + if ($type === 'profile') { $type = 'module'; } if (!isset($files[$type])) { @@ -328,7 +328,7 @@ function drupal_get_filename($type, $name, $filename = NULL) { // the list of extension pathnames from various providers, checking faster // providers first. // Retrieve the current module list (derived from the service container). - if ($type == 'module' && \Drupal::hasService('module_handler')) { + if ($type === 'module' && \Drupal::hasService('module_handler')) { foreach (\Drupal::moduleHandler()->getModuleList() as $module_name => $module) { $files[$type][$module_name] = $module->getPathname(); } @@ -342,7 +342,7 @@ function drupal_get_filename($type, $name, $filename = NULL) { if (!isset($files[$type][$name])) { $listing = new ExtensionDiscovery(); // Prevent an infinite recursion by this legacy function. - if ($original_type == 'profile') { + if ($original_type === 'profile') { $listing->setProfileDirectories(array()); } foreach ($listing->scan($original_type) as $extension_name => $file) { @@ -409,7 +409,7 @@ function drupal_page_is_cacheable($allow_caching = NULL) { $allow_caching_static = $allow_caching; } - return $allow_caching_static && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD') + return $allow_caching_static && ($_SERVER['REQUEST_METHOD'] === 'GET' || $_SERVER['REQUEST_METHOD'] === 'HEAD') && PHP_SAPI !== 'cli'; } @@ -528,7 +528,7 @@ function drupal_send_headers($default_headers = array(), $only_default = FALSE) } } foreach ($headers as $name_lower => $value) { - if ($name_lower == 'status') { + if ($name_lower === 'status') { header($_SERVER['SERVER_PROTOCOL'] . ' ' . $value); } // Skip headers that have been unset. @@ -609,7 +609,7 @@ function drupal_serve_page_from_cache(Response $response, Request $request) { } // Negotiate whether to use compression. - if ($response->headers->get('Content-Encoding') == 'gzip' && extension_loaded('zlib')) { + if ($response->headers->get('Content-Encoding') === 'gzip' && extension_loaded('zlib')) { if (strpos($request->headers->get('Accept-Encoding'), 'gzip') !== FALSE) { // The response content is already gzip'ed, so make sure // zlib.output_compression does not compress it once more. @@ -634,8 +634,8 @@ function drupal_serve_page_from_cache(Response $response, Request $request) { $if_none_match = $request->server->has('HTTP_IF_NONE_MATCH') ? stripslashes($request->server->get('HTTP_IF_NONE_MATCH')) : FALSE; if ($if_modified_since && $if_none_match - && $if_none_match == $response->getEtag() // etag must match - && $if_modified_since == $last_modified->getTimestamp()) { // if-modified-since must match + && $if_none_match === $response->getEtag() // etag must match + && $if_modified_since === $last_modified->getTimestamp()) { // if-modified-since must match $response->setStatusCode(304); $response->setContent(NULL); @@ -1230,7 +1230,7 @@ function drupal_valid_test_ua($new_prefix = NULL) { function drupal_generate_test_ua($prefix) { static $key, $last_prefix; - if (!isset($key) || $last_prefix != $prefix) { + if (!isset($key) || $last_prefix !== $prefix) { $last_prefix = $prefix; $key_file = DRUPAL_ROOT . '/sites/simpletest/' . substr($prefix, 10) . '/.htkey'; // When issuing an outbound HTTP client request from within an inbound test @@ -1239,7 +1239,7 @@ function drupal_generate_test_ua($prefix) { // prefix would invalidate all subsequent inbound requests. // @see \Drupal\Core\Http\Plugin\SimpletestHttpRequestSubscriber if (DRUPAL_TEST_IN_CHILD_SITE && $parent_prefix = drupal_valid_test_ua()) { - if ($parent_prefix != $prefix) { + if ($parent_prefix !== $prefix) { throw new \RuntimeException("Malformed User-Agent: Expected '$parent_prefix' but got '$prefix'."); } // If the file is not readable, a PHP warning is expected in this case. @@ -1373,7 +1373,7 @@ function request_path() { // page might be accessed as http://example.com/user or as // http://example.com/index.php/user. Strip the script name from $path. $script = basename($_SERVER['SCRIPT_NAME']); - if ($path == $script) { + if ($path === $script) { $path = ''; } elseif (strpos($path, $script . '/') === 0) { @@ -1546,7 +1546,7 @@ function &drupal_static($name, $default_value = NULL, $reset = FALSE) { $default[$name] = $data[$name] = $default_value; return $data[$name]; } - // Reset all: ($name == NULL). This needs to be done one at a time so that + // Reset all: ($name === NULL). This needs to be done one at a time so that // references returned by earlier invocations of drupal_static() also get // reset. foreach ($default as $name => $value) { diff --git a/core/includes/common.inc b/core/includes/common.inc index 3d245a0..cd1ad97 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -328,7 +328,7 @@ function drupal_get_destination() { else { $path = current_path(); $query = UrlHelper::buildQuery(UrlHelper::filterQueryParameters($query->all())); - if ($query != '') { + if ($query !== '') { $path .= '?' . $query; } $destination = array('destination' => $path); @@ -431,7 +431,7 @@ function format_xml_elements($array) { $output .= new Attribute($value['attributes']); } - if (isset($value['value']) && $value['value'] != '') { + if (isset($value['value']) && $value['value'] !== '') { $output .= '>' . (is_array($value['value']) ? format_xml_elements($value['value']) : String::checkPlain($value['value'])) . '\n"; } else { @@ -615,11 +615,11 @@ function _format_date_callback(array $matches = NULL, $new_langcode = NULL) { 'langcode' => $langcode, ); - if ($code == 'F') { + if ($code === 'F') { $options['context'] = 'Long month name'; } - if ($code == '') { + if ($code === '') { $cache[$langcode][$code][$string] = $string; } else { @@ -842,7 +842,7 @@ function drupal_set_time_limit($time_limit) { if (function_exists('set_time_limit')) { $current = ini_get('max_execution_time'); // Do not set time limit if it is currently unlimited. - if ($current != 0) { + if ($current !== 0) { @set_time_limit($time_limit); } } @@ -1647,7 +1647,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS // Filter out elements of the given scope. $items = array(); foreach ($javascript as $key => $item) { - if ($item['scope'] == $scope) { + if ($item['scope'] === $scope) { $items[$key] = $item; } } @@ -1696,7 +1696,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS // because drupal_get_js() was intentionally passed a $javascript argument // stripped of settings, potentially in order to override how settings get // output, so in this case, do not add the setting to this output. - if ($scope == 'header' && isset($items['settings'])) { + if ($scope === 'header' && isset($items['settings'])) { $items['settings']['data'][] = $setting; } } @@ -2050,7 +2050,7 @@ function drupal_process_states(&$elements) { // still want to be able to show/hide them. Since there's no actual HTML input // element available, setting #attributes does not make sense, but a wrapper // is available, so setting #wrapper_attributes makes it work. - $key = ($elements['#type'] == 'item') ? '#wrapper_attributes' : '#attributes'; + $key = ($elements['#type'] === 'item') ? '#wrapper_attributes' : '#attributes'; $elements[$key]['data-drupal-states'] = JSON::encode($elements['#states']); } @@ -2486,7 +2486,7 @@ function drupal_prepare_page($page) { // Allow menu callbacks to return strings or arbitrary arrays to render. // If the array returned is not of #type page directly, we need to fill // in the page with defaults. - if (is_string($page) || (is_array($page) && (!isset($page['#type']) || ($page['#type'] != 'page')))) { + if (is_string($page) || (is_array($page) && (!isset($page['#type']) || ($page['#type'] !== 'page')))) { drupal_set_page_content($page); $page = element_info('page'); } @@ -3020,7 +3020,7 @@ function render(&$element) { } if (is_array($element)) { // Early return if this element was pre-rendered (no need to re-render). - if (isset($element['#printed']) && $element['#printed'] == TRUE && isset($element['#markup']) && strlen($element['#markup']) > 0) { + if (isset($element['#printed']) && $element['#printed'] === TRUE && isset($element['#markup']) && strlen($element['#markup']) > 0) { return $element['#markup']; } show($element); diff --git a/core/includes/database.inc b/core/includes/database.inc index d1fef5a..7c3e302 100644 --- a/core/includes/database.inc +++ b/core/includes/database.inc @@ -195,7 +195,7 @@ * function my_other_function($id) { * // The transaction is still open here. * - * if ($id % 2 == 0) { + * if ($id % 2 === 0) { * db_update('example') * ->condition('id', $id) * ->fields(array('field2' => 10)) @@ -342,7 +342,7 @@ function db_query_temporary($query, array $args = array(), array $options = arra * A new Insert object for this connection. */ function db_insert($table, array $options = array()) { - if (empty($options['target']) || $options['target'] == 'replica') { + if (empty($options['target']) || $options['target'] === 'replica') { $options['target'] = 'default'; } return Database::getConnection($options['target'])->insert($table, $options); @@ -360,7 +360,7 @@ function db_insert($table, array $options = array()) { * A new Merge object for this connection. */ function db_merge($table, array $options = array()) { - if (empty($options['target']) || $options['target'] == 'replica') { + if (empty($options['target']) || $options['target'] === 'replica') { $options['target'] = 'default'; } return Database::getConnection($options['target'])->merge($table, $options); @@ -378,7 +378,7 @@ function db_merge($table, array $options = array()) { * A new Update object for this connection. */ function db_update($table, array $options = array()) { - if (empty($options['target']) || $options['target'] == 'replica') { + if (empty($options['target']) || $options['target'] === 'replica') { $options['target'] = 'default'; } return Database::getConnection($options['target'])->update($table, $options); @@ -396,7 +396,7 @@ function db_update($table, array $options = array()) { * A new Delete object for this connection. */ function db_delete($table, array $options = array()) { - if (empty($options['target']) || $options['target'] == 'replica') { + if (empty($options['target']) || $options['target'] === 'replica') { $options['target'] = 'default'; } return Database::getConnection($options['target'])->delete($table, $options); @@ -414,7 +414,7 @@ function db_delete($table, array $options = array()) { * A new Truncate object for this connection. */ function db_truncate($table, array $options = array()) { - if (empty($options['target']) || $options['target'] == 'replica') { + if (empty($options['target']) || $options['target'] === 'replica') { $options['target'] = 'default'; } return Database::getConnection($options['target'])->truncate($table, $options); diff --git a/core/includes/errors.inc b/core/includes/errors.inc index 1048e0e..7ab6432 100644 --- a/core/includes/errors.inc +++ b/core/includes/errors.inc @@ -74,7 +74,7 @@ function _drupal_error_handler_real($error_level, $message, $filename, $line, $c '%line' => $caller['line'], 'severity_level' => $severity_level, 'backtrace' => $backtrace, - ), $error_level == E_RECOVERABLE_ERROR); + ), $error_level === E_RECOVERABLE_ERROR); } } @@ -96,11 +96,11 @@ function error_displayable($error = NULL) { return TRUE; } $error_level = _drupal_get_error_level(); - if ($error_level == ERROR_REPORTING_DISPLAY_ALL || $error_level == ERROR_REPORTING_DISPLAY_VERBOSE) { + if ($error_level === ERROR_REPORTING_DISPLAY_ALL || $error_level === ERROR_REPORTING_DISPLAY_VERBOSE) { return TRUE; } - if ($error_level == ERROR_REPORTING_DISPLAY_SOME && isset($error)) { - return $error['%type'] != 'Notice' && $error['%type'] != 'Strict warning'; + if ($error_level === ERROR_REPORTING_DISPLAY_SOME && isset($error)) { + return $error['%type'] !== 'Notice' && $error['%type'] !== 'Strict warning'; } return FALSE; } @@ -192,7 +192,7 @@ function _drupal_log_error($error, $fatal = FALSE) { // If error type is 'User notice' then treat it as debug information // instead of an error message. // @see debug() - if ($error['%type'] == 'User notice') { + if ($error['%type'] === 'User notice') { $error['%type'] = 'Debug'; $class = 'status'; } @@ -200,7 +200,7 @@ function _drupal_log_error($error, $fatal = FALSE) { // Attempt to reduce verbosity by removing DRUPAL_ROOT from the file path // in the message. This does not happen for (false) security. $root_length = strlen(DRUPAL_ROOT); - if (substr($error['%file'], 0, $root_length) == DRUPAL_ROOT) { + if (substr($error['%file'], 0, $root_length) === DRUPAL_ROOT) { $error['%file'] = substr($error['%file'], $root_length + 1); } // Should not translate the string to avoid errors producing more errors. @@ -209,7 +209,7 @@ function _drupal_log_error($error, $fatal = FALSE) { // Check if verbose error reporting is on. $error_level = _drupal_get_error_level(); - if ($error_level == ERROR_REPORTING_DISPLAY_VERBOSE) { + if ($error_level === ERROR_REPORTING_DISPLAY_VERBOSE) { // First trace is the error itself, already contained in the message. // While the second trace is the error source and also contained in the // message, the message doesn't contain argument values, so we output it diff --git a/core/includes/file.inc b/core/includes/file.inc index 6ffb269..3c8268a 100644 --- a/core/includes/file.inc +++ b/core/includes/file.inc @@ -231,7 +231,7 @@ function file_get_stream_wrappers($filter = STREAM_WRAPPERS_ALL) { else { $wrappers[$scheme]['override'] = FALSE; } - if (($info['type'] & STREAM_WRAPPERS_LOCAL) == STREAM_WRAPPERS_LOCAL) { + if (($info['type'] & STREAM_WRAPPERS_LOCAL) === STREAM_WRAPPERS_LOCAL) { stream_wrapper_register($scheme, $info['class']); } else { @@ -240,7 +240,7 @@ function file_get_stream_wrappers($filter = STREAM_WRAPPERS_ALL) { } // Pre-populate the static cache with the filters most typically used. $wrappers_storage[STREAM_WRAPPERS_ALL][$scheme] = $wrappers[$scheme]; - if (($info['type'] & STREAM_WRAPPERS_WRITE_VISIBLE) == STREAM_WRAPPERS_WRITE_VISIBLE) { + if (($info['type'] & STREAM_WRAPPERS_WRITE_VISIBLE) === STREAM_WRAPPERS_WRITE_VISIBLE) { $wrappers_storage[STREAM_WRAPPERS_WRITE_VISIBLE][$scheme] = $wrappers[$scheme]; } } @@ -250,7 +250,7 @@ function file_get_stream_wrappers($filter = STREAM_WRAPPERS_ALL) { $wrappers_storage[$filter] = array(); foreach ($wrappers_storage[STREAM_WRAPPERS_ALL] as $scheme => $info) { // Bit-wise filter. - if (($info['type'] & $filter) == $filter) { + if (($info['type'] & $filter) === $filter) { $wrappers_storage[$filter][$scheme] = $info; } } @@ -326,7 +326,7 @@ function file_uri_target($uri) { $data = explode('://', $uri, 2); // Remove erroneous leading or trailing, forward-slashes and backslashes. - return count($data) == 2 ? trim($data[1], '\/') : FALSE; + return count($data) === 2 ? trim($data[1], '\/') : FALSE; } /** @@ -467,7 +467,7 @@ function file_create_url($uri) { // HTTP and to https://example.com/bar.jpg when viewing a HTTPS page) // Both types of relative URIs are characterized by a leading slash, hence // we can use a single check. - if (drupal_substr($uri, 0, 1) == '/') { + if (drupal_substr($uri, 0, 1) === '/') { return $uri; } else { @@ -476,7 +476,7 @@ function file_create_url($uri) { return $GLOBALS['base_url'] . '/' . UrlHelper::encodePath($uri); } } - elseif ($scheme == 'http' || $scheme == 'https') { + elseif ($scheme === 'http' || $scheme === 'https') { // Check for HTTP so that we don't have to implement getExternalUrl() for // the HTTP wrapper. return $uri; @@ -517,7 +517,7 @@ function file_url_transform_relative($file_url) { $host = $request->getHost(); $scheme = $request->getScheme(); $port = $request->getPort() ?: 80; - if (('http' == $scheme && $port == 80) || ('https' == $scheme && $port == 443)) { + if (('http' === $scheme && $port === 80) || ('https' === $scheme && $port === 443)) { $http_host = $host; } else { @@ -744,7 +744,7 @@ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXIST // Assert that the source and destination filenames are not the same. $real_source = drupal_realpath($source); $real_destination = drupal_realpath($destination); - if ($source == $destination || ($real_source !== FALSE) && ($real_source == $real_destination)) { + if ($source === $destination || ($real_source !== FALSE) && ($real_source === $real_destination)) { drupal_set_message(t('The specified file %file was not copied because it would overwrite itself.', array('%file' => $source)), 'error'); $logger->notice('File %file could not be copied because it would overwrite itself.', array('%file' => $source)); return FALSE; @@ -835,7 +835,7 @@ function file_destination($destination, $replace) { */ function file_unmanaged_move($source, $destination = NULL, $replace = FILE_EXISTS_RENAME) { $filepath = file_unmanaged_copy($source, $destination, $replace); - if ($filepath == FALSE || file_unmanaged_delete($source) == FALSE) { + if ($filepath === FALSE || file_unmanaged_delete($source) === FALSE) { return FALSE; } return $filepath; @@ -899,7 +899,7 @@ function file_munge_filename($filename, $extensions, $alerts = TRUE) { } $filename = $new_filename . '.' . $final_extension; - if ($alerts && $original != $filename) { + if ($alerts && $original !== $filename) { drupal_set_message(t('For security reasons, your upload has been renamed to %filename.', array('%filename' => $filename))); } } @@ -939,13 +939,13 @@ function file_create_filename($basename, $directory) { // Strip control characters (ASCII value < 32). Though these are allowed in // some filesystems, not many applications handle them well. $basename = preg_replace('/[\x00-\x1F]/u', '_', $basename); - if (substr(PHP_OS, 0, 3) == 'WIN') { + if (substr(PHP_OS, 0, 3) === 'WIN') { // These characters are not allowed in Windows filenames $basename = str_replace(array(':', '*', '?', '"', '<', '>', '|'), '_', $basename); } // A URI or path may already have a trailing slash or look like "public://". - if (substr($directory, -1) == '/') { + if (substr($directory, -1) === '/') { $separator = ''; } else { @@ -1078,7 +1078,7 @@ function file_unmanaged_delete_recursive($path, $callback = NULL) { if (is_dir($path)) { $dir = dir($path); while (($entry = $dir->read()) !== FALSE) { - if ($entry == '.' || $entry == '..') { + if ($entry === '.' || $entry === '..') { continue; } $entry_path = $path . '/' . $entry; @@ -1214,7 +1214,7 @@ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) { 'min_depth' => 0, ); // Normalize $dir only once. - if ($depth == 0) { + if ($depth === 0) { $dir = file_stream_wrapper_uri_normalize($dir); $dir_has_slash = (substr($dir, -1) === '/'); } @@ -1227,8 +1227,8 @@ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) { if ($handle = @opendir($dir)) { while (FALSE !== ($filename = readdir($handle))) { // Skip this file if it matches the nomask or starts with a dot. - if ($filename[0] != '.' && !(isset($options['nomask']) && preg_match($options['nomask'], $filename))) { - if ($depth == 0 && $dir_has_slash) { + if ($filename[0] !== '.' && !(isset($options['nomask']) && preg_match($options['nomask'], $filename))) { + if ($depth === 0 && $dir_has_slash) { $uri = "$dir$filename"; } else { @@ -1378,7 +1378,7 @@ function drupal_chmod($uri, $mode = NULL) { */ function drupal_unlink($uri, $context = NULL) { $scheme = file_uri_scheme($uri); - if (!file_stream_wrapper_valid_scheme($scheme) && (substr(PHP_OS, 0, 3) == 'WIN')) { + if (!file_stream_wrapper_valid_scheme($scheme) && (substr(PHP_OS, 0, 3) === 'WIN')) { chmod($uri, 0600); } if ($context) { @@ -1464,7 +1464,7 @@ function drupal_dirname($uri) { */ function drupal_basename($uri, $suffix = NULL) { $separators = '/'; - if (DIRECTORY_SEPARATOR != '/') { + if (DIRECTORY_SEPARATOR !== '/') { // For Windows OS add special separator. $separators .= DIRECTORY_SEPARATOR; } @@ -1529,7 +1529,7 @@ function drupal_mkdir($uri, $mode = NULL, $recursive = FALSE, $context = NULL) { $components = explode(DIRECTORY_SEPARATOR, $uri); // If the filepath is absolute the first component will be empty as there // will be nothing before the first slash. - if ($components[0] == '') { + if ($components[0] === '') { $recursive_path = DIRECTORY_SEPARATOR; // Get rid of the empty first component. array_shift($components); @@ -1600,7 +1600,7 @@ function _drupal_mkdir_call($uri, $mode, $recursive, $context) { */ function drupal_rmdir($uri, $context = NULL) { $scheme = file_uri_scheme($uri); - if (!file_stream_wrapper_valid_scheme($scheme) && (substr(PHP_OS, 0, 3) == 'WIN')) { + if (!file_stream_wrapper_valid_scheme($scheme) && (substr(PHP_OS, 0, 3) === 'WIN')) { chmod($uri, 0700); } if ($context) { @@ -1696,7 +1696,7 @@ function file_directory_os_temp() { } // Operating system specific dirs. - if (substr(PHP_OS, 0, 3) == 'WIN') { + if (substr(PHP_OS, 0, 3) === 'WIN') { $directories[] = 'c:\\windows\\temp'; $directories[] = 'c:\\winnt\\temp'; } diff --git a/core/includes/form.inc b/core/includes/form.inc index 260ffbe..b9811e3 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -76,10 +76,10 @@ function drupal_process_form($form_id, &$form, FormStateInterface $form_state) { * @see \Drupal\Core\Form\FormValidatorInterface::executeValidateHandlers() */ function form_execute_handlers($type, &$form, FormStateInterface $form_state) { - if ($type == 'submit') { + if ($type === 'submit') { \Drupal::service('form_submitter')->executeSubmitHandlers($form, $form_state); } - elseif ($type == 'validate') { + elseif ($type === 'validate') { \Drupal::service('form_validator')->executeValidateHandlers($form, $form_state); } } @@ -226,7 +226,7 @@ function form_select_options($element, $choices = NULL) { } else { $key = (string) $key; - $empty_choice = $empty_value && $key == '_none'; + $empty_choice = $empty_value && $key === '_none'; if ($value_valid && ((!$value_is_array && (string) $element['#value'] === $key || ($value_is_array && in_array($key, $element['#value']))) || $empty_choice)) { $selected = ' selected="selected"'; } @@ -282,7 +282,7 @@ function form_get_options($element, $key) { $keys[] = $index; } } - elseif ($index == $key) { + elseif ($index === $key) { $keys[] = $index; } } @@ -310,7 +310,7 @@ function template_preprocess_fieldset(&$variables) { $variables['suffix'] = isset($element['#field_suffix']) ? $element['#field_suffix'] : NULL; $variables['children'] = $element['#children']; $legend_attributes = array(); - if (isset($element['#title_display']) && $element['#title_display'] == 'invisible') { + if (isset($element['#title_display']) && $element['#title_display'] === 'invisible') { $legend_attributes['class'][] = 'visually-hidden'; } $variables['legend']['attributes'] = new Attribute($legend_attributes); @@ -588,7 +588,7 @@ function template_preprocess_form_element(&$variables) { $element['#title_display'] = 'none'; } // If #title_dislay is not some of the visible options, add a CSS class. - if ($element['#title_display'] != 'before' && $element['#title_display'] != 'after') { + if ($element['#title_display'] !== 'before' && $element['#title_display'] !== 'after') { $variables['attributes']['class'][] = 'form-no-label'; } @@ -644,11 +644,11 @@ function template_preprocess_form_element_label(&$variables) { $variables['title'] = (isset($element['#title']) && $element['#title'] !== '') ? Xss::filterAdmin($element['#title']) : ''; $variables['attributes'] = array(); // Style the label as class option to display inline with the element. - if ($element['#title_display'] == 'after') { + if ($element['#title_display'] === 'after') { $variables['attributes']['class'][] = 'option'; } // Show label only to screen readers to avoid disruption in visual flows. - elseif ($element['#title_display'] == 'invisible') { + elseif ($element['#title_display'] === 'invisible') { $variables['attributes']['class'][] = 'visually-hidden'; } @@ -761,7 +761,7 @@ function template_preprocess_form_element_label(&$variables) { * $context['sandbox']['current_id'] = $row->id; * $context['message'] = String::checkPlain($row->title); * } - * if ($context['sandbox']['progress'] != $context['sandbox']['max']) { + * if ($context['sandbox']['progress'] !== $context['sandbox']['max']) { * $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; * } * } diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index f1e0be1..860ceb0 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -481,7 +481,7 @@ function install_run_tasks(&$install_state) { $install_state['active_task'] = $task_name; $original_parameters = $install_state['parameters']; $output = install_run_task($task, $install_state); - $install_state['parameters_changed'] = ($install_state['parameters'] != $original_parameters); + $install_state['parameters_changed'] = ($install_state['parameters'] !== $original_parameters); // Store this task as having been performed during the current request, // and save it to the database as completed, if we need to and if the // database is in a state that allows us to do so. Also mark the @@ -489,7 +489,7 @@ function install_run_tasks(&$install_state) { if (!$install_state['task_not_complete']) { $install_state['tasks_performed'][] = $task_name; $install_state['installation_finished'] = empty($tasks_to_perform); - if ($task['run'] == INSTALL_TASK_RUN_IF_NOT_COMPLETED || $install_state['installation_finished']) { + if ($task['run'] === INSTALL_TASK_RUN_IF_NOT_COMPLETED || $install_state['installation_finished']) { \Drupal::state()->set('install_task', $install_state['installation_finished'] ? 'done' : $task_name); } } @@ -517,10 +517,10 @@ function install_run_tasks(&$install_state) { function install_run_task($task, &$install_state) { $function = $task['function']; - if ($task['type'] == 'form') { + if ($task['type'] === 'form') { return install_get_form($function, $install_state); } - elseif ($task['type'] == 'batch') { + elseif ($task['type'] === 'batch') { // Start a new batch based on the task function, if one is not running // already. $current_batch = \Drupal::state()->get('install_current_batch'); @@ -555,7 +555,7 @@ function install_run_task($task, &$install_state) { } // If we are in the middle of processing this batch, keep sending back // any output from the batch process, until the task is complete. - elseif ($current_batch == $function) { + elseif ($current_batch === $function) { $output = _batch_page(\Drupal::request()); // Because Batch API now returns a JSON response for intermediary steps, // but the installer doesn't handle Response objects yet, just send the @@ -611,10 +611,10 @@ function install_tasks_to_perform($install_state) { // Also, if we started this page request with an indication of the last // task that was completed, skip that task and all those that come before // it, unless they are marked as always needing to run. - if ($task['run'] == INSTALL_TASK_SKIP || in_array($name, $install_state['tasks_performed']) || (!empty($install_state['completed_task']) && empty($completed_task_found) && $task['run'] != INSTALL_TASK_RUN_IF_REACHED)) { + if ($task['run'] === INSTALL_TASK_SKIP || in_array($name, $install_state['tasks_performed']) || (!empty($install_state['completed_task']) && empty($completed_task_found) && $task['run'] !== INSTALL_TASK_RUN_IF_REACHED)) { unset($tasks[$name]); } - if (!empty($install_state['completed_task']) && $name == $install_state['completed_task']) { + if (!empty($install_state['completed_task']) && $name === $install_state['completed_task']) { $completed_task_found = TRUE; } } @@ -640,11 +640,11 @@ function install_tasks($install_state) { // Determine whether a translation file must be imported during the // 'install_import_translations' task. Import when a non-English language is // available and selected. - $needs_translations = count($install_state['translations']) > 1 && !empty($install_state['parameters']['langcode']) && $install_state['parameters']['langcode'] != 'en'; + $needs_translations = count($install_state['translations']) > 1 && !empty($install_state['parameters']['langcode']) && $install_state['parameters']['langcode'] !== 'en'; // Determine whether a translation file must be downloaded during the // 'install_download_translation' task. Download when a non-English language // is selected, but no translation is yet in the translations directory. - $needs_download = isset($install_state['parameters']['langcode']) && !isset($install_state['translations'][$install_state['parameters']['langcode']]) && $install_state['parameters']['langcode'] != 'en'; + $needs_download = isset($install_state['parameters']['langcode']) && !isset($install_state['translations'][$install_state['parameters']['langcode']]) && $install_state['parameters']['langcode'] !== 'en'; // Start with the core installation tasks that run before handing control // to the installation profile. @@ -658,7 +658,7 @@ function install_tasks($install_state) { ), 'install_select_profile' => array( 'display_name' => t('Choose profile'), - 'display' => empty($install_state['profile_info']['distribution']['name']) && count($install_state['profiles']) != 1, + 'display' => empty($install_state['profile_info']['distribution']['name']) && count($install_state['profiles']) !== 1, 'run' => INSTALL_TASK_RUN_IF_REACHED, ), 'install_load_profile' => array( @@ -993,7 +993,7 @@ function install_verify_completed_task() { catch (\Exception $e) { } if (isset($task)) { - if ($task == 'done') { + if ($task === 'done') { throw new AlreadyInstalledException(\Drupal::service('string_translation')); } return $task; @@ -1107,7 +1107,7 @@ function install_select_profile(&$install_state) { */ function _install_select_profile(&$install_state) { // Don't need to choose profile if only one available. - if (count($install_state['profiles']) == 1) { + if (count($install_state['profiles']) === 1) { return key($install_state['profiles']); } if (!empty($install_state['parameters']['profile'])) { @@ -1179,7 +1179,7 @@ function install_select_language(&$install_state) { if (!empty($install_state['parameters']['langcode'])) { $standard_languages = LanguageManager::getStandardLanguageList(); $langcode = $install_state['parameters']['langcode']; - if ($langcode == 'en' || isset($files[$langcode]) || isset($standard_languages[$langcode])) { + if ($langcode === 'en' || isset($files[$langcode]) || isset($standard_languages[$langcode])) { $install_state['parameters']['langcode'] = $langcode; return; } @@ -1198,7 +1198,7 @@ function install_select_language(&$install_state) { // (English) is available, assume the user knows what he is doing. Otherwise // thow an error. else { - if (count($files) == 1) { + if (count($files) === 1) { $install_state['parameters']['langcode'] = current(array_keys($files)); return; } @@ -1555,7 +1555,7 @@ function install_import_translations(&$install_state) { // If a non-English language was selected, remove English and import the // translations. - if ($langcode != 'en') { + if ($langcode !== 'en') { entity_delete_multiple('configurable_language', array('en')); // Set up a batch to import translations for the newly added language. @@ -2061,11 +2061,11 @@ function install_display_requirements($install_state, $requirements) { // If there are errors, always display them. If there are only warnings, skip // them if the user has provided a URL parameter acknowledging the warnings // and indicating a desire to continue anyway. See drupal_requirements_url(). - if ($severity == REQUIREMENT_ERROR || ($severity == REQUIREMENT_WARNING && empty($install_state['parameters']['continue']))) { + if ($severity === REQUIREMENT_ERROR || ($severity === REQUIREMENT_WARNING && empty($install_state['parameters']['continue']))) { if ($install_state['interactive']) { $build['report']['#theme'] = 'status_report'; $build['report']['#requirements'] = $requirements; - if ($severity == REQUIREMENT_WARNING) { + if ($severity === REQUIREMENT_WARNING) { $build['#title'] = t('Requirements review'); $build['#suffix'] = t('Check the messages and retry, or you may choose to continue anyway.', array('!retry' => check_url(drupal_requirements_url(REQUIREMENT_ERROR)), '!cont' => check_url(drupal_requirements_url($severity)))); } @@ -2082,7 +2082,7 @@ function install_display_requirements($install_state, $requirements) { // Skip warnings altogether for non-interactive installations; these // proceed in a single request so there is no good opportunity (and no // good method) to warn the user anyway. - if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) { + if (isset($requirement['severity']) && $requirement['severity'] === REQUIREMENT_ERROR) { $failures[] = $requirement['title'] . ': ' . $requirement['value'] . "\n\n" . $requirement['description']; } } diff --git a/core/includes/install.inc b/core/includes/install.inc index d1c1596..4f7f74f 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -201,7 +201,7 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) { $variable_names = array(); $settings_settings = array(); foreach ($settings as $setting => $data) { - if ($setting != 'settings') { + if ($setting !== 'settings') { _drupal_rewrite_settings_global($GLOBALS[$setting], $data); } else { @@ -242,10 +242,10 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) { } break; case 'candidate_left': - if ($value == '[') { + if ($value === '[') { $state = 'array_index'; } - if ($value == '=') { + if ($value === '=') { $state = 'candidate_right'; } break; @@ -260,7 +260,7 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) { } break; case 'right_bracket': - if ($value == ']') { + if ($value === ']') { if (isset($current[$index])) { // If the new settings has this index, descend into it. $parent = &$current; @@ -290,12 +290,12 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) { } break; case 'wait_for_semicolon': - if ($value == ';') { + if ($value === ';') { $state = 'default'; } break; case 'semicolon_skip': - if ($value == ';') { + if ($value === ';') { $value = ''; $state = 'default'; } @@ -351,10 +351,10 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) { * TRUE if this token represents a scalar or NULL. */ function _drupal_rewrite_settings_is_simple($type, $value) { - $is_integer = $type == T_LNUMBER; - $is_float = $type == T_DNUMBER; - $is_string = $type == T_CONSTANT_ENCAPSED_STRING; - $is_boolean_or_null = $type == T_STRING && in_array(strtoupper($value), array('TRUE', 'FALSE', 'NULL')); + $is_integer = $type === T_LNUMBER; + $is_float = $type === T_DNUMBER; + $is_string = $type === T_CONSTANT_ENCAPSED_STRING; + $is_boolean_or_null = $type === T_STRING && in_array(strtoupper($value), array('TRUE', 'FALSE', 'NULL')); return $is_integer || $is_float || $is_string || $is_boolean_or_null; } @@ -373,9 +373,9 @@ function _drupal_rewrite_settings_is_simple($type, $value) { * TRUE if this token represents a number or a string. */ function _drupal_rewrite_settings_is_array_index($type) { - $is_integer = $type == T_LNUMBER; - $is_float = $type == T_DNUMBER; - $is_string = $type == T_CONSTANT_ENCAPSED_STRING; + $is_integer = $type === T_LNUMBER; + $is_float = $type === T_DNUMBER; + $is_string = $type === T_CONSTANT_ENCAPSED_STRING; return $is_integer || $is_float || $is_string; } @@ -703,7 +703,7 @@ function drupal_verify_install_file($file, $mask = NULL, $type = 'file') { switch ($current_mask) { case FILE_EXIST: if (!file_exists($file)) { - if ($type == 'dir') { + if ($type === 'dir') { drupal_install_mkdir($file, $mask); } if (!file_exists($file)) { @@ -943,7 +943,7 @@ function drupal_requirements_url($severity) { $query = array(); // If there are no errors, only warnings, append 'continue=1' to the URL so // the user can bypass this screen on the next page load. - if ($severity == REQUIREMENT_WARNING) { + if ($severity === REQUIREMENT_WARNING) { $query['continue'] = 1; } return drupal_current_script_url($query); @@ -1014,10 +1014,10 @@ function drupal_check_module($module) { module_load_install($module); // Check requirements $requirements = \Drupal::moduleHandler()->invoke($module, 'requirements', array('install')); - if (is_array($requirements) && drupal_requirements_severity($requirements) == REQUIREMENT_ERROR) { + if (is_array($requirements) && drupal_requirements_severity($requirements) === REQUIREMENT_ERROR) { // Print any error messages foreach ($requirements as $requirement) { - if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) { + if (isset($requirement['severity']) && $requirement['severity'] === REQUIREMENT_ERROR) { $message = $requirement['description']; if (isset($requirement['value']) && $requirement['value']) { $message .= ' (' . t('Currently using !item !version', array('!item' => $requirement['title'], '!version' => $requirement['value'])) . ')'; @@ -1098,7 +1098,7 @@ function install_profile_info($profile, $langcode = 'en') { // Remove that dependency, since a module cannot depend on itself. $required = array_diff(drupal_required_modules(), array($profile)); - $locale = !empty($langcode) && $langcode != 'en' ? array('locale') : array(); + $locale = !empty($langcode) && $langcode !== 'en' ? array('locale') : array(); $info['dependencies'] = array_unique(array_merge($required, $info['dependencies'], $locale)); diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 51dcd9a..5941789 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -488,7 +488,7 @@ function menu_secondary_menu() { // If the secondary menu source is set as the primary menu, we display the // second level of the primary menu. - if ($secondary_links_source == $main_links_source) { + if ($secondary_links_source === $main_links_source) { return menu_navigation_links($main_links_source, 1); } else { diff --git a/core/includes/pager.inc b/core/includes/pager.inc index 3dae62e..fbfb15f 100644 --- a/core/includes/pager.inc +++ b/core/includes/pager.inc @@ -318,7 +318,7 @@ function template_preprocess_pager(&$variables) { } // When there is more than one page, create the pager list. - if ($i != $pager_max) { + if ($i !== $pager_max) { // Check whether there are further previous pages. if ($i > 1) { $items[] = array( @@ -351,7 +351,7 @@ function template_preprocess_pager(&$variables) { ), ); } - if ($i == $pager_current) { + if ($i === $pager_current) { $items[] = array( '#wrapper_attributes' => array('class' => array('pager-current')), '#markup' => $i, diff --git a/core/includes/schema.inc b/core/includes/schema.inc index f181c54..433619a 100644 --- a/core/includes/schema.inc +++ b/core/includes/schema.inc @@ -380,7 +380,7 @@ function drupal_write_record($table, &$record, $primary_keys = array()) { // Go through the schema to determine fields to write. foreach ($schema['fields'] as $field => $info) { - if ($info['type'] == 'serial') { + if ($info['type'] === 'serial') { // Skip serial types if we are updating. if (!empty($primary_keys)) { continue; @@ -407,7 +407,7 @@ function drupal_write_record($table, &$record, $primary_keys = array()) { // always exist, as they cannot be unset. Therefore, if $field is a serial // type and the value is NULL, skip it. // @see http://php.net/manual/en/function.property-exists.php - if ($info['type'] == 'serial' && !isset($object->$field)) { + if ($info['type'] === 'serial' && !isset($object->$field)) { $default_fields[] = $field; continue; } @@ -465,7 +465,7 @@ function drupal_write_record($table, &$record, $primary_keys = array()) { if (isset($serial)) { // If the database was not told to return the last insert id, it will be // because we already know it. - if (isset($options) && $options['return'] != Database::RETURN_INSERT_ID) { + if (isset($options) && $options['return'] !== Database::RETURN_INSERT_ID) { $object->$serial = $fields[$serial]; } else { @@ -477,7 +477,7 @@ function drupal_write_record($table, &$record, $primary_keys = array()) { // query failed. Note that we explicitly check for FALSE, because // a valid update query which doesn't change any values will return // zero (0) affected rows. - elseif ($query_return === FALSE && count($primary_keys) == 1) { + elseif ($query_return === FALSE && count($primary_keys) === 1) { $return = FALSE; } @@ -516,10 +516,10 @@ function drupal_write_record($table, &$record, $primary_keys = array()) { function drupal_schema_get_field_value(array $info, $value) { // Preserve legal NULL values. if (isset($value) || !empty($info['not null'])) { - if ($info['type'] == 'int' || $info['type'] == 'serial') { + if ($info['type'] === 'int' || $info['type'] === 'serial') { $value = (int) $value; } - elseif ($info['type'] == 'float') { + elseif ($info['type'] === 'float') { $value = (float) $value; } elseif (!is_array($value)) { diff --git a/core/includes/tablesort.inc b/core/includes/tablesort.inc index 0b3574f..3d8665b 100644 --- a/core/includes/tablesort.inc +++ b/core/includes/tablesort.inc @@ -43,12 +43,12 @@ function tablesort_header(&$cell_content, array &$cell_attributes, array $header // Special formatting for the currently sorted column header. if (isset($cell_attributes['field'])) { $title = t('sort by @s', array('@s' => $cell_content)); - if ($cell_content == $ts['name']) { + if ($cell_content === $ts['name']) { // aria-sort is a WAI-ARIA property that indicates if items in a table // or grid are sorted in ascending or descending order. See // http://www.w3.org/TR/wai-aria/states_and_properties#aria-sort - $cell_attributes['aria-sort'] = ($ts['sort'] == 'asc') ? 'ascending' : 'descending'; - $ts['sort'] = (($ts['sort'] == 'asc') ? 'desc' : 'asc'); + $cell_attributes['aria-sort'] = ($ts['sort'] === 'asc') ? 'ascending' : 'descending'; + $ts['sort'] = (($ts['sort'] === 'asc') ? 'desc' : 'asc'); $cell_attributes['class'][] = 'active'; $tablesort_indicator = array( '#theme' => 'tablesort_indicator', @@ -100,12 +100,12 @@ function tablesort_get_order($headers) { $order = \Drupal::request()->query->get('order', ''); foreach ($headers as $header) { if (is_array($header)) { - if (isset($header['data']) && $order == $header['data']) { + if (isset($header['data']) && $order === $header['data']) { $default = $header; break; } - if (empty($default) && isset($header['sort']) && ($header['sort'] == 'asc' || $header['sort'] == 'desc')) { + if (empty($default) && isset($header['sort']) && ($header['sort'] === 'asc' || $header['sort'] === 'desc')) { $default = $header; } } @@ -134,7 +134,7 @@ function tablesort_get_order($headers) { function tablesort_get_sort($headers) { $query = \Drupal::request()->query; if ($query->has('sort')) { - return (strtolower($query->get('sort')) == 'desc') ? 'desc' : 'asc'; + return (strtolower($query->get('sort')) === 'desc') ? 'desc' : 'asc'; } // The user has not specified a sort. Use the default for the currently sorted // header if specified; otherwise use "asc". @@ -142,7 +142,7 @@ function tablesort_get_sort($headers) { // Find out which header is currently being sorted. $ts = tablesort_get_order($headers); foreach ($headers as $header) { - if (is_array($header) && isset($header['data']) && $header['data'] == $ts['name'] && isset($header['sort'])) { + if (is_array($header) && isset($header['data']) && $header['data'] === $ts['name'] && isset($header['sort'])) { return $header['sort']; } } diff --git a/core/includes/theme.inc b/core/includes/theme.inc index b349918..c17b6d5 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -388,7 +388,7 @@ function _theme($hook, $variables = array()) { // The theme engine may use a different extension and a different renderer. $theme_engine = $active_theme->getEngine(); if (isset($theme_engine)) { - if ($info['type'] != 'module') { + if ($info['type'] !== 'module') { if (function_exists($theme_engine . '_render_template')) { $render_function = $theme_engine . '_render_template'; } @@ -740,22 +740,22 @@ function theme_get_setting($setting_name, $theme = NULL) { */ function theme_settings_convert_to_config(array $theme_settings, Config $config) { foreach ($theme_settings as $key => $value) { - if ($key == 'default_logo') { + if ($key === 'default_logo') { $config->set('logo.use_default', $value); } - else if ($key == 'logo_path') { + else if ($key === 'logo_path') { $config->set('logo.path', $value); } - else if ($key == 'default_favicon') { + else if ($key === 'default_favicon') { $config->set('favicon.use_default', $value); } - else if ($key == 'favicon_path') { + else if ($key === 'favicon_path') { $config->set('favicon.path', $value); } - else if ($key == 'favicon_mimetype') { + else if ($key === 'favicon_mimetype') { $config->set('favicon.mimetype', $value); } - else if (substr($key, 0, 7) == 'toggle_') { + else if (substr($key, 0, 7) === 'toggle_') { $config->set('features.' . drupal_substr($key, 7), $value); } else if (!in_array($key, array('theme', 'logo_upload'))) { @@ -1391,7 +1391,7 @@ function template_preprocess_table(&$variables) { } } // Add active class if needed for sortable tables. - if (isset($variables['header'][$col_key]['data']) && $variables['header'][$col_key]['data'] == $ts['name'] && !empty($variables['header'][$col_key]['field'])) { + if (isset($variables['header'][$col_key]['data']) && $variables['header'][$col_key]['data'] === $ts['name'] && !empty($variables['header'][$col_key]['field'])) { $cell_attributes['class'][] = 'active'; } // Copy RESPONSIVE_PRIORITY_LOW/RESPONSIVE_PRIORITY_MEDIUM @@ -1420,7 +1420,7 @@ function template_preprocess_table(&$variables) { */ function template_preprocess_tablesort_indicator(&$variables) { // Provide the image attributes for an ascending or descending image. - if ($variables['style'] == 'asc') { + if ($variables['style'] === 'asc') { $variables['arrow_asc'] = file_create_url('core/misc/arrow-asc.png'); } else { @@ -1579,11 +1579,11 @@ function template_preprocess_task_list(&$variables) { $items = $variables['items']; $active = $variables['active']; - $done = isset($items[$active]) || $active == NULL; + $done = isset($items[$active]) || $active === NULL; foreach ($items as $k => $item) { $variables['tasks'][$k]['item'] = $item; $variables['tasks'][$k]['attributes'] = new Attribute(); - if ($active == $k) { + if ($active === $k) { $variables['tasks'][$k]['attributes']->addClass('active'); $variables['tasks'][$k]['status'] = t('active'); $done = FALSE; @@ -1712,7 +1712,7 @@ function template_preprocess_html(&$variables) { // Populate the body classes. if ($suggestions = theme_get_suggestions($path_args, 'page', '-')) { foreach ($suggestions as $suggestion) { - if ($suggestion != 'page-front') { + if ($suggestion !== 'page-front') { // Add current suggestion to page classes to make it possible to theme // the page depending on the current page type (e.g. node, admin, user, // etc.) as well as more specific data like node-12 or node-edit. @@ -1757,14 +1757,14 @@ function template_preprocess_html(&$variables) { $html_heads = drupal_get_html_head(FALSE); uasort($html_heads, 'Drupal\Component\Utility\SortArray::sortByWeightElement'); foreach ($html_heads as $name => $tag) { - if ($tag['#tag'] == 'link') { + if ($tag['#tag'] === 'link') { $link = new LinkElement($name, isset($tag['#attributes']['content']) ? $tag['#attributes']['content'] : NULL, $tag['#attributes']); if (!empty($tag['#noscript'])) { $link->setNoScript(); } $page->addLinkElement($link); } - elseif ($tag['#tag'] == 'meta') { + elseif ($tag['#tag'] === 'meta') { $metatag = new MetaElement(NULL, $tag['#attributes']); if (!empty($tag['#noscript'])) { $metatag->setNoScript(); @@ -1815,7 +1815,7 @@ function template_preprocess_page(&$variables) { $variables['layout'] = 'first'; } if (!empty($variables['page']['sidebar_second'])) { - $variables['layout'] = ($variables['layout'] == 'first') ? 'both' : 'second'; + $variables['layout'] = ($variables['layout'] === 'first') ? 'both' : 'second'; } $variables['base_path'] = base_path(); @@ -2067,7 +2067,7 @@ function template_preprocess_region(&$variables) { function template_preprocess_field(&$variables, $hook) { $element = $variables['element']; - $variables['label_hidden'] = ($element['#label_display'] == 'hidden'); + $variables['label_hidden'] = ($element['#label_display'] === 'hidden'); // Always set the field label - allow themes to decide whether to display it. // In addition the label should be rendered but hidden to support screen // readers. @@ -2101,12 +2101,12 @@ function template_preprocess_field(&$variables, $hook) { ); // Add a "clearfix" class to the wrapper since we float the label and the // field items in field.module.css if the label is inline. - if ($element['#label_display'] == 'inline') { + if ($element['#label_display'] === 'inline') { $variables['attributes']['class'][] = 'clearfix'; } // Hide labels visually, but display them to screenreaders if applicable. - if ($element['#label_display'] == 'visually_hidden') { + if ($element['#label_display'] === 'visually_hidden') { $variables['title_attributes']['class'][] = 'visually-hidden'; } diff --git a/core/includes/theme.maintenance.inc b/core/includes/theme.maintenance.inc index 8d4c10d..b1465f7 100644 --- a/core/includes/theme.maintenance.inc +++ b/core/includes/theme.maintenance.inc @@ -33,7 +33,7 @@ function _drupal_maintenance_theme() { Unicode::check(); // Install and update pages are treated differently to prevent theming overrides. - if (defined('MAINTENANCE_MODE') && (MAINTENANCE_MODE == 'install' || MAINTENANCE_MODE == 'update')) { + if (defined('MAINTENANCE_MODE') && (MAINTENANCE_MODE === 'install' || MAINTENANCE_MODE === 'update')) { if (drupal_installation_attempted()) { $custom_theme = $GLOBALS['install_state']['theme']; } diff --git a/core/includes/update.inc b/core/includes/update.inc index 125907d..a50e648 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -51,15 +51,15 @@ function update_check_incompatibility($name, $type = 'module') { $modules = system_rebuild_module_data(); } - if ($type == 'module' && isset($modules[$name])) { + if ($type === 'module' && isset($modules[$name])) { $file = $modules[$name]; } - elseif ($type == 'theme' && isset($themes[$name])) { + elseif ($type === 'theme' && isset($themes[$name])) { $file = $themes[$name]; } if (!isset($file) || !isset($file->info['core']) - || $file->info['core'] != \Drupal::CORE_COMPATIBILITY + || $file->info['core'] !== \Drupal::CORE_COMPATIBILITY || version_compare(phpversion(), $file->info['php']) < 0) { return TRUE; } @@ -244,7 +244,7 @@ function update_do_one($module, $number, $dependency_map, &$context) { } // Record the schema update if it was completed successfully. - if ($context['finished'] == 1 && empty($ret['#abort'])) { + if ($context['finished'] === 1 && empty($ret['#abort'])) { drupal_set_installed_schema_version($module, $number); } @@ -303,7 +303,7 @@ function update_get_update_list() { $modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE); foreach ($modules as $module => $schema_version) { // Skip uninstalled and incompatible modules. - if ($schema_version == SCHEMA_UNINSTALLED || update_check_incompatibility($module)) { + if ($schema_version === SCHEMA_UNINSTALLED || update_check_incompatibility($module)) { continue; } // Display a requirements error if the user somehow has a schema version @@ -316,7 +316,7 @@ function update_get_update_list() { $updates = drupal_get_schema_versions($module); if ($updates !== FALSE) { // \Drupal::moduleHandler()->invoke() returns NULL for nonexisting hooks, - // so if no updates are removed, it will == 0. + // so if no updates are removed, it will === 0. $last_removed = \Drupal::moduleHandler()->invoke($module, 'update_last_removed'); if ($schema_version < $last_removed) { $ret[$module]['warning'] = '' . $module . ' module cannot be updated. Its schema version is ' . $schema_version . '. Updates up to and including ' . $last_removed . ' have been removed in this release. In order to update ' . $module . ' module, you will first need to upgrade to the last version in which these updates were available.'; @@ -325,7 +325,7 @@ function update_get_update_list() { $updates = array_combine($updates, $updates); foreach (array_keys($updates) as $update) { - if ($update == \Drupal::CORE_MINIMUM_SCHEMA_VERSION) { + if ($update === \Drupal::CORE_MINIMUM_SCHEMA_VERSION) { $ret[$module]['warning'] = '' . $module . ' module cannot be updated. It contains an update numbered as ' . \Drupal::CORE_MINIMUM_SCHEMA_VERSION . ' which is reserved for the earliest installation of a module in Drupal ' . \Drupal::CORE_COMPATIBILITY . ', before any updates. In order to update ' . $module . ' module, you will need to install a version of the module with valid updates.'; continue 2; } @@ -604,7 +604,7 @@ function update_retrieve_dependencies() { // Get a list of installed modules, arranged so that we invoke their hooks in // the same order that \Drupal::moduleHandler()->invokeAll() does. foreach (\Drupal::keyValue('system.schema')->getAll() as $module => $schema) { - if ($schema == SCHEMA_UNINSTALLED) { + if ($schema === SCHEMA_UNINSTALLED) { // Nothing to upgrade. continue; } @@ -722,7 +722,7 @@ function update_language_list($flags = LanguageInterface::STATE_CONFIGURABLE) { $langcode = substr($langcode_config_name, strlen('language.entity.')); $info = \Drupal::config($langcode_config_name)->get(); $languages[$langcode] = new Language(array( - 'default' => ($info['id'] == $default->id), + 'default' => ($info['id'] === $default->id), 'name' => $info['label'], 'id' => $info['id'], 'direction' => $info['direction'], diff --git a/core/lib/Drupal/Component/Annotation/Plugin/Discovery/AnnotatedClassDiscovery.php b/core/lib/Drupal/Component/Annotation/Plugin/Discovery/AnnotatedClassDiscovery.php index 18d9ae8..f5b1706 100644 --- a/core/lib/Drupal/Component/Annotation/Plugin/Discovery/AnnotatedClassDiscovery.php +++ b/core/lib/Drupal/Component/Annotation/Plugin/Discovery/AnnotatedClassDiscovery.php @@ -99,7 +99,7 @@ public function getDefinitions() { new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS) ); foreach ($iterator as $fileinfo) { - if ($fileinfo->getExtension() == 'php') { + if ($fileinfo->getExtension() === 'php') { $sub_path = $iterator->getSubIterator()->getSubPath(); $sub_path = $sub_path ? str_replace(DIRECTORY_SEPARATOR, '\\', $sub_path) . '\\' : ''; $class = $namespace . '\\' . $sub_path . $fileinfo->getBasename('.php'); diff --git a/core/lib/Drupal/Component/Datetime/DateTimePlus.php b/core/lib/Drupal/Component/Datetime/DateTimePlus.php index fedab23..aa60f70 100644 --- a/core/lib/Drupal/Component/Datetime/DateTimePlus.php +++ b/core/lib/Drupal/Component/Datetime/DateTimePlus.php @@ -205,7 +205,7 @@ public static function createFromFormat($format, $time, $timezone = NULL, $setti $datetimeplus->setTimestamp($date->getTimestamp()); $datetimeplus->setTimezone($date->getTimezone()); - if ($settings['validate_format'] && $test_time != $time) { + if ($settings['validate_format'] && $test_time !== $time) { throw new \Exception('The created date does not match the input value.'); } } diff --git a/core/lib/Drupal/Component/Diff/Diff.php b/core/lib/Drupal/Component/Diff/Diff.php index 92affb0..5bdd297 100644 --- a/core/lib/Drupal/Component/Diff/Diff.php +++ b/core/lib/Drupal/Component/Diff/Diff.php @@ -63,7 +63,7 @@ public function reverse() { */ public function isEmpty() { foreach ($this->edits as $edit) { - if ($edit->type != 'copy') { + if ($edit->type !== 'copy') { return FALSE; } } @@ -80,7 +80,7 @@ public function isEmpty() { public function lcs() { $lcs = 0; foreach ($this->edits as $edit) { - if ($edit->type == 'copy') { + if ($edit->type === 'copy') { $lcs += sizeof($edit->orig); } } @@ -131,25 +131,25 @@ public function closing() { * This is here only for debugging purposes. */ public function check($from_lines, $to_lines) { - if (serialize($from_lines) != serialize($this->orig())) { + if (serialize($from_lines) !== serialize($this->orig())) { trigger_error("Reconstructed original doesn't match", E_USER_ERROR); } - if (serialize($to_lines) != serialize($this->closing())) { + if (serialize($to_lines) !== serialize($this->closing())) { trigger_error("Reconstructed closing doesn't match", E_USER_ERROR); } $rev = $this->reverse(); - if (serialize($to_lines) != serialize($rev->orig())) { + if (serialize($to_lines) !== serialize($rev->orig())) { trigger_error("Reversed original doesn't match", E_USER_ERROR); } - if (serialize($from_lines) != serialize($rev->closing())) { + if (serialize($from_lines) !== serialize($rev->closing())) { trigger_error("Reversed closing doesn't match", E_USER_ERROR); } $prevtype = 'none'; foreach ($this->edits as $edit) { - if ( $prevtype == $edit->type ) { + if ( $prevtype === $edit->type ) { trigger_error("Edit sequence is non-optimal", E_USER_ERROR); } $prevtype = $edit->type; diff --git a/core/lib/Drupal/Component/Diff/DiffFormatter.php b/core/lib/Drupal/Component/Diff/DiffFormatter.php index 5dc9e1b..69d20d4 100644 --- a/core/lib/Drupal/Component/Diff/DiffFormatter.php +++ b/core/lib/Drupal/Component/Diff/DiffFormatter.php @@ -56,7 +56,7 @@ public function format(Diff $diff) { $this->_start_diff(); foreach ($diff->getEdits() as $edit) { - if ($edit->type == 'copy') { + if ($edit->type === 'copy') { if (is_array($block)) { if (sizeof($edit->orig) <= $nlead + $ntrail) { $block[] = $edit; @@ -111,16 +111,16 @@ public function format(Diff $diff) { protected function _block($xbeg, $xlen, $ybeg, $ylen, &$edits) { $this->_start_block($this->_block_header($xbeg, $xlen, $ybeg, $ylen)); foreach ($edits as $edit) { - if ($edit->type == 'copy') { + if ($edit->type === 'copy') { $this->_context($edit->orig); } - elseif ($edit->type == 'add') { + elseif ($edit->type === 'add') { $this->_added($edit->closing); } - elseif ($edit->type == 'delete') { + elseif ($edit->type === 'delete') { $this->_deleted($edit->orig); } - elseif ($edit->type == 'change') { + elseif ($edit->type === 'change') { $this->_changed($edit->orig, $edit->closing); } else { diff --git a/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php b/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php index 9fe90ce..fee841a 100644 --- a/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php +++ b/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php @@ -152,8 +152,8 @@ protected function _line_hash($line) { * array of NCHUNKS+1 (X, Y) indexes giving the diving points between * sub sequences. The first sub-sequence is contained in [X0, X1), * [Y0, Y1), the second in [X1, X2), [Y1, Y2) and so on. Note - * that (X0, Y0) == (XOFF, YOFF) and - * (X[NCHUNKS], Y[NCHUNKS]) == (XLIM, YLIM). + * that (X0, Y0) === (XOFF, YOFF) and + * (X[NCHUNKS], Y[NCHUNKS]) === (XLIM, YLIM). * * This function assumes that the first lines of the specified portions * of the two files do not match, and likewise that the last lines do not @@ -243,7 +243,7 @@ protected function _diag($xoff, $xlim, $yoff, $ylim, $nchunks) { protected function _lcs_pos($ypos) { $end = $this->lcs; - if ($end == 0 || $ypos > $this->seq[$end]) { + if ($end === 0 || $ypos > $this->seq[$end]) { $this->seq[++$this->lcs] = $ypos; $this->in_seq[$ypos] = 1; return $this->lcs; @@ -260,7 +260,7 @@ protected function _lcs_pos($ypos) { } } - $this::USE_ASSERTS && assert($ypos != $this->seq[$end]); + $this::USE_ASSERTS && assert($ypos !== $this->seq[$end]); $this->in_seq[$this->seq[$end]] = FALSE; $this->seq[$end] = $ypos; @@ -283,18 +283,18 @@ protected function _lcs_pos($ypos) { protected function _compareseq($xoff, $xlim, $yoff, $ylim) { // Slide down the bottom initial diagonal. - while ($xoff < $xlim && $yoff < $ylim && $this->xv[$xoff] == $this->yv[$yoff]) { + while ($xoff < $xlim && $yoff < $ylim && $this->xv[$xoff] === $this->yv[$yoff]) { ++$xoff; ++$yoff; } // Slide up the top initial diagonal. - while ($xlim > $xoff && $ylim > $yoff && $this->xv[$xlim - 1] == $this->yv[$ylim - 1]) { + while ($xlim > $xoff && $ylim > $yoff && $this->xv[$xlim - 1] === $this->yv[$ylim - 1]) { --$xlim; --$ylim; } - if ($xoff == $xlim || $yoff == $ylim) { + if ($xoff === $xlim || $yoff === $ylim) { $lcs = 0; } else { @@ -306,7 +306,7 @@ protected function _compareseq($xoff, $xlim, $yoff, $ylim) { = $this->_diag($xoff, $xlim, $yoff, $ylim, $nchunks); } - if ($lcs == 0) { + if ($lcs === 0) { // X and Y sequences have no common subsequence: // mark all changed. while ($yoff < $ylim) { @@ -344,7 +344,7 @@ protected function _shift_boundaries($lines, &$changed, $other_changed) { $i = 0; $j = 0; - $this::USE_ASSERTS && assert('sizeof($lines) == sizeof($changed)'); + $this::USE_ASSERTS && assert('sizeof($lines) === sizeof($changed)'); $len = sizeof($lines); $other_len = sizeof($other_changed); @@ -357,8 +357,8 @@ protected function _shift_boundaries($lines, &$changed, $other_changed) { * the first $i elements of $changed and the first $j elements * of $other_changed both contain the same number of zeros * (unchanged lines). - * Furthermore, $j is always kept so that $j == $other_len or - * $other_changed[$j] == FALSE. + * Furthermore, $j is always kept so that $j === $other_len or + * $other_changed[$j] === FALSE. */ while ($j < $other_len && $other_changed[$j]) { $j++; @@ -372,7 +372,7 @@ protected function _shift_boundaries($lines, &$changed, $other_changed) { } } - if ($i == $len) { + if ($i === $len) { break; } $start = $i; @@ -394,7 +394,7 @@ protected function _shift_boundaries($lines, &$changed, $other_changed) { * previous unchanged line matches the last changed one. * This merges with previous changed regions. */ - while ($start > 0 && $lines[$start - 1] == $lines[$i - 1]) { + while ($start > 0 && $lines[$start - 1] === $lines[$i - 1]) { $changed[--$start] = 1; $changed[--$i] = FALSE; while ($start > 0 && $changed[$start - 1]) { @@ -410,7 +410,7 @@ protected function _shift_boundaries($lines, &$changed, $other_changed) { /* * Set CORRESPONDING to the end of the changed run, at the last * point where it corresponds to a changed run in the other file. - * CORRESPONDING == LEN means no such point has been found. + * CORRESPONDING === LEN means no such point has been found. */ $corresponding = $j < $other_len ? $i : $len; @@ -421,7 +421,7 @@ protected function _shift_boundaries($lines, &$changed, $other_changed) { * Do this second, so that if there are no merges, * the changed region is moved forward as far as possible. */ - while ($i < $len && $lines[$start] == $lines[$i]) { + while ($i < $len && $lines[$start] === $lines[$i]) { $changed[$start++] = FALSE; $changed[$i++] = 1; while ($i < $len && $changed[$i]) { @@ -436,7 +436,7 @@ protected function _shift_boundaries($lines, &$changed, $other_changed) { } } } - } while ($runlength != $i - $start); + } while ($runlength !== $i - $start); /* * If possible, move the fully-merged run of changes diff --git a/core/lib/Drupal/Component/Diff/Engine/HWLDFWordAccumulator.php b/core/lib/Drupal/Component/Diff/Engine/HWLDFWordAccumulator.php index 8c4ebea..5d68aec 100644 --- a/core/lib/Drupal/Component/Diff/Engine/HWLDFWordAccumulator.php +++ b/core/lib/Drupal/Component/Diff/Engine/HWLDFWordAccumulator.php @@ -33,7 +33,7 @@ class HWLDFWordAccumulator { protected function _flushGroup($new_tag) { if ($this->group !== '') { - if ($this->tag == 'mark') { + if ($this->tag === 'mark') { $this->line .= '' . String::checkPlain($this->group) . ''; } else { @@ -46,7 +46,7 @@ protected function _flushGroup($new_tag) { protected function _flushLine($new_tag) { $this->_flushGroup($new_tag); - if ($this->line != '') { + if ($this->line !== '') { // @todo This is probably not the right place to do this. To be // addressed in https://drupal.org/node/2280963 array_push($this->lines, SafeMarkup::set($this->line)); @@ -59,15 +59,15 @@ protected function _flushLine($new_tag) { } public function addWords($words, $tag = '') { - if ($tag != $this->tag) { + if ($tag !== $this->tag) { $this->_flushGroup($tag); } foreach ($words as $word) { // new-line should only come as first char of word. - if ($word == '') { + if ($word === '') { continue; } - if ($word[0] == "\n") { + if ($word[0] === "\n") { $this->_flushLine($tag); $word = Unicode::substr($word, 1); } diff --git a/core/lib/Drupal/Component/Diff/MappedDiff.php b/core/lib/Drupal/Component/Diff/MappedDiff.php index 5350a69..307f5c6 100644 --- a/core/lib/Drupal/Component/Diff/MappedDiff.php +++ b/core/lib/Drupal/Component/Diff/MappedDiff.php @@ -35,8 +35,8 @@ class MappedDiff extends Diff { */ public function __construct($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines) { - assert(sizeof($from_lines) == sizeof($mapped_from_lines)); - assert(sizeof($to_lines) == sizeof($mapped_to_lines)); + assert(sizeof($from_lines) === sizeof($mapped_from_lines)); + assert(sizeof($to_lines) === sizeof($mapped_to_lines)); parent::__construct($mapped_from_lines, $mapped_to_lines); diff --git a/core/lib/Drupal/Component/Diff/WordLevelDiff.php b/core/lib/Drupal/Component/Diff/WordLevelDiff.php index c9114bc..5372b4c 100644 --- a/core/lib/Drupal/Component/Diff/WordLevelDiff.php +++ b/core/lib/Drupal/Component/Diff/WordLevelDiff.php @@ -53,7 +53,7 @@ public function orig() { $orig = new HWLDFWordAccumulator(); foreach ($this->edits as $edit) { - if ($edit->type == 'copy') { + if ($edit->type === 'copy') { $orig->addWords($edit->orig); } elseif ($edit->orig) { @@ -68,7 +68,7 @@ public function closing() { $closing = new HWLDFWordAccumulator(); foreach ($this->edits as $edit) { - if ($edit->type == 'copy') { + if ($edit->type === 'copy') { $closing->addWords($edit->closing); } elseif ($edit->closing) { diff --git a/core/lib/Drupal/Component/Gettext/PoHeader.php b/core/lib/Drupal/Component/Gettext/PoHeader.php index 3136f2e..121fbaf 100644 --- a/core/lib/Drupal/Component/Gettext/PoHeader.php +++ b/core/lib/Drupal/Component/Gettext/PoHeader.php @@ -219,7 +219,7 @@ function parsePluralForms($pluralforms) { } // If the number of plurals is zero, we return a default result. - if ($nplurals == 0) { + if ($nplurals === 0) { return array($nplurals, array('default' => 0)); } @@ -234,7 +234,7 @@ function parsePluralForms($pluralforms) { } $default = $plurals[$i - 1]; $plurals = array_filter($plurals, function ($value) use ($default) { - return ($value != $default); + return ($value !== $default); }); $plurals['default'] = $default; @@ -299,15 +299,15 @@ private function parseArithmetic($string) { if (is_numeric($token)) { $element_stack[] = $current_token; } - elseif ($current_token == "n") { + elseif ($current_token === "n") { $element_stack[] = '$n'; } - elseif ($current_token == "(") { + elseif ($current_token === "(") { $operator_stack[] = $current_token; } - elseif ($current_token == ")") { + elseif ($current_token === ")") { $topop = array_pop($operator_stack); - while (isset($topop) && ($topop != "(")) { + while (isset($topop) && ($topop !== "(")) { $element_stack[] = $topop; $topop = array_pop($operator_stack); } @@ -317,7 +317,7 @@ private function parseArithmetic($string) { // $element_stack until the precedence in $operator_stack is less // than current, then push into $operator_stack. $topop = array_pop($operator_stack); - while (isset($topop) && ($precedence[$topop] >= $precedence[$current_token]) && !(($precedence[$topop] == $precedence[$current_token]) && !empty($right_associativity[$topop]) && !empty($right_associativity[$current_token]))) { + while (isset($topop) && ($precedence[$topop] >= $precedence[$current_token]) && !(($precedence[$topop] === $precedence[$current_token]) && !empty($right_associativity[$topop]) && !empty($right_associativity[$current_token]))) { $element_stack[] = $topop; $topop = array_pop($operator_stack); } @@ -335,7 +335,7 @@ private function parseArithmetic($string) { // Flush operator stack. $topop = array_pop($operator_stack); - while ($topop != NULL) { + while ($topop !== NULL) { $element_stack[] = $topop; $topop = array_pop($operator_stack); } @@ -348,10 +348,10 @@ private function parseArithmetic($string) { for ($i = 2; $i < count($element_stack); $i++) { $op = $element_stack[$i]; if (!empty($precedence[$op])) { - if ($op == ":") { + if ($op === ":") { $f = $element_stack[$i - 2] . "):" . $element_stack[$i - 1] . ")"; } - elseif ($op == "?") { + elseif ($op === "?") { $f = "(" . $element_stack[$i - 2] . "?(" . $element_stack[$i - 1]; } else { @@ -364,7 +364,7 @@ private function parseArithmetic($string) { } // If only one element is left, the number of operators is appropriate. - return count($element_stack) == 1 ? $return : FALSE; + return count($element_stack) === 1 ? $return : FALSE; } /** @@ -397,7 +397,7 @@ private function tokenizeFormula($formula) { case 2: case 3: case 4: - if ($next == '=') { + if ($next === '=') { $tokens[] = $formula[$i] . '='; $i++; } @@ -406,7 +406,7 @@ private function tokenizeFormula($formula) { } break; case 5: - if ($next == '&') { + if ($next === '&') { $tokens[] = '&&'; $i++; } @@ -415,7 +415,7 @@ private function tokenizeFormula($formula) { } break; case 6: - if ($next == '|') { + if ($next === '|') { $tokens[] = '||'; $i++; } @@ -461,7 +461,7 @@ private function tokenizeFormula($formula) { * removed and replaced by the evaluation result. This is typically 2 * arguments and 1 element for the operator. * Because the operator is '!=' the example stack is evaluated as: - * $f = (int) 2 != 1; + * $f = (int) 2 !== 1; * The resulting stack is: * array( * 0 => 1, @@ -505,10 +505,10 @@ protected function evaluatePlural($element_stack, $n) { $delta = 2; switch ($element_stack[$i]) { case '==': - $f = $element_stack[$i - 2] == $element_stack[$i - 1]; + $f = $element_stack[$i - 2] === $element_stack[$i - 1]; break; case '!=': - $f = $element_stack[$i - 2] != $element_stack[$i - 1]; + $f = $element_stack[$i - 2] !== $element_stack[$i - 1]; break; case '<=': $f = $element_stack[$i - 2] <= $element_stack[$i - 1]; diff --git a/core/lib/Drupal/Component/Gettext/PoMemoryWriter.php b/core/lib/Drupal/Component/Gettext/PoMemoryWriter.php index 11c5361..96077b4 100644 --- a/core/lib/Drupal/Component/Gettext/PoMemoryWriter.php +++ b/core/lib/Drupal/Component/Gettext/PoMemoryWriter.php @@ -39,14 +39,14 @@ public function writeItem(PoItem $item) { $item->setTranslation(implode(LOCALE_PLURAL_DELIMITER, $item->getTranslation())); } $context = $item->getContext(); - $this->_items[$context != NULL ? $context : ''][$item->getSource()] = $item->getTranslation(); + $this->_items[$context !== NULL ? $context : ''][$item->getSource()] = $item->getTranslation(); } /** * Implements Drupal\Component\Gettext\PoWriterInterface::writeItems(). */ public function writeItems(PoReaderInterface $reader, $count = -1) { - $forever = $count == -1; + $forever = $count === -1; while (($count-- > 0 || $forever) && ($item = $reader->readItem())) { $this->writeItem($item); } diff --git a/core/lib/Drupal/Component/Gettext/PoStreamReader.php b/core/lib/Drupal/Component/Gettext/PoStreamReader.php index f0f4ea5..25365aa 100644 --- a/core/lib/Drupal/Component/Gettext/PoStreamReader.php +++ b/core/lib/Drupal/Component/Gettext/PoStreamReader.php @@ -258,7 +258,7 @@ private function readLine() { if (!$this->_finished) { - if ($this->_line_number == 0) { + if ($this->_line_number === 0) { // The first line might come with a UTF-8 BOM, which should be removed. $line = str_replace("\xEF\xBB\xBF", '', $line); // Current plurality for 'msgstr[]'. @@ -281,11 +281,11 @@ private function readLine() { if (!strncmp('#', $line, 1)) { // Lines starting with '#' are comments. - if ($this->_context == 'COMMENT') { + if ($this->_context === 'COMMENT') { // Already in comment context, add to current comment. $this->_current_item['#'][] = substr($line, 1); } - elseif (($this->_context == 'MSGSTR') || ($this->_context == 'MSGSTR_ARR')) { + elseif (($this->_context === 'MSGSTR') || ($this->_context === 'MSGSTR_ARR')) { // We are currently in string context, save current item. $this->setItemFromArray($this->_current_item); @@ -306,7 +306,7 @@ private function readLine() { elseif (!strncmp('msgid_plural', $line, 12)) { // A plural form for the current source string. - if ($this->_context != 'MSGID') { + if ($this->_context !== 'MSGID') { // A plural form can only be added to an msgid directly. $this->_errors[] = String::format('The translation stream %uri contains an error: "msgid_plural" was expected but not found on line %line.', $log_vars); return FALSE; @@ -337,14 +337,14 @@ private function readLine() { elseif (!strncmp('msgid', $line, 5)) { // Starting a new message. - if (($this->_context == 'MSGSTR') || ($this->_context == 'MSGSTR_ARR')) { + if (($this->_context === 'MSGSTR') || ($this->_context === 'MSGSTR_ARR')) { // We are currently in string context, save current item. $this->setItemFromArray($this->_current_item); // Start a new context for the msgid. $this->_current_item = array(); } - elseif ($this->_context == 'MSGID') { + elseif ($this->_context === 'MSGID') { // We are currently already in the context, meaning we passed an id with no data. $this->_errors[] = String::format('The translation stream %uri contains an error: "msgid" is unexpected on line %line.', $log_vars); return FALSE; @@ -368,7 +368,7 @@ private function readLine() { elseif (!strncmp('msgctxt', $line, 7)) { // Starting a new context. - if (($this->_context == 'MSGSTR') || ($this->_context == 'MSGSTR_ARR')) { + if (($this->_context === 'MSGSTR') || ($this->_context === 'MSGSTR_ARR')) { // We are currently in string context, save current item. $this->setItemFromArray($this->_current_item); $this->_current_item = array(); @@ -398,10 +398,10 @@ private function readLine() { elseif (!strncmp('msgstr[', $line, 7)) { // A message string for a specific plurality. - if (($this->_context != 'MSGID') && - ($this->_context != 'MSGCTXT') && - ($this->_context != 'MSGID_PLURAL') && - ($this->_context != 'MSGSTR_ARR')) { + if (($this->_context !== 'MSGID') && + ($this->_context !== 'MSGCTXT') && + ($this->_context !== 'MSGID_PLURAL') && + ($this->_context !== 'MSGSTR_ARR')) { // Plural message strings must come after msgid, msgxtxt, // msgid_plural, or other msgstr[] entries. $this->_errors[] = String::format('The translation stream %uri contains an error: "msgstr[]" is unexpected on line %line.', $log_vars); @@ -440,7 +440,7 @@ private function readLine() { elseif (!strncmp("msgstr", $line, 6)) { // A string pair for an msgidid (with optional context). - if (($this->_context != 'MSGID') && ($this->_context != 'MSGCTXT')) { + if (($this->_context !== 'MSGID') && ($this->_context !== 'MSGCTXT')) { // Strings are only valid within an id or context scope. $this->_errors[] = String::format('The translation stream %uri contains an error: "msgstr" is unexpected on line %line.', $log_vars); return FALSE; @@ -462,7 +462,7 @@ private function readLine() { $this->_context = 'MSGSTR'; return; } - elseif ($line != '') { + elseif ($line !== '') { // Anything that is not a token may be a continuation of a previous token. $quoted = $this->parseQuoted($line); @@ -473,7 +473,7 @@ private function readLine() { } // Append the string to the current item. - if (($this->_context == 'MSGID') || ($this->_context == 'MSGID_PLURAL')) { + if (($this->_context === 'MSGID') || ($this->_context === 'MSGID_PLURAL')) { if (is_array($this->_current_item['msgid'])) { // Add string to last array element for plural sources. $last_index = count($this->_current_item['msgid']) - 1; @@ -484,15 +484,15 @@ private function readLine() { $this->_current_item['msgid'] .= $quoted; } } - elseif ($this->_context == 'MSGCTXT') { + elseif ($this->_context === 'MSGCTXT') { // Multiline context name. $this->_current_item['msgctxt'] .= $quoted; } - elseif ($this->_context == 'MSGSTR') { + elseif ($this->_context === 'MSGSTR') { // Multiline translation string. $this->_current_item['msgstr'] .= $quoted; } - elseif ($this->_context == 'MSGSTR_ARR') { + elseif ($this->_context === 'MSGSTR_ARR') { // Multiline plural translation string. $this->_current_item['msgstr'][$this->_current_plural_index] .= $quoted; } @@ -506,11 +506,11 @@ private function readLine() { } // Empty line read or EOF of PO stream, close out the last entry. - if (($this->_context == 'MSGSTR') || ($this->_context == 'MSGSTR_ARR')) { + if (($this->_context === 'MSGSTR') || ($this->_context === 'MSGSTR_ARR')) { $this->setItemFromArray($this->_current_item); $this->_current_item = array(); } - elseif ($this->_context != 'COMMENT') { + elseif ($this->_context !== 'COMMENT') { $this->_errors[] = String::format('The translation stream %uri ended unexpectedly at line %line.', $log_vars); return FALSE; } @@ -556,17 +556,17 @@ public function setItemFromArray($value) { * The string parsed from inside the quotes. */ function parseQuoted($string) { - if (substr($string, 0, 1) != substr($string, -1, 1)) { + if (substr($string, 0, 1) !== substr($string, -1, 1)) { // Start and end quotes must be the same. return FALSE; } $quote = substr($string, 0, 1); $string = substr($string, 1, -1); - if ($quote == '"') { + if ($quote === '"') { // Double quotes: strip slashes. return stripcslashes($string); } - elseif ($quote == "'") { + elseif ($quote === "'") { // Simple quote: return as-is. return $string; } diff --git a/core/lib/Drupal/Component/Gettext/PoStreamWriter.php b/core/lib/Drupal/Component/Gettext/PoStreamWriter.php index 84076ff..fc4c03f 100644 --- a/core/lib/Drupal/Component/Gettext/PoStreamWriter.php +++ b/core/lib/Drupal/Component/Gettext/PoStreamWriter.php @@ -139,7 +139,7 @@ public function writeItem(PoItem $item) { * Implements Drupal\Component\Gettext\PoWriterInterface::writeItems(). */ public function writeItems(PoReaderInterface $reader, $count = -1) { - $forever = $count == -1; + $forever = $count === -1; while (($count-- > 0 || $forever) && ($item = $reader->readItem())) { $this->writeItem($item); } diff --git a/core/lib/Drupal/Component/Graph/Graph.php b/core/lib/Drupal/Component/Graph/Graph.php index 726c723..ae3df99 100644 --- a/core/lib/Drupal/Component/Graph/Graph.php +++ b/core/lib/Drupal/Component/Graph/Graph.php @@ -125,7 +125,7 @@ protected function depthFirstSearch(&$state, $start, &$component = NULL) { // Mark that $start can reach $end. $this->graph[$start]['paths'][$end] = $v; - if (isset($this->graph[$end]['component']) && $component != $this->graph[$end]['component']) { + if (isset($this->graph[$end]['component']) && $component !== $this->graph[$end]['component']) { // This vertex already has a component, use that from now on and // reassign all the previously explored vertices. $new_component = $this->graph[$end]['component']; diff --git a/core/lib/Drupal/Component/PhpStorage/FileReadOnlyStorage.php b/core/lib/Drupal/Component/PhpStorage/FileReadOnlyStorage.php index 1a460ad..a1deb33 100644 --- a/core/lib/Drupal/Component/PhpStorage/FileReadOnlyStorage.php +++ b/core/lib/Drupal/Component/PhpStorage/FileReadOnlyStorage.php @@ -93,7 +93,7 @@ public function listAll() { foreach (new \DirectoryIterator($this->directory) as $fileinfo) { if (!$fileinfo->isDot()) { $name = $fileinfo->getFilename(); - if ($name != '.htaccess') { + if ($name !== '.htaccess') { $names[] = $name; } } diff --git a/core/lib/Drupal/Component/PhpStorage/FileStorage.php b/core/lib/Drupal/Component/PhpStorage/FileStorage.php index 78f1222..cdb959a 100644 --- a/core/lib/Drupal/Component/PhpStorage/FileStorage.php +++ b/core/lib/Drupal/Component/PhpStorage/FileStorage.php @@ -258,7 +258,7 @@ public function listAll() { foreach (new \DirectoryIterator($this->directory) as $fileinfo) { if (!$fileinfo->isDot()) { $name = $fileinfo->getFilename(); - if ($name != '.htaccess') { + if ($name !== '.htaccess') { $names[] = $name; } } diff --git a/core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php b/core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php index 73486a8..60a5c29 100644 --- a/core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php +++ b/core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php @@ -97,7 +97,7 @@ public function save($name, $data) { // on and the updated mtime match. $previous_mtime = 0; $i = 0; - while (($mtime = $this->getUncachedMTime($directory)) && ($mtime != $previous_mtime)) { + while (($mtime = $this->getUncachedMTime($directory)) && ($mtime !== $previous_mtime)) { $previous_mtime = $mtime; // Reset the file back in the temporary location if this is not the first // iteration. diff --git a/core/lib/Drupal/Component/Plugin/Factory/ReflectionFactory.php b/core/lib/Drupal/Component/Plugin/Factory/ReflectionFactory.php index ae9dfe1..c78ff78 100644 --- a/core/lib/Drupal/Component/Plugin/Factory/ReflectionFactory.php +++ b/core/lib/Drupal/Component/Plugin/Factory/ReflectionFactory.php @@ -59,13 +59,13 @@ protected function getInstanceArguments(\ReflectionClass $reflector, $plugin_id, foreach ($reflector->getMethod('__construct')->getParameters() as $param) { $param_name = $param->getName(); - if ($param_name == 'plugin_id') { + if ($param_name === 'plugin_id') { $arguments[] = $plugin_id; } - elseif ($param_name == 'plugin_definition') { + elseif ($param_name === 'plugin_definition') { $arguments[] = $plugin_definition; } - elseif ($param_name == 'configuration') { + elseif ($param_name === 'configuration') { $arguments[] = $configuration; } elseif (isset($configuration[$param_name]) || array_key_exists($param_name, $configuration)) { diff --git a/core/lib/Drupal/Component/Transliteration/PHPTransliteration.php b/core/lib/Drupal/Component/Transliteration/PHPTransliteration.php index 0db05389..e918655 100644 --- a/core/lib/Drupal/Component/Transliteration/PHPTransliteration.php +++ b/core/lib/Drupal/Component/Transliteration/PHPTransliteration.php @@ -84,7 +84,7 @@ public function transliterate($string, $langcode = 'en', $unknown_character = '? // Split into Unicode characters and transliterate each one. foreach (preg_split('//u', $string, 0, PREG_SPLIT_NO_EMPTY) as $character) { $code = self::ordUTF8($character); - if ($code == -1) { + if ($code === -1) { $to_add = $unknown_character; } else { @@ -118,19 +118,19 @@ public function transliterate($string, $langcode = 'en', $unknown_character = '? protected static function ordUTF8($character) { $first_byte = ord($character[0]); - if (($first_byte & 0x80) == 0) { + if (($first_byte & 0x80) === 0) { // Single-byte form: 0xxxxxxxx. return $first_byte; } - if (($first_byte & 0xe0) == 0xc0) { + if (($first_byte & 0xe0) === 0xc0) { // Two-byte form: 110xxxxx 10xxxxxx. return (($first_byte & 0x1f) << 6) + (ord($character[1]) & 0x3f); } - if (($first_byte & 0xf0) == 0xe0) { + if (($first_byte & 0xf0) === 0xe0) { // Three-byte form: 1110xxxx 10xxxxxx 10xxxxxx. return (($first_byte & 0x0f) << 12) + ((ord($character[1]) & 0x3f) << 6) + (ord($character[2]) & 0x3f); } - if (($first_byte & 0xf8) == 0xf0) { + if (($first_byte & 0xf8) === 0xf0) { // Four-byte form: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx. return (($first_byte & 0x07) << 18) + ((ord($character[1]) & 0x3f) << 12) + ((ord($character[2]) & 0x3f) << 6) + (ord($character[3]) & 0x3f); } diff --git a/core/lib/Drupal/Component/Utility/Color.php b/core/lib/Drupal/Component/Utility/Color.php index 4b09a28..3ffa019 100644 --- a/core/lib/Drupal/Component/Utility/Color.php +++ b/core/lib/Drupal/Component/Utility/Color.php @@ -55,7 +55,7 @@ public static function hexToRgb($hex) { $hex = ltrim($hex, '#'); // Convert shorthands like '#abc' to '#aabbcc'. - if (strlen($hex) == 3) { + if (strlen($hex) === 3) { $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; } diff --git a/core/lib/Drupal/Component/Utility/Environment.php b/core/lib/Drupal/Component/Utility/Environment.php index 087bcad..583d938 100644 --- a/core/lib/Drupal/Component/Utility/Environment.php +++ b/core/lib/Drupal/Component/Utility/Environment.php @@ -39,7 +39,7 @@ public static function checkMemoryLimit($required, $memory_limit = NULL) { // - The memory limit is set to unlimited (-1). // - The memory limit is greater than or equal to the memory required for // the operation. - return ((!$memory_limit) || ($memory_limit == -1) || (Bytes::toInt($memory_limit) >= Bytes::toInt($required))); + return ((!$memory_limit) || ($memory_limit === -1) || (Bytes::toInt($memory_limit) >= Bytes::toInt($required))); } } diff --git a/core/lib/Drupal/Component/Utility/Random.php b/core/lib/Drupal/Component/Utility/Random.php index af9e22a..c344631 100644 --- a/core/lib/Drupal/Component/Utility/Random.php +++ b/core/lib/Drupal/Component/Utility/Random.php @@ -65,7 +65,7 @@ public function string($length = 8, $unique = FALSE, $validator = NULL) { // unique or if $validator is a callable that returns FALSE. To generate a // random string this loop must be carried out at least once. do { - if ($counter == static::MAXIMUM_TRIES) { + if ($counter === static::MAXIMUM_TRIES) { throw new \RuntimeException('Unable to generate a unique random name'); } $str = ''; @@ -118,7 +118,7 @@ public function name($length = 8, $unique = FALSE) { $counter = 0; do { - if ($counter == static::MAXIMUM_TRIES) { + if ($counter === static::MAXIMUM_TRIES) { throw new \RuntimeException('Unable to generate a unique random name'); } $str = chr(mt_rand(97, 122)); @@ -296,7 +296,7 @@ public function image($destination, $min_resolution, $max_resolution) { $smaller_dimension = ($smaller_dimension % 2) ? $smaller_dimension : $smaller_dimension; imageellipse($im, $width / 2, $height / 2, $smaller_dimension, $smaller_dimension, $color); - $save_function = 'image'. ($extension == 'jpg' ? 'jpeg' : $extension); + $save_function = 'image'. ($extension === 'jpg' ? 'jpeg' : $extension); $save_function($im, $destination); return $destination; } diff --git a/core/lib/Drupal/Component/Utility/SortArray.php b/core/lib/Drupal/Component/Utility/SortArray.php index 79688ec..54aad8d 100644 --- a/core/lib/Drupal/Component/Utility/SortArray.php +++ b/core/lib/Drupal/Component/Utility/SortArray.php @@ -129,7 +129,7 @@ public static function sortByKeyInt($a, $b, $key) { $a_weight = (is_array($a) && isset($a[$key])) ? $a[$key] : 0; $b_weight = (is_array($b) && isset($b[$key])) ? $b[$key] : 0; - if ($a_weight == $b_weight) { + if ($a_weight === $b_weight) { return 0; } diff --git a/core/lib/Drupal/Component/Utility/Tags.php b/core/lib/Drupal/Component/Utility/Tags.php index 628ce70..c6d7613 100644 --- a/core/lib/Drupal/Component/Utility/Tags.php +++ b/core/lib/Drupal/Component/Utility/Tags.php @@ -36,7 +36,7 @@ public static function explode($tags) { // or includes a comma or quote character), we remove the escape // formatting so to save the term into the database as the user intends. $tag = trim(str_replace('""', '"', preg_replace('/^"(.*)"$/', '\1', $tag))); - if ($tag != "") { + if ($tag !== "") { $tags[] = $tag; } } diff --git a/core/lib/Drupal/Component/Utility/Unicode.php b/core/lib/Drupal/Component/Utility/Unicode.php index c03e116..2484a23 100644 --- a/core/lib/Drupal/Component/Utility/Unicode.php +++ b/core/lib/Drupal/Component/Utility/Unicode.php @@ -155,22 +155,22 @@ public static function check() { } // Check mbstring configuration. - if (ini_get('mbstring.func_overload') != 0) { + if (ini_get('mbstring.func_overload') !== '0') { static::$status = static::STATUS_ERROR; return 'mbstring.func_overload'; } - if (ini_get('mbstring.encoding_translation') != 0) { + if (ini_get('mbstring.encoding_translation') !== '0') { static::$status = static::STATUS_ERROR; return 'mbstring.encoding_translation'; } // mbstring.http_input and mbstring.http_output are deprecated and empty by // default in PHP 5.6. - if (version_compare(PHP_VERSION, '5.6.0') == -1) { - if (ini_get('mbstring.http_input') != 'pass') { + if (version_compare(PHP_VERSION, '5.6.0') === -1) { + if (ini_get('mbstring.http_input') !== 'pass') { static::$status = static::STATUS_ERROR; return 'mbstring.http_input'; } - if (ini_get('mbstring.http_output') != 'pass') { + if (ini_get('mbstring.http_output') !== 'pass') { static::$status = static::STATUS_ERROR; return 'mbstring.http_output'; } @@ -254,7 +254,7 @@ public static function truncateBytes($string, $len) { * The length of the string. */ public static function strlen($text) { - if (static::getStatus() == static::STATUS_MULTIBYTE) { + if (static::getStatus() === static::STATUS_MULTIBYTE) { return mb_strlen($text); } else { @@ -273,7 +273,7 @@ public static function strlen($text) { * The string in uppercase. */ public static function strtoupper($text) { - if (static::getStatus() == static::STATUS_MULTIBYTE) { + if (static::getStatus() === static::STATUS_MULTIBYTE) { return mb_strtoupper($text); } else { @@ -295,7 +295,7 @@ public static function strtoupper($text) { * The string in lowercase. */ public static function strtolower($text) { - if (static::getStatus() == static::STATUS_MULTIBYTE) { + if (static::getStatus() === static::STATUS_MULTIBYTE) { return mb_strtolower($text); } else { @@ -372,7 +372,7 @@ public static function ucwords($text) { * The shortened string. */ public static function substr($text, $start, $length = NULL) { - if (static::getStatus() == static::STATUS_MULTIBYTE) { + if (static::getStatus() === static::STATUS_MULTIBYTE) { return $length === NULL ? mb_substr($text, $start) : mb_substr($text, $start, $length); } else { @@ -450,7 +450,7 @@ public static function substr($text, $start, $length = NULL) { } } else { - // $length == 0, return an empty string. + // $length === 0, return an empty string. return ''; } @@ -590,8 +590,8 @@ public static function mimeHeaderEncode($string) { */ public static function mimeHeaderDecode($header) { $callback = function ($matches) { - $data = ($matches[2] == 'B') ? base64_decode($matches[3]) : str_replace('_', ' ', quoted_printable_decode($matches[3])); - if (strtolower($matches[1]) != 'utf-8') { + $data = ($matches[2] === 'B') ? base64_decode($matches[3]) : str_replace('_', ' ', quoted_printable_decode($matches[3])); + if (strtolower($matches[1]) !== 'utf-8') { $data = static::convertToUtf8($data, $matches[1]); } return $data; @@ -640,13 +640,13 @@ public static function caseFlip($matches) { * TRUE if the text is valid UTF-8, FALSE if not. */ public static function validateUtf8($text) { - if (strlen($text) == 0) { + if (strlen($text) === 0) { return TRUE; } // With the PCRE_UTF8 modifier 'u', preg_match() fails silently on strings // containing invalid UTF-8 byte sequences. It does not reject character // codes above U+10FFFF (represented by 4 or more octets), though. - return (preg_match('/^./us', $text) == 1); + return (preg_match('/^./us', $text) === 1); } } diff --git a/core/lib/Drupal/Component/Utility/UrlHelper.php b/core/lib/Drupal/Component/Utility/UrlHelper.php index 0c0e07d..3aa45f9 100644 --- a/core/lib/Drupal/Component/Utility/UrlHelper.php +++ b/core/lib/Drupal/Component/Utility/UrlHelper.php @@ -154,7 +154,7 @@ public static function parse($url) { // Don't support URLs without a path, like 'http://'. list(, $path) = explode('://', $parts[0], 2); - if ($path != '') { + if ($path !== '') { $options['path'] = $parts[0]; } // If there is a query string, transform it into keyed query parameters. @@ -218,7 +218,7 @@ public static function isExternal($path) { // Avoid calling stripDangerousProtocols() if there is any // slash (/), hash (#) or question_mark (?) before the colon (:) // occurrence - if any - as this would clearly mean it is not a URL. - return $colonpos !== FALSE && !preg_match('![/?#]!', substr($path, 0, $colonpos)) && static::stripDangerousProtocols($path) == $path; + return $colonpos !== FALSE && !preg_match('![/?#]!', substr($path, 0, $colonpos)) && static::stripDangerousProtocols($path) === $path; } /** @@ -244,14 +244,14 @@ public static function externalIsLocal($url, $base_url) { } if (!isset($url_parts['path']) || !isset($base_parts['path'])) { - return (!isset($base_parts['path']) || $base_parts['path'] == '/') - && ($url_parts['host'] == $base_parts['host']); + return (!isset($base_parts['path']) || $base_parts['path'] === '/') + && ($url_parts['host'] === $base_parts['host']); } else { // When comparing base paths, we need a trailing slash to make sure a // partial URL match isn't occurring. Since base_path() always returns // with a trailing slash, we don't need to add the trailing slash here. - return ($url_parts['host'] == $base_parts['host'] && stripos($url_parts['path'], $base_parts['path']) === 0); + return ($url_parts['host'] === $base_parts['host'] && stripos($url_parts['path'], $base_parts['path']) === 0); } } @@ -323,7 +323,7 @@ public static function stripDangerousProtocols($uri) { $uri = substr($uri, $colonpos + 1); } } - } while ($before != $uri); + } while ($before !== $uri); return $uri; } diff --git a/core/lib/Drupal/Component/Utility/UserAgent.php b/core/lib/Drupal/Component/Utility/UserAgent.php index 6a3b238..b977dc7 100644 --- a/core/lib/Drupal/Component/Utility/UserAgent.php +++ b/core/lib/Drupal/Component/Utility/UserAgent.php @@ -55,7 +55,7 @@ public static function getBestMatchingLangcode($http_accept_language, $langcodes if ($mappings) { $langcode = strtolower($match[1]); foreach ($mappings as $ua_langcode => $standard_langcode) { - if ($langcode == $ua_langcode) { + if ($langcode === $ua_langcode) { $match[1] = $standard_langcode; } } @@ -91,7 +91,7 @@ public static function getBestMatchingLangcode($http_accept_language, $langcodes // first occurrence of '-' otherwise we get a non-existing language zh. // All other languages use a langcode without a '-', so we can safely // split on the first occurrence of it. - if (strlen($langcode) > 7 && (substr($langcode, 0, 7) == 'zh-hant' || substr($langcode, 0, 7) == 'zh-hans')) { + if (strlen($langcode) > 7 && (substr($langcode, 0, 7) === 'zh-hant' || substr($langcode, 0, 7) === 'zh-hans')) { $generic_tag = substr($langcode, 0, 7); } else { diff --git a/core/lib/Drupal/Component/Utility/Variable.php b/core/lib/Drupal/Component/Utility/Variable.php index 2da908b..063f60d 100644 --- a/core/lib/Drupal/Component/Utility/Variable.php +++ b/core/lib/Drupal/Component/Utility/Variable.php @@ -33,7 +33,7 @@ public static function export($var, $prefix = '') { else { $output = "array(\n"; // Don't export keys if the array is non associative. - $export_keys = array_values($var) != $var; + $export_keys = array_values($var) !== $var; foreach ($var as $key => $value) { $output .= ' ' . ($export_keys ? static::export($key) . ' => ' : '') . static::export($value, ' ', FALSE) . ",\n"; } diff --git a/core/lib/Drupal/Component/Utility/Xss.php b/core/lib/Drupal/Component/Utility/Xss.php index 7a77182..25d9635 100644 --- a/core/lib/Drupal/Component/Utility/Xss.php +++ b/core/lib/Drupal/Component/Utility/Xss.php @@ -143,11 +143,11 @@ public static function filterAdmin($string) { * version of the HTML element. */ protected static function split($string, $html_tags, $split_mode) { - if (substr($string, 0, 1) != '<') { + if (substr($string, 0, 1) !== '<') { // We matched a lone ">" character. return '>'; } - elseif (strlen($string) == 1) { + elseif (strlen($string) === 1) { // We matched a lone "<" character. return '<'; } @@ -179,7 +179,7 @@ protected static function split($string, $html_tags, $split_mode) { return $comment; } - if ($slash != '') { + if ($slash !== '') { return ""; } @@ -210,7 +210,7 @@ protected static function attributes($attributes) { $attribute_name = ''; $skip = FALSE; - while (strlen($attributes) != 0) { + while (strlen($attributes) !== 0) { // Was the last operation successful? $working = 0; @@ -219,7 +219,7 @@ protected static function attributes($attributes) { // Attribute name, href for instance. if (preg_match('/^([-a-zA-Z]+)/', $attributes, $match)) { $attribute_name = strtolower($match[1]); - $skip = ($attribute_name == 'style' || substr($attribute_name, 0, 2) == 'on'); + $skip = ($attribute_name === 'style' || substr($attribute_name, 0, 2) === 'on'); $working = $mode = 1; $attributes = preg_replace('/^[-a-zA-Z]+/', '', $attributes); } @@ -279,7 +279,7 @@ protected static function attributes($attributes) { break; } - if ($working == 0) { + if ($working === 0) { // Not well formed; remove and try again. $attributes = preg_replace('/ ^ @@ -297,7 +297,7 @@ protected static function attributes($attributes) { } // The attribute list ends with a valueless attribute like "selected". - if ($mode == 1 && !$skip) { + if ($mode === 1 && !$skip) { $attributes_array[] = $attribute_name; } return $attributes_array; diff --git a/core/lib/Drupal/Core/Access/AccessManager.php b/core/lib/Drupal/Core/Access/AccessManager.php index a56e379..f544691 100644 --- a/core/lib/Drupal/Core/Access/AccessManager.php +++ b/core/lib/Drupal/Core/Access/AccessManager.php @@ -233,7 +233,7 @@ public function check(Route $route, Request $request, AccountInterface $account $checks = $route->getOption('_access_checks') ?: array(); $conjunction = $route->getOption('_access_mode') ?: static::ACCESS_MODE_ALL; - if ($conjunction == static::ACCESS_MODE_ALL) { + if ($conjunction === static::ACCESS_MODE_ALL) { $result = $this->checkAll($checks, $route, $request, $account); } else { diff --git a/core/lib/Drupal/Core/Access/CsrfAccessCheck.php b/core/lib/Drupal/Core/Access/CsrfAccessCheck.php index b603e5c..910f2e5 100644 --- a/core/lib/Drupal/Core/Access/CsrfAccessCheck.php +++ b/core/lib/Drupal/Core/Access/CsrfAccessCheck.php @@ -71,7 +71,7 @@ public function access(Route $route, Request $request) { // Allow if all access checks are needed. This sets DENY if not all access // checks are needed, because another access checker should explicitly grant // access for the route. - return $access->allowIf($conjunction == AccessManagerInterface::ACCESS_MODE_ALL); + return $access->allowIf($conjunction === AccessManagerInterface::ACCESS_MODE_ALL); } } diff --git a/core/lib/Drupal/Core/Ajax/AjaxResponse.php b/core/lib/Drupal/Core/Ajax/AjaxResponse.php index 2ae1853..ced8a27 100644 --- a/core/lib/Drupal/Core/Ajax/AjaxResponse.php +++ b/core/lib/Drupal/Core/Ajax/AjaxResponse.php @@ -75,7 +75,7 @@ public function prepare(Request $request) { * The request object. */ public function prepareResponse(Request $request) { - if ($this->data == '{}') { + if ($this->data === '{}') { $this->setData($this->ajaxRender($request)); } } diff --git a/core/lib/Drupal/Core/Ajax/AjaxResponseRenderer.php b/core/lib/Drupal/Core/Ajax/AjaxResponseRenderer.php index bb55433..0dfdd55 100644 --- a/core/lib/Drupal/Core/Ajax/AjaxResponseRenderer.php +++ b/core/lib/Drupal/Core/Ajax/AjaxResponseRenderer.php @@ -44,7 +44,7 @@ public function render($content) { $response = new AjaxResponse(); - if (isset($content['#type']) && ($content['#type'] == 'ajax')) { + if (isset($content['#type']) && ($content['#type'] === 'ajax')) { // Complex Ajax callbacks can return a result that contains an error // message or a specific set of commands to send to the browser. $content += $this->elementInfo('ajax'); diff --git a/core/lib/Drupal/Core/Archiver/ArchiveTar.php b/core/lib/Drupal/Core/Archiver/ArchiveTar.php index b891f92..5942ab7 100644 --- a/core/lib/Drupal/Core/Archiver/ArchiveTar.php +++ b/core/lib/Drupal/Core/Archiver/ArchiveTar.php @@ -109,17 +109,17 @@ function __construct($p_tarname, $p_compress = null) // $this->PEAR(); $this->_compress = false; $this->_compress_type = 'none'; - if (($p_compress === null) || ($p_compress == '')) { + if (($p_compress === null) || ($p_compress === '')) { if (@file_exists($p_tarname)) { if ($fp = @fopen($p_tarname, "rb")) { // look for gzip magic cookie $data = fread($fp, 2); fclose($fp); - if ($data == "\37\213") { + if ($data === "\37\213") { $this->_compress = true; $this->_compress_type = 'gz'; // No sure it's enought for a magic code .... - } elseif ($data == "BZ") { + } elseif ($data === "BZ") { $this->_compress = true; $this->_compress_type = 'bz2'; } @@ -127,20 +127,20 @@ function __construct($p_tarname, $p_compress = null) } else { // probably a remote file or some file accessible // through a stream interface - if (substr($p_tarname, -2) == 'gz') { + if (substr($p_tarname, -2) === 'gz') { $this->_compress = true; $this->_compress_type = 'gz'; - } elseif ((substr($p_tarname, -3) == 'bz2') || - (substr($p_tarname, -2) == 'bz')) { + } elseif ((substr($p_tarname, -3) === 'bz2') || + (substr($p_tarname, -2) === 'bz')) { $this->_compress = true; $this->_compress_type = 'bz2'; } } } else { - if (($p_compress === true) || ($p_compress == 'gz')) { + if (($p_compress === true) || ($p_compress === 'gz')) { $this->_compress = true; $this->_compress_type = 'gz'; - } else if ($p_compress == 'bz2') { + } else if ($p_compress === 'bz2') { $this->_compress = true; $this->_compress_type = 'bz2'; } else { @@ -151,9 +151,9 @@ function __construct($p_tarname, $p_compress = null) } $this->_tarname = $p_tarname; if ($this->_compress) { // assert zlib or bz2 extension support - if ($this->_compress_type == 'gz') + if ($this->_compress_type === 'gz') $extname = 'zlib'; - else if ($this->_compress_type == 'bz2') + else if ($this->_compress_type === 'bz2') $extname = 'bz2'; if (!extension_loaded($extname)) { @@ -182,17 +182,17 @@ function loadExtension($ext) { if (!extension_loaded($ext)) { // if either returns true dl() will produce a FATAL error, stop that - if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) { + if ((ini_get('enable_dl') !== 1) || (ini_get('safe_mode') === 1)) { return false; } if (OS_WINDOWS) { $suffix = '.dll'; - } elseif (PHP_OS == 'HP-UX') { + } elseif (PHP_OS === 'HP-UX') { $suffix = '.sl'; - } elseif (PHP_OS == 'AIX') { + } elseif (PHP_OS === 'AIX') { $suffix = '.a'; - } elseif (PHP_OS == 'OSX') { + } elseif (PHP_OS === 'OSX') { $suffix = '.bundle'; } else { $suffix = '.so'; @@ -211,7 +211,7 @@ function __destruct() { $this->_close(); // ----- Look for a local copy to delete - if ($this->_temp_tarname != '') + if ($this->_temp_tarname !== '') @drupal_unlink($this->_temp_tarname); // $this->_PEAR(); } @@ -334,7 +334,7 @@ function createModify($p_filelist, $p_add_dir, $p_remove_dir='') if (!$this->_openWrite()) return false; - if ($p_filelist != '') { + if ($p_filelist !== '') { if (is_array($p_filelist)) $v_list = $p_filelist; elseif (is_string($p_filelist)) @@ -589,7 +589,7 @@ function setAttribute() $v_result = true; // ----- Get the number of variable list of arguments - if (($v_size = func_num_args()) == 0) { + if (($v_size = func_num_args()) === 0) { return true; } @@ -650,7 +650,7 @@ function _warning($p_message) // {{{ _isArchive() function _isArchive($p_filename=NULL) { - if ($p_filename == NULL) { + if ($p_filename === NULL) { $p_filename = $this->_tarname; } clearstatcache(TRUE, $p_filename); @@ -661,17 +661,17 @@ function _isArchive($p_filename=NULL) // {{{ _openWrite() function _openWrite() { - if ($this->_compress_type == 'gz') + if ($this->_compress_type === 'gz') $this->_file = @gzopen($this->_tarname, "wb9"); - else if ($this->_compress_type == 'bz2') + else if ($this->_compress_type === 'bz2') $this->_file = @bzopen($this->_tarname, "w"); - else if ($this->_compress_type == 'none') + else if ($this->_compress_type === 'none') $this->_file = @fopen($this->_tarname, "wb"); else $this->_error('Unknown or missing compression type (' .$this->_compress_type.')'); - if ($this->_file == 0) { + if ($this->_file === 0) { $this->_error('Unable to open in write mode \'' .$this->_tarname.'\''); return false; @@ -684,10 +684,10 @@ function _openWrite() // {{{ _openRead() function _openRead() { - if (strtolower(substr($this->_tarname, 0, 7)) == 'http://') { + if (strtolower(substr($this->_tarname, 0, 7)) === 'http://') { // ----- Look if a local copy need to be done - if ($this->_temp_tarname == '') { + if ($this->_temp_tarname === '') { $this->_temp_tarname = uniqid('tar').'.tmp'; if (!$v_file_from = @fopen($this->_tarname, 'rb')) { $this->_error('Unable to open in read mode \'' @@ -714,17 +714,17 @@ function _openRead() // ----- File to open if the normal Tar file $v_filename = $this->_tarname; - if ($this->_compress_type == 'gz') + if ($this->_compress_type === 'gz') $this->_file = @gzopen($v_filename, "rb"); - else if ($this->_compress_type == 'bz2') + else if ($this->_compress_type === 'bz2') $this->_file = @bzopen($v_filename, "r"); - else if ($this->_compress_type == 'none') + else if ($this->_compress_type === 'none') $this->_file = @fopen($v_filename, "rb"); else $this->_error('Unknown or missing compression type (' .$this->_compress_type.')'); - if ($this->_file == 0) { + if ($this->_file === 0) { $this->_error('Unable to open in read mode \''.$v_filename.'\''); return false; } @@ -736,19 +736,19 @@ function _openRead() // {{{ _openReadWrite() function _openReadWrite() { - if ($this->_compress_type == 'gz') + if ($this->_compress_type === 'gz') $this->_file = @gzopen($this->_tarname, "r+b"); - else if ($this->_compress_type == 'bz2') { + else if ($this->_compress_type === 'bz2') { $this->_error('Unable to open bz2 in read/write mode \'' .$this->_tarname.'\' (limitation of bz2 extension)'); return false; - } else if ($this->_compress_type == 'none') + } else if ($this->_compress_type === 'none') $this->_file = @fopen($this->_tarname, "r+b"); else $this->_error('Unknown or missing compression type (' .$this->_compress_type.')'); - if ($this->_file == 0) { + if ($this->_file === 0) { $this->_error('Unable to open in read/write mode \'' .$this->_tarname.'\''); return false; @@ -763,11 +763,11 @@ function _close() { //if (isset($this->_file)) { if (is_resource($this->_file)) { - if ($this->_compress_type == 'gz') + if ($this->_compress_type === 'gz') @gzclose($this->_file); - else if ($this->_compress_type == 'bz2') + else if ($this->_compress_type === 'bz2') @bzclose($this->_file); - else if ($this->_compress_type == 'none') + else if ($this->_compress_type === 'none') @fclose($this->_file); else $this->_error('Unknown or missing compression type (' @@ -778,7 +778,7 @@ function _close() // ----- Look if a local copy need to be erase // Note that it might be interesting to keep the url for a time : ToDo - if ($this->_temp_tarname != '') { + if ($this->_temp_tarname !== '') { @drupal_unlink($this->_temp_tarname); $this->_temp_tarname = ''; } @@ -793,7 +793,7 @@ function _cleanFile() $this->_close(); // ----- Look for a local copy - if ($this->_temp_tarname != '') { + if ($this->_temp_tarname !== '') { // ----- Remove the local copy but not the remote tarname @drupal_unlink($this->_temp_tarname); $this->_temp_tarname = ''; @@ -812,21 +812,21 @@ function _writeBlock($p_binary_data, $p_len=null) { if (is_resource($this->_file)) { if ($p_len === null) { - if ($this->_compress_type == 'gz') + if ($this->_compress_type === 'gz') @gzputs($this->_file, $p_binary_data); - else if ($this->_compress_type == 'bz2') + else if ($this->_compress_type === 'bz2') @bzwrite($this->_file, $p_binary_data); - else if ($this->_compress_type == 'none') + else if ($this->_compress_type === 'none') @fputs($this->_file, $p_binary_data); else $this->_error('Unknown or missing compression type (' .$this->_compress_type.')'); } else { - if ($this->_compress_type == 'gz') + if ($this->_compress_type === 'gz') @gzputs($this->_file, $p_binary_data, $p_len); - else if ($this->_compress_type == 'bz2') + else if ($this->_compress_type === 'bz2') @bzwrite($this->_file, $p_binary_data, $p_len); - else if ($this->_compress_type == 'none') + else if ($this->_compress_type === 'none') @fputs($this->_file, $p_binary_data, $p_len); else $this->_error('Unknown or missing compression type (' @@ -843,11 +843,11 @@ function _readBlock() { $v_block = null; if (is_resource($this->_file)) { - if ($this->_compress_type == 'gz') + if ($this->_compress_type === 'gz') $v_block = @gzread($this->_file, 512); - else if ($this->_compress_type == 'bz2') + else if ($this->_compress_type === 'bz2') $v_block = @bzread($this->_file, 512); - else if ($this->_compress_type == 'none') + else if ($this->_compress_type === 'none') $v_block = @fread($this->_file, 512); else $this->_error('Unknown or missing compression type (' @@ -864,14 +864,14 @@ function _jumpBlock($p_len=null) if ($p_len === null) $p_len = 1; - if ($this->_compress_type == 'gz') { + if ($this->_compress_type === 'gz') { @gzseek($this->_file, gztell($this->_file)+($p_len*512)); } - else if ($this->_compress_type == 'bz2') { + else if ($this->_compress_type === 'bz2') { // ----- Replace missing bztell() and bzseek() for ($i=0; $i<$p_len; $i++) $this->_readBlock(); - } else if ($this->_compress_type == 'none') + } else if ($this->_compress_type === 'none') @fseek($this->_file, ftell($this->_file)+($p_len*512)); else $this->_error('Unknown or missing compression type (' @@ -909,7 +909,7 @@ function _addList($p_list, $p_add_dir, $p_remove_dir) return false; } - if (sizeof($p_list) == 0) + if (sizeof($p_list) === 0) return true; foreach ($p_list as $v_filename) { @@ -918,10 +918,10 @@ function _addList($p_list, $p_add_dir, $p_remove_dir) } // ----- Skip the current tar name - if ($v_filename == $this->_tarname) + if ($v_filename === $this->_tarname) continue; - if ($v_filename == '') + if ($v_filename === '') continue; if (!file_exists($v_filename)) { @@ -939,8 +939,8 @@ function _addList($p_list, $p_add_dir, $p_remove_dir) continue; } while (false !== ($p_hitem = readdir($p_hdir))) { - if (($p_hitem != '.') && ($p_hitem != '..')) { - if ($v_filename != ".") + if (($p_hitem !== '.') && ($p_hitem !== '..')) { + if ($v_filename !== ".") $p_temp_list[0] = $v_filename.'/'.$p_hitem; else $p_temp_list[0] = $p_hitem; @@ -969,7 +969,7 @@ function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir) return false; } - if ($p_filename == '') { + if ($p_filename === '') { $this->_error('Invalid file name'); return false; } @@ -977,19 +977,19 @@ function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir) // ----- Calculate the stored filename $p_filename = $this->_translateWinPath($p_filename, false); $v_stored_filename = $p_filename; - if (strcmp($p_filename, $p_remove_dir) == 0) { + if (strcmp($p_filename, $p_remove_dir) === 0) { return true; } - if ($p_remove_dir != '') { - if (substr($p_remove_dir, -1) != '/') + if ($p_remove_dir !== '') { + if (substr($p_remove_dir, -1) !== '/') $p_remove_dir .= '/'; - if (substr($p_filename, 0, strlen($p_remove_dir)) == $p_remove_dir) + if (substr($p_filename, 0, strlen($p_remove_dir)) === $p_remove_dir) $v_stored_filename = substr($p_filename, strlen($p_remove_dir)); } $v_stored_filename = $this->_translateWinPath($v_stored_filename); - if ($p_add_dir != '') { - if (substr($p_add_dir, -1) == '/') + if ($p_add_dir !== '') { + if (substr($p_add_dir, -1) === '/') $v_stored_filename = $p_add_dir.$v_stored_filename; else $v_stored_filename = $p_add_dir.'/'.$v_stored_filename; @@ -998,7 +998,7 @@ function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir) $v_stored_filename = $this->_pathReduction($v_stored_filename); if ($this->_isArchive($p_filename)) { - if (($v_file = @fopen($p_filename, "rb")) == 0) { + if (($v_file = @fopen($p_filename, "rb")) === 0) { $this->_warning("Unable to open file '".$p_filename ."' in binary read mode"); return true; @@ -1007,7 +1007,7 @@ function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir) if (!$this->_writeHeader($p_filename, $v_stored_filename)) return false; - while (($v_buffer = fread($v_file, 512)) != '') { + while (($v_buffer = fread($v_file, 512)) !== '') { $v_binary_data = pack("a512", "$v_buffer"); $this->_writeBlock($v_binary_data); } @@ -1032,7 +1032,7 @@ function _addString($p_filename, $p_string) return false; } - if ($p_filename == '') { + if ($p_filename === '') { $this->_error('Invalid file name'); return false; } @@ -1045,7 +1045,7 @@ function _addString($p_filename, $p_string) return false; $i=0; - while (($v_buffer = substr($p_string, (($i++)*512), 512)) != '') { + while (($v_buffer = substr($p_string, (($i++)*512), 512)) !== '') { $v_binary_data = pack("a512", $v_buffer); $this->_writeBlock($v_binary_data); } @@ -1057,7 +1057,7 @@ function _addString($p_filename, $p_string) // {{{ _writeHeader() function _writeHeader($p_filename, $p_stored_filename) { - if ($p_stored_filename == '') + if ($p_stored_filename === '') $p_stored_filename = $p_filename; $v_reduce_filename = $this->_pathReduction($p_stored_filename); @@ -1148,7 +1148,7 @@ function _writeHeaderBlock($p_filename, $p_size, $p_mtime=0, $p_perms=0, return false; } - if ($p_type == "5") { + if ($p_type === "5") { $v_size = sprintf("%11s ", DecOct(0)); } else { $v_size = sprintf("%11s ", DecOct($p_size)); @@ -1266,7 +1266,7 @@ function _writeLongHeader($p_filename) // ----- Write the filename as content of the block $i=0; - while (($v_buffer = substr($p_filename, (($i++)*512), 512)) != '') { + while (($v_buffer = substr($p_filename, (($i++)*512), 512)) !== '') { $v_binary_data = pack("a512", "$v_buffer"); $this->_writeBlock($v_binary_data); } @@ -1283,7 +1283,7 @@ function _readHeader($v_binary_data, &$v_header) return true; } - if (strlen($v_binary_data) != 512) { + if (strlen($v_binary_data) !== 512) { $v_header['filename'] = ''; $this->_error('Invalid block size : '.strlen($v_binary_data)); return false; @@ -1311,11 +1311,11 @@ function _readHeader($v_binary_data, &$v_header) // ----- Extract the checksum $v_header['checksum'] = OctDec(trim($v_data['checksum'])); - if ($v_header['checksum'] != $v_checksum) { + if ($v_header['checksum'] !== $v_checksum) { $v_header['filename'] = ''; // ----- Look for last block (empty block) - if (($v_checksum == 256) && ($v_header['checksum'] == 0)) + if (($v_checksum === 256) && ($v_header['checksum'] === 0)) return true; $this->_error('Invalid checksum for file "'.$v_data['filename'] @@ -1336,7 +1336,7 @@ function _readHeader($v_binary_data, &$v_header) $v_header['gid'] = OctDec(trim($v_data['gid'])); $v_header['size'] = OctDec(trim($v_data['size'])); $v_header['mtime'] = OctDec(trim($v_data['mtime'])); - if (($v_header['typeflag'] = $v_data['typeflag']) == "5") { + if (($v_header['typeflag'] = $v_data['typeflag']) === "5") { $v_header['size'] = 0; } $v_header['link'] = trim($v_data['link']); @@ -1383,7 +1383,7 @@ function _readLongHeader(&$v_header) $v_content = $this->_readBlock(); $v_filename .= $v_content; } - if (($v_header['size'] % 512) != 0) { + if (($v_header['size'] % 512) !== 0) { $v_content = $this->_readBlock(); $v_filename .= $v_content; } @@ -1418,22 +1418,22 @@ function _extractInString($p_filename) { $v_result_str = ""; - While (strlen($v_binary_data = $this->_readBlock()) != 0) + While (strlen($v_binary_data = $this->_readBlock()) !== 0) { if (!$this->_readHeader($v_binary_data, $v_header)) return NULL; - if ($v_header['filename'] == '') + if ($v_header['filename'] === '') continue; // ----- Look for long filename - if ($v_header['typeflag'] == 'L') { + if ($v_header['typeflag'] === 'L') { if (!$this->_readLongHeader($v_header)) return NULL; } - if ($v_header['filename'] == $p_filename) { - if ($v_header['typeflag'] == "5") { + if ($v_header['filename'] === $p_filename) { + if ($v_header['typeflag'] === "5") { $this->_error('Unable to extract in string a directory ' .'entry {'.$v_header['filename'].'}'); return NULL; @@ -1442,7 +1442,7 @@ function _extractInString($p_filename) for ($i=0; $i<$n; $i++) { $v_result_str .= $this->_readBlock(); } - if (($v_header['size'] % 512) != 0) { + if (($v_header['size'] % 512) !== 0) { $v_content = $this->_readBlock(); $v_result_str .= substr($v_content, 0, ($v_header['size'] % 512)); @@ -1468,14 +1468,14 @@ function _extractList($p_path, &$p_list_detail, $p_mode, $v_listing = false; $p_path = $this->_translateWinPath($p_path, false); - if ($p_path == '' || (substr($p_path, 0, 1) != '/' - && substr($p_path, 0, 3) != "../" && !strpos($p_path, ':'))) { + if ($p_path === '' || (substr($p_path, 0, 1) !== '/' + && substr($p_path, 0, 3) !== "../" && !strpos($p_path, ':'))) { $p_path = "./".$p_path; } $p_remove_path = $this->_translateWinPath($p_remove_path); // ----- Look for path to remove format (should end by /) - if (($p_remove_path != '') && (substr($p_remove_path, -1) != '/')) + if (($p_remove_path !== '') && (substr($p_remove_path, -1) !== '/')) $p_remove_path .= '/'; $p_remove_path_size = strlen($p_remove_path); @@ -1499,7 +1499,7 @@ function _extractList($p_path, &$p_list_detail, $p_mode, clearstatcache(); - while (strlen($v_binary_data = $this->_readBlock()) != 0) + while (strlen($v_binary_data = $this->_readBlock()) !== 0) { $v_extract_file = FALSE; $v_extraction_stopped = 0; @@ -1507,12 +1507,12 @@ function _extractList($p_path, &$p_list_detail, $p_mode, if (!$this->_readHeader($v_binary_data, $v_header)) return false; - if ($v_header['filename'] == '') { + if ($v_header['filename'] === '') { continue; } // ----- Look for long filename - if ($v_header['typeflag'] == 'L') { + if ($v_header['typeflag'] === 'L') { if (!$this->_readLongHeader($v_header)) return false; } @@ -1523,18 +1523,18 @@ function _extractList($p_path, &$p_list_detail, $p_mode, for ($i=0; $i strlen($p_file_list[$i])) && (substr($v_header['filename'], 0, strlen($p_file_list[$i])) - == $p_file_list[$i])) { + === $p_file_list[$i])) { $v_extract_file = TRUE; break; } } // ----- It is a file, so compare the file names - elseif ($p_file_list[$i] == $v_header['filename']) { + elseif ($p_file_list[$i] === $v_header['filename']) { $v_extract_file = TRUE; break; } @@ -1546,29 +1546,29 @@ function _extractList($p_path, &$p_list_detail, $p_mode, // ----- Look if this file need to be extracted if (($v_extract_file) && (!$v_listing)) { - if (($p_remove_path != '') + if (($p_remove_path !== '') && (substr($v_header['filename'], 0, $p_remove_path_size) - == $p_remove_path)) + === $p_remove_path)) $v_header['filename'] = substr($v_header['filename'], $p_remove_path_size); - if (($p_path != './') && ($p_path != '/')) { - while (substr($p_path, -1) == '/') + if (($p_path !== './') && ($p_path !== '/')) { + while (substr($p_path, -1) === '/') $p_path = substr($p_path, 0, strlen($p_path)-1); - if (substr($v_header['filename'], 0, 1) == '/') + if (substr($v_header['filename'], 0, 1) === '/') $v_header['filename'] = $p_path.$v_header['filename']; else $v_header['filename'] = $p_path.'/'.$v_header['filename']; } if (file_exists($v_header['filename'])) { if ( (@is_dir($v_header['filename'])) - && ($v_header['typeflag'] == '')) { + && ($v_header['typeflag'] === '')) { $this->_error('File '.$v_header['filename'] .' already exists as a directory'); return false; } if ( ($this->_isArchive($v_header['filename'])) - && ($v_header['typeflag'] == "5")) { + && ($v_header['typeflag'] === "5")) { $this->_error('Directory '.$v_header['filename'] .' already exists as a file'); return false; @@ -1585,15 +1585,15 @@ function _extractList($p_path, &$p_list_detail, $p_mode, // ----- Check the directory availability and create it if necessary elseif (($v_result - = $this->_dirCheck(($v_header['typeflag'] == "5" + = $this->_dirCheck(($v_header['typeflag'] === "5" ?$v_header['filename'] - :dirname($v_header['filename'])))) != 1) { + :dirname($v_header['filename'])))) !== 1) { $this->_error('Unable to create path for '.$v_header['filename']); return false; } if ($v_extract_file) { - if ($v_header['typeflag'] == "5") { + if ($v_header['typeflag'] === "5") { if (!@file_exists($v_header['filename'])) { // Drupal integration. // Changed the code to use drupal_mkdir() instead of mkdir(). @@ -1603,7 +1603,7 @@ function _extractList($p_path, &$p_list_detail, $p_mode, return false; } } - } elseif ($v_header['typeflag'] == "2") { + } elseif ($v_header['typeflag'] === "2") { if (@file_exists($v_header['filename'])) { @drupal_unlink($v_header['filename']); } @@ -1613,7 +1613,7 @@ function _extractList($p_path, &$p_list_detail, $p_mode, return false; } } else { - if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) { + if (($v_dest_file = @fopen($v_header['filename'], "wb")) === 0) { $this->_error('Error while opening {'.$v_header['filename'] .'} in write binary mode'); return false; @@ -1623,7 +1623,7 @@ function _extractList($p_path, &$p_list_detail, $p_mode, $v_content = $this->_readBlock(); fwrite($v_dest_file, $v_content, 512); } - if (($v_header['size'] % 512) != 0) { + if (($v_header['size'] % 512) !== 0) { $v_content = $this->_readBlock(); fwrite($v_dest_file, $v_content, ($v_header['size'] % 512)); } @@ -1641,7 +1641,7 @@ function _extractList($p_path, &$p_list_detail, $p_mode, // ----- Check the file size clearstatcache(TRUE, $v_header['filename']); - if (filesize($v_header['filename']) != $v_header['size']) { + if (filesize($v_header['filename']) !== $v_header['size']) { $this->_error('Extracted file '.$v_header['filename'] .' does not have the correct file size \'' .filesize($v_header['filename']) @@ -1667,13 +1667,13 @@ function _extractList($p_path, &$p_list_detail, $p_mode, if ($v_listing || $v_extract_file || $v_extraction_stopped) { // ----- Log extracted files if (($v_file_dir = dirname($v_header['filename'])) - == $v_header['filename']) + === $v_header['filename']) $v_file_dir = ''; - if ((substr($v_header['filename'], 0, 1) == '/') && ($v_file_dir == '')) + if ((substr($v_header['filename'], 0, 1) === '/') && ($v_file_dir === '')) $v_file_dir = '/'; $p_list_detail[$v_nb++] = $v_header; - if (is_array($p_file_list) && (count($p_list_detail) == count($p_file_list))) { + if (is_array($p_file_list) && (count($p_list_detail) === count($p_file_list))) { return true; } } @@ -1686,7 +1686,7 @@ function _extractList($p_path, &$p_list_detail, $p_mode, // {{{ _openAppend() function _openAppend() { - if (filesize($this->_tarname) == 0) + if (filesize($this->_tarname) === 0) return $this->_openWrite(); if ($this->_compress) { @@ -1699,12 +1699,12 @@ function _openAppend() return false; } - if ($this->_compress_type == 'gz') + if ($this->_compress_type === 'gz') $v_temp_tar = @gzopen($this->_tarname.".tmp", "rb"); - elseif ($this->_compress_type == 'bz2') + elseif ($this->_compress_type === 'bz2') $v_temp_tar = @bzopen($this->_tarname.".tmp", "r"); - if ($v_temp_tar == 0) { + if ($v_temp_tar === 0) { $this->_error('Unable to open file \''.$this->_tarname .'.tmp\' in binary read mode'); @rename($this->_tarname.".tmp", $this->_tarname); @@ -1716,10 +1716,10 @@ function _openAppend() return false; } - if ($this->_compress_type == 'gz') { + if ($this->_compress_type === 'gz') { while (!@gzeof($v_temp_tar)) { $v_buffer = @gzread($v_temp_tar, 512); - if ($v_buffer == ARCHIVE_TAR_END_BLOCK) { + if ($v_buffer === ARCHIVE_TAR_END_BLOCK) { // do not copy end blocks, we will re-make them // after appending continue; @@ -1730,9 +1730,9 @@ function _openAppend() @gzclose($v_temp_tar); } - elseif ($this->_compress_type == 'bz2') { + elseif ($this->_compress_type === 'bz2') { while (strlen($v_buffer = @bzread($v_temp_tar, 512)) > 0) { - if ($v_buffer == ARCHIVE_TAR_END_BLOCK) { + if ($v_buffer === ARCHIVE_TAR_END_BLOCK) { continue; } $v_binary_data = pack("a512", $v_buffer); @@ -1760,10 +1760,10 @@ function _openAppend() // The standard is two, but we should try to handle // other cases. fseek($this->_file, $v_size - 1024); - if (fread($this->_file, 512) == ARCHIVE_TAR_END_BLOCK) { + if (fread($this->_file, 512) === ARCHIVE_TAR_END_BLOCK) { fseek($this->_file, $v_size - 1024); } - elseif (fread($this->_file, 512) == ARCHIVE_TAR_END_BLOCK) { + elseif (fread($this->_file, 512) === ARCHIVE_TAR_END_BLOCK) { fseek($this->_file, $v_size - 512); } } @@ -1800,13 +1800,13 @@ function _append($p_filelist, $p_add_dir='', $p_remove_dir='') function _dirCheck($p_dir) { clearstatcache(TRUE, $p_dir); - if ((@is_dir($p_dir)) || ($p_dir == '')) + if ((@is_dir($p_dir)) || ($p_dir === '')) return true; $p_parent_dir = dirname($p_dir); - if (($p_parent_dir != $p_dir) && - ($p_parent_dir != '') && + if (($p_parent_dir !== $p_dir) && + ($p_parent_dir !== '') && (!$this->_dirCheck($p_parent_dir))) return false; @@ -1840,22 +1840,22 @@ function _pathReduction($p_dir) $v_result = ''; // ----- Look for not empty path - if ($p_dir != '') { + if ($p_dir !== '') { // ----- Explode path by directory names $v_list = explode('/', $p_dir); // ----- Study directories from last to first for ($i=sizeof($v_list)-1; $i>=0; $i--) { // ----- Look for current path - if ($v_list[$i] == ".") { + if ($v_list[$i] === ".") { // ----- Ignore this directory // Should be the first $i=0, but no check is done } - else if ($v_list[$i] == "..") { + else if ($v_list[$i] === "..") { // ----- Ignore it and ignore the $i-1 $i--; } - else if ( ($v_list[$i] == '') + else if ( ($v_list[$i] === '') && ($i!=(sizeof($v_list)-1)) && ($i!=0)) { // ----- Ignore only the double '//' in path, @@ -1878,11 +1878,11 @@ function _translateWinPath($p_path, $p_remove_disk_letter=true) if (defined('OS_WINDOWS') && OS_WINDOWS) { // ----- Look for potential disk letter if ( ($p_remove_disk_letter) - && (($v_position = strpos($p_path, ':')) != false)) { + && (($v_position = strpos($p_path, ':')) !== false)) { $p_path = substr($p_path, $v_position+1); } // ----- Change potential windows directory separator - if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { + if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) === '\\')) { $p_path = strtr($p_path, '\\', '/'); } } diff --git a/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php b/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php index 0d482fb..ed865c0 100644 --- a/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php +++ b/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php @@ -136,7 +136,7 @@ public function render(array $css_assets) { else { break; } - } while ($get_ie_group_key($next_css_asset) == $current_ie_group_key); + } while ($get_ie_group_key($next_css_asset) === $current_ie_group_key); // In addition to IE's limit of 31 total CSS inclusion tags, it // also has a limit of 31 @import statements per STYLE tag. diff --git a/core/lib/Drupal/Core/Asset/CssOptimizer.php b/core/lib/Drupal/Core/Asset/CssOptimizer.php index 1090d5a..3a80d47 100644 --- a/core/lib/Drupal/Core/Asset/CssOptimizer.php +++ b/core/lib/Drupal/Core/Asset/CssOptimizer.php @@ -139,7 +139,7 @@ protected function loadNestedFile($matches) { $directory = dirname($filename); // If the file is in the current directory, make sure '.' doesn't appear in // the url() path. - $directory = $directory == '.' ? '' : $directory .'/'; + $directory = $directory === '.' ? '' : $directory .'/'; // Alter all internal url() paths. Leave external paths alone. We don't need // to normalize absolute paths here (i.e. remove folder/... segments) @@ -225,7 +225,7 @@ public function rewriteFileURI($matches) { // Prefix with base and remove '../' segments where possible. $path = $this->rewriteFileURIBasePath . $matches[1]; $last = ''; - while ($path != $last) { + while ($path !== $last) { $last = $path; $path = preg_replace('`(^|/)(?!\.\./)([^/]+)/\.\./`', '$1', $path); } diff --git a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php index bd962bd..e0bd27a 100644 --- a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php +++ b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php @@ -107,7 +107,7 @@ public function buildByExtension($extension) { // @todo After Asset(ic) changes, retain the definitions as-is and // properly resolve dependencies for all (css) libraries per category, // and only once prior to rendering out an HTML page. - if ($type == 'css' && !empty($library[$type])) { + if ($type === 'css' && !empty($library[$type])) { foreach ($library[$type] as $category => $files) { foreach ($files as $source => $options) { if (!isset($options['weight'])) { @@ -126,24 +126,24 @@ public function buildByExtension($extension) { if (!is_array($options)) { $options = array(); } - if ($type == 'js' && isset($options['weight']) && $options['weight'] > 0) { + if ($type === 'js' && isset($options['weight']) && $options['weight'] > 0) { throw new \UnexpectedValueException("The $extension/$id library defines a positive weight for '$source'. Only negative weights are allowed (but should be avoided). Instead of a positive weight, specify accurate dependencies for this library."); } // Unconditionally apply default groups for the defined asset files. // The library system is a dependency management system. Each library // properly specifies its dependencies instead of relying on a custom // processing order. - if ($type == 'js') { + if ($type === 'js') { $options['group'] = JS_LIBRARY; } - elseif ($type == 'css') { - $options['group'] = $extension_type == 'theme' ? CSS_AGGREGATE_THEME : CSS_AGGREGATE_DEFAULT; + elseif ($type === 'css') { + $options['group'] = $extension_type === 'theme' ? CSS_AGGREGATE_THEME : CSS_AGGREGATE_DEFAULT; } // By default, all library assets are files. if (!isset($options['type'])) { $options['type'] = 'file'; } - if ($options['type'] == 'external') { + if ($options['type'] === 'external') { $options['data'] = $source; } // Determine the file asset URI. @@ -178,7 +178,7 @@ public function buildByExtension($extension) { } // Set the 'minified' flag on JS file assets, default to FALSE. - if ($type == 'js' && $options['type'] == 'file') { + if ($type === 'js' && $options['type'] === 'file') { $options['minified'] = isset($options['minified']) ? $options['minified'] : FALSE; } diff --git a/core/lib/Drupal/Core/Authentication/AuthenticationManager.php b/core/lib/Drupal/Core/Authentication/AuthenticationManager.php index 7c357c9..755f9a8 100644 --- a/core/lib/Drupal/Core/Authentication/AuthenticationManager.php +++ b/core/lib/Drupal/Core/Authentication/AuthenticationManager.php @@ -186,7 +186,7 @@ public function handleException(GetResponseForExceptionEvent $event) { $providers = array_intersect($active_providers, array_keys($this->getSortedProviders())); foreach ($providers as $provider_id) { - if ($this->providers[$provider_id]->handleException($event) == TRUE) { + if ($this->providers[$provider_id]->handleException($event) === TRUE) { break; } } diff --git a/core/lib/Drupal/Core/Batch/Percentage.php b/core/lib/Drupal/Core/Batch/Percentage.php index 6cb1bef..b355d76 100644 --- a/core/lib/Drupal/Core/Batch/Percentage.php +++ b/core/lib/Drupal/Core/Batch/Percentage.php @@ -32,7 +32,7 @@ class Percentage { * @see _batch_process() */ public static function format($total, $current) { - if (!$total || $total == $current) { + if (!$total || $total === $current) { // If $total doesn't evaluate as true or is equal to the current set, then // we're finished, and we can return "100". $percentage = '100'; @@ -50,7 +50,7 @@ public static function format($total, $current) { // may be erroneously rounded up to 100%. To prevent that, we add one // more decimal place and try again. $decimal_places++; - } while ($percentage == '100'); + } while ($percentage === '100'); } return $percentage; } diff --git a/core/lib/Drupal/Core/Block/BlockManager.php b/core/lib/Drupal/Core/Block/BlockManager.php index 8cde728..21ddc38 100644 --- a/core/lib/Drupal/Core/Block/BlockManager.php +++ b/core/lib/Drupal/Core/Block/BlockManager.php @@ -103,7 +103,7 @@ public function getSortedDefinitions() { // Sort the plugins first by category, then by label. $definitions = $this->getDefinitionsForContexts(); uasort($definitions, function ($a, $b) { - if ($a['category'] != $b['category']) { + if ($a['category'] !== $b['category']) { return strnatcasecmp($a['category'], $b['category']); } return strnatcasecmp($a['admin_label'], $b['admin_label']); diff --git a/core/lib/Drupal/Core/Cache/ApcuBackend.php b/core/lib/Drupal/Core/Cache/ApcuBackend.php index 0ec166f..6d7d8f3 100644 --- a/core/lib/Drupal/Core/Cache/ApcuBackend.php +++ b/core/lib/Drupal/Core/Cache/ApcuBackend.php @@ -166,15 +166,15 @@ protected function prepareItem($cache, $allow_invalid) { $checksum = $this->checksumTags($cache->tags); // Check if deleteTags() has been called with any of the entry's tags. - if ($cache->checksum_deletions != $checksum['deletions']) { + if ($cache->checksum_deletions !== $checksum['deletions']) { return FALSE; } // Check expire time. - $cache->valid = $cache->expire == Cache::PERMANENT || $cache->expire >= REQUEST_TIME; + $cache->valid = $cache->expire === Cache::PERMANENT || $cache->expire >= REQUEST_TIME; // Check if invalidateTags() has been called with any of the entry's tags. - if ($cache->checksum_invalidations != $checksum['invalidations']) { + if ($cache->checksum_invalidations !== $checksum['invalidations']) { $cache->valid = FALSE; } diff --git a/core/lib/Drupal/Core/Cache/CacheCollector.php b/core/lib/Drupal/Core/Cache/CacheCollector.php index b90327e..702b683 100644 --- a/core/lib/Drupal/Core/Cache/CacheCollector.php +++ b/core/lib/Drupal/Core/Cache/CacheCollector.php @@ -238,7 +238,7 @@ protected function updateCache($lock = TRUE) { // entry if the creation date did not change as this could result in an // inconsistent cache. if ($cache = $this->cache->get($cid, $this->cacheInvalidated)) { - if ($this->cacheInvalidated && $cache->created != $this->cacheCreated) { + if ($this->cacheInvalidated && $cache->created !== $this->cacheCreated) { // We have invalidated the cache in this request and got a different // cache entry. Do not attempt to overwrite data that might have been // changed in a different request. We'll let the cache rebuild in diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php index 9386610..90d6cfb 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -119,15 +119,15 @@ protected function prepareItem($cache, $allow_invalid) { $checksum = $this->checksumTags($cache->tags); // Check if deleteTags() has been called with any of the entry's tags. - if ($cache->checksum_deletions != $checksum['deletions']) { + if ($cache->checksum_deletions !== $checksum['deletions']) { return FALSE; } // Check expire time. - $cache->valid = $cache->expire == Cache::PERMANENT || $cache->expire >= REQUEST_TIME; + $cache->valid = $cache->expire === Cache::PERMANENT || $cache->expire >= REQUEST_TIME; // Check if invalidateTags() has been called with any of the entry's tags. - if ($cache->checksum_invalidations != $checksum['invalidations']) { + if ($cache->checksum_invalidations !== $checksum['invalidations']) { $cache->valid = FALSE; } diff --git a/core/lib/Drupal/Core/Cache/MemoryBackend.php b/core/lib/Drupal/Core/Cache/MemoryBackend.php index ce8e199..28ad811 100644 --- a/core/lib/Drupal/Core/Cache/MemoryBackend.php +++ b/core/lib/Drupal/Core/Cache/MemoryBackend.php @@ -94,7 +94,7 @@ protected function prepareItem($cache, $allow_invalid) { $prepared->data = unserialize($prepared->data); // Check expire time. - $prepared->valid = $prepared->expire == Cache::PERMANENT || $prepared->expire >= REQUEST_TIME; + $prepared->valid = $prepared->expire === Cache::PERMANENT || $prepared->expire >= REQUEST_TIME; if (!$allow_invalid && !$prepared->valid) { return FALSE; diff --git a/core/lib/Drupal/Core/Cache/PhpBackend.php b/core/lib/Drupal/Core/Cache/PhpBackend.php index 8613859..ad04837 100644 --- a/core/lib/Drupal/Core/Cache/PhpBackend.php +++ b/core/lib/Drupal/Core/Cache/PhpBackend.php @@ -120,7 +120,7 @@ protected function prepareItem($cache, $allow_invalid) { } // Check expire time. - $cache->valid = $cache->expire == Cache::PERMANENT || $cache->expire >= REQUEST_TIME; + $cache->valid = $cache->expire === Cache::PERMANENT || $cache->expire >= REQUEST_TIME; if (!$allow_invalid && !$cache->valid) { return FALSE; diff --git a/core/lib/Drupal/Core/Condition/ConditionAccessResolverTrait.php b/core/lib/Drupal/Core/Condition/ConditionAccessResolverTrait.php index 528e662..420c936 100644 --- a/core/lib/Drupal/Core/Condition/ConditionAccessResolverTrait.php +++ b/core/lib/Drupal/Core/Condition/ConditionAccessResolverTrait.php @@ -36,18 +36,18 @@ protected function resolveConditions($conditions, $condition_logic) { } // If a condition fails and all conditions were needed, deny access. - if (!$pass && $condition_logic == 'and') { + if (!$pass && $condition_logic === 'and') { return FALSE; } // If a condition passes and only one condition was needed, grant access. - elseif ($pass && $condition_logic == 'or') { + elseif ($pass && $condition_logic === 'or') { return TRUE; } } // Return TRUE if logic was 'and', meaning all rules passed. // Return FALSE if logic was 'or', meaning no rule passed. - return $condition_logic == 'and'; + return $condition_logic === 'and'; } } diff --git a/core/lib/Drupal/Core/Config/CachedStorage.php b/core/lib/Drupal/Core/Config/CachedStorage.php index 0b089ca..daeac31 100644 --- a/core/lib/Drupal/Core/Config/CachedStorage.php +++ b/core/lib/Drupal/Core/Config/CachedStorage.php @@ -315,7 +315,7 @@ protected function getCacheKeys(array $names) { */ protected function getCollectionPrefix() { $collection = $this->storage->getCollectionName(); - if ($collection == StorageInterface::DEFAULT_COLLECTION) { + if ($collection === StorageInterface::DEFAULT_COLLECTION) { return ''; } return $collection . ':'; diff --git a/core/lib/Drupal/Core/Config/Config.php b/core/lib/Drupal/Core/Config/Config.php index b3b51c2..4c506f8 100644 --- a/core/lib/Drupal/Core/Config/Config.php +++ b/core/lib/Drupal/Core/Config/Config.php @@ -96,7 +96,7 @@ public function get($key = '') { } else { $parts = explode('.', $key); - if (count($parts) == 1) { + if (count($parts) === 1) { return isset($this->overriddenData[$key]) ? $this->overriddenData[$key] : NULL; } else { @@ -290,7 +290,7 @@ public function getOriginal($key = '', $apply_overrides = TRUE) { } else { $parts = explode('.', $key); - if (count($parts) == 1) { + if (count($parts) === 1) { return isset($original_data[$key]) ? $original_data[$key] : NULL; } else { diff --git a/core/lib/Drupal/Core/Config/ConfigBase.php b/core/lib/Drupal/Core/Config/ConfigBase.php index 552eacf..812d699 100644 --- a/core/lib/Drupal/Core/Config/ConfigBase.php +++ b/core/lib/Drupal/Core/Config/ConfigBase.php @@ -142,7 +142,7 @@ public function get($key = '') { } else { $parts = explode('.', $key); - if (count($parts) == 1) { + if (count($parts) === 1) { return isset($this->data[$key]) ? $this->data[$key] : NULL; } else { @@ -191,7 +191,7 @@ public function set($key, $value) { $this->validateKeys($value); } $parts = explode('.', $key); - if (count($parts) == 1) { + if (count($parts) === 1) { $this->data[$key] = $value; } else { @@ -233,7 +233,7 @@ protected function validateKeys(array $data) { */ public function clear($key) { $parts = explode('.', $key); - if (count($parts) == 1) { + if (count($parts) === 1) { unset($this->data[$key]); } else { diff --git a/core/lib/Drupal/Core/Config/ConfigCollectionInfo.php b/core/lib/Drupal/Core/Config/ConfigCollectionInfo.php index 43be83e..9d672c3 100644 --- a/core/lib/Drupal/Core/Config/ConfigCollectionInfo.php +++ b/core/lib/Drupal/Core/Config/ConfigCollectionInfo.php @@ -38,7 +38,7 @@ class ConfigCollectionInfo extends Event { * \Drupal\Core\Config\StorageInterface::DEFAULT_COLLECTION */ public function addCollection($collection, ConfigFactoryOverrideInterface $override_service = NULL) { - if ($collection == StorageInterface::DEFAULT_COLLECTION) { + if ($collection === StorageInterface::DEFAULT_COLLECTION) { throw new \InvalidArgumentException('Can not add the default collection to the ConfigCollectionInfo object'); } $this->collections[$collection] = $override_service; diff --git a/core/lib/Drupal/Core/Config/ConfigImporter.php b/core/lib/Drupal/Core/Config/ConfigImporter.php index b87c76d..5b23144 100644 --- a/core/lib/Drupal/Core/Config/ConfigImporter.php +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php @@ -442,7 +442,7 @@ protected function getExtensionChangelist($type, $op = NULL) { protected function getUnprocessedExtensions($type) { $changelist = $this->getExtensionChangelist($type); - if ($type == 'theme') { + if ($type === 'theme') { $unprocessed = array( 'enable' => array_diff($changelist['enable'], $this->processedExtensions[$type]['enable']), 'disable' => array_diff($changelist['disable'], $this->processedExtensions[$type]['disable']), @@ -595,7 +595,7 @@ protected function processConfigurations(array &$context) { // This involves recalculating the changelist which will ensure that if // extensions have been processed any configuration affected will be taken // into account. - if ($this->totalConfigurationToProcess == 0) { + if ($this->totalConfigurationToProcess === 0) { $this->storageComparer->reset(); foreach ($this->storageComparer->getAllCollectionNames() as $collection) { foreach (array('delete', 'create', 'rename', 'update') as $op) { @@ -608,7 +608,7 @@ protected function processConfigurations(array &$context) { if ($this->checkOp($operation['collection'], $operation['op'], $operation['name'])) { $this->processConfiguration($operation['collection'], $operation['op'], $operation['name']); } - if ($operation['collection'] == StorageInterface::DEFAULT_COLLECTION) { + if ($operation['collection'] === StorageInterface::DEFAULT_COLLECTION) { $context['message'] = $this->t('Synchronizing configuration: @op @name.', array('@op' => $operation['op'], '@name' => $operation['name'])); } else { @@ -714,7 +714,7 @@ protected function validate() { $names = $this->storageComparer->extractRenameNames($name); $old_entity_type_id = $this->configManager->getEntityTypeIdByName($names['old_name']); $new_entity_type_id = $this->configManager->getEntityTypeIdByName($names['new_name']); - if ($old_entity_type_id != $new_entity_type_id) { + if ($old_entity_type_id !== $new_entity_type_id) { $this->logError($this->t('Entity type mismatch on rename. !old_type not equal to !new_type for existing configuration !old_name and staged configuration !new_name.', array('old_type' => $old_entity_type_id, 'new_type' => $new_entity_type_id, 'old_name' => $names['old_name'], 'new_name' => $names['new_name']))); } // Has to be a configuration entity. @@ -782,7 +782,7 @@ protected function processExtension($type, $op, $name) { \Drupal::service('config.installer') ->setSyncing(TRUE) ->setSourceStorage($this->storageComparer->getSourceStorage()); - if ($type == 'module') { + if ($type === 'module') { $this->moduleHandler->$op(array($name), FALSE); // Installing a module can cause a kernel boot therefore reinject all the // services. @@ -793,12 +793,12 @@ protected function processExtension($type, $op, $name) { // the enabled modules. $this->moduleHandler->loadAll(); } - if ($type == 'theme') { + if ($type === 'theme') { // Theme disables possible remove default or admin themes therefore we // need to import this before doing any. If there are no disables and // the default or admin theme is change this will be picked up whilst // processing configuration. - if ($op == 'disable' && $this->processedSystemTheme === FALSE) { + if ($op === 'disable' && $this->processedSystemTheme === FALSE) { $this->importConfig(StorageInterface::DEFAULT_COLLECTION, 'update', 'system.theme'); $this->configManager->getConfigFactory()->reset('system.theme'); $this->processedSystemTheme = TRUE; @@ -832,7 +832,7 @@ protected function processExtension($type, $op, $name) { * TRUE is to continue processing, FALSE otherwise. */ protected function checkOp($collection, $op, $name) { - if ($op == 'rename') { + if ($op === 'rename') { $names = $this->storageComparer->extractRenameNames($name); $target_exists = $this->storageComparer->getTargetStorage($collection)->exists($names['new_name']); if ($target_exists) { @@ -910,7 +910,7 @@ protected function importConfig($collection, $op, $name) { else { $config = new Config($name, $this->storageComparer->getTargetStorage($collection), $this->eventDispatcher, $this->typedConfigManager); } - if ($op == 'delete') { + if ($op === 'delete') { $config->delete(); } else { @@ -947,7 +947,7 @@ protected function importConfig($collection, $op, $name) { */ protected function importInvokeOwner($collection, $op, $name) { // Renames are handled separately. - if ($op == 'rename') { + if ($op === 'rename') { return $this->importInvokeRename($collection, $name); } // Validate the configuration object name before importing it. diff --git a/core/lib/Drupal/Core/Config/ConfigInstaller.php b/core/lib/Drupal/Core/Config/ConfigInstaller.php index 6fe1afa..6604189 100644 --- a/core/lib/Drupal/Core/Config/ConfigInstaller.php +++ b/core/lib/Drupal/Core/Config/ConfigInstaller.php @@ -287,7 +287,7 @@ public function getSourceStorage($collection = StorageInterface::DEFAULT_COLLECT // config directories for default configuration. $this->sourceStorage = new ExtensionInstallStorage($this->activeStorage, InstallStorage::CONFIG_INSTALL_DIRECTORY, $collection); } - if ($this->sourceStorage->getCollectionName() != $collection) { + if ($this->sourceStorage->getCollectionName() !== $collection) { $this->sourceStorage = $this->sourceStorage->createCollection($collection); } return $this->sourceStorage; @@ -304,7 +304,7 @@ public function getSourceStorage($collection = StorageInterface::DEFAULT_COLLECT * The configuration storage that provides the default configuration. */ protected function getActiveStorage($collection = StorageInterface::DEFAULT_COLLECTION) { - if ($this->activeStorage->getCollectionName() != $collection) { + if ($this->activeStorage->getCollectionName() !== $collection) { $this->activeStorage = $this->activeStorage->createCollection($collection); } return $this->activeStorage; diff --git a/core/lib/Drupal/Core/Config/ConfigManager.php b/core/lib/Drupal/Core/Config/ConfigManager.php index 226178c..647e482 100644 --- a/core/lib/Drupal/Core/Config/ConfigManager.php +++ b/core/lib/Drupal/Core/Config/ConfigManager.php @@ -125,7 +125,7 @@ public function getConfigFactory() { * {@inheritdoc} */ public function diff(StorageInterface $source_storage, StorageInterface $target_storage, $source_name, $target_name = NULL, $collection = StorageInterface::DEFAULT_COLLECTION) { - if ($collection != StorageInterface::DEFAULT_COLLECTION) { + if ($collection !== StorageInterface::DEFAULT_COLLECTION) { $source_storage = $source_storage->createCollection($collection); $target_storage = $target_storage->createCollection($collection); } @@ -297,7 +297,7 @@ public function findConfigEntityDependentsAsEntities($type, array $names) { * {@inheritdoc} */ public function supportsConfigurationEntities($collection) { - return $collection == StorageInterface::DEFAULT_COLLECTION; + return $collection === StorageInterface::DEFAULT_COLLECTION; } /** diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php b/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php index 0603e4a..48dfa3c 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php @@ -79,11 +79,11 @@ public function getDependentEntities($type, $name) { $dependent_entities = array(); $entities_to_check = array(); - if ($type == 'entity') { + if ($type === 'entity') { $entities_to_check[] = $name; } else { - if ($type == 'module' || $type == 'theme') { + if ($type === 'module' || $type === 'theme') { $dependent_entities = array_filter($this->data, function (ConfigEntityDependency $entity) use ($type, $name) { return $entity->hasDependency($type, $name); }); diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index c329032..2e927aa 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -229,7 +229,7 @@ public function createDuplicate() { public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) { $a_weight = isset($a->weight) ? $a->weight : 0; $b_weight = isset($b->weight) ? $b->weight : 0; - if ($a_weight == $b_weight) { + if ($a_weight === $b_weight) { $a_label = $a->label(); $b_label = $b->label(); return strnatcasecmp($a_label, $b_label); @@ -251,7 +251,7 @@ public function toArray() { foreach (array_keys($definition['mapping']) as $name) { // Special handling for IDs so that computed compound IDs work. // @see \Drupal\Core\Entity\EntityDisplayBase::id() - if ($name == $id_key) { + if ($name === $id_key) { $properties[$name] = $this->id(); } else { @@ -290,7 +290,7 @@ public function preSave(EntityStorageInterface $storage) { ->condition('uuid', $this->uuid()) ->execute(); $matched_entity = reset($matching_entities); - if (!empty($matched_entity) && ($matched_entity != $this->id()) && $matched_entity != $this->getOriginalId()) { + if (!empty($matched_entity) && ($matched_entity !== $this->id()) && $matched_entity !== $this->getOriginalId()) { throw new ConfigDuplicateUUIDException(String::format('Attempt to save a configuration entity %id with UUID %uuid when this UUID is already used for %matched', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%matched' => $matched_entity))); } @@ -298,7 +298,7 @@ public function preSave(EntityStorageInterface $storage) { if (!$this->isNew()) { $original = $storage->loadUnchanged($this->getOriginalId()); // Ensure that the UUID cannot be changed for an existing entity. - if ($original && ($original->uuid() != $this->uuid())) { + if ($original && ($original->uuid() !== $this->uuid())) { throw new ConfigDuplicateUUIDException(String::format('Attempt to save a configuration entity %id with UUID %uuid when this entity already exists with UUID %original_uuid', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%original_uuid' => $original->uuid()))); } } @@ -365,7 +365,7 @@ protected function addDependency($type, $name) { // explicitly declare the dependency. An explicit dependency on Core, which // provides some plugins, is also not needed. // @see \Drupal\Core\Config\Entity\ConfigEntityDependency::hasDependency() - if ($type == 'module' && ($name == $this->getEntityType()->getProvider() || $name == 'core')) { + if ($type === 'module' && ($name === $this->getEntityType()->getProvider() || $name === 'core')) { return $this; } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php index c6618a6..6764ced 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php @@ -70,7 +70,7 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) { if (!$update) { $this->entityManager()->onBundleCreate($this->getEntityType()->getBundleOf(), $this->id()); } - elseif ($this->getOriginalId() != $this->id()) { + elseif ($this->getOriginalId() !== $this->id()) { $this->renameDisplays(); $this->entityManager()->onBundleRename($this->getEntityType()->getBundleOf(), $this->getOriginalId(), $this->id()); } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityDependency.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityDependency.php index 7da6ecb..6bdf191 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityDependency.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityDependency.php @@ -60,7 +60,7 @@ public function getDependencies($type) { if (isset($this->dependencies[$type])) { $dependencies = $this->dependencies[$type]; } - if ($type == 'module') { + if ($type === 'module') { $dependencies[] = substr($this->name, 0, strpos($this->name, '.')); } return $dependencies; @@ -80,7 +80,7 @@ public function getDependencies($type) { */ public function hasDependency($type, $name) { // A config entity is always dependent on its provider. - if ($type == 'module' && strpos($this->name, $name . '.') === 0) { + if ($type === 'module' && strpos($this->name, $name . '.') === 0) { return TRUE; } return isset($this->dependencies[$type]) && array_search($name, $this->dependencies[$type]) !== FALSE; diff --git a/core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php b/core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php index 65f167c..f74a25d 100644 --- a/core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php +++ b/core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php @@ -148,7 +148,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) { */ public function submitForm(array &$form, FormStateInterface $form_state) { foreach ($form_state->getValue($this->entitiesKey) as $id => $value) { - if (isset($this->entities[$id]) && $this->entities[$id]->get($this->weightKey) != $value['weight']) { + if (isset($this->entities[$id]) && $this->entities[$id]->get($this->weightKey) !== $value['weight']) { // Save entity only when its weight was changed. $this->entities[$id]->set($this->weightKey, $value['weight']); $this->entities[$id]->save(); diff --git a/core/lib/Drupal/Core/Config/Entity/Query/Condition.php b/core/lib/Drupal/Core/Config/Entity/Query/Condition.php index e6d2d52..9025d77 100644 --- a/core/lib/Drupal/Core/Config/Entity/Query/Condition.php +++ b/core/lib/Drupal/Core/Config/Entity/Query/Condition.php @@ -23,7 +23,7 @@ class Condition extends ConditionBase { * Implements \Drupal\Core\Entity\Query\ConditionInterface::compile(). */ public function compile($configs) { - $and = strtoupper($this->conjunction) == 'AND'; + $and = strtoupper($this->conjunction) === 'AND'; $single_conditions = array(); $condition_groups = array(); foreach ($this->conditions as $condition) { @@ -55,7 +55,7 @@ public function compile($configs) { // matter and this config object does not match. // If OR and it is matching, then the rest of conditions do not // matter and this config object does match. - if ($and != $match ) { + if ($and !== $match ) { break; } } @@ -167,7 +167,7 @@ protected function match(array $condition, $value) { switch ($condition['operator']) { case '=': - return $value == $condition['value']; + return $value === $condition['value']; case '>': return $value > $condition['value']; case '<': @@ -177,7 +177,7 @@ protected function match(array $condition, $value) { case '<=': return $value <= $condition['value']; case '<>': - return $value != $condition['value']; + return $value !== $condition['value']; case 'IN': return array_search($value, $condition['value']) !== FALSE; case 'NOT IN': diff --git a/core/lib/Drupal/Core/Config/Entity/Query/Query.php b/core/lib/Drupal/Core/Config/Entity/Query/Query.php index 7332680..9da5781 100644 --- a/core/lib/Drupal/Core/Config/Entity/Query/Query.php +++ b/core/lib/Drupal/Core/Config/Entity/Query/Query.php @@ -85,7 +85,7 @@ public function execute() { // Apply sort settings. foreach ($this->sort as $sort) { - $direction = $sort['direction'] == 'ASC' ? -1 : 1; + $direction = $sort['direction'] === 'ASC' ? -1 : 1; $field = $sort['field']; uasort($result, function($a, $b) use ($field, $direction) { return ($a[$field] <= $b[$field]) ? $direction : -$direction; @@ -122,14 +122,14 @@ protected function loadRecords() { // Search the conditions for restrictions on entity IDs. $ids = array(); - if ($this->condition->getConjunction() == 'AND') { + if ($this->condition->getConjunction() === 'AND') { foreach ($this->condition->conditions() as $condition) { - if (is_string($condition['field']) && $condition['field'] == $this->entityType->getKey('id')) { + if (is_string($condition['field']) && $condition['field'] === $this->entityType->getKey('id')) { $operator = $condition['operator'] ?: (is_array($condition['value']) ? 'IN' : '='); - if ($operator == '=') { + if ($operator === '=') { $ids = array($condition['value']); } - elseif ($operator == 'IN') { + elseif ($operator === 'IN') { $ids = $condition['value']; } // We stop at the first restricting condition on ID. In the (weird) diff --git a/core/lib/Drupal/Core/Config/FileStorage.php b/core/lib/Drupal/Core/Config/FileStorage.php index 88af39e..dd69bcd 100644 --- a/core/lib/Drupal/Core/Config/FileStorage.php +++ b/core/lib/Drupal/Core/Config/FileStorage.php @@ -71,7 +71,7 @@ protected function ensureStorage() { $dir = $this->getCollectionDirectory(); $success = file_prepare_directory($dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); // Only create .htaccess file in root directory. - if ($dir == $this->directory) { + if ($dir === $this->directory) { $success = $success && file_save_htaccess($this->directory, TRUE, TRUE); } if (!$success) { @@ -229,7 +229,7 @@ public function deleteAll($prefix = '') { $success = FALSE; } } - if ($success && $this->collection != StorageInterface::DEFAULT_COLLECTION) { + if ($success && $this->collection !== StorageInterface::DEFAULT_COLLECTION) { // Remove empty directories. if (!(new \FilesystemIterator($this->getCollectionDirectory()))->valid()) { drupal_rmdir($this->getCollectionDirectory()); @@ -326,7 +326,7 @@ protected function getAllCollectionNamesHelper($directory) { * The directory for the collection. */ protected function getCollectionDirectory() { - if ($this->collection == StorageInterface::DEFAULT_COLLECTION) { + if ($this->collection === StorageInterface::DEFAULT_COLLECTION) { $dir = $this->directory; } else { diff --git a/core/lib/Drupal/Core/Config/Schema/SchemaCheckTrait.php b/core/lib/Drupal/Core/Config/Schema/SchemaCheckTrait.php index 0836eaf..93cfe32 100644 --- a/core/lib/Drupal/Core/Config/Schema/SchemaCheckTrait.php +++ b/core/lib/Drupal/Core/Config/Schema/SchemaCheckTrait.php @@ -93,10 +93,10 @@ protected function checkValue($key, $value) { $type = gettype($value); if ($element instanceof PrimitiveInterface) { $success = - ($type == 'integer' && $element instanceof IntegerInterface) || - ($type == 'double' && $element instanceof FloatInterface) || - ($type == 'boolean' && $element instanceof BooleanInterface) || - ($type == 'string' && $element instanceof StringInterface) || + ($type === 'integer' && $element instanceof IntegerInterface) || + ($type === 'double' && $element instanceof FloatInterface) || + ($type === 'boolean' && $element instanceof BooleanInterface) || + ($type === 'string' && $element instanceof StringInterface) || // Null values are allowed for all types. ($value === NULL); } diff --git a/core/lib/Drupal/Core/Config/StorageComparer.php b/core/lib/Drupal/Core/Config/StorageComparer.php index 3072381..df7f347 100644 --- a/core/lib/Drupal/Core/Config/StorageComparer.php +++ b/core/lib/Drupal/Core/Config/StorageComparer.php @@ -119,7 +119,7 @@ public function __construct(StorageInterface $source_storage, StorageInterface $ */ public function getSourceStorage($collection = StorageInterface::DEFAULT_COLLECTION) { if (!isset($this->sourceStorages[$collection])) { - if ($collection == StorageInterface::DEFAULT_COLLECTION) { + if ($collection === StorageInterface::DEFAULT_COLLECTION) { $this->sourceStorages[$collection] = $this->sourceStorage; } else { @@ -134,7 +134,7 @@ public function getSourceStorage($collection = StorageInterface::DEFAULT_COLLECT */ public function getTargetStorage($collection = StorageInterface::DEFAULT_COLLECTION) { if (!isset($this->targetStorages[$collection])) { - if ($collection == StorageInterface::DEFAULT_COLLECTION) { + if ($collection === StorageInterface::DEFAULT_COLLECTION) { $this->targetStorages[$collection] = $this->targetStorage; } else { @@ -188,7 +188,7 @@ protected function addChangeList($collection, $op, array $changes, array $sort_o // Sort the changlist in the same order as the $sort_order array and // ensure the array is keyed from 0. $this->changelist[$collection][$op] = array_values(array_intersect($sort_order, $this->changelist[$collection][$op])); - if ($count != count($this->changelist[$collection][$op])) { + if ($count !== count($this->changelist[$collection][$op])) { throw new \InvalidArgumentException(String::format('Sorting the @op changelist should not change its length.', array('@op' => $op))); } } @@ -259,7 +259,7 @@ protected function addChangelistUpdate($collection) { $recreates = array(); foreach (array_intersect($this->sourceNames[$collection], $this->targetNames[$collection]) as $name) { if ($this->sourceData[$collection][$name] !== $this->targetData[$collection][$name]) { - if (isset($this->sourceData[$collection][$name]['uuid']) && $this->sourceData[$collection][$name]['uuid'] != $this->targetData[$collection][$name]['uuid']) { + if (isset($this->sourceData[$collection][$name]['uuid']) && $this->sourceData[$collection][$name]['uuid'] !== $this->targetData[$collection][$name]['uuid']) { // The entity has the same file as an existing entity but the UUIDs do // not match. This means that the entity has been recreated so config // synchronisation should do the same. diff --git a/core/lib/Drupal/Core/Config/TypedConfigManager.php b/core/lib/Drupal/Core/Config/TypedConfigManager.php index d775cc2..ef91316 100644 --- a/core/lib/Drupal/Core/Config/TypedConfigManager.php +++ b/core/lib/Drupal/Core/Config/TypedConfigManager.php @@ -180,7 +180,7 @@ public function clearCachedDefinitions() { protected function getFallbackName($name) { // Check for definition of $name with filesystem marker. $replaced = preg_replace('/([^\.:]+)([\.:\*]*)$/', '*\2', $name); - if ($replaced != $name) { + if ($replaced !== $name) { if (isset($this->definitions[$replaced])) { return $replaced; } @@ -190,7 +190,7 @@ protected function getFallbackName($name) { // breakpoint.breakpoint.*.* becomes // breakpoint.breakpoint.* $one_star = preg_replace('/\.([:\.\*]*)$/', '.*', $replaced); - if ($one_star != $replaced && isset($this->definitions[$one_star])) { + if ($one_star !== $replaced && isset($this->definitions[$one_star])) { return $one_star; } // Check for next level. For example, if breakpoint.breakpoint.* has @@ -267,7 +267,7 @@ protected function replaceVariable($value, $data) { } else { // Get nested value and continue processing. - if ($name == '%parent') { + if ($name === '%parent') { // Switch replacement values with values from the parent. $parent = $data['%parent']; $data = $parent->getValue(); @@ -290,7 +290,7 @@ protected function replaceVariable($value, $data) { public function hasConfigSchema($name) { // The schema system falls back on the Undefined class for unknown types. $definition = $this->getDefinition($name); - return is_array($definition) && ($definition['class'] != '\Drupal\Core\Config\Schema\Undefined'); + return is_array($definition) && ($definition['class'] !== '\Drupal\Core\Config\Schema\Undefined'); } } diff --git a/core/lib/Drupal/Core/Controller/ControllerResolver.php b/core/lib/Drupal/Core/Controller/ControllerResolver.php index d5193e7..2c05026 100644 --- a/core/lib/Drupal/Core/Controller/ControllerResolver.php +++ b/core/lib/Drupal/Core/Controller/ControllerResolver.php @@ -117,7 +117,7 @@ public function getController(Request $request) { protected function createController($controller) { // Controller in the service:method notation. $count = substr_count($controller, ':'); - if ($count == 1) { + if ($count === 1) { list($class_or_service, $method) = explode(':', $controller, 2); } // Controller in the class::method notation. @@ -146,7 +146,7 @@ protected function doGetArguments(Request $request, $controller, array $paramete elseif ($param->getClass() && $param->getClass()->isInstance($request)) { $arguments[] = $request; } - elseif ($param->getClass() && ($param->getClass()->name == 'Drupal\Core\Routing\RouteMatchInterface' || is_subclass_of($param->getClass()->name, 'Drupal\Core\Routing\RouteMatchInterface'))) { + elseif ($param->getClass() && ($param->getClass()->name === 'Drupal\Core\Routing\RouteMatchInterface' || is_subclass_of($param->getClass()->name, 'Drupal\Core\Routing\RouteMatchInterface'))) { $arguments[] = RouteMatch::createFromRequest($request); } elseif ($param->isDefaultValueAvailable()) { diff --git a/core/lib/Drupal/Core/Controller/DialogController.php b/core/lib/Drupal/Core/Controller/DialogController.php index 48279e5..6121c2c 100644 --- a/core/lib/Drupal/Core/Controller/DialogController.php +++ b/core/lib/Drupal/Core/Controller/DialogController.php @@ -113,7 +113,7 @@ public function dialog(Request $request, RouteMatchInterface $route_match, $_con // If the target was nominated in the incoming options, use that. $target = $options['target']; // Ensure the target includes the #. - if (substr($target, 0, 1) != '#') { + if (substr($target, 0, 1) !== '#') { $target = '#' . $target; } // This shouldn't be passed on to jQuery.ui.dialog. diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php index 7cbe167..6508b3c 100644 --- a/core/lib/Drupal/Core/Database/Connection.php +++ b/core/lib/Drupal/Core/Database/Connection.php @@ -272,7 +272,7 @@ protected function setPrefix($prefix) { $this->prefixSearch = array(); $this->prefixReplace = array(); foreach ($this->prefixes as $key => $val) { - if ($key != 'default') { + if ($key !== 'default') { $this->prefixSearch[] = '{' . $key . '}'; $this->prefixReplace[] = $val . $key; } @@ -562,7 +562,7 @@ public function query($query, array $args = array(), $options = array()) { $query_string = ($query instanceof StatementInterface) ? $stmt->getQueryString() : $query; $message = $e->getMessage() . ": " . $query_string . "; " . print_r($args, TRUE); // Match all SQLSTATE 23xxx errors. - if (substr($e->getCode(), -6, -3) == '23') { + if (substr($e->getCode(), -6, -3) === '23') { $exception = new IntegrityConstraintViolationException($message, $e->getCode(), $e); } else { @@ -918,7 +918,7 @@ public function rollback($savepoint_name = 'drupal_transaction') { // we need to throw an exception. $rolled_back_other_active_savepoints = FALSE; while ($savepoint = array_pop($this->transactionLayers)) { - if ($savepoint == $savepoint_name) { + if ($savepoint === $savepoint_name) { // If it is the last the transaction in the stack, then it is not a // savepoint, it is the transaction itself so we will need to roll back // the transaction rather than a savepoint. diff --git a/core/lib/Drupal/Core/Database/Driver/fake/ConditionResolver.php b/core/lib/Drupal/Core/Database/Driver/fake/ConditionResolver.php index ea69504..0d75523 100644 --- a/core/lib/Drupal/Core/Database/Driver/fake/ConditionResolver.php +++ b/core/lib/Drupal/Core/Database/Driver/fake/ConditionResolver.php @@ -25,14 +25,14 @@ class ConditionResolver { */ public static function matchGroup(DatabaseRowInterface $row, Condition $condition_group) { $conditions = $condition_group->conditions(); - $and = $conditions['#conjunction'] == 'AND'; + $and = $conditions['#conjunction'] === 'AND'; unset($conditions['#conjunction']); $match = TRUE; foreach ($conditions as $condition) { $match = $condition['field'] instanceof Condition ? static::matchGroup($row, $condition['field']) : static::matchSingle($row, $condition); // For AND, finish matching on the first fail. For OR, finish on first // success. - if ($and != $match) { + if ($and !== $match) { break; } } @@ -57,7 +57,7 @@ protected static function matchSingle(DatabaseRowInterface $row, array $conditio $row_value = $row->getValue($condition['field']); switch ($condition['operator']) { case '=': - return $row_value == $condition['value']; + return $row_value === $condition['value']; case '<=': return $row_value <= $condition['value']; @@ -66,10 +66,10 @@ protected static function matchSingle(DatabaseRowInterface $row, array $conditio return $row_value >= $condition['value']; case '!=': - return $row_value != $condition['value']; + return $row_value !== $condition['value']; case '<>': - return $row_value != $condition['value']; + return $row_value !== $condition['value']; case '<': return $row_value < $condition['value']; diff --git a/core/lib/Drupal/Core/Database/Driver/fake/FakeSelect.php b/core/lib/Drupal/Core/Database/Driver/fake/FakeSelect.php index 629bf1a..570b316 100644 --- a/core/lib/Drupal/Core/Database/Driver/fake/FakeSelect.php +++ b/core/lib/Drupal/Core/Database/Driver/fake/FakeSelect.php @@ -85,13 +85,13 @@ public function addJoin($type, $table, $alias = NULL, $condition = NULL, $argume } $alias = parent::addJoin($type, $table, $alias, $condition, $arguments); if (isset($type)) { - if ($type != 'INNER' && $type != 'LEFT') { + if ($type !== 'INNER' && $type !== 'LEFT') { throw new \Exception(sprintf('%s type not supported, only INNER and LEFT.', $type)); } if (!preg_match('/^(\w+\.)?(\w+)\s*=\s*(\w+)\.(\w+)$/', $condition, $matches)) { throw new \Exception('Only x.field1 = y.field2 conditions are supported.' . $condition); } - if (!$matches[1] && count($this->tables) == 2) { + if (!$matches[1] && count($this->tables) === 2) { $aliases = array_keys($this->tables); $matches[1] = $aliases[0]; } @@ -101,14 +101,14 @@ public function addJoin($type, $table, $alias = NULL, $condition = NULL, $argume if (!$matches[1]) { throw new \Exception('Only x.field1 = y.field2 conditions are supported.' . $condition); } - if ($matches[1] == $alias) { + if ($matches[1] === $alias) { $this->tables[$alias] += array( 'added_field' => $matches[2], 'original_table_alias' => $matches[3], 'original_field' => $matches[4], ); } - elseif ($matches[3] == $alias) { + elseif ($matches[3] === $alias) { $this->tables[$alias] += array( 'added_field' => $matches[4], 'original_table_alias' => $matches[1], @@ -130,7 +130,7 @@ public function execute() { // Single table count queries often do not contain fields which this class // does not support otherwise, so add a shortcut. - if (count($this->tables) == 1 && $this->countQuery) { + if (count($this->tables) === 1 && $this->countQuery) { $table_info = reset($this->tables); $where = $this->where; if (!empty($this->databaseContents[$table_info['table']])) { @@ -219,12 +219,12 @@ protected function executeJoins() { foreach ($results as $row) { $joined = FALSE; foreach ($this->databaseContents[$table_info['table']] as $candidate_row) { - if ($row[$table_info['original_table_alias']]['result'][$table_info['original_field']] == $candidate_row[$table_info['added_field']]) { + if ($row[$table_info['original_table_alias']]['result'][$table_info['original_field']] === $candidate_row[$table_info['added_field']]) { $joined = TRUE; $new_rows[] = $this->getNewRow($table_alias, $fields, $candidate_row, $row); } } - if (!$joined && $table_info['join type'] == 'LEFT') { + if (!$joined && $table_info['join type'] === 'LEFT') { // Because PHP doesn't scope their foreach statements, // $candidate_row may contain the last value assigned to it from the // previous statement. @@ -287,8 +287,8 @@ protected function sortCallback($a, $b) { foreach ($this->order as $field => $direction) { $a_value = $a_row->getValue($field); $b_value = $b_row->getValue($field); - if ($a_value != $b_value) { - return (($a_value < $b_value) == ($direction == 'ASC')) ? -1 : 1; + if ($a_value !== $b_value) { + return (($a_value < $b_value) === ($direction === 'ASC')) ? -1 : 1; } } return 0; diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php b/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php index 66cd34f..68a424b 100644 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php +++ b/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php @@ -252,7 +252,7 @@ protected function popCommittableTransactions() { // // To avoid exceptions when no actual error has occurred, we silently // succeed for MySQL error code 1305 ("SAVEPOINT does not exist"). - if ($e->getPrevious()->errorInfo[1] == '1305') { + if ($e->getPrevious()->errorInfo[1] === '1305') { // If one SAVEPOINT was released automatically, then all were. // Therefore, clean the transaction stack. $this->transactionLayers = array(); diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php b/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php index 32c217b..b9a88be 100644 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php +++ b/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php @@ -50,7 +50,7 @@ protected function connect() { } catch (\Exception $e) { // Attempt to create the database if it is not found. - if ($e->getCode() == Connection::DATABASE_NOT_FOUND) { + if ($e->getCode() === Connection::DATABASE_NOT_FOUND) { // Remove the database string from connection info. $connection_info = Database::getConnectionInfo(); $database = $connection_info['default']['database']; diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php index e033bd5..38d7228 100644 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php +++ b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php @@ -211,7 +211,7 @@ protected function processField($field) { $field['mysql_type'] = $map[$field['type'] . ':' . $field['size']]; } - if (isset($field['type']) && $field['type'] == 'serial') { + if (isset($field['type']) && $field['type'] === 'serial') { $field['auto_increment'] = TRUE; } @@ -474,7 +474,7 @@ public function changeField($table, $field, $field_new, $spec, $keys_new = array if (!$this->fieldExists($table, $field)) { throw new SchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.", array('@table' => $table, '@name' => $field))); } - if (($field != $field_new) && $this->fieldExists($table, $field_new)) { + if (($field !== $field_new) && $this->fieldExists($table, $field_new)) { throw new SchemaObjectExistsException(t("Cannot rename field @table.@name to @name_new: target field already exists.", array('@table' => $table, '@name' => $field, '@name_new' => $field_new))); } diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php index 7048e88..4452bb2 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php @@ -145,7 +145,7 @@ public function query($query, array $args = array(), $options = array()) { catch (\PDOException $e) { if ($options['throw_exception']) { // Match all SQLSTATE 23xxx errors. - if (substr($e->getCode(), -6, -3) == '23') { + if (substr($e->getCode(), -6, -3) === '23') { $e = new IntegrityConstraintViolationException($e->getMessage(), $e->getCode(), $e); } // Add additional debug information. diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php index fba74da..191d42d 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php @@ -55,7 +55,7 @@ public function execute() { // Force $last_insert_id to the specified value. This is only done // if $index is 0. - if ($index == 0) { + if ($index === 0) { $last_insert_id = $serial_value; } // Sequences must be greater than or equal to 1. @@ -93,7 +93,7 @@ public function execute() { $options['sequence_name'] = $table_information->sequences[0]; } // If there are no sequences then we can't get a last insert id. - elseif ($options['return'] == Database::RETURN_INSERT_ID) { + elseif ($options['return'] === Database::RETURN_INSERT_ID) { $options['return'] = Database::RETURN_NULL; } // Only use the returned last_insert_id if it is not already set. diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php index a5f0acd..6eada0f 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php @@ -67,7 +67,7 @@ protected function connect() { } catch (\Exception $e) { // Attempt to create the database if it is not found. - if ($e->getCode() == Connection::DATABASE_NOT_FOUND) { + if ($e->getCode() === Connection::DATABASE_NOT_FOUND) { // Remove the database string from connection info. $connection_info = Database::getConnectionInfo(); $database = $connection_info['default']['database']; @@ -114,7 +114,7 @@ protected function connect() { */ protected function checkEncoding() { try { - if (db_query('SHOW server_encoding')->fetchField() == 'UTF8') { + if (db_query('SHOW server_encoding')->fetchField() === 'UTF8') { $this->pass(t('Database is encoded in UTF-8')); } else { @@ -181,7 +181,7 @@ function checkBinaryOutput() { */ protected function checkBinaryOutputSuccess() { $bytea_output = db_query("SELECT 'encoding'::bytea AS output")->fetchField(); - return ($bytea_output == 'encoding'); + return ($bytea_output === 'encoding'); } /** diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php index 63349ad..b4a4e14 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php @@ -66,7 +66,7 @@ public function queryTableInformation($table) { ':default' => '%nextval%', )); foreach ($result as $column) { - if ($column->data_type == 'bytea') { + if ($column->data_type === 'bytea') { $table_information->blob_fields[$column->column_name] = TRUE; } elseif (preg_match("/nextval\('([^']+)'/", $column->column_default, $matches)) { @@ -183,7 +183,7 @@ protected function createTableSql($name, $table) { protected function createFieldSql($name, $spec) { $sql = $name . ' ' . $spec['pgsql_type']; - if (isset($spec['type']) && $spec['type'] == 'serial') { + if (isset($spec['type']) && $spec['type'] === 'serial') { unset($spec['not null']); } @@ -254,7 +254,7 @@ protected function processField($field) { break; } } - if (isset($field['type']) && $field['type'] == 'serial') { + if (isset($field['type']) && $field['type'] === 'serial') { unset($field['not null']); } return $field; @@ -533,7 +533,7 @@ public function changeField($table, $field, $field_new, $spec, $new_keys = array if (!$this->fieldExists($table, $field)) { throw new SchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.", array('@table' => $table, '@name' => $field))); } - if (($field != $field_new) && $this->fieldExists($table, $field_new)) { + if (($field !== $field_new) && $this->fieldExists($table, $field_new)) { throw new SchemaObjectExistsException(t("Cannot rename field @table.@name to @name_new: target field already exists.", array('@table' => $table, '@name' => $field, '@name_new' => $field_new))); } @@ -570,7 +570,7 @@ public function changeField($table, $field, $field_new, $spec, $new_keys = array // Usually, we do this via a simple typecast 'USING fieldname::type'. But // the typecast does not work for conversions to bytea. // @see http://www.postgresql.org/docs/current/static/datatype-binary.html - if ($spec['pgsql_type'] != 'bytea') { + if ($spec['pgsql_type'] !== 'bytea') { $this->connection->query('ALTER TABLE {' . $table . '} ALTER "' . $field . '" TYPE ' . $typecast . ' USING "' . $field . '"::' . $typecast); } else { @@ -607,7 +607,7 @@ public function changeField($table, $field, $field_new, $spec, $new_keys = array } // Rename the column if necessary. - if ($field != $field_new) { + if ($field !== $field_new) { $this->connection->query('ALTER TABLE {' . $table . '} RENAME "' . $field . '" TO "' . $field_new . '"'); } diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Select.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Select.php index 2a931ec..020408d 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Select.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Select.php @@ -67,14 +67,14 @@ public function orderBy($field, $direction = 'ASC') { foreach ($this->fields as $existing_field) { if (!empty($table)) { // If table alias is given, check if field and table exists. - if ($existing_field['table'] == $table && $existing_field['field'] == $table_field) { + if ($existing_field['table'] === $table && $existing_field['field'] === $table_field) { return $return; } } else { // If there is no table, simply check if the field exists as a field or // an aliased field. - if ($existing_field['alias'] == $field) { + if ($existing_field['alias'] === $field) { return $return; } } @@ -82,7 +82,7 @@ public function orderBy($field, $direction = 'ASC') { // Also check expression aliases. foreach ($this->expressions as $expression) { - if ($expression['alias'] == $field) { + if ($expression['alias'] === $field) { return $return; } } @@ -100,7 +100,7 @@ public function orderBy($field, $direction = 'ASC') { // If $field contains an characters which are not allowed in a field name // it is considered an expression, these can't be handeld automatically // either. - if ($this->connection->escapeField($field) != $field) { + if ($this->connection->escapeField($field) !== $field) { return $return; } diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php index 6cacf4e..0f1c1d8 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php @@ -151,7 +151,7 @@ public function __destruct() { $count = $this->query('SELECT COUNT(*) FROM ' . $prefix . '.sqlite_master WHERE type = :type AND name NOT LIKE :pattern', array(':type' => 'table', ':pattern' => 'sqlite_%'))->fetchField(); // We can prune the database file if it doesn't have any tables. - if ($count == 0) { + if ($count === 0) { // Detach the database. $this->query('DETACH DATABASE :schema', array(':schema' => $prefix)); // Destroy the database file. @@ -343,7 +343,7 @@ public function rollback($savepoint_name = 'drupal_transaction') { // We need to find the point we're rolling back to, all other savepoints // before are no longer needed. while ($savepoint = array_pop($this->transactionLayers)) { - if ($savepoint == $savepoint_name) { + if ($savepoint === $savepoint_name) { // Mark whole stack of transactions as needed roll back. $this->willRollback = TRUE; // If it is the last the transaction in the stack, then it is not a @@ -389,7 +389,7 @@ public function popTransaction($name) { // Commit everything since SAVEPOINT $name. while($savepoint = array_pop($this->transactionLayers)) { - if ($savepoint != $name) continue; + if ($savepoint !== $name) continue; // If there are no more layers left then we should commit or rollback. if (empty($this->transactionLayers)) { diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php index 97eab54..f54ac55 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php @@ -67,7 +67,7 @@ protected function connect() { } catch (\Exception $e) { // Attempt to create the database if it is not found. - if ($e->getCode() == Connection::DATABASE_NOT_FOUND) { + if ($e->getCode() === Connection::DATABASE_NOT_FOUND) { // Remove the database string from connection info. $connection_info = Database::getConnectionInfo(); $database = $connection_info['default']['database']; diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php index dc09d86..598664d 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php @@ -79,7 +79,7 @@ protected function createColumsSql($tablename, $schema) { // Add the SQL statement for each field. foreach ($schema['fields'] as $name => $field) { - if (isset($field['type']) && $field['type'] == 'serial') { + if (isset($field['type']) && $field['type'] === 'serial') { if (isset($schema['primary key']) && ($key = array_search($name, $schema['primary key'])) !== FALSE) { unset($schema['primary key'][$key]); } @@ -132,7 +132,7 @@ protected function processField($field) { $field['sqlite_type'] = $map[$field['type'] . ':' . $field['size']]; } - if (isset($field['type']) && $field['type'] == 'serial') { + if (isset($field['type']) && $field['type'] === 'serial') { $field['auto_increment'] = TRUE; } @@ -408,7 +408,7 @@ protected function alterTable($table, $old_schema, $new_schema, array $mapping = $old_count = $this->connection->query('SELECT COUNT(*) FROM {' . $table . '}')->fetchField(); $new_count = $this->connection->query('SELECT COUNT(*) FROM {' . $new_table . '}')->fetchField(); - if ($old_count == $new_count) { + if ($old_count === $new_count) { $this->dropTable($table); $this->renameTable($new_table, $table); } @@ -499,7 +499,7 @@ public function dropField($table, $field) { unset($new_schema['fields'][$field]); foreach ($new_schema['indexes'] as $index => $fields) { foreach ($fields as $key => $field_name) { - if ($field_name == $field) { + if ($field_name === $field) { unset($new_schema['indexes'][$index][$key]); } } @@ -516,7 +516,7 @@ public function changeField($table, $field, $field_new, $spec, $keys_new = array if (!$this->fieldExists($table, $field)) { throw new SchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.", array('@table' => $table, '@name' => $field))); } - if (($field != $field_new) && $this->fieldExists($table, $field_new)) { + if (($field !== $field_new) && $this->fieldExists($table, $field_new)) { throw new SchemaObjectExistsException(t("Cannot rename field @table.@name to @name_new: target field already exists.", array('@table' => $table, '@name' => $field, '@name_new' => $field_new))); } @@ -524,7 +524,7 @@ public function changeField($table, $field, $field_new, $spec, $keys_new = array $new_schema = $old_schema; // Map the old field to the new field. - if ($field != $field_new) { + if ($field !== $field_new) { $mapping[$field_new] = $field; } else { @@ -595,7 +595,7 @@ public function addIndex($table, $name, $fields) { public function indexExists($table, $name) { $info = $this->getPrefixInfo($table); - return $this->connection->query('PRAGMA ' . $info['schema'] . '.index_info(' . $info['table'] . '_' . $name . ')')->fetchField() != ''; + return $this->connection->query('PRAGMA ' . $info['schema'] . '.index_info(' . $info['table'] . '_' . $name . ')')->fetchField() !== ''; } public function dropIndex($table, $name) { diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php index 0be036d..c171593 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php @@ -72,7 +72,7 @@ protected function getStatement($query, &$args = array()) { // PDO allows placeholders to not be prefixed by a colon. See // http://marc.info/?l=php-internals&m=111234321827149&w=2 for // more. - if ($placeholder[0] != ':') { + if ($placeholder[0] !== ':') { $placeholder = ":$placeholder"; } // When replacing the placeholders, make sure we search for the diff --git a/core/lib/Drupal/Core/Database/Install/Tasks.php b/core/lib/Drupal/Core/Database/Install/Tasks.php index c4d88d2..c24f7f5 100644 --- a/core/lib/Drupal/Core/Database/Install/Tasks.php +++ b/core/lib/Drupal/Core/Database/Install/Tasks.php @@ -251,7 +251,7 @@ public function getFormOptions(array $database) { ); $profile = drupal_get_profile(); - $db_prefix = ($profile == 'standard') ? 'drupal_' : $profile . '_'; + $db_prefix = ($profile === 'standard') ? 'drupal_' : $profile . '_'; $form['advanced_options']['prefix'] = array( '#type' => 'textfield', '#title' => t('Table name prefix'), diff --git a/core/lib/Drupal/Core/Database/Query/Condition.php b/core/lib/Drupal/Core/Database/Query/Condition.php index 0f2e1a6..cbe19bf 100644 --- a/core/lib/Drupal/Core/Database/Query/Condition.php +++ b/core/lib/Drupal/Core/Database/Query/Condition.php @@ -158,7 +158,7 @@ public function arguments() { public function compile(Connection $connection, PlaceholderInterface $queryPlaceholder) { // Re-compile if this condition changed or if we are compiled against a // different query placeholder object. - if ($this->changed || isset($this->queryPlaceholderIdentifier) && ($this->queryPlaceholderIdentifier != $queryPlaceholder->uniqueIdentifier())) { + if ($this->changed || isset($this->queryPlaceholderIdentifier) && ($this->queryPlaceholderIdentifier !== $queryPlaceholder->uniqueIdentifier())) { $this->queryPlaceholderIdentifier = $queryPlaceholder->uniqueIdentifier(); $condition_fragments = array(); diff --git a/core/lib/Drupal/Core/Database/Query/Insert.php b/core/lib/Drupal/Core/Database/Query/Insert.php index 392c8c2..d0b12e5 100644 --- a/core/lib/Drupal/Core/Database/Query/Insert.php +++ b/core/lib/Drupal/Core/Database/Query/Insert.php @@ -288,7 +288,7 @@ public function preExecute() { } else { // Don't execute query without fields. - if (count($this->insertFields) + count($this->defaultFields) == 0) { + if (count($this->insertFields) + count($this->defaultFields) === 0) { throw new NoFieldsException('There are no fields available to insert with.'); } } diff --git a/core/lib/Drupal/Core/Database/Query/Select.php b/core/lib/Drupal/Core/Database/Query/Select.php index 3c687da..e0257ac 100644 --- a/core/lib/Drupal/Core/Database/Query/Select.php +++ b/core/lib/Drupal/Core/Database/Query/Select.php @@ -718,7 +718,7 @@ public function addJoin($type, $table, $alias = NULL, $condition = NULL, $argume */ public function orderBy($field, $direction = 'ASC') { // Only allow ASC and DESC, default to ASC. - $direction = strtoupper($direction) == 'DESC' ? 'DESC' : 'ASC'; + $direction = strtoupper($direction) === 'DESC' ? 'DESC' : 'ASC'; $this->order[$field] = $direction; return $this; } diff --git a/core/lib/Drupal/Core/Database/StatementPrefetch.php b/core/lib/Drupal/Core/Database/StatementPrefetch.php index c32d94a..4074e34 100644 --- a/core/lib/Drupal/Core/Database/StatementPrefetch.php +++ b/core/lib/Drupal/Core/Database/StatementPrefetch.php @@ -181,7 +181,7 @@ public function execute($args = array(), $options = array()) { $this->throwPDOException(); } - if ($options['return'] == Database::RETURN_AFFECTED) { + if ($options['return'] === Database::RETURN_AFFECTED) { $this->rowCount = $statement->rowCount(); } // Fetch all the data from the reply, in order to release any lock diff --git a/core/lib/Drupal/Core/Datetime/DateFormatter.php b/core/lib/Drupal/Core/Datetime/DateFormatter.php index b97f2e1..189c2b6 100644 --- a/core/lib/Drupal/Core/Datetime/DateFormatter.php +++ b/core/lib/Drupal/Core/Datetime/DateFormatter.php @@ -185,7 +185,7 @@ public function formatInterval($interval, $granularity = 2, $langcode = NULL) { $granularity--; } - if ($granularity == 0) { + if ($granularity === 0) { break; } } diff --git a/core/lib/Drupal/Core/Datetime/DateHelper.php b/core/lib/Drupal/Core/Datetime/DateHelper.php index 1357267..f8a8113 100644 --- a/core/lib/Drupal/Core/Datetime/DateHelper.php +++ b/core/lib/Drupal/Core/Datetime/DateHelper.php @@ -345,7 +345,7 @@ public static function days($required = FALSE, $month = NULL, $year = NULL) { */ public static function hours($format = 'H', $required = FALSE) { $hours = array(); - if ($format == 'h' || $format == 'g') { + if ($format === 'h' || $format === 'g') { $min = 1; $max = 12; } @@ -354,7 +354,7 @@ public static function hours($format = 'H', $required = FALSE) { $max = 23; } for ($i = $min; $i <= $max; $i++) { - $formatted = ($format == 'H' || $format == 'h') ? DrupalDateTime::datePad($i) : $i; + $formatted = ($format === 'H' || $format === 'h') ? DrupalDateTime::datePad($i) : $i; $hours[$i] = $formatted; } $none = array('' => ''); @@ -383,7 +383,7 @@ public static function minutes($format = 'i', $required = FALSE, $increment = 1) $increment = 1; } for ($i = 0; $i < 60; $i += $increment) { - $formatted = $format == 'i' ? DrupalDateTime::datePad($i) : $i; + $formatted = $format === 'i' ? DrupalDateTime::datePad($i) : $i; $minutes[$i] = $formatted; } $none = array('' => ''); @@ -412,7 +412,7 @@ public static function seconds($format = 's', $required = FALSE, $increment = 1) $increment = 1; } for ($i = 0; $i < 60; $i += $increment) { - $formatted = $format == 's' ? DrupalDateTime::datePad($i) : $i; + $formatted = $format === 's' ? DrupalDateTime::datePad($i) : $i; $seconds[$i] = $formatted; } $none = array('' => ''); diff --git a/core/lib/Drupal/Core/Datetime/Element/Datelist.php b/core/lib/Drupal/Core/Datetime/Element/Datelist.php index c330a4f..c945a72 100644 --- a/core/lib/Drupal/Core/Datetime/Element/Datelist.php +++ b/core/lib/Drupal/Core/Datetime/Element/Datelist.php @@ -56,10 +56,10 @@ public static function valueCallback(&$element, $input, FormStateInterface $form if ($input !== FALSE) { $return = $input; if (isset($input['ampm'])) { - if ($input['ampm'] == 'pm' && $input['hour'] < 12) { + if ($input['ampm'] === 'pm' && $input['hour'] < 12) { $input['hour'] += 12; } - elseif ($input['ampm'] == 'am' && $input['hour'] == 12) { + elseif ($input['ampm'] === 'am' && $input['hour'] === 12) { $input['hour'] -= 12; } unset($input['ampm']); @@ -252,7 +252,7 @@ public static function processDatelist(&$element, FormStateInterface $form_state $default = !empty($element['#value'][$part]) ? $element['#value'][$part] : ''; $value = $date instanceOf DrupalDateTime && !$date->hasErrors() ? $date->format($format) : $default; - if (!empty($value) && $part != 'ampm') { + if (!empty($value) && $part !== 'ampm') { $value = intval($value); } @@ -338,17 +338,17 @@ protected static function incrementRound(&$date, $increment) { $hour = intval(date_format($date, 'H')); $second = intval(round(intval(date_format($date, 's')) / $increment) * $increment); $minute = intval(date_format($date, 'i')); - if ($second == 60) { + if ($second === 60) { $minute += 1; $second = 0; } $minute = intval(round($minute / $increment) * $increment); - if ($minute == 60) { + if ($minute === 60) { $hour += 1; $minute = 0; } date_time_set($date, $hour, $minute, $second); - if ($hour == 24) { + if ($hour === 24) { $day += 1; $year = date_format($date, 'Y'); $month = date_format($date, 'n'); diff --git a/core/lib/Drupal/Core/Datetime/Element/Datetime.php b/core/lib/Drupal/Core/Datetime/Element/Datetime.php index df0847e..9fdea6b 100644 --- a/core/lib/Drupal/Core/Datetime/Element/Datetime.php +++ b/core/lib/Drupal/Core/Datetime/Element/Datetime.php @@ -74,14 +74,14 @@ public function getInfo() { */ public static function valueCallback(&$element, $input, FormStateInterface $form_state) { if ($input !== FALSE) { - $date_input = $element['#date_date_element'] != 'none' && !empty($input['date']) ? $input['date'] : ''; - $time_input = $element['#date_time_element'] != 'none' && !empty($input['time']) ? $input['time'] : ''; - $date_format = $element['#date_date_element'] != 'none' ? static::getHtml5DateFormat($element) : ''; - $time_format = $element['#date_time_element'] != 'none' ? static::getHtml5TimeFormat($element) : ''; + $date_input = $element['#date_date_element'] !== 'none' && !empty($input['date']) ? $input['date'] : ''; + $time_input = $element['#date_time_element'] !== 'none' && !empty($input['time']) ? $input['time'] : ''; + $date_format = $element['#date_date_element'] !== 'none' ? static::getHtml5DateFormat($element) : ''; + $time_format = $element['#date_time_element'] !== 'none' ? static::getHtml5TimeFormat($element) : ''; $timezone = !empty($element['#date_timezone']) ? $element['#date_timezone'] : NULL; // Seconds will be omitted in a post in case there's no entry. - if (!empty($time_input) && strlen($time_input) == 5) { + if (!empty($time_input) && strlen($time_input) === 5) { $time_input .= ':00'; } @@ -232,9 +232,9 @@ public static function processDatetime(&$element, FormStateInterface $form_state $element['#tree'] = TRUE; - if ($element['#date_date_element'] != 'none') { + if ($element['#date_date_element'] !== 'none') { - $date_format = $element['#date_date_element'] != 'none' ? static::getHtml5DateFormat($element) : ''; + $date_format = $element['#date_date_element'] !== 'none' ? static::getHtml5DateFormat($element) : ''; $date_value = !empty($date) ? $date->format($date_format, $format_settings) : $element['#value']['date']; // Creating format examples on every individual date item is messy, and @@ -279,9 +279,9 @@ public static function processDatetime(&$element, FormStateInterface $form_state } } - if ($element['#date_time_element'] != 'none') { + if ($element['#date_time_element'] !== 'none') { - $time_format = $element['#date_time_element'] != 'none' ? static::getHtml5TimeFormat($element) : ''; + $time_format = $element['#date_time_element'] !== 'none' ? static::getHtml5TimeFormat($element) : ''; $time_value = !empty($date) ? $date->format($time_format, $format_settings) : $element['#value']['time']; // Adds the HTML5 attributes. @@ -334,8 +334,8 @@ public static function validateDatetime(&$element, FormStateInterface $form_stat if ($input_exists) { $title = !empty($element['#title']) ? $element['#title'] : ''; - $date_format = $element['#date_date_element'] != 'none' ? static::getHtml5DateFormat($element) : ''; - $time_format = $element['#date_time_element'] != 'none' ? static::getHtml5TimeFormat($element) : ''; + $date_format = $element['#date_date_element'] !== 'none' ? static::getHtml5DateFormat($element) : ''; + $time_format = $element['#date_time_element'] !== 'none' ? static::getHtml5TimeFormat($element) : ''; $format = trim($date_format . ' ' . $time_format); // If there's empty input and the field is not required, set it to empty. diff --git a/core/lib/Drupal/Core/Datetime/Entity/DateFormat.php b/core/lib/Drupal/Core/Datetime/Entity/DateFormat.php index 2cc01e8..9a0ea31 100644 --- a/core/lib/Drupal/Core/Datetime/Entity/DateFormat.php +++ b/core/lib/Drupal/Core/Datetime/Entity/DateFormat.php @@ -83,7 +83,7 @@ public function isLocked() { * {@inheritdoc} */ public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) { - if ($a->isLocked() == $b->isLocked()) { + if ($a->isLocked() === $b->isLocked()) { $a_label = $a->label(); $b_label = $b->label(); return strnatcasecmp($a_label, $b_label); diff --git a/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php b/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php index 18927ca..5ad7b1c 100644 --- a/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php +++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php @@ -93,10 +93,10 @@ public function process(ContainerBuilder $container) { if ($param->getClass()) { $interface = $param->getClass(); } - if ($param->getName() == 'id') { + if ($param->getName() === 'id') { $id_pos = $pos; } - if ($param->getName() == 'priority') { + if ($param->getName() === 'priority') { $priority_pos = $pos; } } diff --git a/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php b/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php index ba29a66..84950a5 100644 --- a/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php +++ b/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php @@ -80,7 +80,7 @@ private function synchronize($id) { foreach ($definition->getMethodCalls() as $call) { foreach ($call[1] as $argument) { - if ($argument instanceof Reference && $id == (string) $argument) { + if ($argument instanceof Reference && $id === (string) $argument) { $this->callMethod($this->get($definitionId), $call); } } diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index c1069a1..21d5218 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -825,7 +825,7 @@ protected function initializeRequestGlobals(Request $request) { // Remove "core" directory if present, allowing install.php, update.php, // and others to auto-detect a base path. $core_position = strrpos($dir, '/core'); - if ($core_position !== FALSE && strlen($dir) - 5 == $core_position) { + if ($core_position !== FALSE && strlen($dir) - 5 === $core_position) { $base_path = substr($dir, 0, $core_position); } else { @@ -1036,7 +1036,7 @@ protected function compileContainer() { // language to not be English in the installer. $default_language_values = Language::$defaultValues; if ($system = $this->getConfigStorage()->read('system.site')) { - if ($default_language_values['id'] != $system['langcode']) { + if ($default_language_values['id'] !== $system['langcode']) { $default_language_values = array('id' => $system['langcode'], 'default' => TRUE); } } diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index e8df9c8..a48aab7 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -177,7 +177,7 @@ public function __construct(array $values, $entity_type, $bundle = FALSE, $trans $this->setDefaultLangcode(); if ($translations) { foreach ($translations as $langcode) { - if ($langcode != $this->defaultLangcode && $langcode != LanguageInterface::LANGCODE_DEFAULT) { + if ($langcode !== $this->defaultLangcode && $langcode !== LanguageInterface::LANGCODE_DEFAULT) { $this->translations[$langcode] = $data; } } @@ -426,7 +426,7 @@ public function get($property_name) { * @return \Drupal\Core\Field\FieldItemListInterface */ protected function getTranslatedField($name, $langcode) { - if ($this->translations[$this->activeLangcode]['status'] == static::TRANSLATION_REMOVED) { + if ($this->translations[$this->activeLangcode]['status'] === static::TRANSLATION_REMOVED) { $message = 'The entity object refers to a removed translation (@langcode) and cannot be manipulated.'; throw new \InvalidArgumentException(String::format($message, array('@langcode' => $this->activeLangcode))); } @@ -440,7 +440,7 @@ protected function getTranslatedField($name, $langcode) { // Non-translatable fields are always stored with // LanguageInterface::LANGCODE_DEFAULT as key. - $default = $langcode == LanguageInterface::LANGCODE_DEFAULT; + $default = $langcode === LanguageInterface::LANGCODE_DEFAULT; if (!$default && !$definition->isTranslatable()) { if (!isset($this->fields[$name][LanguageInterface::LANGCODE_DEFAULT])) { $this->fields[$name][LanguageInterface::LANGCODE_DEFAULT] = $this->getTranslatedField($name, LanguageInterface::LANGCODE_DEFAULT); @@ -474,7 +474,7 @@ protected function getTranslatedField($name, $langcode) { */ public function set($name, $value, $notify = TRUE) { // If default language or an entity key changes we need to react to that. - $notify = $name == 'langcode' || in_array($name, $this->getEntityType()->getKeys()); + $notify = $name === 'langcode' || in_array($name, $this->getEntityType()->getKeys()); $this->get($name)->setValue($value, $notify); } @@ -550,7 +550,7 @@ public function isEmpty() { * {@inheritdoc} */ public function access($operation, AccountInterface $account = NULL, $return_as_object = FALSE) { - if ($operation == 'create') { + if ($operation === 'create') { return $this->entityManager() ->getAccessControlHandler($this->entityTypeId) ->createAccess($this->bundle(), $account, [], $return_as_object); @@ -565,7 +565,7 @@ public function access($operation, AccountInterface $account = NULL, $return_as_ */ public function language() { $language = NULL; - if ($this->activeLangcode != LanguageInterface::LANGCODE_DEFAULT) { + if ($this->activeLangcode !== LanguageInterface::LANGCODE_DEFAULT) { if (!isset($this->languages[$this->activeLangcode])) { $this->languages += $this->languageManager()->getLanguages(LanguageInterface::STATE_ALL); } @@ -623,7 +623,7 @@ protected function updateFieldLangcodes($langcode) { * {@inheritdoc} */ public function onChange($name) { - if ($name == 'langcode') { + if ($name === 'langcode') { $this->setDefaultLangcode(); if (isset($this->translations[$this->defaultLangcode])) { $message = String::format('A translation already exists for the specified language (@langcode).', array('@langcode' => $this->defaultLangcode)); @@ -636,7 +636,7 @@ public function onChange($name) { // that check, as it ready only and must not change, unsetting it could // lead to recursions. if ($key = array_search($name, $this->getEntityType()->getKeys())) { - if (isset($this->entityKeys[$key]) && $key != 'bundle') { + if (isset($this->entityKeys[$key]) && $key !== 'bundle') { unset($this->entityKeys[$key]); } } @@ -650,13 +650,13 @@ public function onChange($name) { public function getTranslation($langcode) { // Ensure we always use the default language code when dealing with the // original entity language. - if ($langcode != LanguageInterface::LANGCODE_DEFAULT && $langcode == $this->defaultLangcode) { + if ($langcode !== LanguageInterface::LANGCODE_DEFAULT && $langcode === $this->defaultLangcode) { $langcode = LanguageInterface::LANGCODE_DEFAULT; } // Populate entity translation object cache so it will be available for all // translation objects. - if ($langcode == $this->activeLangcode) { + if ($langcode === $this->activeLangcode) { $this->translations[$langcode]['entity'] = $this; } @@ -740,7 +740,7 @@ protected function initializeTranslation($langcode) { * {@inheritdoc} */ public function hasTranslation($langcode) { - if ($langcode == $this->defaultLangcode) { + if ($langcode === $this->defaultLangcode) { $langcode = LanguageInterface::LANGCODE_DEFAULT; } return !empty($this->translations[$langcode]['status']); @@ -786,7 +786,7 @@ public function addTranslation($langcode, array $values = array()) { * {@inheritdoc} */ public function removeTranslation($langcode) { - if (isset($this->translations[$langcode]) && $langcode != LanguageInterface::LANGCODE_DEFAULT && $langcode != $this->defaultLangcode) { + if (isset($this->translations[$langcode]) && $langcode !== LanguageInterface::LANGCODE_DEFAULT && $langcode !== $this->defaultLangcode) { foreach ($this->getFieldDefinitions() as $name => $definition) { if ($definition->isTranslatable()) { unset($this->values[$name][$langcode]); @@ -805,7 +805,7 @@ public function removeTranslation($langcode) { * {@inheritdoc} */ public function initTranslation($langcode) { - if ($langcode != LanguageInterface::LANGCODE_DEFAULT && $langcode != $this->defaultLangcode) { + if ($langcode !== LanguageInterface::LANGCODE_DEFAULT && $langcode !== $this->defaultLangcode) { $this->translations[$langcode]['status'] = static::TRANSLATION_EXISTING; } } @@ -899,7 +899,7 @@ public function __set($name, $value) { } // The translations array is unset when cloning the entity object, we just // need to restore it. - elseif ($name == 'translations') { + elseif ($name === 'translations') { $this->translations = $value; } // Else directly read/write plain values. That way, fields not yet converted @@ -937,7 +937,7 @@ public function __unset($name) { * Overrides Entity::createDuplicate(). */ public function createDuplicate() { - if ($this->translations[$this->activeLangcode]['status'] == static::TRANSLATION_REMOVED) { + if ($this->translations[$this->activeLangcode]['status'] === static::TRANSLATION_REMOVED) { $message = 'The entity object refers to a removed translation (@langcode) and cannot be manipulated.'; throw new \InvalidArgumentException(String::format($message, array('@langcode' => $this->activeLangcode))); } diff --git a/core/lib/Drupal/Core/Entity/ContentEntityForm.php b/core/lib/Drupal/Core/Entity/ContentEntityForm.php index f1a10ca..ad8abbc 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityForm.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityForm.php @@ -100,7 +100,7 @@ public function getFormLangcode(FormStateInterface $form_state) { * {@inheritdoc} */ public function isDefaultFormLangcode(FormStateInterface $form_state) { - return $this->getFormLangcode($form_state) == $this->entity->getUntranslated()->language()->id; + return $this->getFormLangcode($form_state) === $this->entity->getUntranslated()->language()->id; } /** diff --git a/core/lib/Drupal/Core/Entity/Enhancer/EntityRouteEnhancer.php b/core/lib/Drupal/Core/Entity/Enhancer/EntityRouteEnhancer.php index 0bbbef8..e18f300 100644 --- a/core/lib/Drupal/Core/Entity/Enhancer/EntityRouteEnhancer.php +++ b/core/lib/Drupal/Core/Entity/Enhancer/EntityRouteEnhancer.php @@ -99,7 +99,7 @@ public function enhance(array $defaults, Request $request) { $type = $details['type']; // Type is of the form entity:{entity_type}. $parameter_entity_type = substr($type, strlen('entity:')); - if ($entity_type == $parameter_entity_type) { + if ($entity_type === $parameter_entity_type) { // We have the matching entity type. Set the '_entity' key // to point to this named placeholder. The entity in this // position is the one being rendered. diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 9424994..c810ea4 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -273,7 +273,7 @@ public function uriRelationships() { * {@inheritdoc} */ public function access($operation, AccountInterface $account = NULL, $return_as_object = FALSE) { - if ($operation == 'create') { + if ($operation === 'create') { return $this->entityManager() ->getAccessControlHandler($this->entityTypeId) ->createAccess($this->bundle(), $account, [], $return_as_object); diff --git a/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php b/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php index 6339c18..86f6fdf 100644 --- a/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php +++ b/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php @@ -68,7 +68,7 @@ public static function collectRenderDisplay(ContentEntityInterface $entity, $for // Check the existence and status of: // - the display for the form mode, // - the 'default' display. - if ($form_mode != 'default') { + if ($form_mode !== 'default') { $candidate_ids[] = $entity_type . '.' . $bundle . '.' . $form_mode; } $candidate_ids[] = $entity_type . '.' . $bundle . '.default'; diff --git a/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php b/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php index 57041e9..5ea4c8a 100644 --- a/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php +++ b/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php @@ -80,7 +80,7 @@ public static function collectRenderDisplays($entities, $view_mode) { // - the 'default' display. $candidate_ids = array(); foreach ($bundles as $bundle) { - if ($view_mode != 'default') { + if ($view_mode !== 'default') { $candidate_ids[$bundle][] = $entity_type . '.' . $bundle . '.' . $view_mode; } $candidate_ids[$bundle][] = $entity_type . '.' . $bundle . '.default'; diff --git a/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php b/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php index e655880..488f81d 100644 --- a/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php +++ b/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php @@ -133,7 +133,7 @@ protected function processAccessHookResults(array $access) { * The access result. */ protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { - if ($operation == 'delete' && $entity->isNew()) { + if ($operation === 'delete' && $entity->isNew()) { return AccessResult::forbidden()->cacheUntilEntityChanges($entity); } if ($admin_permission = $this->entityType->getAdminPermission()) { diff --git a/core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php b/core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php index 09fcf36..e4a579e 100644 --- a/core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php +++ b/core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php @@ -71,7 +71,7 @@ public function getChangeSummary() { foreach ($this->getChangeList() as $entity_type_id => $change_list) { // Process entity type definition changes. - if (!empty($change_list['entity_type']) && $change_list['entity_type'] == static::DEFINITION_UPDATED) { + if (!empty($change_list['entity_type']) && $change_list['entity_type'] === static::DEFINITION_UPDATED) { $entity_type = $this->entityManager->getDefinition($entity_type_id); $summary[$entity_type_id][] = $this->t('Update the %entity_type entity type.', array('%entity_type' => $entity_type->getLabel())); } @@ -108,7 +108,7 @@ public function getChangeSummary() { public function applyUpdates() { foreach ($this->getChangeList() as $entity_type_id => $change_list) { // Process entity type definition changes. - if (!empty($change_list['entity_type']) && $change_list['entity_type'] == static::DEFINITION_UPDATED) { + if (!empty($change_list['entity_type']) && $change_list['entity_type'] === static::DEFINITION_UPDATED) { $entity_type = $this->entityManager->getDefinition($entity_type_id); $original = $this->entityManager->getLastInstalledDefinition($entity_type_id); $this->entityManager->onEntityTypeUpdate($entity_type, $original); diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php index c3728fc..38de6c4 100644 --- a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php +++ b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php @@ -158,7 +158,7 @@ public function calculateDependencies() { $target_entity_type = \Drupal::entityManager()->getDefinition($this->targetEntityType); $bundle_entity_type_id = $target_entity_type->getBundleEntityType(); - if ($bundle_entity_type_id != 'bundle') { + if ($bundle_entity_type_id !== 'bundle') { // If the target entity type uses entities to manage its bundles then // depend on the bundle entity. $bundle_entity = \Drupal::entityManager()->getStorage($bundle_entity_type_id)->load($this->bundle); @@ -188,7 +188,7 @@ public function calculateDependencies() { } } // Depend on configured modes. - if ($this->mode != 'default') { + if ($this->mode !== 'default') { $mode_entity = \Drupal::entityManager()->getStorage('entity_' . $this->displayContext . '_mode')->load($target_entity_type->id() . '.' . $this->mode); $this->addDependency('entity', $mode_entity->getConfigDependencyName()); } @@ -232,13 +232,13 @@ public function toArray() { */ protected function init() { // Fill in defaults for extra fields. - $context = $this->displayContext == 'view' ? 'display' : $this->displayContext; + $context = $this->displayContext === 'view' ? 'display' : $this->displayContext; $extra_fields = \Drupal::entityManager()->getExtraFields($this->targetEntityType, $this->bundle); $extra_fields = isset($extra_fields[$context]) ? $extra_fields[$context] : array(); foreach ($extra_fields as $name => $definition) { if (!isset($this->content[$name]) && !isset($this->hidden[$name])) { // Extra fields are visible by default unless they explicitly say so. - if (!isset($definition['visible']) || $definition['visible'] == TRUE) { + if (!isset($definition['visible']) || $definition['visible'] === TRUE) { $this->content[$name] = array( 'weight' => $definition['weight'] ); @@ -255,7 +255,7 @@ protected function init() { if (!$definition->isDisplayConfigurable($this->displayContext) || (!isset($this->content[$name]) && !isset($this->hidden[$name]))) { $options = $definition->getDisplayOptions($this->displayContext); - if (!empty($options['type']) && $options['type'] == 'hidden') { + if (!empty($options['type']) && $options['type'] === 'hidden') { $this->hidden[$name] = TRUE; } elseif ($options) { diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php index 01fefaf..e3aecc4 100644 --- a/core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php +++ b/core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php @@ -68,7 +68,7 @@ public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) $a_type = $a->getTargetType(); $b_type = $b->getTargetType(); $type_order = strnatcasecmp($a_type, $b_type); - return $type_order != 0 ? $type_order : parent::sort($a, $b); + return $type_order !== 0 ? $type_order : parent::sort($a, $b); } /** diff --git a/core/lib/Drupal/Core/Entity/EntityForm.php b/core/lib/Drupal/Core/Entity/EntityForm.php index 6c1792e..18fb391 100644 --- a/core/lib/Drupal/Core/Entity/EntityForm.php +++ b/core/lib/Drupal/Core/Entity/EntityForm.php @@ -63,7 +63,7 @@ public function getBaseFormID() { // it is different from the actual form ID, since callbacks would be invoked // twice otherwise. $base_form_id = $this->entity->getEntityTypeId() . '_form'; - if ($base_form_id == $this->getFormId()) { + if ($base_form_id === $this->getFormId()) { $base_form_id = NULL; } return $base_form_id; @@ -77,7 +77,7 @@ public function getFormId() { if ($this->entity->getEntityType()->hasKey('bundle')) { $form_id = $this->entity->bundle() . '_' . $form_id; } - if ($this->operation != 'default') { + if ($this->operation !== 'default') { $form_id = $form_id . '_' . $this->operation; } return $form_id . '_form'; diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index a2aedf3..c28a248 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -391,7 +391,7 @@ protected function buildBaseFieldDefinitions($entity_type_id) { foreach ($module_definitions as $field_name => $definition) { // @todo Remove this check once FieldDefinitionInterface exposes a // proper provider setter. See https://drupal.org/node/2225961. - if ($definition instanceof BaseFieldDefinition && $definition->getProvider() == NULL) { + if ($definition instanceof BaseFieldDefinition && $definition->getProvider() === NULL) { $definition->setProvider($module); } $base_field_definitions[$field_name] = $definition; @@ -593,7 +593,7 @@ public function getFieldMapByFieldType($field_type) { $map = $this->getFieldMap(); foreach ($map as $entity_type => $fields) { foreach ($fields as $field_name => $field_info) { - if ($field_info['type'] == $field_type) { + if ($field_info['type'] === $field_type) { $filtered_map[$entity_type][$field_name] = $field_info; } } @@ -956,7 +956,7 @@ public function getEntityTypeFromClass($class_name) { $same_class = 0; $entity_type_id = NULL; foreach ($this->getDefinitions() as $entity_type) { - if ($entity_type->getOriginalClass() == $class_name || $entity_type->getClass() == $class_name) { + if ($entity_type->getOriginalClass() === $class_name || $entity_type->getClass() === $class_name) { $entity_type_id = $entity_type->id(); if ($same_class++) { throw new AmbiguousEntityClassException($class_name); diff --git a/core/lib/Drupal/Core/Entity/EntityResolverManager.php b/core/lib/Drupal/Core/Entity/EntityResolverManager.php index 94b9aea..ea4b11b 100644 --- a/core/lib/Drupal/Core/Entity/EntityResolverManager.php +++ b/core/lib/Drupal/Core/Entity/EntityResolverManager.php @@ -125,7 +125,7 @@ protected function setParametersFromReflection($controller, Route $route) { if (isset($entity_types[$parameter_name])) { $entity_type = $entity_types[$parameter_name]; $entity_class = $entity_type->getClass(); - if (($reflection_class = $parameter->getClass()) && (is_subclass_of($entity_class, $reflection_class->name) || $entity_class == $reflection_class->name)) { + if (($reflection_class = $parameter->getClass()) && (is_subclass_of($entity_class, $reflection_class->name) || $entity_class === $reflection_class->name)) { $parameter_definitions += array($parameter_name => array()); $parameter_definitions[$parameter_name] += array( 'type' => 'entity:' . $parameter_name, @@ -165,7 +165,7 @@ protected function setParametersFromEntityInformation(Route $route) { if (isset($info['type'])) { // The parameter types are in the form 'entity:$entity_type'. list(, $parameter_entity_type) = explode(':', $info['type'], 2); - if ($parameter_entity_type == $entity_type) { + if ($parameter_entity_type === $entity_type) { return; } } diff --git a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php index cd27e7d..c99882d 100644 --- a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php +++ b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php @@ -373,7 +373,7 @@ public function resetCache(array $entities = NULL) { * TRUE if the view mode can be cached, FALSE otherwise. */ protected function isViewModeCacheable($view_mode) { - if ($view_mode == 'default') { + if ($view_mode === 'default') { // The 'default' is not an actual view mode. return TRUE; } @@ -395,7 +395,7 @@ public function viewField(FieldItemListInterface $items, $display_options = arra $display = EntityViewDisplay::collectRenderDisplay($entity, $view_mode); // Hide all fields except the current one. foreach (array_keys($entity->getFieldDefinitions()) as $name) { - if ($name != $field_name) { + if ($name !== $field_name) { $display->removeComponent($name); } } diff --git a/core/lib/Drupal/Core/Entity/KeyValueStore/Query/Query.php b/core/lib/Drupal/Core/Entity/KeyValueStore/Query/Query.php index d35466f..1117983 100644 --- a/core/lib/Drupal/Core/Entity/KeyValueStore/Query/Query.php +++ b/core/lib/Drupal/Core/Entity/KeyValueStore/Query/Query.php @@ -53,7 +53,7 @@ public function execute() { // Apply sort settings. foreach ($this->sort as $sort) { - $direction = $sort['direction'] == 'ASC' ? -1 : 1; + $direction = $sort['direction'] === 'ASC' ? -1 : 1; $field = $sort['field']; uasort($result, function($a, $b) use ($field, $direction) { return ($a[$field] <= $b[$field]) ? $direction : -$direction; diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraintValidator.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraintValidator.php index 5e316ca..34ade61 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraintValidator.php +++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraintValidator.php @@ -22,7 +22,7 @@ class EntityTypeConstraintValidator extends ConstraintValidator { public function validate($entity, Constraint $constraint) { /** @var $entity \Drupal\Core\Entity\EntityInterface */ - if (!empty($entity) && $entity->getEntityTypeId() != $constraint->type) { + if (!empty($entity) && $entity->getEntityTypeId() !== $constraint->type) { $this->context->addViolation($constraint->message, array('%type' => $constraint->type)); } } diff --git a/core/lib/Drupal/Core/Entity/Query/QueryBase.php b/core/lib/Drupal/Core/Entity/Query/QueryBase.php index f5d36a1..71f9165 100644 --- a/core/lib/Drupal/Core/Entity/Query/QueryBase.php +++ b/core/lib/Drupal/Core/Entity/Query/QueryBase.php @@ -315,7 +315,7 @@ public function tableSort(&$headers) { $order = tablesort_get_order($headers); $direction = tablesort_get_sort($headers); foreach ($headers as $header) { - if (is_array($header) && ($header['data'] == $order['name'])) { + if (is_array($header) && ($header['data'] === $order['name'])) { $this->sort($header['specifier'], $direction, isset($header['langcode']) ? $header['langcode'] : NULL); } } diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php b/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php index 1067db3..610d6f7 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php @@ -44,7 +44,7 @@ public function compile($conditionContainer) { $sqlQuery->condition($sqlCondition); } else { - $type = strtoupper($this->conjunction) == 'OR' || $condition['operator'] == 'IS NULL' ? 'LEFT' : 'INNER'; + $type = strtoupper($this->conjunction) === 'OR' || $condition['operator'] === 'IS NULL' ? 'LEFT' : 'INNER'; $this->translateCondition($condition); $field = $tables->addField($condition['field'], $type, $condition['langcode']); $conditionContainer->condition($field, $condition['value'], $condition['operator']); diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php b/core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php index cd83691..baaaee1 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php @@ -36,7 +36,7 @@ public function compile($conditionContainer) { $sql_query->condition($sql_condition); } else { - $type = ((strtoupper($this->conjunction) == 'OR') || ($condition['operator'] == 'IS NULL')) ? 'LEFT' : 'INNER'; + $type = ((strtoupper($this->conjunction) === 'OR') || ($condition['operator'] === 'IS NULL')) ? 'LEFT' : 'INNER'; $this->translateCondition($condition); $field = $tables->addField($condition['field'], $type, $condition['langcode']); $function = $condition['function']; diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Query.php b/core/lib/Drupal/Core/Entity/Query/Sql/Query.php index cf8eb39..ee5dff6 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/Query.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/Query.php @@ -211,7 +211,7 @@ protected function addSort() { // Order based on the smallest element of each group if the // direction is ascending, or on the largest element of each group // if the direction is descending. - $function = $direction == 'ASC' ? 'min' : 'max'; + $function = $direction === 'ASC' ? 'min' : 'max'; $expression = "$function($sql_alias)"; $expression_alias = $this->sqlQuery->addExpression($expression); $this->sqlQuery->orderBy($expression_alias, $direction); diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php index b1c1a54..90102e1 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php @@ -89,7 +89,7 @@ public function addField($field, $type, $langcode) { for ($key = 0; $key <= $count; $key ++) { // If there is revision support and only the current revision is being // queried then use the revision id. Otherwise, the entity id will do. - if (($revision_key = $entity_type->getKey('revision')) && $age == EntityStorageInterface::FIELD_LOAD_CURRENT) { + if (($revision_key = $entity_type->getKey('revision')) && $age === EntityStorageInterface::FIELD_LOAD_CURRENT) { // This contains the relevant SQL field to be used when joining entity // tables. $entity_id_field = $revision_key; @@ -171,7 +171,7 @@ public function addField($field, $type, $langcode) { $next_index_prefix = $relationship_specifier; } // Check for a valid relationship. - if (isset($propertyDefinitions[$relationship_specifier]) && $field_storage->getPropertyDefinition('entity')->getDataType() == 'entity_reference' ) { + if (isset($propertyDefinitions[$relationship_specifier]) && $field_storage->getPropertyDefinition('entity')->getDataType() === 'entity_reference' ) { // If it is, use the entity type. $entity_type_id = $propertyDefinitions[$relationship_specifier]->getTargetDefinition()->getEntityTypeId(); $entity_type = $this->entityManager->getDefinition($entity_type_id); @@ -224,8 +224,8 @@ protected function ensureFieldTable($index_prefix, &$field, $type, $langcode, $b $entity_type_id = $this->sqlQuery->getMetaData('entity_type'); /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */ $table_mapping = $this->entityManager->getStorage($entity_type_id)->getTableMapping(); - $table = $this->sqlQuery->getMetaData('age') == EntityStorageInterface::FIELD_LOAD_CURRENT ? $table_mapping->getDedicatedDataTableName($field) : $table_mapping->getDedicatedRevisionTableName($field); - if ($field->getCardinality() != 1) { + $table = $this->sqlQuery->getMetaData('age') === EntityStorageInterface::FIELD_LOAD_CURRENT ? $table_mapping->getDedicatedDataTableName($field) : $table_mapping->getDedicatedRevisionTableName($field); + if ($field->getCardinality() !== 1) { $this->sqlQuery->addMetaData('simple_query', FALSE); } $this->fieldTables[$index_prefix . $field_name] = $this->addJoin($type, $table, "%alias.$field_id_field = $base_table.$entity_id_field", $langcode); diff --git a/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php b/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php index 4e1546b..8982c87 100644 --- a/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php +++ b/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php @@ -122,7 +122,7 @@ public function getFieldNames($table_name) { public function getColumnNames($field_name) { if (!isset($this->columnMapping[$field_name])) { $column_names = array_keys($this->fieldStorageDefinitions[$field_name]->getColumns()); - if (count($column_names) == 1) { + if (count($column_names) === 1) { $this->columnMapping[$field_name] = array(reset($column_names) => $field_name); } else { diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php index a46df01..8c38c92 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php @@ -599,7 +599,7 @@ protected function attachPropertyData(array &$entities) { foreach ($data_fields as $field_name) { $columns = $table_mapping->getColumnNames($field_name); // Do not key single-column fields by property name. - if (count($columns) == 1) { + if (count($columns) === 1) { $entities[$id][$field_name][$langcode] = $values[reset($columns)]; } else { @@ -916,7 +916,7 @@ protected function savePropertyData(EntityInterface $entity, $table_name = NULL) if (!isset($table_name)) { $table_name = $this->dataTable; } - $revision = $table_name != $this->dataTable; + $revision = $table_name !== $this->dataTable; if (!$revision || !$entity->isNewRevision()) { $key = $revision ? $this->revisionKey : $this->idKey; @@ -945,7 +945,7 @@ protected function savePropertyData(EntityInterface $entity, $table_name = NULL) * {@inheritdoc} */ protected function invokeHook($hook, EntityInterface $entity) { - if ($hook == 'presave') { + if ($hook === 'presave') { $this->invokeFieldMethod('preSave', $entity); } parent::invokeHook($hook, $entity); @@ -983,7 +983,7 @@ protected function mapToStorageRecord(ContentEntityInterface $entity, $table_nam // stored serialized. // @todo Give field types more control over this behavior in // https://drupal.org/node/2232427. - if (!$definition->getMainPropertyName() && count($columns) == 1) { + if (!$definition->getMainPropertyName() && count($columns) === 1) { $value = $entity->$field_name->first()->getValue(); } else { @@ -1025,11 +1025,11 @@ protected function isColumnSerial($table_name, $schema_name) { switch ($table_name) { case $this->baseTable: - $result = $schema_name == $this->idKey; + $result = $schema_name === $this->idKey; break; case $this->revisionTable: - $result = $schema_name == $this->revisionKey; + $result = $schema_name === $this->revisionKey; break; } @@ -1053,7 +1053,7 @@ protected function mapToDataStorageRecord(EntityInterface $entity, $table_name = } $record = $this->mapToStorageRecord($entity, $table_name); $record->langcode = $entity->language()->id; - $record->default_langcode = intval($record->langcode == $entity->getUntranslated()->language()->id); + $record->default_langcode = intval($record->langcode === $entity->getUntranslated()->language()->id); return $record; } @@ -1130,7 +1130,7 @@ protected function loadFieldItems(array $entities) { break; } } - $load_current = $age == static::FIELD_LOAD_CURRENT; + $load_current = $age === static::FIELD_LOAD_CURRENT; // Collect entities ids, bundles and languages. $bundles = array(); @@ -1178,12 +1178,12 @@ protected function loadFieldItems(array $entities) { // Ensure that records for non-translatable fields having invalid // languages are skipped. - if ($row->langcode == $default_langcodes[$row->entity_id] || $definitions[$bundle][$field_name]->isTranslatable()) { + if ($row->langcode === $default_langcodes[$row->entity_id] || $definitions[$bundle][$field_name]->isTranslatable()) { if (!isset($delta_count[$row->entity_id][$row->langcode])) { $delta_count[$row->entity_id][$row->langcode] = 0; } - if ($storage_definition->getCardinality() == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED || $delta_count[$row->entity_id][$row->langcode] < $storage_definition->getCardinality()) { + if ($storage_definition->getCardinality() === FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED || $delta_count[$row->entity_id][$row->langcode] < $storage_definition->getCardinality()) { $item = array(); // For each column declared by the field, populate the item from the // prefixed database column. @@ -1278,7 +1278,7 @@ protected function saveFieldItems(EntityInterface $entity, $update = TRUE) { $query->values($record); $revision_query->values($record); - if ($storage_definition->getCardinality() != FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED && ++$delta_count == $storage_definition->getCardinality()) { + if ($storage_definition->getCardinality() !== FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED && ++$delta_count === $storage_definition->getCardinality()) { break; } } @@ -1356,7 +1356,7 @@ protected function deleteFieldItemsRevision(EntityInterface $entity) { protected function usesDedicatedTable(FieldStorageDefinitionInterface $definition) { // Everything that is not provided by the entity type is stored in a // dedicated table. - return $definition->getProvider() != $this->entityType->getProvider() && !$definition->hasCustomStorage(); + return $definition->getProvider() !== $this->entityType->getProvider() && !$definition->hasCustomStorage(); } /** @@ -1458,7 +1458,7 @@ public function onFieldStorageDefinitionUpdate(FieldStorageDefinitionInterface $ } } else { - if ($storage_definition->getColumns() != $original->getColumns()) { + if ($storage_definition->getColumns() !== $original->getColumns()) { throw new FieldStorageDefinitionUpdateForbiddenException("The SQL storage cannot change the schema for an existing field with data."); } // There is data, so there are no column changes. Drop all the prior @@ -1472,7 +1472,7 @@ public function onFieldStorageDefinitionUpdate(FieldStorageDefinitionInterface $ $original_schema = $original->getSchema(); foreach ($original_schema['indexes'] as $name => $columns) { - if (!isset($schema['indexes'][$name]) || $columns != $schema['indexes'][$name]) { + if (!isset($schema['indexes'][$name]) || $columns !== $schema['indexes'][$name]) { $real_name = static::_fieldIndexName($storage_definition, $name); $this->database->schema()->dropIndex($table, $real_name); $this->database->schema()->dropIndex($revision_table, $real_name); @@ -1481,7 +1481,7 @@ public function onFieldStorageDefinitionUpdate(FieldStorageDefinitionInterface $ $table = $table_mapping->getDedicatedDataTableName($storage_definition); $revision_table = $table_mapping->getDedicatedRevisionTableName($storage_definition); foreach ($schema['indexes'] as $name => $columns) { - if (!isset($original_schema['indexes'][$name]) || $columns != $original_schema['indexes'][$name]) { + if (!isset($original_schema['indexes'][$name]) || $columns !== $original_schema['indexes'][$name]) { $real_name = static::_fieldIndexName($storage_definition, $name); $real_columns = array(); foreach ($columns as $column_name) { @@ -1738,7 +1738,7 @@ public static function _fieldSqlSchema(FieldStorageDefinitionInterface $storage_ // Define the entity ID schema based on the field definitions. $id_definition = $definitions[$entity_type->getKey('id')]; - if ($id_definition->getType() == 'integer') { + if ($id_definition->getType() === 'integer') { $id_schema = array( 'type' => 'int', 'unsigned' => TRUE, @@ -1758,7 +1758,7 @@ public static function _fieldSqlSchema(FieldStorageDefinitionInterface $storage_ // Define the revision ID schema, default to integer if there is no revision // ID. $revision_id_definition = $entity_type->hasKey('revision') ? $definitions[$entity_type->getKey('revision')] : NULL; - if (!$revision_id_definition || $revision_id_definition->getType() == 'integer') { + if (!$revision_id_definition || $revision_id_definition->getType() === 'integer') { $revision_id_schema = array( 'type' => 'int', 'unsigned' => TRUE, diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php index ca61630..18dc33b 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php @@ -80,10 +80,10 @@ public function __construct(EntityManagerInterface $entity_manager, ContentEntit */ public function requiresEntityStorageSchemaChanges(EntityTypeInterface $entity_type, EntityTypeInterface $original) { return - $entity_type->getStorageClass() != $original->getStorageClass() || - $entity_type->getKeys() != $original->getKeys() || - $entity_type->isRevisionable() != $original->isRevisionable() || - $entity_type->isTranslatable() != $original->isTranslatable(); + $entity_type->getStorageClass() !== $original->getStorageClass() || + $entity_type->getKeys() !== $original->getKeys() || + $entity_type->isRevisionable() !== $original->isRevisionable() || + $entity_type->isTranslatable() !== $original->isTranslatable(); } /** @@ -91,10 +91,10 @@ public function requiresEntityStorageSchemaChanges(EntityTypeInterface $entity_t */ public function requiresFieldStorageSchemaChanges(FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original) { return - $storage_definition->hasCustomStorage() != $original->hasCustomStorage() || - $storage_definition->getSchema() != $original->getSchema() || - $storage_definition->isRevisionable() != $original->isRevisionable() || - $storage_definition->isTranslatable() != $original->isTranslatable(); + $storage_definition->hasCustomStorage() !== $original->hasCustomStorage() || + $storage_definition->getSchema() !== $original->getSchema() || + $storage_definition->isRevisionable() !== $original->isRevisionable() || + $storage_definition->isTranslatable() !== $original->isTranslatable(); } /** @@ -106,7 +106,7 @@ public function requiresEntityDataMigration(EntityTypeInterface $entity_type, En // @todo Remove in https://www.drupal.org/node/2335879. $original_storage_class = $original->getStorageClass(); $null_storage_class = 'Drupal\Core\Entity\ContentEntityNullStorage'; - if ($original_storage_class == $null_storage_class || is_subclass_of($original_storage_class, $null_storage_class)) { + if ($original_storage_class === $null_storage_class || is_subclass_of($original_storage_class, $null_storage_class)) { return FALSE; } @@ -116,7 +116,7 @@ public function requiresEntityDataMigration(EntityTypeInterface $entity_type, En // table is empty. // @todo Ask the old storage handler rather than assuming: // https://www.drupal.org/node/2335879. - $entity_type->getStorageClass() != $original_storage_class || + $entity_type->getStorageClass() !== $original_storage_class || !$this->tableIsEmpty($this->storage->getBaseTable()); } @@ -242,7 +242,7 @@ public function onFieldStorageDefinitionDelete(FieldStorageDefinitionInterface $ * @throws \Drupal\Core\Entity\EntityStorageException */ protected function checkEntityType(EntityTypeInterface $entity_type) { - if ($entity_type->id() != $this->entityType->id()) { + if ($entity_type->id() !== $this->entityType->id()) { throw new EntityStorageException(String::format('Unsupported entity type @id', array('@id' => $entity_type->id()))); } return TRUE; @@ -288,7 +288,7 @@ protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $res // Add the schema for extra fields. foreach ($table_mapping->getExtraColumns($table_name) as $column_name) { - if ($column_name == 'default_langcode') { + if ($column_name === 'default_langcode') { $this->addDefaultLangcodeSchema($schema[$table_name]); } } @@ -738,7 +738,7 @@ protected function processRevisionDataTable(array &$schema) { * The entity key name. */ protected function processIdentifierSchema(&$schema, $key) { - if ($schema['fields'][$key]['type'] == 'int') { + if ($schema['fields'][$key]['type'] === 'int') { $schema['fields'][$key]['type'] = 'serial'; } unset($schema['fields'][$key]['default']); diff --git a/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php b/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php index c2268c8..9654cf2 100644 --- a/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php +++ b/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php @@ -37,7 +37,7 @@ public static function create($entity_type_id = NULL) { */ public static function createFromDataType($data_type) { $parts = explode(':', $data_type); - if ($parts[0] != 'entity') { + if ($parts[0] !== 'entity') { throw new \InvalidArgumentException('Data type must be in the form of "entity:ENTITY_TYPE:BUNDLE."'); } $definition = static::create(); @@ -66,7 +66,7 @@ public function getPropertyDefinitions() { // @todo: Add support for handling multiple bundles. // See https://drupal.org/node/2169813. $bundles = $this->getBundles(); - if (is_array($bundles) && count($bundles) == 1) { + if (is_array($bundles) && count($bundles) === 1) { $this->propertyDefinitions = \Drupal::entityManager()->getFieldDefinitions($entity_type_id, reset($bundles)); } else { @@ -90,7 +90,7 @@ public function getDataType() { if ($entity_type = $this->getEntityTypeId()) { $type .= ':' . $entity_type; // Append the bundle only if we know it for sure. - if (($bundles = $this->getBundles()) && count($bundles) == 1) { + if (($bundles = $this->getBundles()) && count($bundles) === 1) { $type .= ':' . reset($bundles); } } diff --git a/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php index 80f7796..b1fbcd3 100644 --- a/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php @@ -44,7 +44,7 @@ public function __construct(AuthenticationProviderInterface $authentication_prov * @see \Drupal\Core\Authentication\AuthenticationProviderInterface::cleanup() */ public function onRespond(FilterResponseEvent $event) { - if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) { + if ($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) { $request = $event->getRequest(); $this->authenticationProvider->cleanup($request); } @@ -56,7 +56,7 @@ public function onRespond(FilterResponseEvent $event) { * @param GetResponseForExceptionEvent $event */ public function onException(GetResponseForExceptionEvent $event) { - if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) { + if ($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) { $this->authenticationProvider->handleException($event); } } diff --git a/core/lib/Drupal/Core/EventSubscriber/CustomPageExceptionHtmlSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/CustomPageExceptionHtmlSubscriber.php index ae3d944..cff4fb4 100644 --- a/core/lib/Drupal/Core/EventSubscriber/CustomPageExceptionHtmlSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/CustomPageExceptionHtmlSubscriber.php @@ -121,7 +121,7 @@ protected function makeSubrequest(GetResponseForExceptionEvent $event, $path, $s // https://www.drupal.org/node/2293523. $system_path = $request->attributes->get('_system_path'); - if ($path && $path != $system_path) { + if ($path && $path !== $system_path) { // @todo The create() method expects a slash-prefixed path, but we store a // normal system path in the site_404 variable. if ($request->getMethod() === 'POST') { diff --git a/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php index b8dc94e..78dd23f 100644 --- a/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php @@ -109,7 +109,7 @@ protected function onHtml(GetResponseForExceptionEvent $event) { // If error type is 'User notice' then treat it as debug information // instead of an error message. // @see debug() - if ($error['%type'] == 'User notice') { + if ($error['%type'] === 'User notice') { $error['%type'] = 'Debug'; $class = 'status'; } @@ -117,7 +117,7 @@ protected function onHtml(GetResponseForExceptionEvent $event) { // Attempt to reduce verbosity by removing DRUPAL_ROOT from the file path // in the message. This does not happen for (false) security. $root_length = strlen(DRUPAL_ROOT); - if (substr($error['%file'], 0, $root_length) == DRUPAL_ROOT) { + if (substr($error['%file'], 0, $root_length) === DRUPAL_ROOT) { $error['%file'] = substr($error['%file'], $root_length + 1); } // Do not translate the string to avoid errors producing more errors. @@ -125,7 +125,7 @@ protected function onHtml(GetResponseForExceptionEvent $event) { $message = String::format('%type: !message in %function (line %line of %file).', $error); // Check if verbose error reporting is on. - if ($this->getErrorLevel() == ERROR_REPORTING_DISPLAY_VERBOSE) { + if ($this->getErrorLevel() === ERROR_REPORTING_DISPLAY_VERBOSE) { $backtrace_exception = $flatten_exception; while ($backtrace_exception->getPrevious()) { $backtrace_exception = $backtrace_exception->getPrevious(); diff --git a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php index 1dca1ee..2a6b2dc 100644 --- a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php @@ -133,7 +133,7 @@ public function onRespond(FilterResponseEvent $event) { */ protected function isCacheControlCustomized(Response $response) { $cache_control = $response->headers->get('Cache-Control'); - return $cache_control != 'no-cache' && $cache_control != 'private, must-revalidate'; + return $cache_control !== 'no-cache' && $cache_control !== 'private, must-revalidate'; } /** diff --git a/core/lib/Drupal/Core/EventSubscriber/HtmlViewSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/HtmlViewSubscriber.php index 6a854d6..90603f0 100644 --- a/core/lib/Drupal/Core/EventSubscriber/HtmlViewSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/HtmlViewSubscriber.php @@ -144,7 +144,7 @@ public static function convertCacheTagsToHeader(array $tags) { * Associative array of cache tags to flatten. */ public static function convertHeaderToCacheTags($tags_header) { - if (!is_string($tags_header) || strlen(trim($tags_header)) == 0) { + if (!is_string($tags_header) || strlen(trim($tags_header)) === 0) { return array(); } diff --git a/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php index f09e3e3..e300598 100644 --- a/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php @@ -106,7 +106,7 @@ public function onKernelRequestMaintenance(GetResponseEvent $event) { // Display a message if the logged in user has access to the site in // maintenance mode. However, suppress it on the maintenance mode // settings page. - if ($route_match->getRouteName() != 'system.site_maintenance_mode') { + if ($route_match->getRouteName() !== 'system.site_maintenance_mode') { if ($this->account->hasPermission('administer site configuration')) { $this->drupalSetMessage($this->t('Operating in maintenance mode. Go online.', array('@url' => $this->urlGenerator->generate('system.site_maintenance_mode'))), 'status', FALSE); } diff --git a/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php index 472b31c..2acd7d5 100644 --- a/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php @@ -52,7 +52,7 @@ public function onKernelRequestConvertPath(GetResponseEvent $event) { $request->attributes->set('_system_path', $path); // Set the cache key on the alias manager cache decorator. - if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) { + if ($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) { $this->aliasManager->setCacheKey($path); } } diff --git a/core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php index 84b94c9..b5879d5 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php @@ -87,7 +87,7 @@ public function onView(GetResponseForControllerResultEvent $event) { // is just an HTML string from a controller, so wrap that into a response // object. The subrequest's response will get dissected and placed into // the larger page as needed. - if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) { + if ($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) { $method = 'on' . $this->negotiation->getContentType($request); if (method_exists($this, $method)) { diff --git a/core/lib/Drupal/Core/Extension/Discovery/RecursiveExtensionFilterIterator.php b/core/lib/Drupal/Core/Extension/Discovery/RecursiveExtensionFilterIterator.php index d5da27c..082feb5 100644 --- a/core/lib/Drupal/Core/Extension/Discovery/RecursiveExtensionFilterIterator.php +++ b/core/lib/Drupal/Core/Extension/Discovery/RecursiveExtensionFilterIterator.php @@ -119,7 +119,7 @@ public function accept() { $name = $this->current()->getFilename(); // FilesystemIterator::SKIP_DOTS only skips '.' and '..', but not hidden // directories (like '.git'). - if ($name[0] == '.') { + if ($name[0] === '.') { return FALSE; } if ($this->isDir()) { @@ -128,7 +128,7 @@ public function accept() { // scanning the top-level/root directory; without this condition, we would // recurse into the whole filesystem tree that possibly contains other // files aside from Drupal. - if ($this->current()->getSubPath() == '') { + if ($this->current()->getSubPath() === '') { return in_array($name, $this->whitelist, TRUE); } // 'config' directories are special-cased here, because every extension @@ -139,15 +139,15 @@ public function accept() { // other config directories, and at the same time, still allow the core // config module to be overridden/replaced in a profile/site directory // (whereas it must be located directly in a modules directory). - if ($name == 'config') { - return substr($this->current()->getPathname(), -14) == 'modules/config'; + if ($name === 'config') { + return substr($this->current()->getPathname(), -14) === 'modules/config'; } // Accept the directory unless the name is blacklisted. return !in_array($name, $this->blacklist, TRUE); } else { // Only accept extension info files. - return substr($name, -9) == '.info.yml'; + return substr($name, -9) === '.info.yml'; } } diff --git a/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php index f51cbb3..33904ee 100644 --- a/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php +++ b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php @@ -222,7 +222,7 @@ public function setProfileDirectoriesFromSettings() { // which test runs are triggered). if (drupal_valid_test_ua() && !drupal_installation_attempted()) { $testing_profile = \Drupal::config('simpletest.settings')->get('parent_profile'); - if ($testing_profile && $testing_profile != $profile) { + if ($testing_profile && $testing_profile !== $profile) { $this->profileDirectories[] = drupal_get_path('profile', $testing_profile); } } @@ -305,8 +305,8 @@ protected function scanDirectory($dir, $include_tests) { // include_paths will not be consulted). Retain the relative originating // directory being scanned, so relative paths can be reconstructed below // (all paths are expected to be relative to DRUPAL_ROOT). - $dir_prefix = ($dir == '' ? '' : "$dir/"); - $absolute_dir = ($dir == '' ? DRUPAL_ROOT : DRUPAL_ROOT . "/$dir"); + $dir_prefix = ($dir === '' ? '' : "$dir/"); + $absolute_dir = ($dir === '' ? DRUPAL_ROOT : DRUPAL_ROOT . "/$dir"); if (!is_dir($absolute_dir)) { return $files; @@ -359,7 +359,7 @@ protected function scanDirectory($dir, $include_tests) { // Determine whether the extension has a main extension file. // For theme engines, the file extension is .engine. - if ($type == 'theme_engine') { + if ($type === 'theme_engine') { $filename = $name . '.engine'; } // For profiles/modules/themes, it is the extension type. diff --git a/core/lib/Drupal/Core/Extension/ModuleHandler.php b/core/lib/Drupal/Core/Extension/ModuleHandler.php index 0917e42..e5b274a 100644 --- a/core/lib/Drupal/Core/Extension/ModuleHandler.php +++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php @@ -250,7 +250,7 @@ public function loadAllIncludes($type, $name = NULL) { * {@inheritdoc} */ public function loadInclude($module, $type, $name = NULL) { - if ($type == 'install') { + if ($type === 'install') { // Make sure the installation API is available include_once DRUPAL_ROOT . '/core/includes/install.inc'; } @@ -559,7 +559,7 @@ protected function buildImplementationInfo($hook) { } // Allow modules to change the weight of specific implementations, but avoid // an infinite loop. - if ($hook != 'module_implements_alter') { + if ($hook !== 'module_implements_alter') { // Remember the original implementations, before they are modified with // hook_module_implements_alter(). $implementations_before = $implementations; @@ -655,18 +655,18 @@ public static function parseDependency($dependency) { foreach (explode(',', $parts[1]) as $version) { if (preg_match("/^\s*$p_op\s*$p_core$p_major\.$p_minor/", $version, $matches)) { $op = !empty($matches['operation']) ? $matches['operation'] : '='; - if ($matches['minor'] == 'x') { + if ($matches['minor'] === 'x') { // Drupal considers "2.x" to mean any version that begins with // "2" (e.g. 2.0, 2.9 are all "2.x"). PHP's version_compare(), // on the other hand, treats "x" as a string; so to // version_compare(), "2.x" is considered less than 2.0. This // means that >=2.x and <2.x are handled by version_compare() // as we need, but > and <= are not. - if ($op == '>' || $op == '<=') { + if ($op === '>' || $op === '<=') { $matches['major']++; } // Equivalence can be checked by adding two restrictions. - if ($op == '=' || $op == '==') { + if ($op === '=' || $op === '==') { $value['versions'][] = array('op' => '<', 'version' => ($matches['major'] + 1) . '.x'); $op = '>='; } @@ -850,7 +850,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) { // the necessary database tables. $entity_manager = \Drupal::entityManager(); foreach ($entity_manager->getDefinitions() as $entity_type) { - if ($entity_type->getProvider() == $module) { + if ($entity_type->getProvider() === $module) { $entity_manager->onEntityTypeCreate($entity_type); } } @@ -915,7 +915,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { } // Skip already uninstalled modules. - if (isset($installed_modules[$dependent]) && !isset($module_list[$dependent]) && $dependent != $profile) { + if (isset($installed_modules[$dependent]) && !isset($module_list[$dependent]) && $dependent !== $profile) { $module_list[$dependent] = $dependent; } } @@ -942,7 +942,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { // Clean up all entity bundles (including field instances) of every entity // type provided by the module that is being uninstalled. foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) { - if ($entity_type->getProvider() == $module) { + if ($entity_type->getProvider() === $module) { foreach (array_keys($entity_manager->getBundleInfo($entity_type_id)) as $bundle) { $entity_manager->onBundleDelete($entity_type_id, $bundle); } @@ -964,7 +964,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { // a SQL-based storage handler can use this as an opportunity to drop // the corresponding database tables. foreach ($entity_manager->getDefinitions() as $entity_type) { - if ($entity_type->getProvider() == $module) { + if ($entity_type->getProvider() === $module) { $entity_manager->onEntityTypeDelete($entity_type); } } @@ -1036,7 +1036,7 @@ protected function removeCacheBins($module) { // This works for the default cache registration and even in some // cases when a non-default "super" factory is used. That should // be extremely rare. - if ($tag['name'] == 'cache.bin' && isset($definition['factory_service']) && isset($definition['factory_method']) && !empty($definition['arguments'])) { + if ($tag['name'] === 'cache.bin' && isset($definition['factory_service']) && isset($definition['factory_method']) && !empty($definition['arguments'])) { try { $factory = \Drupal::service($definition['factory_service']); if (method_exists($factory, $definition['factory_method'])) { diff --git a/core/lib/Drupal/Core/Field/BaseFieldDefinition.php b/core/lib/Drupal/Core/Field/BaseFieldDefinition.php index 20b31ad..ab52a9d 100644 --- a/core/lib/Drupal/Core/Field/BaseFieldDefinition.php +++ b/core/lib/Drupal/Core/Field/BaseFieldDefinition.php @@ -270,7 +270,7 @@ public function setCardinality($cardinality) { */ public function isMultiple() { $cardinality = $this->getCardinality(); - return ($cardinality == static::CARDINALITY_UNLIMITED) || ($cardinality > 1); + return ($cardinality === static::CARDINALITY_UNLIMITED) || ($cardinality > 1); } /** diff --git a/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php b/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php index 75f679e..e66cb4e 100644 --- a/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php +++ b/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php @@ -169,10 +169,10 @@ public function preSave(EntityStorageInterface $storage) { } else { // Some updates are always disallowed. - if ($this->entity_type != $this->original->entity_type) { + if ($this->entity_type !== $this->original->entity_type) { throw new FieldException(String::format('Cannot change the entity_type of an existing base field bundle override (entity type:@entity_type, bundle:@bundle, field name: @field_name)', array('@field_name' => $this->field_name, '@entity_type' => $this->entity_type, '@bundle' => $this->original->bundle))); } - if ($this->bundle != $this->original->bundle && empty($this->bundleRenameAllowed)) { + if ($this->bundle !== $this->original->bundle && empty($this->bundleRenameAllowed)) { throw new FieldException(String::format('Cannot change the bundle of an existing base field bundle override (entity type:@entity_type, bundle:@bundle, field name: @field_name)', array('@field_name' => $this->field_name, '@entity_type' => $this->entity_type, '@bundle' => $this->original->bundle))); } $previous_definition = $this->original; diff --git a/core/lib/Drupal/Core/Field/FieldConfigBase.php b/core/lib/Drupal/Core/Field/FieldConfigBase.php index 17a4348..999a1d2 100644 --- a/core/lib/Drupal/Core/Field/FieldConfigBase.php +++ b/core/lib/Drupal/Core/Field/FieldConfigBase.php @@ -229,7 +229,7 @@ public function targetBundle() { public function calculateDependencies() { parent::calculateDependencies(); $bundle_entity_type_id = $this->entityManager()->getDefinition($this->entity_type)->getBundleEntityType(); - if ($bundle_entity_type_id != 'bundle') { + if ($bundle_entity_type_id !== 'bundle') { // If the target entity type uses entities to manage its bundles then // depend on the bundle entity. $bundle_entity = $this->entityManager()->getStorage($bundle_entity_type_id)->load($this->bundle); diff --git a/core/lib/Drupal/Core/Field/FieldItemList.php b/core/lib/Drupal/Core/Field/FieldItemList.php index 69daf67..b436621 100644 --- a/core/lib/Drupal/Core/Field/FieldItemList.php +++ b/core/lib/Drupal/Core/Field/FieldItemList.php @@ -300,7 +300,7 @@ public function getConstraints() { // form submitted values, this can only happen with 'multiple value' // widgets. $cardinality = $this->getFieldDefinition()->getFieldStorageDefinition()->getCardinality(); - if ($cardinality != FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) { + if ($cardinality !== FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) { $constraints[] = \Drupal::typedDataManager() ->getValidationConstraintManager() ->create('Count', array( diff --git a/core/lib/Drupal/Core/Field/FormatterPluginManager.php b/core/lib/Drupal/Core/Field/FormatterPluginManager.php index b7b297b..6546a66 100644 --- a/core/lib/Drupal/Core/Field/FormatterPluginManager.php +++ b/core/lib/Drupal/Core/Field/FormatterPluginManager.php @@ -104,7 +104,7 @@ public function getInstance(array $options) { $field_type = $field_definition->getType(); // Fill in default configuration if needed. - if (!isset($options['prepare']) || $options['prepare'] == TRUE) { + if (!isset($options['prepare']) || $options['prepare'] === TRUE) { $configuration = $this->prepareConfiguration($field_type, $configuration); } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php index d261ded..5a01bef 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php @@ -83,7 +83,7 @@ public function viewElements(FieldItemListInterface $items) { } // Output the raw value in a content attribute if the text of the HTML // element differs from the raw value (for example when a prefix is used). - if (!empty($item->_attributes) && $item->value != $output) { + if (!empty($item->_attributes) && $item->value !== $output) { $item->_attributes += array('content' => $item->value); } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php index 7727607..4a53a26 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php @@ -175,10 +175,10 @@ public function getValue($include_computed = FALSE) { */ public function onChange($property_name) { // Make sure that the target ID and the target property stay in sync. - if ($property_name == 'target_id') { + if ($property_name === 'target_id') { $this->properties['entity']->setValue($this->target_id, FALSE); } - elseif ($property_name == 'entity') { + elseif ($property_name === 'entity') { $this->set('target_id', $this->properties['entity']->getTargetIdentifier(), FALSE); } parent::onChange($property_name); diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php index 961eb67..c7d29c8 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php @@ -102,10 +102,10 @@ public function applyDefaultValue($notify = TRUE) { */ public function onChange($property_name) { // Make sure that the value and the language property stay in sync. - if ($property_name == 'value') { + if ($property_name === 'value') { $this->properties['language']->setValue($this->value, FALSE); } - elseif ($property_name == 'language') { + elseif ($property_name === 'language') { $this->set('value', $this->properties['language']->getTargetIdentifier(), FALSE); } parent::onChange($property_name); diff --git a/core/lib/Drupal/Core/Field/TypedData/FieldItemDataDefinition.php b/core/lib/Drupal/Core/Field/TypedData/FieldItemDataDefinition.php index 7b85e8c..f220479 100644 --- a/core/lib/Drupal/Core/Field/TypedData/FieldItemDataDefinition.php +++ b/core/lib/Drupal/Core/Field/TypedData/FieldItemDataDefinition.php @@ -34,7 +34,7 @@ class FieldItemDataDefinition extends DataDefinition implements ComplexDataDefin public static function createFromDataType($data_type) { // The data type of a field item is in the form of "field_item:$field_type". $parts = explode(':', $data_type, 2); - if ($parts[0] != 'field_item') { + if ($parts[0] !== 'field_item') { throw new \InvalidArgumentException('Data type must be in the form of "field_item:FIELD_TYPE".'); } diff --git a/core/lib/Drupal/Core/Field/WidgetBase.php b/core/lib/Drupal/Core/Field/WidgetBase.php index 1166340..a491f5c 100644 --- a/core/lib/Drupal/Core/Field/WidgetBase.php +++ b/core/lib/Drupal/Core/Field/WidgetBase.php @@ -209,7 +209,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f ); // Add 'add more' button, if not working with a programmed form. - if ($cardinality == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED && !$form_state->isProgrammed()) { + if ($cardinality === FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED && !$form_state->isProgrammed()) { $id_prefix = implode('-', array_merge($parents, array($field_name))); $wrapper_id = drupal_html_id($id_prefix . '-add-more-wrapper'); $elements['#prefix'] = '
'; @@ -283,7 +283,7 @@ public static function addMoreAjax(array $form, FormStateInterface $form_state) $element = NestedArray::getValue($form, array_slice($button['#array_parents'], 0, -1)); // Ensure the widget allows adding additional items. - if ($element['#cardinality'] != FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) { + if ($element['#cardinality'] !== FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) { return; } @@ -304,7 +304,7 @@ protected function formSingleElement(FieldItemListInterface $items, $delta, arra $element += array( '#field_parents' => $form['#parents'], // Only the first widget should be required. - '#required' => $delta == 0 && $this->fieldDefinition->isRequired(), + '#required' => $delta === 0 && $this->fieldDefinition->isRequired(), '#delta' => $delta, '#weight' => $delta, ); diff --git a/core/lib/Drupal/Core/FileTransfer/FTPExtension.php b/core/lib/Drupal/Core/FileTransfer/FTPExtension.php index f87293b..0e69f48 100644 --- a/core/lib/Drupal/Core/FileTransfer/FTPExtension.php +++ b/core/lib/Drupal/Core/FileTransfer/FTPExtension.php @@ -57,7 +57,7 @@ protected function removeDirectoryJailed($directory) { $list = array(); } foreach ($list as $item) { - if ($item == '.' || $item == '..') { + if ($item === '.' || $item === '..') { continue; } if (@ftp_chdir($this->connection, $item)) { @@ -100,7 +100,7 @@ public function isDirectory($path) { * Implements Drupal\Core\FileTransfer\FileTransfer::isFile(). */ public function isFile($path) { - return ftp_size($this->connection, $path) != -1; + return ftp_size($this->connection, $path) !== -1; } /** diff --git a/core/lib/Drupal/Core/FileTransfer/FileTransfer.php b/core/lib/Drupal/Core/FileTransfer/FileTransfer.php index d64624b..3c84549 100644 --- a/core/lib/Drupal/Core/FileTransfer/FileTransfer.php +++ b/core/lib/Drupal/Core/FileTransfer/FileTransfer.php @@ -96,12 +96,12 @@ static function factory($jail, $settings) { * The variable specified in $name. */ function __get($name) { - if ($name == 'connection') { + if ($name === 'connection') { $this->connect(); return $this->connection; } - if ($name == 'chroot') { + if ($name === 'chroot') { $this->setChroot(); return $this->chroot; } @@ -239,7 +239,7 @@ function __get($name) { $path = preg_replace('|^([a-z]{1}):|i', '', $path); // Strip out windows driveletter if its there. if ($strip_chroot) { if ($this->chroot && strpos($path, $this->chroot) === 0) { - $path = ($path == $this->chroot) ? '' : substr($path, strlen($this->chroot)); + $path = ($path === $this->chroot) ? '' : substr($path, strlen($this->chroot)); } } return $path; @@ -256,7 +256,7 @@ function __get($name) { */ function sanitizePath($path) { $path = str_replace('\\', '/', $path); // Windows path sanitization. - if (substr($path, -1) == '/') { + if (substr($path, -1) === '/') { $path = substr($path, 0, -1); } return $path; diff --git a/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php b/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php index e163c04..db9e9da 100644 --- a/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php +++ b/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php @@ -109,7 +109,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['connection_settings'][$name] += $this->addConnectionSettings($name); // Start non-JS code. - if ($form_state->getValue(array('connection_settings', 'authorize_filetransfer_default')) == $name) { + if ($form_state->getValue(array('connection_settings', 'authorize_filetransfer_default')) === $name) { // Change the submit button to the submit_process one. $form['submit_process']['#attributes'] = array(); @@ -140,7 +140,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { public function validateForm(array &$form, FormStateInterface $form_state) { // Only validate the form if we have collected all of the user input and are // ready to proceed with updating or installing. - if ($form_state->getTriggeringElement()['#name'] != 'process_updates') { + if ($form_state->getTriggeringElement()['#name'] !== 'process_updates') { return; } @@ -187,7 +187,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // property. Otherwise, we store everything that's not explicitly // marked with #filetransfer_save set to FALSE. if (!isset($form['connection_settings'][$filetransfer_backend][$key]['#filetransfer_save'])) { - if ($form['connection_settings'][$filetransfer_backend][$key]['#type'] != 'password') { + if ($form['connection_settings'][$filetransfer_backend][$key]['#type'] !== 'password') { $connection_settings[$key] = $value; } } @@ -292,7 +292,7 @@ protected function addConnectionSettings($backend) { protected function setConnectionSettingsDefaults(&$element, $key, array $defaults) { // If we're operating on a form element which isn't a details, and we have // a default setting saved, stash it in #default_value. - if (!empty($key) && isset($defaults[$key]) && isset($element['#type']) && $element['#type'] != 'details') { + if (!empty($key) && isset($defaults[$key]) && isset($element['#type']) && $element['#type'] !== 'details') { $element['#default_value'] = $defaults[$key]; } // Now, we walk through all the child elements, and recursively invoke diff --git a/core/lib/Drupal/Core/FileTransfer/SSH.php b/core/lib/Drupal/Core/FileTransfer/SSH.php index 91e6e5f..da76f80 100644 --- a/core/lib/Drupal/Core/FileTransfer/SSH.php +++ b/core/lib/Drupal/Core/FileTransfer/SSH.php @@ -102,7 +102,7 @@ public function isDirectory($path) { $directory = escapeshellarg($path); $cmd = "[ -d {$directory} ] && echo 'yes'"; if ($output = @ssh2_exec($this->connection, $cmd)) { - if ($output == 'yes') { + if ($output === 'yes') { return TRUE; } return FALSE; @@ -119,7 +119,7 @@ public function isFile($path) { $file = escapeshellarg($path); $cmd = "[ -f {$file} ] && echo 'yes'"; if ($output = @ssh2_exec($this->connection, $cmd)) { - if ($output == 'yes') { + if ($output === 'yes') { return TRUE; } return FALSE; diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php index 0564398..ebf618f 100644 --- a/core/lib/Drupal/Core/Form/FormBuilder.php +++ b/core/lib/Drupal/Core/Form/FormBuilder.php @@ -205,7 +205,7 @@ public function buildForm($form_id, FormStateInterface &$form_state) { // the form to proceed. In addition, if there is stored form_state data from // a previous step, we'll retrieve it so it can be passed on to the form // processing code. - $check_cache = isset($input['form_id']) && $input['form_id'] == $form_id && !empty($input['form_build_id']); + $check_cache = isset($input['form_id']) && $input['form_id'] === $form_id && !empty($input['form_build_id']); if ($check_cache) { $form = $this->getCache($input['form_build_id'], $form_state); } @@ -455,7 +455,7 @@ public function processForm($form_id, &$form, FormStateInterface &$form_state) { // exactly one submit button in the form, and if so, automatically use it // as triggering_element. $buttons = $form_state->getButtons(); - if ($form_state->isProgrammed() && !$form_state->getTriggeringElement() && count($buttons) == 1) { + if ($form_state->isProgrammed() && !$form_state->getTriggeringElement() && count($buttons) === 1) { $form_state->setTriggeringElement(reset($buttons)); } $this->formValidator->validateForm($form_id, $form, $form_state); @@ -680,7 +680,7 @@ public function doBuildForm($form_id, &$element, FormStateInterface &$form_state ); // Special handling if we're on the top level form element. - if (isset($element['#type']) && $element['#type'] == 'form') { + if (isset($element['#type']) && $element['#type'] === 'form') { if (!empty($element['#https']) && Settings::get('mixed_mode_sessions', FALSE) && !UrlHelper::isExternal($element['#action'])) { global $base_root; @@ -698,7 +698,7 @@ public function doBuildForm($form_id, &$element, FormStateInterface &$form_state // for programmed forms coming from self::submitForm(), or if the form_id // coming from the POST data is set and matches the current form_id. $input = $form_state->getUserInput(); - if ($form_state->isProgrammed() || (!empty($input) && (isset($input['form_id']) && ($input['form_id'] == $form_id)))) { + if ($form_state->isProgrammed() || (!empty($input) && (isset($input['form_id']) && ($input['form_id'] === $form_id)))) { $form_state->setProcessInput(); } else { @@ -798,13 +798,13 @@ public function doBuildForm($form_id, &$element, FormStateInterface &$form_state // If there is a file element, we need to flip a flag so later the // form encoding can be set. - if (isset($element['#type']) && $element['#type'] == 'file') { + if (isset($element['#type']) && $element['#type'] === 'file') { $form_state->setHasFileElement(); } // Final tasks for the form element after self::doBuildForm() has run for // all other elements. - if (isset($element['#type']) && $element['#type'] == 'form') { + if (isset($element['#type']) && $element['#type'] === 'form') { // If there is a file element, we set the form encoding. if ($form_state->hasFileElement()) { $element['#attributes']['enctype'] = 'multipart/form-data'; @@ -862,7 +862,7 @@ protected function handleInputElement($form_id, &$element, FormStateInterface &$ if (!isset($element['#name'])) { $name = array_shift($element['#parents']); $element['#name'] = $name; - if ($element['#type'] == 'file') { + if ($element['#type'] === 'file') { // To make it easier to handle files in file.inc, we place all // file fields in the 'files' array. Also, we do not support // nested file names. @@ -1018,8 +1018,8 @@ protected function handleInputElement($form_id, &$element, FormStateInterface &$ */ protected function elementTriggeredScriptedSubmission($element, FormStateInterface &$form_state) { $input = $form_state->getUserInput(); - if (!empty($input['_triggering_element_name']) && $element['#name'] == $input['_triggering_element_name']) { - if (empty($input['_triggering_element_value']) || $input['_triggering_element_value'] == $element['#value']) { + if (!empty($input['_triggering_element_name']) && $element['#name'] === $input['_triggering_element_name']) { + if (empty($input['_triggering_element_value']) || $input['_triggering_element_value'] === $element['#value']) { return TRUE; } } @@ -1053,7 +1053,7 @@ protected function buttonWasClicked($element, FormStateInterface &$form_state) { // long as $form['#name'] puts the value at the top level of the tree of // \Drupal::request()->request data. $input = $form_state->getUserInput(); - if (isset($input[$element['#name']]) && $input[$element['#name']] == $element['#value']) { + if (isset($input[$element['#name']]) && $input[$element['#name']] === $element['#value']) { return TRUE; } // When image buttons are clicked, browsers do NOT pass the form element diff --git a/core/lib/Drupal/Core/Form/FormState.php b/core/lib/Drupal/Core/Form/FormState.php index edef14e..601304a 100644 --- a/core/lib/Drupal/Core/Form/FormState.php +++ b/core/lib/Drupal/Core/Form/FormState.php @@ -1107,7 +1107,7 @@ public function isRebuilding() { * {@inheritdoc} */ public function prepareCallback($callback) { - if (is_string($callback) && substr($callback, 0, 2) == '::') { + if (is_string($callback) && substr($callback, 0, 2) === '::') { $callback = [$this->getFormObject(), substr($callback, 2)]; } return $callback; diff --git a/core/lib/Drupal/Core/Form/FormValidator.php b/core/lib/Drupal/Core/Form/FormValidator.php index ee2da65..0c004dc 100644 --- a/core/lib/Drupal/Core/Form/FormValidator.php +++ b/core/lib/Drupal/Core/Form/FormValidator.php @@ -239,7 +239,7 @@ protected function doValidateForm(&$elements, FormStateInterface &$form_state, $ // An unchecked checkbox has a #value of integer 0, different than // string '0', which could be a valid value. $is_empty_multiple = (!count($elements['#value'])); - $is_empty_string = (is_string($elements['#value']) && Unicode::strlen(trim($elements['#value'])) == 0); + $is_empty_string = (is_string($elements['#value']) && Unicode::strlen(trim($elements['#value'])) === 0); $is_empty_value = ($elements['#value'] === 0); if ($is_empty_multiple || $is_empty_string || $is_empty_value) { // Flag this element as #required_but_empty to allow #element_validate @@ -315,7 +315,7 @@ protected function performRequiredValidation(&$elements, FormStateInterface &$fo } if (isset($elements['#options']) && isset($elements['#value'])) { - if ($elements['#type'] == 'select') { + if ($elements['#type'] === 'select') { $options = OptGroup::flattenOptions($elements['#options']); } else { @@ -339,7 +339,7 @@ protected function performRequiredValidation(&$elements, FormStateInterface &$fo // is identical to the empty option's value, we reset the element's // value to NULL to trigger the regular #required handling below. // @see \Drupal\Core\Render\Element\Select::processSelect() - elseif ($elements['#type'] == 'select' && !$elements['#multiple'] && $elements['#required'] && !isset($elements['#default_value']) && $elements['#value'] === $elements['#empty_value']) { + elseif ($elements['#type'] === 'select' && !$elements['#multiple'] && $elements['#required'] && !isset($elements['#default_value']) && $elements['#value'] === $elements['#empty_value']) { $elements['#value'] = NULL; $form_state->setValueForElement($elements, NULL); } diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php index dc4abaa..f295112 100644 --- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php +++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php @@ -72,7 +72,7 @@ protected function getToolkitOperationPluginId($toolkit_id, $operation) { $definitions = array_filter($definitions, function ($definition) use ($toolkit_id, $operation) { - return $definition['toolkit'] == $toolkit_id && $definition['operation'] == $operation; + return $definition['toolkit'] === $toolkit_id && $definition['operation'] === $operation; } ); diff --git a/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php b/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php index 8cf65c9..9acf045 100644 --- a/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php @@ -75,7 +75,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#required' => TRUE, '#default_value' => $default_driver, ); - if (count($drivers) == 1) { + if (count($drivers) === 1) { $form['driver']['#disabled'] = TRUE; } diff --git a/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php index d989364..931a63f 100644 --- a/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php +++ b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php @@ -131,7 +131,7 @@ public function setIfNotExists($key, $value) { ->condition('collection', $this->collection) ->condition('name', $key) ->execute(); - return $result == Merge::STATUS_INSERT; + return $result === Merge::STATUS_INSERT; } /** diff --git a/core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php index 729ffd8..53abb8a 100644 --- a/core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php +++ b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php @@ -123,7 +123,7 @@ function setWithExpireIfNotExists($key, $value, $expire) { ->condition('collection', $this->collection) ->condition('name', $key) ->execute(); - return $result == Merge::STATUS_INSERT; + return $result === Merge::STATUS_INSERT; } /** diff --git a/core/lib/Drupal/Core/Language/Language.php b/core/lib/Drupal/Core/Language/Language.php index 0797003..b1b8497 100644 --- a/core/lib/Drupal/Core/Language/Language.php +++ b/core/lib/Drupal/Core/Language/Language.php @@ -159,7 +159,7 @@ public static function sort(&$languages) { uasort($languages, function (LanguageInterface $a, LanguageInterface $b) { $a_weight = $a->getWeight(); $b_weight = $b->getWeight(); - if ($a_weight == $b_weight) { + if ($a_weight === $b_weight) { return strnatcasecmp($a->getName(), $b->getName()); } return ($a_weight < $b_weight) ? -1 : 1; diff --git a/core/lib/Drupal/Core/Language/LanguageManager.php b/core/lib/Drupal/Core/Language/LanguageManager.php index 35a3fad..6d6100d 100644 --- a/core/lib/Drupal/Core/Language/LanguageManager.php +++ b/core/lib/Drupal/Core/Language/LanguageManager.php @@ -182,7 +182,7 @@ public function getLanguage($langcode) { * {@inheritdoc} */ public function getLanguageName($langcode) { - if ($langcode == LanguageInterface::LANGCODE_NOT_SPECIFIED) { + if ($langcode === LanguageInterface::LANGCODE_NOT_SPECIFIED) { return $this->t('None'); } if ($language = $this->getLanguage($langcode)) { diff --git a/core/lib/Drupal/Core/Mail/MailFormatHelper.php b/core/lib/Drupal/Core/Mail/MailFormatHelper.php index 3f180cc..646ece2 100644 --- a/core/lib/Drupal/Core/Mail/MailFormatHelper.php +++ b/core/lib/Drupal/Core/Mail/MailFormatHelper.php @@ -237,7 +237,7 @@ public static function htmlToText($string, $allowed_tags = NULL) { case '/h2': $casing = NULL; // Pad the line with dashes. - $output = static::htmlToTextPad($output, ($tagname == '/h1') ? '=' : '-', ' '); + $output = static::htmlToTextPad($output, ($tagname === '/h1') ? '=' : '-', ' '); array_pop($indent); // Ensure blank new-line. $chunk = ''; diff --git a/core/lib/Drupal/Core/Menu/ContextualLinkManager.php b/core/lib/Drupal/Core/Menu/ContextualLinkManager.php index b99c11f..977adfe 100644 --- a/core/lib/Drupal/Core/Menu/ContextualLinkManager.php +++ b/core/lib/Drupal/Core/Menu/ContextualLinkManager.php @@ -146,7 +146,7 @@ public function getContextualLinkPluginsByGroup($group_name) { else { $contextual_links = array(); foreach ($this->getDefinitions() as $plugin_id => $plugin_definition) { - if ($plugin_definition['group'] == $group_name) { + if ($plugin_definition['group'] === $group_name) { $contextual_links[$plugin_id] = $plugin_definition; } } diff --git a/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php b/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php index 0d6c995..1bfa2a9 100644 --- a/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php +++ b/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php @@ -151,7 +151,7 @@ public function checkNodeAccess(array $tree) { */ protected function collectNodeLinks(array &$tree, array &$node_links) { foreach ($tree as $key => &$element) { - if ($element->link->getRouteName() == 'entity.node.canonical') { + if ($element->link->getRouteName() === 'entity.node.canonical') { $nid = $element->link->getRouteParameters()['node']; $node_links[$nid][$key] = $element; // Deny access by default. checkNodeAccess() will re-add it. diff --git a/core/lib/Drupal/Core/Menu/LocalActionDefault.php b/core/lib/Drupal/Core/Menu/LocalActionDefault.php index d5b7229..71984bb 100644 --- a/core/lib/Drupal/Core/Menu/LocalActionDefault.php +++ b/core/lib/Drupal/Core/Menu/LocalActionDefault.php @@ -98,7 +98,7 @@ public function getRouteParameters(Request $request) { // attribute holds the original path strings keyed to the corresponding // slugs in the path patterns. For example, if the route's path pattern is // /filter/tips/{filter_format} and the path is /filter/tips/plain_text then - // $raw_variables->get('filter_format') == 'plain_text'. + // $raw_variables->get('filter_format') === 'plain_text'. $raw_variables = $request->attributes->get('_raw_variables'); foreach ($variables as $name) { diff --git a/core/lib/Drupal/Core/Menu/LocalTaskDefault.php b/core/lib/Drupal/Core/Menu/LocalTaskDefault.php index 45e0f772..3afe758 100644 --- a/core/lib/Drupal/Core/Menu/LocalTaskDefault.php +++ b/core/lib/Drupal/Core/Menu/LocalTaskDefault.php @@ -49,7 +49,7 @@ public function getRouteParameters(Request $request) { // attribute holds the original path strings keyed to the corresponding // slugs in the path patterns. For example, if the route's path pattern is // /filter/tips/{filter_format} and the path is /filter/tips/plain_text then - // $raw_variables->get('filter_format') == 'plain_text'. + // $raw_variables->get('filter_format') === 'plain_text'. $raw_variables = $request->attributes->get('_raw_variables'); @@ -96,7 +96,7 @@ public function getTitle(Request $request = NULL) { public function getWeight() { // By default the weight is 0, or -10 for the root tab. if (!isset($this->pluginDefinition['weight'])) { - if ($this->pluginDefinition['base_route'] == $this->pluginDefinition['route_name']) { + if ($this->pluginDefinition['base_route'] === $this->pluginDefinition['route_name']) { $this->pluginDefinition['weight'] = -10; } else { diff --git a/core/lib/Drupal/Core/Menu/LocalTaskManager.php b/core/lib/Drupal/Core/Menu/LocalTaskManager.php index 862050c..b18cd86 100644 --- a/core/lib/Drupal/Core/Menu/LocalTaskManager.php +++ b/core/lib/Drupal/Core/Menu/LocalTaskManager.php @@ -205,7 +205,7 @@ public function getLocalTasksForRoute($route_name) { // reference like &$task_info causes bugs. $definitions[$plugin_id]['base_route'] = $definitions[$task_info['parent_id']]['base_route']; } - if ($route_name == $task_info['route_name']) { + if ($route_name === $task_info['route_name']) { if(!empty($task_info['base_route'])) { $base_routes[$task_info['base_route']] = $task_info['base_route']; } @@ -254,7 +254,7 @@ public function getLocalTasksForRoute($route_name) { // path and sets the active class accordingly. But the parents of // the current local task may be on a different route in which // case we have to set the class manually by flagging it active. - if (!empty($parents[$plugin_id]) && $route_name != $task_info['route_name']) { + if (!empty($parents[$plugin_id]) && $route_name !== $task_info['route_name']) { $plugin->setActive(); } if (isset($children[$plugin_id])) { @@ -339,7 +339,7 @@ public function getTasksBuild($current_route_name) { protected function isRouteActive($current_route_name, $route_name, $route_parameters) { // Flag the list element as active if this tab's route and parameters match // the current request's route and route variables. - $active = $current_route_name == $route_name; + $active = $current_route_name === $route_name; $request = $this->requestStack->getCurrentRequest(); if ($active) { // The request is injected, so we need to verify that we have the expected @@ -348,7 +348,7 @@ protected function isRouteActive($current_route_name, $route_name, $route_parame // If we don't have _raw_variables, we assume the attributes are still the // original values. $raw_variables = $raw_variables_bag ? $raw_variables_bag->all() : $request->attributes->all(); - $active = array_intersect_assoc($route_parameters, $raw_variables) == $route_parameters; + $active = array_intersect_assoc($route_parameters, $raw_variables) === $route_parameters; } return $active; } diff --git a/core/lib/Drupal/Core/Menu/MenuActiveTrail.php b/core/lib/Drupal/Core/Menu/MenuActiveTrail.php index 4732c5c..d28387b 100644 --- a/core/lib/Drupal/Core/Menu/MenuActiveTrail.php +++ b/core/lib/Drupal/Core/Menu/MenuActiveTrail.php @@ -49,7 +49,7 @@ public function __construct(MenuLinkManagerInterface $menu_link_manager, RouteMa */ public function getActiveTrailIds($menu_name) { // Parent ids; used both as key and value to ensure uniqueness. - // We always want all the top-level links with parent == ''. + // We always want all the top-level links with parent === ''. $active_trail = array('' => ''); // If a link in the given menu indeed matches the route, then use it to diff --git a/core/lib/Drupal/Core/Menu/MenuParentFormSelector.php b/core/lib/Drupal/Core/Menu/MenuParentFormSelector.php index 93bfba1..4060b91 100644 --- a/core/lib/Drupal/Core/Menu/MenuParentFormSelector.php +++ b/core/lib/Drupal/Core/Menu/MenuParentFormSelector.php @@ -142,7 +142,7 @@ protected function parentSelectOptionsTreeWalk(array $tree, $menu_name, $indent, break; } $link = $element->link; - if ($link->getPluginId() != $exclude) { + if ($link->getPluginId() !== $exclude) { $title = $indent . ' ' . Unicode::truncate($link->getTitle(), 30, TRUE, FALSE); if (!$link->isEnabled()) { $title .= ' (' . $this->t('disabled') . ')'; diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php index 92775b4..a1d02a6 100644 --- a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php +++ b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php @@ -402,7 +402,7 @@ protected function preSave(array &$link, array $original) { // Need to check both parent and menu_name, since parent can be empty in any // menu. - if ($original && ($link['parent'] != $original['parent'] || $link['menu_name'] != $original['menu_name'])) { + if ($original && ($link['parent'] !== $original['parent'] || $link['menu_name'] !== $original['menu_name'])) { $this->moveChildren($fields, $original); } // We needed the mlid above, but not in the update query. @@ -569,7 +569,7 @@ protected function findParent($link, $original) { if (isset($link['parent'])) { $candidates[] = $link['parent']; } - elseif (!empty($original['parent']) && $link['menu_name'] == $original['menu_name']) { + elseif (!empty($original['parent']) && $link['menu_name'] === $original['menu_name']) { // Otherwise, fall back to the original parent. $candidates[] = $original['parent']; } @@ -1331,7 +1331,7 @@ protected static function schemaDefinition() { 'size' => 'small', ), 'depth' => array( - 'description' => 'The depth relative to the top level. A link with empty parent will have depth == 1.', + 'description' => 'The depth relative to the top level. A link with empty parent will have depth === 1.', 'type' => 'int', 'not null' => TRUE, 'default' => 0, diff --git a/core/lib/Drupal/Core/Page/HtmlFragment.php b/core/lib/Drupal/Core/Page/HtmlFragment.php index b3c55d8..3c62048 100644 --- a/core/lib/Drupal/Core/Page/HtmlFragment.php +++ b/core/lib/Drupal/Core/Page/HtmlFragment.php @@ -171,10 +171,10 @@ public function getContent() { * @return $this */ public function setTitle($title, $output = Title::CHECK_PLAIN) { - if ($output == Title::CHECK_PLAIN) { + if ($output === Title::CHECK_PLAIN) { $this->title = String::checkPlain($title); } - else if ($output == Title::FILTER_XSS_ADMIN) { + else if ($output === Title::FILTER_XSS_ADMIN) { $this->title = Xss::filterAdmin($title); } else { diff --git a/core/lib/Drupal/Core/ParamConverter/EntityConverter.php b/core/lib/Drupal/Core/ParamConverter/EntityConverter.php index 683fdff..f385d9e 100644 --- a/core/lib/Drupal/Core/ParamConverter/EntityConverter.php +++ b/core/lib/Drupal/Core/ParamConverter/EntityConverter.php @@ -76,7 +76,7 @@ public function applies($definition, $name, Route $route) { $entity_type_id = substr($definition['type'], strlen('entity:')); if (strpos($definition['type'], '{') !== FALSE) { $entity_type_slug = substr($entity_type_id, 1, -1); - return $name != $entity_type_slug && in_array($entity_type_slug, $route->compile()->getVariables(), TRUE); + return $name !== $entity_type_slug && in_array($entity_type_slug, $route->compile()->getVariables(), TRUE); } return $this->entityManager->hasDefinition($entity_type_id); } diff --git a/core/lib/Drupal/Core/Password/PhpassHashedPassword.php b/core/lib/Drupal/Core/Password/PhpassHashedPassword.php index b047a8d..e1bd241 100644 --- a/core/lib/Drupal/Core/Password/PhpassHashedPassword.php +++ b/core/lib/Drupal/Core/Password/PhpassHashedPassword.php @@ -161,19 +161,19 @@ protected function crypt($algo, $password, $setting) { // The first 12 characters of an existing hash are its setting string. $setting = substr($setting, 0, 12); - if ($setting[0] != '$' || $setting[2] != '$') { + if ($setting[0] !== '$' || $setting[2] !== '$') { return FALSE; } $count_log2 = $this->getCountLog2($setting); // Stored hashes may have been crypted with any iteration count. However we // do not allow applying the algorithm for unreasonable low and high values // respectively. - if ($count_log2 != $this->enforceLog2Boundaries($count_log2)) { + if ($count_log2 !== $this->enforceLog2Boundaries($count_log2)) { return FALSE; } $salt = substr($setting, 4, 8); // Hashes must have an 8 character salt. - if (strlen($salt) != 8) { + if (strlen($salt) !== 8) { return FALSE; } @@ -191,7 +191,7 @@ protected function crypt($algo, $password, $setting) { // $this->base64Encode() of a 16 byte MD5 will always be 22 characters. // $this->base64Encode() of a 64 byte sha512 will always be 86 characters. $expected = 12 + ceil((8 * $len) / 6); - return (strlen($output) == $expected) ? substr($output, 0, static::HASH_LENGTH) : FALSE; + return (strlen($output) === $expected) ? substr($output, 0, static::HASH_LENGTH) : FALSE; } /** @@ -216,7 +216,7 @@ public function hash($password) { * Implements Drupal\Core\Password\PasswordInterface::checkPassword(). */ public function check($password, UserInterface $account) { - if (substr($account->getPassword(), 0, 2) == 'U$') { + if (substr($account->getPassword(), 0, 2) === 'U$') { // This may be an updated password from user_update_7000(). Such hashes // have 'U' added as the first character and need an extra md5() (see the // Drupal 7 documentation). @@ -243,7 +243,7 @@ public function check($password, UserInterface $account) { default: return FALSE; } - return ($hash && $stored_hash == $hash); + return ($hash && $stored_hash === $hash); } /** @@ -251,7 +251,7 @@ public function check($password, UserInterface $account) { */ public function userNeedsNewHash(UserInterface $account) { // Check whether this was an updated password. - if ((substr($account->getPassword(), 0, 3) != '$S$') || (strlen($account->getPassword()) != static::HASH_LENGTH)) { + if ((substr($account->getPassword(), 0, 3) !== '$S$') || (strlen($account->getPassword()) !== static::HASH_LENGTH)) { return TRUE; } // Ensure that $count_log2 is within set bounds. diff --git a/core/lib/Drupal/Core/Path/AliasStorage.php b/core/lib/Drupal/Core/Path/AliasStorage.php index 153866b..9eb9241 100644 --- a/core/lib/Drupal/Core/Path/AliasStorage.php +++ b/core/lib/Drupal/Core/Path/AliasStorage.php @@ -127,7 +127,7 @@ public function preloadPathAlias($preloaded, $langcode) { // created alias for each source. Subsequent queries using fetchField() must // use pid DESC to have the same effect. For performance reasons, the query // builder is not used here. - if ($langcode == LanguageInterface::LANGCODE_NOT_SPECIFIED) { + if ($langcode === LanguageInterface::LANGCODE_NOT_SPECIFIED) { // Prevent PDO from complaining about a token the query doesn't use. unset($args[':langcode']); $result = $this->connection->query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND langcode = :langcode_undetermined ORDER BY pid ASC', $args); @@ -152,7 +152,7 @@ public function lookupPathAlias($path, $langcode) { ':langcode_undetermined' => LanguageInterface::LANGCODE_NOT_SPECIFIED, ); // See the queries above. - if ($langcode == LanguageInterface::LANGCODE_NOT_SPECIFIED) { + if ($langcode === LanguageInterface::LANGCODE_NOT_SPECIFIED) { unset($args[':langcode']); $alias = $this->connection->query("SELECT alias FROM {url_alias} WHERE source = :source AND langcode = :langcode_undetermined ORDER BY pid DESC", $args)->fetchField(); } @@ -176,7 +176,7 @@ public function lookupPathSource($path, $langcode) { ':langcode_undetermined' => LanguageInterface::LANGCODE_NOT_SPECIFIED, ); // See the queries above. - if ($langcode == LanguageInterface::LANGCODE_NOT_SPECIFIED) { + if ($langcode === LanguageInterface::LANGCODE_NOT_SPECIFIED) { unset($args[':langcode']); $result = $this->connection->query("SELECT source FROM {url_alias} WHERE alias = :alias AND langcode = :langcode_undetermined ORDER BY pid DESC", $args); } diff --git a/core/lib/Drupal/Core/Path/PathMatcher.php b/core/lib/Drupal/Core/Path/PathMatcher.php index 95c56dd..eef8f41 100644 --- a/core/lib/Drupal/Core/Path/PathMatcher.php +++ b/core/lib/Drupal/Core/Path/PathMatcher.php @@ -84,7 +84,7 @@ public function matchPath($path, $patterns) { public function isFrontPage() { // Cache the result as this is called often. if (!isset($this->isCurrentFrontPage)) { - $this->isCurrentFrontPage = (current_path() == $this->getFrontPagePath()); + $this->isCurrentFrontPage = (current_path() === $this->getFrontPagePath()); } return $this->isCurrentFrontPage; } diff --git a/core/lib/Drupal/Core/Path/PathValidator.php b/core/lib/Drupal/Core/Path/PathValidator.php index b6c3a5a..e331629 100644 --- a/core/lib/Drupal/Core/Path/PathValidator.php +++ b/core/lib/Drupal/Core/Path/PathValidator.php @@ -92,7 +92,7 @@ public function getUrlIfValid($path) { $options['fragment'] = $parsed_url['fragment']; } - if ($parsed_url['path'] == '') { + if ($parsed_url['path'] === '') { return new Url('', [], $options); } elseif (UrlHelper::isExternal($path) && UrlHelper::isValid($path)) { diff --git a/core/lib/Drupal/Core/PathProcessor/PathProcessorFront.php b/core/lib/Drupal/Core/PathProcessor/PathProcessorFront.php index 11c66fd..b377571 100644 --- a/core/lib/Drupal/Core/PathProcessor/PathProcessorFront.php +++ b/core/lib/Drupal/Core/PathProcessor/PathProcessorFront.php @@ -50,7 +50,7 @@ public function processInbound($path, Request $request) { */ public function processOutbound($path, &$options = array(), Request $request = NULL) { // The special path '' links to the default front page. - if ($path == '') { + if ($path === '') { $path = ''; } return $path; diff --git a/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php b/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php index a5a5a3a..a4c620a 100644 --- a/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php +++ b/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php @@ -53,13 +53,13 @@ public function getMatchingContexts(array $contexts, ContextDefinitionInterface // If the data types do not match, this context is invalid unless the // expected data type is any, which means all data types are supported. - if ($definition->getDataType() != 'any' && $definition->getDataType() != $context_definition->getDataType()) { + if ($definition->getDataType() !== 'any' && $definition->getDataType() !== $context_definition->getDataType()) { return FALSE; } // If any constraint does not match, this context is invalid. foreach ($definition->getConstraints() as $constraint_name => $constraint) { - if ($context_definition->getConstraint($constraint_name) != $constraint) { + if ($context_definition->getConstraint($constraint_name) !== $constraint) { return FALSE; } } diff --git a/core/lib/Drupal/Core/Queue/Memory.php b/core/lib/Drupal/Core/Queue/Memory.php index 0dff021..09397cf 100644 --- a/core/lib/Drupal/Core/Queue/Memory.php +++ b/core/lib/Drupal/Core/Queue/Memory.php @@ -67,7 +67,7 @@ public function numberOfItems() { */ public function claimItem($lease_time = 30) { foreach ($this->queue as $key => $item) { - if ($item->expire == 0) { + if ($item->expire === 0) { $item->expire = time() + $lease_time; $this->queue[$key] = $item; return $item; @@ -87,7 +87,7 @@ public function deleteItem($item) { * Implements Drupal\Core\Queue\QueueInterface::releaseItem(). */ public function releaseItem($item) { - if (isset($this->queue[$item->item_id]) && $this->queue[$item->item_id]->expire != 0) { + if (isset($this->queue[$item->item_id]) && $this->queue[$item->item_id]->expire !== 0) { $this->queue[$item->item_id]->expire = 0; return TRUE; } diff --git a/core/lib/Drupal/Core/Render/Element.php b/core/lib/Drupal/Core/Render/Element.php index eed5c30..242d804 100644 --- a/core/lib/Drupal/Core/Render/Element.php +++ b/core/lib/Drupal/Core/Render/Element.php @@ -28,7 +28,7 @@ class Element { * TRUE of the key is a property, FALSE otherwise. */ public static function property($key) { - return $key[0] == '#'; + return $key[0] === '#'; } /** @@ -54,7 +54,7 @@ public static function properties(array $element) { * TRUE if the element is a child, FALSE otherwise. */ public static function child($key) { - return !isset($key[0]) || $key[0] != '#'; + return !isset($key[0]) || $key[0] !== '#'; } /** diff --git a/core/lib/Drupal/Core/Render/Element/Checkboxes.php b/core/lib/Drupal/Core/Render/Element/Checkboxes.php index 303b6e3..28f85de 100644 --- a/core/lib/Drupal/Core/Render/Element/Checkboxes.php +++ b/core/lib/Drupal/Core/Render/Element/Checkboxes.php @@ -49,7 +49,7 @@ public static function processCheckboxes(&$element, FormStateInterface $form_sta $value = is_array($element['#value']) ? $element['#value'] : array(); $element['#tree'] = TRUE; if (count($element['#options']) > 0) { - if (!isset($element['#default_value']) || $element['#default_value'] == 0) { + if (!isset($element['#default_value']) || $element['#default_value'] === 0) { $element['#default_value'] = array(); } $weight = 0; diff --git a/core/lib/Drupal/Core/Render/Element/CompositeFormElementTrait.php b/core/lib/Drupal/Core/Render/Element/CompositeFormElementTrait.php index 4c1855a..f27569c 100644 --- a/core/lib/Drupal/Core/Render/Element/CompositeFormElementTrait.php +++ b/core/lib/Drupal/Core/Render/Element/CompositeFormElementTrait.php @@ -22,7 +22,7 @@ */ public static function preRenderCompositeFormElement($element) { // Set the element's title attribute to show #title as a tooltip, if needed. - if (isset($element['#title']) && $element['#title_display'] == 'attribute') { + if (isset($element['#title']) && $element['#title_display'] === 'attribute') { $element['#attributes']['title'] = $element['#title']; if (!empty($element['#required'])) { // Append an indication that this field is required. diff --git a/core/lib/Drupal/Core/Render/Element/ImageButton.php b/core/lib/Drupal/Core/Render/Element/ImageButton.php index 5517792..3c9d85b 100644 --- a/core/lib/Drupal/Core/Render/Element/ImageButton.php +++ b/core/lib/Drupal/Core/Render/Element/ImageButton.php @@ -51,7 +51,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form $input = $form_state->getUserInput(); foreach (explode('[', $element['#name']) as $element_name) { // chop off the ] that may exist. - if (substr($element_name, -1) == ']') { + if (substr($element_name, -1) === ']') { $element_name = substr($element_name, 0, -1); } diff --git a/core/lib/Drupal/Core/Render/Element/MachineName.php b/core/lib/Drupal/Core/Render/Element/MachineName.php index fb57c52..4a79bf4 100644 --- a/core/lib/Drupal/Core/Render/Element/MachineName.php +++ b/core/lib/Drupal/Core/Render/Element/MachineName.php @@ -201,7 +201,7 @@ public static function validateMachineName(&$element, FormStateInterface $form_s if (!isset($element['#machine_name']['error'])) { // Since a hyphen is the most common alternative replacement character, // a corresponding validation error message is supported here. - if ($element['#machine_name']['replace'] == '-') { + if ($element['#machine_name']['replace'] === '-') { $form_state->setError($element, t('The machine-readable name must contain only lowercase letters, numbers, and hyphens.')); } // Otherwise, we assume the default (underscore). diff --git a/core/lib/Drupal/Core/Render/Element/Number.php b/core/lib/Drupal/Core/Render/Element/Number.php index 5e39541..5235ba5 100644 --- a/core/lib/Drupal/Core/Render/Element/Number.php +++ b/core/lib/Drupal/Core/Render/Element/Number.php @@ -69,7 +69,7 @@ public static function validateNumber(&$element, FormStateInterface $form_state, $form_state->setError($element, t('%name must be lower than or equal to %max.', array('%name' => $name, '%max' => $element['#max']))); } - if (isset($element['#step']) && strtolower($element['#step']) != 'any') { + if (isset($element['#step']) && strtolower($element['#step']) !== 'any') { // Check that the input is an allowed multiple of #step (offset by #min if // #min is set). $offset = isset($element['#min']) ? $element['#min'] : 0.0; diff --git a/core/lib/Drupal/Core/Render/Element/PathElement.php b/core/lib/Drupal/Core/Render/Element/PathElement.php index f4ea306..f2ff0b7 100644 --- a/core/lib/Drupal/Core/Render/Element/PathElement.php +++ b/core/lib/Drupal/Core/Render/Element/PathElement.php @@ -64,27 +64,27 @@ public static function valueCallback(&$element, $input, FormStateInterface $form * This checks that the submitted value matches an active route. */ public static function validateMatchedPath(&$element, FormStateInterface $form_state, &$complete_form) { - if (!empty($element['#value']) && ($element['#validate_path'] || $element['#convert_path'] != self::CONVERT_NONE)) { + if (!empty($element['#value']) && ($element['#validate_path'] || $element['#convert_path'] !== self::CONVERT_NONE)) { /** @var \Drupal\Core\Url $url */ if ($url = \Drupal::service('path.validator')->getUrlIfValid($element['#value'])) { if ($url->isExternal()) { $form_state->setError($element, t('You cannot use an external URL, please enter a relative path.')); return; } - if ($element['#convert_path'] == self::CONVERT_NONE) { + if ($element['#convert_path'] === self::CONVERT_NONE) { // Url is valid, no conversion required. return; } // We do the value conversion here whilst the Url object is in scope // after validation has occurred. - if ($element['#convert_path'] == self::CONVERT_ROUTE) { + if ($element['#convert_path'] === self::CONVERT_ROUTE) { $form_state->setValueForElement($element, array( 'route_name' => $url->getRouteName(), 'route_parameters' => $url->getRouteParameters(), )); return; } - elseif ($element['#convert_path'] == self::CONVERT_URL) { + elseif ($element['#convert_path'] === self::CONVERT_URL) { $form_state->setValueForElement($element, $url); return; } diff --git a/core/lib/Drupal/Core/Render/Element/Radio.php b/core/lib/Drupal/Core/Render/Element/Radio.php index f106d07..7295ca6 100644 --- a/core/lib/Drupal/Core/Render/Element/Radio.php +++ b/core/lib/Drupal/Core/Render/Element/Radio.php @@ -57,7 +57,7 @@ public static function preRenderRadio($element) { $element['#attributes']['type'] = 'radio'; Element::setAttributes($element, array('id', 'name', '#return_value' => 'value')); - if (isset($element['#return_value']) && $element['#value'] !== FALSE && $element['#value'] == $element['#return_value']) { + if (isset($element['#return_value']) && $element['#value'] !== FALSE && $element['#value'] === $element['#return_value']) { $element['#attributes']['checked'] = 'checked'; } static::setAttributes($element, array('form-radio')); diff --git a/core/lib/Drupal/Core/Render/Element/Range.php b/core/lib/Drupal/Core/Render/Element/Range.php index 234d92f..b359b7d 100644 --- a/core/lib/Drupal/Core/Render/Element/Range.php +++ b/core/lib/Drupal/Core/Render/Element/Range.php @@ -60,7 +60,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form $offset = ($element['#max'] - $element['#min']) / 2; // Round to the step. - if (strtolower($element['#step']) != 'any') { + if (strtolower($element['#step']) !== 'any') { $steps = round($offset / $element['#step']); $offset = $element['#step'] * $steps; } diff --git a/core/lib/Drupal/Core/Render/Element/Table.php b/core/lib/Drupal/Core/Render/Element/Table.php index 29c8303..f65e2db 100644 --- a/core/lib/Drupal/Core/Render/Element/Table.php +++ b/core/lib/Drupal/Core/Render/Element/Table.php @@ -143,7 +143,7 @@ public static function processTable(&$element, FormStateInterface $form_state, & // defaulting to 'title'? unset($label_element); $title = NULL; - if (isset($row['title']['#type']) && $row['title']['#type'] == 'label') { + if (isset($row['title']['#type']) && $row['title']['#type'] === 'label') { $label_element = &$row['title']; } else { @@ -185,7 +185,7 @@ public static function processTable(&$element, FormStateInterface $form_state, & $row['select']['#parents'] = $element_parents; } else { - $row['select']['#default_value'] = ($element['#default_value'] == $key ? $key : NULL); + $row['select']['#default_value'] = ($element['#default_value'] === $key ? $key : NULL); $row['select']['#parents'] = $element['#parents']; } if (isset($label_element)) { diff --git a/core/lib/Drupal/Core/Render/Element/Tableselect.php b/core/lib/Drupal/Core/Render/Element/Tableselect.php index 0833369..a87a45f 100644 --- a/core/lib/Drupal/Core/Render/Element/Tableselect.php +++ b/core/lib/Drupal/Core/Render/Element/Tableselect.php @@ -51,7 +51,7 @@ public function getInfo() { * {@inheritdoc} */ public static function valueCallback(&$element, $input, FormStateInterface $form_state) { - // If $element['#multiple'] == FALSE, then radio buttons are displayed and + // If $element['#multiple'] === FALSE, then radio buttons are displayed and // the default value handling is used. if (isset($element['#multiple']) && $element['#multiple']) { // Checkboxes are being displayed with the default value coming from the @@ -233,7 +233,7 @@ public static function processTableselect(&$element, FormStateInterface $form_st '#type' => 'radio', '#title' => '', '#return_value' => $key, - '#default_value' => ($element['#default_value'] == $key) ? $key : NULL, + '#default_value' => ($element['#default_value'] === $key) ? $key : NULL, '#attributes' => $element['#attributes'], '#parents' => $element['#parents'], '#id' => drupal_html_id('edit-' . implode('-', $parents_for_id)), diff --git a/core/lib/Drupal/Core/Routing/Enhancer/AjaxEnhancer.php b/core/lib/Drupal/Core/Routing/Enhancer/AjaxEnhancer.php index 4d0c707..087642d 100644 --- a/core/lib/Drupal/Core/Routing/Enhancer/AjaxEnhancer.php +++ b/core/lib/Drupal/Core/Routing/Enhancer/AjaxEnhancer.php @@ -40,7 +40,7 @@ public function enhance(array $defaults, Request $request) { // A request can have the 'ajax' content type when the controller supports // basically both simple HTML and Ajax routes by returning a render array. // In those cases we want to convert it to a proper ajax response as well. - if (empty($defaults['_content']) && $defaults['_controller'] != 'controller.ajax:content' && in_array($this->negotiation->getContentType($request), array('drupal_ajax', 'ajax', 'iframeupload'))) { + if (empty($defaults['_content']) && $defaults['_controller'] !== 'controller.ajax:content' && in_array($this->negotiation->getContentType($request), array('drupal_ajax', 'ajax', 'iframeupload'))) { $defaults['_content'] = isset($defaults['_controller']) ? $defaults['_controller'] : NULL; $defaults['_controller'] = 'controller.ajax:content'; } diff --git a/core/lib/Drupal/Core/Routing/RoutePreloader.php b/core/lib/Drupal/Core/Routing/RoutePreloader.php index 7952d17..ab8dec4 100644 --- a/core/lib/Drupal/Core/Routing/RoutePreloader.php +++ b/core/lib/Drupal/Core/Routing/RoutePreloader.php @@ -75,7 +75,7 @@ public function __construct(RouteProviderInterface $route_provider, StateInterfa */ public function onRequest(KernelEvent $event) { // Just preload on normal HTML pages, as they will display menu links. - if ($this->negotiation->getContentType($event->getRequest()) == 'html') { + if ($this->negotiation->getContentType($event->getRequest()) === 'html') { $this->loadNonAdminRoutes(); } } @@ -98,7 +98,7 @@ protected function loadNonAdminRoutes() { public function onAlterRoutes(RouteBuildEvent $event) { $collection = $event->getRouteCollection(); foreach ($collection->all() as $name => $route) { - if (strpos($route->getPath(), '/admin/') !== 0 && $route->getPath() != '/admin') { + if (strpos($route->getPath(), '/admin/') !== 0 && $route->getPath() !== '/admin') { $this->nonAdminRoutesOnRebuild[] = $name; } } diff --git a/core/lib/Drupal/Core/Routing/RouteProvider.php b/core/lib/Drupal/Core/Routing/RouteProvider.php index 22b8177..22f22e5 100644 --- a/core/lib/Drupal/Core/Routing/RouteProvider.php +++ b/core/lib/Drupal/Core/Routing/RouteProvider.php @@ -203,7 +203,7 @@ public function getCandidateOutlines(array $parts) { // The highest possible mask is a 1 bit for every part of the path. We will // check every value down from there to generate a possible outline. - if ($number_parts == 1) { + if ($number_parts === 1) { $masks = array(1); } elseif ($number_parts <= 3) { diff --git a/core/lib/Drupal/Core/Routing/UrlGenerator.php b/core/lib/Drupal/Core/Routing/UrlGenerator.php index faa8456..51f4f6f 100644 --- a/core/lib/Drupal/Core/Routing/UrlGenerator.php +++ b/core/lib/Drupal/Core/Routing/UrlGenerator.php @@ -208,7 +208,7 @@ public function generateFromRoute($name, $parameters = array(), $options = array $fragment = ''; if (isset($options['fragment'])) { - if (($fragment = trim($options['fragment'])) != '') { + if (($fragment = trim($options['fragment'])) !== '') { $fragment = '#' . $fragment; } } @@ -231,9 +231,9 @@ public function generateFromRoute($name, $parameters = array(), $options = array $scheme = $req; } $port = ''; - if ('http' === $scheme && 80 != $this->context->getHttpPort()) { + if ('http' === $scheme && 80 !== $this->context->getHttpPort()) { $port = ':' . $this->context->getHttpPort(); - } elseif ('https' === $scheme && 443 != $this->context->getHttpsPort()) { + } elseif ('https' === $scheme && 443 !== $this->context->getHttpsPort()) { $port = ':' . $this->context->getHttpsPort(); } return $scheme . '://' . $host . $port . $base_url . $path . $fragment; @@ -265,7 +265,7 @@ public function generateFromPath($path = NULL, $options = array()) { // would require another function call, and performance inside url() is // critical. $colonpos = strpos($path, ':'); - $options['external'] = ($colonpos !== FALSE && !preg_match('![/?#]!', substr($path, 0, $colonpos)) && UrlHelper::stripDangerousProtocols($path) == $path); + $options['external'] = ($colonpos !== FALSE && !preg_match('![/?#]!', substr($path, 0, $colonpos)) && UrlHelper::stripDangerousProtocols($path) === $path); } if (isset($options['fragment']) && $options['fragment'] !== '') { @@ -319,7 +319,7 @@ public function generateFromPath($path = NULL, $options = array()) { $options['base_url'] = $this->baseUrl; } } - elseif (rtrim($options['base_url'], '/') == $options['base_url']) { + elseif (rtrim($options['base_url'], '/') === $options['base_url']) { $options['base_url'] .= '/'; } $base = $options['absolute'] ? $options['base_url'] : $this->basePath; diff --git a/core/lib/Drupal/Core/Session/SessionHandler.php b/core/lib/Drupal/Core/Session/SessionHandler.php index c8d69fb..d655832 100644 --- a/core/lib/Drupal/Core/Session/SessionHandler.php +++ b/core/lib/Drupal/Core/Session/SessionHandler.php @@ -119,7 +119,7 @@ public function read($sid) { // We found the client's session record and they are an authenticated, // active user. - if ($values && $values['uid'] > 0 && $values['status'] == 1) { + if ($values && $values['uid'] > 0 && $values['status'] === '1') { // Add roles element to $user. $rids = $this->connection->query("SELECT ur.rid FROM {users_roles} ur WHERE ur.uid = :uid", array( ':uid' => $values['uid'], diff --git a/core/lib/Drupal/Core/Session/UserSession.php b/core/lib/Drupal/Core/Session/UserSession.php index 7364da9..e0195a4 100644 --- a/core/lib/Drupal/Core/Session/UserSession.php +++ b/core/lib/Drupal/Core/Session/UserSession.php @@ -176,7 +176,7 @@ public function isAuthenticated() { * {@inheritdoc} */ public function isAnonymous() { - return $this->uid == 0; + return $this->uid === 0; } /** diff --git a/core/lib/Drupal/Core/StreamWrapper/LocalStream.php b/core/lib/Drupal/Core/StreamWrapper/LocalStream.php index 937953f..a1e00a6 100644 --- a/core/lib/Drupal/Core/StreamWrapper/LocalStream.php +++ b/core/lib/Drupal/Core/StreamWrapper/LocalStream.php @@ -392,7 +392,7 @@ public function dirname($uri = NULL) { $target = $this->getTarget($uri); $dirname = dirname($target); - if ($dirname == '.') { + if ($dirname === '.') { $dirname = ''; } diff --git a/core/lib/Drupal/Core/StringTranslation/TranslationManager.php b/core/lib/Drupal/Core/StringTranslation/TranslationManager.php index e6d2a66..64ad74d 100644 --- a/core/lib/Drupal/Core/StringTranslation/TranslationManager.php +++ b/core/lib/Drupal/Core/StringTranslation/TranslationManager.php @@ -160,14 +160,14 @@ public function formatPlural($count, $singular, $plural, array $args = array(), // Split joined translation strings into array. $translated_array = explode(LOCALE_PLURAL_DELIMITER, $translated_strings); - if ($count == 1) { + if ($count === 1) { return SafeMarkup::set($translated_array[0]); } // Get the plural index through the gettext formula. // @todo implement static variable to minimize function_exists() usage. $index = (function_exists('locale_get_plural')) ? locale_get_plural($count, isset($options['langcode']) ? $options['langcode'] : NULL) : -1; - if ($index == 0) { + if ($index === 0) { // Singular form. $return = $translated_array[0]; } diff --git a/core/lib/Drupal/Core/Template/Attribute.php b/core/lib/Drupal/Core/Template/Attribute.php index 7ea9b4c..485c72a 100644 --- a/core/lib/Drupal/Core/Template/Attribute.php +++ b/core/lib/Drupal/Core/Template/Attribute.php @@ -98,7 +98,7 @@ protected function createAttributeValue($name, $value) { } // An array value or 'class' attribute name are forced to always be an // AttributeArray value for consistency. - if (is_array($value) || $name == 'class') { + if (is_array($value) || $name === 'class') { // Cast the value to an array if the value was passed in as a string. // @todo Decide to fix all the broken instances of class as a string // in core or cast them. diff --git a/core/lib/Drupal/Core/Template/TwigNodeVisitor.php b/core/lib/Drupal/Core/Template/TwigNodeVisitor.php index 4915c16..8433a05 100644 --- a/core/lib/Drupal/Core/Template/TwigNodeVisitor.php +++ b/core/lib/Drupal/Core/Template/TwigNodeVisitor.php @@ -47,7 +47,7 @@ function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env) { // Change the 'escape' filter to our own 'drupal_escape' filter. else if ($node instanceof \Twig_Node_Expression_Filter) { $name = $node->getNode('filter')->getAttribute('value'); - if ('escape' == $name || 'e' == $name) { + if ('escape' === $name || 'e' === $name) { // Use our own escape filter that is SafeMarkup aware. $node->getNode('filter')->setAttribute('value', 'drupal_escape'); diff --git a/core/lib/Drupal/Core/Theme/AjaxBasePageNegotiator.php b/core/lib/Drupal/Core/Theme/AjaxBasePageNegotiator.php index b15ce93..e529736 100644 --- a/core/lib/Drupal/Core/Theme/AjaxBasePageNegotiator.php +++ b/core/lib/Drupal/Core/Theme/AjaxBasePageNegotiator.php @@ -75,7 +75,7 @@ public function applies(RouteMatchInterface $route_match) { // Check whether the route was configured to use the base page theme. return ($route = $route_match->getRouteObject()) && $route->hasOption('_theme') - && $route->getOption('_theme') == 'ajax_base_page'; + && $route->getOption('_theme') === 'ajax_base_page'; } /** diff --git a/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php index 0ad005d..5fc5054 100644 --- a/core/lib/Drupal/Core/Theme/Registry.php +++ b/core/lib/Drupal/Core/Theme/Registry.php @@ -433,7 +433,7 @@ protected function processExtension(&$cache, $name, $type, $theme, $path) { // If function and file are omitted, default to standard naming // conventions. if (!isset($info['template']) && !isset($info['function'])) { - $result[$hook]['function'] = ($type == 'module' ? 'theme_' : $name . '_') . $hook; + $result[$hook]['function'] = ($type === 'module' ? 'theme_' : $name . '_') . $hook; } if (isset($cache[$hook]['includes'])) { @@ -470,7 +470,7 @@ protected function processExtension(&$cache, $name, $type, $theme, $path) { if (!isset($info['preprocess functions']) || !is_array($info['preprocess functions'])) { $info['preprocess functions'] = array(); $prefixes = array(); - if ($type == 'module') { + if ($type === 'module') { // Default variable preprocessor prefix. $prefixes[] = 'template'; // Add all modules so they can intervene with their own variable @@ -478,7 +478,7 @@ protected function processExtension(&$cache, $name, $type, $theme, $path) { // even if they are not the owner of the current hook. $prefixes = array_merge($prefixes, $module_list); } - elseif ($type == 'theme_engine' || $type == 'base_theme_engine') { + elseif ($type === 'theme_engine' || $type === 'base_theme_engine') { // Theme engines get an extra set that come before the normally // named variable preprocessors. $prefixes[] = $name . '_engine'; @@ -521,7 +521,7 @@ protected function processExtension(&$cache, $name, $type, $theme, $path) { // Let themes have variable preprocessors even if they didn't register a // template. - if ($type == 'theme' || $type == 'base_theme') { + if ($type === 'theme' || $type === 'base_theme') { foreach ($cache as $hook => $info) { // Check only if not registered by the theme or engine. if (empty($result[$hook])) { diff --git a/core/lib/Drupal/Core/TypedData/DataReferenceDefinition.php b/core/lib/Drupal/Core/TypedData/DataReferenceDefinition.php index 23fb420..cfc65cf 100644 --- a/core/lib/Drupal/Core/TypedData/DataReferenceDefinition.php +++ b/core/lib/Drupal/Core/TypedData/DataReferenceDefinition.php @@ -40,7 +40,7 @@ public static function create($target_data_type) { * {@inheritdoc} */ public static function createFromDataType($data_type) { - if (substr($data_type, -strlen('_reference')) != '_reference') { + if (substr($data_type, -strlen('_reference')) !== '_reference') { throw new \InvalidArgumentException('Data type must be of the form "{TARGET_TYPE}_reference"'); } // Cut of the _reference suffix. diff --git a/core/lib/Drupal/Core/TypedData/ListDataDefinition.php b/core/lib/Drupal/Core/TypedData/ListDataDefinition.php index b710a75..b066b9e 100644 --- a/core/lib/Drupal/Core/TypedData/ListDataDefinition.php +++ b/core/lib/Drupal/Core/TypedData/ListDataDefinition.php @@ -68,7 +68,7 @@ public function getDataType() { * {@inheritdoc} */ public function setDataType($type) { - if ($type != 'list') { + if ($type !== 'list') { throw new \LogicException('Lists must always be of data type "list".'); } } diff --git a/core/lib/Drupal/Core/Updater/Updater.php b/core/lib/Drupal/Core/Updater/Updater.php index 045a981..0c386bd 100644 --- a/core/lib/Drupal/Core/Updater/Updater.php +++ b/core/lib/Drupal/Core/Updater/Updater.php @@ -100,7 +100,7 @@ public static function findInfoFile($directory) { return FALSE; } foreach ($info_files as $info_file) { - if (drupal_substr($info_file->filename, 0, -5) == drupal_basename($directory)) { + if (drupal_substr($info_file->filename, 0, -5) === drupal_basename($directory)) { // Info file Has the same name as the directory, return it. return $info_file->uri; } @@ -277,7 +277,7 @@ public function prepareInstallDirectory(&$filetransfer, $directory) { if (!is_writable($parent_dir)) { @chmod($parent_dir, 0755); // It is expected that this will fail if the directory is owned by the - // FTP user. If the FTP user == web server, it will succeed. + // FTP user. If the FTP user === web server, it will succeed. try { $filetransfer->createDirectory($directory); $this->makeWorldReadable($filetransfer, $directory); diff --git a/core/lib/Drupal/Core/Url.php b/core/lib/Drupal/Core/Url.php index d97f017..9c861d4 100644 --- a/core/lib/Drupal/Core/Url.php +++ b/core/lib/Drupal/Core/Url.php @@ -131,7 +131,7 @@ public static function createFromPath($path) { } // Special case the front page route. - if ($path == '') { + if ($path === '') { return new static($path); } else { diff --git a/core/lib/Drupal/Core/Utility/Error.php b/core/lib/Drupal/Core/Utility/Error.php index e3bca6d..215f46b 100644 --- a/core/lib/Drupal/Core/Utility/Error.php +++ b/core/lib/Drupal/Core/Utility/Error.php @@ -218,13 +218,13 @@ public static function formatFlattenedBacktrace(array $backtrace) { foreach ($trace['args'] as $arg) { $type = $arg[0]; $value = $arg[1]; - if ($type == 'array') { + if ($type === 'array') { $call['args'][] = '[' . ucfirst($type) . ']'; } - elseif ($type == 'null') { + elseif ($type === 'null') { $call['args'][] = strtoupper($type); } - elseif ($type == 'boolean') { + elseif ($type === 'boolean') { $call['args'][] = $value ? 'TRUE' : 'FALSE'; } else { diff --git a/core/lib/Drupal/Core/Utility/LinkGenerator.php b/core/lib/Drupal/Core/Utility/LinkGenerator.php index f8660ab..1ca5184 100644 --- a/core/lib/Drupal/Core/Utility/LinkGenerator.php +++ b/core/lib/Drupal/Core/Utility/LinkGenerator.php @@ -109,7 +109,7 @@ public function generateFromUrl($text, Url $url) { // @todo System path is deprecated - use the route name and parameters. $system_path = $url->getInternalPath(); // Special case for the front page. - $variables['options']['attributes']['data-drupal-link-system-path'] = $system_path == '' ? '' : $system_path; + $variables['options']['attributes']['data-drupal-link-system-path'] = $system_path === '' ? '' : $system_path; } } diff --git a/core/lib/Drupal/Core/Utility/ProjectInfo.php b/core/lib/Drupal/Core/Utility/ProjectInfo.php index 2a49c8c..684910a 100644 --- a/core/lib/Drupal/Core/Utility/ProjectInfo.php +++ b/core/lib/Drupal/Core/Utility/ProjectInfo.php @@ -64,7 +64,7 @@ function processInfoList(array &$projects, array $list, $project_type, $status, } } // Otherwise, just add projects of the proper status to our list. - elseif ($file->status != $status) { + elseif ($file->status !== $status) { continue; } @@ -109,7 +109,7 @@ function processInfoList(array &$projects, array $list, $project_type, $status, // or theme. If the project name is 'drupal', we don't want it to show up // under the usual "Modules" section, we put it at a special "Drupal Core" // section at the top of the report. - if ($project_name == 'drupal') { + if ($project_name === 'drupal') { $project_display_type = 'core'; } else { @@ -123,7 +123,7 @@ function processInfoList(array &$projects, array $list, $project_type, $status, } // Add a list of sub-themes that "depend on" the project and a list of base // themes that are "required by" the project. - if ($project_name == 'drupal') { + if ($project_name === 'drupal') { // Drupal core is always required, so this extra info would be noise. $sub_themes = array(); $base_themes = array(); @@ -150,7 +150,7 @@ function processInfoList(array &$projects, array $list, $project_type, $status, 'base_themes' => $base_themes, ); } - elseif ($projects[$project_name]['project_type'] == $project_display_type) { + elseif ($projects[$project_name]['project_type'] === $project_display_type) { // Only add the file we're processing to the 'includes' array for this // project if it is of the same type and status (which is encoded in the // $project_display_type). This prevents listing all the disabled diff --git a/core/lib/Drupal/Core/Utility/Token.php b/core/lib/Drupal/Core/Utility/Token.php index d03d645..4e3d014 100644 --- a/core/lib/Drupal/Core/Utility/Token.php +++ b/core/lib/Drupal/Core/Utility/Token.php @@ -270,7 +270,7 @@ public function generate($type, array $tokens, array $data = array(), array $opt * 'created' => '[node:created]', * ); * $results = Token::findWithPrefix($data, 'author'); - * $results == array('name' => '[node:author:name]'); + * $results === array('name' => '[node:author:name]'); * @endcode * * @param array $tokens @@ -289,7 +289,7 @@ public function findWithPrefix(array $tokens, $prefix, $delimiter = ':') { $results = array(); foreach ($tokens as $token => $raw) { $parts = explode($delimiter, $token, 2); - if (count($parts) == 2 && $parts[0] == $prefix) { + if (count($parts) === 2 && $parts[0] === $prefix) { $results[$parts[1]] = $raw; } } diff --git a/core/lib/Drupal/Core/Validation/DrupalTranslator.php b/core/lib/Drupal/Core/Validation/DrupalTranslator.php index 01302ce..a0ac5ff 100644 --- a/core/lib/Drupal/Core/Validation/DrupalTranslator.php +++ b/core/lib/Drupal/Core/Validation/DrupalTranslator.php @@ -68,7 +68,7 @@ protected function processParameters(array $parameters) { // t() does not work will objects being passed as replacement strings. } // Check for symfony replacement patterns in the form "{{ name }}". - elseif (strpos($key, '{{ ') === 0 && strrpos($key, ' }}') == strlen($key) - 3) { + elseif (strpos($key, '{{ ') === 0 && strrpos($key, ' }}') === strlen($key) - 3) { // Transform it into a Drupal pattern using the format %name. $key = '%' . substr($key, 3, strlen($key) - 6); $return[$key] = $value; diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php index fe3a1fb..2007233 100644 --- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php +++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php @@ -37,7 +37,7 @@ public function validate($value, Constraint $constraint) { if ($typed_data instanceof BinaryInterface && !is_resource($value)) { $valid = FALSE; } - if ($typed_data instanceof BooleanInterface && !(is_bool($value) || $value === 0 || $value === '0' || $value === 1 || $value == '1')) { + if ($typed_data instanceof BooleanInterface && !(is_bool($value) || $value === 0 || $value === '0' || $value === 1 || $value === '1')) { $valid = FALSE; } if ($typed_data instanceof FloatInterface && filter_var($value, FILTER_VALIDATE_FLOAT) === FALSE) { diff --git a/core/misc/ajax.js b/core/misc/ajax.js index dc3fe34..2e76c65 100644 --- a/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -114,7 +114,7 @@ function loadAjaxBehavior(base) { responseText = responseText.replace(/<("[^"]*"|'[^']*'|[^'">])*>/gi, ""); responseText = responseText.replace(/[\n]+\s+/g, "\n"); - // We don't need readyState except for status == 0. + // We don't need readyState except for status === 0. readyStateText = xmlhttp.status === 0 ? ("\n" + Drupal.t("ReadyState: !readyState", {'!readyState': xmlhttp.readyState})) : ""; this.message = statusCode + pathText + statusText + responseText + readyStateText; diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index 64eb275..8c3aabc 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -170,7 +170,7 @@ function aggregator_filter_xss($value) { * Implements hook_preprocess_HOOK() for block templates. */ function aggregator_preprocess_block(&$variables) { - if ($variables['configuration']['provider'] == 'aggregator') { + if ($variables['configuration']['provider'] === 'aggregator') { $variables['attributes']['role'] = 'complementary'; } } diff --git a/core/modules/aggregator/aggregator.theme.inc b/core/modules/aggregator/aggregator.theme.inc index 605025c..7ca325d 100644 --- a/core/modules/aggregator/aggregator.theme.inc +++ b/core/modules/aggregator/aggregator.theme.inc @@ -32,7 +32,7 @@ function template_preprocess_aggregator_item(&$variables) { $variables['source_url'] = url('aggregator/sources/' . $fid); $variables['source_title'] = String::checkPlain($item->ftitle); } - if (date('Ymd', $item->getPostedTime()) == date('Ymd')) { + if (date('Ymd', $item->getPostedTime()) === date('Ymd')) { $variables['source_date'] = t('%ago ago', array('%ago' => \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $item->getPostedTime()))); } else { diff --git a/core/modules/aggregator/src/FeedForm.php b/core/modules/aggregator/src/FeedForm.php index 1832cb5..c55f412 100644 --- a/core/modules/aggregator/src/FeedForm.php +++ b/core/modules/aggregator/src/FeedForm.php @@ -48,10 +48,10 @@ public function validate(array $form, FormStateInterface $form_state) { $feed_storage = $this->entityManager->getStorage('aggregator_feed'); $result = $feed_storage->getFeedDuplicates($feed); foreach ($result as $item) { - if (strcasecmp($item->label(), $feed->label()) == 0) { + if (strcasecmp($item->label(), $feed->label()) === 0) { $form_state->setErrorByName('title', $this->t('A feed named %feed already exists. Enter a unique title.', array('%feed' => $feed->label()))); } - if (strcasecmp($item->getUrl(), $feed->getUrl()) == 0) { + if (strcasecmp($item->getUrl(), $feed->getUrl()) === 0) { $form_state->setErrorByName('url', $this->t('A feed with this URL %url already exists. Enter a unique URL.', array('%url' => $feed->getUrl()))); } } diff --git a/core/modules/aggregator/src/Form/OpmlFeedAdd.php b/core/modules/aggregator/src/Form/OpmlFeedAdd.php index 2eec507..f20ab0a 100644 --- a/core/modules/aggregator/src/Form/OpmlFeedAdd.php +++ b/core/modules/aggregator/src/Form/OpmlFeedAdd.php @@ -105,7 +105,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { public function validateForm(array &$form, FormStateInterface $form_state) { // If both fields are empty or filled, cancel. $file_upload = $this->getRequest()->files->get('files[upload]', NULL, TRUE); - if ($form_state->isValueEmpty('remote') == empty($file_upload)) { + if ($form_state->isValueEmpty('remote') === empty($file_upload)) { $form_state->setErrorByName('remote', $this->t('Either upload a file or enter a URL.')); } } @@ -155,11 +155,11 @@ public function submitForm(array &$form, FormStateInterface $form_state) { ->execute(); $result = $this->feedStorage->loadMultiple($ids); foreach ($result as $old) { - if (strcasecmp($old->label(), $feed['title']) == 0) { + if (strcasecmp($old->label(), $feed['title']) === 0) { drupal_set_message($this->t('A feed named %title already exists.', array('%title' => $old->label())), 'warning'); continue 2; } - if (strcasecmp($old->getUrl(), $feed['url']) == 0) { + if (strcasecmp($old->getUrl(), $feed['url']) === 0) { drupal_set_message($this->t('A feed with the URL %url already exists.', array('%url' => $old->getUrl())), 'warning'); continue 2; } @@ -198,7 +198,7 @@ protected function parseOpml($opml) { $xml_parser = drupal_xml_parser_create($opml); if (xml_parse_into_struct($xml_parser, $opml, $values)) { foreach ($values as $entry) { - if ($entry['tag'] == 'OUTLINE' && isset($entry['attributes'])) { + if ($entry['tag'] === 'OUTLINE' && isset($entry['attributes'])) { $item = $entry['attributes']; if (!empty($item['XMLURL']) && !empty($item['TEXT'])) { $feeds[] = array('title' => $item['TEXT'], 'url' => $item['XMLURL']); diff --git a/core/modules/aggregator/src/ItemViewBuilder.php b/core/modules/aggregator/src/ItemViewBuilder.php index 7d3f919..93e4212 100644 --- a/core/modules/aggregator/src/ItemViewBuilder.php +++ b/core/modules/aggregator/src/ItemViewBuilder.php @@ -22,7 +22,7 @@ protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langco $defaults = parent::getBuildDefaults($entity, $view_mode, $langcode); // Use a different template for the summary view mode. - if ($view_mode == 'summary') { + if ($view_mode === 'summary') { $defaults['#theme'] = 'aggregator_summary_item'; } return $defaults; diff --git a/core/modules/aggregator/src/ItemsImporter.php b/core/modules/aggregator/src/ItemsImporter.php index af19325..c2f992e 100644 --- a/core/modules/aggregator/src/ItemsImporter.php +++ b/core/modules/aggregator/src/ItemsImporter.php @@ -114,7 +114,7 @@ public function refresh(FeedInterface $feed) { // feed we compare stored hash and new hash calculated from downloaded // data. If both are equal we say that feed is not updated. $hash = hash('sha256', $feed->source_string); - $has_new_content = $success && ($feed->getHash() != $hash); + $has_new_content = $success && ($feed->getHash() !== $hash); if ($has_new_content) { // Parse the feed. @@ -128,7 +128,7 @@ public function refresh(FeedInterface $feed) { $feed->save(); // Log if feed URL has changed. - if ($feed->getUrl() != $feed_url) { + if ($feed->getUrl() !== $feed_url) { $this->logger->notice('Updated URL for feed %title to %url.', array('%title' => $feed->label(), '%url' => $feed->getUrl())); } diff --git a/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php b/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php index 8695d25..e0aa0b4 100644 --- a/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php +++ b/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php @@ -86,7 +86,7 @@ public function fetch(FeedInterface $feed) { // In case of a 304 Not Modified, there is no new content, so return // FALSE. - if ($response->getStatusCode() == 304) { + if ($response->getStatusCode() === 304) { return FALSE; } @@ -97,7 +97,7 @@ public function fetch(FeedInterface $feed) { // Update the feed URL in case of a 301 redirect. - if ($response->getEffectiveUrl() != $feed->getUrl()) { + if ($response->getEffectiveUrl() !== $feed->getUrl()) { $feed->setUrl($response->getEffectiveUrl()); } return TRUE; diff --git a/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php b/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php index 642646a..ed6c414 100644 --- a/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php +++ b/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php @@ -146,7 +146,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta $lengths = array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000); $options = array_map(function($length) { - return ($length == 0) ? t('Unlimited') : format_plural($length, '1 character', '@count characters'); + return ($length === 0) ? t('Unlimited') : format_plural($length, '1 character', '@count characters'); }, array_combine($lengths, $lengths)); $form['processors'][$info['id']]['aggregator_teaser_length'] = array( @@ -191,7 +191,7 @@ public function process(FeedInterface $feed) { if (!empty($item['guid'])) { $values = array('fid' => $feed->id(), 'guid' => $item['guid']); } - elseif ($item['link'] && $item['link'] != $feed->link && $item['link'] != $feed->url) { + elseif ($item['link'] && $item['link'] !== $feed->link && $item['link'] !== $feed->url) { $values = array('fid' => $feed->id(), 'link' => $item['link']); } else { @@ -246,7 +246,7 @@ public function delete(FeedInterface $feed) { public function postProcess(FeedInterface $feed) { $aggregator_clear = $this->configuration['items']['expire']; - if ($aggregator_clear != AGGREGATOR_CLEAR_NEVER) { + if ($aggregator_clear !== AGGREGATOR_CLEAR_NEVER) { // Delete all items that are older than flush item timer. $age = REQUEST_TIME - $aggregator_clear; $result = $this->itemQuery diff --git a/core/modules/aggregator/src/Tests/AggregatorTestBase.php b/core/modules/aggregator/src/Tests/AggregatorTestBase.php index 71a0bfe..e7fe19d 100644 --- a/core/modules/aggregator/src/Tests/AggregatorTestBase.php +++ b/core/modules/aggregator/src/Tests/AggregatorTestBase.php @@ -27,7 +27,7 @@ protected function setUp() { parent::setUp(); // Create an Article node type. - if ($this->profile != 'standard') { + if ($this->profile !== 'standard') { $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); } @@ -173,7 +173,7 @@ function updateFeedItems(FeedInterface $feed, $expected_count = NULL) { if ($expected_count !== NULL) { $feed->item_count = count($feed->items); - $this->assertEqual($expected_count, $feed->item_count, format_string('Total items in feed equal to the total items in database (!val1 != !val2)', array('!val1' => $expected_count, '!val2' => $feed->item_count))); + $this->assertEqual($expected_count, $feed->item_count, format_string('Total items in feed equal to the total items in database (!val1 !== !val2)', array('!val1' => $expected_count, '!val2' => $feed->item_count))); } } @@ -202,7 +202,7 @@ function updateAndDelete(FeedInterface $feed, $expected_count) { $this->assertTrue($count); $this->deleteFeedItems($feed); $count = db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField(); - $this->assertTrue($count == 0); + $this->assertTrue($count === 0); } /** @@ -218,7 +218,7 @@ function updateAndDelete(FeedInterface $feed, $expected_count) { */ function uniqueFeed($feed_name, $feed_url) { $result = db_query("SELECT COUNT(*) FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $feed_name, ':url' => $feed_url))->fetchField(); - return (1 == $result); + return (1 === $result); } /** diff --git a/core/modules/aggregator/src/Tests/ImportOpmlTest.php b/core/modules/aggregator/src/Tests/ImportOpmlTest.php index 821a34a..06ecc6e 100644 --- a/core/modules/aggregator/src/Tests/ImportOpmlTest.php +++ b/core/modules/aggregator/src/Tests/ImportOpmlTest.php @@ -106,7 +106,7 @@ function submitImportForm() { foreach ($feeds_from_db as $feed) { $title[$feed->url] = $feed->title; $url[$feed->title] = $feed->url; - $refresh = $refresh && $feed->refresh == 900; + $refresh = $refresh && $feed->refresh === 900; } $this->assertEqual($title[$feeds[0]['url[0][value]']], $feeds[0]['title[0][value]'], 'First feed was added correctly.'); diff --git a/core/modules/aggregator/tests/modules/aggregator_test/src/Controller/AggregatorTestRssController.php b/core/modules/aggregator/tests/modules/aggregator_test/src/Controller/AggregatorTestRssController.php index 067d669..03e2147 100644 --- a/core/modules/aggregator/tests/modules/aggregator_test/src/Controller/AggregatorTestRssController.php +++ b/core/modules/aggregator/tests/modules/aggregator_test/src/Controller/AggregatorTestRssController.php @@ -48,7 +48,7 @@ public function testFeed($use_last_modified, $use_etag, Request $request) { $response->headers->set('ETag', $etag); } // Return 304 not modified if either last modified or etag match. - if ($last_modified == $if_modified_since || $etag == $if_none_match) { + if ($last_modified === $if_modified_since || $etag === $if_none_match) { $response->setStatusCode(304); return $response; } diff --git a/core/modules/aggregator/tests/modules/aggregator_test/src/Plugin/aggregator/fetcher/TestFetcher.php b/core/modules/aggregator/tests/modules/aggregator_test/src/Plugin/aggregator/fetcher/TestFetcher.php index aec4ded..454179e 100644 --- a/core/modules/aggregator/tests/modules/aggregator_test/src/Plugin/aggregator/fetcher/TestFetcher.php +++ b/core/modules/aggregator/tests/modules/aggregator_test/src/Plugin/aggregator/fetcher/TestFetcher.php @@ -28,7 +28,7 @@ class TestFetcher extends DefaultFetcher implements FetcherInterface { * Implements \Drupal\aggregator\Plugin\FetcherInterface::fetch(). */ public function fetch(FeedInterface $feed) { - if ($feed->label() == 'Do not fetch') { + if ($feed->label() === 'Do not fetch') { return FALSE; } return parent::fetch($feed); diff --git a/core/modules/ban/src/Form/BanAdmin.php b/core/modules/ban/src/Form/BanAdmin.php index 94c1d4f..52a5e70 100644 --- a/core/modules/ban/src/Form/BanAdmin.php +++ b/core/modules/ban/src/Form/BanAdmin.php @@ -109,10 +109,10 @@ public function validateForm(array &$form, FormStateInterface $form_state) { if ($this->ipManager->isBanned($ip)) { $form_state->setErrorByName('ip', $this->t('This IP address is already banned.')); } - elseif ($ip == $this->getRequest()->getClientIP()) { + elseif ($ip === $this->getRequest()->getClientIP()) { $form_state->setErrorByName('ip', $this->t('You may not ban your own IP address.')); } - elseif (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE) == FALSE) { + elseif (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE) === FALSE) { $form_state->setErrorByName('ip', $this->t('Enter a valid IP address.')); } } diff --git a/core/modules/block/block.api.php b/core/modules/block/block.api.php index 43f03e9..2a10198 100644 --- a/core/modules/block/block.api.php +++ b/core/modules/block/block.api.php @@ -154,8 +154,8 @@ function hook_block_view_BASE_BLOCK_ID_alter(array &$build, \Drupal\Core\Block\B function hook_block_access(\Drupal\block\Entity\Block $block, $operation, \Drupal\user\Entity\User $account, $langcode) { // Example code that would prevent displaying the 'Powered by Drupal' block in // a region different than the footer. - if ($operation == 'view' && $block->get('plugin') == 'system_powered_by_block') { - return AccessResult::forbiddenIf($block->get('region') != 'footer')->cacheUntilEntityChanges($block); + if ($operation === 'view' && $block->get('plugin') === 'system_powered_by_block') { + return AccessResult::forbiddenIf($block->get('region') !== 'footer')->cacheUntilEntityChanges($block); } // No opinion. diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 339d163..578809a 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -37,7 +37,7 @@ function block_help($route_name, RouteMatchInterface $route_match) { $output .= ''; return $output; } - if ($route_name == 'block.admin_display' || $route_name == 'block.admin_display_theme') { + if ($route_name === 'block.admin_display' || $route_name === 'block.admin_display_theme') { $demo_theme = $route_match->getParameter('theme') ?: \Drupal::config('system.theme')->get('default'); $themes = list_themes(); $output = '

' . t('This page provides a drag-and-drop interface for adding a block to a region, and for controlling the order of blocks within regions. To add a block to a region, or to configure its specific title and visibility settings, click the block title under Place blocks. Since not all themes implement the same regions, or display regions in the same way, blocks are positioned on a per-theme basis. Remember that your changes will not be saved until you click the Save blocks button at the bottom of the page.') . '

'; @@ -83,7 +83,7 @@ function block_page_build(&$page) { // Fetch a list of regions for the current theme. $all_regions = system_region_list($theme); - if (\Drupal::routeMatch()->getRouteName() != 'block.admin_demo') { + if (\Drupal::routeMatch()->getRouteName() !== 'block.admin_demo') { // Create a full page display variant, which will load blocks into their // regions. $page += \Drupal::service('plugin.manager.display_variant') @@ -103,7 +103,7 @@ function block_page_build(&$page) { $page['page_top']['backlink'] = array( '#type' => 'link', '#title' => t('Exit block region demonstration'), - '#href' => 'admin/structure/block' . (\Drupal::config('system.theme')->get('default') == $theme ? '' : '/list/' . $theme), + '#href' => 'admin/structure/block' . (\Drupal::config('system.theme')->get('default') === $theme ? '' : '/list/' . $theme), '#options' => array('attributes' => array('class' => array('block-demo-backlink'))), '#weight' => -10, ); @@ -134,14 +134,14 @@ function _block_rehash($theme = NULL) { $region = $block->get('region'); $status = $block->status(); // Disable blocks in invalid regions. - if (!empty($region) && $region != BlockInterface::BLOCK_REGION_NONE && !isset($regions[$region]) && $status) { + if (!empty($region) && $region !== BlockInterface::BLOCK_REGION_NONE && !isset($regions[$region]) && $status) { drupal_set_message(t('The block %info was assigned to the invalid region %region and has been disabled.', array('%info' => $block_id, '%region' => $region)), 'warning'); // Disabled modules are moved into the BlockInterface::BLOCK_REGION_NONE // later so no need to move the block to another region. $block->disable()->save(); } // Set region to none if not enabled. - if (!$status && $region != BlockInterface::BLOCK_REGION_NONE) { + if (!$status && $region !== BlockInterface::BLOCK_REGION_NONE) { $block->set('region', BlockInterface::BLOCK_REGION_NONE); $block->save(); } @@ -310,7 +310,7 @@ function block_user_role_delete($role) { function block_menu_delete(Menu $menu) { if (!$menu->isSyncing()) { foreach (Block::loadMultiple() as $block) { - if ($block->get('plugin') == 'system_menu_block:' . $menu->id()) { + if ($block->get('plugin') === 'system_menu_block:' . $menu->id()) { $block->delete(); } } diff --git a/core/modules/block/src/BlockAccessControlHandler.php b/core/modules/block/src/BlockAccessControlHandler.php index 8bfa365..c9e064a 100644 --- a/core/modules/block/src/BlockAccessControlHandler.php +++ b/core/modules/block/src/BlockAccessControlHandler.php @@ -24,7 +24,7 @@ class BlockAccessControlHandler extends EntityAccessControlHandler { */ protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { /** @var $entity \Drupal\block\BlockInterface */ - if ($operation != 'view') { + if ($operation !== 'view') { return parent::checkAccess($entity, $operation, $langcode, $account); } diff --git a/core/modules/block/src/BlockListBuilder.php b/core/modules/block/src/BlockListBuilder.php index e5da65d..608ab33 100644 --- a/core/modules/block/src/BlockListBuilder.php +++ b/core/modules/block/src/BlockListBuilder.php @@ -216,7 +216,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { ), ); $form['blocks'][$region]['title'] = array( - '#markup' => $region != BlockInterface::BLOCK_REGION_NONE ? $title : t('Disabled'), + '#markup' => $region !== BlockInterface::BLOCK_REGION_NONE ? $title : t('Disabled'), '#wrapper_attributes' => array( 'colspan' => 5, ), @@ -247,7 +247,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { 'class' => array('draggable'), ), ); - if ($placement && $placement == drupal_html_class($entity_id)) { + if ($placement && $placement === drupal_html_class($entity_id)) { $form['blocks'][$entity_id]['#attributes']['id'] = 'block-placed'; } @@ -404,7 +404,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $entity_values = $form_state->getValue(array('blocks', $entity_id)); $entity->set('weight', $entity_values['weight']); $entity->set('region', $entity_values['region']); - if ($entity->get('region') == BlockInterface::BLOCK_REGION_NONE) { + if ($entity->get('region') === BlockInterface::BLOCK_REGION_NONE) { $entity->disable(); } else { diff --git a/core/modules/block/src/Entity/Block.php b/core/modules/block/src/Entity/Block.php index ee977d0..f629ee1 100644 --- a/core/modules/block/src/Entity/Block.php +++ b/core/modules/block/src/Entity/Block.php @@ -136,7 +136,7 @@ public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) return $status; } // Sort by weight, unless disabled. - if ($a->get('region') != static::BLOCK_REGION_NONE) { + if ($a->get('region') !== static::BLOCK_REGION_NONE) { $weight = $a->get('weight') - $b->get('weight'); if ($weight) { return $weight; diff --git a/core/modules/block/src/EventSubscriber/NodeRouteContext.php b/core/modules/block/src/EventSubscriber/NodeRouteContext.php index c1bd2bf..20be6f4 100644 --- a/core/modules/block/src/EventSubscriber/NodeRouteContext.php +++ b/core/modules/block/src/EventSubscriber/NodeRouteContext.php @@ -45,7 +45,7 @@ protected function determineBlockContext() { } $this->addContext('node', $context); } - elseif ($this->routeMatch->getRouteName() == 'node.add') { + elseif ($this->routeMatch->getRouteName() === 'node.add') { $node_type = $this->routeMatch->getParameter('node_type'); $context = new Context(new ContextDefinition('entity:node')); $context->setContextValue(Node::create(array('type' => $node_type->id()))); diff --git a/core/modules/block/src/Plugin/Derivative/ThemeLocalTask.php b/core/modules/block/src/Plugin/Derivative/ThemeLocalTask.php index 849df45..2da4e74 100644 --- a/core/modules/block/src/Plugin/Derivative/ThemeLocalTask.php +++ b/core/modules/block/src/Plugin/Derivative/ThemeLocalTask.php @@ -68,7 +68,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { $this->derivatives[$theme_name]['route_parameters'] = array('theme' => $theme_name); } // Default task! - if ($default_theme == $theme_name) { + if ($default_theme === $theme_name) { $this->derivatives[$theme_name]['route_name'] = 'block.admin_display'; // Emulate default logic because without the base plugin id we can't // change the base_route. diff --git a/core/modules/block/src/Tests/BlockRenderOrderTest.php b/core/modules/block/src/Tests/BlockRenderOrderTest.php index b21d5f0..e149853 100644 --- a/core/modules/block/src/Tests/BlockRenderOrderTest.php +++ b/core/modules/block/src/Tests/BlockRenderOrderTest.php @@ -73,7 +73,7 @@ function testBlockRenderOrder() { foreach ($controller->loadMultiple() as $return_block) { $id = $return_block->get('id'); if ($return_block_weight = $return_block->get('weight')) { - $this->assertTrue($test_blocks[$id]['weight'] == $return_block_weight, 'Block weight is set as "' . $return_block_weight . '" for ' . $id . ' block.'); + $this->assertTrue($test_blocks[$id]['weight'] === $return_block_weight, 'Block weight is set as "' . $return_block_weight . '" for ' . $id . ' block.'); $position[$id] = strpos($test_content, drupal_html_class('block-' . $test_blocks[$id]['id'])); } } diff --git a/core/modules/block/src/Tests/BlockUiTest.php b/core/modules/block/src/Tests/BlockUiTest.php index ebe5712..d7908c6 100644 --- a/core/modules/block/src/Tests/BlockUiTest.php +++ b/core/modules/block/src/Tests/BlockUiTest.php @@ -101,7 +101,7 @@ function testBlockAdminUiPage() { $block = $this->blocks[$delta]; $label = $block->label(); $element = $this->xpath('//*[@id="blocks"]/tbody/tr[' . $values['tr'] . ']/td[1]/text()'); - $this->assertTrue((string) $element[0] == $label, 'The "' . $label . '" block title is set inside the ' . $values['settings']['region'] . ' region.'); + $this->assertTrue((string) $element[0] === $label, 'The "' . $label . '" block title is set inside the ' . $values['settings']['region'] . ' region.'); // Look for a test block region select form element. $this->assertField('blocks[' . $values['settings']['id'] . '][region]', 'The block "' . $values['label'] . '" has a region assignment field.'); // Move the test block to the header region. diff --git a/core/modules/block/src/Tests/BlockViewBuilderTest.php b/core/modules/block/src/Tests/BlockViewBuilderTest.php index 8c9fb13..35eac0c 100644 --- a/core/modules/block/src/Tests/BlockViewBuilderTest.php +++ b/core/modules/block/src/Tests/BlockViewBuilderTest.php @@ -157,7 +157,7 @@ protected function verifyRenderCacheHandling() { // Test that entities with caching disabled do not generate a cache entry. $build = $this->getBlockRenderArray(); - $this->assertTrue(isset($build['#cache']) && array_keys($build['#cache']) == array('tags'), 'The render array element of uncacheable blocks is not cached, but does have cache tags set.'); + $this->assertTrue(isset($build['#cache']) && array_keys($build['#cache']) === array('tags'), 'The render array element of uncacheable blocks is not cached, but does have cache tags set.'); // Enable block caching. $this->setBlockCacheConfig(array( diff --git a/core/modules/block/src/Tests/NewDefaultThemeBlocksTest.php b/core/modules/block/src/Tests/NewDefaultThemeBlocksTest.php index 9a6642c..3383172 100644 --- a/core/modules/block/src/Tests/NewDefaultThemeBlocksTest.php +++ b/core/modules/block/src/Tests/NewDefaultThemeBlocksTest.php @@ -44,7 +44,7 @@ function testNewDefaultThemeBlocks() { // Enable a different theme. $new_theme = 'bartik'; - $this->assertFalse($new_theme == $default_theme, 'The new theme is different from the previous default theme.'); + $this->assertFalse($new_theme === $default_theme, 'The new theme is different from the previous default theme.'); theme_enable(array($new_theme)); \Drupal::config('system.theme') ->set('default', $new_theme) @@ -57,7 +57,7 @@ function testNewDefaultThemeBlocks() { $new_blocks = $this->container->get('entity.query')->get('block') ->condition('theme', $new_theme) ->execute(); - $this->assertTrue(count($default_block_names) == count($new_blocks), 'The new default theme has the same number of blocks as the previous theme.'); + $this->assertTrue(count($default_block_names) === count($new_blocks), 'The new default theme has the same number of blocks as the previous theme.'); foreach ($default_block_names as $default_block_name) { // Remove the matching block from the list of blocks in the new theme. // E.g., if the old theme has block.block.stark_admin, diff --git a/core/modules/block/src/Theme/AdminDemoNegotiator.php b/core/modules/block/src/Theme/AdminDemoNegotiator.php index 50d88c3..13094ae 100644 --- a/core/modules/block/src/Theme/AdminDemoNegotiator.php +++ b/core/modules/block/src/Theme/AdminDemoNegotiator.php @@ -19,7 +19,7 @@ class AdminDemoNegotiator implements ThemeNegotiatorInterface { * {@inheritdoc} */ public function applies(RouteMatchInterface $route_match) { - return $route_match->getRouteName() == 'block.admin_demo'; + return $route_match->getRouteName() === 'block.admin_demo'; } /** diff --git a/core/modules/block_content/src/BlockContentForm.php b/core/modules/block_content/src/BlockContentForm.php index df923ee..1a30a03 100644 --- a/core/modules/block_content/src/BlockContentForm.php +++ b/core/modules/block_content/src/BlockContentForm.php @@ -95,7 +95,7 @@ public function form(array $form, FormStateInterface $form_state) { $block = $this->entity; $account = $this->currentUser(); - if ($this->operation == 'edit') { + if ($this->operation === 'edit') { $form['#title'] = $this->t('Edit custom block %label', array('%label' => $block->label())); } // Override the default CSS class name, since the user-defined custom block diff --git a/core/modules/block_content/src/BlockContentTypeForm.php b/core/modules/block_content/src/BlockContentTypeForm.php index e34bbc3..57dac62 100644 --- a/core/modules/block_content/src/BlockContentTypeForm.php +++ b/core/modules/block_content/src/BlockContentTypeForm.php @@ -94,7 +94,7 @@ public function save(array $form, FormStateInterface $form_state) { $edit_link = \Drupal::linkGenerator()->generateFromUrl($this->t('Edit'), $this->entity->urlInfo()); $logger = $this->logger('block_content'); - if ($status == SAVED_UPDATED) { + if ($status === SAVED_UPDATED) { drupal_set_message(t('Custom block type %label has been updated.', array('%label' => $block_type->label()))); $logger->notice('Custom block type %label has been updated.', array('%label' => $block_type->label(), 'link' => $edit_link)); } diff --git a/core/modules/block_content/src/BlockContentViewBuilder.php b/core/modules/block_content/src/BlockContentViewBuilder.php index ff2a853..fa471bc 100644 --- a/core/modules/block_content/src/BlockContentViewBuilder.php +++ b/core/modules/block_content/src/BlockContentViewBuilder.php @@ -33,7 +33,7 @@ protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langco protected function alterBuild(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode, $langcode = NULL) { parent::alterBuild($build, $entity, $display, $view_mode, $langcode); // Add contextual links for this custom block. - if (!$entity->isNew() && $view_mode == 'full') { + if (!$entity->isNew() && $view_mode === 'full') { $build['#contextual_links']['block_content'] = array( 'route_parameters' => array('block_content' => $entity->id()), 'metadata' => array('changed' => $entity->getChangedTime()), diff --git a/core/modules/block_content/src/Controller/BlockContentController.php b/core/modules/block_content/src/Controller/BlockContentController.php index 4716bba..ea5d6ef 100644 --- a/core/modules/block_content/src/Controller/BlockContentController.php +++ b/core/modules/block_content/src/Controller/BlockContentController.php @@ -67,7 +67,7 @@ public function __construct(EntityStorageInterface $block_content_storage, Entit */ public function add(Request $request) { $types = $this->blockContentTypeStorage->loadMultiple(); - if ($types && count($types) == 1) { + if ($types && count($types) === 1) { $type = reset($types); return $this->addForm($type, $request); } diff --git a/core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php b/core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php index e22425e..a73603b 100644 --- a/core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php +++ b/core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php @@ -26,11 +26,11 @@ public function getOptions(Request $request) { $options['query']['theme'] = $request->attributes->get('theme'); } // Adds a destination on custom block listing. - if ($request->attributes->get(RouteObjectInterface::ROUTE_NAME) == 'block_content.list') { + if ($request->attributes->get(RouteObjectInterface::ROUTE_NAME) === 'block_content.list') { $options['query']['destination'] = 'admin/structure/block/block-content'; } // Adds a destination on custom block listing. - if ($request->attributes->get(RouteObjectInterface::ROUTE_NAME) == 'block_content.list') { + if ($request->attributes->get(RouteObjectInterface::ROUTE_NAME) === 'block_content.list') { $options['query']['destination'] = 'admin/structure/block/block-content'; } return $options; diff --git a/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php b/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php index aec6f69..59cc41d 100644 --- a/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php +++ b/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php @@ -90,7 +90,7 @@ protected function getNewEntityValues($langcode) { protected function getEditValues($values, $langcode, $new = FALSE) { $edit = parent::getEditValues($values, $langcode, $new); foreach ($edit as $property => $value) { - if ($property == 'info') { + if ($property === 'info') { $edit['info[0][value]'] = $value; unset($edit[$property]); } diff --git a/core/modules/block_content/src/Tests/BlockContentTypeTest.php b/core/modules/block_content/src/Tests/BlockContentTypeTest.php index b36d009..e720025 100644 --- a/core/modules/block_content/src/Tests/BlockContentTypeTest.php +++ b/core/modules/block_content/src/Tests/BlockContentTypeTest.php @@ -156,12 +156,12 @@ public function testsBlockContentAddTypes() { foreach ($themes as $theme) { // Test that adding a block from the 'place blocks' form sends you to the // block configure form. - $path = $theme == $default_theme ? 'admin/structure/block' : "admin/structure/block/list/$theme"; + $path = $theme === $default_theme ? 'admin/structure/block' : "admin/structure/block/list/$theme"; $this->drupalGet($path); $this->clickLink(t('Add custom block')); // The seven theme has markup inside the link, we cannot use clickLink(). - if ($default_theme == 'seven') { - $options = $theme != $default_theme ? array('query' => array('theme' => $theme)) : array(); + if ($default_theme === 'seven') { + $options = $theme !== $default_theme ? array('query' => array('theme' => $theme)) : array(); $this->assertLinkByHref(url('block/add/foo', $options)); $this->drupalGet('block/add/foo', $options); } diff --git a/core/modules/block_content/tests/modules/block_content_test/block_content_test.module b/core/modules/block_content/tests/modules/block_content_test/block_content_test.module index d714cb2..7a2074a 100644 --- a/core/modules/block_content/tests/modules/block_content_test/block_content_test.module +++ b/core/modules/block_content/tests/modules/block_content_test/block_content_test.module @@ -24,12 +24,12 @@ function block_content_test_block_content_view(array &$build, BlockContent $bloc * Implements hook_block_content_presave(). */ function block_content_test_block_content_presave(BlockContent $block_content) { - if ($block_content->label() == 'testing_block_content_presave') { + if ($block_content->label() === 'testing_block_content_presave') { $block_content->setInfo($block_content->label() .'_presave'); } // Determine changes. - if (!empty($block_content->original) && $block_content->original->label() == 'test_changes') { - if ($block_content->original->label() != $block_content->label()) { + if (!empty($block_content->original) && $block_content->original->label() === 'test_changes') { + if ($block_content->original->label() !== $block_content->label()) { $block_content->setInfo($block_content->label() .'_presave'); // Drupal 1.0 release. $block_content->changed = 979534800; @@ -42,8 +42,8 @@ function block_content_test_block_content_presave(BlockContent $block_content) { */ function block_content_test_block_content_update(BlockContent $block_content) { // Determine changes on update. - if (!empty($block_content->original) && $block_content->original->label() == 'test_changes') { - if ($block_content->original->label() != $block_content->label()) { + if (!empty($block_content->original) && $block_content->original->label() === 'test_changes') { + if ($block_content->original->label() !== $block_content->label()) { $block_content->setInfo($block_content->label() .'_update'); } } @@ -58,11 +58,11 @@ function block_content_test_block_content_update(BlockContent $block_content) { */ function block_content_test_block_content_insert(BlockContent $block_content) { // Set the block_content title to the block_content ID and save. - if ($block_content->label() == 'new') { + if ($block_content->label() === 'new') { $block_content->setInfo('BlockContent ' . $block_content->id()); $block_content->save(); } - if ($block_content->label() == 'fail_creation') { + if ($block_content->label() === 'fail_creation') { throw new Exception('Test exception for rollback.'); } } diff --git a/core/modules/book/book.install b/core/modules/book/book.install index 76ddc81..4de44da 100644 --- a/core/modules/book/book.install +++ b/core/modules/book/book.install @@ -55,7 +55,7 @@ function book_schema() { 'default' => 0, ), 'depth' => array( - 'description' => 'The depth relative to the top level. A link with pid == 0 will have depth == 1.', + 'description' => 'The depth relative to the top level. A link with pid === 0 will have depth === 1.', 'type' => 'int', 'not null' => TRUE, 'default' => 0, diff --git a/core/modules/book/book.module b/core/modules/book/book.module index e67b279..a6d19a6 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -118,11 +118,11 @@ function book_entity_type_build(array &$entity_types) { * Implements hook_node_links_alter(). */ function book_node_links_alter(array &$node_links, NodeInterface $node, array &$context) { - if ($context['view_mode'] != 'rss') { + if ($context['view_mode'] !== 'rss') { $account = \Drupal::currentUser(); if (isset($node->book['depth'])) { - if ($context['view_mode'] == 'full' && node_is_page($node)) { + if ($context['view_mode'] === 'full' && node_is_page($node)) { $child_type = \Drupal::config('book.settings')->get('child_type'); $access_control_handler = \Drupal::entityManager()->getAccessControlHandler('node'); if (($account->hasPermission('add content to books') || $account->hasPermission('administer book outlines')) && $access_control_handler->createAccess($child_type) && $node->isPublished() && $node->book['depth'] < BookManager::BOOK_MAX_DEPTH) { @@ -253,7 +253,7 @@ function book_node_load($nodes) { * Implements hook_ENTITY_TYPE_view() for node entities. */ function book_node_view(array &$build, EntityInterface $node, EntityViewDisplayInterface $display, $view_mode) { - if ($view_mode == 'full') { + if ($view_mode === 'full') { if (!empty($node->book['bid']) && empty($node->in_preview)) { $book_navigation = array( '#theme' => 'book_navigation', '#book_link' => $node->book); $build['book_navigation'] = array( @@ -488,7 +488,7 @@ function template_preprocess_book_export_html(&$variables) { $variables['title'] = String::checkPlain($variables['title']); $variables['base_url'] = $base_url; $variables['language'] = $language_interface; - $variables['language_rtl'] = ($language_interface->direction == LanguageInterface::DIRECTION_RTL); + $variables['language_rtl'] = ($language_interface->direction === LanguageInterface::DIRECTION_RTL); $variables['head'] = drupal_get_html_head(); // HTML element attributes. @@ -563,7 +563,7 @@ function book_type_is_allowed($type) { * node type is changed. */ function book_node_type_update(NodeTypeInterface $type) { - if ($type->getOriginalId() != $type->id()) { + if ($type->getOriginalId() !== $type->id()) { $config = \Drupal::config('book.settings'); // Update the list of node types that are allowed to be added to books. $allowed_types = $config->get('allowed_types'); @@ -578,7 +578,7 @@ function book_node_type_update(NodeTypeInterface $type) { } // Update the setting for the "Add child page" link. - if ($config->get('child_type') == $type->getOriginalId()) { + if ($config->get('child_type') === $type->getOriginalId()) { $config->set('child_type', $type->id()); } $config->save(); diff --git a/core/modules/book/src/BookManager.php b/core/modules/book/src/BookManager.php index ad906ed..5ef42ee 100644 --- a/core/modules/book/src/BookManager.php +++ b/core/modules/book/src/BookManager.php @@ -210,7 +210,7 @@ public function addFormElements(array $form, FormStateInterface $form_state, Nod ); $options = array(); $nid = !$node->isNew() ? $node->id() : 'new'; - if ($node->id() && ($nid == $node->book['original_bid']) && ($node->book['parent_depth_limit'] == 0)) { + if ($node->id() && ($nid === $node->book['original_bid']) && ($node->book['parent_depth_limit'] === 0)) { // This is the top level node in a maximum depth book and thus cannot be moved. $options[$node->id()] = $node->label(); } @@ -220,7 +220,7 @@ public function addFormElements(array $form, FormStateInterface $form_state, Nod } } - if ($account->hasPermission('create new books') && ($nid == 'new' || ($nid != $node->book['original_bid']))) { + if ($account->hasPermission('create new books') && ($nid === 'new' || ($nid !== $node->book['original_bid']))) { // The node can become a new book, if it is not one already. $options = array($nid => $this->t('- Create a new book -')) + $options; } @@ -253,7 +253,7 @@ public function addFormElements(array $form, FormStateInterface $form_state, Nod * {@inheritdoc} */ public function checkNodeIsRemovable(NodeInterface $node) { - return (!empty($node->book['bid']) && (($node->book['bid'] != $node->id()) || !$node->book['has_children'])); + return (!empty($node->book['bid']) && (($node->book['bid'] !== $node->id()) || !$node->book['has_children'])); } /** @@ -264,7 +264,7 @@ public function updateOutline(NodeInterface $node) { return FALSE; } - if (!empty($node->book['bid']) && $node->book['bid'] == 'new') { + if (!empty($node->book['bid']) && $node->book['bid'] === 'new') { // New nodes that are their own book. $node->book['bid'] = $node->id(); } @@ -276,7 +276,7 @@ public function updateOutline(NodeInterface $node) { $node->book['nid'] = $node->id(); // Create a new book from a node. - if ($node->book['bid'] == $node->id()) { + if ($node->book['bid'] === $node->id()) { $node->book['pid'] = 0; } elseif ($node->book['pid'] < 0) { @@ -293,7 +293,7 @@ public function updateOutline(NodeInterface $node) { */ public function getBookParents(array $item, array $parent = array()) { $book = array(); - if ($item['pid'] == 0) { + if ($item['pid'] === 0) { $book['p1'] = $item['nid']; for ($i = 2; $i <= static::BOOK_MAX_DEPTH; $i++) { $parent_property = "p$i"; @@ -439,7 +439,7 @@ public function deleteFromBook($nid) { $this->connection->delete('book') ->condition('nid', $nid) ->execute(); - if ($nid == $original['bid']) { + if ($nid === $original['bid']) { // Handle deletion of a top-level post. $result = $this->connection->query("SELECT * FROM {book} WHERE pid = :nid", array( ':nid' => $nid @@ -522,10 +522,10 @@ public function bookTreeOutput(array $tree) { $num_items = count($items); foreach ($items as $i => $data) { $class = array(); - if ($i == 0) { + if ($i === 0) { $class[] = 'first'; } - if ($i == $num_items - 1) { + if ($i === $num_items - 1) { $class[] = 'last'; } // Set a class for the
  • -tag. Since $data['below'] may contain local @@ -640,7 +640,7 @@ protected function doBookTreeBuild($bid, array $parameters = array()) { $query->condition('pid', $parameters['expanded'], 'IN'); } $min_depth = (isset($parameters['min_depth']) ? $parameters['min_depth'] : 1); - if ($min_depth != 1) { + if ($min_depth !== 1) { $query->condition('depth', $min_depth, '>='); } if (isset($parameters['max_depth'])) { @@ -771,15 +771,15 @@ public function saveBookLink(array $link, $new) { // Using the Book ID as the key keeps this unique. $affected_bids[$original['bid']] = $original['bid']; // Handle links that are moving. - if ($link['bid'] != $original['bid'] || $link['pid'] != $original['pid']) { + if ($link['bid'] !== $original['bid'] || $link['pid'] !== $original['pid']) { // Update the bid for this page and all children. - if ($link['pid'] == 0) { + if ($link['pid'] === 0) { $link['depth'] = 1; $parent = array(); } // In case the form did not specify a proper PID we use the BID as new // parent. - elseif (($parent_link = $this->loadBookLink($link['pid'], FALSE)) && $parent_link['bid'] != $link['bid']) { + elseif (($parent_link = $this->loadBookLink($link['pid'], FALSE)) && $parent_link['bid'] !== $link['bid']) { $link['pid'] = $link['bid']; $parent = $this->loadBookLink($link['pid'], FALSE); $link['depth'] = $parent['depth'] + 1; @@ -871,7 +871,7 @@ protected function moveChildren(array $link, array $original) { * or the parent was updated successfully), FALSE on failure. */ protected function updateParent(array $link) { - if ($link['pid'] == 0) { + if ($link['pid'] === 0) { // Nothing to update. return TRUE; } @@ -896,7 +896,7 @@ protected function updateParent(array $link) { * failure. */ protected function updateOriginalParent(array $original) { - if ($original['pid'] == 0) { + if ($original['pid'] === 0) { // There were no parents of this link. Nothing to update. return TRUE; } diff --git a/core/modules/book/src/BookOutline.php b/core/modules/book/src/BookOutline.php index 484fd2c..37db727 100644 --- a/core/modules/book/src/BookOutline.php +++ b/core/modules/book/src/BookOutline.php @@ -41,7 +41,7 @@ public function __construct(BookManagerInterface $book_manager) { */ public function prevLink(array $book_link) { // If the parent is zero, we are at the start of a book. - if ($book_link['pid'] == 0) { + if ($book_link['pid'] === 0) { return NULL; } // Assigning the array to $flat resets the array pointer for use with each(). @@ -50,11 +50,11 @@ public function prevLink(array $book_link) { do { $prev = $curr; list($key, $curr) = each($flat); - } while ($key && $key != $book_link['nid']); + } while ($key && $key !== $book_link['nid']); - if ($key == $book_link['nid']) { + if ($key === $book_link['nid']) { // The previous page in the book may be a child of the previous visible link. - if ($prev['depth'] == $book_link['depth']) { + if ($prev['depth'] === $book_link['depth']) { // The subtree will have only one link at the top level - get its data. $tree = $this->bookManager->bookSubtreeData($prev); $data = array_shift($tree); @@ -87,9 +87,9 @@ public function nextLink(array $book_link) { $flat = $this->bookManager->bookTreeGetFlat($book_link); do { list($key,) = each($flat); - } while ($key && $key != $book_link['nid']); + } while ($key && $key !== $book_link['nid']); - if ($key == $book_link['nid']) { + if ($key === $book_link['nid']) { $next = current($flat); if ($next) { $this->bookManager->bookLinkTranslate($next); @@ -116,9 +116,9 @@ public function childrenLinks(array $book_link) { // Walk through the array until we find the current page. do { $link = array_shift($flat); - } while ($link && ($link['nid'] != $book_link['nid'])); + } while ($link && ($link['nid'] !== $book_link['nid'])); // Continue though the array and collect the links whose parent is this page. - while (($link = array_shift($flat)) && $link['pid'] == $book_link['nid']) { + while (($link = array_shift($flat)) && $link['pid'] === $book_link['nid']) { $data['link'] = $link; $data['below'] = ''; $children[] = $data; diff --git a/core/modules/book/src/Form/BookAdminEditForm.php b/core/modules/book/src/Form/BookAdminEditForm.php index 9a2b754..afac6ea 100644 --- a/core/modules/book/src/Form/BookAdminEditForm.php +++ b/core/modules/book/src/Form/BookAdminEditForm.php @@ -85,7 +85,7 @@ public function buildForm(array $form, FormStateInterface $form_state, NodeInter * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) { - if ($form_state->getValue('tree_hash') != $form_state->getValue('tree_current_hash')) { + if ($form_state->getValue('tree_hash') !== $form_state->getValue('tree_current_hash')) { $form_state->setErrorByName('', $this->t('This book has been modified by another user, the changes could not be saved.')); } } @@ -106,7 +106,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $values = $form_state->getValue(array('table', $key)); // Update menu item if moved. - if ($row['pid']['#default_value'] != $values['pid'] || $row['weight']['#default_value'] != $values['weight']) { + if ($row['pid']['#default_value'] !== $values['pid'] || $row['weight']['#default_value'] !== $values['weight']) { $link = $this->bookManager->loadBookLink($values['nid'], FALSE); $link['weight'] = $values['weight']; $link['pid'] = $values['pid']; @@ -114,7 +114,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { } // Update the title if changed. - if ($row['title']['#default_value'] != $values['title']) { + if ($row['title']['#default_value'] !== $values['title']) { $node = $this->nodeStorage->load($values['nid']); $node->revision_log = $this->t('Title changed from %original to %current.', array('%original' => $node->label(), '%current' => $values['title'])); $node->title = $values['title']; diff --git a/core/modules/book/src/Plugin/Block/BookNavigationBlock.php b/core/modules/book/src/Plugin/Block/BookNavigationBlock.php index 441d052..f06059f 100644 --- a/core/modules/book/src/Plugin/Block/BookNavigationBlock.php +++ b/core/modules/book/src/Plugin/Block/BookNavigationBlock.php @@ -117,11 +117,11 @@ public function build() { if ($node = $this->requestStack->getCurrentRequest()->get('node')) { $current_bid = empty($node->book['bid']) ? 0 : $node->book['bid']; } - if ($this->configuration['block_mode'] == 'all pages') { + if ($this->configuration['block_mode'] === 'all pages') { $book_menus = array(); $pseudo_tree = array(0 => array('below' => FALSE)); foreach ($this->bookManager->getAllBooks() as $book_id => $book) { - if ($book['bid'] == $current_bid) { + if ($book['bid'] === $current_bid) { // If the current page is a node associated with a book, the menu // needs to be retrieved. $data = $this->bookManager->bookTreeAllData($node->book['bid'], $node->book); diff --git a/core/modules/breakpoint/src/BreakpointManager.php b/core/modules/breakpoint/src/BreakpointManager.php index 757f2cf..0053e7d 100644 --- a/core/modules/breakpoint/src/BreakpointManager.php +++ b/core/modules/breakpoint/src/BreakpointManager.php @@ -171,7 +171,7 @@ public function getBreakpointsByGroup($group) { else { $breakpoints = array(); foreach ($this->getDefinitions() as $plugin_id => $plugin_definition) { - if ($plugin_definition['group'] == $group) { + if ($plugin_definition['group'] === $group) { $breakpoints[$plugin_id] = $plugin_definition; } } diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php index 02049b6..e0a6edb 100644 --- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php +++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php @@ -326,7 +326,7 @@ protected function generateFormatTagsSetting(Editor $editor) { foreach ($possible_format_tags as $tag) { $input = '<' . $tag . '>TEST'; $output = trim(check_markup($input, $editor->id())); - if ($input == $output) { + if ($input === $output) { $format_tags[] = $tag; } } diff --git a/core/modules/ckeditor/src/Tests/CKEditorTest.php b/core/modules/ckeditor/src/Tests/CKEditorTest.php index 7041583..e888136 100644 --- a/core/modules/ckeditor/src/Tests/CKEditorTest.php +++ b/core/modules/ckeditor/src/Tests/CKEditorTest.php @@ -347,15 +347,15 @@ function testLanguages() { $langcodes = $this->ckeditor->getLangcodes(); // Language codes transformed with browser mappings. - $this->assertTrue($langcodes['pt-pt'] == 'pt', '"pt" properly resolved'); - $this->assertTrue($langcodes['zh-hans'] == 'zh-cn', '"zh-hans" properly resolved'); + $this->assertTrue($langcodes['pt-pt'] === 'pt', '"pt" properly resolved'); + $this->assertTrue($langcodes['zh-hans'] === 'zh-cn', '"zh-hans" properly resolved'); // Language code both in Drupal and CKEditor. - $this->assertTrue($langcodes['gl'] == 'gl', '"gl" properly resolved'); + $this->assertTrue($langcodes['gl'] === 'gl', '"gl" properly resolved'); // Language codes only in CKEditor. - $this->assertTrue($langcodes['en-au'] == 'en-au', '"en-au" properly resolved'); - $this->assertTrue($langcodes['sr-latn'] == 'sr-latn', '"sr-latn" properly resolved'); + $this->assertTrue($langcodes['en-au'] === 'en-au', '"en-au" properly resolved'); + $this->assertTrue($langcodes['sr-latn'] === 'sr-latn', '"sr-latn" properly resolved'); } /** diff --git a/core/modules/color/color.install b/core/modules/color/color.install index c3f9a74..83f1f61 100644 --- a/core/modules/color/color.install +++ b/core/modules/color/color.install @@ -11,7 +11,7 @@ function color_requirements($phase) { $requirements = array(); - if ($phase == 'runtime') { + if ($phase === 'runtime') { // Check for the PHP GD library. if (function_exists('imagegd2')) { $info = gd_info(); diff --git a/core/modules/color/color.module b/core/modules/color/color.module index a0c0896..0dbca90 100644 --- a/core/modules/color/color.module +++ b/core/modules/color/color.module @@ -83,7 +83,7 @@ function color_css_alter(&$css) { foreach ($color_paths as $color_path) { // Color module currently requires unique file names to be used, // which allows us to compare different file paths. - if (drupal_basename($old_path) == drupal_basename($color_path)) { + if (drupal_basename($old_path) === drupal_basename($color_path)) { // Replace the path to the new css file. // This keeps the order of the stylesheets intact. $css[drupal_basename($old_path)]['data'] = $color_path; @@ -186,7 +186,7 @@ function color_scheme_form($complete_form, FormStateInterface $form_state, $them // Note: we use the original theme when the default scheme is chosen. $current_scheme = \Drupal::config('color.theme.' . $theme)->get('palette'); foreach ($schemes as $key => $scheme) { - if ($current_scheme == $scheme) { + if ($current_scheme === $scheme) { $scheme_name = $key; break; } @@ -360,7 +360,7 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) { // Resolve palette. $palette = $form_state->getValue('palette'); - if ($form_state->getValue('scheme') != '') { + if ($form_state->getValue('scheme') !== '') { foreach ($palette as $key => $color) { if (isset($info['schemes'][$form_state->getValue('scheme')]['colors'][$key])) { $palette[$key] = $info['schemes'][$form_state->getValue('scheme')]['colors'][$key]; @@ -403,7 +403,7 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) { } // No change in color config, use the standard theme from color.inc. - if (implode(',', color_get_palette($theme, TRUE)) == implode(',', $palette)) { + if (implode(',', color_get_palette($theme, TRUE)) === implode(',', $palette)) { $config->delete(); return; } @@ -581,7 +581,7 @@ function _color_render_images($theme, &$info, &$paths, $palette) { // Render gradients. foreach ($info['gradients'] as $gradient) { // Get direction of the gradient. - if (isset($gradient['direction']) && $gradient['direction'] == 'horizontal') { + if (isset($gradient['direction']) && $gradient['direction'] === 'horizontal') { // Horizontal gradient. for ($x = 0; $x < $gradient['dimension'][2]; $x++) { $color = _color_blend($target, $palette[$gradient['colors'][0]], $palette[$gradient['colors'][1]], $x / ($gradient['dimension'][2] - 1)); @@ -610,7 +610,7 @@ function _color_render_images($theme, &$info, &$paths, $palette) { $image = drupal_realpath($paths['target'] . $base); // Cut out slice. - if ($file == 'screenshot.png') { + if ($file === 'screenshot.png') { $slice = imagecreatetruecolor(150, 90); imagecopyresampled($slice, $target, 0, 0, $x, $y, 150, 90, $width, $height); \Drupal::config('color.theme.' . $theme) @@ -644,8 +644,8 @@ function _color_render_images($theme, &$info, &$paths, $palette) { * Note: this function is significantly different from the JS version, as it * is written to match the blended images perfectly. * - * Constraint: if (ref2 == target + (ref1 - target) * delta) for some fraction - * delta then (return == target + (given - target) * delta). + * Constraint: if (ref2 === target + (ref1 - target) * delta) for some fraction + * delta then (return === target + (given - target) * delta). * * Loose constraint: Preserve relative positions in saturation and luminance * space. @@ -723,7 +723,7 @@ function _color_blend($img, $hex1, $hex2, $alpha) { * Converts a hex color into an RGB triplet. */ function _color_unpack($hex, $normalize = FALSE) { - if (strlen($hex) == 4) { + if (strlen($hex) === 4) { $hex = $hex[1] . $hex[1] . $hex[2] . $hex[2] . $hex[3] . $hex[3]; } $c = hexdec($hex); @@ -794,9 +794,9 @@ function _color_rgb2hsl($rgb) { $h = 0; if ($delta > 0) { - if ($max == $r && $max != $g) $h += ($g - $b) / $delta; - if ($max == $g && $max != $b) $h += (2 + ($b - $r) / $delta); - if ($max == $b && $max != $r) $h += (4 + ($r - $g) / $delta); + if ($max === $r && $max !== $g) $h += ($g - $b) / $delta; + if ($max === $g && $max !== $b) $h += (2 + ($b - $r) / $delta); + if ($max === $b && $max !== $r) $h += (4 + ($r - $g) / $delta); $h /= 6; } diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index dbe3bee..fd313d2 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -142,7 +142,7 @@ function comment_theme() { * Implements hook_ENTITY_TYPE_create() for 'field_instance_config'. */ function comment_field_instance_config_create(FieldInstanceConfigInterface $instance) { - if ($instance->getType() == 'comment' && !$instance->isSyncing()) { + if ($instance->getType() === 'comment' && !$instance->isSyncing()) { // Assign default values for the field instance. if (!isset($instance->default_value)) { $instance->default_value = array(); @@ -163,7 +163,7 @@ function comment_field_instance_config_create(FieldInstanceConfigInterface $inst * Implements hook_ENTITY_TYPE_update() for 'field_instance_config'. */ function comment_field_instance_config_update(FieldInstanceConfigInterface $instance) { - if ($instance->getType() == 'comment') { + if ($instance->getType() === 'comment') { // Comment field settings also affects the rendering of *comment* entities, // not only the *commented* entities. \Drupal::entityManager()->getViewBuilder('comment')->resetCache(); @@ -174,7 +174,7 @@ function comment_field_instance_config_update(FieldInstanceConfigInterface $inst * Implements hook_ENTITY_TYPE_insert() for 'field_storage_config'. */ function comment_field_storage_config_insert(FieldStorageConfigInterface $field_storage) { - if ($field_storage->getType() == 'comment') { + if ($field_storage->getType() === 'comment') { // Check that the target entity type uses an integer ID. $entity_type_id = $field_storage->getTargetEntityTypeId(); if (!_comment_entity_uses_integer_id($entity_type_id)) { @@ -187,7 +187,7 @@ function comment_field_storage_config_insert(FieldStorageConfigInterface $field_ * Implements hook_ENTITY_TYPE_delete() for 'field_instance_config'. */ function comment_field_instance_config_delete(FieldInstanceConfigInterface $instance) { - if ($instance->getType() == 'comment') { + if ($instance->getType() === 'comment') { // Delete all comments that used by the entity bundle. $entity_query = \Drupal::entityQuery('comment'); $entity_query->condition('entity_type', $instance->getEntityTypeId()); @@ -344,7 +344,7 @@ function comment_view_multiple($comments, $view_mode = 'full', $langcode = NULL) */ function comment_form_field_ui_field_overview_form_alter(&$form, FormStateInterface $form_state) { $request = \Drupal::request(); - if ($form['#entity_type'] == 'comment' && $request->attributes->has('commented_entity_type')) { + if ($form['#entity_type'] === 'comment' && $request->attributes->has('commented_entity_type')) { $form['#title'] = \Drupal::service('comment.manager')->getFieldUIPageTitle($request->attributes->get('commented_entity_type'), $request->attributes->get('field_name')); } $entity_type_id = $form['#entity_type']; @@ -359,7 +359,7 @@ function comment_form_field_ui_field_overview_form_alter(&$form, FormStateInterf */ function comment_form_field_ui_form_display_overview_form_alter(&$form, FormStateInterface $form_state) { $request = \Drupal::request(); - if ($form['#entity_type'] == 'comment' && $request->attributes->has('commented_entity_type')) { + if ($form['#entity_type'] === 'comment' && $request->attributes->has('commented_entity_type')) { $form['#title'] = \Drupal::service('comment.manager')->getFieldUIPageTitle($request->attributes->get('commented_entity_type'), $request->attributes->get('field_name')); } } @@ -369,7 +369,7 @@ function comment_form_field_ui_form_display_overview_form_alter(&$form, FormStat */ function comment_form_field_ui_display_overview_form_alter(&$form, FormStateInterface $form_state) { $request = \Drupal::request(); - if ($form['#entity_type'] == 'comment' && $request->attributes->has('commented_entity_type')) { + if ($form['#entity_type'] === 'comment' && $request->attributes->has('commented_entity_type')) { $form['#title'] = \Drupal::service('comment.manager')->getFieldUIPageTitle($request->attributes->get('commented_entity_type'), $request->attributes->get('field_name')); } } @@ -378,7 +378,7 @@ function comment_form_field_ui_display_overview_form_alter(&$form, FormStateInte * Implements hook_form_FORM_ID_alter(). */ function comment_form_field_ui_field_storage_edit_form_alter(&$form, FormStateInterface $form_state) { - if ($form['#field']->getType() == 'comment') { + if ($form['#field']->getType() === 'comment') { // We only support posting one comment at the time so it doesn't make sense // to let the site builder choose anything else. $form['field']['cardinality_container']['cardinality']['#options'] = array(1 => 1); @@ -491,7 +491,7 @@ function comment_node_update_index(EntityInterface $node, $langcode) { $authenticated_can_access = $roles[DRUPAL_AUTHENTICATED_RID]->hasPermission('access comments'); foreach ($roles as $rid => $role) { if ($role->hasPermission('search content') && !$role->hasPermission('access comments')) { - if ($rid == DRUPAL_AUTHENTICATED_RID || $rid == DRUPAL_ANONYMOUS_RID || !$authenticated_can_access) { + if ($rid === DRUPAL_AUTHENTICATED_RID || $rid === DRUPAL_ANONYMOUS_RID || !$authenticated_can_access) { $index_comments = FALSE; break; } @@ -549,8 +549,8 @@ function comment_node_search_result(EntityInterface $node) { } // Do not make a string if comments are hidden. $status = $node->get($field_name)->status; - if (\Drupal::currentUser()->hasPermission('access comments') && $status != CommentItemInterface::HIDDEN) { - if ($status == CommentItemInterface::OPEN) { + if (\Drupal::currentUser()->hasPermission('access comments') && $status !== CommentItemInterface::HIDDEN) { + if ($status === CommentItemInterface::OPEN) { // At least one comment field is open. $open = TRUE; } @@ -674,7 +674,7 @@ function comment_preview(CommentInterface $comment, FormStateInterface $form_sta * Implements hook_preprocess_HOOK() for block templates. */ function comment_preprocess_block(&$variables) { - if ($variables['configuration']['provider'] == 'comment') { + if ($variables['configuration']['provider'] === 'comment') { $variables['attributes']['role'] = 'navigation'; } } @@ -730,7 +730,7 @@ function template_preprocess_comment(&$variables) { $variables['new_indicator_timestamp'] = $comment->getChangedTime(); $variables['created'] = format_date($comment->getCreatedTime()); // Avoid calling format_date() twice on the same timestamp. - if ($comment->getChangedTime() == $comment->getCreatedTime()) { + if ($comment->getChangedTime() === $comment->getCreatedTime()) { $variables['changed'] = $variables['created']; } else { @@ -781,7 +781,7 @@ function template_preprocess_comment(&$variables) { $variables['parent_author'] = drupal_render($username); $variables['parent_created'] = format_date($comment_parent->getCreatedTime()); // Avoid calling format_date() twice on the same timestamp. - if ($comment_parent->getChangedTime() == $comment_parent->getCreatedTime()) { + if ($comment_parent->getChangedTime() === $comment_parent->getCreatedTime()) { $variables['parent_changed'] = $variables['parent_created']; } else { @@ -822,7 +822,7 @@ function template_preprocess_comment(&$variables) { // Gather comment classes. $variables['attributes']['class'][] = 'comment'; // 'published' class is not needed, it is either 'preview' or 'unpublished'. - if ($variables['status'] != 'published') { + if ($variables['status'] !== 'published') { $variables['attributes']['class'][] = $variables['status']; } if (!$comment->getOwnerId()) { @@ -830,7 +830,7 @@ function template_preprocess_comment(&$variables) { } else { // @todo Use $entity->getAuthorId() after https://drupal.org/node/2078387 - if ($commented_entity instanceof EntityOwnerInterface && $comment->getOwnerId() == $commented_entity->getOwnerId()) { + if ($commented_entity instanceof EntityOwnerInterface && $comment->getOwnerId() === $commented_entity->getOwnerId()) { $variables['attributes']['class'][] = 'by-' . $commented_entity->getEntityTypeId() . '-author'; } } @@ -858,7 +858,7 @@ function template_preprocess_comment(&$variables) { */ function comment_preprocess_field(&$variables) { $element = $variables['element']; - if ($element['#field_type'] == 'comment') { + if ($element['#field_type'] === 'comment') { // Provide contextual information. $variables['comment_display_mode'] = $element[0]['#comment_display_mode']; $variables['comment_type'] = $element[0]['#comment_type']; diff --git a/core/modules/comment/comment.tokens.inc b/core/modules/comment/comment.tokens.inc index b34fdcb..93c3209 100644 --- a/core/modules/comment/comment.tokens.inc +++ b/core/modules/comment/comment.tokens.inc @@ -129,7 +129,7 @@ function comment_tokens($type, $tokens, array $data = array(), array $options = $replacements = array(); - if ($type == 'comment' && !empty($data['comment'])) { + if ($type === 'comment' && !empty($data['comment'])) { /** @var \Drupal\comment\CommentInterface $comment */ $comment = $data['comment']; @@ -206,7 +206,7 @@ function comment_tokens($type, $tokens, array $data = array(), array $options = // Support legacy comment node tokens, since tokens are embedded in // user data and can't be upgraded directly. // @todo Remove in Drupal 9, see https://drupal.org/node/2031901. - if ($comment->getCommentedEntityTypeId() == 'node') { + if ($comment->getCommentedEntityTypeId() === 'node') { $entity = $comment->getCommentedEntity(); $title = $entity->label(); $replacements[$original] = $sanitize ? Xss::filter($title) : $title; @@ -224,7 +224,7 @@ function comment_tokens($type, $tokens, array $data = array(), array $options = $replacements += $token_service->generate($comment->getCommentedEntityTypeId(), $entity_tokens, array($comment->getCommentedEntityTypeId() => $entity), $options); } - if (($node_tokens = $token_service->findwithPrefix($tokens, 'node')) && $comment->getCommentedEntityTypeId() == 'node') { + if (($node_tokens = $token_service->findwithPrefix($tokens, 'node')) && $comment->getCommentedEntityTypeId() === 'node') { $node = $comment->getCommentedEntity(); $replacements += $token_service->generate('node', $node_tokens, array('node' => $node), $options); } @@ -245,8 +245,8 @@ function comment_tokens($type, $tokens, array $data = array(), array $options = $replacements += $token_service->generate('user', $author_tokens, array('user' => $account), $options); } } - elseif (($type == 'entity' & !empty($data['entity'])) || - ($type == 'node' & !empty($data['node']))) { + elseif (($type === 'entity' & !empty($data['entity'])) || + ($type === 'node' & !empty($data['node']))) { /** @var $entity \Drupal\Core\Entity\ContentEntityInterface */ $entity = !empty($data['entity']) ? $data['entity'] : $data['node']; diff --git a/core/modules/comment/comment.views.inc b/core/modules/comment/comment.views.inc index a3d873b..244f2e5 100644 --- a/core/modules/comment/comment.views.inc +++ b/core/modules/comment/comment.views.inc @@ -22,7 +22,7 @@ function comment_views_data_alter(&$data) { // Provide a integration for each entity type except comment. foreach (\Drupal::entityManager()->getDefinitions() as $entity_type_id => $entity_type) { - if ($entity_type_id == 'comment' || !$entity_type->isFieldable() || !$entity_type->getBaseTable()) { + if ($entity_type_id === 'comment' || !$entity_type->isFieldable() || !$entity_type->getBaseTable()) { continue; } $fields = \Drupal::service('comment.manager')->getFields($entity_type_id); diff --git a/core/modules/comment/src/CommentAccessControlHandler.php b/core/modules/comment/src/CommentAccessControlHandler.php index a31f5d7..4827d5d 100644 --- a/core/modules/comment/src/CommentAccessControlHandler.php +++ b/core/modules/comment/src/CommentAccessControlHandler.php @@ -27,7 +27,7 @@ protected function checkAccess(EntityInterface $entity, $operation, $langcode, A if ($account->hasPermission('administer comments')) { $access = AccessResult::allowed()->cachePerRole(); - return ($operation != 'view') ? $access : $access->andIf($entity->getCommentedEntity()->access($operation, $account, TRUE)); + return ($operation !== 'view') ? $access : $access->andIf($entity->getCommentedEntity()->access($operation, $account, TRUE)); } switch ($operation) { @@ -36,7 +36,7 @@ protected function checkAccess(EntityInterface $entity, $operation, $langcode, A ->andIf($entity->getCommentedEntity()->access($operation, $account, TRUE)); case 'update': - return AccessResult::allowedIf($account->id() && $account->id() == $entity->getOwnerId() && $entity->isPublished() && $account->hasPermission('edit own comments'))->cachePerRole()->cachePerUser()->cacheUntilEntityChanges($entity); + return AccessResult::allowedIf($account->id() && $account->id() === $entity->getOwnerId() && $entity->isPublished() && $account->hasPermission('edit own comments'))->cachePerRole()->cachePerUser()->cacheUntilEntityChanges($entity); default: // No opinion. diff --git a/core/modules/comment/src/CommentBreadcrumbBuilder.php b/core/modules/comment/src/CommentBreadcrumbBuilder.php index 1ec574d..4855ca0 100644 --- a/core/modules/comment/src/CommentBreadcrumbBuilder.php +++ b/core/modules/comment/src/CommentBreadcrumbBuilder.php @@ -22,7 +22,7 @@ class CommentBreadcrumbBuilder implements BreadcrumbBuilderInterface { * {@inheritdoc} */ public function applies(RouteMatchInterface $route_match) { - return $route_match->getRouteName() == 'comment.reply' && $route_match->getParameter('entity'); + return $route_match->getRouteName() === 'comment.reply' && $route_match->getParameter('entity'); } /** diff --git a/core/modules/comment/src/CommentForm.php b/core/modules/comment/src/CommentForm.php index 2c99bf8..813884b 100644 --- a/core/modules/comment/src/CommentForm.php +++ b/core/modules/comment/src/CommentForm.php @@ -87,7 +87,7 @@ public function form(array $form, FormStateInterface $form_state) { $anonymous_contact = $field_definition->getSetting('anonymous'); $is_admin = $comment->id() && $this->currentUser->hasPermission('administer comments'); - if (!$this->currentUser->isAuthenticated() && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT) { + if (!$this->currentUser->isAuthenticated() && $anonymous_contact !== COMMENT_ANONYMOUS_MAYNOT_CONTACT) { $form['#attached']['library'][] = 'core/drupal.form'; $form['#attributes']['data-user-info-from-browser'] = TRUE; } @@ -142,7 +142,7 @@ public function form(array $form, FormStateInterface $form_state) { '#type' => 'textfield', '#title' => $this->t('Your name'), '#default_value' => $author, - '#required' => ($this->currentUser->isAnonymous() && $anonymous_contact == COMMENT_ANONYMOUS_MUST_CONTACT), + '#required' => ($this->currentUser->isAnonymous() && $anonymous_contact === COMMENT_ANONYMOUS_MUST_CONTACT), '#maxlength' => 60, '#size' => 30, ); @@ -175,11 +175,11 @@ public function form(array $form, FormStateInterface $form_state) { '#type' => 'email', '#title' => $this->t('Email'), '#default_value' => $comment->getAuthorEmail(), - '#required' => ($this->currentUser->isAnonymous() && $anonymous_contact == COMMENT_ANONYMOUS_MUST_CONTACT), + '#required' => ($this->currentUser->isAnonymous() && $anonymous_contact === COMMENT_ANONYMOUS_MUST_CONTACT), '#maxlength' => 64, '#size' => 30, '#description' => $this->t('The content of this field is kept private and will not be shown publicly.'), - '#access' => $is_admin || ($this->currentUser->isAnonymous() && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT), + '#access' => $is_admin || ($this->currentUser->isAnonymous() && $anonymous_contact !== COMMENT_ANONYMOUS_MAYNOT_CONTACT), ); $form['author']['homepage'] = array( @@ -188,7 +188,7 @@ public function form(array $form, FormStateInterface $form_state) { '#default_value' => $comment->getHomepage(), '#maxlength' => 255, '#size' => 30, - '#access' => $is_admin || ($this->currentUser->isAnonymous() && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT), + '#access' => $is_admin || ($this->currentUser->isAnonymous() && $anonymous_contact !== COMMENT_ANONYMOUS_MAYNOT_CONTACT), ); // Add administrative comment publishing options. @@ -239,12 +239,12 @@ protected function actions(array $form, FormStateInterface $form_state) { // Only show the save button if comment previews are optional or if we are // already previewing the submission. - $element['submit']['#access'] = ($comment->id() && $this->currentUser->hasPermission('administer comments')) || $preview_mode != DRUPAL_REQUIRED || $form_state->get('comment_preview'); + $element['submit']['#access'] = ($comment->id() && $this->currentUser->hasPermission('administer comments')) || $preview_mode !== DRUPAL_REQUIRED || $form_state->get('comment_preview'); $element['preview'] = array( '#type' => 'submit', '#value' => $this->t('Preview'), - '#access' => $preview_mode != DRUPAL_DISABLED, + '#access' => $preview_mode !== DRUPAL_DISABLED, '#validate' => array('::validate'), '#submit' => array('::submitForm', '::preview'), ); @@ -323,7 +323,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // Validate the comment's subject. If not specified, extract from comment // body. - if (trim($comment->getSubject()) == '') { + if (trim($comment->getSubject()) === '') { // The body may be in any format, so: // 1) Filter it into HTML // 2) Strip out all HTML tags @@ -332,7 +332,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $comment->setSubject(Unicode::truncate(trim(String::decodeEntities(strip_tags($comment_text))), 29, TRUE)); // Edge cases where the comment body is populated only by HTML tags will // require a default subject. - if ($comment->getSubject() == '') { + if ($comment->getSubject() === '') { $comment->setSubject($this->t('(No subject)')); } } @@ -365,7 +365,7 @@ public function save(array $form, FormStateInterface $form_state) { $uri = $entity->urlInfo(); $logger = $this->logger('content'); - if ($this->currentUser->hasPermission('post comments') && ($this->currentUser->hasPermission('administer comments') || $entity->{$field_name}->status == CommentItemInterface::OPEN)) { + if ($this->currentUser->hasPermission('post comments') && ($this->currentUser->hasPermission('administer comments') || $entity->{$field_name}->status === CommentItemInterface::OPEN)) { $comment->save(); $form_state->setValue('cid', $comment->id()); diff --git a/core/modules/comment/src/CommentLinkBuilder.php b/core/modules/comment/src/CommentLinkBuilder.php index b1864da..fd30ddd 100644 --- a/core/modules/comment/src/CommentLinkBuilder.php +++ b/core/modules/comment/src/CommentLinkBuilder.php @@ -69,7 +69,7 @@ public function __construct(AccountInterface $current_user, CommentManagerInterf public function buildCommentedEntityLinks(ContentEntityInterface $entity, array &$context) { $entity_links = array(); $view_mode = $context['view_mode']; - if ($view_mode == 'search_index' || $view_mode == 'search_result' || $view_mode == 'print') { + if ($view_mode === 'search_index' || $view_mode === 'search_result' || $view_mode === 'print') { // Do not add any links if the entity is displayed for: // - search indexing. // - constructing a search result excerpt. @@ -85,10 +85,10 @@ public function buildCommentedEntityLinks(ContentEntityInterface $entity, array } $links = array(); $commenting_status = $entity->get($field_name)->status; - if ($commenting_status != CommentItemInterface::HIDDEN) { + if ($commenting_status !== CommentItemInterface::HIDDEN) { // Entity has commenting status open or closed. $field_definition = $entity->getFieldDefinition($field_name); - if ($view_mode == 'rss') { + if ($view_mode === 'rss') { // Add a comments RSS element which is a URL to the comments of this // entity. $options = array( @@ -100,7 +100,7 @@ public function buildCommentedEntityLinks(ContentEntityInterface $entity, array 'value' => $entity->url('canonical', $options), ); } - elseif ($view_mode == 'teaser') { + elseif ($view_mode === 'teaser') { // Teaser view: display the number of comments that have been posted, // or a link to add new comments if the user has permission, the // entity is open to new comments, and there currently are none. @@ -126,7 +126,7 @@ public function buildCommentedEntityLinks(ContentEntityInterface $entity, array } } // Provide a link to new comment form. - if ($commenting_status == CommentItemInterface::OPEN) { + if ($commenting_status === CommentItemInterface::OPEN) { $comment_form_location = $field_definition->getSetting('form_location'); if ($this->currentUser->hasPermission('post comments')) { $links['comment-add'] = array( @@ -135,7 +135,7 @@ public function buildCommentedEntityLinks(ContentEntityInterface $entity, array 'attributes' => array('title' => $this->t('Add a new comment to this page.')), 'fragment' => 'comment-form', ); - if ($comment_form_location == CommentItemInterface::FORM_SEPARATE_PAGE) { + if ($comment_form_location === CommentItemInterface::FORM_SEPARATE_PAGE) { $links['comment-add']['route_name'] = 'comment.reply'; $links['comment-add']['route_parameters'] = array( 'entity_type' => $entity->getEntityTypeId(), @@ -159,18 +159,18 @@ public function buildCommentedEntityLinks(ContentEntityInterface $entity, array // Entity in other view modes: add a "post comment" link if the user // is allowed to post comments and if this entity is allowing new // comments. - if ($commenting_status == CommentItemInterface::OPEN) { + if ($commenting_status === CommentItemInterface::OPEN) { $comment_form_location = $field_definition->getSetting('form_location'); if ($this->currentUser->hasPermission('post comments')) { // Show the "post comment" link if the form is on another page, or // if there are existing comments that the link will skip past. - if ($comment_form_location == CommentItemInterface::FORM_SEPARATE_PAGE || (!empty($entity->get($field_name)->comment_count) && $this->currentUser->hasPermission('access comments'))) { + if ($comment_form_location === CommentItemInterface::FORM_SEPARATE_PAGE || (!empty($entity->get($field_name)->comment_count) && $this->currentUser->hasPermission('access comments'))) { $links['comment-add'] = array( 'title' => $this->t('Add new comment'), 'attributes' => array('title' => $this->t('Share your thoughts and opinions related to this posting.')), 'fragment' => 'comment-form', ); - if ($comment_form_location == CommentItemInterface::FORM_SEPARATE_PAGE) { + if ($comment_form_location === CommentItemInterface::FORM_SEPARATE_PAGE) { $links['comment-add']['route_name'] = 'comment.reply'; $links['comment-add']['route_parameters'] = array( 'entity_type' => $entity->getEntityTypeId(), @@ -199,7 +199,7 @@ public function buildCommentedEntityLinks(ContentEntityInterface $entity, array '#links' => $links, '#attributes' => array('class' => array('links', 'inline')), ); - if ($view_mode == 'teaser' && $this->moduleHandler->moduleExists('history') && $this->currentUser->isAuthenticated()) { + if ($view_mode === 'teaser' && $this->moduleHandler->moduleExists('history') && $this->currentUser->isAuthenticated()) { $entity_links['comment__' . $field_name]['#attached']['library'][] = 'comment/drupal.node-new-comments-link'; // Embed the metadata for the "X new comments" link (if any) on this diff --git a/core/modules/comment/src/CommentManager.php b/core/modules/comment/src/CommentManager.php index 5c76abb..d711968 100644 --- a/core/modules/comment/src/CommentManager.php +++ b/core/modules/comment/src/CommentManager.php @@ -273,14 +273,14 @@ public function forbiddenMessage(EntityInterface $entity, $field_name) { if ($this->authenticatedCanPostComments) { // We cannot use drupal_get_destination() because these links // sometimes appear on /node and taxonomy listing pages. - if ($entity->get($field_name)->getFieldDefinition()->getSetting('form_location') == CommentItemInterface::FORM_SEPARATE_PAGE) { + if ($entity->get($field_name)->getFieldDefinition()->getSetting('form_location') === CommentItemInterface::FORM_SEPARATE_PAGE) { $destination = array('destination' => 'comment/reply/' . $entity->getEntityTypeId() . '/' . $entity->id() . '/' . $field_name . '#comment-form'); } else { $destination = array('destination' => $entity->getSystemPath() . '#comment-form'); } - if ($this->userConfig->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY) { + if ($this->userConfig->get('register') !== USER_REGISTER_ADMINISTRATORS_ONLY) { // Users can register themselves. return $this->t('Log in or register to post comments', array( '@login' => $this->urlGenerator->generateFromRoute('user.login', array(), array('query' => $destination)), @@ -306,7 +306,7 @@ public function getCountNewComments(EntityInterface $entity, $field_name = NULL, if ($this->currentUser->isAuthenticated() && $this->moduleHandler->moduleExists('history')) { // Retrieve the timestamp at which the current user last viewed this entity. if (!$timestamp) { - if ($entity->getEntityTypeId() == 'node') { + if ($entity->getEntityTypeId() === 'node') { $timestamp = history_read($entity->id()); } else { diff --git a/core/modules/comment/src/CommentStorage.php b/core/modules/comment/src/CommentStorage.php index 714b4c1..4fe778d 100644 --- a/core/modules/comment/src/CommentStorage.php +++ b/core/modules/comment/src/CommentStorage.php @@ -107,7 +107,7 @@ public function getDisplayOrdinal(CommentInterface $comment, $comment_mode, $div $query->condition('c1.status', CommentInterface::PUBLISHED); } - if ($comment_mode == CommentManagerInterface::COMMENT_MODE_FLAT) { + if ($comment_mode === CommentManagerInterface::COMMENT_MODE_FLAT) { // For rendering flat comments, cid is used for ordering comments due to // unpredictable behavior with timestamp, so we make the same assumption // here. @@ -139,7 +139,7 @@ public function getNewCommentPageNumber($total_comments, $new_comments, ContentE // Only one page of comments. $count = 0; } - elseif ($instance->getSetting('default_mode') == CommentManagerInterface::COMMENT_MODE_FLAT) { + elseif ($instance->getSetting('default_mode') === CommentManagerInterface::COMMENT_MODE_FLAT) { // Flat comments. $count = $total_comments - $new_comments; } @@ -296,7 +296,7 @@ public function loadThread(EntityInterface $entity, $field_name, $mode, $comment $query->condition('c.status', CommentInterface::PUBLISHED); $count_query->condition('c.status', CommentInterface::PUBLISHED); } - if ($mode == CommentManagerInterface::COMMENT_MODE_FLAT) { + if ($mode === CommentManagerInterface::COMMENT_MODE_FLAT) { $query->orderBy('c.cid', 'ASC'); } else { diff --git a/core/modules/comment/src/CommentTypeForm.php b/core/modules/comment/src/CommentTypeForm.php index 0d93b1c..5b6495c 100644 --- a/core/modules/comment/src/CommentTypeForm.php +++ b/core/modules/comment/src/CommentTypeForm.php @@ -148,7 +148,7 @@ public function save(array $form, FormStateInterface $form_state) { $status = $comment_type->save(); $edit_link = \Drupal::linkGenerator()->generateFromUrl($this->t('Edit'), $this->entity->urlInfo()); - if ($status == SAVED_UPDATED) { + if ($status === SAVED_UPDATED) { drupal_set_message(t('Comment type %label has been updated.', array('%label' => $comment_type->label()))); $this->logger->notice('Comment type %label has been updated.', array('%label' => $comment_type->label(), 'link' => $edit_link)); } diff --git a/core/modules/comment/src/CommentViewBuilder.php b/core/modules/comment/src/CommentViewBuilder.php index cd36bc4..d382250 100644 --- a/core/modules/comment/src/CommentViewBuilder.php +++ b/core/modules/comment/src/CommentViewBuilder.php @@ -224,7 +224,7 @@ protected static function buildLinks(CommentInterface $entity, EntityInterface $ $container = \Drupal::getContainer(); - if ($status == CommentItemInterface::OPEN) { + if ($status === CommentItemInterface::OPEN) { if ($entity->access('delete')) { $links['comment-delete'] = array( 'title' => t('Delete'), @@ -289,7 +289,7 @@ protected function alterBuild(array &$build, EntityInterface $comment, EntityVie $commented_entity = $comment->getCommentedEntity(); $field_definition = $this->entityManager->getFieldDefinitions($commented_entity->getEntityTypeId(), $commented_entity->bundle())[$comment->getFieldName()]; $is_threaded = isset($comment->divs) - && $field_definition->getSetting('default_mode') == CommentManagerInterface::COMMENT_MODE_THREADED; + && $field_definition->getSetting('default_mode') === CommentManagerInterface::COMMENT_MODE_THREADED; // Add indentation div or close open divs as needed. if ($is_threaded) { diff --git a/core/modules/comment/src/CommentViewsData.php b/core/modules/comment/src/CommentViewsData.php index 866bc99..3835fd0 100644 --- a/core/modules/comment/src/CommentViewsData.php +++ b/core/modules/comment/src/CommentViewsData.php @@ -386,7 +386,7 @@ public function getViewsData() { // Provide a relationship for each entity type except comment. foreach ($entities_types as $type => $entity_type) { - if ($type == 'comment' || !$entity_type->isFieldable() || !$entity_type->getBaseTable()) { + if ($type === 'comment' || !$entity_type->isFieldable() || !$entity_type->getBaseTable()) { continue; } if ($fields = \Drupal::service('comment.manager')->getFields($type)) { @@ -465,7 +465,7 @@ public function getViewsData() { // Provide a relationship for each entity type except comment. foreach ($entities_types as $type => $entity_type) { - if ($type == 'comment' || !$entity_type->isFieldable() || !$entity_type->getBaseTable()) { + if ($type === 'comment' || !$entity_type->isFieldable() || !$entity_type->getBaseTable()) { continue; } // This relationship does not use the 'field id' column, if the entity has diff --git a/core/modules/comment/src/Controller/AdminController.php b/core/modules/comment/src/Controller/AdminController.php index 4c1592f..0524de5 100644 --- a/core/modules/comment/src/Controller/AdminController.php +++ b/core/modules/comment/src/Controller/AdminController.php @@ -56,7 +56,7 @@ public function __construct(FormBuilderInterface $form_builder) { * administration form. */ public function adminPage(Request $request, $type = 'new') { - if ($request->request->get('operation') == 'delete' && $request->request->get('comments')) { + if ($request->request->get('operation') === 'delete' && $request->request->get('comments')) { return $this->formBuilder->getForm('\Drupal\comment\Form\ConfirmDeleteMultiple', $request); } else { diff --git a/core/modules/comment/src/Controller/CommentController.php b/core/modules/comment/src/Controller/CommentController.php index af415d0..06596fc 100644 --- a/core/modules/comment/src/Controller/CommentController.php +++ b/core/modules/comment/src/Controller/CommentController.php @@ -207,9 +207,9 @@ public function getReplyForm(Request $request, EntityInterface $entity, $field_n } // The user is not just previewing a comment. - if ($request->request->get('op') != $this->t('Preview')) { + if ($request->request->get('op') !== $this->t('Preview')) { $status = $entity->{$field_name}->status; - if ($status != CommentItemInterface::OPEN) { + if ($status !== CommentItemInterface::OPEN) { drupal_set_message($this->t("This discussion is closed: you can't post new comments."), 'error'); return new RedirectResponse($uri->toString()); } @@ -224,7 +224,7 @@ public function getReplyForm(Request $request, EntityInterface $entity, $field_n // Load the parent comment. $comment = $this->entityManager()->getStorage('comment')->load($pid); // Check if the parent comment is published and belongs to the entity. - if (!$comment->isPublished() || ($comment->getCommentedEntityId() != $entity->id())) { + if (!$comment->isPublished() || ($comment->getCommentedEntityId() !== $entity->id())) { drupal_set_message($this->t('The comment you are replying to does not exist.'), 'error'); return new RedirectResponse($uri->toString()); } diff --git a/core/modules/comment/src/Entity/Comment.php b/core/modules/comment/src/Entity/Comment.php index 9823f9f..78361dd 100644 --- a/core/modules/comment/src/Entity/Comment.php +++ b/core/modules/comment/src/Entity/Comment.php @@ -105,7 +105,7 @@ public function preSave(EntityStorageInterface $storage) { // Get the max value in *this* thread. $max = $storage->getMaxThreadPerThread($this); - if ($max == '') { + if ($max === '') { // First child of this parent. As the other two cases do an // increment of the thread number before creating the thread // string set this to -1 so it requires an increment too. @@ -410,7 +410,7 @@ public function setAuthorName($name) { public function getAuthorEmail() { $mail = $this->get('mail')->value; - if ($this->get('uid')->target_id != 0) { + if ($this->get('uid')->target_id !== 0) { $mail = $this->get('uid')->entity->getEmail(); } @@ -469,7 +469,7 @@ public function setCreatedTime($created) { * {@inheritdoc} */ public function isPublished() { - return $this->get('status')->value == CommentInterface::PUBLISHED; + return $this->get('status')->value === CommentInterface::PUBLISHED; } /** diff --git a/core/modules/comment/src/Form/CommentAdminOverview.php b/core/modules/comment/src/Form/CommentAdminOverview.php index 723241a..ea982d6 100644 --- a/core/modules/comment/src/Form/CommentAdminOverview.php +++ b/core/modules/comment/src/Form/CommentAdminOverview.php @@ -111,7 +111,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $type = ' '#attributes' => array('class' => array('container-inline')), ); - if ($type == 'approval') { + if ($type === 'approval') { $options['publish'] = $this->t('Publish the selected comments'); } else { @@ -132,7 +132,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $type = ' ); // Load the comments that need to be displayed. - $status = ($type == 'approval') ? CommentInterface::NOT_PUBLISHED : CommentInterface::PUBLISHED; + $status = ($type === 'approval') ? CommentInterface::NOT_PUBLISHED : CommentInterface::PUBLISHED; $header = array( 'subject' => array( 'data' => $this->t('Subject'), @@ -254,7 +254,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $type = ' public function validateForm(array &$form, FormStateInterface $form_state) { $form_state->setValue('comments', array_diff($form_state->getValue('comments'), array(0))); // We can't execute any 'Update options' if no comments were selected. - if (count($form_state->getValue('comments')) == 0) { + if (count($form_state->getValue('comments')) === 0) { $form_state->setErrorByName('', $this->t('Select one or more comments to perform the update on.')); } } @@ -269,12 +269,12 @@ public function submitForm(array &$form, FormStateInterface $form_state) { foreach ($cids as $cid) { // Delete operation handled in \Drupal\comment\Form\ConfirmDeleteMultiple // see \Drupal\comment\Controller\AdminController::adminPage(). - if ($operation == 'unpublish') { + if ($operation === 'unpublish') { $comment = $this->commentStorage->load($cid); $comment->setPublished(FALSE); $comment->save(); } - elseif ($operation == 'publish') { + elseif ($operation === 'publish') { $comment = $this->commentStorage->load($cid); $comment->setPublished(TRUE); $comment->save(); diff --git a/core/modules/comment/src/Form/CommentTypeDeleteForm.php b/core/modules/comment/src/Form/CommentTypeDeleteForm.php index 7ac7ce7..2a1d624 100644 --- a/core/modules/comment/src/Form/CommentTypeDeleteForm.php +++ b/core/modules/comment/src/Form/CommentTypeDeleteForm.php @@ -118,7 +118,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $caption = ''; foreach (array_keys($this->commentManager->getFields($entity_type)) as $field_name) { /** @var \Drupal\field\FieldStorageConfigInterface $field_storage */ - if (($field_storage = FieldStorageConfig::loadByName($entity_type, $field_name)) && $field_storage->getSetting('comment_type') == $this->entity->id() && !$field_storage->deleted) { + if (($field_storage = FieldStorageConfig::loadByName($entity_type, $field_name)) && $field_storage->getSetting('comment_type') === $this->entity->id() && !$field_storage->deleted) { $caption .= '

    ' . $this->t('%label is used by the %field field on your site. You can not remove this comment type until you have removed the field.', array( '%label' => $this->entity->label(), '%field' => $field_storage->label(), diff --git a/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php b/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php index aa41d12..2c8398a 100644 --- a/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php +++ b/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php @@ -139,7 +139,7 @@ public function viewElements(FieldItemListInterface $items) { $status = $items->status; - if ($status != CommentItemInterface::HIDDEN && empty($entity->in_preview) && + if ($status !== CommentItemInterface::HIDDEN && empty($entity->in_preview) && // Comments are added to the search results and search index by // comment_node_update_index() instead of by this formatter, so don't // return anything if the view mode is search_index or search_result. @@ -168,7 +168,7 @@ public function viewElements(FieldItemListInterface $items) { // Append comment form if the comments are open and the form is set to // display below the entity. Do not show the form for the print view mode. - if ($status == CommentItemInterface::OPEN && $comment_settings['form_location'] == CommentItemInterface::FORM_BELOW && $this->viewMode != 'print') { + if ($status === CommentItemInterface::OPEN && $comment_settings['form_location'] === CommentItemInterface::FORM_BELOW && $this->viewMode !== 'print') { // Only show the add comment form if the user has permission. if ($this->currentUser->hasPermission('post comments')) { // All users in the "anonymous" role can use the same form: it is fine diff --git a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php index b54564a..39d4beb 100644 --- a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php +++ b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php @@ -166,7 +166,7 @@ public function instanceSettingsForm(array $form, FormStateInterface $form_state * {@inheritdoc} */ public function __get($name) { - if ($name == 'status' && !isset($this->values[$name])) { + if ($name === 'status' && !isset($this->values[$name])) { // Get default value from field instance when no data saved in entity. $field_default_values = $this->getFieldDefinition()->getDefaultValue($this->getEntity()); return $field_default_values[0]['status']; @@ -198,7 +198,7 @@ public function settingsForm(array &$form, FormStateInterface $form_state, $has_ $options = array(); $entity_type = $this->getEntity()->getEntityTypeId(); foreach ($comment_types as $comment_type) { - if ($comment_type->getTargetEntityTypeId() == $entity_type) { + if ($comment_type->getTargetEntityTypeId() === $entity_type) { $options[$comment_type->id()] = $comment_type->label(); } } diff --git a/core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php b/core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php index 87309c5..9ffc2e2 100644 --- a/core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php +++ b/core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php @@ -54,7 +54,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen // If the entity doesn't have any comments, the "hidden" option makes no // sense, so don't even bother presenting it to the user unless this is the // default value widget on the field settings form. - if ($element['#field_parents'] != array('default_value_input') && !$items->comment_count) { + if ($element['#field_parents'] !== array('default_value_input') && !$items->comment_count) { $element['status'][CommentItemInterface::HIDDEN]['#access'] = FALSE; // Also adjust the description of the "closed" option. $element['status'][CommentItemInterface::CLOSED]['#description'] = t('Users cannot post comments.'); @@ -73,7 +73,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen '#type' => 'details', // Open the details when the selected value is different to the stored // default values for the field instance. - '#open' => ($items->status != $field_default_values[0]['status']), + '#open' => ($items->status !== $field_default_values[0]['status']), '#group' => 'advanced', '#attributes' => array( 'class' => array('comment-' . drupal_html_class($entity->getEntityTypeId()) . '-settings-form'), diff --git a/core/modules/comment/src/Plugin/views/argument/UserUid.php b/core/modules/comment/src/Plugin/views/argument/UserUid.php index 5e104bd..417eff8 100644 --- a/core/modules/comment/src/Plugin/views/argument/UserUid.php +++ b/core/modules/comment/src/Plugin/views/argument/UserUid.php @@ -77,7 +77,7 @@ protected function defaultActions($which = NULL) { return $actions; } - if ($which != 'summary asc' && $which != 'summary desc') { + if ($which !== 'summary asc' && $which !== 'summary desc') { return parent::defaultActions($which); } } @@ -86,7 +86,7 @@ public function query($group_by = FALSE) { $this->ensureMyTable(); // Use the table definition to correctly add this user ID condition. - if ($this->table != 'comment') { + if ($this->table !== 'comment') { $subselect = $this->database->select('comment', 'c'); $subselect->addField('c', 'cid'); $subselect->condition('c.uid', $this->argument); diff --git a/core/modules/comment/src/Plugin/views/field/LinkApprove.php b/core/modules/comment/src/Plugin/views/field/LinkApprove.php index 1fde0a7..4bef13f 100644 --- a/core/modules/comment/src/Plugin/views/field/LinkApprove.php +++ b/core/modules/comment/src/Plugin/views/field/LinkApprove.php @@ -43,7 +43,7 @@ protected function renderLink($data, ResultRow $values) { $status = $this->getValue($values, 'status'); // Don't show an approve link on published comment. - if ($status == CommentInterface::PUBLISHED) { + if ($status === CommentInterface::PUBLISHED) { return; } diff --git a/core/modules/comment/src/Plugin/views/row/Rss.php b/core/modules/comment/src/Plugin/views/row/Rss.php index 50354fb..a007cb7 100644 --- a/core/modules/comment/src/Plugin/views/row/Rss.php +++ b/core/modules/comment/src/Plugin/views/row/Rss.php @@ -88,7 +88,7 @@ public function render($row) { } $view_mode = $this->options['view_mode']; - if ($view_mode == 'default') { + if ($view_mode === 'default') { $view_mode = \Drupal::config('system.rss')->get('items.view_mode'); } @@ -128,7 +128,7 @@ public function render($row) { $this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $comment->rss_namespaces); } - if ($view_mode != 'title') { + if ($view_mode !== 'title') { // We render comment contents. $item_text .= drupal_render($build); } diff --git a/core/modules/comment/src/Plugin/views/sort/Thread.php b/core/modules/comment/src/Plugin/views/sort/Thread.php index a8bcad5..37e51c0 100644 --- a/core/modules/comment/src/Plugin/views/sort/Thread.php +++ b/core/modules/comment/src/Plugin/views/sort/Thread.php @@ -23,7 +23,7 @@ public function query() { //Read comment_render() in comment.module for an explanation of the //thinking behind this sort. - if ($this->options['order'] == 'DESC') { + if ($this->options['order'] === 'DESC') { $this->query->addOrderBy($this->tableAlias, $this->realField, $this->options['order']); } else { diff --git a/core/modules/comment/src/Tests/CommentCSSTest.php b/core/modules/comment/src/Tests/CommentCSSTest.php index a3d8a61..97caa33 100644 --- a/core/modules/comment/src/Tests/CommentCSSTest.php +++ b/core/modules/comment/src/Tests/CommentCSSTest.php @@ -86,11 +86,11 @@ function testCommentClasses() { $this->assertIdentical(1, count($this->xpath('//*[@data-history-node-id="' . $node->id() . '"]')), 'data-history-node-id attribute is set on node.'); // Verify classes if the comment is visible for the current user. - if ($case['comment_status'] == CommentInterface::PUBLISHED || $case['user'] == 'admin') { + if ($case['comment_status'] === CommentInterface::PUBLISHED || $case['user'] === 'admin') { // Verify the by-anonymous class. $comments = $this->xpath('//*[contains(@class, "comment") and contains(@class, "by-anonymous")]'); - if ($case['comment_uid'] == 0) { - $this->assertTrue(count($comments) == 1, 'by-anonymous class found.'); + if ($case['comment_uid'] === 0) { + $this->assertTrue(count($comments) === 1, 'by-anonymous class found.'); } else { $this->assertFalse(count($comments), 'by-anonymous class not found.'); @@ -98,8 +98,8 @@ function testCommentClasses() { // Verify the by-node-author class. $comments = $this->xpath('//*[contains(@class, "comment") and contains(@class, "by-node-author")]'); - if ($case['comment_uid'] > 0 && $case['comment_uid'] == $case['node_uid']) { - $this->assertTrue(count($comments) == 1, 'by-node-author class found.'); + if ($case['comment_uid'] > 0 && $case['comment_uid'] === $case['node_uid']) { + $this->assertTrue(count($comments) === 1, 'by-node-author class found.'); } else { $this->assertFalse(count($comments), 'by-node-author class not found.'); @@ -115,8 +115,8 @@ function testCommentClasses() { // Verify the unpublished class. $comments = $this->xpath('//*[contains(@class, "comment") and contains(@class, "unpublished")]'); - if ($case['comment_status'] == CommentInterface::NOT_PUBLISHED && $case['user'] == 'admin') { - $this->assertTrue(count($comments) == 1, 'unpublished class found.'); + if ($case['comment_status'] === CommentInterface::NOT_PUBLISHED && $case['user'] === 'admin') { + $this->assertTrue(count($comments) === 1, 'unpublished class found.'); } else { $this->assertFalse(count($comments), 'unpublished class not found.'); @@ -126,7 +126,7 @@ function testCommentClasses() { // drupal.comment-new-indicator library to add a "new" indicator to each // comment that was created or changed after the last time the current // user read the corresponding node. - if ($case['comment_status'] == CommentInterface::PUBLISHED || $case['user'] == 'admin') { + if ($case['comment_status'] === CommentInterface::PUBLISHED || $case['user'] === 'admin') { $this->assertIdentical(1, count($this->xpath('//*[contains(@class, "comment")]/*[@data-comment-timestamp="' . $comment->getChangedTime() . '"]')), 'data-comment-timestamp attribute is set on comment'); $expectedJS = ($case['user'] !== 'anonymous'); $this->assertIdentical($expectedJS, isset($settings['ajaxPageState']['js']['core/modules/comment/js/comment-new-indicator.js']), 'drupal.comment-new-indicator library is present.'); diff --git a/core/modules/comment/src/Tests/CommentInterfaceTest.php b/core/modules/comment/src/Tests/CommentInterfaceTest.php index 94e423c..69bd28b 100644 --- a/core/modules/comment/src/Tests/CommentInterfaceTest.php +++ b/core/modules/comment/src/Tests/CommentInterfaceTest.php @@ -76,7 +76,7 @@ function testCommentInterface() { // Test changing the comment author to "Anonymous". $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), array('name' => '')); - $this->assertTrue($comment->getAuthorName() == t('Anonymous') && $comment->getOwnerId() == 0, 'Comment author successfully changed to anonymous.'); + $this->assertTrue($comment->getAuthorName() === t('Anonymous') && $comment->getOwnerId() === 0, 'Comment author successfully changed to anonymous.'); // Test changing the comment author to an unverified user. $random_name = $this->randomMachineName(); @@ -88,7 +88,7 @@ function testCommentInterface() { // Test changing the comment author to a verified user. $this->drupalGet('comment/' . $comment->id() . '/edit'); $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), array('name' => $this->web_user->getUsername())); - $this->assertTrue($comment->getAuthorName() == $this->web_user->getUsername() && $comment->getOwnerId() == $this->web_user->id(), 'Comment author successfully changed to a registered user.'); + $this->assertTrue($comment->getAuthorName() === $this->web_user->getUsername() && $comment->getOwnerId() === $this->web_user->id(), 'Comment author successfully changed to a registered user.'); $this->drupalLogout(); diff --git a/core/modules/comment/src/Tests/CommentLinksTest.php b/core/modules/comment/src/Tests/CommentLinksTest.php index 00484b6..82c569b 100644 --- a/core/modules/comment/src/Tests/CommentLinksTest.php +++ b/core/modules/comment/src/Tests/CommentLinksTest.php @@ -99,7 +99,7 @@ public function testCommentLinks() { // In teaser view, a link containing the comment count is always // expected. - if ($path == 'node') { + if ($path === 'node') { $this->assertLink(t('1 comment')); } $this->assertLink('Add new comment'); diff --git a/core/modules/comment/src/Tests/CommentNonNodeTest.php b/core/modules/comment/src/Tests/CommentNonNodeTest.php index 85f0554..eb5d810 100644 --- a/core/modules/comment/src/Tests/CommentNonNodeTest.php +++ b/core/modules/comment/src/Tests/CommentNonNodeTest.php @@ -203,7 +203,7 @@ function performCommentOperation($comment, $operation, $approval = FALSE) { $edit['comments[' . $comment->id() . ']'] = TRUE; $this->drupalPostForm('admin/content/comment' . ($approval ? '/approval' : ''), $edit, t('Update')); - if ($operation == 'delete') { + if ($operation === 'delete') { $this->drupalPostForm(NULL, array(), t('Delete comments')); $this->assertRaw(format_plural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), format_string('Operation "@operation" was performed on comment.', array('@operation' => $operation))); } diff --git a/core/modules/comment/src/Tests/CommentTestBase.php b/core/modules/comment/src/Tests/CommentTestBase.php index 05f139d..1be1086 100644 --- a/core/modules/comment/src/Tests/CommentTestBase.php +++ b/core/modules/comment/src/Tests/CommentTestBase.php @@ -342,7 +342,7 @@ function performCommentOperation(CommentInterface $comment, $operation, $approva $edit['comments[' . $comment->id() . ']'] = TRUE; $this->drupalPostForm('admin/content/comment' . ($approval ? '/approval' : ''), $edit, t('Update')); - if ($operation == 'delete') { + if ($operation === 'delete') { $this->drupalPostForm(NULL, array(), t('Delete comments')); $this->assertRaw(format_plural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), format_string('Operation "@operation" was performed on comment.', array('@operation' => $operation))); } diff --git a/core/modules/comment/src/Tests/CommentTranslationUITest.php b/core/modules/comment/src/Tests/CommentTranslationUITest.php index 14ea0db..051d41f 100644 --- a/core/modules/comment/src/Tests/CommentTranslationUITest.php +++ b/core/modules/comment/src/Tests/CommentTranslationUITest.php @@ -77,7 +77,7 @@ function setupTestFields() { * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::createEntity(). */ protected function createEntity($values, $langcode, $comment_type = 'comment_article') { - if ($comment_type == 'comment_article') { + if ($comment_type === 'comment_article') { // This is the article node type, with the 'comment_article' field. $node_type = 'article'; $field_name = 'comment_article'; diff --git a/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php b/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php index 2993f28..d19f1f5 100644 --- a/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php +++ b/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php @@ -145,11 +145,11 @@ public function testCommentLinkBuilder(NodeInterface $node, $context, $has_acces else { $this->assertSame($links, $expected); } - if ($context['view_mode'] == 'rss' && $node->get('comment')->status) { + if ($context['view_mode'] === 'rss' && $node->get('comment')->status) { $found = FALSE; if ($node->get('comment')->status) { foreach ($node->rss_elements as $element) { - if ($element['key'] == 'comments') { + if ($element['key'] === 'comments') { $found = TRUE; break; } @@ -216,7 +216,7 @@ public function getLinkCombinations() { $expected = array(); // When comments are enabled in teaser mode, and comments exist, and the // user has access - we can output the comment count. - if ($combination['comments'] && $combination['view_mode'] == 'teaser' && $combination['comment_count'] && $combination['has_access_comments']) { + if ($combination['comments'] && $combination['view_mode'] === 'teaser' && $combination['comment_count'] && $combination['has_access_comments']) { $expected['comment-comments'] = '1 comment'; // And if history module exists, we can show a 'new comments' link. if ($combination['history_exists']) { @@ -224,17 +224,17 @@ public function getLinkCombinations() { } } // All view modes other than RSS. - if ($combination['view_mode'] != 'rss') { + if ($combination['view_mode'] !== 'rss') { // Where commenting is open. - if ($combination['comments'] == CommentItemInterface::OPEN) { + if ($combination['comments'] === CommentItemInterface::OPEN) { // And the user has post-comments permission. if ($combination['has_post_comments']) { // If the view mode is teaser, or the user can access comments and // comments exist or the form is on a separate page. - if ($combination['view_mode'] == 'teaser' || ($combination['has_access_comments'] && $combination['comment_count']) || $combination['form_location'] == CommentItemInterface::FORM_SEPARATE_PAGE) { + if ($combination['view_mode'] === 'teaser' || ($combination['has_access_comments'] && $combination['comment_count']) || $combination['form_location'] === CommentItemInterface::FORM_SEPARATE_PAGE) { // There should be a add comment link. $expected['comment-add'] = array('title' => 'Add new comment'); - if ($combination['form_location'] == CommentItemInterface::FORM_BELOW) { + if ($combination['form_location'] === CommentItemInterface::FORM_BELOW) { // On the same page. $expected['comment-add']['route_name'] = 'node.view'; } diff --git a/core/modules/config/config.module b/core/modules/config/config.module index e22b71b..76019a0 100644 --- a/core/modules/config/config.module +++ b/core/modules/config/config.module @@ -52,7 +52,7 @@ function config_permission() { function config_file_download($uri) { $scheme = file_uri_scheme($uri); $target = file_uri_target($uri); - if ($scheme == 'temporary' && $target == 'config.tar.gz') { + if ($scheme === 'temporary' && $target === 'config.tar.gz') { return array( 'Content-disposition' => 'attachment; filename="config.tar.gz"', ); diff --git a/core/modules/config/src/Form/ConfigSync.php b/core/modules/config/src/Form/ConfigSync.php index f73de96..a9661d4 100644 --- a/core/modules/config/src/Form/ConfigSync.php +++ b/core/modules/config/src/Form/ConfigSync.php @@ -218,7 +218,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['#attached']['library'][] = 'core/drupal.ajax'; foreach ($storage_comparer->getAllCollectionNames() as $collection) { - if ($collection != StorageInterface::DEFAULT_COLLECTION) { + if ($collection !== StorageInterface::DEFAULT_COLLECTION) { $form[$collection]['collection_heading'] = array( '#type' => 'html_tag', '#tag' => 'h2', @@ -259,7 +259,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { ); foreach ($config_names as $config_name) { - if ($config_change_type == 'rename') { + if ($config_change_type === 'rename') { $names = $storage_comparer->extractRenameNames($config_name); $route_options = array('source_name' => $names['old_name'], 'target_name' => $names['new_name']); $config_name = $this->t('!source_name to !target_name', array('!source_name' => $names['old_name'], '!target_name' => $names['new_name'])); @@ -267,7 +267,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { else { $route_options = array('source_name' => $config_name); } - if ($collection != StorageInterface::DEFAULT_COLLECTION) { + if ($collection !== StorageInterface::DEFAULT_COLLECTION) { $route_options['collection'] = $collection; $href = $this->urlGenerator->getPathFromRoute('config.diff_collection', $route_options); } diff --git a/core/modules/config/src/Tests/ConfigExportImportUITest.php b/core/modules/config/src/Tests/ConfigExportImportUITest.php index 442ada7..d476cd6 100644 --- a/core/modules/config/src/Tests/ConfigExportImportUITest.php +++ b/core/modules/config/src/Tests/ConfigExportImportUITest.php @@ -98,13 +98,13 @@ public function testExportImport() { // Delete the custom field. $field_instances = entity_load_multiple('field_instance_config'); foreach ($field_instances as $field_instance) { - if ($field_instance->field_name == $this->fieldName) { + if ($field_instance->field_name === $this->fieldName) { $field_instance->delete(); } } $field_storages = entity_load_multiple('field_storage_config'); foreach ($field_storages as $field_storage) { - if ($field_storage->name == $this->fieldName) { + if ($field_storage->name === $this->fieldName) { $field_storage->delete(); } } diff --git a/core/modules/config/src/Tests/ConfigImportAllTest.php b/core/modules/config/src/Tests/ConfigImportAllTest.php index 7b73631..a478b4e 100644 --- a/core/modules/config/src/Tests/ConfigImportAllTest.php +++ b/core/modules/config/src/Tests/ConfigImportAllTest.php @@ -46,7 +46,7 @@ public function testInstallUninstall() { $all_modules = array_filter($all_modules, function ($module) { // Filter hidden, already enabled modules and modules in the Testing // package. - if (!empty($module->info['hidden']) || $module->status == TRUE || $module->info['package'] == 'Testing') { + if (!empty($module->info['hidden']) || $module->status === TRUE || $module->info['package'] === 'Testing') { return FALSE; } return TRUE; @@ -80,7 +80,7 @@ public function testInstallUninstall() { $all_modules = system_rebuild_module_data(); $modules_to_uninstall = array_filter($all_modules, function ($module) { // Filter required and not enabled modules. - if (!empty($module->info['required']) || $module->status == FALSE) { + if (!empty($module->info['required']) || $module->status === FALSE) { return FALSE; } return TRUE; diff --git a/core/modules/config/src/Tests/ConfigSchemaTest.php b/core/modules/config/src/Tests/ConfigSchemaTest.php index 5dbec35..2060e9e 100644 --- a/core/modules/config/src/Tests/ConfigSchemaTest.php +++ b/core/modules/config/src/Tests/ConfigSchemaTest.php @@ -285,19 +285,19 @@ function testSchemaData() { // And test some ComplexDataInterface methods. $properties = $list->getProperties(); - $this->assertTrue(count($properties) == 3 && $properties['front'] == $list['front'], 'Got the right properties for site page.'); + $this->assertTrue(count($properties) === 3 && $properties['front'] === $list['front'], 'Got the right properties for site page.'); $values = $list->toArray(); - $this->assertTrue(count($values) == 3 && $values['front'] == 'user', 'Got the right property values for site page.'); + $this->assertTrue(count($values) === 3 && $values['front'] === 'user', 'Got the right property values for site page.'); // Now let's try something more complex, with nested objects. $wrapper = \Drupal::service('config.typed')->get('image.style.large'); $effects = $wrapper->get('effects'); // The function is_array() doesn't work with ArrayAccess, so we use count(). - $this->assertTrue(count($effects) == 1, 'Got an array with effects for image.style.large data'); + $this->assertTrue(count($effects) === 1, 'Got an array with effects for image.style.large data'); $uuid = key($effects->getValue()); $effect = $effects[$uuid]; - $this->assertTrue(count($effect['data']) && $effect['id']->getValue() == 'image_scale', 'Got data for the image scale effect from metadata.'); + $this->assertTrue(count($effect['data']) && $effect['id']->getValue() === 'image_scale', 'Got data for the image scale effect from metadata.'); $this->assertTrue($effect['data']['width'] instanceof IntegerInterface, 'Got the right type for the scale effect width.'); $this->assertEqual($effect['data']['width']->getValue(), 480, 'Got the right value for the scale effect width.' ); diff --git a/core/modules/config/tests/config_import_test/src/EventSubscriber.php b/core/modules/config/tests/config_import_test/src/EventSubscriber.php index 0be4f97..fdfbaf2 100644 --- a/core/modules/config/tests/config_import_test/src/EventSubscriber.php +++ b/core/modules/config/tests/config_import_test/src/EventSubscriber.php @@ -58,13 +58,13 @@ public function onConfigImporterValidate(ConfigImporterEvent $event) { */ public function onConfigSave(ConfigCrudEvent $event) { $config = $event->getConfig(); - if ($config->getName() == 'action.settings') { + if ($config->getName() === 'action.settings') { $values = $this->state->get('ConfigImportUITest.action.settings.recursion_limit', array()); $values[] = $config->get('recursion_limit'); $this->state->set('ConfigImportUITest.action.settings.recursion_limit', $values); } - if ($config->getName() == 'core.extension') { + if ($config->getName() === 'core.extension') { $installed = $this->state->get('ConfigImportUITest.core.extension.modules_installed', array()); $uninstalled = $this->state->get('ConfigImportUITest.core.extension.modules_uninstalled', array()); $original = $config->getOriginal('module'); @@ -90,7 +90,7 @@ public function onConfigSave(ConfigCrudEvent $event) { */ public function onConfigDelete(ConfigCrudEvent $event) { $config = $event->getConfig(); - if ($config->getName() == 'action.settings') { + if ($config->getName() === 'action.settings') { $value = $this->state->get('ConfigImportUITest.action.settings.delete', 0); $this->state->set('ConfigImportUITest.action.settings.delete', $value + 1); } diff --git a/core/modules/config/tests/config_test/src/Entity/ConfigTest.php b/core/modules/config/tests/config_test/src/Entity/ConfigTest.php index b022cc6..7cf29c3 100644 --- a/core/modules/config/tests/config_test/src/Entity/ConfigTest.php +++ b/core/modules/config/tests/config_test/src/Entity/ConfigTest.php @@ -98,14 +98,14 @@ public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) */ public function postSave(EntityStorageInterface $storage, $update = TRUE) { // Used to test secondary writes during config sync. - if ($this->id() == 'primary') { + if ($this->id() === 'primary') { $secondary = $storage->create(array( 'id' => 'secondary', 'label' => 'Secondary Default', )); $secondary->save(); } - if ($this->id() == 'deleter') { + if ($this->id() === 'deleter') { $deletee = $storage->load('deletee'); $deletee->delete(); } @@ -117,7 +117,7 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) { public static function postDelete(EntityStorageInterface $storage, array $entities) { parent::postDelete($storage, $entities); foreach ($entities as $entity) { - if ($entity->id() == 'deleter') { + if ($entity->id() === 'deleter') { $deletee = $storage->load('deletee'); $deletee->delete(); } diff --git a/core/modules/config_translation/config_translation.module b/core/modules/config_translation/config_translation.module index 43aa754..a75ca19 100644 --- a/core/modules/config_translation/config_translation.module +++ b/core/modules/config_translation/config_translation.module @@ -89,10 +89,10 @@ function config_translation_entity_type_alter(array &$entity_types) { /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ foreach ($entity_types as $entity_type_id => $entity_type) { if ($entity_type->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface')) { - if ($entity_type_id == 'block') { + if ($entity_type_id === 'block') { $class = 'Drupal\config_translation\Controller\ConfigTranslationBlockListBuilder'; } - elseif ($entity_type_id == 'field_instance_config') { + elseif ($entity_type_id === 'field_instance_config') { $class = 'Drupal\config_translation\Controller\ConfigTranslationFieldInstanceListBuilder'; // Will be filled in dynamically, see \Drupal\field\Entity\FieldInstanceConfig::linkTemplates(). $entity_type->setLinkTemplate('drupal:config-translation-overview', 'config_translation.item.overview.'); diff --git a/core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php b/core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php index da7f424..4d617cb 100644 --- a/core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php +++ b/core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php @@ -34,7 +34,7 @@ public function access(Route $route, Request $request, AccountInterface $account $access = !empty($target_language) && !$target_language->locked && - $target_language->id != $this->sourceLanguage->id; + $target_language->id !== $this->sourceLanguage->id; return $base_access->andIf(AccessResult::allowedIf($access)); } diff --git a/core/modules/config_translation/src/ConfigNamesMapper.php b/core/modules/config_translation/src/ConfigNamesMapper.php index 57811d9..d887d70 100644 --- a/core/modules/config_translation/src/ConfigNamesMapper.php +++ b/core/modules/config_translation/src/ConfigNamesMapper.php @@ -425,7 +425,7 @@ public function getLanguageWithFallback() { // 'Built-in English' because we assume such configuration is shipped with // core and the modules and not custom created. (In the later case an // English language configured on the site is assumed.) - if (empty($language) && $langcode == 'en') { + if (empty($language) && $langcode === 'en') { $language = new Language(array('id' => 'en', 'name' => $this->t('Built-in English'))); } return $language; diff --git a/core/modules/config_translation/src/Controller/ConfigTranslationController.php b/core/modules/config_translation/src/Controller/ConfigTranslationController.php index 646d3b8..dacd4ab 100644 --- a/core/modules/config_translation/src/Controller/ConfigTranslationController.php +++ b/core/modules/config_translation/src/Controller/ConfigTranslationController.php @@ -134,7 +134,7 @@ public function itemPage(Request $request, RouteMatchInterface $route_match, $pl $original_langcode = $mapper->getLangcode(); if (!isset($languages[$original_langcode])) { $language_name = $this->languageManager->getLanguageName($original_langcode); - if ($original_langcode == 'en') { + if ($original_langcode === 'en') { $language_name = $this->t('Built-in English'); } // Create a dummy language object for this listing only. @@ -162,7 +162,7 @@ public function itemPage(Request $request, RouteMatchInterface $route_match, $pl // Prepare the language name and the operations depending on whether this // is the original language or not. - if ($langcode == $original_langcode) { + if ($langcode === $original_langcode) { $language_name = '' . $this->t('@language (original)', array('@language' => $language->name)) . ''; // Check access for the path/route for editing, so we can decide to diff --git a/core/modules/config_translation/src/Controller/ConfigTranslationEntityListBuilder.php b/core/modules/config_translation/src/Controller/ConfigTranslationEntityListBuilder.php index 9d94468..8c8b80f 100644 --- a/core/modules/config_translation/src/Controller/ConfigTranslationEntityListBuilder.php +++ b/core/modules/config_translation/src/Controller/ConfigTranslationEntityListBuilder.php @@ -88,7 +88,7 @@ public function getDefaultOperations(EntityInterface $entity) { foreach (array_keys($operations) as $operation) { // This is a translation UI for translators. Show the translation // operation only. - if (!($operation == 'translate')) { + if (!($operation === 'translate')) { unset($operations[$operation]); } } @@ -120,7 +120,7 @@ protected function sortRowsMultiple($a, $b, $keys) { $a_value = (is_array($a) && isset($a[$key]['data'])) ? $a[$key]['data'] : ''; $b_value = (is_array($b) && isset($b[$key]['data'])) ? $b[$key]['data'] : ''; - if ($a_value == $b_value && !empty($keys)) { + if ($a_value === $b_value && !empty($keys)) { return $this->sortRowsMultiple($a, $b, $keys); } diff --git a/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php b/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php index d195d24..8d92594 100644 --- a/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php +++ b/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php @@ -385,7 +385,7 @@ protected function setConfig(LanguageInterface $language, Config $base_config, L // If we have a new translation or different from what is stored in // locale before, save this as an updated customize translation. - if ($translation->isNew() || $translation->getString() != $value['translation']) { + if ($translation->isNew() || $translation->getString() !== $value['translation']) { $translation->setString($value['translation']) ->setCustomized() ->save(); diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php index 690beee..41c80a2 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php @@ -317,7 +317,7 @@ public function testContactConfigEntityTranslation() { // Check language specific auto reply text in email body. foreach ($captured_emails as $email) { - if ($email['id'] == 'contact_page_autoreply') { + if ($email['id'] === 'contact_page_autoreply') { // Trim because we get an added newline for the body. $this->assertEqual(trim($email['body']), 'Thank you for your mail - ' . $email['langcode']); } diff --git a/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module b/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module index eb41793..7971a08 100644 --- a/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module +++ b/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module @@ -13,7 +13,7 @@ */ function config_translation_test_system_info_alter(array &$info, Extension $file, $type) { // @see \Drupal\config_translation\Tests\ConfigTranslationUiThemeTest - if ($file->getType() == 'theme' && $file->getName() == 'config_translation_test_theme') { + if ($file->getType() === 'theme' && $file->getName() === 'config_translation_test_theme') { $info['hidden'] = FALSE; } } diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index 3a72233..48e74f4 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -79,7 +79,7 @@ function contact_entity_extra_field_info() { 'description' => t('Email'), 'weight' => -40, ); - if ($bundle == 'personal') { + if ($bundle === 'personal') { $fields['contact_message'][$bundle]['form']['recipient'] = array( 'label' => t('Recipient user name'), 'description' => t('User'), diff --git a/core/modules/contact/src/Access/ContactPageAccess.php b/core/modules/contact/src/Access/ContactPageAccess.php index 0a7eae7..ef9cc41 100644 --- a/core/modules/contact/src/Access/ContactPageAccess.php +++ b/core/modules/contact/src/Access/ContactPageAccess.php @@ -66,7 +66,7 @@ public function access(UserInterface $user, AccountInterface $account) { } // Users may not contact themselves. - if ($account->id() == $contact_account->id()) { + if ($account->id() === $contact_account->id()) { return AccessResult::forbidden()->cachePerUser(); } diff --git a/core/modules/contact/src/ContactFormAccessControlHandler.php b/core/modules/contact/src/ContactFormAccessControlHandler.php index 3af949a..b8e6a8e 100644 --- a/core/modules/contact/src/ContactFormAccessControlHandler.php +++ b/core/modules/contact/src/ContactFormAccessControlHandler.php @@ -23,11 +23,11 @@ class ContactFormAccessControlHandler extends EntityAccessControlHandler { * {@inheritdoc} */ public function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { - if ($operation == 'view') { + if ($operation === 'view') { // Do not allow access personal form via site-wide route. return AccessResult::allowedIf($account->hasPermission('access site-wide contact form') && $entity->id() !== 'personal')->cachePerRole(); } - elseif ($operation == 'delete' || $operation == 'update') { + elseif ($operation === 'delete' || $operation === 'update') { // Do not allow the 'personal' form to be deleted, as it's used for // the personal contact form. return AccessResult::allowedIf($account->hasPermission('administer contact forms') && $entity->id() !== 'personal')->cachePerRole(); diff --git a/core/modules/contact/src/ContactFormEditForm.php b/core/modules/contact/src/ContactFormEditForm.php index c07dbf2..b3849b2 100644 --- a/core/modules/contact/src/ContactFormEditForm.php +++ b/core/modules/contact/src/ContactFormEditForm.php @@ -98,7 +98,7 @@ public function save(array $form, FormStateInterface $form_state) { $edit_link = \Drupal::linkGenerator()->generateFromUrl($this->t('Edit'), $this->entity->urlInfo()); - if ($status == SAVED_UPDATED) { + if ($status === SAVED_UPDATED) { drupal_set_message($this->t('Contact form %label has been updated.', array('%label' => $contact_form->label()))); $this->logger('contact')->notice('Contact form %label has been updated.', array('%label' => $contact_form->label(), 'link' => $edit_link)); } @@ -114,7 +114,7 @@ public function save(array $form, FormStateInterface $form_state) { ->save(); } // If it was the default form, empty out the setting. - elseif ($contact_settings->get('default_form') == $contact_form->id()) { + elseif ($contact_settings->get('default_form') === $contact_form->id()) { $contact_settings ->set('default_form', NULL) ->save(); diff --git a/core/modules/contact/src/ContactFormListBuilder.php b/core/modules/contact/src/ContactFormListBuilder.php index 883ad9a..22b5471 100644 --- a/core/modules/contact/src/ContactFormListBuilder.php +++ b/core/modules/contact/src/ContactFormListBuilder.php @@ -34,14 +34,14 @@ public function buildHeader() { public function buildRow(EntityInterface $entity) { $row['form'] = $this->getLabel($entity); // Special case the personal form. - if ($entity->id() == 'personal') { + if ($entity->id() === 'personal') { $row['recipients'] = t('Selected user'); $row['selected'] = t('No'); } else { $row['recipients'] = String::checkPlain(implode(', ', $entity->getRecipients())); $default_form = \Drupal::config('contact.settings')->get('default_form'); - $row['selected'] = ($default_form == $entity->id() ? t('Yes') : t('No')); + $row['selected'] = ($default_form === $entity->id() ? t('Yes') : t('No')); } return $row + parent::buildRow($entity); } diff --git a/core/modules/contact/src/Entity/Message.php b/core/modules/contact/src/Entity/Message.php index 9d2269e..591c165 100644 --- a/core/modules/contact/src/Entity/Message.php +++ b/core/modules/contact/src/Entity/Message.php @@ -40,7 +40,7 @@ class Message extends ContentEntityBase implements MessageInterface { * {@inheritdoc} */ public function isPersonal() { - return $this->bundle() == 'personal'; + return $this->bundle() === 'personal'; } /** diff --git a/core/modules/contact/src/MessageViewBuilder.php b/core/modules/contact/src/MessageViewBuilder.php index 23e9b43..17fab1f 100644 --- a/core/modules/contact/src/MessageViewBuilder.php +++ b/core/modules/contact/src/MessageViewBuilder.php @@ -53,11 +53,11 @@ public function buildComponents(array &$build, array $entities, array $displays, public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) { $build = parent::view($entity, $view_mode, $langcode); - if ($view_mode == 'mail') { + if ($view_mode === 'mail') { // Convert field labels into headings. // @todo Improve drupal_html_to_text() to convert DIVs correctly. foreach (Element::children($build) as $key) { - if (isset($build[$key]['#label_display']) && $build[$key]['#label_display'] == 'above') { + if (isset($build[$key]['#label_display']) && $build[$key]['#label_display'] === 'above') { $build[$key] += array('#prefix' => ''); $build[$key]['#prefix'] = $build[$key]['#title'] . ":\n"; $build[$key]['#label_display'] = 'hidden'; diff --git a/core/modules/contact/src/Tests/ContactSitewideTest.php b/core/modules/contact/src/Tests/ContactSitewideTest.php index 436b2bf..0bf2123 100644 --- a/core/modules/contact/src/Tests/ContactSitewideTest.php +++ b/core/modules/contact/src/Tests/ContactSitewideTest.php @@ -234,7 +234,7 @@ function testSiteWideContact() { // Find out in which row the form we want to add a field to is. $i = 0; foreach($this->xpath('//table/tbody/tr') as $row) { - if (((string)$row->td[0]) == $label) { + if (((string)$row->td[0]) === $label) { break; } $i++; @@ -386,7 +386,7 @@ function submitContact($name, $mail, $subject, $id, $message) { $edit['mail'] = $mail; $edit['subject[0][value]'] = $subject; $edit['message[0][value]'] = $message; - if ($id == \Drupal::config('contact.settings')->get('default_form')) { + if ($id === \Drupal::config('contact.settings')->get('default_form')) { $this->drupalPostForm('contact', $edit, t('Send message')); } else { @@ -400,7 +400,7 @@ function submitContact($name, $mail, $subject, $id, $message) { function deleteContactForms() { $contact_forms = entity_load_multiple('contact_form'); foreach ($contact_forms as $id => $contact_form) { - if ($id == 'personal') { + if ($id === 'personal') { // Personal form could not be deleted. $this->drupalGet("admin/structure/contact/manage/$id/delete"); $this->assertResponse(403); diff --git a/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module b/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module index 70311f1..54a8b80 100644 --- a/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module +++ b/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module @@ -11,7 +11,7 @@ * Implements hook_entity_base_field_info(). */ function contact_storage_test_entity_base_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) { - if ($entity_type->id() == 'contact_message') { + if ($entity_type->id() === 'contact_message') { $fields = array(); $fields['id'] = BaseFieldDefinition::create('integer') ->setLabel(t('Message ID')) diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc index 529a325..1512d66 100644 --- a/core/modules/content_translation/content_translation.admin.inc +++ b/core/modules/content_translation/content_translation.admin.inc @@ -306,7 +306,7 @@ function content_translation_form_language_content_settings_submit(array $form, $translatable = FALSE; } $field_config = $fields[$field_name]->getConfig($bundle); - if ($field_config->isTranslatable() != $translatable) { + if ($field_config->isTranslatable() !== $translatable) { $field_config ->setTranslatable($translatable) ->save(); diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index f1a1b60..23f9aa9 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -457,7 +457,7 @@ function content_translation_language_fallback_candidates_entity_view_alter(&$ca $entity = $context['data']; $entity_type_id = $entity->getEntityTypeId(); $entity_type = $entity->getEntityType(); - $permission = $entity_type->getPermissionGranularity() == 'bundle' ? $permission = "translate {$entity->bundle()} $entity_type_id" : "translate $entity_type_id"; + $permission = $entity_type->getPermissionGranularity() === 'bundle' ? $permission = "translate {$entity->bundle()} $entity_type_id" : "translate $entity_type_id"; $current_user = \Drupal::currentuser(); if (!$current_user->hasPermission('translate any entity') && !$current_user->hasPermission($permission)) { foreach ($entity->getTranslationLanguages() as $langcode => $language) { @@ -751,7 +751,7 @@ function content_translation_language_configuration_element_submit(array $form, $context = $form_state->get(['language', $key]); $enabled = $form_state->getValue(array($key, 'content_translation')); - if (content_translation_enabled($context['entity_type'], $context['bundle']) != $enabled) { + if (content_translation_enabled($context['entity_type'], $context['bundle']) !== $enabled) { content_translation_set_config($context['entity_type'], $context['bundle'], 'enabled', $enabled); \Drupal::entityManager()->clearCachedDefinitions(); \Drupal::service('router.builder')->setRebuildNeeded(); diff --git a/core/modules/content_translation/src/Access/ContentTranslationManageAccessCheck.php b/core/modules/content_translation/src/Access/ContentTranslationManageAccessCheck.php index 6c85edd..d162ac8 100644 --- a/core/modules/content_translation/src/Access/ContentTranslationManageAccessCheck.php +++ b/core/modules/content_translation/src/Access/ContentTranslationManageAccessCheck.php @@ -87,7 +87,7 @@ public function access(Route $route, Request $request, AccountInterface $account case 'create': $source_language = $this->languageManager->getLanguage($source) ?: $entity->language(); $target_language = $this->languageManager->getLanguage($target) ?: $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT); - $is_new_translation = ($source_language->getId() != $target_language->getId() + $is_new_translation = ($source_language->getId() !== $target_language->getId() && isset($languages[$source_language->getId()]) && isset($languages[$target_language->getId()]) && !isset($translations[$target_language->getId()])); @@ -98,7 +98,7 @@ public function access(Route $route, Request $request, AccountInterface $account case 'delete': $language = $this->languageManager->getLanguage($language) ?: $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT); $has_translation = isset($languages[$language->getId()]) - && $language->getId() != $entity->getUntranslated()->language()->getId() + && $language->getId() !== $entity->getUntranslated()->language()->getId() && isset($translations[$language->getId()]); return AccessResult::allowedIf($has_translation)->cachePerRole()->cacheUntilEntityChanges($entity) ->andIf($handler->getTranslationAccess($entity, $operation)); diff --git a/core/modules/content_translation/src/Access/ContentTranslationOverviewAccess.php b/core/modules/content_translation/src/Access/ContentTranslationOverviewAccess.php index 13e240b..5fa739f 100644 --- a/core/modules/content_translation/src/Access/ContentTranslationOverviewAccess.php +++ b/core/modules/content_translation/src/Access/ContentTranslationOverviewAccess.php @@ -69,7 +69,7 @@ public function access(Request $request, AccountInterface $account) { // Check per entity permission. $permission = "translate {$entity_type}"; - if ($definition->getPermissionGranularity() == 'bundle') { + if ($definition->getPermissionGranularity() === 'bundle') { $permission = "translate {$bundle} {$entity_type}"; } return $access->allowIfHasPermission($account, $permission); diff --git a/core/modules/content_translation/src/ContentTranslationHandler.php b/core/modules/content_translation/src/ContentTranslationHandler.php index b619036..b875c3d 100644 --- a/core/modules/content_translation/src/ContentTranslationHandler.php +++ b/core/modules/content_translation/src/ContentTranslationHandler.php @@ -53,7 +53,7 @@ public function retranslate(EntityInterface $entity, $langcode = NULL) { $updated_langcode = !empty($langcode) ? $langcode : $entity->language()->id; $translations = $entity->getTranslationLanguages(); foreach ($translations as $langcode => $language) { - $entity->translation[$langcode]['outdated'] = $langcode != $updated_langcode; + $entity->translation[$langcode]['outdated'] = $langcode !== $updated_langcode; } } @@ -69,7 +69,7 @@ public function getTranslationAccess(EntityInterface $entity, $op) { // explicit translate permission. $current_user = \Drupal::currentUser(); if (!$current_user->hasPermission('translate any entity') && $permission_granularity = $entity_type->getPermissionGranularity()) { - $translate_permission = $current_user->hasPermission($permission_granularity == 'bundle' ? "translate {$entity->bundle()} {$entity->getEntityTypeId()}" : "translate {$entity->getEntityTypeId()}"); + $translate_permission = $current_user->hasPermission($permission_granularity === 'bundle' ? "translate {$entity->bundle()} {$entity->getEntityTypeId()}" : "translate {$entity->getEntityTypeId()}"); } return AccessResult::allowedIf($translate_permission && $current_user->hasPermission("$op content translations"))->cachePerRole(); } @@ -108,7 +108,7 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En if (isset($languages[$form_langcode]) && ($has_translations || $new_translation)) { $title = $this->entityFormTitle($entity); // When editing the original values display just the entity label. - if ($form_langcode != $entity_langcode) { + if ($form_langcode !== $entity_langcode) { $t_args = array('%language' => $languages[$form_langcode]->name, '%title' => $entity->label()); $title = empty($source_langcode) ? $title . ' [' . t('%language translation', $t_args) . ']' : t('Create %language translation of %title', $t_args); } @@ -147,11 +147,11 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En // Disable languages for existing translations, so it is not possible to // switch this node to some language which is already in the translation // set. - $language_widget = isset($form['langcode']) && $form['langcode']['#type'] == 'language_select'; + $language_widget = isset($form['langcode']) && $form['langcode']['#type'] === 'language_select'; if ($language_widget && $has_translations) { $form['langcode']['#options'] = array(); foreach (language_list(LanguageInterface::STATE_CONFIGURABLE) as $language) { - if (empty($translations[$language->id]) || $language->id == $entity_langcode) { + if (empty($translations[$language->id]) || $language->id === $entity_langcode) { $form['langcode']['#options'][$language->id] = $language->name; } } diff --git a/core/modules/content_translation/src/Controller/ContentTranslationController.php b/core/modules/content_translation/src/Controller/ContentTranslationController.php index 93b4887..dfb0a6b 100644 --- a/core/modules/content_translation/src/Controller/ContentTranslationController.php +++ b/core/modules/content_translation/src/Controller/ContentTranslationController.php @@ -70,7 +70,7 @@ public function overview(Request $request, $entity_type_id = NULL) { // Show source-language column if there are non-original source langcodes. $additional_source_langcodes = array_filter($entity->translation, function ($translation) use ($original) { - return !empty($translation['source']) && $translation['source'] != $original; + return !empty($translation['source']) && $translation['source'] !== $original; }); $show_source_column = !empty($additional_source_langcodes); @@ -120,7 +120,7 @@ public function overview(Request $request, $entity_type_id = NULL) { if (array_key_exists($langcode, $translations)) { // Existing translation in the translation set: display status. $source = isset($entity->translation[$langcode]['source']) ? $entity->translation[$langcode]['source'] : ''; - $is_original = $langcode == $original; + $is_original = $langcode === $original; $label = $entity->getTranslation($langcode)->label(); $link = isset($links->links[$langcode]['href']) ? $links->links[$langcode] : array('href' => $entity->getSystemPath()); $link += array('language' => $language); @@ -174,7 +174,7 @@ public function overview(Request $request, $entity_type_id = NULL) { $row_title = $source_name = $this->t('n/a'); $source = $entity->language()->getId(); - if ($source != $langcode && $handler->getTranslationAccess($entity, 'create')->isAllowed()) { + if ($source !== $langcode && $handler->getTranslationAccess($entity, 'create')->isAllowed()) { if ($translatable) { $links['add'] = array( 'title' => $this->t('Add'), diff --git a/core/modules/content_translation/src/FieldTranslationSynchronizer.php b/core/modules/content_translation/src/FieldTranslationSynchronizer.php index 6715577..2336d6a 100644 --- a/core/modules/content_translation/src/FieldTranslationSynchronizer.php +++ b/core/modules/content_translation/src/FieldTranslationSynchronizer.php @@ -51,7 +51,7 @@ public function synchronizeFields(ContentEntityInterface $entity, $sync_langcode // If the entity language is being changed there is nothing to synchronize. $entity_type = $entity->getEntityTypeId(); $entity_unchanged = isset($entity->original) ? $entity->original : $this->entityManager->getStorage($entity_type)->loadUnchanged($entity->id()); - if ($entity->getUntranslated()->language()->id != $entity_unchanged->getUntranslated()->language()->id) { + if ($entity->getUntranslated()->language()->id !== $entity_unchanged->getUntranslated()->language()->id) { return; } @@ -133,7 +133,7 @@ public function synchronizeItems(array &$values, array $unchanged_items, $sync_l foreach ($translations as $langcode) { // We need to synchronize only values different from the source ones. - if ($langcode != $sync_langcode) { + if ($langcode !== $sync_langcode) { // Reinitialize the change map as it is emptied while processing each // language. $change_map = $original_change_map; diff --git a/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php b/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php index 5783ed8..2af181d 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php @@ -192,7 +192,7 @@ function testImageFieldSync() { $translation = $entity->getTranslation($langcode); // Check that one value has been dropped from the original values. - $assert = count($entity->{$this->fieldName}) == 2; + $assert = count($entity->{$this->fieldName}) === 2; $this->assertTrue($assert, 'One item correctly removed from the synchronized field values.'); // Check that fids have been synchronized and translatable column values @@ -201,7 +201,7 @@ function testImageFieldSync() { foreach ($entity->{$this->fieldName} as $delta => $item) { $value = $values[$default_langcode][$item->target_id]; $source_item = $translation->{$this->fieldName}->get($delta); - $assert = $item->target_id == $source_item->target_id && $item->alt == $value['alt'] && $item->title == $value['title']; + $assert = $item->target_id === $source_item->target_id && $item->alt === $value['alt'] && $item->title === $value['title']; $this->assertTrue($assert, format_string('Field item @fid has been successfully synchronized.', array('@fid' => $item->target_id))); $fids[$item->target_id] = TRUE; } @@ -223,17 +223,17 @@ function testImageFieldSync() { $translation = $entity->getTranslation($langcode); // Check that the value has been added to the default language. - $assert = count($entity->{$this->fieldName}->getValue()) == 3; + $assert = count($entity->{$this->fieldName}->getValue()) === 3; $this->assertTrue($assert, 'One item correctly added to the synchronized field values.'); foreach ($entity->{$this->fieldName} as $delta => $item) { // When adding an item its value is copied over all the target languages, // thus in this case the source language needs to be used to check the // values instead of the target one. - $fid_langcode = $item->target_id != $removed_fid ? $default_langcode : $langcode; + $fid_langcode = $item->target_id !== $removed_fid ? $default_langcode : $langcode; $value = $values[$fid_langcode][$item->target_id]; $source_item = $translation->{$this->fieldName}->get($delta); - $assert = $item->target_id == $source_item->target_id && $item->alt == $value['alt'] && $item->title == $value['title']; + $assert = $item->target_id === $source_item->target_id && $item->alt === $value['alt'] && $item->title === $value['title']; $this->assertTrue($assert, format_string('Field item @fid has been successfully synchronized.', array('@fid' => $item->target_id))); } } diff --git a/core/modules/content_translation/src/Tests/ContentTranslationSyncUnitTest.php b/core/modules/content_translation/src/Tests/ContentTranslationSyncUnitTest.php index b05b446..1ba2158 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationSyncUnitTest.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationSyncUnitTest.php @@ -76,7 +76,7 @@ protected function setUp() { foreach ($this->langcodes as $langcode) { for ($delta = 0; $delta < $this->cardinality; $delta++) { foreach ($this->columns as $column) { - $sync = in_array($column, $this->synchronized) && $langcode != $this->langcodes[0]; + $sync = in_array($column, $this->synchronized) && $langcode !== $this->langcodes[0]; $value = $sync ? $this->unchangedFieldValues[$this->langcodes[0]][$delta][$column] : $langcode . '-' . $delta . '-' . $column; $this->unchangedFieldValues[$langcode][$delta][$column] = $value; } @@ -104,12 +104,12 @@ public function testFieldSync() { // Check that the old values are still in place. for ($delta = 0; $delta < $this->cardinality; $delta++) { foreach ($this->columns as $column) { - $result = $result && ($this->unchangedFieldValues[$langcode][$delta][$column] == $field_values[$langcode][$delta][$column]); + $result = $result && ($this->unchangedFieldValues[$langcode][$delta][$column] === $field_values[$langcode][$delta][$column]); } } // Check that the new item is available in all languages. foreach ($this->columns as $column) { - $result = $result && ($field_values[$langcode][$delta][$column] == $field_values[$sync_langcode][$delta][$column]); + $result = $result && ($field_values[$langcode][$delta][$column] === $field_values[$sync_langcode][$delta][$column]); } } $this->assertTrue($result, 'A new item has been correctly synchronized.'); @@ -130,9 +130,9 @@ public function testFieldSync() { // Check that the old values are still in place. for ($delta = 0; $delta < $this->cardinality; $delta++) { // Skip the removed item. - if ($delta != $sync_delta) { + if ($delta !== $sync_delta) { foreach ($this->columns as $column) { - $result = $result && ($this->unchangedFieldValues[$langcode][$delta][$column] == $field_values[$langcode][$new_delta][$column]); + $result = $result && ($this->unchangedFieldValues[$langcode][$delta][$column] === $field_values[$langcode][$new_delta][$column]); } $new_delta++; } @@ -162,12 +162,12 @@ public function testFieldSync() { if (in_array($column, $this->synchronized)) { // If we are dealing with a synchronize column the current value is // supposed to be the same of the source items. - $result = $result && $field_values[$sync_langcode][$delta][$column] == $value; + $result = $result && $field_values[$sync_langcode][$delta][$column] === $value; } else { // Otherwise the values should be unchanged. $old_delta = ($delta > 0 ? $delta : $this->cardinality) - 1; - $result = $result && $this->unchangedFieldValues[$langcode][$old_delta][$column] == $value; + $result = $result && $this->unchangedFieldValues[$langcode][$old_delta][$column] === $value; } } } @@ -217,7 +217,7 @@ function($delta) { return $delta === 0 || $delta === 3; }, // synchronization process. The other ones are retained or synced // depending on the logic implemented by the delta callback. $value = $delta > 0 && $delta_callback($delta) ? $changed_items[0][$column] : $unchanged_items[$delta][$column]; - $result = $result && ($field_values[$langcode][$delta][$column] == $value); + $result = $result && ($field_values[$langcode][$delta][$column] === $value); } } } @@ -245,7 +245,7 @@ public function testDifferingSyncedColumns() { foreach ($this->unchangedFieldValues as $langcode => $unchanged_items) { for ($delta = 0; $delta < $this->cardinality; $delta++) { foreach ($this->columns as $column) { - $result = $result && ($field_values[$langcode][$delta][$column] == $changed_items[$delta][$column]); + $result = $result && ($field_values[$langcode][$delta][$column] === $changed_items[$delta][$column]); } } } diff --git a/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php b/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php index f2fa13d..8e8b43a 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php @@ -119,7 +119,7 @@ protected function getTranslatorPermissions() { protected function getTranslatePermission() { $entity_type = \Drupal::entityManager()->getDefinition($this->entityTypeId); if ($permission_granularity = $entity_type->getPermissionGranularity()) { - return $permission_granularity == 'bundle' ? "translate {$this->bundle} {$this->entityTypeId}" : "translate {$this->entityTypeId}"; + return $permission_granularity === 'bundle' ? "translate {$this->bundle} {$this->entityTypeId}" : "translate {$this->entityTypeId}"; } } diff --git a/core/modules/content_translation/src/Tests/ContentTranslationUITest.php b/core/modules/content_translation/src/Tests/ContentTranslationUITest.php index 58d0c59..8bdbf73 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationUITest.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationUITest.php @@ -147,10 +147,10 @@ protected function doTestOutdatedStatus() { // Check that every translation has the correct "outdated" status. foreach ($this->langcodes as $added_langcode) { - $prefix = $added_langcode != $default_langcode ? $added_langcode . '/' : ''; + $prefix = $added_langcode !== $default_langcode ? $added_langcode . '/' : ''; $path = $prefix . $edit_path; $this->drupalGet($path); - if ($added_langcode == $langcode) { + if ($added_langcode === $langcode) { $this->assertFieldByXPath('//input[@name="content_translation[retranslate]"]', FALSE, 'The retranslate flag is not checked by default.'); } else { @@ -242,7 +242,7 @@ protected function doTestTranslationDeletion() { $entity = entity_load($this->entityTypeId, $this->entityId, TRUE); if ($this->assertTrue(is_object($entity), 'Entity found')) { $translations = $entity->getTranslationLanguages(); - $this->assertTrue(count($translations) == 2 && empty($translations[$langcode]), 'Translation successfully deleted.'); + $this->assertTrue(count($translations) === 2 && empty($translations[$langcode]), 'Translation successfully deleted.'); } } @@ -343,7 +343,7 @@ protected function getTranslation(EntityInterface $entity, $langcode) { * The property value. */ protected function getValue(EntityInterface $translation, $property, $langcode) { - $key = $property == 'user_id' ? 'target_id' : 'value'; + $key = $property === 'user_id' ? 'target_id' : 'value'; return $translation->get($property)->{$key}; } diff --git a/core/modules/content_translation/src/Tests/ContentTranslationWorkflowsTest.php b/core/modules/content_translation/src/Tests/ContentTranslationWorkflowsTest.php index ccb3f80..8a1ad6a 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationWorkflowsTest.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationWorkflowsTest.php @@ -92,7 +92,7 @@ function testWorkflows() { $this->drupalGet($translations_path); foreach ($ops as $op => $label) { - if ($op != $current_op) { + if ($op !== $current_op) { $this->assertNoLink($label, format_string('No %op link found.', array('%op' => $label))); } else { @@ -132,12 +132,12 @@ protected function assertWorkflows(UserInterface $user, $expected_status) { // Check whether the user is allowed to create a translation. $add_translation_path = $translations_path . "/add/$default_langcode/$langcode"; - if ($expected_status['add_translation'] == 200) { + if ($expected_status['add_translation'] === 200) { $this->clickLink('Add'); $this->assertUrl($add_translation_path, $options, 'The translation overview points to the translation form when creating translations.'); // Check that the translation form does not contain shared elements for // translators. - if ($expected_status['edit'] == 403) { + if ($expected_status['edit'] === 403) { $this->assertNoSharedElements(); } } @@ -150,9 +150,9 @@ protected function assertWorkflows(UserInterface $user, $expected_status) { $langcode = $this->langcodes[2]; $edit_translation_path = $translations_path . "/edit/$langcode"; $options = array('language' => $languages[$langcode]); - if ($expected_status['edit_translation'] == 200) { + if ($expected_status['edit_translation'] === 200) { $this->drupalGet($translations_path, $options); - $editor = $expected_status['edit'] == 200; + $editor = $expected_status['edit'] === 200; if ($editor) { $this->clickLink('Edit', 2); diff --git a/core/modules/datetime/src/DateTimeComputed.php b/core/modules/datetime/src/DateTimeComputed.php index 271cba9..fc4d81d 100644 --- a/core/modules/datetime/src/DateTimeComputed.php +++ b/core/modules/datetime/src/DateTimeComputed.php @@ -48,7 +48,7 @@ public function getValue($langcode = NULL) { $item = $this->getParent(); $value = $item->{($this->definition->getSetting('date source'))}; - $storage_format = $item->getFieldDefinition()->getSetting('datetime_type') == 'date' ? DATETIME_DATE_STORAGE_FORMAT : DATETIME_DATETIME_STORAGE_FORMAT; + $storage_format = $item->getFieldDefinition()->getSetting('datetime_type') === 'date' ? DATETIME_DATE_STORAGE_FORMAT : DATETIME_DATETIME_STORAGE_FORMAT; try { $date = DrupalDateTime::createFromFormat($storage_format, $value, DATETIME_STORAGE_TIMEZONE); if ($date instanceOf DrupalDateTime && !$date->hasErrors()) { diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php index f983c8d..e3533cb 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php +++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php @@ -118,7 +118,7 @@ public function viewElements(FieldItemListInterface $items) { // The formatted output will be in local time. $date->setTimeZone(timezone_open(drupal_get_user_timezone())); - if ($this->getFieldSetting('datetime_type') == 'date') { + if ($this->getFieldSetting('datetime_type') === 'date') { // A date without time will pick up the current time, use the default. datetime_date_default_time($date); } diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php index 24fc69c..de0ca0b 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php +++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php @@ -39,7 +39,7 @@ public function viewElements(FieldItemListInterface $items) { $date = $item->date; $date->setTimeZone(timezone_open(drupal_get_user_timezone())); $format = DATETIME_DATETIME_STORAGE_FORMAT; - if ($this->getFieldSetting('datetime_type') == 'date') { + if ($this->getFieldSetting('datetime_type') === 'date') { // A date without time will pick up the current time, use the default. datetime_date_default_time($date); $format = DATETIME_DATE_STORAGE_FORMAT; diff --git a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php index e78a194..75dbd79 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php +++ b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php @@ -52,7 +52,7 @@ public function defaultValuesForm(array &$form, FormStateInterface $form_state) '#type' => 'textfield', '#title' => t('Relative default value'), '#description' => t("Describe a time by reference to the current day, like '+90 days' (90 days from the day the field is created) or '+1 Saturday' (the next Saturday). See !strtotime for more details.", array('!strtotime' => l('strtotime', 'http://www.php.net/manual/en/function.strtotime.php'))), - '#default_value' => (isset($default_value[0]['default_date_type']) && $default_value[0]['default_date_type'] == static::DEFAULT_VALUE_CUSTOM) ? $default_value[0]['default_date'] : '', + '#default_value' => (isset($default_value[0]['default_date_type']) && $default_value[0]['default_date_type'] === static::DEFAULT_VALUE_CUSTOM) ? $default_value[0]['default_date'] : '', '#states' => array( 'visible' => array( ':input[id="edit-default-value-input-default-date-type"]' => array('value' => static::DEFAULT_VALUE_CUSTOM), @@ -69,7 +69,7 @@ public function defaultValuesForm(array &$form, FormStateInterface $form_state) * {@inheritdoc} */ public function defaultValuesFormValidate(array $element, array &$form, FormStateInterface $form_state) { - if ($form_state->getValue(['default_value_input', 'default_date_type']) == static::DEFAULT_VALUE_CUSTOM) { + if ($form_state->getValue(['default_value_input', 'default_date_type']) === static::DEFAULT_VALUE_CUSTOM) { $is_strtotime = @strtotime($form_state->getValue(array('default_value_input', 'default_date'))); if (!$is_strtotime) { $form_state->setErrorByName('default_value_input][default_date', t('The relative date value entered is invalid.')); @@ -82,7 +82,7 @@ public function defaultValuesFormValidate(array $element, array &$form, FormStat */ public function defaultValuesFormSubmit(array $element, array &$form, FormStateInterface $form_state) { if ($form_state->getValue(array('default_value_input', 'default_date_type'))) { - if ($form_state->getValue(array('default_value_input', 'default_date_type')) == static::DEFAULT_VALUE_NOW) { + if ($form_state->getValue(array('default_value_input', 'default_date_type')) === static::DEFAULT_VALUE_NOW) { $form_state->setValueForElement($element['default_date'], static::DEFAULT_VALUE_NOW); } return array($form_state->getValue('default_value_input')); @@ -100,7 +100,7 @@ public static function processDefaultValue($default_value, ContentEntityInterfac // A default value should be in the format and timezone used for date // storage. $date = new DrupalDateTime($default_value[0]['default_date'], DATETIME_STORAGE_TIMEZONE); - $storage_format = $definition->getSetting('datetime_type') == DateTimeItem::DATETIME_TYPE_DATE ? DATETIME_DATE_STORAGE_FORMAT: DATETIME_DATETIME_STORAGE_FORMAT; + $storage_format = $definition->getSetting('datetime_type') === DateTimeItem::DATETIME_TYPE_DATE ? DATETIME_DATE_STORAGE_FORMAT: DATETIME_DATETIME_STORAGE_FORMAT; $value = $date->format($storage_format); // We only provide a default value for the first item, as do all fields. // Otherwise, there is no way to clear out unwanted values on multiple value diff --git a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php index 4b37a3c..fb091b4 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php +++ b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php @@ -111,7 +111,7 @@ public static function generateSampleValue(FieldDefinitionInterface $field_defin // Just pick a date in the past year. No guidance is provided by this Field // type. $timestamp = REQUEST_TIME - mt_rand(0, 86400*365); - if ($type == DateTimeItem::DATETIME_TYPE_DATE) { + if ($type === DateTimeItem::DATETIME_TYPE_DATE) { $values['value'] = gmdate(DATETIME_DATE_STORAGE_FORMAT, $timestamp); } else { @@ -135,7 +135,7 @@ public function onChange($property_name) { parent::onChange($property_name); // Enforce that the computed date is recalculated. - if ($property_name == 'value') { + if ($property_name === 'value') { $this->date = NULL; } } diff --git a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php index d460416..7bedafb 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php +++ b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php @@ -92,7 +92,7 @@ function settingsForm(array $form, FormStateInterface $form_state) { '#options' => array('MDY' => t('Month/Day/Year'), 'DMY' => t('Day/Month/Year'), 'YMD' => t('Year/Month/Day')), ); - if ($this->getFieldSetting('datetime_type') == 'datetime') { + if ($this->getFieldSetting('datetime_type') === 'datetime') { $element['time_type'] = array( '#type' => 'select', '#title' => t('Time type'), @@ -129,7 +129,7 @@ public function settingsSummary() { $summary = array(); $summary[] = t('Date part order: !order', array('!order' => $this->getSetting('date_order'))); - if ($this->getFieldSetting('datetime_type') == 'datetime') { + if ($this->getFieldSetting('datetime_type') === 'datetime') { $summary[] = t('Time type: !time_type', array('!time_type' => $this->getSetting('time_type'))); } $summary[] = t('Time increments: !increment', array('!increment' => $this->getSetting('increment'))); diff --git a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php index 32d3668..375b870 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php +++ b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php @@ -44,7 +44,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen // The date was created and verified during field_load(), so it is safe to // use without further inspection. $date->setTimezone(new \DateTimeZone($element['value']['#date_timezone'])); - if ($this->getFieldSetting('datetime_type') == DateTimeItem::DATETIME_TYPE_DATE) { + if ($this->getFieldSetting('datetime_type') === DateTimeItem::DATETIME_TYPE_DATE) { // A date without time will pick up the current time, use the default // time. datetime_date_default_time($date); diff --git a/core/modules/dblog/src/Tests/DbLogTest.php b/core/modules/dblog/src/Tests/DbLogTest.php index 4dc37e4..1ce3053 100644 --- a/core/modules/dblog/src/Tests/DbLogTest.php +++ b/core/modules/dblog/src/Tests/DbLogTest.php @@ -86,7 +86,7 @@ private function verifyRowLimit($row_limit) { // Check row limit variable. $current_limit = \Drupal::config('dblog.settings')->get('row_limit'); - $this->assertTrue($current_limit == $row_limit, format_string('[Cache] Row limit variable of @count equals row limit of @limit', array('@count' => $current_limit, '@limit' => $row_limit))); + $this->assertTrue($current_limit === $row_limit, format_string('[Cache] Row limit variable of @count equals row limit of @limit', array('@count' => $current_limit, '@limit' => $row_limit))); } /** @@ -107,7 +107,7 @@ private function verifyCron($row_limit) { // Verify that the database log row count equals the row limit plus one // because cron adds a record after it runs. $count = db_query('SELECT COUNT(wid) FROM {watchdog}')->fetchField(); - $this->assertTrue($count == $row_limit + 1, format_string('Dblog row count of @count equals row limit of @limit plus one', array('@count' => $count, '@limit' => $row_limit))); + $this->assertTrue($count === $row_limit + 1, format_string('Dblog row count of @count equals row limit of @limit plus one', array('@count' => $count, '@limit' => $row_limit))); } /** @@ -154,28 +154,28 @@ private function verifyReports($response = 200) { // View the database log help page. $this->drupalGet('admin/help/dblog'); $this->assertResponse($response); - if ($response == 200) { + if ($response === 200) { $this->assertText(t('Database Logging'), 'DBLog help was displayed'); } // View the database log report page. $this->drupalGet('admin/reports/dblog'); $this->assertResponse($response); - if ($response == 200) { + if ($response === 200) { $this->assertText(t('Recent log messages'), 'DBLog report was displayed'); } // View the database log page-not-found report page. $this->drupalGet('admin/reports/page-not-found'); $this->assertResponse($response); - if ($response == 200) { + if ($response === 200) { $this->assertText("Top 'page not found' errors", 'DBLog page-not-found report was displayed'); } // View the database log access-denied report page. $this->drupalGet('admin/reports/access-denied'); $this->assertResponse($response); - if ($response == 200) { + if ($response === 200) { $this->assertText("Top 'access denied' errors", 'DBLog access-denied report was displayed'); } @@ -183,7 +183,7 @@ private function verifyReports($response = 200) { $wid = db_query('SELECT MIN(wid) FROM {watchdog}')->fetchField(); $this->drupalGet('admin/reports/dblog/event/' . $wid); $this->assertResponse($response); - if ($response == 200) { + if ($response === 200) { $this->assertText(t('Details'), 'DBLog event node was displayed'); } @@ -236,7 +236,7 @@ private function doUser() { $this->assertResponse(200); // Retrieve the user object. $user = user_load_by_name($name); - $this->assertTrue($user != NULL, format_string('User @name was loaded', array('@name' => $name))); + $this->assertTrue($user !== NULL, format_string('User @name was loaded', array('@name' => $name))); // pass_raw property is needed by drupalLogin. $user->pass_raw = $pass; // Login user. @@ -279,7 +279,7 @@ private function doUser() { // Found link with the message text. $links = array_shift($links); foreach ($links->attributes() as $attr => $value) { - if ($attr == 'href') { + if ($attr === 'href') { // Extract link to details page. $link = drupal_substr($value, strpos($value, 'admin/reports/dblog/event/')); $this->drupalGet($link); @@ -322,7 +322,7 @@ private function doNode($type) { $this->assertResponse(200); // Retrieve the node object. $node = $this->drupalGetNodeByTitle($title); - $this->assertTrue($node != NULL, format_string('Node @title was loaded', array('@title' => $title))); + $this->assertTrue($node !== NULL, format_string('Node @title was loaded', array('@title' => $title))); // Edit the node. $edit = $this->getContentUpdate($type); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); @@ -492,7 +492,7 @@ protected function testFilter() { // Count the number of entries of this type. $type_count = 0; foreach ($types as $type) { - if ($type['type'] == $type_name) { + if ($type['type'] === $type_name) { $type_count += $type['count']; } } @@ -565,7 +565,7 @@ protected function getTypeCount(array $types) { $count = array_fill(0, count($types), 0); foreach ($entries as $entry) { foreach ($types as $key => $type) { - if ($entry['type'] == $type['type'] && $entry['severity'] == $type['severity']) { + if ($entry['type'] === $type['type'] && $entry['severity'] === $type['severity']) { $count[$key]++; break; } diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index 85f58fa..efdbd1a 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -214,7 +214,7 @@ function editor_form_filter_admin_format_submit($form, FormStateInterface $form_ // Delete the existing editor if disabling or switching between editors. $format_id = $form_state->getFormObject()->getEntity()->id(); $original_editor = editor_load($format_id); - if ($original_editor && $original_editor->getEditor() != $form_state->getValue('editor')) { + if ($original_editor && $original_editor->getEditor() !== $form_state->getValue('editor')) { $original_editor->delete(); } @@ -339,7 +339,7 @@ function editor_entity_update(EntityInterface $entity) { // On new revisions, all files are considered to be a new usage and no // deletion of previous file usages are necessary. - if (!empty($entity->original) && $entity->getRevisionId() != $entity->original->getRevisionId()) { + if (!empty($entity->original) && $entity->getRevisionId() !== $entity->original->getRevisionId()) { $referenced_files_by_field = _editor_get_file_uuids_by_field($entity); foreach ($referenced_files_by_field as $field => $uuids) { _editor_record_file_usage($uuids, $entity); diff --git a/core/modules/editor/src/Plugin/InPlaceEditor/Editor.php b/core/modules/editor/src/Plugin/InPlaceEditor/Editor.php index d729943..248ea2c 100644 --- a/core/modules/editor/src/Plugin/InPlaceEditor/Editor.php +++ b/core/modules/editor/src/Plugin/InPlaceEditor/Editor.php @@ -29,7 +29,7 @@ public function isCompatible(FieldItemListInterface $items) { $field_definition = $items->getFieldDefinition(); // This editor is incompatible with multivalued fields. - if ($field_definition->getFieldStorageDefinition()->getCardinality() != 1) { + if ($field_definition->getFieldStorageDefinition()->getCardinality() !== 1) { return FALSE; } // This editor is compatible with processed ("rich") text fields; but only diff --git a/core/modules/entity_reference/entity_reference.module b/core/modules/entity_reference/entity_reference.module index 2fcfecd..5aeb406 100644 --- a/core/modules/entity_reference/entity_reference.module +++ b/core/modules/entity_reference/entity_reference.module @@ -69,7 +69,7 @@ function entity_reference_field_widget_info_alter(&$info) { * Reset the instance handler settings, when the target type is changed. */ function entity_reference_field_storage_config_update(FieldStorageConfigInterface $field_storage) { - if ($field_storage->type != 'entity_reference') { + if ($field_storage->type !== 'entity_reference') { // Only act on entity reference fields. return; } @@ -79,7 +79,7 @@ function entity_reference_field_storage_config_update(FieldStorageConfigInterfac return; } - if ($field_storage->getSetting('target_type') == $field_storage->original->getSetting('target_type')) { + if ($field_storage->getSetting('target_type') === $field_storage->original->getSetting('target_type')) { // Target type didn't change. return; } diff --git a/core/modules/entity_reference/src/ConfigurableEntityReferenceItem.php b/core/modules/entity_reference/src/ConfigurableEntityReferenceItem.php index f4fd800..bbbe8d8 100644 --- a/core/modules/entity_reference/src/ConfigurableEntityReferenceItem.php +++ b/core/modules/entity_reference/src/ConfigurableEntityReferenceItem.php @@ -94,7 +94,7 @@ public function getSettableOptions(AccountInterface $account = NULL) { $return[$bundle_label] = $entity_ids; } - return count($return) == 1 ? reset($return) : $return; + return count($return) === 1 ? reset($return) : $return; } /** diff --git a/core/modules/entity_reference/src/EntityReferenceController.php b/core/modules/entity_reference/src/EntityReferenceController.php index 026b5d5..98c349a 100644 --- a/core/modules/entity_reference/src/EntityReferenceController.php +++ b/core/modules/entity_reference/src/EntityReferenceController.php @@ -79,7 +79,7 @@ public function handleAutocomplete(Request $request, $type, $field_name, $entity $field_definition = $definitions[$field_name]; $access_control_handler = $this->entityManager()->getAccessControlHandler($entity_type); - if ($field_definition->getType() != 'entity_reference' || !$access_control_handler->fieldAccess('edit', $field_definition)) { + if ($field_definition->getType() !== 'entity_reference' || !$access_control_handler->fieldAccess('edit', $field_definition)) { throw new AccessDeniedHttpException(); } @@ -91,7 +91,7 @@ public function handleAutocomplete(Request $request, $type, $field_name, $entity $prefix = ''; // The user entered a comma-separated list of entity labels, so we generate // a prefix. - if ($type == 'tags' && !empty($last_item)) { + if ($type === 'tags' && !empty($last_item)) { $prefix = count($items_typed) ? Tags::implode($items_typed) . ', ' : ''; } diff --git a/core/modules/entity_reference/src/Plugin/Field/FieldWidget/AutocompleteTagsWidget.php b/core/modules/entity_reference/src/Plugin/Field/FieldWidget/AutocompleteTagsWidget.php index b289a06..f9c9063 100644 --- a/core/modules/entity_reference/src/Plugin/Field/FieldWidget/AutocompleteTagsWidget.php +++ b/core/modules/entity_reference/src/Plugin/Field/FieldWidget/AutocompleteTagsWidget.php @@ -70,7 +70,7 @@ public function elementValidate($element, FormStateInterface $form_state, $form) if ($match) { $value[] = array('target_id' => $match); } - elseif ($auto_create && (count($this->getSelectionHandlerSetting('target_bundles')) == 1 || count($bundles) == 1)) { + elseif ($auto_create && (count($this->getSelectionHandlerSetting('target_bundles')) === 1 || count($bundles) === 1)) { // Auto-create item. See // \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::presave(). $value[] = array( diff --git a/core/modules/entity_reference/src/Plugin/Field/FieldWidget/AutocompleteWidget.php b/core/modules/entity_reference/src/Plugin/Field/FieldWidget/AutocompleteWidget.php index ef9e6ea..2e2341c 100644 --- a/core/modules/entity_reference/src/Plugin/Field/FieldWidget/AutocompleteWidget.php +++ b/core/modules/entity_reference/src/Plugin/Field/FieldWidget/AutocompleteWidget.php @@ -80,7 +80,7 @@ public function elementValidate($element, FormStateInterface $form_state, $form) $value = $handler->validateAutocompleteInput($element['#value'], $element, $form_state, $form, !$auto_create); } - if (!$value && $auto_create && (count($this->getSelectionHandlerSetting('target_bundles')) == 1)) { + if (!$value && $auto_create && (count($this->getSelectionHandlerSetting('target_bundles')) === 1)) { // Auto-create item. See // \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::presave(). $value = array( diff --git a/core/modules/entity_reference/src/Plugin/entity_reference/selection/SelectionBase.php b/core/modules/entity_reference/src/Plugin/entity_reference/selection/SelectionBase.php index aba32fd..fefb7c7 100644 --- a/core/modules/entity_reference/src/Plugin/entity_reference/selection/SelectionBase.php +++ b/core/modules/entity_reference/src/Plugin/entity_reference/selection/SelectionBase.php @@ -86,10 +86,10 @@ public static function settingsForm(FieldDefinitionInterface $field_definition) $target_bundles_title = t('Bundles'); // Default core entity types with sensible labels. - if ($entity_type_id == 'node') { + if ($entity_type_id === 'node') { $target_bundles_title = t('Content types'); } - elseif ($entity_type_id == 'taxonomy_term') { + elseif ($entity_type_id === 'taxonomy_term') { $target_bundles_title = t('Vocabularies'); } @@ -151,7 +151,7 @@ public static function settingsForm(FieldDefinitionInterface $field_definition) '#process' => array('_entity_reference_form_process_merge_parent'), ); - if ($selection_handler_settings['sort']['field'] != '_none') { + if ($selection_handler_settings['sort']['field'] !== '_none') { // Merge-in default values. $selection_handler_settings['sort'] += array( 'direction' => 'ASC', @@ -306,7 +306,7 @@ public function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') { $handler_settings = $this->fieldDefinition->getSetting('handler_settings'); if (!empty($handler_settings['sort'])) { $sort_settings = $handler_settings['sort']; - if ($sort_settings['field'] != '_none') { + if ($sort_settings['field'] !== '_none') { $query->sort($sort_settings['field'], $sort_settings['direction']); } } diff --git a/core/modules/entity_reference/src/Plugin/views/display/EntityReference.php b/core/modules/entity_reference/src/Plugin/views/display/EntityReference.php index beeb095..6d32e58 100644 --- a/core/modules/entity_reference/src/Plugin/views/display/EntityReference.php +++ b/core/modules/entity_reference/src/Plugin/views/display/EntityReference.php @@ -129,7 +129,7 @@ public function query() { if (isset($options['match'])) { $style_options = $this->getOption('style'); $value = db_like($options['match']) . '%'; - if ($options['match_operator'] != 'STARTS_WITH') { + if ($options['match_operator'] !== 'STARTS_WITH') { $value = '%' . $value; } diff --git a/core/modules/entity_reference/src/Tests/EntityReferenceFieldTest.php b/core/modules/entity_reference/src/Tests/EntityReferenceFieldTest.php index 22a3847..c6b2410 100644 --- a/core/modules/entity_reference/src/Tests/EntityReferenceFieldTest.php +++ b/core/modules/entity_reference/src/Tests/EntityReferenceFieldTest.php @@ -117,7 +117,7 @@ public function testReferencedEntitiesMultipleLoad() { $reference_field[4]['target_id'] = NULL; $target_entities[4] = NULL; - // Attach the first created target entity as the sixth item ($delta == 5) of + // Attach the first created target entity as the sixth item ($delta === 5) of // the parent entity field. We want to test the case when the same target // entity is referenced twice (or more times) in the same entity reference // field. diff --git a/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php b/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php index a86adfd..fc51d6c 100644 --- a/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php +++ b/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php @@ -125,7 +125,7 @@ public function testRelationship() { // The second and third entity refer to the first one. // The value key on the result will be in the format // BASE_TABLE_FIELD_NAME. - $this->assertEqual($view->result[$index]->entity_test_entity_test__field_test_id, $index == 0 ? NULL : 1); + $this->assertEqual($view->result[$index]->entity_test_entity_test__field_test_id, $index === 0 ? NULL : 1); if ($index > 0) { // Test that the correct relationship entity is on the row. @@ -139,7 +139,7 @@ public function testRelationship() { foreach (array_keys($view->result) as $index) { $this->assertEqual($view->result[$index]->id, $this->entities[$index + 1]->id()); // The second and third entity refer to the first one. - $this->assertEqual($view->result[$index]->entity_test_entity_test__field_test_id, $index == 0 ? NULL : 1); + $this->assertEqual($view->result[$index]->entity_test_entity_test__field_test_id, $index === 0 ? NULL : 1); } } diff --git a/core/modules/entity_reference/src/Tests/Views/SelectionTest.php b/core/modules/entity_reference/src/Tests/Views/SelectionTest.php index dbfe0f6..9116642 100644 --- a/core/modules/entity_reference/src/Tests/Views/SelectionTest.php +++ b/core/modules/entity_reference/src/Tests/Views/SelectionTest.php @@ -69,7 +69,7 @@ public function testSelectionHandler() { $success = FALSE; foreach ($result as $node_type => $values) { foreach ($values as $nid => $label) { - if (!$success = $nodes[$node_type][$nid] == trim(strip_tags($label))) { + if (!$success = $nodes[$node_type][$nid] === trim(strip_tags($label))) { // There was some error, so break. break; } diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php index d905c69..011a8c2 100644 --- a/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -163,7 +163,7 @@ function hook_field_widget_info_alter(array &$info) { function hook_field_widget_form_alter(&$element, \Drupal\Core\Form\FormStateInterface $form_state, $context) { // Add a css class to widget form elements for all fields of type mytype. $field_definition = $context['items']->getFieldDefinition(); - if ($field_definition->getType() == 'mytype') { + if ($field_definition->getType() === 'mytype') { // Be sure not to overwrite existing attributes. $element['#attributes']['class'][] = 'myclass'; } diff --git a/core/modules/field/field.module b/core/modules/field/field.module index ec8d2b7..3ae5043 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -123,7 +123,7 @@ function field_cron() { function field_system_info_alter(&$info, Extension $file, $type) { // It is not safe to call entity_load_multiple_by_properties() during // maintenance mode. - if ($type == 'module' && !defined('MAINTENANCE_MODE')) { + if ($type === 'module' && !defined('MAINTENANCE_MODE')) { $fields = entity_load_multiple_by_properties('field_storage_config', array('module' => $file->getName(), 'include_deleted' => TRUE)); if ($fields) { $info['required'] = TRUE; diff --git a/core/modules/field/field.purge.inc b/core/modules/field/field.purge.inc index 2676952..af8055d 100644 --- a/core/modules/field/field.purge.inc +++ b/core/modules/field/field.purge.inc @@ -94,13 +94,13 @@ function field_purge_batch($batch_size, $field_storage_uuid = NULL) { } $count_purged = \Drupal::entityManager()->getStorage($entity_type)->purgeFieldData($instance, $batch_size); - if ($count_purged < $batch_size || $count_purged == 0) { + if ($count_purged < $batch_size || $count_purged === 0) { // No field data remains for the instance, so we can remove it. field_purge_instance($instance); } $batch_size -= $count_purged; // Only delete up to the maximum number of records. - if ($batch_size == 0) { + if ($batch_size === 0) { break; } } @@ -110,7 +110,7 @@ function field_purge_batch($batch_size, $field_storage_uuid = NULL) { $deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: array(); foreach ($deleted_storages as $field_storage) { $field_storage = new FieldStorageConfig($field_storage); - if ($field_storage_uuid && $field_storage->uuid() != $field_storage_uuid) { + if ($field_storage_uuid && $field_storage->uuid() !== $field_storage_uuid) { // If a specific UUID is provided, only purge the corresponding field. continue; } diff --git a/core/modules/field/field.views.inc b/core/modules/field/field.views.inc index a01ee5c..3375d4f 100644 --- a/core/modules/field/field.views.inc +++ b/core/modules/field/field.views.inc @@ -245,7 +245,7 @@ function field_views_field_default_views_data(FieldStorageConfigInterface $field $table = $table_info['table']; $table_alias = $table_info['alias']; - if ($type == EntityStorageInterface::FIELD_LOAD_CURRENT) { + if ($type === EntityStorageInterface::FIELD_LOAD_CURRENT) { $group = $group_name; $field_alias = $field_name; } @@ -266,8 +266,8 @@ function field_views_field_default_views_data(FieldStorageConfigInterface $field $aliases = array(); $also_known = array(); foreach ($all_labels as $label_name => $true) { - if ($type == EntityStorageInterface::FIELD_LOAD_CURRENT) { - if ($label != $label_name) { + if ($type === EntityStorageInterface::FIELD_LOAD_CURRENT) { + if ($label !== $label_name) { $aliases[] = array( 'base' => $base_table, 'group' => $group_name, @@ -277,7 +277,7 @@ function field_views_field_default_views_data(FieldStorageConfigInterface $field $also_known[] = t('@group: @field', array('@group' => $group_name, '@field' => $label_name)); } } - elseif ($supports_revisions && $label != $label_name) { + elseif ($supports_revisions && $label !== $label_name) { $aliases[] = array( 'base' => $table, 'group' => t('@group (historical data)', array('@group' => $group_name)), @@ -305,7 +305,7 @@ function field_views_field_default_views_data(FieldStorageConfigInterface $field 'entity_tables' => $entity_tables, // Default the element type to div, let the UI change it if necessary. 'element type' => 'div', - 'is revision' => $type == EntityStorageInterface::FIELD_LOAD_REVISION, + 'is revision' => $type === EntityStorageInterface::FIELD_LOAD_REVISION, ); } @@ -337,7 +337,7 @@ function field_views_field_default_views_data(FieldStorageConfigInterface $field break; } - if (count($field_columns) == 1 || $column == 'value') { + if (count($field_columns) === 1 || $column === 'value') { $title = t('@label (!name)', array('@label' => $label, '!name' => $field_name)); $title_short = $label; } @@ -351,7 +351,7 @@ function field_views_field_default_views_data(FieldStorageConfigInterface $field $table = $table_info['table']; $table_alias = $table_info['alias']; - if ($type == EntityStorageInterface::FIELD_LOAD_CURRENT) { + if ($type === EntityStorageInterface::FIELD_LOAD_CURRENT) { $group = $group_name; } else { @@ -374,8 +374,8 @@ function field_views_field_default_views_data(FieldStorageConfigInterface $field $aliases = array(); $also_known = array(); foreach ($all_labels as $label_name => $true) { - if ($label != $label_name) { - if (count($field_columns) == 1 || $column == 'value') { + if ($label !== $label_name) { + if (count($field_columns) === 1 || $column === 'value') { $alias_title = t('@label (!name)', array('@label' => $label_name, '!name' => $field_name)); } else { @@ -477,11 +477,11 @@ function list_field_views_data(FieldStorageConfigInterface $field_storage) { $data = field_views_field_default_views_data($field_storage); foreach ($data as $table_name => $table_data) { foreach ($table_data as $field_name => $field_data) { - if (isset($field_data['filter']) && $field_name != 'delta') { + if (isset($field_data['filter']) && $field_name !== 'delta') { $data[$table_name][$field_name]['filter']['id'] = 'field_list'; } - if (isset($field_data['argument']) && $field_name != 'delta') { - if ($field_storage->getType() == 'list_text') { + if (isset($field_data['argument']) && $field_name !== 'delta') { + if ($field_storage->getType() === 'list_text') { $data[$table_name][$field_name]['argument']['id'] = 'field_list_string'; } else { diff --git a/core/modules/field/src/ConfigImporterFieldPurger.php b/core/modules/field/src/ConfigImporterFieldPurger.php index f762954..39cd707 100644 --- a/core/modules/field/src/ConfigImporterFieldPurger.php +++ b/core/modules/field/src/ConfigImporterFieldPurger.php @@ -36,7 +36,7 @@ public static function process(array &$context, ConfigImporter $config_importer) $field_storages = static::getFieldStoragesToPurge($context['sandbox']['field']['extensions'], $config_importer->getUnprocessedConfiguration('delete')); // Get the first field storage to process. $field_storage = reset($field_storages); - if (!isset($context['sandbox']['field']['current_storage_id']) || $context['sandbox']['field']['current_storage_id'] != $field_storage->id()) { + if (!isset($context['sandbox']['field']['current_storage_id']) || $context['sandbox']['field']['current_storage_id'] !== $field_storage->id()) { $context['sandbox']['field']['current_storage_id'] = $field_storage->id(); // If the storage has not been deleted yet we need to do that. This is the // case when the storage deletion is staged. @@ -47,7 +47,7 @@ public static function process(array &$context, ConfigImporter $config_importer) field_purge_batch($context['sandbox']['field']['purge_batch_size'], $field_storage->uuid()); $context['sandbox']['field']['current_progress']++; $fields_to_delete_count = count(static::getFieldStoragesToPurge($context['sandbox']['field']['extensions'], $config_importer->getUnprocessedConfiguration('delete'))); - if ($fields_to_delete_count == 0) { + if ($fields_to_delete_count === 0) { $context['finished'] = 1; } else { diff --git a/core/modules/field/src/Entity/FieldInstanceConfig.php b/core/modules/field/src/Entity/FieldInstanceConfig.php index 4a4239d..1a2f8c1 100644 --- a/core/modules/field/src/Entity/FieldInstanceConfig.php +++ b/core/modules/field/src/Entity/FieldInstanceConfig.php @@ -146,13 +146,13 @@ public function preSave(EntityStorageInterface $storage) { } else { // Some updates are always disallowed. - if ($this->entity_type != $this->original->entity_type) { + if ($this->entity_type !== $this->original->entity_type) { throw new FieldException("Cannot change an existing instance's entity_type."); } - if ($this->bundle != $this->original->bundle && empty($this->bundleRenameAllowed)) { + if ($this->bundle !== $this->original->bundle && empty($this->bundleRenameAllowed)) { throw new FieldException("Cannot change an existing instance's bundle."); } - if ($storage_definition->uuid() != $this->original->getFieldStorageDefinition()->uuid()) { + if ($storage_definition->uuid() !== $this->original->getFieldStorageDefinition()->uuid()) { throw new FieldException("Cannot change an existing instance's storage."); } // Set the default instance settings. @@ -219,7 +219,7 @@ public static function postDelete(EntityStorageInterface $storage, array $instan $storages_to_delete = array(); foreach ($instances as $instance) { $storage_definition = $instance->getFieldStorageDefinition(); - if (!$instance->deleted && empty($instance->noFieldDelete) && !$instance->isUninstalling() && count($storage_definition->getBundles()) == 0) { + if (!$instance->deleted && empty($instance->noFieldDelete) && !$instance->isUninstalling() && count($storage_definition->getBundles()) === 0) { // Key by field UUID to avoid deleting the same storage twice. $storages_to_delete[$storage_definition->uuid()] = $storage_definition; } diff --git a/core/modules/field/src/Entity/FieldStorageConfig.php b/core/modules/field/src/Entity/FieldStorageConfig.php index 128ac01..4789273 100644 --- a/core/modules/field/src/Entity/FieldStorageConfig.php +++ b/core/modules/field/src/Entity/FieldStorageConfig.php @@ -319,10 +319,10 @@ protected function preSaveUpdated(EntityStorageInterface $storage) { $field_type_manager = \Drupal::service('plugin.manager.field.field_type'); // Some updates are always disallowed. - if ($this->type != $this->original->type) { + if ($this->type !== $this->original->type) { throw new FieldException("Cannot change the field type for an existing field storage."); } - if ($this->entity_type != $this->original->entity_type) { + if ($this->entity_type !== $this->original->entity_type) { throw new FieldException("Cannot change the entity type for an existing field storage."); } @@ -583,7 +583,7 @@ public function isRequired() { */ public function isMultiple() { $cardinality = $this->getCardinality(); - return ($cardinality == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) || ($cardinality > 1); + return ($cardinality === FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) || ($cardinality > 1); } /** diff --git a/core/modules/field/src/FieldInstanceConfigAccessControlHandler.php b/core/modules/field/src/FieldInstanceConfigAccessControlHandler.php index eb4a37f..aabfe4c 100644 --- a/core/modules/field/src/FieldInstanceConfigAccessControlHandler.php +++ b/core/modules/field/src/FieldInstanceConfigAccessControlHandler.php @@ -23,7 +23,7 @@ class FieldInstanceConfigAccessControlHandler extends EntityAccessControlHandler * {@inheritdoc} */ protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { - if ($operation == 'delete') { + if ($operation === 'delete') { $field_storage_entity = $entity->getFieldStorageDefinition(); if ($field_storage_entity->isLocked()) { return AccessResult::forbidden()->cacheUntilEntityChanges($field_storage_entity); diff --git a/core/modules/field/src/FieldInstanceConfigStorage.php b/core/modules/field/src/FieldInstanceConfigStorage.php index 2c4e5d1..7d2c64d 100644 --- a/core/modules/field/src/FieldInstanceConfigStorage.php +++ b/core/modules/field/src/FieldInstanceConfigStorage.php @@ -157,7 +157,7 @@ public function loadByProperties(array $conditions = array()) { } // Skip to the next instance as soon as one condition does not match. - if ($checked_value != $value) { + if ($checked_value !== $value) { continue 2; } } diff --git a/core/modules/field/src/FieldStorageConfigStorage.php b/core/modules/field/src/FieldStorageConfigStorage.php index 563deef..5ad10ea 100644 --- a/core/modules/field/src/FieldStorageConfigStorage.php +++ b/core/modules/field/src/FieldStorageConfigStorage.php @@ -150,7 +150,7 @@ public function loadByProperties(array $conditions = array()) { } // Skip to the next field as soon as one condition does not match. - if ($checked_value != $value) { + if ($checked_value !== $value) { continue 2; } } diff --git a/core/modules/field/src/Plugin/views/field/Field.php b/core/modules/field/src/Plugin/views/field/Field.php index 7788a5b..3f6b673 100644 --- a/core/modules/field/src/Plugin/views/field/Field.php +++ b/core/modules/field/src/Plugin/views/field/Field.php @@ -202,7 +202,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o // Otherwise, we only limit values if the user hasn't selected "all", 0, or // the value matching field cardinality. - if ((intval($this->options['delta_limit']) && ($this->options['delta_limit'] != $cardinality)) || intval($this->options['delta_offset'])) { + if ((intval($this->options['delta_limit']) && ($this->options['delta_limit'] !== $cardinality)) || intval($this->options['delta_offset'])) { $this->limit_values = TRUE; } } @@ -231,7 +231,7 @@ function get_base_table() { // If the current field is under a relationship you can't be sure that the // base table of the view is the base table of the current field. // For example a field from a node author on a node view does have users as base table. - if (!empty($this->options['relationship']) && $this->options['relationship'] != 'none') { + if (!empty($this->options['relationship']) && $this->options['relationship'] !== 'none') { $relationships = $this->view->display_handler->getOption('relationships'); if (!empty($relationships[$this->options['relationship']])) { $options = $relationships[$this->options['relationship']]; @@ -265,7 +265,7 @@ public function query($use_groupby = FALSE) { if ($use_groupby) { // Add the fields that we're actually grouping on. $options = array(); - if ($this->options['group_column'] != 'entity_id') { + if ($this->options['group_column'] !== 'entity_id') { $options = array($this->options['group_column'] => $this->options['group_column']); } $options += is_array($this->options['group_columns']) ? $this->options['group_columns'] : array(); @@ -373,7 +373,7 @@ protected function defineOptions() { $column_names = array_keys($field_storage->getColumns()); $default_column = ''; // Try to determine a sensible default. - if (count($column_names) == 1) { + if (count($column_names) === 1) { $default_column = $column_names[0]; } elseif (in_array('value', $column_names)) { @@ -450,7 +450,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { } // No need to ask the user anything if the field has only one column. - if (count($field->getColumns()) == 1) { + if (count($field->getColumns()) === 1) { $form['click_sort_column'] = array( '#type' => 'value', '#value' => isset($column_names[0]) ? $column_names[0] : '', @@ -539,7 +539,7 @@ function multiple_options_form(&$form, FormStateInterface $form_state) { // translating prefix and suffix separately. list($prefix, $suffix) = explode('@count', t('Display @count value(s)')); - if ($field->getCardinality() == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) { + if ($field->getCardinality() === FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) { $type = 'textfield'; $options = NULL; $size = 5; @@ -698,7 +698,7 @@ protected function renderItems($items) { } return SafeMarkup::set($output); } - if ($this->options['multi_type'] == 'separator') { + if ($this->options['multi_type'] === 'separator') { $output = ''; $separator = ''; $escaped_separator = Xss::filterAdmin($this->options['separator']); @@ -853,7 +853,7 @@ function process_entity(EntityInterface $entity) { // We should only get here in this case if there's an offset, and // in that case we're limiting to all values after the offset. - if ($delta_limit == 'all') { + if ($delta_limit === 'all') { $delta_limit = count($all_values) - $offset; } } @@ -869,9 +869,9 @@ function process_entity(EntityInterface $entity) { // If first-last option was selected, only use the first and last values if (!$delta_first_last // Use the first value. - || $new_delta == $offset + || $new_delta === $offset // Use the last value. - || $new_delta == ($delta_limit + $offset - 1)) { + || $new_delta === ($delta_limit + $offset - 1)) { $new_values[] = $all_values[$new_delta]; } } diff --git a/core/modules/field/src/Tests/BulkDeleteTest.php b/core/modules/field/src/Tests/BulkDeleteTest.php index d37d919..b8999b4 100644 --- a/core/modules/field/src/Tests/BulkDeleteTest.php +++ b/core/modules/field/src/Tests/BulkDeleteTest.php @@ -75,13 +75,13 @@ function checkHooksInvocations($expected_hooks, $actual_hooks) { foreach ($actual_invocations as $actual_arguments) { // The argument we are looking for is either an array of entities as // the second argument or a single entity object as the first. - if ($argument instanceof EntityInterface && $actual_arguments[0]->id() == $argument->id()) { + if ($argument instanceof EntityInterface && $actual_arguments[0]->id() === $argument->id()) { $found = TRUE; break; } // In case of an array, compare the array size and make sure it // contains the same elements. - elseif (is_array($argument) && count($actual_arguments[1]) == count($argument) && count(array_diff_key($actual_arguments[1], $argument)) == 0) { + elseif (is_array($argument) && count($actual_arguments[1]) === count($argument) && count(array_diff_key($actual_arguments[1], $argument)) === 0) { $found = TRUE; break; } diff --git a/core/modules/field/src/Tests/CrudTest.php b/core/modules/field/src/Tests/CrudTest.php index ec9b4d7..4298c89 100644 --- a/core/modules/field/src/Tests/CrudTest.php +++ b/core/modules/field/src/Tests/CrudTest.php @@ -204,11 +204,11 @@ function testRead() { // Check that 'single column' criteria works. $fields = entity_load_multiple_by_properties('field_storage_config', array('field_name' => $field_storage_definition['name'])); - $this->assertTrue(count($fields) == 1 && isset($fields[$id]), 'The field was properly read.'); + $this->assertTrue(count($fields) === 1 && isset($fields[$id]), 'The field was properly read.'); // Check that 'multi column' criteria works. $fields = entity_load_multiple_by_properties('field_storage_config', array('field_name' => $field_storage_definition['name'], 'type' => $field_storage_definition['type'])); - $this->assertTrue(count($fields) == 1 && isset($fields[$id]), 'The field was properly read.'); + $this->assertTrue(count($fields) === 1 && isset($fields[$id]), 'The field was properly read.'); $fields = entity_load_multiple_by_properties('field_storage_config', array('field_name' => $field_storage_definition['name'], 'type' => 'foo')); $this->assertTrue(empty($fields), 'No field was found.'); diff --git a/core/modules/field/src/Tests/FieldAttachOtherTest.php b/core/modules/field/src/Tests/FieldAttachOtherTest.php index 978ea0e..3119cd9 100644 --- a/core/modules/field/src/Tests/FieldAttachOtherTest.php +++ b/core/modules/field/src/Tests/FieldAttachOtherTest.php @@ -269,7 +269,7 @@ function testEntityFormDisplayBuildForm() { // Test generating widgets for all fields. $display = entity_get_form_display($entity_type, $this->fieldTestData->instance->bundle, 'default'); foreach ($display->getComponents() as $name => $options) { - if ($name != $this->fieldTestData->field_name_2) { + if ($name !== $this->fieldTestData->field_name_2) { $display->removeComponent($name); } } @@ -346,13 +346,13 @@ function testEntityFormDisplayExtractFormValues() { $expected_values = array(); $expected_values_2 = array(); foreach ($weights as $key => $value) { - if ($key != 1) { + if ($key !== 1) { $expected_values[] = array('value' => $values[$key]['value']); } } $this->assertIdentical($entity->{$this->fieldTestData->field_name}->getValue(), $expected_values, 'Submit filters empty values'); foreach ($weights_2 as $key => $value) { - if ($key != 1) { + if ($key !== 1) { $expected_values_2[] = array('value' => $values_2[$key]['value']); } } @@ -360,7 +360,7 @@ function testEntityFormDisplayExtractFormValues() { // Call EntityFormDisplayInterface::extractFormValues() for a single field (the second field). foreach ($display->getComponents() as $name => $options) { - if ($name != $this->fieldTestData->field_name_2) { + if ($name !== $this->fieldTestData->field_name_2) { $display->removeComponent($name); } } @@ -368,7 +368,7 @@ function testEntityFormDisplayExtractFormValues() { $display->extractFormValues($entity, $form, $form_state); $expected_values_2 = array(); foreach ($weights_2 as $key => $value) { - if ($key != 1) { + if ($key !== 1) { $expected_values_2[] = array('value' => $values_2[$key]['value']); } } diff --git a/core/modules/field/src/Tests/FieldInstanceCrudTest.php b/core/modules/field/src/Tests/FieldInstanceCrudTest.php index a59917a..15026f0 100644 --- a/core/modules/field/src/Tests/FieldInstanceCrudTest.php +++ b/core/modules/field/src/Tests/FieldInstanceCrudTest.php @@ -117,9 +117,9 @@ function testReadFieldInstance() { // Read the instance back. $instance = entity_load('field_instance_config', 'entity_test.' . $this->instanceDefinition['bundle'] . '.' . $this->instanceDefinition['field_name']); - $this->assertTrue($this->instanceDefinition['field_name'] == $instance->getName(), 'The field was properly read.'); - $this->assertTrue($this->instanceDefinition['entity_type'] == $instance->entity_type, 'The field was properly read.'); - $this->assertTrue($this->instanceDefinition['bundle'] == $instance->bundle, 'The field was properly read.'); + $this->assertTrue($this->instanceDefinition['field_name'] === $instance->getName(), 'The field was properly read.'); + $this->assertTrue($this->instanceDefinition['entity_type'] === $instance->entity_type, 'The field was properly read.'); + $this->assertTrue($this->instanceDefinition['bundle'] === $instance->bundle, 'The field was properly read.'); } /** diff --git a/core/modules/field/src/Tests/FieldValidationTest.php b/core/modules/field/src/Tests/FieldValidationTest.php index 7795684..f3ecc56 100644 --- a/core/modules/field/src/Tests/FieldValidationTest.php +++ b/core/modules/field/src/Tests/FieldValidationTest.php @@ -80,7 +80,7 @@ function testFieldConstraints() { $expected_violations = array(); for ($delta = 0; $delta < $cardinality; $delta++) { // All deltas except '1' have incorrect values. - if ($delta == 1) { + if ($delta === 1) { $value = 1; } else { diff --git a/core/modules/field/src/Tests/TranslationTest.php b/core/modules/field/src/Tests/TranslationTest.php index f37bdf6..bcf348e 100644 --- a/core/modules/field/src/Tests/TranslationTest.php +++ b/core/modules/field/src/Tests/TranslationTest.php @@ -132,7 +132,7 @@ function testTranslatableFieldSaveLoad() { foreach ($field_translations as $langcode => $items) { $result = TRUE; foreach ($items as $delta => $item) { - $result = $result && $item['value'] == $entity->getTranslation($langcode)->{$this->field_name}[$delta]->value; + $result = $result && $item['value'] === $entity->getTranslation($langcode)->{$this->field_name}[$delta]->value; } $this->assertTrue($result, format_string('%language translation correctly handled.', array('%language' => $langcode))); } diff --git a/core/modules/field/src/Tests/TranslationWebTest.php b/core/modules/field/src/Tests/TranslationWebTest.php index f3b3ead..abb44c1 100644 --- a/core/modules/field/src/Tests/TranslationWebTest.php +++ b/core/modules/field/src/Tests/TranslationWebTest.php @@ -128,7 +128,7 @@ private function checkTranslationRevisions($id, $revision_id, $available_langcod $field_name = $this->fieldStorage->getName(); $entity = entity_revision_load($this->entity_type, $revision_id); foreach ($available_langcodes as $langcode => $value) { - $passed = $entity->getTranslation($langcode)->{$field_name}->value == $value + 1; + $passed = $entity->getTranslation($langcode)->{$field_name}->value === $value + 1; $this->assertTrue($passed, format_string('The @language translation for revision @revision was correctly stored', array('@language' => $langcode, '@revision' => $entity->getRevisionId()))); } } diff --git a/core/modules/field/tests/modules/field_test/field_test.entity.inc b/core/modules/field/tests/modules/field_test/field_test.entity.inc index d5614ac..9f0aa5a 100644 --- a/core/modules/field/tests/modules/field_test/field_test.entity.inc +++ b/core/modules/field/tests/modules/field_test/field_test.entity.inc @@ -24,7 +24,7 @@ function field_test_entity_info_translatable($entity_type_id = NULL, $translatab $entity_manager = \Drupal::entityManager(); $original = $entity_manager->getDefinition($entity_type_id); $stored_value[$entity_type_id] = $translatable; - if ($translatable != $original->isTranslatable()) { + if ($translatable !== $original->isTranslatable()) { $entity_manager->clearCachedDefinitions(); $entity_type = $entity_manager->getDefinition($entity_type_id); $entity_manager->onEntityTypeUpdate($entity_type, $original); diff --git a/core/modules/field/tests/modules/field_test/field_test.field.inc b/core/modules/field/tests/modules/field_test/field_test.field.inc index b1a5589..ec67267 100644 --- a/core/modules/field/tests/modules/field_test/field_test.field.inc +++ b/core/modules/field/tests/modules/field_test/field_test.field.inc @@ -24,7 +24,7 @@ function field_test_field_widget_info_alter(&$info) { * Implements hook_field_storage_config_update_forbid(). */ function field_test_field_storage_config_update_forbid(FieldStorageConfigInterface $field_storage, FieldStorageConfigInterface $prior_field_storage) { - if ($field_storage->getType() == 'test_field' && $field_storage->getSetting('unchangeable') != $prior_field_storage->getSetting('unchangeable')) { + if ($field_storage->getType() === 'test_field' && $field_storage->getSetting('unchangeable') !== $prior_field_storage->getSetting('unchangeable')) { throw new FieldStorageDefinitionUpdateForbiddenException("field_test 'unchangeable' setting cannot be changed'"); } } @@ -40,13 +40,13 @@ function field_test_default_value(ContentEntityInterface $entity, FieldDefinitio * Implements hook_entity_field_access(). */ function field_test_entity_field_access($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL) { - if ($field_definition->getName() == "field_no_{$operation}_access") { + if ($field_definition->getName() === "field_no_{$operation}_access") { return AccessResult::forbidden(); } // Only grant view access to test_view_field fields when the user has // 'view test_view_field content' permission. - if ($field_definition->getName() == 'test_view_field' && $operation == 'view') { + if ($field_definition->getName() === 'test_view_field' && $operation === 'view') { return AccessResult::forbiddenIf(!$account->hasPermission('view test_view_field content'))->cachePerRole(); } diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldApplicableFormatter.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldApplicableFormatter.php index 24704e1..99e9bd2 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldApplicableFormatter.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldFormatter/TestFieldApplicableFormatter.php @@ -32,7 +32,7 @@ class TestFieldApplicableFormatter extends FormatterBase { * {@inheritdoc} */ public static function isApplicable(FieldDefinitionInterface $field_definition) { - return $field_definition->getName() != 'deny_applicable'; + return $field_definition->getName() !== 'deny_applicable'; } /** diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php index be2ab05..c324921 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php @@ -103,7 +103,7 @@ public static function multipleValidate($element, FormStateInterface $form_state */ public static function isApplicable(FieldDefinitionInterface $field_definition) { // Returns FALSE if machine name of the field equals field_onewidgetfield. - return $field_definition->getName() != "field_onewidgetfield"; + return $field_definition->getName() !== "field_onewidgetfield"; } } diff --git a/core/modules/field_ui/field_ui.api.php b/core/modules/field_ui/field_ui.api.php index 4e44c3a..9f507c5 100644 --- a/core/modules/field_ui/field_ui.api.php +++ b/core/modules/field_ui/field_ui.api.php @@ -33,7 +33,7 @@ function hook_field_formatter_third_party_settings_form(\Drupal\Core\Field\Forma $element = array(); // Add a 'my_setting' checkbox to the settings form for 'foo_formatter' field // formatters. - if ($plugin->getPluginId() == 'foo_formatter') { + if ($plugin->getPluginId() === 'foo_formatter') { $element['my_setting'] = array( '#type' => 'checkbox', '#title' => t('My setting'), @@ -66,7 +66,7 @@ function hook_field_widget_third_party_settings_form(\Drupal\Core\Field\WidgetIn $element = array(); // Add a 'my_setting' checkbox to the settings form for 'foo_widget' field // widgets. - if ($plugin->getPluginId() == 'foo_widget') { + if ($plugin->getPluginId() === 'foo_widget') { $element['my_setting'] = array( '#type' => 'checkbox', '#title' => t('My setting'), @@ -92,7 +92,7 @@ function hook_field_widget_third_party_settings_form(\Drupal\Core\Field\WidgetIn function hook_field_formatter_settings_summary_alter(&$summary, $context) { // Append a message to the summary when an instance of foo_formatter has // mysetting set to TRUE for the current view mode. - if ($context['formatter']->getPluginId() == 'foo_formatter') { + if ($context['formatter']->getPluginId() === 'foo_formatter') { if ($context['formatter']->getThirdPartySetting('my_module', 'my_setting')) { $summary[] = t('My setting enabled.'); } @@ -115,7 +115,7 @@ function hook_field_formatter_settings_summary_alter(&$summary, $context) { function hook_field_widget_settings_summary_alter(&$summary, $context) { // Append a message to the summary when an instance of foo_widget has // mysetting set to TRUE for the current view mode. - if ($context['widget']->getPluginId() == 'foo_widget') { + if ($context['widget']->getPluginId() === 'foo_widget') { if ($context['widget']->getThirdPartySetting('my_module', 'my_setting')) { $summary[] = t('My setting enabled.'); } diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index 9dbcbd2..d238f5f 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -293,7 +293,7 @@ function theme_field_ui_table($variables) { foreach (Element::children($element) as $cell_key) { $child = &$element[$cell_key]; // Do not render a cell for children of #type 'value'. - if (!(isset($child['#type']) && $child['#type'] == 'value')) { + if (!(isset($child['#type']) && $child['#type'] === 'value')) { $cell = array('data' => drupal_render($child)); if (isset($child['#cell_attributes'])) { $cell += $child['#cell_attributes']; diff --git a/core/modules/field_ui/src/Access/FormModeAccessCheck.php b/core/modules/field_ui/src/Access/FormModeAccessCheck.php index 1b2d95d..607b26c 100644 --- a/core/modules/field_ui/src/Access/FormModeAccessCheck.php +++ b/core/modules/field_ui/src/Access/FormModeAccessCheck.php @@ -69,7 +69,7 @@ public function access(Route $route, Request $request, AccountInterface $account } $visibility = FALSE; - if ($form_mode_name == 'default') { + if ($form_mode_name === 'default') { $visibility = TRUE; } elseif ($entity_display = $this->entityManager->getStorage('entity_form_display')->load($entity_type_id . '.' . $bundle . '.' . $form_mode_name)) { @@ -77,7 +77,7 @@ public function access(Route $route, Request $request, AccountInterface $account } $access = AccessResult::create(); - if ($form_mode_name != 'default' && $entity_display) { + if ($form_mode_name !== 'default' && $entity_display) { $access->cacheUntilEntityChanges($entity_display); } diff --git a/core/modules/field_ui/src/Access/ViewModeAccessCheck.php b/core/modules/field_ui/src/Access/ViewModeAccessCheck.php index 3c9c2be..b5c5989 100644 --- a/core/modules/field_ui/src/Access/ViewModeAccessCheck.php +++ b/core/modules/field_ui/src/Access/ViewModeAccessCheck.php @@ -69,7 +69,7 @@ public function access(Route $route, Request $request, AccountInterface $account } $visibility = FALSE; - if ($view_mode_name == 'default') { + if ($view_mode_name === 'default') { $visibility = TRUE; } elseif ($entity_display = $this->entityManager->getStorage('entity_view_display')->load($entity_type_id . '.' . $bundle . '.' . $view_mode_name)) { @@ -77,7 +77,7 @@ public function access(Route $route, Request $request, AccountInterface $account } $access = AccessResult::create(); - if ($view_mode_name != 'default' && $entity_display) { + if ($view_mode_name !== 'default' && $entity_display) { $access->cacheUntilEntityChanges($entity_display); } diff --git a/core/modules/field_ui/src/DisplayOverview.php b/core/modules/field_ui/src/DisplayOverview.php index 2bc07c1..384eafe 100644 --- a/core/modules/field_ui/src/DisplayOverview.php +++ b/core/modules/field_ui/src/DisplayOverview.php @@ -150,7 +150,7 @@ protected function getEntityDisplay($mode) { protected function getPlugin(FieldDefinitionInterface $field_definition, $configuration) { $plugin = NULL; - if ($configuration && $configuration['type'] != 'hidden') { + if ($configuration && $configuration['type'] !== 'hidden') { $plugin = $this->pluginManager->getInstance(array( 'field_definition' => $field_definition, 'view_mode' => $this->mode, diff --git a/core/modules/field_ui/src/DisplayOverviewBase.php b/core/modules/field_ui/src/DisplayOverviewBase.php index 802d012..27f8d4c 100644 --- a/core/modules/field_ui/src/DisplayOverviewBase.php +++ b/core/modules/field_ui/src/DisplayOverviewBase.php @@ -183,7 +183,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_t $form['fields'] = $table; // Custom display settings. - if ($this->mode == 'default') { + if ($this->mode === 'default') { // Only show the settings if there is at least one custom display mode. if ($display_modes = $this->getDisplayModes()) { $form['modes'] = array( @@ -344,7 +344,7 @@ protected function buildFieldRow(FieldDefinitionInterface $field_definition, Ent '#field_name' => $field_name, ); - if ($form_state->get('plugin_settings_edit') == $field_name) { + if ($form_state->get('plugin_settings_edit') === $field_name) { // We are currently editing this field's plugin settings. Display the // settings form and submit buttons. $field_row['plugin']['settings_edit_form'] = array(); @@ -513,7 +513,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // values. $values = $form_values['fields'][$field_name]; - if ($values['type'] == 'hidden') { + if ($values['type'] === 'hidden') { $display->removeComponent($field_name); } else { @@ -565,7 +565,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // Collect data for 'extra' fields. foreach ($form['#extra'] as $name) { - if ($form_values['fields'][$name]['type'] == 'hidden') { + if ($form_values['fields'][$name]['type'] === 'hidden') { $display->removeComponent($name); } else { @@ -579,7 +579,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $display->save(); // Handle the 'display modes' checkboxes if present. - if ($this->mode == 'default' && !empty($form_values['display_modes_custom'])) { + if ($this->mode === 'default' && !empty($form_values['display_modes_custom'])) { $display_modes = $this->getDisplayModes(); $current_statuses = $this->getDisplayStatuses(); @@ -711,7 +711,7 @@ public function multistepAjax($form, FormStateInterface $form_state) { * @see \Drupal\Core\Entity\EntityManagerInterface::getExtraFields() */ protected function getExtraFields() { - $context = $this->displayContext == 'view' ? 'display' : $this->displayContext; + $context = $this->displayContext === 'view' ? 'display' : $this->displayContext; $extra_fields = $this->entityManager->getExtraFields($this->entity_type, $this->bundle); return isset($extra_fields[$context]) ? $extra_fields[$context] : array(); } @@ -790,7 +790,7 @@ public function getRowRegion($row) { switch ($row['#row_type']) { case 'field': case 'extra_field': - return ($row['plugin']['type']['#value'] == 'hidden' ? 'hidden' : 'content'); + return ($row['plugin']['type']['#value'] === 'hidden' ? 'hidden' : 'content'); } } @@ -822,7 +822,7 @@ protected function getDisplays() { foreach ($ids as $id) { $config_id = str_replace($config_prefix . '.', '', $id); list(,, $display_mode) = explode('.', $config_id); - if ($display_mode != 'default') { + if ($display_mode !== 'default') { $load_ids[] = $config_id; } } diff --git a/core/modules/field_ui/src/EntityDisplayModeListBuilder.php b/core/modules/field_ui/src/EntityDisplayModeListBuilder.php index f52d721..dfa82f4 100644 --- a/core/modules/field_ui/src/EntityDisplayModeListBuilder.php +++ b/core/modules/field_ui/src/EntityDisplayModeListBuilder.php @@ -110,7 +110,7 @@ public function render() { } // Move content at the top. - if ($entity_type == 'node') { + if ($entity_type === 'node') { $table['#weight'] = -10; } diff --git a/core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php b/core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php index 9b7fdd2..5f26542 100644 --- a/core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php +++ b/core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php @@ -109,7 +109,7 @@ public function form(array $form, FormStateInterface $form_state) { */ public function exists($entity_id, array $element) { // Do not allow to add internal 'default' view mode. - if ($entity_id == 'default') { + if ($entity_id === 'default') { return TRUE; } return (bool) $this->queryFactory diff --git a/core/modules/field_ui/src/Form/FieldStorageEditForm.php b/core/modules/field_ui/src/Form/FieldStorageEditForm.php index edb6d22..d7c4aad 100644 --- a/core/modules/field_ui/src/Form/FieldStorageEditForm.php +++ b/core/modules/field_ui/src/Form/FieldStorageEditForm.php @@ -119,11 +119,11 @@ public function buildForm(array $form, FormStateInterface $form_state, FieldInst 'number' => $this->t('Limited'), FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED => $this->t('Unlimited'), ), - '#default_value' => ($cardinality == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) ? FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED : 'number', + '#default_value' => ($cardinality === FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) ? FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED : 'number', ); $form['field']['cardinality_container']['cardinality_number'] = array( '#type' => 'number', - '#default_value' => $cardinality != FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED ? $cardinality : 1, + '#default_value' => $cardinality !== FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED ? $cardinality : 1, '#min' => 1, '#title' => $this->t('Limit'), '#title_display' => 'invisible', diff --git a/core/modules/field_ui/src/FormDisplayOverview.php b/core/modules/field_ui/src/FormDisplayOverview.php index aacd423..daf9c9f 100644 --- a/core/modules/field_ui/src/FormDisplayOverview.php +++ b/core/modules/field_ui/src/FormDisplayOverview.php @@ -116,7 +116,7 @@ protected function getEntityDisplay($mode) { protected function getPlugin(FieldDefinitionInterface $field_definition, $configuration) { $plugin = NULL; - if ($configuration && $configuration['type'] != 'hidden') { + if ($configuration && $configuration['type'] !== 'hidden') { $plugin = $this->pluginManager->getInstance(array( 'field_definition' => $field_definition, 'form_mode' => $this->mode, diff --git a/core/modules/field_ui/src/Tests/FieldUIRouteTest.php b/core/modules/field_ui/src/Tests/FieldUIRouteTest.php index 1f4d3ea..babc12c 100644 --- a/core/modules/field_ui/src/Tests/FieldUIRouteTest.php +++ b/core/modules/field_ui/src/Tests/FieldUIRouteTest.php @@ -70,7 +70,7 @@ public function testFieldUIRoutes() { $this->drupalGet('admin/config/people/accounts/form-display/register'); $this->assertTitle('Manage form display | Drupal'); $this->assertLocalTasks(); - $this->assert(count($this->xpath('//ul/li[1]/a[contains(text(), :text)]', array(':text' => 'Default'))) == 1, 'Default secondary tab is in first position.'); + $this->assert(count($this->xpath('//ul/li[1]/a[contains(text(), :text)]', array(':text' => 'Default'))) === 1, 'Default secondary tab is in first position.'); } /** diff --git a/core/modules/field_ui/src/Tests/ManageFieldsTest.php b/core/modules/field_ui/src/Tests/ManageFieldsTest.php index c137308..6d4be1f 100644 --- a/core/modules/field_ui/src/Tests/ManageFieldsTest.php +++ b/core/modules/field_ui/src/Tests/ManageFieldsTest.php @@ -240,11 +240,11 @@ protected function deleteFieldInstance() { function assertFieldSettings($bundle, $field_name, $string = 'dummy test string', $entity_type = 'node') { // Assert field storage settings. $field_storage = FieldStorageConfig::loadByName($entity_type, $field_name); - $this->assertTrue($field_storage->getSetting('test_field_storage_setting') == $string, 'Field storage settings were found.'); + $this->assertTrue($field_storage->getSetting('test_field_storage_setting') === $string, 'Field storage settings were found.'); // Assert instance settings. $instance = FieldInstanceConfig::loadByName($entity_type, $bundle, $field_name); - $this->assertTrue($instance->getSetting('test_instance_setting') == $string, 'Field instance settings were found.'); + $this->assertTrue($instance->getSetting('test_instance_setting') === $string, 'Field instance settings were found.'); } /** diff --git a/core/modules/file/file.field.inc b/core/modules/file/file.field.inc index 3e88433..f274d59 100644 --- a/core/modules/file/file.field.inc +++ b/core/modules/file/file.field.inc @@ -81,7 +81,7 @@ function template_preprocess_file_widget_multiple(&$variables) { // "operations" column. $operations_elements = array(); foreach (Element::children($widget) as $sub_key) { - if (isset($widget[$sub_key]['#type']) && $widget[$sub_key]['#type'] == 'submit') { + if (isset($widget[$sub_key]['#type']) && $widget[$sub_key]['#type'] === 'submit') { hide($widget[$sub_key]); $operations_elements[] = &$widget[$sub_key]; } @@ -171,7 +171,7 @@ function template_preprocess_file_upload_help(&$variables) { $descriptions[] = Html::normalize($description); } if (isset($cardinality)) { - if ($cardinality == -1) { + if ($cardinality === -1) { $descriptions[] = t('Unlimited number of files can be uploaded to this field.'); } else { @@ -188,7 +188,7 @@ function template_preprocess_file_upload_help(&$variables) { if (isset($upload_validators['file_validate_image_resolution'])) { $max = $upload_validators['file_validate_image_resolution'][0]; $min = $upload_validators['file_validate_image_resolution'][1]; - if ($min && $max && $min == $max) { + if ($min && $max && $min === $max) { $descriptions[] = t('Images must be exactly !size pixels.', array('!size' => '' . $max . '')); } elseif ($min && $max) { @@ -218,9 +218,9 @@ function template_preprocess_file_upload_help(&$variables) { function file_field_find_file_reference_column(FieldDefinitionInterface $field) { $schema = $field->getFieldStorageDefinition()->getSchema(); foreach ($schema['foreign keys'] as $data) { - if ($data['table'] == 'file_managed') { + if ($data['table'] === 'file_managed') { foreach ($data['columns'] as $field_column => $column) { - if ($column == 'fid') { + if ($column === 'fid') { return $field_column; } } diff --git a/core/modules/file/file.install b/core/modules/file/file.install index 8d13c03..2129476 100644 --- a/core/modules/file/file.install +++ b/core/modules/file/file.install @@ -66,7 +66,7 @@ function file_requirements($phase) { $requirements = array(); // Check the server's ability to indicate upload progress. - if ($phase == 'runtime') { + if ($phase === 'runtime') { $implementation = file_progress_implementation(); $server_software = \Drupal::request()->server->get('SERVER_SOFTWARE'); $apache = strpos($server_software, 'Apache') !== FALSE; @@ -88,11 +88,11 @@ function file_requirements($phase) { $value = t('Not enabled'); $description = t('Your server is capable of displaying file upload progress, but does not have the required libraries. It is recommended to install the PECL uploadprogress library (preferred) or to install APC.', array('@uploadprogress_url' => 'http://pecl.php.net/package/uploadprogress', '@apc_url' => 'http://php.net/apc')); } - elseif ($implementation == 'apc') { + elseif ($implementation === 'apc') { $value = t('Enabled (APC RFC1867)', array('@url' => 'http://php.net/manual/apc.configuration.php#ini.apc.rfc1867')); $description = t('Your server is capable of displaying file upload progress using APC RFC1867. Note that only one upload at a time is supported. It is recommended to use the PECL uploadprogress library if possible.', array('@url' => 'http://pecl.php.net/package/uploadprogress')); } - elseif ($implementation == 'uploadprogress') { + elseif ($implementation === 'uploadprogress') { $value = t('Enabled (PECL uploadprogress)', array('@url' => 'http://pecl.php.net/package/uploadprogress')); } $requirements['file_progress'] = array( diff --git a/core/modules/file/file.module b/core/modules/file/file.module index 03e10bf..11b1179 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -181,7 +181,7 @@ function file_copy(FileInterface $source, $destination = NULL, $replace = FILE_E // If we are replacing an existing file re-use its database record. // @todo Do not create a new entity in order to update it, see // https://drupal.org/node/2241865 - if ($replace == FILE_EXISTS_REPLACE) { + if ($replace === FILE_EXISTS_REPLACE) { $existing_files = entity_load_multiple_by_properties('file', array('uri' => $uri)); if (count($existing_files)) { $existing = reset($existing_files); @@ -192,7 +192,7 @@ function file_copy(FileInterface $source, $destination = NULL, $replace = FILE_E } // If we are renaming around an existing file (rather than a directory), // use its basename for the filename. - elseif ($replace == FILE_EXISTS_RENAME && is_file($destination)) { + elseif ($replace === FILE_EXISTS_RENAME && is_file($destination)) { $file->setFilename(drupal_basename($destination)); } @@ -257,7 +257,7 @@ function file_move(FileInterface $source, $destination = NULL, $replace = FILE_E $file = clone $source; $file->setFileUri($uri); // If we are replacing an existing file re-use its database record. - if ($replace == FILE_EXISTS_REPLACE) { + if ($replace === FILE_EXISTS_REPLACE) { $existing_files = entity_load_multiple_by_properties('file', array('uri' => $uri)); if (count($existing_files)) { $existing = reset($existing_files); @@ -268,7 +268,7 @@ function file_move(FileInterface $source, $destination = NULL, $replace = FILE_E } // If we are renaming around an existing file (rather than a directory), // use its basename for the filename. - elseif ($replace == FILE_EXISTS_RENAME && is_file($destination)) { + elseif ($replace === FILE_EXISTS_RENAME && is_file($destination)) { $file->setFilename(drupal_basename($destination)); } @@ -528,7 +528,7 @@ function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAM // If we are replacing an existing file re-use its database record. // @todo Do not create a new entity in order to update it, see // https://drupal.org/node/2241865 - if ($replace == FILE_EXISTS_REPLACE) { + if ($replace === FILE_EXISTS_REPLACE) { $existing_files = entity_load_multiple_by_properties('file', array('uri' => $uri)); if (count($existing_files)) { $existing = reset($existing_files); @@ -539,7 +539,7 @@ function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAM } // If we are renaming around an existing file (rather than a directory), // use its basename for the filename. - elseif ($replace == FILE_EXISTS_RENAME && is_file($destination)) { + elseif ($replace === FILE_EXISTS_RENAME && is_file($destination)) { $file->setFilename(drupal_basename($destination)); } @@ -632,7 +632,7 @@ function file_file_download($uri) { // temporary files where the host entity has not yet been saved (for example, // an image preview on a node/add form) in which case, allow download by the // file's owner. - if (empty($references) && ($file->isPermanent() || $file->getOwnerId() != \Drupal::currentUser()->id())) { + if (empty($references) && ($file->isPermanent() || $file->getOwnerId() !== \Drupal::currentUser()->id())) { return; } @@ -713,7 +713,7 @@ function file_cron() { * * @return * Function returns array of files or a single file object if $delta - * != NULL. Each file object contains the file information if the + * !== NULL. Each file object contains the file information if the * upload succeeded or FALSE in the event of an error. Function * returns NULL if no file was uploaded. * @@ -824,7 +824,7 @@ function file_save_upload($form_field_name, $validators = array(), $destination // rename filename.php.foo and filename.php to filename.php.foo.txt and // filename.php.txt, respectively). Don't rename if 'allow_insecure_uploads' // evaluates to TRUE. - if (!\Drupal::config('system.file')->get('allow_insecure_uploads') && preg_match('/\.(php|pl|py|cgi|asp|js)(\.|$)/i', $file->getFilename()) && (substr($file->getFilename(), -4) != '.txt')) { + if (!\Drupal::config('system.file')->get('allow_insecure_uploads') && preg_match('/\.(php|pl|py|cgi|asp|js)(\.|$)/i', $file->getFilename()) && (substr($file->getFilename(), -4) !== '.txt')) { $file->setMimeType('text/plain'); // The destination filename will also later be used to create the URI. $file->setFilename($file->getFilename() . '.txt'); @@ -851,7 +851,7 @@ function file_save_upload($form_field_name, $validators = array(), $destination $file->source = $form_field_name; // A file URI may already have a trailing slash or look like "public://". - if (substr($destination, -1) != '/') { + if (substr($destination, -1) !== '/') { $destination .= '/'; } $file->destination = file_destination($destination . $file->getFilename(), $replace); @@ -904,7 +904,7 @@ function file_save_upload($form_field_name, $validators = array(), $destination // If we are replacing an existing file re-use its database record. // @todo Do not create a new entity in order to update it, see // https://drupal.org/node/2241865 - if ($replace == FILE_EXISTS_REPLACE) { + if ($replace === FILE_EXISTS_REPLACE) { $existing_files = entity_load_multiple_by_properties('file', array('uri' => $file->getFileUri())); if (count($existing_files)) { $existing = reset($existing_files); @@ -973,7 +973,7 @@ function file_tokens($type, $tokens, array $data = array(), array $options = arr $replacements = array(); - if ($type == 'file' && !empty($data['file'])) { + if ($type === 'file' && !empty($data['file'])) { /** @var \Drupal\file\FileInterface $file */ $file = $data['file']; @@ -1150,7 +1150,7 @@ function file_managed_file_process($element, FormStateInterface $form_state, $fo // Force the progress indicator for the remove button to be either 'none' or // 'throbber', even if the upload button is using something else. - $ajax_settings['progress']['type'] = ($element['#progress_indicator'] == 'none') ? 'none' : 'throbber'; + $ajax_settings['progress']['type'] = ($element['#progress_indicator'] === 'none') ? 'none' : 'throbber'; $ajax_settings['progress']['message'] = NULL; $ajax_settings['effect'] = 'none'; $element['remove_button'] = array( @@ -1170,10 +1170,10 @@ function file_managed_file_process($element, FormStateInterface $form_state, $fo ); // Add progress bar support to the upload if possible. - if ($element['#progress_indicator'] == 'bar' && $implementation = file_progress_implementation()) { + if ($element['#progress_indicator'] === 'bar' && $implementation = file_progress_implementation()) { $upload_progress_key = mt_rand(); - if ($implementation == 'uploadprogress') { + if ($implementation === 'uploadprogress') { $element['UPLOAD_IDENTIFIER'] = array( '#type' => 'hidden', '#value' => $upload_progress_key, @@ -1183,7 +1183,7 @@ function file_managed_file_process($element, FormStateInterface $form_state, $fo '#weight' => -20, ); } - elseif ($implementation == 'apc') { + elseif ($implementation === 'apc') { $element['APC_UPLOAD_PROGRESS'] = array( '#type' => 'hidden', '#value' => $upload_progress_key, @@ -1332,7 +1332,7 @@ function file_managed_file_validate(&$element, FormStateInterface $form_state) { // references. This prevents unmanaged files from being deleted if this // item were to be deleted. $clicked_button = end($form_state->getTriggeringElement()['#parents']); - if ($clicked_button != 'remove_button' && !empty($element['fids']['#value'])) { + if ($clicked_button !== 'remove_button' && !empty($element['fids']['#value'])) { $fids = $element['fids']['#value']; foreach ($fids as $fid) { if ($file = file_load($fid)) { @@ -1376,7 +1376,7 @@ function file_managed_file_submit($form, FormStateInterface $form_state) { // the form are processed by file_managed_file_value() regardless of which // button was clicked. Action is needed here for the remove button, because we // only remove a file in response to its remove button being clicked. - if ($button_key == 'remove_button') { + if ($button_key === 'remove_button') { $fids = array_keys($element['#files']); // Get files that will be removed. if ($element['#multiple']) { @@ -1831,7 +1831,7 @@ function file_get_file_references(FileInterface $file, FieldDefinitionInterface // The usage table contains usage of every revision. If we are looking // for every revision or the entity does not support revisions then // every usage is already a match. - $match_entity_type = $age == EntityStorageInterface::FIELD_LOAD_REVISION || !$entity_type->hasKey('revision'); + $match_entity_type = $age === EntityStorageInterface::FIELD_LOAD_REVISION || !$entity_type->hasKey('revision'); $entities = entity_load_multiple($entity_type_id, array_keys($entity_ids)); foreach ($entities as $entity) { $bundle = $entity->bundle(); @@ -1859,7 +1859,7 @@ function file_get_file_references(FileInterface $file, FieldDefinitionInterface // revision. if (!$match && ($items = $entity->get($field_name))) { foreach ($items as $item) { - if ($file->id() == $item->{$field_column}) { + if ($file->id() === $item->{$field_column}) { $match = TRUE; break; } @@ -1880,7 +1880,7 @@ function file_get_file_references(FileInterface $file, FieldDefinitionInterface foreach (array_keys($data) as $entity_type_id) { $field_storage_definitions = \Drupal::entityManager()->getFieldStorageDefinitions($entity_type_id); $current_field = $field_storage_definitions[$field_name]; - if (($field_type && $current_field->getType() != $field_type) || ($field && $field->uuid() != $current_field->uuid())) { + if (($field_type && $current_field->getType() !== $field_type) || ($field && $field->uuid() !== $current_field->uuid())) { unset($return[$field_name][$entity_type_id]); } } diff --git a/core/modules/file/src/Controller/FileWidgetAjaxController.php b/core/modules/file/src/Controller/FileWidgetAjaxController.php index 1198672..80da7f4 100644 --- a/core/modules/file/src/Controller/FileWidgetAjaxController.php +++ b/core/modules/file/src/Controller/FileWidgetAjaxController.php @@ -99,14 +99,14 @@ public function progress($key) { ); $implementation = file_progress_implementation(); - if ($implementation == 'uploadprogress') { + if ($implementation === 'uploadprogress') { $status = uploadprogress_get_info($key); if (isset($status['bytes_uploaded']) && !empty($status['bytes_total'])) { $progress['message'] = t('Uploading... (@current of @total)', array('@current' => format_size($status['bytes_uploaded']), '@total' => format_size($status['bytes_total']))); $progress['percentage'] = round(100 * $status['bytes_uploaded'] / $status['bytes_total']); } } - elseif ($implementation == 'apc') { + elseif ($implementation === 'apc') { $status = apc_fetch('upload_' . $key); if (isset($status['current']) && !empty($status['total'])) { $progress['message'] = t('Uploading... (@current of @total)', array('@current' => format_size($status['current']), '@total' => format_size($status['total']))); diff --git a/core/modules/file/src/Entity/File.php b/core/modules/file/src/Entity/File.php index b21a182..6353af7 100644 --- a/core/modules/file/src/Entity/File.php +++ b/core/modules/file/src/Entity/File.php @@ -160,14 +160,14 @@ public function setOwner(UserInterface $account) { * {@inheritdoc} */ public function isPermanent() { - return $this->get('status')->value == FILE_STATUS_PERMANENT; + return $this->get('status')->value === FILE_STATUS_PERMANENT; } /** * {@inheritdoc} */ public function isTemporary() { - return $this->get('status')->value == 0; + return $this->get('status')->value === 0; } /** diff --git a/core/modules/file/src/FileAccessControlHandler.php b/core/modules/file/src/FileAccessControlHandler.php index cd87b19..cc55aa0 100644 --- a/core/modules/file/src/FileAccessControlHandler.php +++ b/core/modules/file/src/FileAccessControlHandler.php @@ -23,7 +23,7 @@ class FileAccessControlHandler extends EntityAccessControlHandler { */ protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { - if ($operation == 'download') { + if ($operation === 'download') { foreach ($this->getFileReferences($entity) as $field_name => $entity_map) { foreach ($entity_map as $referencing_entity_type => $referencing_entities) { /** @var \Drupal\Core\Entity\EntityInterface $referencing_entity */ diff --git a/core/modules/file/src/Plugin/Field/FieldType/FileFieldItemList.php b/core/modules/file/src/Plugin/Field/FieldType/FileFieldItemList.php index f8ee03c..2eefdeb 100644 --- a/core/modules/file/src/Plugin/Field/FieldType/FileFieldItemList.php +++ b/core/modules/file/src/Plugin/Field/FieldType/FileFieldItemList.php @@ -50,7 +50,7 @@ public function update() { // On new revisions, all files are considered to be a new usage and no // deletion of previous file usages are necessary. - if (!empty($entity->original) && $entity->getRevisionId() != $entity->original->getRevisionId()) { + if (!empty($entity->original) && $entity->getRevisionId() !== $entity->original->getRevisionId()) { foreach ($files as $file) { \Drupal::service('file.usage')->add($file, 'file', $entity->getEntityTypeId(), $entity->id()); } diff --git a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php index f9becf4..ba21023 100644 --- a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php +++ b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php @@ -131,8 +131,8 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f } } - $empty_single_allowed = ($cardinality == 1 && $delta == 0); - $empty_multiple_allowed = ($cardinality == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED || $delta < $cardinality) && !$form_state->isProgrammed(); + $empty_single_allowed = ($cardinality === 1 && $delta === 0); + $empty_multiple_allowed = ($cardinality === FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED || $delta < $cardinality) && !$form_state->isProgrammed(); // Add one more empty row for new uploads except when this is a programmed // multiple form as it is not necessary. @@ -143,7 +143,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f ); $element = $this->formSingleElement($items, $delta, $element, $form, $form_state); if ($element) { - $element['#required'] = ($element['#required'] && $delta == 0); + $element['#required'] = ($element['#required'] && $delta === 0); $elements[$delta] = $element; } } @@ -245,8 +245,8 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen '#cardinality' => $cardinality, ); $element['#description'] = drupal_render($file_upload_help); - $element['#multiple'] = $cardinality != 1 ? TRUE : FALSE; - if ($cardinality != 1 && $cardinality != -1) { + $element['#multiple'] = $cardinality !== 1 ? TRUE : FALSE; + if ($cardinality !== 1 && $cardinality !== -1) { $element['#element_validate'] = array(array(get_class($this), 'validateMultipleCount')); } } @@ -378,7 +378,7 @@ public static function process($element, FormStateInterface $form_state, $form) // Adjust the Ajax settings so that on upload and remove of any individual // file, the entire group of file fields is updated together. - if ($element['#cardinality'] != 1) { + if ($element['#cardinality'] !== 1) { $parents = array_slice($element['#array_parents'], 0, -1); $new_path = 'file/ajax'; $new_options = array( @@ -425,7 +425,7 @@ public static function processMultiple($element, FormStateInterface $form_state, $count = count($element_children); foreach ($element_children as $delta => $key) { - if ($key != $element['#file_upload_delta']) { + if ($key !== $element['#file_upload_delta']) { $description = static::getDescriptionFromElement($element[$key]); $element[$key]['_weight'] = array( '#type' => 'weight', diff --git a/core/modules/file/src/Tests/DownloadTest.php b/core/modules/file/src/Tests/DownloadTest.php index 92ba740..30c68c4 100644 --- a/core/modules/file/src/Tests/DownloadTest.php +++ b/core/modules/file/src/Tests/DownloadTest.php @@ -120,7 +120,7 @@ function testFileCreateUrl() { 'unclean' => 'index.php/', ); foreach ($clean_url_settings as $clean_url_setting => $script_path) { - $clean_urls = $clean_url_setting == 'clean'; + $clean_urls = $clean_url_setting === 'clean'; $request = $this->prepareRequestForGenerator($clean_urls); $base_path = $request->getSchemeAndHttpHost() . $request->getBasePath(); $this->checkUrl('public', '', $basename, $base_path . '/' . file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath() . '/' . $basename_encoded); @@ -156,14 +156,14 @@ private function checkUrl($scheme, $directory, $filename, $expected_url) { $url = file_create_url($file->getFileUri()); $this->assertEqual($url, $expected_url, 'Generated URL matches expected URL.'); - if ($scheme == 'private') { + if ($scheme === 'private') { // Tell the implementation of hook_file_download() in file_test.module // that this file may be downloaded. file_test_set_return('download', array('x-foo' => 'Bar')); } $this->drupalGet($url); - if ($this->assertResponse(200) == 'pass') { + if ($this->assertResponse(200) === 'pass') { $this->assertRaw(file_get_contents($file->getFileUri()), 'Contents of the file are correct.'); } diff --git a/core/modules/file/src/Tests/FileFieldTestBase.php b/core/modules/file/src/Tests/FileFieldTestBase.php index fb9552a..9115bc3 100644 --- a/core/modules/file/src/Tests/FileFieldTestBase.php +++ b/core/modules/file/src/Tests/FileFieldTestBase.php @@ -161,7 +161,7 @@ function uploadNodeFile($file, $field_name, $nid_or_type, $new_revision = TRUE, // Attach a file to the node. $field_storage = FieldStorageConfig::loadByName('node', $field_name); $name = 'files[' . $field_name . '_0]'; - if ($field_storage->getCardinality() != 1) { + if ($field_storage->getCardinality() !== 1) { $name .= '[]'; } $edit[$name] = drupal_realpath($file->getFileUri()); diff --git a/core/modules/file/src/Tests/FileFieldWidgetTest.php b/core/modules/file/src/Tests/FileFieldWidgetTest.php index 9ae0940..87d325a 100644 --- a/core/modules/file/src/Tests/FileFieldWidgetTest.php +++ b/core/modules/file/src/Tests/FileFieldWidgetTest.php @@ -136,7 +136,7 @@ function testMultiValuedWidget() { foreach ($buttons as $i => $button) { $key = $i >= $remaining ? $i - $remaining : $i; $check_field_name = $field_name2; - if ($current_field_name == $field_name && $i < $remaining) { + if ($current_field_name === $field_name && $i < $remaining) { $check_field_name = $field_name; } @@ -155,7 +155,7 @@ function testMultiValuedWidget() { // data, and since drupalPostForm() will result in $this being updated // with a newly rebuilt form, this doesn't cause problems. foreach ($buttons as $button) { - if ($button['name'] != $button_name) { + if ($button['name'] !== $button_name) { $button['value'] = 'DUMMY'; } } @@ -174,12 +174,12 @@ function testMultiValuedWidget() { // correct name. $upload_button_name = $current_field_name . '_' . $remaining . '_upload_button'; $buttons = $this->xpath('//input[@type="submit" and @value="Upload" and @name=:name]', array(':name' => $upload_button_name)); - $this->assertTrue(is_array($buttons) && count($buttons) == 1, format_string('The upload button is displayed with the correct name (JSMode=%type).', array('%type' => $type))); + $this->assertTrue(is_array($buttons) && count($buttons) === 1, format_string('The upload button is displayed with the correct name (JSMode=%type).', array('%type' => $type))); // Ensure only at most one button per field is displayed. $buttons = $this->xpath('//input[@type="submit" and @value="Upload"]'); - $expected = $current_field_name == $field_name ? 1 : 2; - $this->assertTrue(is_array($buttons) && count($buttons) == $expected, format_string('After removing a file, only one "Upload" button for each possible field is displayed (JSMode=%type).', array('%type' => $type))); + $expected = $current_field_name === $field_name ? 1 : 2; + $this->assertTrue(is_array($buttons) && count($buttons) === $expected, format_string('After removing a file, only one "Upload" button for each possible field is displayed (JSMode=%type).', array('%type' => $type))); } } diff --git a/core/modules/file/src/Tests/FileManagedTestBase.php b/core/modules/file/src/Tests/FileManagedTestBase.php index 3147f73..41174f7 100644 --- a/core/modules/file/src/Tests/FileManagedTestBase.php +++ b/core/modules/file/src/Tests/FileManagedTestBase.php @@ -76,10 +76,10 @@ function assertFileHookCalled($hook, $expected_count = 1, $message = NULL) { $actual_count = count(file_test_get_calls($hook)); if (!isset($message)) { - if ($actual_count == $expected_count) { + if ($actual_count === $expected_count) { $message = format_string('hook_file_@name was called correctly.', array('@name' => $hook)); } - elseif ($expected_count == 0) { + elseif ($expected_count === 0) { $message = format_plural($actual_count, 'hook_file_@name was not expected to be called but was actually called once.', 'hook_file_@name was not expected to be called but was actually called @count times.', array('@name' => $hook, '@count' => $actual_count)); } else { @@ -98,13 +98,13 @@ function assertFileHookCalled($hook, $expected_count = 1, $message = NULL) { * File object to compare. */ function assertFileUnchanged(FileInterface $before, FileInterface $after) { - $this->assertEqual($before->id(), $after->id(), t('File id is the same: %file1 == %file2.', array('%file1' => $before->id(), '%file2' => $after->id())), 'File unchanged'); - $this->assertEqual($before->getOwner()->id(), $after->getOwner()->id(), t('File owner is the same: %file1 == %file2.', array('%file1' => $before->getOwner()->id(), '%file2' => $after->getOwner()->id())), 'File unchanged'); - $this->assertEqual($before->getFilename(), $after->getFilename(), t('File name is the same: %file1 == %file2.', array('%file1' => $before->getFilename(), '%file2' => $after->getFilename())), 'File unchanged'); - $this->assertEqual($before->getFileUri(), $after->getFileUri(), t('File path is the same: %file1 == %file2.', array('%file1' => $before->getFileUri(), '%file2' => $after->getFileUri())), 'File unchanged'); - $this->assertEqual($before->getMimeType(), $after->getMimeType(), t('File MIME type is the same: %file1 == %file2.', array('%file1' => $before->getMimeType(), '%file2' => $after->getMimeType())), 'File unchanged'); - $this->assertEqual($before->getSize(), $after->getSize(), t('File size is the same: %file1 == %file2.', array('%file1' => $before->getSize(), '%file2' => $after->getSize())), 'File unchanged'); - $this->assertEqual($before->isPermanent(), $after->isPermanent(), t('File status is the same: %file1 == %file2.', array('%file1' => $before->isPermanent(), '%file2' => $after->isPermanent())), 'File unchanged'); + $this->assertEqual($before->id(), $after->id(), t('File id is the same: %file1 === %file2.', array('%file1' => $before->id(), '%file2' => $after->id())), 'File unchanged'); + $this->assertEqual($before->getOwner()->id(), $after->getOwner()->id(), t('File owner is the same: %file1 === %file2.', array('%file1' => $before->getOwner()->id(), '%file2' => $after->getOwner()->id())), 'File unchanged'); + $this->assertEqual($before->getFilename(), $after->getFilename(), t('File name is the same: %file1 === %file2.', array('%file1' => $before->getFilename(), '%file2' => $after->getFilename())), 'File unchanged'); + $this->assertEqual($before->getFileUri(), $after->getFileUri(), t('File path is the same: %file1 === %file2.', array('%file1' => $before->getFileUri(), '%file2' => $after->getFileUri())), 'File unchanged'); + $this->assertEqual($before->getMimeType(), $after->getMimeType(), t('File MIME type is the same: %file1 === %file2.', array('%file1' => $before->getMimeType(), '%file2' => $after->getMimeType())), 'File unchanged'); + $this->assertEqual($before->getSize(), $after->getSize(), t('File size is the same: %file1 === %file2.', array('%file1' => $before->getSize(), '%file2' => $after->getSize())), 'File unchanged'); + $this->assertEqual($before->isPermanent(), $after->isPermanent(), t('File status is the same: %file1 === %file2.', array('%file1' => $before->isPermanent(), '%file2' => $after->isPermanent())), 'File unchanged'); } /** @@ -116,8 +116,8 @@ function assertFileUnchanged(FileInterface $before, FileInterface $after) { * File object to compare. */ function assertDifferentFile(FileInterface $file1, FileInterface $file2) { - $this->assertNotEqual($file1->id(), $file2->id(), t('Files have different ids: %file1 != %file2.', array('%file1' => $file1->id(), '%file2' => $file2->id())), 'Different file'); - $this->assertNotEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have different paths: %file1 != %file2.', array('%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri())), 'Different file'); + $this->assertNotEqual($file1->id(), $file2->id(), t('Files have different ids: %file1 !== %file2.', array('%file1' => $file1->id(), '%file2' => $file2->id())), 'Different file'); + $this->assertNotEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have different paths: %file1 !== %file2.', array('%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri())), 'Different file'); } /** @@ -129,8 +129,8 @@ function assertDifferentFile(FileInterface $file1, FileInterface $file2) { * File object to compare. */ function assertSameFile(FileInterface $file1, FileInterface $file2) { - $this->assertEqual($file1->id(), $file2->id(), t('Files have the same ids: %file1 == %file2.', array('%file1' => $file1->id(), '%file2-fid' => $file2->id())), 'Same file'); - $this->assertEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have the same path: %file1 == %file2.', array('%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri())), 'Same file'); + $this->assertEqual($file1->id(), $file2->id(), t('Files have the same ids: %file1 === %file2.', array('%file1' => $file1->id(), '%file2-fid' => $file2->id())), 'Same file'); + $this->assertEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have the same path: %file1 === %file2.', array('%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri())), 'Same file'); } /** diff --git a/core/modules/file/src/Tests/FileManagedUnitTestBase.php b/core/modules/file/src/Tests/FileManagedUnitTestBase.php index 051601a..08d2929 100644 --- a/core/modules/file/src/Tests/FileManagedUnitTestBase.php +++ b/core/modules/file/src/Tests/FileManagedUnitTestBase.php @@ -88,10 +88,10 @@ function assertFileHookCalled($hook, $expected_count = 1, $message = NULL) { $actual_count = count(file_test_get_calls($hook)); if (!isset($message)) { - if ($actual_count == $expected_count) { + if ($actual_count === $expected_count) { $message = format_string('hook_file_@name was called correctly.', array('@name' => $hook)); } - elseif ($expected_count == 0) { + elseif ($expected_count === 0) { $message = format_plural($actual_count, 'hook_file_@name was not expected to be called but was actually called once.', 'hook_file_@name was not expected to be called but was actually called @count times.', array('@name' => $hook, '@count' => $actual_count)); } else { @@ -110,13 +110,13 @@ function assertFileHookCalled($hook, $expected_count = 1, $message = NULL) { * File object to compare. */ function assertFileUnchanged(FileInterface $before, FileInterface $after) { - $this->assertEqual($before->id(), $after->id(), t('File id is the same: %file1 == %file2.', array('%file1' => $before->id(), '%file2' => $after->id())), 'File unchanged'); - $this->assertEqual($before->getOwner()->id(), $after->getOwner()->id(), t('File owner is the same: %file1 == %file2.', array('%file1' => $before->getOwner()->id(), '%file2' => $after->getOwner()->id())), 'File unchanged'); - $this->assertEqual($before->getFilename(), $after->getFilename(), t('File name is the same: %file1 == %file2.', array('%file1' => $before->getFilename(), '%file2' => $after->getFilename())), 'File unchanged'); - $this->assertEqual($before->getFileUri(), $after->getFileUri(), t('File path is the same: %file1 == %file2.', array('%file1' => $before->getFileUri(), '%file2' => $after->getFileUri())), 'File unchanged'); - $this->assertEqual($before->getMimeType(), $after->getMimeType(), t('File MIME type is the same: %file1 == %file2.', array('%file1' => $before->getMimeType(), '%file2' => $after->getMimeType())), 'File unchanged'); - $this->assertEqual($before->getSize(), $after->getSize(), t('File size is the same: %file1 == %file2.', array('%file1' => $before->getSize(), '%file2' => $after->getSize())), 'File unchanged'); - $this->assertEqual($before->isPermanent(), $after->isPermanent(), t('File status is the same: %file1 == %file2.', array('%file1' => $before->isPermanent(), '%file2' => $after->isPermanent())), 'File unchanged'); + $this->assertEqual($before->id(), $after->id(), t('File id is the same: %file1 === %file2.', array('%file1' => $before->id(), '%file2' => $after->id())), 'File unchanged'); + $this->assertEqual($before->getOwner()->id(), $after->getOwner()->id(), t('File owner is the same: %file1 === %file2.', array('%file1' => $before->getOwner()->id(), '%file2' => $after->getOwner()->id())), 'File unchanged'); + $this->assertEqual($before->getFilename(), $after->getFilename(), t('File name is the same: %file1 === %file2.', array('%file1' => $before->getFilename(), '%file2' => $after->getFilename())), 'File unchanged'); + $this->assertEqual($before->getFileUri(), $after->getFileUri(), t('File path is the same: %file1 === %file2.', array('%file1' => $before->getFileUri(), '%file2' => $after->getFileUri())), 'File unchanged'); + $this->assertEqual($before->getMimeType(), $after->getMimeType(), t('File MIME type is the same: %file1 === %file2.', array('%file1' => $before->getMimeType(), '%file2' => $after->getMimeType())), 'File unchanged'); + $this->assertEqual($before->getSize(), $after->getSize(), t('File size is the same: %file1 === %file2.', array('%file1' => $before->getSize(), '%file2' => $after->getSize())), 'File unchanged'); + $this->assertEqual($before->isPermanent(), $after->isPermanent(), t('File status is the same: %file1 === %file2.', array('%file1' => $before->isPermanent(), '%file2' => $after->isPermanent())), 'File unchanged'); } /** @@ -128,8 +128,8 @@ function assertFileUnchanged(FileInterface $before, FileInterface $after) { * File object to compare. */ function assertDifferentFile(FileInterface $file1, FileInterface $file2) { - $this->assertNotEqual($file1->id(), $file2->id(), t('Files have different ids: %file1 != %file2.', array('%file1' => $file1->id(), '%file2' => $file2->id())), 'Different file'); - $this->assertNotEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have different paths: %file1 != %file2.', array('%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri())), 'Different file'); + $this->assertNotEqual($file1->id(), $file2->id(), t('Files have different ids: %file1 !== %file2.', array('%file1' => $file1->id(), '%file2' => $file2->id())), 'Different file'); + $this->assertNotEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have different paths: %file1 !== %file2.', array('%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri())), 'Different file'); } /** @@ -141,8 +141,8 @@ function assertDifferentFile(FileInterface $file1, FileInterface $file2) { * File object to compare. */ function assertSameFile(FileInterface $file1, FileInterface $file2) { - $this->assertEqual($file1->id(), $file2->id(), t('Files have the same ids: %file1 == %file2.', array('%file1' => $file1->id(), '%file2-fid' => $file2->id())), 'Same file'); - $this->assertEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have the same path: %file1 == %file2.', array('%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri())), 'Same file'); + $this->assertEqual($file1->id(), $file2->id(), t('Files have the same ids: %file1 === %file2.', array('%file1' => $file1->id(), '%file2-fid' => $file2->id())), 'Same file'); + $this->assertEqual($file1->getFileUri(), $file2->getFileUri(), t('Files have the same path: %file1 === %file2.', array('%file1' => $file1->getFileUri(), '%file2' => $file2->getFileUri())), 'Same file'); } /** diff --git a/core/modules/file/tests/file_test/file_test.module b/core/modules/file/tests/file_test/file_test.module index b1bdeb3..e4c5c77 100644 --- a/core/modules/file/tests/file_test/file_test.module +++ b/core/modules/file/tests/file_test/file_test.module @@ -223,7 +223,7 @@ function file_test_file_url_alter(&$uri) { return; } // Test alteration of file URLs to use a CDN. - elseif ($alter_mode == 'cdn') { + elseif ($alter_mode === 'cdn') { $cdn_extensions = array('css', 'js', 'gif', 'jpg', 'jpeg', 'png'); // Most CDNs don't support private file transfers without a lot of hassle, @@ -259,11 +259,11 @@ function file_test_file_url_alter(&$uri) { } } // Test alteration of file URLs to use root-relative URLs. - elseif ($alter_mode == 'root-relative') { + elseif ($alter_mode === 'root-relative') { // Only serve shipped files and public created files with root-relative // URLs. $scheme = file_uri_scheme($uri); - if (!$scheme || $scheme == 'public') { + if (!$scheme || $scheme === 'public') { // Shipped files. if (!$scheme) { $path = $uri; @@ -282,11 +282,11 @@ function file_test_file_url_alter(&$uri) { } } // Test alteration of file URLs to use protocol-relative URLs. - elseif ($alter_mode == 'protocol-relative') { + elseif ($alter_mode === 'protocol-relative') { // Only serve shipped files and public created files with protocol-relative // URLs. $scheme = file_uri_scheme($uri); - if (!$scheme || $scheme == 'public') { + if (!$scheme || $scheme === 'public') { // Shipped files. if (!$scheme) { $path = $uri; diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index d31cca1..54c1f81 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -161,7 +161,7 @@ function filter_pre_render_text(array $element) { $enabled = $filter->status === TRUE; $type = $filter->getType(); // Prevent FilterInterface::TYPE_HTML_RESTRICTOR from being skipped. - $filter_type_must_be_applied = $type == FilterInterface::TYPE_HTML_RESTRICTOR || !in_array($type, $filter_types_to_skip); + $filter_type_must_be_applied = $type === FilterInterface::TYPE_HTML_RESTRICTOR || !in_array($type, $filter_types_to_skip); return $enabled && $filter_type_must_be_applied; }; @@ -657,7 +657,7 @@ function filter_process_format($element) { // Hide the text format selector and any other child element (such as text // field's summary). foreach (Element::children($element) as $key) { - if ($key != 'value') { + if ($key !== 'value') { $element[$key]['#access'] = FALSE; } } @@ -704,7 +704,7 @@ function _filter_tips($format_id, $long = FALSE) { $tips = array(); // If only listing one format, extract it from the $formats array. - if ($format_id != -1) { + if ($format_id !== -1) { $formats = array($formats[$format_id]); } @@ -925,9 +925,9 @@ function _filter_url($text, $filter) { $open_tag = ''; for ($i = 0; $i < count($chunks); $i++) { - if ($chunk_type == 'text') { + if ($chunk_type === 'text') { // Only process this text if there are no unclosed $ignore_tags. - if ($open_tag == '') { + if ($open_tag === '') { // If there is a match, inject a link into this chunk via the callback // function contained in $task. $chunks[$i] = preg_replace_callback($pattern, $task, $chunks[$i]); @@ -937,7 +937,7 @@ function _filter_url($text, $filter) { } else { // Only process this tag if there are no unclosed $ignore_tags. - if ($open_tag == '') { + if ($open_tag === '') { // Check whether this tag is contained in $ignore_tags. if (preg_match("`<($ignore_tags)(?:\s|>)`i", $chunks[$i], $matches)) { $open_tag = $matches[1]; @@ -1086,14 +1086,14 @@ function _filter_autop($text) { $output = ''; foreach ($chunks as $i => $chunk) { if ($i % 2) { - $comment = (substr($chunk, 0, 4) == ''); // If the size is zero, and there is no delimiter, the entire body is the summary. - if ($size == 0 && $delimiter === FALSE) { + if ($size === 0 && $delimiter === FALSE) { return $text; } diff --git a/core/modules/toolbar/src/Controller/ToolbarController.php b/core/modules/toolbar/src/Controller/ToolbarController.php index b1de82d..ae89f19 100644 --- a/core/modules/toolbar/src/Controller/ToolbarController.php +++ b/core/modules/toolbar/src/Controller/ToolbarController.php @@ -43,7 +43,7 @@ public function subtreesJsonp() { */ public function checkSubTreeAccess(Request $request, $langcode) { $hash = $request->get('hash'); - return AccessResult::allowedIf($this->currentUser()->hasPermission('access toolbar') && $hash == _toolbar_get_subtrees_hash($langcode))->cachePerRole(); + return AccessResult::allowedIf($this->currentUser()->hasPermission('access toolbar') && $hash === _toolbar_get_subtrees_hash($langcode))->cachePerRole(); } } diff --git a/core/modules/tour/src/Entity/Tour.php b/core/modules/tour/src/Entity/Tour.php index 55b94f1..765cf42 100644 --- a/core/modules/tour/src/Entity/Tour.php +++ b/core/modules/tour/src/Entity/Tour.php @@ -110,7 +110,7 @@ public function getTips() { $tips[] = $this->getTip($id); } uasort($tips, function ($a, $b) { - if ($a->getWeight() == $b->getWeight()) { + if ($a->getWeight() === $b->getWeight()) { return 0; } return ($a->getWeight() < $b->getWeight()) ? -1 : 1; diff --git a/core/modules/tour/tests/tour_test/tour_test.module b/core/modules/tour/tests/tour_test/tour_test.module index 69a9a54..2e1d2ef 100644 --- a/core/modules/tour/tests/tour_test/tour_test.module +++ b/core/modules/tour/tests/tour_test/tour_test.module @@ -20,7 +20,7 @@ function tour_test_tour_load($entities) { * Implements hook_ENTITY_TYPE_presave() for tour. */ function tour_test_tour_presave($entity) { - if ($entity->id() == 'tour-entity-create-test-en') { + if ($entity->id() === 'tour-entity-create-test-en') { $entity->set('label', $entity->label() . ' alter'); } } @@ -30,7 +30,7 @@ function tour_test_tour_presave($entity) { */ function tour_test_tour_tips_alter(array &$tour_tips, EntityInterface $entity) { foreach ($tour_tips as $tour_tip) { - if ($tour_tip->get('id') == 'tour-code-test-1') { + if ($tour_tip->get('id') === 'tour-code-test-1') { $tour_tip->set('body', 'Altered by hook_tour_tips_alter'); } } diff --git a/core/modules/tour/tour.api.php b/core/modules/tour/tour.api.php index 04049f5..0eff855 100644 --- a/core/modules/tour/tour.api.php +++ b/core/modules/tour/tour.api.php @@ -20,7 +20,7 @@ */ function hook_tour_tips_alter(array &$tour_tips, Drupal\Core\Entity\EntityInterface $entity) { foreach ($tour_tips as $tour_tip) { - if ($tour_tip->get('id') == 'tour-code-test-1') { + if ($tour_tip->get('id') === 'tour-code-test-1') { $tour_tip->set('body', 'Altered by hook_tour_tips_alter'); } } diff --git a/core/modules/tracker/src/Access/ViewOwnTrackerAccessCheck.php b/core/modules/tracker/src/Access/ViewOwnTrackerAccessCheck.php index 097627c..617c198 100644 --- a/core/modules/tracker/src/Access/ViewOwnTrackerAccessCheck.php +++ b/core/modules/tracker/src/Access/ViewOwnTrackerAccessCheck.php @@ -29,6 +29,7 @@ class ViewOwnTrackerAccessCheck implements AccessInterface { * The access result. */ public function access(AccountInterface $account, UserInterface $user) { - return AccessResult::allowedIf($user && $account->isAuthenticated() && ($user->id() == $account->id()))->cachePerUser(); + return AccessResult::allowedIf($user && $account->isAuthenticated() && ($user->id() === $account->id()))->cachePerUser(); } + } diff --git a/core/modules/tracker/tracker.install b/core/modules/tracker/tracker.install index 5f3e5a0..895e023 100644 --- a/core/modules/tracker/tracker.install +++ b/core/modules/tracker/tracker.install @@ -17,7 +17,7 @@ function tracker_uninstall() { */ function tracker_install() { $max_nid = db_query('SELECT MAX(nid) FROM {node}')->fetchField(); - if ($max_nid != 0) { + if ($max_nid !== 0) { \Drupal::state()->set('tracker.index_nid', $max_nid); // To avoid timing out while attempting to do a complete indexing, we // simply call our cron job to remove stale records and begin the process. diff --git a/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module index fba29f8..95a4a73 100644 --- a/core/modules/tracker/tracker.module +++ b/core/modules/tracker/tracker.module @@ -146,7 +146,7 @@ function tracker_cron() { */ function _tracker_myrecent_access(AccountInterface $account) { // This path is only allowed for authenticated users looking at their own content. - return $account->id() && (\Drupal::currentUser()->id() == $account->id()) && $account->hasPermission('access content'); + return $account->id() && (\Drupal::currentUser()->id() === $account->id()) && $account->hasPermission('access content'); } /** @@ -201,7 +201,7 @@ function tracker_node_predelete(EntityInterface $node, $arg = 0) { * Implements hook_ENTITY_TYPE_update() for comment entities. */ function tracker_comment_update(CommentInterface $comment) { - if ($comment->getCommentedEntityTypeId() == 'node') { + if ($comment->getCommentedEntityTypeId() === 'node') { if ($comment->isPublished()) { _tracker_add($comment->getCommentedEntityId(), $comment->getOwnerId(), $comment->getChangedTime()); } @@ -215,7 +215,7 @@ function tracker_comment_update(CommentInterface $comment) { * Implements hook_ENTITY_TYPE_insert() for comment entities. */ function tracker_comment_insert(CommentInterface $comment) { - if ($comment->getCommentedEntityTypeId() == 'node' && $comment->isPublished()) { + if ($comment->getCommentedEntityTypeId() === 'node' && $comment->isPublished()) { _tracker_add($comment->getCommentedEntityId(), $comment->getOwnerId(), $comment->getChangedTime()); } } @@ -224,7 +224,7 @@ function tracker_comment_insert(CommentInterface $comment) { * Implements hook_ENTITY_TYPE_delete() for comment entities. */ function tracker_comment_delete(CommentInterface $comment) { - if ($comment->getCommentedEntityTypeId() == 'node') { + if ($comment->getCommentedEntityTypeId() === 'node') { _tracker_remove($comment->getCommentedEntityId(), $comment->getOwnerId(), $comment->getChangedTime()); } } @@ -316,7 +316,7 @@ function _tracker_remove($nid, $uid = NULL, $changed = NULL) { // The user only keeps their subscription if the node exists. if ($node) { // And they are the author of the node. - $keep_subscription = ($node->getOwnerId() == $uid); + $keep_subscription = ($node->getOwnerId() === $uid); // Or if they have commented on the node. if (!$keep_subscription) { diff --git a/core/modules/update/src/Form/UpdateManagerInstall.php b/core/modules/update/src/Form/UpdateManagerInstall.php index 3198a28..d4d921f 100644 --- a/core/modules/update/src/Form/UpdateManagerInstall.php +++ b/core/modules/update/src/Form/UpdateManagerInstall.php @@ -205,7 +205,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // install the code, there's no need to prompt for FTP/SSH credentials. // Instead, we instantiate a Drupal\Core\FileTransfer\Local and invoke // update_authorize_run_install() directly. - if (fileowner($project_real_location) == fileowner(conf_path())) { + if (fileowner($project_real_location) === fileowner(conf_path())) { $this->moduleHandler->loadInclude('update', 'inc', 'update.authorize'); $filetransfer = new Local(DRUPAL_ROOT); call_user_func_array('update_authorize_run_install', array_merge(array($filetransfer), $arguments)); diff --git a/core/modules/update/src/Form/UpdateManagerUpdate.php b/core/modules/update/src/Form/UpdateManagerUpdate.php index c90247f..8f6cf7c 100644 --- a/core/modules/update/src/Form/UpdateManagerUpdate.php +++ b/core/modules/update/src/Form/UpdateManagerUpdate.php @@ -105,7 +105,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $project_data = update_calculate_project_data($available); foreach ($project_data as $name => $project) { // Filter out projects which are up to date already. - if ($project['status'] == UPDATE_CURRENT) { + if ($project['status'] === UPDATE_CURRENT) { continue; } // The project name to display can vary based on the info we have. @@ -123,7 +123,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { else { $project_name = String::checkPlain($name); } - if ($project['project_type'] == 'theme' || $project['project_type'] == 'theme-disabled') { + if ($project['project_type'] === 'theme' || $project['project_type'] === 'theme-disabled') { $project_name .= ' ' . $this->t('(Theme)'); } @@ -135,7 +135,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $recommended_release = $project['releases'][$project['recommended']]; $recommended_version = $recommended_release['version'] . ' ' . l($this->t('(Release notes)'), $recommended_release['release_link'], array('attributes' => array('title' => $this->t('Release notes for @project_title', array('@project_title' => $project['title']))))); - if ($recommended_release['version_major'] != $project['existing_major']) { + if ($recommended_release['version_major'] !== $project['existing_major']) { $recommended_version .= '

    ' . $this->t('This update is a major version update which means that it may not be backwards compatible with your currently running version. It is recommended that you read the release notes and proceed at your own risk.') . '
    '; } @@ -180,7 +180,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $entry['#attributes'] = array('class' => array('update-' . $type)); // Drupal core needs to be upgraded manually. - $needs_manual = $project['project_type'] == 'core'; + $needs_manual = $project['project_type'] === 'core'; if ($needs_manual) { // There are no checkboxes in the 'Manual updates' table so it will be diff --git a/core/modules/update/src/Form/UpdateReady.php b/core/modules/update/src/Form/UpdateReady.php index 66e94de..9a25e22 100644 --- a/core/modules/update/src/Form/UpdateReady.php +++ b/core/modules/update/src/Form/UpdateReady.php @@ -100,7 +100,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { public function submitForm(array &$form, FormStateInterface $form_state) { // Store maintenance_mode setting so we can restore it when done. $_SESSION['maintenance_mode'] = $this->state->get('system.maintenance_mode'); - if ($form_state->getValue('maintenance_mode') == TRUE) { + if ($form_state->getValue('maintenance_mode') === TRUE) { $this->state->set('system.maintenance_mode', TRUE); } @@ -131,7 +131,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // trying to install the code, there's no need to prompt for FTP/SSH // credentials. Instead, we instantiate a Drupal\Core\FileTransfer\Local // and invoke update_authorize_run_update() directly. - if (fileowner($project_real_location) == fileowner(conf_path())) { + if (fileowner($project_real_location) === fileowner(conf_path())) { $this->moduleHandler->loadInclude('update', 'inc', 'update.authorize'); $filetransfer = new Local(DRUPAL_ROOT); update_authorize_run_update($filetransfer, $updates); diff --git a/core/modules/update/src/UpdateSettingsForm.php b/core/modules/update/src/UpdateSettingsForm.php index fb872b6..fbdf61a 100644 --- a/core/modules/update/src/UpdateSettingsForm.php +++ b/core/modules/update/src/UpdateSettingsForm.php @@ -90,7 +90,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) { if (empty($invalid)) { $form_state->set('notify_emails', $valid); } - elseif (count($invalid) == 1) { + elseif (count($invalid) === 1) { $form_state->setErrorByName('update_notify_emails', $this->t('%email is not a valid email address.', array('%email' => reset($invalid)))); } else { @@ -108,7 +108,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $config = $this->config('update.settings'); // See if the update_check_disabled setting is being changed, and if so, // invalidate all update status data. - if ($form_state->getValue('update_check_disabled') != $config->get('check.disabled_extensions')) { + if ($form_state->getValue('update_check_disabled') !== $config->get('check.disabled_extensions')) { update_storage_clear(); } diff --git a/core/modules/update/update.api.php b/core/modules/update/update.api.php index b5c8120..91f929b 100644 --- a/core/modules/update/update.api.php +++ b/core/modules/update/update.api.php @@ -86,7 +86,7 @@ function hook_update_status_alter(&$projects) { $settings = \Drupal::config('update_advanced.settings')->get('projects'); foreach ($projects as $project => $project_info) { if (isset($settings[$project]) && isset($settings[$project]['check']) && - ($settings[$project]['check'] == 'never' || + ($settings[$project]['check'] === 'never' || (isset($project_info['recommended']) && $settings[$project]['check'] === $project_info['recommended']))) { $projects[$project]['status'] = UPDATE_NOT_CHECKED; diff --git a/core/modules/update/update.authorize.inc b/core/modules/update/update.authorize.inc index 3bfdbcf..5f28202 100644 --- a/core/modules/update/update.authorize.inc +++ b/core/modules/update/update.authorize.inc @@ -198,7 +198,7 @@ function update_authorize_update_batch_finished($success, $results) { _update_authorize_clear_update_status(); // Take the site out of maintenance mode if it was previously that way. - if ($offline && isset($_SESSION['maintenance_mode']) && $_SESSION['maintenance_mode'] == FALSE) { + if ($offline && isset($_SESSION['maintenance_mode']) && $_SESSION['maintenance_mode'] === FALSE) { \Drupal::state()->set('system.maintenance_mode', FALSE); $page_message = array( 'message' => t('Update was completed successfully. Your site has been taken out of maintenance mode.'), @@ -260,7 +260,7 @@ function update_authorize_install_batch_finished($success, $results) { $offline = \Drupal::state()->get('system.maintenance_mode'); if ($success) { // Take the site out of maintenance mode if it was previously that way. - if ($offline && isset($_SESSION['maintenance_mode']) && $_SESSION['maintenance_mode'] == FALSE) { + if ($offline && isset($_SESSION['maintenance_mode']) && $_SESSION['maintenance_mode'] === FALSE) { \Drupal::state()->set('system.maintenance_mode', FALSE); $page_message = array( 'message' => t('Installation was completed successfully. Your site has been taken out of maintenance mode.'), diff --git a/core/modules/update/update.compare.inc b/core/modules/update/update.compare.inc index da6d63b..40a659a 100644 --- a/core/modules/update/update.compare.inc +++ b/core/modules/update/update.compare.inc @@ -334,7 +334,7 @@ function update_calculate_project_update_status(&$project_data, $available) { // data we currently have (if any) is stale, and we've got a task queued // up to (re)fetch the data. In that case, we mark it as such, merge in // whatever data we have (e.g. project title and link), and move on. - if (!empty($available['fetch_status']) && $available['fetch_status'] == UPDATE_FETCH_PENDING) { + if (!empty($available['fetch_status']) && $available['fetch_status'] === UPDATE_FETCH_PENDING) { $project_data['status'] = UPDATE_FETCH_PENDING; $project_data['reason'] = t('No available update data'); $project_data['fetch_status'] = $available['fetch_status']; @@ -354,7 +354,7 @@ function update_calculate_project_update_status(&$project_data, $available) { in_array('Insecure', $release['terms']['Release type'])) { $project_data['status'] = UPDATE_NOT_SECURE; } - elseif ($release['status'] == 'unpublished') { + elseif ($release['status'] === 'unpublished') { $project_data['status'] = UPDATE_REVOKED; if (empty($project_data['extra'])) { $project_data['extra'] = array(); @@ -380,7 +380,7 @@ function update_calculate_project_update_status(&$project_data, $available) { } // Otherwise, ignore unpublished, insecure, or unsupported releases. - if ($release['status'] == 'unpublished' || + if ($release['status'] === 'unpublished' || (isset($release['terms']['Release type']) && (in_array('Insecure', $release['terms']['Release type']) || in_array('Unsupported', $release['terms']['Release type'])))) { @@ -415,16 +415,16 @@ function update_calculate_project_update_status(&$project_data, $available) { // Look for the 'latest version' if we haven't found it yet. Latest is // defined as the most recent version for the target major version. if (!isset($project_data['latest_version']) - && $release['version_major'] == $target_major) { + && $release['version_major'] === $target_major) { $project_data['latest_version'] = $version; $project_data['releases'][$version] = $release; } // Look for the development snapshot release for this branch. if (!isset($project_data['dev_version']) - && $release['version_major'] == $target_major + && $release['version_major'] === $target_major && isset($release['version_extra']) - && $release['version_extra'] == 'dev') { + && $release['version_extra'] === 'dev') { $project_data['dev_version'] = $version; $project_data['releases'][$version] = $release; } @@ -432,13 +432,13 @@ function update_calculate_project_update_status(&$project_data, $available) { // Look for the 'recommended' version if we haven't found it yet (see // phpdoc at the top of this function for the definition). if (!isset($project_data['recommended']) - && $release['version_major'] == $target_major + && $release['version_major'] === $target_major && isset($release['version_patch'])) { - if ($patch != $release['version_patch']) { + if ($patch !== $release['version_patch']) { $patch = $release['version_patch']; $release_patch_changed = $release; } - if (empty($release['version_extra']) && $patch == $release['version_patch']) { + if (empty($release['version_extra']) && $patch === $release['version_patch']) { $project_data['recommended'] = $release_patch_changed['version']; $project_data['releases'][$release_patch_changed['version']] = $release_patch_changed; } @@ -455,7 +455,7 @@ function update_calculate_project_update_status(&$project_data, $available) { // differences between the datestamp in the .info.yml file and the // timestamp of the tarball itself (which are usually off by 1 or 2 // seconds) so that we don't flag that as a new release. - if ($project_data['install_type'] == 'dev') { + if ($project_data['install_type'] === 'dev') { if (empty($project_data['datestamp'])) { // We don't have current timestamp info, so we can't know. continue; @@ -505,7 +505,7 @@ function update_calculate_project_update_status(&$project_data, $available) { // with the latest official version, and record the absolute latest in // 'latest_dev' so we can correctly decide if there's a newer release // than our current snapshot. - if ($project_data['install_type'] == 'dev') { + if ($project_data['install_type'] === 'dev') { if (isset($project_data['dev_version']) && $available['releases'][$project_data['dev_version']]['date'] > $available['releases'][$project_data['latest_version']]['date']) { $project_data['latest_dev'] = $project_data['dev_version']; } diff --git a/core/modules/update/update.fetch.inc b/core/modules/update/update.fetch.inc index 7b71edb..6334184 100644 --- a/core/modules/update/update.fetch.inc +++ b/core/modules/update/update.fetch.inc @@ -78,11 +78,11 @@ function _update_cron_notify() { module_load_install('update'); $status = update_requirements('runtime'); $params = array(); - $notify_all = ($update_config->get('notification.threshold') == 'all'); + $notify_all = ($update_config->get('notification.threshold') === 'all'); foreach (array('core', 'contrib') as $report_type) { $type = 'update_' . $report_type; if (isset($status[$type]['severity']) - && ($status[$type]['severity'] == REQUIREMENT_ERROR || ($notify_all && $status[$type]['reason'] == UPDATE_NOT_CURRENT))) { + && ($status[$type]['severity'] === REQUIREMENT_ERROR || ($notify_all && $status[$type]['reason'] === UPDATE_NOT_CURRENT))) { $params[$report_type] = $status[$type]['reason']; } } diff --git a/core/modules/update/update.install b/core/modules/update/update.install index 7997ec8..6ba3624 100644 --- a/core/modules/update/update.install +++ b/core/modules/update/update.install @@ -27,7 +27,7 @@ */ function update_requirements($phase) { $requirements = array(); - if ($phase == 'runtime') { + if ($phase === 'runtime') { if ($available = update_get_available(FALSE)) { module_load_include('inc', 'update', 'update.compare'); $data = update_calculate_project_data($available); @@ -96,14 +96,14 @@ function update_uninstall() { */ function _update_requirement_check($project, $type) { $requirement = array(); - if ($type == 'core') { + if ($type === 'core') { $requirement['title'] = t('Drupal core update status'); } else { $requirement['title'] = t('Module and theme update status'); } $status = $project['status']; - if ($status != UPDATE_CURRENT) { + if ($status !== UPDATE_CURRENT) { $requirement['reason'] = $status; $requirement['description'] = _update_message_text($type, $status, TRUE); $requirement['severity'] = REQUIREMENT_ERROR; @@ -131,7 +131,7 @@ function _update_requirement_check($project, $type) { default: $requirement_label = t('Up to date'); } - if ($status != UPDATE_CURRENT && $type == 'core' && isset($project['recommended'])) { + if ($status !== UPDATE_CURRENT && $type === 'core' && isset($project['recommended'])) { $requirement_label .= ' ' . t('(version @version available)', array('@version' => $project['recommended'])); } $requirement['value'] = l($requirement_label, update_manager_access() ? 'admin/reports/updates/update' : 'admin/reports/updates'); diff --git a/core/modules/update/update.manager.inc b/core/modules/update/update.manager.inc index 1faf7fd..164f050 100644 --- a/core/modules/update/update.manager.inc +++ b/core/modules/update/update.manager.inc @@ -98,7 +98,7 @@ function _update_manager_check_backends(&$form, $operation) { $available_backends = drupal_get_filetransfer_info(); if (empty($available_backends)) { - if ($operation == 'update') { + if ($operation === 'update') { $form['available_backends']['#markup'] = t('Your server does not support updating modules and themes from this interface. Instead, update modules and themes by uploading the new versions directly to the server, as described in the handbook.', array('@handbook_url' => 'http://drupal.org/getting-started/install-contrib')); } else { @@ -111,7 +111,7 @@ function _update_manager_check_backends(&$form, $operation) { foreach ($available_backends as $backend) { $backend_names[] = $backend['title']; } - if ($operation == 'update') { + if ($operation === 'update') { $form['available_backends']['#markup'] = format_plural( count($available_backends), 'Updating modules and themes requires @backends access to your server. See the handbook for other update methods.', diff --git a/core/modules/update/update.module b/core/modules/update/update.module index 6529a48..2e7329c 100644 --- a/core/modules/update/update.module +++ b/core/modules/update/update.module @@ -132,10 +132,10 @@ function update_page_build() { $type = 'update_' . $report_type; if (!empty($verbose)) { if (isset($status[$type]['severity'])) { - if ($status[$type]['severity'] == REQUIREMENT_ERROR) { + if ($status[$type]['severity'] === REQUIREMENT_ERROR) { drupal_set_message($status[$type]['description'], 'error'); } - elseif ($status[$type]['severity'] == REQUIREMENT_WARNING) { + elseif ($status[$type]['severity'] === REQUIREMENT_WARNING) { drupal_set_message($status[$type]['description'], 'warning'); } } @@ -337,7 +337,7 @@ function update_get_available($refresh = FALSE) { // If we think this project needs to fetch, actually create the task now // and remember that we think we're missing some data. - if (!empty($available[$key]['fetch_status']) && $available[$key]['fetch_status'] == UPDATE_FETCH_PENDING) { + if (!empty($available[$key]['fetch_status']) && $available[$key]['fetch_status'] === UPDATE_FETCH_PENDING) { \Drupal::service('update.processor')->createFetchTask($project); $needs_refresh = TRUE; } @@ -445,7 +445,7 @@ function update_mail($key, &$message, $params) { $message['body'][] = t('You can automatically install your missing updates using the Update manager:', array(), array('langcode' => $langcode)) . "\n" . url('admin/reports/updates/update', array('absolute' => TRUE, 'language' => $language)); } $settings_url = url('admin/reports/updates/settings', array('absolute' => TRUE)); - if (\Drupal::config('update.settings')->get('notification.threshold') == 'all') { + if (\Drupal::config('update.settings')->get('notification.threshold') === 'all') { $message['body'][] = t('Your site is currently configured to send these emails when any updates are available. To get notified only for security updates, !url.', array('!url' => $settings_url)); } else { @@ -478,7 +478,7 @@ function _update_message_text($msg_type, $msg_reason, $report_link = FALSE, $lan $text = ''; switch ($msg_reason) { case UPDATE_NOT_SECURE: - if ($msg_type == 'core') { + if ($msg_type === 'core') { $text = t('There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately!', array(), array('langcode' => $langcode)); } else { @@ -487,7 +487,7 @@ function _update_message_text($msg_type, $msg_reason, $report_link = FALSE, $lan break; case UPDATE_REVOKED: - if ($msg_type == 'core') { + if ($msg_type === 'core') { $text = t('Your version of Drupal has been revoked and is no longer available for download. Upgrading is strongly recommended!', array(), array('langcode' => $langcode)); } else { @@ -496,7 +496,7 @@ function _update_message_text($msg_type, $msg_reason, $report_link = FALSE, $lan break; case UPDATE_NOT_SUPPORTED: - if ($msg_type == 'core') { + if ($msg_type === 'core') { $text = t('Your version of Drupal is no longer supported. Upgrading is strongly recommended!', array(), array('langcode' => $langcode)); } else { @@ -505,7 +505,7 @@ function _update_message_text($msg_type, $msg_reason, $report_link = FALSE, $lan break; case UPDATE_NOT_CURRENT: - if ($msg_type == 'core') { + if ($msg_type === 'core') { $text = t('There are updates available for your version of Drupal. To ensure the proper functioning of your site, you should update as soon as possible.', array(), array('langcode' => $langcode)); } else { @@ -517,7 +517,7 @@ function _update_message_text($msg_type, $msg_reason, $report_link = FALSE, $lan case UPDATE_NOT_CHECKED: case UPDATE_NOT_FETCHED: case UPDATE_FETCH_PENDING: - if ($msg_type == 'core') { + if ($msg_type === 'core') { $text = t('There was a problem checking available updates for Drupal.', array('@update-report' => url('admin/reports/updates')), array('langcode' => $langcode)); } else { @@ -621,7 +621,7 @@ function update_verify_update_archive($project, $archive_file, $directory) { $info = \Drupal::service('info_parser')->parse($file->uri); // If the module or theme is incompatible with Drupal core, set an error. - if (empty($info['core']) || $info['core'] != \Drupal::CORE_COMPATIBILITY) { + if (empty($info['core']) || $info['core'] !== \Drupal::CORE_COMPATIBILITY) { $incompatible[] = !empty($info['name']) ? $info['name'] : t('Unknown'); } else { diff --git a/core/modules/update/update.report.inc b/core/modules/update/update.report.inc index ad396c8..063ba99 100644 --- a/core/modules/update/update.report.inc +++ b/core/modules/update/update.report.inc @@ -138,7 +138,7 @@ function template_preprocess_update_project_status(&$variables) { $variables['url'] = (isset($project['link'])) ? url($project['link']) : NULL; $variables['install_type'] = $project['install_type']; - if ($project['install_type'] == 'dev' && !empty($project['datestamp'])) { + if ($project['install_type'] === 'dev' && !empty($project['datestamp'])) { $variables['datestamp'] = format_date($project['datestamp'], 'custom', 'Y-M-d'); } @@ -148,14 +148,14 @@ function template_preprocess_update_project_status(&$variables) { $security_class = array(); $version_class = array(); if (isset($project['recommended'])) { - if ($project['status'] != UPDATE_CURRENT || $project['existing_version'] !== $project['recommended']) { + if ($project['status'] !== UPDATE_CURRENT || $project['existing_version'] !== $project['recommended']) { // First, figure out what to recommend. // If there's only 1 security update and it has the same version we're // recommending, give it the same CSS class as if it was recommended, // but don't print out a separate "Recommended" line for this project. if (!empty($project['security updates']) - && count($project['security updates']) == 1 + && count($project['security updates']) === 1 && $project['security updates'][0]['version'] === $project['recommended'] ) { $security_class[] = 'version-recommended'; @@ -167,7 +167,7 @@ function template_preprocess_update_project_status(&$variables) { // version and anything else for an extra visual hint. if ($project['recommended'] !== $project['latest_version'] || !empty($project['also']) - || ($project['install_type'] == 'dev' + || ($project['install_type'] === 'dev' && isset($project['dev_version']) && $project['latest_version'] !== $project['dev_version'] && $project['recommended'] !== $project['dev_version']) @@ -206,8 +206,8 @@ function template_preprocess_update_project_status(&$variables) { '#attributes' => array('class' => array('version-latest')), ); } - if ($project['install_type'] == 'dev' - && $project['status'] != UPDATE_CURRENT + if ($project['install_type'] === 'dev' + && $project['status'] !== UPDATE_CURRENT && isset($project['dev_version']) && $project['recommended'] !== $project['dev_version']) { $versions_inner[] = array( diff --git a/core/modules/user/src/Access/RegisterAccessCheck.php b/core/modules/user/src/Access/RegisterAccessCheck.php index 0f0a3f5..c217097 100644 --- a/core/modules/user/src/Access/RegisterAccessCheck.php +++ b/core/modules/user/src/Access/RegisterAccessCheck.php @@ -27,6 +27,7 @@ class RegisterAccessCheck implements AccessInterface { */ public function access(AccountInterface $account) { // @todo cacheable per role once https://www.drupal.org/node/2040135 lands. - return AccessResult::allowedIf($account->isAnonymous() && \Drupal::config('user.settings')->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY)->setCacheable(FALSE); + return AccessResult::allowedIf($account->isAnonymous() && \Drupal::config('user.settings')->get('register') !== USER_REGISTER_ADMINISTRATORS_ONLY)->setCacheable(FALSE); } + } diff --git a/core/modules/user/src/AccountForm.php b/core/modules/user/src/AccountForm.php index ba11c0e..d35bd49 100644 --- a/core/modules/user/src/AccountForm.php +++ b/core/modules/user/src/AccountForm.php @@ -108,7 +108,7 @@ public function form(array $form, FormStateInterface $form_state) { 'spellcheck' => 'false', ), '#default_value' => (!$register ? $account->getUsername() : ''), - '#access' => ($register || ($user->id() == $account->id() && $user->hasPermission('change own username')) || $admin), + '#access' => ($register || ($user->id() === $account->id() && $user->hasPermission('change own username')) || $admin), ); // Display password field only for existing users or when user is allowed to @@ -122,7 +122,7 @@ public function form(array $form, FormStateInterface $form_state) { // To skip the current password field, the user must have logged in via a // one-time link and have the token in the URL. - $pass_reset = isset($_SESSION['pass_reset_' . $account->id()]) && (\Drupal::request()->query->get('pass-reset-token') == $_SESSION['pass_reset_' . $account->id()]); + $pass_reset = isset($_SESSION['pass_reset_' . $account->id()]) && (\Drupal::request()->query->get('pass-reset-token') === $_SESSION['pass_reset_' . $account->id()]); $protected_values = array(); $current_pass_description = ''; @@ -137,7 +137,7 @@ public function form(array $form, FormStateInterface $form_state) { } // The user must enter their current password to change to a new one. - if ($user->id() == $account->id()) { + if ($user->id() === $account->id()) { $form['account']['current_pass_required_values'] = array( '#type' => 'value', '#value' => $protected_values, @@ -171,7 +171,7 @@ public function form(array $form, FormStateInterface $form_state) { // When not building the user registration form, prevent web browsers from // autofilling/prefilling the email, username, and password fields. - if ($this->getOperation() != 'register') { + if ($this->getOperation() !== 'register') { foreach (array('mail', 'name', 'pass') as $key) { if (isset($form['account'][$key])) { $form['account'][$key]['#attributes']['autocomplete'] = 'off'; @@ -183,7 +183,7 @@ public function form(array $form, FormStateInterface $form_state) { $status = $account->isActive(); } else { - $status = $register ? $config->get('register') == USER_REGISTER_VISITORS : $account->isActive(); + $status = $register ? $config->get('register') === USER_REGISTER_VISITORS : $account->isActive(); } $form['account']['status'] = array( diff --git a/core/modules/user/src/AccountSettingsForm.php b/core/modules/user/src/AccountSettingsForm.php index c03d17f..2ebf6eb 100644 --- a/core/modules/user/src/AccountSettingsForm.php +++ b/core/modules/user/src/AccountSettingsForm.php @@ -188,7 +188,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['email_admin_created'] = array( '#type' => 'details', '#title' => $this->t('Welcome (new user created by administrator)'), - '#open' => $config->get('register') == USER_REGISTER_ADMINISTRATORS_ONLY, + '#open' => $config->get('register') === USER_REGISTER_ADMINISTRATORS_ONLY, '#description' => $this->t('Edit the welcome email messages sent to new member accounts created by an administrator.') . ' ' . $email_token_help, '#group' => 'email', ); @@ -208,7 +208,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['email_pending_approval'] = array( '#type' => 'details', '#title' => $this->t('Welcome (awaiting approval)'), - '#open' => $config->get('register') == USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL, + '#open' => $config->get('register') === USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL, '#description' => $this->t('Edit the welcome email messages sent to new members upon registering, when administrative approval is required.') . ' ' . $email_token_help, '#group' => 'email', ); @@ -228,7 +228,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['email_pending_approval_admin'] = array( '#type' => 'details', '#title' => $this->t('Admin (user awaiting approval)'), - '#open' => $config->get('register') == USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL, + '#open' => $config->get('register') === USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL, '#description' => $this->t('Edit the email notifying the site administrator that there are new members awaiting administrative approval.') . ' ' . $email_token_help, '#group' => 'email', ); @@ -248,7 +248,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['email_no_approval_required'] = array( '#type' => 'details', '#title' => $this->t('Welcome (no approval required)'), - '#open' => $config->get('register') == USER_REGISTER_VISITORS, + '#open' => $config->get('register') === USER_REGISTER_VISITORS, '#description' => $this->t('Edit the welcome email messages sent to new members upon registering, when no administrator approval is required.') . ' ' . $email_token_help, '#group' => 'email', ); diff --git a/core/modules/user/src/Controller/UserController.php b/core/modules/user/src/Controller/UserController.php index be1b03d..2284933 100644 --- a/core/modules/user/src/Controller/UserController.php +++ b/core/modules/user/src/Controller/UserController.php @@ -80,7 +80,7 @@ public function resetPass($uid, $timestamp, $hash) { // isn't already logged in. if ($account->isAuthenticated()) { // The current user is already logged in. - if ($account->id() == $uid) { + if ($account->id() === $uid) { drupal_set_message($this->t('You are logged in as %user. Change your password.', array('%user' => $account->getUsername(), '!user_edit' => $this->url('entity.user.edit_form', array('user' => $account->id()))))); } // A different user is already logged in on the computer. diff --git a/core/modules/user/src/Entity/User.php b/core/modules/user/src/Entity/User.php index eb46586..9598a40 100644 --- a/core/modules/user/src/Entity/User.php +++ b/core/modules/user/src/Entity/User.php @@ -88,7 +88,7 @@ public function preSave(EntityStorageInterface $storage) { parent::preSave($storage); // Update the user password if it has changed. - if ($this->isNew() || ($this->pass->value && $this->pass->value != $this->original->pass->value)) { + if ($this->isNew() || ($this->pass->value && $this->pass->value !== $this->original->pass->value)) { // Allow alternate password hashing schemes. $this->pass->value = \Drupal::service('password')->hash(trim($this->pass->value)); // Abort if the hashing failed and returned FALSE. @@ -123,28 +123,28 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) { $session_manager = \Drupal::service('session_manager'); // If the password has been changed, delete all open sessions for the // user and recreate the current one. - if ($this->pass->value != $this->original->pass->value) { + if ($this->pass->value !== $this->original->pass->value) { $session_manager->delete($this->id()); - if ($this->id() == \Drupal::currentUser()->id()) { + if ($this->id() === \Drupal::currentUser()->id()) { $session_manager->regenerate(); } } // Update user roles if changed. - if ($this->getRoles() != $this->original->getRoles()) { + if ($this->getRoles() !== $this->original->getRoles()) { $storage->deleteUserRoles(array($this->id())); $storage->saveRoles($this); } // If the user was blocked, delete the user's sessions to force a logout. - if ($this->original->status->value != $this->status->value && $this->status->value == 0) { + if ($this->original->status->value !== $this->status->value && $this->status->value === 0) { $session_manager->delete($this->id()); } // Send emails after we have the new user object. - if ($this->status->value != $this->original->status->value) { + if ($this->status->value !== $this->original->status->value) { // The user's status is changing; conditionally send notification email. - $op = $this->status->value == 1 ? 'status_activated' : 'status_blocked'; + $op = $this->status->value === 1 ? 'status_activated' : 'status_blocked'; _user_mail_notify($op, $this); } } @@ -333,14 +333,14 @@ public function setLastLoginTime($timestamp) { * {@inheritdoc} */ public function isActive() { - return $this->get('status')->value == 1; + return $this->get('status')->value === 1; } /** * {@inheritdoc} */ public function isBlocked() { - return $this->get('status')->value == 0; + return $this->get('status')->value === 0; } /** @@ -411,7 +411,7 @@ public function isAuthenticated() { * {@inheritdoc} */ public function isAnonymous() { - return $this->id() == 0; + return $this->id() === 0; } /** diff --git a/core/modules/user/src/EventSubscriber/MaintenanceModeSubscriber.php b/core/modules/user/src/EventSubscriber/MaintenanceModeSubscriber.php index f6aee69..d08a70b 100644 --- a/core/modules/user/src/EventSubscriber/MaintenanceModeSubscriber.php +++ b/core/modules/user/src/EventSubscriber/MaintenanceModeSubscriber.php @@ -66,19 +66,19 @@ public function onKernelRequestMaintenance(GetResponseEvent $event) { return; } - if ($this->account->isAnonymous() && $path == 'user') { + if ($this->account->isAnonymous() && $path === 'user') { // Forward anonymous user to login page. $event->setResponse(new RedirectResponse(url('user/login', array('absolute' => TRUE)))); return; } } if ($this->account->isAuthenticated()) { - if ($path == 'user/login') { + if ($path === 'user/login') { // If user is logged in, redirect to 'user' instead of giving 403. $event->setResponse(new RedirectResponse(url('user', array('absolute' => TRUE)))); return; } - if ($path == 'user/register') { + if ($path === 'user/register') { // Authenticated user should be redirected to user edit page. $event->setResponse(new RedirectResponse(url('user/' . $this->account->id() . '/edit', array('absolute' => TRUE)))); return; diff --git a/core/modules/user/src/Form/UserCancelForm.php b/core/modules/user/src/Form/UserCancelForm.php index 59ccf3a..b92297a 100644 --- a/core/modules/user/src/Form/UserCancelForm.php +++ b/core/modules/user/src/Form/UserCancelForm.php @@ -33,7 +33,7 @@ class UserCancelForm extends ContentEntityConfirmFormBase { * {@inheritdoc} */ public function getQuestion() { - if ($this->entity->id() == $this->currentUser()->id()) { + if ($this->entity->id() === $this->currentUser()->id()) { return $this->t('Are you sure you want to cancel your account?'); } return $this->t('Are you sure you want to cancel the account %name?', array('%name' => $this->entity->label())); @@ -81,7 +81,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $admin_access = $user->hasPermission('administer users'); $form['user_cancel_method'] = array( '#type' => 'radios', - '#title' => ($this->entity->id() == $user->id() ? $this->t('When cancelling your account') : $this->t('When cancelling the account')), + '#title' => ($this->entity->id() === $user->id() ? $this->t('When cancelling your account') : $this->t('When cancelling the account')), '#access' => $admin_access || $user->hasPermission('select account cancellation method'), ); $form['user_cancel_method'] += $this->cancelMethods; @@ -89,7 +89,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { // Allow user administrators to skip the account cancellation confirmation // mail (by default), as long as they do not attempt to cancel their own // account. - $override_access = $admin_access && ($this->entity->id() != $user->id()); + $override_access = $admin_access && ($this->entity->id() !== $user->id()); $form['user_cancel_confirm'] = array( '#type' => 'checkbox', '#title' => $this->t('Require email confirmation to cancel account'), @@ -122,7 +122,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // Cancel account immediately, if the current user has administrative // privileges, no confirmation mail shall be sent, and the user does not // attempt to cancel the own account. - if ($this->currentUser()->hasPermission('administer users') && $form_state->isValueEmpty('user_cancel_confirm') && $this->entity->id() != $this->currentUser()->id()) { + if ($this->currentUser()->hasPermission('administer users') && $form_state->isValueEmpty('user_cancel_confirm') && $this->entity->id() !== $this->currentUser()->id()) { user_cancel($form_state->getValues(), $this->entity->id(), $form_state->getValue('user_cancel_method')); $form_state->setRedirect('user.admin_account'); diff --git a/core/modules/user/src/Form/UserLoginForm.php b/core/modules/user/src/Form/UserLoginForm.php index e1275a4..f922bd4 100644 --- a/core/modules/user/src/Form/UserLoginForm.php +++ b/core/modules/user/src/Form/UserLoginForm.php @@ -206,7 +206,7 @@ public function validateFinal(array &$form, FormStateInterface $form_state) { } if ($flood_control_triggered = $form_state->get('flood_control_triggered')) { - if ($flood_control_triggered == 'user') { + if ($flood_control_triggered === 'user') { $form_state->setErrorByName('name', format_plural($flood_config->get('user_limit'), 'Sorry, there has been more than one failed login attempt for this account. It is temporarily blocked. Try again later or request a new password.', 'Sorry, there have been more than @count failed login attempts for this account. It is temporarily blocked. Try again later or request a new password.', array('@url' => url('user/password')))); } else { diff --git a/core/modules/user/src/Form/UserMultipleCancelConfirm.php b/core/modules/user/src/Form/UserMultipleCancelConfirm.php index 9bcfd7b..bdccb5b 100644 --- a/core/modules/user/src/Form/UserMultipleCancelConfirm.php +++ b/core/modules/user/src/Form/UserMultipleCancelConfirm.php @@ -127,7 +127,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { // Output a notice that user 1 cannot be canceled. if (isset($accounts[1])) { - $redirect = (count($accounts) == 1); + $redirect = (count($accounts) === 1); $message = $this->t('The user account %name cannot be canceled.', array('%name' => $accounts[1]->label())); drupal_set_message($message, $redirect ? 'error' : 'warning'); // If only user 1 was selected, redirect to the overview. @@ -181,7 +181,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { continue; } // Prevent user administrators from deleting themselves without confirmation. - if ($uid == $current_user_id) { + if ($uid === $current_user_id) { $admin_form_mock = array(); $admin_form_state = $form_state; $admin_form_state->unsetValue('user_cancel_confirm'); diff --git a/core/modules/user/src/PermissionHandler.php b/core/modules/user/src/PermissionHandler.php index 1cbe222..2562a60 100644 --- a/core/modules/user/src/PermissionHandler.php +++ b/core/modules/user/src/PermissionHandler.php @@ -199,7 +199,7 @@ protected function sortPermissions(array $all_permissions = array()) { $modules = $this->getModuleNames(); uasort($all_permissions, function (array $permission_a, array $permission_b) use ($modules) { - if ($modules[$permission_a['provider']] == $modules[$permission_b['provider']]) { + if ($modules[$permission_a['provider']] === $modules[$permission_b['provider']]) { return $permission_a['title'] > $permission_b['title']; } else { diff --git a/core/modules/user/src/Plugin/Block/UserLoginBlock.php b/core/modules/user/src/Plugin/Block/UserLoginBlock.php index 7b3727d..31e6625 100644 --- a/core/modules/user/src/Plugin/Block/UserLoginBlock.php +++ b/core/modules/user/src/Plugin/Block/UserLoginBlock.php @@ -43,7 +43,7 @@ public function build() { $form['#action'] = url(current_path(), array('query' => drupal_get_destination(), 'external' => FALSE)); // Build action links. $items = array(); - if (\Drupal::config('user.settings')->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY) { + if (\Drupal::config('user.settings')->get('register') !== USER_REGISTER_ADMINISTRATORS_ONLY) { $items['create_account'] = l(t('Create new account'), 'user/register', array( 'attributes' => array( 'title' => t('Create a new user account.'), diff --git a/core/modules/user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php b/core/modules/user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php index e30a0bf..4af3815 100644 --- a/core/modules/user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php +++ b/core/modules/user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php @@ -52,7 +52,7 @@ public function viewElements(FieldItemListInterface $items) { * {@inheritdoc} */ public static function isApplicable(FieldDefinitionInterface $field_definition) { - return $field_definition->getFieldStorageDefinition()->getSetting('target_type') == 'user'; + return $field_definition->getFieldStorageDefinition()->getSetting('target_type') === 'user'; } } diff --git a/core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUser.php b/core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUser.php index f2c99fe..0a7aa90 100644 --- a/core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUser.php +++ b/core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUser.php @@ -38,7 +38,7 @@ public function getLangcode(Request $request = NULL) { $preferred_langcode = $this->currentUser->getPreferredLangcode(); $default_langcode = $this->languageManager->getDefaultLanguage()->id; $languages = $this->languageManager->getLanguages(); - if (!empty($preferred_langcode) && $preferred_langcode != $default_langcode && isset($languages[$preferred_langcode])) { + if (!empty($preferred_langcode) && $preferred_langcode !== $default_langcode && isset($languages[$preferred_langcode])) { $langcode = $preferred_langcode; } } diff --git a/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraintValidator.php b/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraintValidator.php index 5b788ca..14a21ef 100644 --- a/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraintValidator.php +++ b/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraintValidator.php @@ -24,10 +24,10 @@ public function validate($items, Constraint $constraint) { return; } $name = $items->first()->value; - if (substr($name, 0, 1) == ' ') { + if (substr($name, 0, 1) === ' ') { $this->context->addViolation($constraint->spaceBeginMessage); } - if (substr($name, -1) == ' ') { + if (substr($name, -1) === ' ') { $this->context->addViolation($constraint->spaceEndMessage); } if (strpos($name, ' ') !== FALSE) { diff --git a/core/modules/user/src/Plugin/entity_reference/selection/UserSelection.php b/core/modules/user/src/Plugin/entity_reference/selection/UserSelection.php index 3820628..b6d1770 100644 --- a/core/modules/user/src/Plugin/entity_reference/selection/UserSelection.php +++ b/core/modules/user/src/Plugin/entity_reference/selection/UserSelection.php @@ -57,7 +57,7 @@ public static function settingsForm(FieldDefinitionInterface $field_definition) '#process' => array('_entity_reference_form_process_merge_parent'), ); - if ($selection_handler_settings['filter']['type'] == 'role') { + if ($selection_handler_settings['filter']['type'] === 'role') { // Merge in default values. $selection_handler_settings['filter'] += array( 'role' => NULL, @@ -135,7 +135,7 @@ public function entityQueryAlter(SelectInterface $query) { // Add the filter by role option. if (!empty($this->fieldDefinition->getSetting('handler_settings')['filter'])) { $filter_settings = $this->fieldDefinition->getSetting('handler_settings')['filter']; - if ($filter_settings['type'] == 'role') { + if ($filter_settings['type'] === 'role') { $tables = $query->getTables(); $base_table = $tables['base_table']['alias']; $query->join('users_roles', 'ur', $base_table . '.uid = ur.uid'); diff --git a/core/modules/user/src/Plugin/views/field/Mail.php b/core/modules/user/src/Plugin/views/field/Mail.php index ad26317..390dba5 100644 --- a/core/modules/user/src/Plugin/views/field/Mail.php +++ b/core/modules/user/src/Plugin/views/field/Mail.php @@ -45,7 +45,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { protected function renderLink($data, ResultRow $values) { parent::renderLink($data, $values); - if ($this->options['link_to_user'] == 'mailto') { + if ($this->options['link_to_user'] === 'mailto') { $this->options['alter']['make_link'] = TRUE; $this->options['alter']['path'] = "mailto:" . $data; } diff --git a/core/modules/user/src/Plugin/views/filter/Name.php b/core/modules/user/src/Plugin/views/filter/Name.php index 391f238..4f83c58 100644 --- a/core/modules/user/src/Plugin/views/filter/Name.php +++ b/core/modules/user/src/Plugin/views/filter/Name.php @@ -92,7 +92,7 @@ public function validateExposed(&$form, FormStateInterface $form_state) { $values = Tags::explode($input); - if (!$this->options['is_grouped'] || ($this->options['is_grouped'] && ($input != 'All'))) { + if (!$this->options['is_grouped'] || ($this->options['is_grouped'] && ($input !== 'All'))) { $uids = $this->validate_user_strings($form[$identifier], $form_state, $values); } else { @@ -114,7 +114,7 @@ function validate_user_strings(&$form, FormStateInterface $form_state, $values) $placeholders = array(); $args = array(); foreach ($values as $value) { - if (strtolower($value) == 'anonymous') { + if (strtolower($value) === 'anonymous') { $uids[] = 0; } else { diff --git a/core/modules/user/src/ProfileForm.php b/core/modules/user/src/ProfileForm.php index e119693..ff35129 100644 --- a/core/modules/user/src/ProfileForm.php +++ b/core/modules/user/src/ProfileForm.php @@ -38,7 +38,7 @@ protected function actions(array $form, FormStateInterface $form_state) { $element['delete']['#type'] = 'submit'; $element['delete']['#value'] = $this->t('Cancel account'); $element['delete']['#submit'] = array('::editCancelSubmit'); - $element['delete']['#access'] = $account->id() > 1 && (($account->id() == $user->id() && $user->hasPermission('cancel account')) || $user->hasPermission('administer users')); + $element['delete']['#access'] = $account->id() > 1 && (($account->id() === $user->id() && $user->hasPermission('cancel account')) || $user->hasPermission('administer users')); return $element; } diff --git a/core/modules/user/src/RoleAccessControlHandler.php b/core/modules/user/src/RoleAccessControlHandler.php index 52f590d..20fa30a 100644 --- a/core/modules/user/src/RoleAccessControlHandler.php +++ b/core/modules/user/src/RoleAccessControlHandler.php @@ -25,7 +25,7 @@ class RoleAccessControlHandler extends EntityAccessControlHandler { protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { switch ($operation) { case 'delete': - if ($entity->id() == DRUPAL_ANONYMOUS_RID || $entity->id() == DRUPAL_AUTHENTICATED_RID) { + if ($entity->id() === DRUPAL_ANONYMOUS_RID || $entity->id() === DRUPAL_AUTHENTICATED_RID) { return AccessResult::forbidden(); } diff --git a/core/modules/user/src/RoleForm.php b/core/modules/user/src/RoleForm.php index 55e0ccd..8e2a4ca 100644 --- a/core/modules/user/src/RoleForm.php +++ b/core/modules/user/src/RoleForm.php @@ -60,7 +60,7 @@ public function save(array $form, FormStateInterface $form_state) { $status = $entity->save(); $edit_link = \Drupal::linkGenerator()->generateFromUrl($this->t('Edit'), $this->entity->urlInfo()); - if ($status == SAVED_UPDATED) { + if ($status === SAVED_UPDATED) { drupal_set_message($this->t('Role %label has been updated.', array('%label' => $entity->label()))); $this->logger('user')->notice('Role %label has been updated.', array('%label' => $entity->label(), 'link' => $edit_link)); } diff --git a/core/modules/user/src/TempStore.php b/core/modules/user/src/TempStore.php index da87691..d9f0def 100644 --- a/core/modules/user/src/TempStore.php +++ b/core/modules/user/src/TempStore.php @@ -116,7 +116,7 @@ public function get($key) { * The data associated with the key, or NULL if the key does not exist. */ public function getIfOwner($key) { - if (($object = $this->storage->get($key)) && ($object->owner == $this->owner)) { + if (($object = $this->storage->get($key)) && ($object->owner === $this->owner)) { return $object->data; } } @@ -161,7 +161,7 @@ public function setIfOwner($key, $value) { return TRUE; } - if (($object = $this->storage->get($key)) && ($object->owner == $this->owner)) { + if (($object = $this->storage->get($key)) && ($object->owner === $this->owner)) { $this->set($key, $value); return TRUE; } @@ -253,7 +253,7 @@ public function deleteIfOwner($key) { if (!$object = $this->storage->get($key)) { return TRUE; } - elseif ($object->owner == $this->owner) { + elseif ($object->owner === $this->owner) { $this->delete($key); return TRUE; } diff --git a/core/modules/user/src/Tests/UserAccountFormFieldsTest.php b/core/modules/user/src/Tests/UserAccountFormFieldsTest.php index df01adc..d2b4075 100644 --- a/core/modules/user/src/Tests/UserAccountFormFieldsTest.php +++ b/core/modules/user/src/Tests/UserAccountFormFieldsTest.php @@ -132,7 +132,7 @@ protected function buildAccountForm($operation) { // @see HtmlEntityFormController::getFormObject() $entity_type = 'user'; $fields = array(); - if ($operation != 'register') { + if ($operation !== 'register') { $fields['uid'] = 2; } $entity = $this->container->get('entity.manager') diff --git a/core/modules/user/src/Tests/UserAdminListingTest.php b/core/modules/user/src/Tests/UserAdminListingTest.php index 65e9ef3..e5fe02d 100644 --- a/core/modules/user/src/Tests/UserAdminListingTest.php +++ b/core/modules/user/src/Tests/UserAdminListingTest.php @@ -84,7 +84,7 @@ public function testUserListing() { $this->assertFalse(array_diff(array_keys($result_accounts), array_keys($accounts)), 'Ensure all accounts are listed.'); foreach ($result_accounts as $name => $values) { - $this->assertEqual($values['status'] == t('active'), $accounts[$name]->status->value, 'Ensure the status is displayed properly.'); + $this->assertEqual($values['status'] === t('active'), $accounts[$name]->status->value, 'Ensure the status is displayed properly.'); } $expected_roles = array('custom_role_1', 'custom_role_2'); diff --git a/core/modules/user/src/Tests/UserCancelTest.php b/core/modules/user/src/Tests/UserCancelTest.php index 714f8fb..be91a00 100644 --- a/core/modules/user/src/Tests/UserCancelTest.php +++ b/core/modules/user/src/Tests/UserCancelTest.php @@ -59,7 +59,7 @@ function testUserCancelWithoutPermission() { // Confirm user's content has not been altered. $test_node = node_load($node->id(), TRUE); - $this->assertTrue(($test_node->getOwnerId() == $account->id() && $test_node->isPublished()), 'Node of the user has not been altered.'); + $this->assertTrue(($test_node->getOwnerId() === $account->id() && $test_node->isPublished()), 'Node of the user has not been altered.'); } /** @@ -140,7 +140,7 @@ function testUserCancelInvalid() { // Confirm user's content has not been altered. $test_node = node_load($node->id(), TRUE); - $this->assertTrue(($test_node->getOwnerId() == $account->id() && $test_node->isPublished()), 'Node of the user has not been altered.'); + $this->assertTrue(($test_node->getOwnerId() === $account->id() && $test_node->isPublished()), 'Node of the user has not been altered.'); } /** @@ -284,11 +284,11 @@ function testUserAnonymize() { // Confirm that user's content has been attributed to anonymous user. $test_node = node_load($node->id(), TRUE); - $this->assertTrue(($test_node->getOwnerId() == 0 && $test_node->isPublished()), 'Node of the user has been attributed to anonymous user.'); + $this->assertTrue(($test_node->getOwnerId() === 0 && $test_node->isPublished()), 'Node of the user has been attributed to anonymous user.'); $test_node = node_revision_load($revision, TRUE); - $this->assertTrue(($test_node->getRevisionAuthor()->id() == 0 && $test_node->isPublished()), 'Node revision of the user has been attributed to anonymous user.'); + $this->assertTrue(($test_node->getRevisionAuthor()->id() === 0 && $test_node->isPublished()), 'Node revision of the user has been attributed to anonymous user.'); $test_node = node_load($revision_node->id(), TRUE); - $this->assertTrue(($test_node->getOwnerId() != 0 && $test_node->isPublished()), "Current revision of the user's node was not attributed to anonymous user."); + $this->assertTrue(($test_node->getOwnerId() !== 0 && $test_node->isPublished()), "Current revision of the user's node was not attributed to anonymous user."); // Confirm that the confirmation message made it through to the end user. $this->assertRaw(t('%name has been deleted.', array('%name' => $account->getUsername())), "Confirmation message displayed to user."); diff --git a/core/modules/user/src/Tests/UserDeleteTest.php b/core/modules/user/src/Tests/UserDeleteTest.php index 747039e..1a639b3 100644 --- a/core/modules/user/src/Tests/UserDeleteTest.php +++ b/core/modules/user/src/Tests/UserDeleteTest.php @@ -49,7 +49,7 @@ function testUserDeleteMultiple() { ->countQuery() ->execute() ->fetchField(); - $this->assertTrue($roles_after_deletion == 0, 'Role assigments deleted along with users'); + $this->assertTrue($roles_after_deletion === 0, 'Role assigments deleted along with users'); // Test if the users are deleted, user_load() will return FALSE. $this->assertFalse(user_load($user_a->id()), format_string('User with id @uid deleted.', array('@uid' => $user_a->id()))); $this->assertFalse(user_load($user_b->id()), format_string('User with id @uid deleted.', array('@uid' => $user_b->id()))); diff --git a/core/modules/user/src/Tests/UserLoginTest.php b/core/modules/user/src/Tests/UserLoginTest.php index 15fd7ce..682a53b 100644 --- a/core/modules/user/src/Tests/UserLoginTest.php +++ b/core/modules/user/src/Tests/UserLoginTest.php @@ -155,7 +155,7 @@ function assertFailedLogin($account, $flood_trigger = NULL) { $this->drupalPostForm('user', $edit, t('Log in')); $this->assertNoFieldByXPath("//input[@name='pass' and @value!='']", NULL, 'Password value attribute is blank.'); if (isset($flood_trigger)) { - if ($flood_trigger == 'user') { + if ($flood_trigger === 'user') { $this->assertRaw(format_plural(\Drupal::config('user.flood')->get('user_limit'), 'Sorry, there has been more than one failed login attempt for this account. It is temporarily blocked. Try again later or request a new password.', 'Sorry, there have been more than @count failed login attempts for this account. It is temporarily blocked. Try again later or request a new password.', array('@url' => url('user/password')))); } else { diff --git a/core/modules/user/src/Tests/UserRegistrationTest.php b/core/modules/user/src/Tests/UserRegistrationTest.php index cc025c8..53f1969 100644 --- a/core/modules/user/src/Tests/UserRegistrationTest.php +++ b/core/modules/user/src/Tests/UserRegistrationTest.php @@ -180,7 +180,7 @@ function testRegistrationDefaultValues() { $this->assertEqual($new_user->getEmail(), $mail, 'Email address matches.'); $this->assertEqual($new_user->getSignature(), '', 'Correct signature field.'); $this->assertTrue(($new_user->getCreatedTime() > REQUEST_TIME - 20 ), 'Correct creation time.'); - $this->assertEqual($new_user->isActive(), $config_user_settings->get('register') == USER_REGISTER_VISITORS ? 1 : 0, 'Correct status field.'); + $this->assertEqual($new_user->isActive(), $config_user_settings->get('register') === USER_REGISTER_VISITORS ? 1 : 0, 'Correct status field.'); $this->assertEqual($new_user->getTimezone(), $config_system_date->get('timezone.default'), 'Correct time zone field.'); $this->assertEqual($new_user->langcode->value, \Drupal::languageManager()->getDefaultLanguage()->id, 'Correct language field.'); $this->assertEqual($new_user->preferred_langcode->value, \Drupal::languageManager()->getDefaultLanguage()->id, 'Correct preferred language field.'); @@ -255,7 +255,7 @@ function testRegistrationWithUserFields() { $value = rand(1, 255); $edit = array(); $edit['test_user_field[0][value]'] = $value; - if ($js == 'js') { + if ($js === 'js') { $this->drupalPostAjaxForm(NULL, $edit, 'test_user_field_add_more'); $this->drupalPostAjaxForm(NULL, $edit, 'test_user_field_add_more'); } diff --git a/core/modules/user/src/UserAccessControlHandler.php b/core/modules/user/src/UserAccessControlHandler.php index aab5f3b..912625f 100644 --- a/core/modules/user/src/UserAccessControlHandler.php +++ b/core/modules/user/src/UserAccessControlHandler.php @@ -42,18 +42,18 @@ protected function checkAccess(EntityInterface $entity, $operation, $langcode, A return AccessResult::allowed()->cachePerRole()->cacheUntilEntityChanges($entity); } // Users can view own profiles at all times. - else if ($account->id() == $entity->id()) { + else if ($account->id() === $entity->id()) { return AccessResult::allowed()->cachePerUser(); } break; case 'update': // Users can always edit their own account. - return AccessResult::allowedIf($account->id() == $entity->id())->cachePerUser(); + return AccessResult::allowedIf($account->id() === $entity->id())->cachePerUser(); case 'delete': // Users with 'cancel account' permission can cancel their own account. - return AccessResult::allowedIf($account->id() == $entity->id() && $account->hasPermission('cancel account'))->cachePerRole()->cachePerUser(); + return AccessResult::allowedIf($account->id() === $entity->id() && $account->hasPermission('cancel account'))->cachePerRole()->cachePerUser(); } // No opinion. diff --git a/core/modules/user/src/UserStorage.php b/core/modules/user/src/UserStorage.php index 9aa844e..4b50a2d 100644 --- a/core/modules/user/src/UserStorage.php +++ b/core/modules/user/src/UserStorage.php @@ -102,7 +102,7 @@ public function save(EntityInterface $entity) { */ protected function isColumnSerial($table_name, $schema_name) { // User storage does not use a serial column for the user id. - return $table_name == $this->revisionTable && $schema_name == $this->revisionKey; + return $table_name === $this->revisionTable && $schema_name === $this->revisionKey; } /** diff --git a/core/modules/user/user.module b/core/modules/user/user.module index eb3d5ae..3a5a21e 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -384,7 +384,7 @@ function user_password($length = 10) { * for the given role. */ function user_role_permissions(array $roles) { - if (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update') { + if (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE === 'update') { return _user_role_permissions_update($roles); } $entities = entity_load_multiple('user_role', $roles); @@ -504,7 +504,7 @@ function user_validate_current_pass(&$form, FormStateInterface $form_state) { // form values like password_confirm that have their own validation // that prevent them from being empty if they are changed. $current_value = $account->hasField($key) ? $account->get($key)->value : $account->$key; - if ((strlen(trim($form_state->getValue($key))) > 0) && ($form_state->getValue($key) != $current_value)) { + if ((strlen(trim($form_state->getValue($key))) > 0) && ($form_state->getValue($key) !== $current_value)) { $current_pass_failed = $form_state->isValueEmpty('current_pass') || !\Drupal::service('password')->check($form_state->getValue('current_pass'), $account); if ($current_pass_failed) { $form_state->setErrorByName('current_pass', t("Your current password is missing or incorrect; it's required to change the %name.", array('%name' => $name))); @@ -520,7 +520,7 @@ function user_validate_current_pass(&$form, FormStateInterface $form_state) { * Implements hook_preprocess_HOOK() for block templates. */ function user_preprocess_block(&$variables) { - if ($variables['configuration']['provider'] == 'user') { + if ($variables['configuration']['provider'] === 'user') { switch ($variables['elements']['#plugin_id']) { case 'user_login_block': $variables['attributes']['role'] = 'form'; @@ -637,7 +637,7 @@ function template_preprocess_username(&$variables) { function user_menu_breadcrumb_alter(&$active_trail, $item) { // Remove "My account" from the breadcrumb when $item is descendant-or-self // of system path user/%. - if (isset($active_trail[1]['module']) && $active_trail[1]['machine_name'] == 'user.page' && strpos($item['path'], 'user/%') === 0) { + if (isset($active_trail[1]['module']) && $active_trail[1]['machine_name'] === 'user.page' && strpos($item['path'], 'user/%') === 0) { array_splice($active_trail, 1, 1); } } @@ -807,7 +807,7 @@ function user_cancel($edit, $uid, $method) { // which invokes hook_ENTITY_TYPE_predelete() and hook_ENTITY_TYPE_delete() // for the user entity. Modules should use those hooks to respond to the // account deletion. - if ($method != 'user_cancel_delete') { + if ($method !== 'user_cancel_delete') { // Allow modules to add further sets to this batch. \Drupal::moduleHandler()->invokeAll('user_cancel', array($edit, $account, $method)); } @@ -821,7 +821,7 @@ function user_cancel($edit, $uid, $method) { ); // After cancelling account, ensure that user is logged out. - if ($account->id() == \Drupal::currentUser()->id()) { + if ($account->id() === \Drupal::currentUser()->id()) { // Batch API stores data in the session, so use the finished operation to // manipulate the current user's session id. $batch['finished'] = '_user_cancel_session_regenerate'; @@ -875,7 +875,7 @@ function _user_cancel($edit, $account, $method) { // their session though, as we might have information in it, and we can't // regenerate it because batch API uses the session ID, we will regenerate it // in _user_cancel_session_regenerate(). - if ($account->id() == $user->id()) { + if ($account->id() === $user->id()) { $user = new AnonymousUserSession(); } } @@ -1335,7 +1335,7 @@ function user_role_revoke_permissions($rid, array $permissions = array()) { function _user_mail_notify($op, $account, $langcode = NULL) { // By default, we always notify except for canceled and blocked. $notify = \Drupal::config('user.settings')->get('notify.' . $op); - if ($notify || ($op != 'status_canceled' && $op != 'status_blocked')) { + if ($notify || ($op !== 'status_canceled' && $op !== 'status_blocked')) { $params['account'] = $account; $langcode = $langcode ? $langcode : $account->getPreferredLangcode(); // Get the custom site notification email to use as the from email address @@ -1350,7 +1350,7 @@ function _user_mail_notify($op, $account, $langcode = NULL) { $site_mail = ini_get('sendmail_from'); } $mail = drupal_mail('user', $op, $account->getEmail(), $langcode, $params, $site_mail); - if ($op == 'register_pending_approval') { + if ($op === 'register_pending_approval') { // If a user registered requiring admin approval, notify the admin, too. // We use the site default language for this. drupal_mail('user', 'register_pending_approval_admin', $site_mail, \Drupal::languageManager()->getDefaultLanguage()->id, $params); diff --git a/core/modules/user/user.pages.inc b/core/modules/user/user.pages.inc index b548e3b..8d9c6df 100644 --- a/core/modules/user/user.pages.inc +++ b/core/modules/user/user.pages.inc @@ -49,7 +49,7 @@ function user_cancel_confirm($account, $timestamp = 0, $hashed_pass = '') { $account_data = \Drupal::service('user.data')->get('user', $account->id()); if (isset($account_data['cancel_method']) && !empty($timestamp) && !empty($hashed_pass)) { // Validate expiration and hashed password/login. - if ($timestamp <= $current && $current - $timestamp < $timeout && $account->id() && $timestamp >= $account->getLastLoginTime() && $hashed_pass == user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime())) { + if ($timestamp <= $current && $current - $timestamp < $timeout && $account->id() && $timestamp >= $account->getLastLoginTime() && $hashed_pass === user_pass_rehash($account->getPassword(), $timestamp, $account->getLastLoginTime())) { $edit = array( 'user_cancel_notify' => isset($account_data['cancel_notify']) ? $account_data['cancel_notify'] : \Drupal::config('user.settings')->get('notify.status_canceled'), ); diff --git a/core/modules/user/user.tokens.inc b/core/modules/user/user.tokens.inc index 51579be..61cf9ff 100644 --- a/core/modules/user/user.tokens.inc +++ b/core/modules/user/user.tokens.inc @@ -78,7 +78,7 @@ function user_tokens($type, $tokens, array $data = array(), array $options = arr $replacements = array(); - if ($type == 'user' && !empty($data['user'])) { + if ($type === 'user' && !empty($data['user'])) { $account = $data['user']; foreach ($tokens as $name => $original) { switch ($name) { @@ -126,7 +126,7 @@ function user_tokens($type, $tokens, array $data = array(), array $options = arr } } - if ($type == 'current-user') { + if ($type === 'current-user') { $account = user_load(\Drupal::currentUser()->id()); $replacements += $token_service->generate('user', $tokens, array('user' => $account), $options); } diff --git a/core/modules/views/src/Controller/ViewAjaxController.php b/core/modules/views/src/Controller/ViewAjaxController.php index 840d1f2..3872d91 100644 --- a/core/modules/views/src/Controller/ViewAjaxController.php +++ b/core/modules/views/src/Controller/ViewAjaxController.php @@ -116,7 +116,7 @@ public function ajaxView(Request $request) { // @see drupal_get_destination() $origin_destination = $path; $query = UrlHelper::buildQuery($request->query->all()); - if ($query != '') { + if ($query !== '') { $origin_destination .= '?' . $query; } $destination = &drupal_static('drupal_get_destination'); diff --git a/core/modules/views/src/DisplayBag.php b/core/modules/views/src/DisplayBag.php index a724745..415584d 100644 --- a/core/modules/views/src/DisplayBag.php +++ b/core/modules/views/src/DisplayBag.php @@ -96,7 +96,7 @@ protected function initializePlugin($display_id) { $this->pluginInstances[$display_id]->initDisplay($this->view, $display); // If this is not the default display handler, let it know which is since // it may well utilize some data from the default. - if ($display_id != 'default') { + if ($display_id !== 'default') { $this->pluginInstances[$display_id]->default_display = $this->pluginInstances['default']; } } diff --git a/core/modules/views/src/Entity/View.php b/core/modules/views/src/Entity/View.php index 1ad685a..5ef0eef 100644 --- a/core/modules/views/src/Entity/View.php +++ b/core/modules/views/src/Entity/View.php @@ -217,7 +217,7 @@ public function addDisplay($plugin_id = 'page', $title = NULL, $id = NULL) { protected function generateDisplayId($plugin_id) { // 'default' is singular and is unique, so just go with 'default' // for it. For all others, start counting. - if ($plugin_id == 'default') { + if ($plugin_id === 'default') { return 'default'; } // Initial ID. @@ -254,7 +254,7 @@ public function calculateDependencies() { // @todo Entity base tables are no longer registered in hook_schema(). Once // we automate the views data for entity types add the entity type // type provider as a dependency. See https://drupal.org/node/1740492. - if ($schema && $this->module != $schema['module']) { + if ($schema && $this->module !== $schema['module']) { $this->addDependency('module', $schema['module']); } @@ -375,7 +375,7 @@ public function mergeDefaultDisplaysOptions() { } // Sort the displays. uasort($displays, function ($display1, $display2) { - if ($display1['position'] != $display2['position']) { + if ($display1['position'] !== $display2['position']) { return $display1['position'] < $display2['position'] ? -1 : 1; } return 0; diff --git a/core/modules/views/src/EntityViewsData.php b/core/modules/views/src/EntityViewsData.php index b2859d0..cd65ab5 100644 --- a/core/modules/views/src/EntityViewsData.php +++ b/core/modules/views/src/EntityViewsData.php @@ -374,11 +374,11 @@ protected function mapSingleFieldViewsData($table, $data_type, $schema_field_nam */ protected function processViewsDataForLanguage($table, FieldDefinitionInterface $field_definition, array &$views_field) { // Apply special titles for the langcode field. - if ($field_definition->getName() == 'langcode') { - if ($table == $this->entityType->getDataTable() || $table == $this->entityType->getBaseTable()) { + if ($field_definition->getName() === 'langcode') { + if ($table === $this->entityType->getDataTable() || $table === $this->entityType->getBaseTable()) { $views_field['title'] = $this->t('Translation language'); } - if ($table == $this->entityType->getRevisionDataTable() || $table == $this->entityType->getRevisionTable()) { + if ($table === $this->entityType->getRevisionDataTable() || $table === $this->entityType->getRevisionTable()) { $views_field['title'] = $this->t('Original language'); } } @@ -418,7 +418,7 @@ protected function processViewsDataForEntityReference($table, FieldDefinitionInt } } - if ($field_definition->getName() == $this->entityType->getKey('bundle')) { + if ($field_definition->getName() === $this->entityType->getKey('bundle')) { // @todo Use the other bundle handlers, once // https://www.drupal.org/node/2322949 is in. $views_field['filter']['id'] = 'bundle'; diff --git a/core/modules/views/src/Form/ViewsForm.php b/core/modules/views/src/Form/ViewsForm.php index c1296b2..71f5075 100644 --- a/core/modules/views/src/Form/ViewsForm.php +++ b/core/modules/views/src/Form/ViewsForm.php @@ -137,7 +137,7 @@ public function buildForm(array $form, FormStateInterface $form_state, ViewExecu // Tell the preprocessor whether it should hide the header, footer, pager... $form['show_view_elements'] = array( '#type' => 'value', - '#value' => ($step == 'views_form_views_form') ? TRUE : FALSE, + '#value' => ($step === 'views_form_views_form') ? TRUE : FALSE, ); $form_object = $this->getFormObject($form_state); diff --git a/core/modules/views/src/ManyToOneHelper.php b/core/modules/views/src/ManyToOneHelper.php index 12bfc35..ad1232a 100644 --- a/core/modules/views/src/ManyToOneHelper.php +++ b/core/modules/views/src/ManyToOneHelper.php @@ -89,11 +89,11 @@ public function addTable($join = NULL, $alias = NULL) { // Cycle through the joins. This isn't as error-safe as the normal // ensurePath logic. Perhaps it should be. $r_join = clone $join; - while ($r_join->leftTable != $base_table) { + while ($r_join->leftTable !== $base_table) { $r_join = HandlerBase::getTableJoin($r_join->leftTable, $base_table); } // If we found that there are tables in between, add the relationship. - if ($r_join->table != $join->table) { + if ($r_join->table !== $join->table) { $relationship = $this->handler->query->addRelationship($this->handler->table . '_' . $r_join->table, $r_join, $r_join->table, $this->handler->relationship); } @@ -162,7 +162,7 @@ public function ensureMyTable() { // Case 1: Operator is an 'or' and we're not reducing duplicates. // We hence get the absolute simplest: $field = $this->handler->relationship . '_' . $this->handler->table . '.' . $this->handler->field; - if ($this->handler->operator == 'or' && empty($this->handler->options['reduce_duplicates'])) { + if ($this->handler->operator === 'or' && empty($this->handler->options['reduce_duplicates'])) { if (empty($this->handler->options['add_table']) && empty($this->handler->view->many_to_one_tables[$field])) { // query optimization, INNER joins are slightly faster, so use them // when we know we can. @@ -197,12 +197,12 @@ public function ensureMyTable() { // Case 2: it's an 'and' or an 'or'. // We do one join per selected value. - if ($this->handler->operator != 'not') { + if ($this->handler->operator !== 'not') { // Clone the join for each table: $this->handler->tableAliases = array(); foreach ($this->handler->value as $value) { $join = $this->getJoin(); - if ($this->handler->operator == 'and') { + if ($this->handler->operator === 'and') { $join->type = 'INNER'; } $join->extra = array( @@ -277,12 +277,12 @@ public function addFilter() { // add_condition determines whether a single expression is enough(FALSE) or the // conditions should be added via an db_or()/db_and() (TRUE). $add_condition = TRUE; - if ($operator == 'not') { + if ($operator === 'not') { $value = NULL; $operator = 'IS NULL'; $add_condition = FALSE; } - elseif ($operator == 'or' && empty($options['reduce_duplicates'])) { + elseif ($operator === 'or' && empty($options['reduce_duplicates'])) { if (count($value) > 1) { $operator = 'IN'; } @@ -296,7 +296,7 @@ public function addFilter() { if (!$add_condition) { if ($formula) { $placeholder = $this->placeholder(); - if ($operator == 'IN') { + if ($operator === 'IN') { $operator = "$operator IN($placeholder)"; } else { @@ -320,7 +320,7 @@ public function addFilter() { if ($add_condition) { $field = $this->handler->realField; - $clause = $operator == 'or' ? db_or() : db_and(); + $clause = $operator === 'or' ? db_or() : db_and(); foreach ($this->handler->tableAliases as $value => $alias) { $clause->condition("$alias.$field", $value); } diff --git a/core/modules/views/src/Plugin/Derivative/ViewsBlock.php b/core/modules/views/src/Plugin/Derivative/ViewsBlock.php index cec9895..9cc31b3 100644 --- a/core/modules/views/src/Plugin/Derivative/ViewsBlock.php +++ b/core/modules/views/src/Plugin/Derivative/ViewsBlock.php @@ -92,7 +92,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { $desc = $display->getOption('block_description'); if (empty($desc)) { - if ($display->display['display_title'] == $display->definition['title']) { + if ($display->display['display_title'] === $display->definition['title']) { $desc = t('!view', array('!view' => $view->label())); } else { diff --git a/core/modules/views/src/Plugin/Derivative/ViewsLocalTask.php b/core/modules/views/src/Plugin/Derivative/ViewsLocalTask.php index ef531b4..adcdc76 100644 --- a/core/modules/views/src/Plugin/Derivative/ViewsLocalTask.php +++ b/core/modules/views/src/Plugin/Derivative/ViewsLocalTask.php @@ -75,7 +75,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { // Don't add a local task for views which override existing routes. // @todo Alternative it could just change the existing entry. - if ($route_name != $plugin_id) { + if ($route_name !== $plugin_id) { continue; } @@ -86,7 +86,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { ) + $base_plugin_definition; // Default local tasks have themselves as root tab. - if ($menu['type'] == 'default tab') { + if ($menu['type'] === 'default tab') { $this->derivatives[$plugin_id]['base_route'] = $route_name; } } @@ -113,7 +113,7 @@ public function alterLocalTasks(&$local_tasks) { $view_route_name = $view_route_names[$executable->storage->id() . '.' . $display_id]; // Don't add a local task for views which override existing routes. - if ($view_route_name != $plugin_id) { + if ($view_route_name !== $plugin_id) { unset($local_tasks[$plugin_id]); continue; } diff --git a/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php b/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php index a07862f..3ac4495 100644 --- a/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php +++ b/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php @@ -140,7 +140,7 @@ public function updateLink(array $new_definition_values, $persist) { // Just save the title to the original view. $changed = FALSE; foreach ($new_definition_values as $key => $new_definition_value) { - if (isset($display['display_options']['menu'][$key]) && $display['display_options']['menu'][$key] != $new_definition_values[$key]) { + if (isset($display['display_options']['menu'][$key]) && $display['display_options']['menu'][$key] !== $new_definition_values[$key]) { $display['display_options']['menu'][$key] = $new_definition_values[$key]; $changed = TRUE; } diff --git a/core/modules/views/src/Plugin/ViewsHandlerManager.php b/core/modules/views/src/Plugin/ViewsHandlerManager.php index e7e1c89..fc1fbaa 100644 --- a/core/modules/views/src/Plugin/ViewsHandlerManager.php +++ b/core/modules/views/src/Plugin/ViewsHandlerManager.php @@ -53,7 +53,7 @@ class ViewsHandlerManager extends DefaultPluginManager { public function __construct($handler_type, \Traversable $namespaces, ViewsData $views_data, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) { $plugin_definition_annotation_name = 'Drupal\views\Annotation\Views' . Container::camelize($handler_type); $plugin_interface = 'Drupal\views\Plugin\views\ViewsHandlerInterface'; - if ($handler_type == 'join') { + if ($handler_type === 'join') { $plugin_interface = 'Drupal\views\Plugin\views\join\JoinPluginInterface'; } parent::__construct("Plugin/views/$handler_type", $namespaces, $module_handler, $plugin_interface, $plugin_definition_annotation_name); diff --git a/core/modules/views/src/Plugin/entity_reference/selection/ViewsSelection.php b/core/modules/views/src/Plugin/entity_reference/selection/ViewsSelection.php index 2152393..e43eae6 100644 --- a/core/modules/views/src/Plugin/entity_reference/selection/ViewsSelection.php +++ b/core/modules/views/src/Plugin/entity_reference/selection/ViewsSelection.php @@ -68,7 +68,7 @@ public static function settingsForm(FieldDefinitionInterface $field_definition) $options = array(); foreach ($displays as $data) { list($view, $display_id) = $data; - if ($view->storage->get('base_table') == $entity_type->getBaseTable()) { + if ($view->storage->get('base_table') === $entity_type->getBaseTable()) { $name = $view->storage->get('id'); $display = $view->storage->get('display'); $options[$name . ':' . $display_id] = $name . ' - ' . $display[$display_id]['display_title']; diff --git a/core/modules/views/src/Plugin/views/HandlerBase.php b/core/modules/views/src/Plugin/views/HandlerBase.php index 964ce9c..884a779 100644 --- a/core/modules/views/src/Plugin/views/HandlerBase.php +++ b/core/modules/views/src/Plugin/views/HandlerBase.php @@ -518,7 +518,7 @@ public function setRelationship() { $this->relationship = NULL; // Don't process non-existant relationships. - if (empty($this->options['relationship']) || $this->options['relationship'] == 'none') { + if (empty($this->options['relationship']) || $this->options['relationship'] === 'none') { return; } @@ -702,7 +702,7 @@ public static function getTableJoin($table, $base_table) { public function getEntityType() { // If the user has configured a relationship on the handler take that into // account. - if (!empty($this->options['relationship']) && $this->options['relationship'] != 'none') { + if (!empty($this->options['relationship']) && $this->options['relationship'] !== 'none') { $views_data = $this->getViewsData()->get($this->view->relationship->table); } else { @@ -738,7 +738,7 @@ public static function breakString($str, $force_int = FALSE) { // Filter any empty matches (Like from '++' in a string) and reset the // array keys. 'strlen' is used as the filter callback so we do not lose - // 0 values (would otherwise evaluate == FALSE). + // 0 values (would otherwise evaluate === FALSE). $value = array_values(array_filter($value, 'strlen')); if ($force_int) { diff --git a/core/modules/views/src/Plugin/views/PluginBase.php b/core/modules/views/src/Plugin/views/PluginBase.php index a92027d..78ba0a6 100644 --- a/core/modules/views/src/Plugin/views/PluginBase.php +++ b/core/modules/views/src/Plugin/views/PluginBase.php @@ -407,7 +407,7 @@ protected function listLanguages($flags = LanguageInterface::STATE_ALL) { // languages below. $languages = $manager->getLanguages($flags); foreach ($languages as $id => $language) { - if ($id == 'site_default') { + if ($id === 'site_default') { $id = '***LANGUAGE_' . $id . '***'; } $list[$id] = t($language->name); diff --git a/core/modules/views/src/Plugin/views/area/AreaPluginBase.php b/core/modules/views/src/Plugin/views/area/AreaPluginBase.php index 1269638..5206668 100644 --- a/core/modules/views/src/Plugin/views/area/AreaPluginBase.php +++ b/core/modules/views/src/Plugin/views/area/AreaPluginBase.php @@ -46,7 +46,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) { parent::init($view, $display, $options); - if ($this->areaType == 'empty') { + if ($this->areaType === 'empty') { $this->options['empty'] = TRUE; } } @@ -85,7 +85,7 @@ public function adminSummary() { public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); - if ($form_state->get('type') != 'empty') { + if ($form_state->get('type') !== 'empty') { $form['empty'] = array( '#type' => 'checkbox', '#title' => t('Display even if view has no result'), diff --git a/core/modules/views/src/Plugin/views/area/TokenizeAreaPluginBase.php b/core/modules/views/src/Plugin/views/area/TokenizeAreaPluginBase.php index 9cf0988..01ce2b7 100644 --- a/core/modules/views/src/Plugin/views/area/TokenizeAreaPluginBase.php +++ b/core/modules/views/src/Plugin/views/area/TokenizeAreaPluginBase.php @@ -81,7 +81,7 @@ public function tokenForm(&$form, FormStateInterface $form_state) { if (!empty($options[$type])) { $items = array(); foreach ($options[$type] as $key => $value) { - $items[] = $key . ' == ' . $value; + $items[] = $key . ' === ' . $value; } $form['tokens']['tokens'] = array( '#theme' => 'item_list', diff --git a/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php b/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php index da87ade..6e3a803 100644 --- a/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php +++ b/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php @@ -291,7 +291,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { continue; } foreach ((array) $info['type'] as $type) { - if ($type == $this->definition['validate type']) { + if ($type === $this->definition['validate type']) { $valid = TRUE; break; } @@ -302,7 +302,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { if ($valid) { $plugin = $this->getPlugin('argument_validator', $id); if ($plugin) { - if ($plugin->access() || $this->options['validate']['type'] == $id) { + if ($plugin->access() || $this->options['validate']['type'] === $id) { // Sanitize ID for js. $sanitized_id = static::encodeValidatorId($id); $form['validate']['options'][$sanitized_id] = array( @@ -509,7 +509,7 @@ public function defaultArgumentForm(&$form, FormStateInterface $form_state) { } $plugin = $this->getPlugin('argument_default', $id); if ($plugin) { - if ($plugin->access() || $this->options['default_argument_type'] == $id) { + if ($plugin->access() || $this->options['default_argument_type'] === $id) { $form['argument_default']['#argument_option'] = 'default'; $form['argument_default'][$id] = array( '#prefix' => '
    ', @@ -733,7 +733,7 @@ public function getDefaultArgument() { * the URL. */ public function processSummaryArguments(&$args) { - if ($this->options['validate']['type'] != 'none') { + if ($this->options['validate']['type'] !== 'none') { if (isset($this->validator) || $this->validator = $this->getPlugin('argument_validator')) { $this->validator->processSummaryArguments($args); } @@ -801,7 +801,7 @@ protected function summaryNameField() { if (isset($this->name_table)) { // if the alias is different then we're probably added, not ensured, // so look up the join and add it instead. - if ($this->tableAlias != $this->name_table) { + if ($this->tableAlias !== $this->name_table) { $j = HandlerBase::getTableJoin($this->name_table, $this->table); if ($j) { $join = clone $j; @@ -980,7 +980,7 @@ public function getValue() { // Find the position of this argument within the view. $position = 0; foreach ($this->view->argument as $id => $argument) { - if ($id == $this->options['id']) { + if ($id === $this->options['id']) { break; } $position++; @@ -1031,7 +1031,7 @@ public function getPlugin($type = 'argument_default', $name = NULL) { // we only fetch the options if we're fetching the plugin actually // in use. - if ($name == $plugin_name) { + if ($name === $plugin_name) { $options = $this->options[$options_name]; } diff --git a/core/modules/views/src/Plugin/views/argument/Date.php b/core/modules/views/src/Plugin/views/argument/Date.php index 3a3db7f..9a98e8b 100644 --- a/core/modules/views/src/Plugin/views/argument/Date.php +++ b/core/modules/views/src/Plugin/views/argument/Date.php @@ -62,7 +62,7 @@ public function defaultArgumentForm(&$form, FormStateInterface $form_state) { * formatted appropriately for this argument. */ public function getDefaultArgument($raw = FALSE) { - if (!$raw && $this->options['default_argument_type'] == 'date') { + if (!$raw && $this->options['default_argument_type'] === 'date') { return date($this->argFormat, REQUEST_TIME); } elseif (!$raw && in_array($this->options['default_argument_type'], array('node_created', 'node_changed'))) { @@ -71,10 +71,10 @@ public function getDefaultArgument($raw = FALSE) { if (!($node instanceof NodeInterface)) { return parent::getDefaultArgument(); } - elseif ($this->options['default_argument_type'] == 'node_created') { + elseif ($this->options['default_argument_type'] === 'node_created') { return date($this->argFormat, $node->getCreatedTime()); } - elseif ($this->options['default_argument_type'] == 'node_changed') { + elseif ($this->options['default_argument_type'] === 'node_changed') { return date($this->argFormat, $node->getChangedTime()); } } diff --git a/core/modules/views/src/Plugin/views/argument/ManyToOne.php b/core/modules/views/src/Plugin/views/argument/ManyToOne.php index 669c944..5736fde 100644 --- a/core/modules/views/src/Plugin/views/argument/ManyToOne.php +++ b/core/modules/views/src/Plugin/views/argument/ManyToOne.php @@ -155,7 +155,7 @@ function title() { return !empty($this->definition['invalid input']) ? $this->definition['invalid input'] : t('Invalid input'); } - return implode($this->operator == 'or' ? ' + ' : ', ', $this->titleQuery()); + return implode($this->operator === 'or' ? ' + ' : ', ', $this->titleQuery()); } protected function summaryQuery() { diff --git a/core/modules/views/src/Plugin/views/argument/Numeric.php b/core/modules/views/src/Plugin/views/argument/Numeric.php index 3051790..b59a7bc 100644 --- a/core/modules/views/src/Plugin/views/argument/Numeric.php +++ b/core/modules/views/src/Plugin/views/argument/Numeric.php @@ -84,7 +84,7 @@ function title() { return !empty($this->definition['invalid input']) ? $this->definition['invalid input'] : t('Invalid input'); } - return implode($this->operator == 'or' ? ' + ' : ', ', $this->titleQuery()); + return implode($this->operator === 'or' ? ' + ' : ', ', $this->titleQuery()); } /** diff --git a/core/modules/views/src/Plugin/views/argument/String.php b/core/modules/views/src/Plugin/views/argument/String.php index a900d0d..f7a230f 100644 --- a/core/modules/views/src/Plugin/views/argument/String.php +++ b/core/modules/views/src/Plugin/views/argument/String.php @@ -225,7 +225,7 @@ public function query($group_by = FALSE) { if ($formula) { $placeholder = $this->placeholder(); - if ($operator == 'IN') { + if ($operator === 'IN') { $field .= " IN($placeholder)"; } else { @@ -278,7 +278,7 @@ function title() { return !empty($this->definition['invalid input']) ? $this->definition['invalid input'] : t('Invalid input'); } - return implode($this->operator == 'or' ? ' + ' : ', ', $this->titleQuery()); + return implode($this->operator === 'or' ? ' + ' : ', ', $this->titleQuery()); } /** diff --git a/core/modules/views/src/Plugin/views/argument_default/QueryParameter.php b/core/modules/views/src/Plugin/views/argument_default/QueryParameter.php index 82bf1fa..846e3ed 100644 --- a/core/modules/views/src/Plugin/views/argument_default/QueryParameter.php +++ b/core/modules/views/src/Plugin/views/argument_default/QueryParameter.php @@ -71,7 +71,7 @@ public function getArgument() { if ($current_request->query->has($this->options['query_param'])) { $param = $current_request->query->get($this->options['query_param']); if (is_array($param)) { - $conjunction = ($this->options['multiple'] == 'and') ? ',' : '+'; + $conjunction = ($this->options['multiple'] === 'and') ? ',' : '+'; $param = implode($conjunction, $param); } diff --git a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php index d747283..ed98132 100644 --- a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php +++ b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php @@ -305,7 +305,7 @@ public function generateResultsKey() { $key_data = array( 'build_info' => $build_info, 'roles' => $user->getRoles(), - 'super-user' => $user->id() == 1, // special caching for super user. + 'super-user' => $user->id() === 1, // special caching for super user. 'langcode' => \Drupal::languageManager()->getCurrentLanguage()->id, 'base_url' => $GLOBALS['base_url'], ); @@ -333,7 +333,7 @@ public function generateOutputKey() { $key_data = array( 'result' => $this->view->result, 'roles' => $user->getRoles(), - 'super-user' => $user->id() == 1, // special caching for super user. + 'super-user' => $user->id() === 1, // special caching for super user. 'theme' => \Drupal::theme()->getActiveTheme()->getName(), 'langcode' => \Drupal::languageManager()->getCurrentLanguage()->id, 'base_url' => $GLOBALS['base_url'], diff --git a/core/modules/views/src/Plugin/views/cache/Time.php b/core/modules/views/src/Plugin/views/cache/Time.php index 037219c..ce42280 100644 --- a/core/modules/views/src/Plugin/views/cache/Time.php +++ b/core/modules/views/src/Plugin/views/cache/Time.php @@ -128,7 +128,7 @@ public function validateOptionsForm(&$form, FormStateInterface $form_state) { $custom_fields = array('output_lifespan', 'results_lifespan'); foreach ($custom_fields as $field) { $cache_options = $form_state->getValue('cache_options'); - if ($cache_options[$field] == 'custom' && !is_numeric($cache_options[$field . '_custom'])) { + if ($cache_options[$field] === 'custom' && !is_numeric($cache_options[$field . '_custom'])) { $form_state->setError($form[$field .'_custom'], t('Custom time values must be numeric.')); } } @@ -141,7 +141,7 @@ public function summaryTitle() { } protected function getLifespan($type) { - $lifespan = $this->options[$type . '_lifespan'] == 'custom' ? $this->options[$type . '_lifespan_custom'] : $this->options[$type . '_lifespan']; + $lifespan = $this->options[$type . '_lifespan'] === 'custom' ? $this->options[$type . '_lifespan_custom'] : $this->options[$type . '_lifespan']; return $lifespan; } diff --git a/core/modules/views/src/Plugin/views/display/Attachment.php b/core/modules/views/src/Plugin/views/display/Attachment.php index 21577cc..57fdbd1 100644 --- a/core/modules/views/src/Plugin/views/display/Attachment.php +++ b/core/modules/views/src/Plugin/views/display/Attachment.php @@ -89,7 +89,7 @@ public function optionsSummary(&$categories, &$options) { if (count($displays) > 1) { $attach_to = t('Multiple displays'); } - elseif (count($displays) == 1) { + elseif (count($displays) === 1) { $display = array_shift($displays); if ($display = $this->view->storage->getDisplay($display)) { $attach_to = String::checkPlain($display['display_title']); diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php index 22e8d16..33d62ce 100644 --- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php @@ -384,7 +384,7 @@ public function useMoreText() { public function acceptAttachments() { // To be able to accept attachments this display have to be able to use // attachments but at the same time, you cannot attach a display to itself. - if (!$this->usesAttachments() || ($this->definition['id'] == $this->view->current_display)) { + if (!$this->usesAttachments() || ($this->definition['id'] === $this->view->current_display)) { return FALSE; } @@ -857,7 +857,7 @@ public function getPlugin($type) { } // Query plugins allow specifying a specific query class per base table. - if ($type == 'query') { + if ($type === 'query') { $views_data = Views::viewsData()->get($this->view->storage->get('base_table')); $name = isset($views_data['table']['base']['query_id']) ? $views_data['table']['base']['query_id'] : 'views_query'; } @@ -914,7 +914,7 @@ public function getHandlers($type) { $info = $this->view->temporary_options[$type][$id]; } - if ($info['id'] != $id) { + if ($info['id'] !== $id) { $info['id'] = $id; } @@ -1114,7 +1114,7 @@ public function optionsSummary(&$categories, &$options) { ), ); - if ($this->display['id'] != 'default') { + if ($this->display['id'] !== 'default') { $options['display_id'] = array( 'category' => 'other', 'title' => t('Machine Name'), @@ -1310,7 +1310,7 @@ public function optionsSummary(&$categories, &$options) { $link_display_option = $this->getOption('link_display'); $link_display = $this->t('None'); - if ($link_display_option == 'custom_url') { + if ($link_display_option === 'custom_url') { $link_display = $this->t('Custom URL'); } elseif (!empty($link_display_option)) { @@ -1748,7 +1748,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { if (!empty($options[$type])) { $items = array(); foreach ($options[$type] as $key => $value) { - $items[] = $key . ' == ' . $value; + $items[] = $key . ' === ' . $value; } $item_list = array( '#theme' => 'item_list', @@ -1887,7 +1887,7 @@ public function validateOptionsForm(&$form, FormStateInterface $form_state) { } foreach ($this->view->displayHandlers as $id => $display) { - if ($id != $this->view->current_display && ($form_state->getValue('display_id') == $id || (isset($display->new_id) && $form_state->getValue('display_id') == $display->new_id))) { + if ($id !== $this->view->current_display && ($form_state->getValue('display_id') === $id || (isset($display->new_id) && $form_state->getValue('display_id') === $display->new_id))) { $form_state->setError($form['display_id'], t('Display id should be unique.')); } } @@ -1979,7 +1979,7 @@ public function submitOptionsForm(&$form, FormStateInterface $form_state) { $plugin_type = $section; $plugin_options = $this->getOption($plugin_type); $type = $form_state->getValue(array($plugin_type, 'type')); - if ($plugin_options['type'] != $type) { + if ($plugin_options['type'] !== $type) { $plugin = Views::pluginManager($plugin_type)->createInstance($type); if ($plugin) { $plugin->init($this->view, $this, $plugin_options['options']); @@ -2093,7 +2093,7 @@ public function renderMoreLink() { if ($this->isMoreEnabled() && ($this->useMoreAlways() || (!empty($this->view->pager) && $this->view->pager->hasMoreRecords()))) { $path = $this->getPath(); - if ($this->getOption('link_display') == 'custom_url' && $override_path = $this->getOption('link_url')) { + if ($this->getOption('link_display') === 'custom_url' && $override_path = $this->getOption('link_url')) { $tokens = $this->getArgumentsTokens(); $path = strtr($override_path, $tokens); } @@ -2204,7 +2204,7 @@ public function elementPreRender(array $element) { $form = \Drupal::formBuilder()->getForm($form_object, $view, $output); // The form is requesting that all non-essential views elements be hidden, // usually because the rendered step is not a view result. - if ($form['show_view_elements']['#value'] == FALSE) { + if ($form['show_view_elements']['#value'] === FALSE) { $element['#header'] = array(); $element['#exposed'] = array(); $element['#pager'] = array(); @@ -2408,12 +2408,12 @@ public function isIdentifierUnique($id, $identifier) { foreach ($this->getHandlers($type) as $key => $handler) { if ($handler->canExpose() && $handler->isExposed()) { if ($handler->isAGroup()) { - if ($id != $key && $identifier == $handler->options['group_info']['identifier']) { + if ($id !== $key && $identifier === $handler->options['group_info']['identifier']) { return FALSE; } } else { - if ($id != $key && $identifier == $handler->options['expose']['identifier']) { + if ($id !== $key && $identifier === $handler->options['expose']['identifier']) { return FALSE; } } diff --git a/core/modules/views/src/Plugin/views/display/Feed.php b/core/modules/views/src/Plugin/views/display/Feed.php index cf556e1..14e4a51 100644 --- a/core/modules/views/src/Plugin/views/display/Feed.php +++ b/core/modules/views/src/Plugin/views/display/Feed.php @@ -120,7 +120,7 @@ public function defaultableSections($section = NULL) { } // Tell views our sitename_title option belongs in the title section. - if ($section == 'title') { + if ($section === 'title') { $sections[] = 'sitename_title'; } elseif (!$section) { @@ -172,7 +172,7 @@ public function optionsSummary(&$categories, &$options) { if (count($displays) > 1) { $attach_to = t('Multiple displays'); } - elseif (count($displays) == 1) { + elseif (count($displays) === 1) { $display = array_shift($displays); $displays = $this->view->storage->get('display'); if (!empty($displays[$display])) { diff --git a/core/modules/views/src/Plugin/views/display/Page.php b/core/modules/views/src/Plugin/views/display/Page.php index cd06df0..f230d3e 100644 --- a/core/modules/views/src/Plugin/views/display/Page.php +++ b/core/modules/views/src/Plugin/views/display/Page.php @@ -141,7 +141,7 @@ public function optionsSummary(&$categories, &$options) { // This adds a 'Settings' link to the style_options setting if the style // has options. - if ($menu['type'] == 'default tab') { + if ($menu['type'] === 'default tab') { $options['menu']['setting'] = t('Parent menu item'); $options['menu']['links']['tab_options'] = t('Change settings for the parent menu'); } @@ -383,22 +383,22 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { public function validateOptionsForm(&$form, FormStateInterface $form_state) { parent::validateOptionsForm($form, $form_state); - if ($form_state->get('section') == 'menu') { + if ($form_state->get('section') === 'menu') { $path = $this->getOption('path'); $menu_type = $form_state->getValue(array('menu', 'type')); - if ($menu_type == 'normal' && strpos($path, '%') !== FALSE) { + if ($menu_type === 'normal' && strpos($path, '%') !== FALSE) { $form_state->setError($form['menu']['type'], t('Views cannot create normal menu items for paths with a % in them.')); } - if ($menu_type == 'default tab' || $menu_type == 'tab') { + if ($menu_type === 'default tab' || $menu_type === 'tab') { $bits = explode('/', $path); $last = array_pop($bits); - if ($last == '%') { + if ($last === '%') { $form_state->setError($form['menu']['type'], t('A display whose path ends with a % cannot be a tab.')); } } - if ($menu_type != 'none' && $form_state->isValueEmpty(array('menu', 'title'))) { + if ($menu_type !== 'none' && $form_state->isValueEmpty(array('menu', 'title'))) { $form_state->setError($form['menu']['title'], t('Title is required for this menu type.')); } } @@ -416,7 +416,7 @@ public function submitOptionsForm(&$form, FormStateInterface $form_state) { list($menu['menu_name'], $menu['parent']) = explode(':', $menu['parent'], 2); $this->setOption('menu', $menu); // send ajax form to options page if we use it. - if ($form_state->getValue(array('menu', 'type')) == 'default tab') { + if ($form_state->getValue(array('menu', 'type')) === 'default tab') { $form_state->get('view')->addFormToStack('display', $this->display['id'], 'tab_options'); } break; @@ -433,13 +433,13 @@ public function validate() { $errors = parent::validate(); $menu = $this->getOption('menu'); - if (!empty($menu['type']) && $menu['type'] != 'none' && empty($menu['title'])) { + if (!empty($menu['type']) && $menu['type'] !== 'none' && empty($menu['title'])) { $errors[] = t('Display @display is set to use a menu but the menu link text is not set.', array('@display' => $this->display['display_title'])); } - if ($menu['type'] == 'default tab') { + if ($menu['type'] === 'default tab') { $tab_options = $this->getOption('tab_options'); - if (!empty($tab_options['type']) && $tab_options['type'] != 'none' && empty($tab_options['title'])) { + if (!empty($tab_options['type']) && $tab_options['type'] !== 'none' && empty($tab_options['title'])) { $errors[] = t('Display @display is set to use a parent menu but the parent menu link text is not set.', array('@display' => $this->display['display_title'])); } } diff --git a/core/modules/views/src/Plugin/views/display/PathPluginBase.php b/core/modules/views/src/Plugin/views/display/PathPluginBase.php index 2400ac0..e6cbb4b 100644 --- a/core/modules/views/src/Plugin/views/display/PathPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/PathPluginBase.php @@ -102,7 +102,7 @@ public function getPath() { protected function isDefaultTabPath() { $menu = $this->getOption('menu'); $tab_options = $this->getOption('tab_options'); - return $menu['type'] == 'default tab' && !empty($tab_options['type']) && $tab_options['type'] != 'none'; + return $menu['type'] === 'default tab' && !empty($tab_options['type']) && $tab_options['type'] !== 'none'; } /** @@ -150,7 +150,7 @@ protected function getRoute($view_id, $display_id) { // routes (defined via {}). As a name for the parameter use arg_$key, so // it can be pulled in the views controller from the request. foreach ($bits as $pos => $bit) { - if ($bit == '%') { + if ($bit === '%') { // Generate the name of the parameter using the key of the argument // handler. $arg_id = 'arg_' . $arg_counter++; @@ -232,7 +232,7 @@ public function alterRoutes(RouteCollection $collection) { $route_path = RouteCompiler::getPatternOutline($route_path); // Ensure that we don't override a route which is already controlled by // views. - if (!$route->hasDefault('view_id') && ('/' . $view_path == $route_path)) { + if (!$route->hasDefault('view_id') && ('/' . $view_path === $route_path)) { $parameters = $route->compile()->getPathVariables(); // @todo Figure out whether we need to merge some settings (like @@ -285,7 +285,7 @@ public function getMenuLinks() { // Replace % with %views_arg for menu autoloading and add to the // page arguments so the argument actually comes through. foreach ($bits as $pos => $bit) { - if ($bit == '%') { + if ($bit === '%') { // If a view requires any arguments we cannot create a static menu link. return array(); } @@ -301,7 +301,7 @@ public function getMenuLinks() { if ($path) { $menu = $this->getOption('menu'); - if (!empty($menu['type']) && $menu['type'] == 'normal') { + if (!empty($menu['type']) && $menu['type'] === 'normal') { $links[$menu_link_id] = array(); // Some views might override existing paths, so we have to set the route // name based upon the altering. @@ -409,7 +409,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { public function validateOptionsForm(&$form, FormStateInterface $form_state) { parent::validateOptionsForm($form, $form_state); - if ($form_state->get('section') == 'path') { + if ($form_state->get('section') === 'path') { $errors = $this->validatePath($form_state->getValue('path')); foreach ($errors as $error) { $form_state->setError($form['path'], $error); @@ -426,7 +426,7 @@ public function validateOptionsForm(&$form, FormStateInterface $form_state) { public function submitOptionsForm(&$form, FormStateInterface $form_state) { parent::submitOptionsForm($form, $form_state); - if ($form_state->get('section') == 'path') { + if ($form_state->get('section') === 'path') { $this->setOption('path', $form_state->getValue('path')); } } diff --git a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php index 121fb94..a0a1cfd 100644 --- a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php +++ b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php @@ -174,7 +174,7 @@ public function query() { if (!$sort->isExposed()) { $sort->query(); } - elseif ($key == $sort_by) { + elseif ($key === $sort_by) { if (isset($exposed_data['sort_order']) && in_array($exposed_data['sort_order'], array('ASC', 'DESC'))) { $sort->options['order'] = $exposed_data['sort_order']; } @@ -297,7 +297,7 @@ public function exposedFormValidate(&$form, FormStateInterface $form_state) { * $view->exposed_raw_input */ public function exposedFormSubmit(&$form, FormStateInterface $form_state, &$exclude) { - if (!$form_state->isValueEmpty('op') && $form_state->getValue('op') == $this->options['reset_button_label']) { + if (!$form_state->isValueEmpty('op') && $form_state->getValue('op') === $this->options['reset_button_label']) { $this->resetForm($form, $form_state); } if ($pager_plugin = $form_state->get('pager_plugin')) { diff --git a/core/modules/views/src/Plugin/views/field/Boolean.php b/core/modules/views/src/Plugin/views/field/Boolean.php index 13b5858..6eafed8 100644 --- a/core/modules/views/src/Plugin/views/field/Boolean.php +++ b/core/modules/views/src/Plugin/views/field/Boolean.php @@ -111,7 +111,7 @@ public function render(ResultRow $values) { $value = !$value; } - if ($this->options['type'] == 'custom') { + if ($this->options['type'] === 'custom') { return $value ? UtilityXss::filterAdmin($this->options['type_custom_true']) : UtilityXss::filterAdmin($this->options['type_custom_false']); } elseif (isset($this->formats[$this->options['type']])) { diff --git a/core/modules/views/src/Plugin/views/field/Date.php b/core/modules/views/src/Plugin/views/field/Date.php index c1a47c3..aa59ee5 100644 --- a/core/modules/views/src/Plugin/views/field/Date.php +++ b/core/modules/views/src/Plugin/views/field/Date.php @@ -159,7 +159,7 @@ public function render(ResultRow $values) { case 'time span': return t(($time_diff < 0 ? '%time hence' : '%time ago'), array('%time' => $this->dateFormatter->formatInterval(abs($time_diff), is_numeric($custom_format) ? $custom_format : 2))); case 'custom': - if ($custom_format == 'r') { + if ($custom_format === 'r') { return format_date($value, $format, $custom_format, $timezone, 'en'); } return format_date($value, $format, $custom_format, $timezone); diff --git a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php index 51eebc4..f14d3b4 100644 --- a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php +++ b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php @@ -118,7 +118,7 @@ protected function allowAdvancedRender() { public function query() { $this->ensureMyTable(); // Add the field. - $params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array(); + $params = $this->options['group_type'] !== 'group' ? array('function' => $this->options['group_type']) : array(); $this->field_alias = $this->query->addField($this->tableAlias, $this->realField, NULL, $params); $this->addAdditionalFields(); @@ -144,7 +144,7 @@ protected function addAdditionalFields($fields = NULL) { } $group_params = array(); - if ($this->options['group_type'] != 'group') { + if ($this->options['group_type'] !== 'group') { $group_params = array( 'function' => $this->options['group_type'], ); @@ -188,7 +188,7 @@ public function clickSort($order) { if (isset($this->field_alias)) { // Since fields should always have themselves already added, just // add a sort on the field. - $params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array(); + $params = $this->options['group_type'] !== 'group' ? array('function' => $this->options['group_type']) : array(); $this->query->addOrderBy(NULL, NULL, $order, $this->field_alias, $params); } } @@ -388,7 +388,7 @@ public function elementWrapperClasses($row_index = NULL) { */ public function getEntity(ResultRow $values) { $relationship_id = $this->options['relationship']; - if ($relationship_id == 'none') { + if ($relationship_id === 'none') { return $values->_entity; } else { @@ -566,7 +566,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['element_type_enable'] = array( '#type' => 'checkbox', '#title' => t('Customize field HTML'), - '#default_value' => !empty($this->options['element_type']) || (string) $this->options['element_type'] == '0' || !empty($this->options['element_class']) || (string) $this->options['element_class'] == '0', + '#default_value' => !empty($this->options['element_type']) || (string) $this->options['element_type'] === '0' || !empty($this->options['element_class']) || (string) $this->options['element_class'] === '0', '#fieldset' => 'style_settings', ); $form['element_type'] = array( @@ -591,7 +591,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { ':input[name="options[element_type_enable]"]' => array('checked' => TRUE), ), ), - '#default_value' => !empty($this->options['element_class']) || (string) $this->options['element_class'] == '0', + '#default_value' => !empty($this->options['element_class']) || (string) $this->options['element_class'] === '0', '#fieldset' => 'style_settings', ); $form['element_class'] = array( @@ -611,7 +611,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['element_label_type_enable'] = array( '#type' => 'checkbox', '#title' => t('Customize label HTML'), - '#default_value' => !empty($this->options['element_label_type']) || (string) $this->options['element_label_type'] == '0' || !empty($this->options['element_label_class']) || (string) $this->options['element_label_class'] == '0', + '#default_value' => !empty($this->options['element_label_type']) || (string) $this->options['element_label_type'] === '0' || !empty($this->options['element_label_class']) || (string) $this->options['element_label_class'] === '0', '#fieldset' => 'style_settings', ); $form['element_label_type'] = array( @@ -635,7 +635,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { ':input[name="options[element_label_type_enable]"]' => array('checked' => TRUE), ), ), - '#default_value' => !empty($this->options['element_label_class']) || (string) $this->options['element_label_class'] == '0', + '#default_value' => !empty($this->options['element_label_class']) || (string) $this->options['element_label_class'] === '0', '#fieldset' => 'style_settings', ); $form['element_label_class'] = array( @@ -655,7 +655,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['element_wrapper_type_enable'] = array( '#type' => 'checkbox', '#title' => t('Customize field and label wrapper HTML'), - '#default_value' => !empty($this->options['element_wrapper_type']) || (string) $this->options['element_wrapper_type'] == '0' || !empty($this->options['element_wrapper_class']) || (string) $this->options['element_wrapper_class'] == '0', + '#default_value' => !empty($this->options['element_wrapper_type']) || (string) $this->options['element_wrapper_type'] === '0' || !empty($this->options['element_wrapper_class']) || (string) $this->options['element_wrapper_class'] === '0', '#fieldset' => 'style_settings', ); $form['element_wrapper_type'] = array( @@ -680,7 +680,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { ':input[name="options[element_wrapper_type_enable]"]' => array('checked' => TRUE), ), ), - '#default_value' => !empty($this->options['element_wrapper_class']) || (string) $this->options['element_wrapper_class'] == '0', + '#default_value' => !empty($this->options['element_wrapper_class']) || (string) $this->options['element_wrapper_class'] === '0', '#fieldset' => 'style_settings', ); $form['element_wrapper_class'] = array( @@ -892,7 +892,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { if (!empty($options[$type])) { $items = array(); foreach ($options[$type] as $key => $value) { - $items[] = $key . ' == ' . $value; + $items[] = $key . ' === ' . $value; } $item_list = array( '#theme' => 'item_list', @@ -1251,12 +1251,12 @@ public function renderText($alter) { // First check whether the field should be hidden if the value(hide_alter_empty = TRUE) /the rewrite is empty (hide_alter_empty = FALSE). // For numeric values you can specify whether "0"/0 should be empty. if ((($this->options['hide_empty'] && empty($value)) - || ($alter['phase'] != static::RENDER_TEXT_PHASE_EMPTY && $no_rewrite_for_empty)) + || ($alter['phase'] !== static::RENDER_TEXT_PHASE_EMPTY && $no_rewrite_for_empty)) && $this->isValueEmpty($value, $this->options['empty_zero'], FALSE)) { return ''; } // Only in empty phase. - if ($alter['phase'] == static::RENDER_TEXT_PHASE_EMPTY && $no_rewrite_for_empty) { + if ($alter['phase'] === static::RENDER_TEXT_PHASE_EMPTY && $no_rewrite_for_empty) { // If we got here then $alter contains the value of "No results text" // and so there is nothing left to do. return $value; @@ -1349,13 +1349,13 @@ protected function renderAsLink($alter, $text, $tokens) { $path = $alter['path']; // strip_tags() removes , so check whether its different to front. - if ($path != '') { + if ($path !== '') { // Use strip tags as there should never be HTML in the path. // However, we need to preserve special characters like " that // were removed by String::checkPlain(). $path = strip_tags(decode_entities(strtr($path, $tokens))); - if (!empty($alter['path_case']) && $alter['path_case'] != 'none') { + if (!empty($alter['path_case']) && $alter['path_case'] !== 'none') { $path = $this->caseTransform($path, $this->options['alter']['path_case']); } @@ -1399,7 +1399,7 @@ protected function renderAsLink($alter, $text, $tokens) { // Remove query parameters that were assigned a query string replacement // token for which there is no value available. foreach ($url['query'] as $param => $val) { - if ($val == '%' . $param) { + if ($val === '%' . $param) { unset($url['query'][$param]); } // Replace any empty query params from URL parsing with NULL. So the @@ -1416,7 +1416,7 @@ protected function renderAsLink($alter, $text, $tokens) { if (isset($url['fragment'])) { $path = strtr($path, array('#' . $url['fragment'] => '')); // If the path is empty we want to have a fragment for the current site. - if ($path == '') { + if ($path === '') { $options['external'] = TRUE; } $options['fragment'] = $url['fragment']; @@ -1424,7 +1424,7 @@ protected function renderAsLink($alter, $text, $tokens) { $alt = strtr($alter['alt'], $tokens); // Set the title attribute of the link only if it improves accessibility - if ($alt && $alt != $text) { + if ($alt && $alt !== $text) { $options['attributes']['title'] = decode_entities($alt); } @@ -1529,7 +1529,7 @@ public function getRenderTokens($item) { } // We only use fields up to (and including) this one. - if ($field == $this->options['id']) { + if ($field === $this->options['id']) { break; } } @@ -1652,7 +1652,7 @@ public function themeFunctions() { $themes[] = $hook . '__' . $this->view->storage->id() . '__' . $display['id']; $themes[] = $hook . '__' . $display['id'] . '__' . $this->options['id']; $themes[] = $hook . '__' . $display['id']; - if ($display['id'] != $display['display_plugin']) { + if ($display['id'] !== $display['display_plugin']) { $themes[] = $hook . '__' . $this->view->storage->id() . '__' . $display['display_plugin'] . '__' . $this->options['id']; $themes[] = $hook . '__' . $this->view->storage->id() . '__' . $display['display_plugin']; $themes[] = $hook . '__' . $display['display_plugin'] . '__' . $this->options['id']; diff --git a/core/modules/views/src/Plugin/views/field/PrerenderList.php b/core/modules/views/src/Plugin/views/field/PrerenderList.php index c309879..64d8e1f 100644 --- a/core/modules/views/src/Plugin/views/field/PrerenderList.php +++ b/core/modules/views/src/Plugin/views/field/PrerenderList.php @@ -75,7 +75,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { */ protected function renderItems($items) { if (!empty($items)) { - if ($this->options['type'] == 'separator') { + if ($this->options['type'] === 'separator') { return implode($this->sanitizeValue($this->options['separator'], 'xss_admin'), $items); } else { diff --git a/core/modules/views/src/Plugin/views/field/Serialized.php b/core/modules/views/src/Plugin/views/field/Serialized.php index 6432c7e..4a9e5b4 100644 --- a/core/modules/views/src/Plugin/views/field/Serialized.php +++ b/core/modules/views/src/Plugin/views/field/Serialized.php @@ -56,7 +56,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { public function validateOptionsForm(&$form, FormStateInterface $form_state) { // Require a key if the format is key. - if ($form_state->getValue(array('options', 'format')) == 'key' && $form_state->getValue(array('options', 'key')) == '') { + if ($form_state->getValue(array('options', 'format')) === 'key' && $form_state->getValue(array('options', 'key')) === '') { $form_state->setError($form['key'], t('You have to enter a key if you want to display a key of the data.')); } } @@ -67,10 +67,10 @@ public function validateOptionsForm(&$form, FormStateInterface $form_state) { public function render(ResultRow $values) { $value = $values->{$this->field_alias}; - if ($this->options['format'] == 'unserialized') { + if ($this->options['format'] === 'unserialized') { return String::checkPlain(print_r(unserialize($value), TRUE)); } - elseif ($this->options['format'] == 'key' && !empty($this->options['key'])) { + elseif ($this->options['format'] === 'key' && !empty($this->options['key'])) { $value = (array) unserialize($value); return String::checkPlain($value[$this->options['key']]); } diff --git a/core/modules/views/src/Plugin/views/filter/BooleanOperator.php b/core/modules/views/src/Plugin/views/filter/BooleanOperator.php index 7a87faa..cb48f25 100644 --- a/core/modules/views/src/Plugin/views/filter/BooleanOperator.php +++ b/core/modules/views/src/Plugin/views/filter/BooleanOperator.php @@ -107,13 +107,13 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o */ public function getValueOptions() { if (isset($this->definition['type'])) { - if ($this->definition['type'] == 'yes-no') { + if ($this->definition['type'] === 'yes-no') { $this->value_options = array(1 => t('Yes'), 0 => t('No')); } - if ($this->definition['type'] == 'on-off') { + if ($this->definition['type'] === 'on-off') { $this->value_options = array(1 => t('On'), 0 => t('Off')); } - if ($this->definition['type'] == 'enabled-disabled') { + if ($this->definition['type'] === 'enabled-disabled') { $this->value_options = array(1 => t('Enabled'), 0 => t('Disabled')); } } @@ -166,7 +166,7 @@ protected function valueForm(&$form, FormStateInterface $form_state) { } protected function valueValidate($form, FormStateInterface $form_state) { - if ($form_state->getValue(array('options', 'value')) == 'All' && !$form_state->isValueEmpty(array('options', 'expose', 'required'))) { + if ($form_state->getValue(array('options', 'value')) === 'All' && !$form_state->isValueEmpty(array('options', 'expose', 'required'))) { $form_state->setErrorByName('value', t('You must select a value unless this is an non-required exposed filter.')); } } diff --git a/core/modules/views/src/Plugin/views/filter/Combine.php b/core/modules/views/src/Plugin/views/filter/Combine.php index 7751027..71ce77d 100644 --- a/core/modules/views/src/Plugin/views/filter/Combine.php +++ b/core/modules/views/src/Plugin/views/filter/Combine.php @@ -132,7 +132,7 @@ protected function opRegex($expression) { } protected function opEmpty($expression) { - if ($this->operator == 'empty') { + if ($this->operator === 'empty') { $operator = "IS NULL"; } else { diff --git a/core/modules/views/src/Plugin/views/filter/Date.php b/core/modules/views/src/Plugin/views/filter/Date.php index 8f0778a..0f68550 100644 --- a/core/modules/views/src/Plugin/views/filter/Date.php +++ b/core/modules/views/src/Plugin/views/filter/Date.php @@ -84,19 +84,19 @@ public function validateExposed(&$form, FormStateInterface $form_state) { public function validateValidTime(&$form, FormStateInterface $form_state, $operator, $value) { $operators = $this->operators(); - if ($operators[$operator]['values'] == 1) { + if ($operators[$operator]['values'] === 1) { $convert = strtotime($value['value']); - if (!empty($form['value']) && ($convert == -1 || $convert === FALSE)) { + if (!empty($form['value']) && ($convert === -1 || $convert === FALSE)) { $form_state->setError($form['value'], t('Invalid date format.')); } } - elseif ($operators[$operator]['values'] == 2) { + elseif ($operators[$operator]['values'] === 2) { $min = strtotime($value['min']); - if ($min == -1 || $min === FALSE) { + if ($min === -1 || $min === FALSE) { $form_state->setError($form['min'], t('Invalid date format.')); } $max = strtotime($value['max']); - if ($max == -1 || $max === FALSE) { + if ($max === -1 || $max === FALSE) { $form_state->setError($form['max'], t('Invalid date format.')); } } @@ -114,7 +114,7 @@ protected function buildGroupValidate($form, FormStateInterface $form_state) { if (empty($group['remove'])) { // Check if the title is defined but value wasn't defined. if (!empty($group['title'])) { - if ((!is_array($group['value']) && empty($group['value'])) || (is_array($group['value']) && count(array_filter($group['value'])) == 1)) { + if ((!is_array($group['value']) && empty($group['value'])) || (is_array($group['value']) && count(array_filter($group['value'])) === 1)) { $form_state->setError($form['group_info']['group_items'][$id]['value'], t('The value is required if title for this item is defined.')); } } @@ -148,13 +148,13 @@ public function acceptExposedInput($input) { $operator = $this->operator; } - if ($operators[$operator]['values'] == 1) { - if ($this->value['value'] == '') { + if ($operators[$operator]['values'] === 1) { + if ($this->value['value'] === '') { return FALSE; } } else { - if ($this->value['min'] == '' || $this->value['max'] == '') { + if ($this->value['min'] === '' || $this->value['max'] === '') { return FALSE; } } @@ -168,7 +168,7 @@ protected function opBetween($field) { $a = intval(strtotime($this->value['min'], 0)); $b = intval(strtotime($this->value['max'], 0)); - if ($this->value['type'] == 'offset') { + if ($this->value['type'] === 'offset') { $a = '***CURRENT_TIME***' . sprintf('%+d', $a); // keep sign $b = '***CURRENT_TIME***' . sprintf('%+d', $b); // keep sign } @@ -180,7 +180,7 @@ protected function opBetween($field) { protected function opSimple($field) { $value = intval(strtotime($this->value['value'], 0)); - if (!empty($this->value['type']) && $this->value['type'] == 'offset') { + if (!empty($this->value['type']) && $this->value['type'] === 'offset') { $value = '***CURRENT_TIME***' . sprintf('%+d', $value); // keep sign } // This is safe because we are manually scrubbing the value. diff --git a/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php index aaaede0..584070b 100644 --- a/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php +++ b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php @@ -622,7 +622,7 @@ public function validateExposeForm($form, FormStateInterface $form_state) { if (empty($identifier)) { $form_state->setError($form['expose']['identifier'], t('The identifier is required if the filter is exposed.')); } - elseif ($identifier == 'value') { + elseif ($identifier === 'value') { $form_state->setError($form['expose']['identifier'], t('This identifier is not allowed.')); } @@ -641,7 +641,7 @@ protected function buildGroupValidate($form, FormStateInterface $form_state) { $form_state->setError($form['group_info']['identifier'], t('The identifier is required if the filter is exposed.')); } - elseif ($identifier == 'value') { + elseif ($identifier === 'value') { $form_state->setError($form['group_info']['identifier'], t('This identifier is not allowed.')); } @@ -658,14 +658,14 @@ protected function buildGroupValidate($form, FormStateInterface $form_state) { // Check if the title is defined but value wasn't defined. if (!empty($group['title']) && $operators[$group['operator']]['values'] > 0) { - if ((!is_array($group['value']) && trim($group['value']) == "") || - (is_array($group['value']) && count(array_filter($group['value'], 'static::arrayFilterZero')) == 0)) { + if ((!is_array($group['value']) && trim($group['value']) === "") || + (is_array($group['value']) && count(array_filter($group['value'], 'static::arrayFilterZero')) === 0)) { $form_state->setError($form['group_info']['group_items'][$id]['value'], t('The value is required if title for this item is defined.')); } } // Check if the value is defined but title wasn't defined. - if ((!is_array($group['value']) && trim($group['value']) != "") || + if ((!is_array($group['value']) && trim($group['value']) !== "") || (is_array($group['value']) && count(array_filter($group['value'], 'static::arrayFilterZero')) > 0)) { if (empty($group['title'])) { $form_state->setError($form['group_info']['group_items'][$id]['title'], t('The title is required if value for this item is defined.')); @@ -695,13 +695,13 @@ protected function buildGroupSubmit($form, FormStateInterface $form_state) { unset($group['weight']); $groups[$new_id] = $group; - if ($form_state->getValue(array('options', 'group_info', 'default_group')) == $id) { + if ($form_state->getValue(array('options', 'group_info', 'default_group')) === $id) { $new_default = $new_id; } } $new_id++; } - if ($new_default != 'All') { + if ($new_default !== 'All') { $form_state->setValue(array('options', 'group_info', 'default_group'), $new_default); } $filter_default_multiple = $form_state->getValue(array('options', 'group_info', 'default_group_multiple')); @@ -754,7 +754,7 @@ public function groupForm(&$form, FormStateInterface $form_state) { } foreach ($this->options['group_info']['group_items'] as $id => $group) { if (!empty($group['title'])) { - $groups[$id] = $id != 'All' ? t($group['title']) : $group['title']; + $groups[$id] = $id !== 'All' ? t($group['title']) : $group['title']; } } @@ -816,21 +816,21 @@ public function buildExposedForm(&$form, FormStateInterface $form_state) { $this->valueForm($form, $form_state); $form[$value] = $form['value']; - if (isset($form[$value]['#title']) && !empty($form[$value]['#type']) && $form[$value]['#type'] != 'checkbox') { + if (isset($form[$value]['#title']) && !empty($form[$value]['#type']) && $form[$value]['#type'] !== 'checkbox') { unset($form[$value]['#title']); } $this->exposedTranslate($form[$value], 'value'); - if (!empty($form['#type']) && ($form['#type'] == 'checkboxes' || ($form['#type'] == 'select' && !empty($form['#multiple'])))) { + if (!empty($form['#type']) && ($form['#type'] === 'checkboxes' || ($form['#type'] === 'select' && !empty($form['#multiple'])))) { unset($form[$value]['#default_value']); } - if (!empty($form['#type']) && $form['#type'] == 'select' && empty($form['#multiple'])) { + if (!empty($form['#type']) && $form['#type'] === 'select' && empty($form['#multiple'])) { $form[$value]['#default_value'] = 'All'; } - if ($value != 'value') { + if ($value !== 'value') { unset($form['value']); } } @@ -952,7 +952,7 @@ protected function buildExposedFiltersGroupForm(&$form, FormStateInterface $form $groups = array('All' => t('- Any -')); // The string '- Any -' will not be rendered see @theme_views_ui_build_group_filter_form // Provide 3 options to start when we are in a new group. - if (count($this->options['group_info']['group_items']) == 0) { + if (count($this->options['group_info']['group_items']) === 0) { $this->options['group_info']['group_items'] = array_fill(1, 3, array()); } @@ -1011,7 +1011,7 @@ protected function buildExposedFiltersGroupForm(&$form, FormStateInterface $form } if ($without_children) { - if (isset($this->options['group_info']['group_items'][$item_id]['value']) && $this->options['group_info']['group_items'][$item_id]['value'] != '') { + if (isset($this->options['group_info']['group_items'][$item_id]['value']) && $this->options['group_info']['group_items'][$item_id]['value'] !== '') { $row['value']['#default_value'] = $this->options['group_info']['group_items'][$item_id]['value']; } } @@ -1133,11 +1133,11 @@ protected function exposedTranslate(&$form, $type) { return; } - if ($form['#type'] == 'radios') { + if ($form['#type'] === 'radios') { $form['#type'] = 'select'; } // Checkboxes don't work so well in exposed forms due to GET conversions. - if ($form['#type'] == 'checkboxes') { + if ($form['#type'] === 'checkboxes') { if (empty($form['#no_convert']) || empty($this->options['expose']['multiple'])) { $form['#type'] = 'select'; } @@ -1151,11 +1151,11 @@ protected function exposedTranslate(&$form, $type) { } // Cleanup in case the translated element's (radios or checkboxes) display value contains html. - if ($form['#type'] == 'select') { + if ($form['#type'] === 'select') { $this->prepareFilterSelectOptions($form['#options']); } - if ($type == 'value' && empty($this->always_required) && empty($this->options['expose']['required']) && $form['#type'] == 'select' && empty($form['#multiple'])) { + if ($type === 'value' && empty($this->always_required) && empty($this->options['expose']['required']) && $form['#type'] === 'select' && empty($form['#multiple'])) { $form['#options'] = array('All' => t('- Any -')) + $form['#options']; $form['#default_value'] = 'All'; } @@ -1246,17 +1246,17 @@ public function convertExposedInput(&$input, $selected_group_id = NULL) { else { $selected_group = $input[$this->options['group_info']['identifier']]; } - if ($selected_group == 'All' && !empty($this->options['group_info']['optional'])) { + if ($selected_group === 'All' && !empty($this->options['group_info']['optional'])) { return NULL; } - if ($selected_group != 'All' && empty($this->options['group_info']['group_items'][$selected_group])) { + if ($selected_group !== 'All' && empty($this->options['group_info']['group_items'][$selected_group])) { return FALSE; } if (isset($selected_group) && isset($this->options['group_info']['group_items'][$selected_group])) { $input[$this->options['expose']['operator']] = $this->options['group_info']['group_items'][$selected_group]['operator']; // Value can be optional, For example for 'empty' and 'not empty' filters. - if (isset($this->options['group_info']['group_items'][$selected_group]['value']) && $this->options['group_info']['group_items'][$selected_group]['value'] != '') { + if (isset($this->options['group_info']['group_items'][$selected_group]['value']) && $this->options['group_info']['group_items'][$selected_group]['value'] !== '') { $input[$this->options['expose']['identifier']] = $this->options['group_info']['group_items'][$selected_group]['value']; } $this->options['expose']['use_operator'] = TRUE; @@ -1348,12 +1348,12 @@ public function acceptExposedInput($input) { // Various ways to check for the absence of non-required input. if (empty($this->options['expose']['required'])) { - if (($this->operator == 'empty' || $this->operator == 'not empty') && $value === '') { + if (($this->operator === 'empty' || $this->operator === 'not empty') && $value === '') { $value = ' '; } - if ($this->operator != 'empty' && $this->operator != 'not empty') { - if ($value == 'All' || $value === array()) { + if ($this->operator !== 'empty' && $this->operator !== 'not empty') { + if ($value === 'All' || $value === array()) { return FALSE; } } @@ -1464,7 +1464,7 @@ public function canGroup() { * TRUE if the value is equal to an empty string, FALSE otherwise. */ protected static function arrayFilterZero($var) { - return trim($var) != ''; + return trim($var) !== ''; } } diff --git a/core/modules/views/src/Plugin/views/filter/GroupByNumeric.php b/core/modules/views/src/Plugin/views/filter/GroupByNumeric.php index 9bd321b..98c90a6 100644 --- a/core/modules/views/src/Plugin/views/filter/GroupByNumeric.php +++ b/core/modules/views/src/Plugin/views/filter/GroupByNumeric.php @@ -28,7 +28,7 @@ public function query() { protected function opBetween($field) { $placeholder_min = $this->placeholder(); $placeholder_max = $this->placeholder(); - if ($this->operator == 'between') { + if ($this->operator === 'between') { $this->query->addHavingExpression($this->options['group'], "$field >= $placeholder_min", array($placeholder_min => $this->value['min'])); $this->query->addHavingExpression($this->options['group'], "$field <= $placeholder_max", array($placeholder_max => $this->value['max'])); } @@ -43,7 +43,7 @@ protected function opSimple($field) { } protected function opEmpty($field) { - if ($this->operator == 'empty') { + if ($this->operator === 'empty') { $operator = "IS NULL"; } else { diff --git a/core/modules/views/src/Plugin/views/filter/InOperator.php b/core/modules/views/src/Plugin/views/filter/InOperator.php index 4d442b8..adc799e 100644 --- a/core/modules/views/src/Plugin/views/filter/InOperator.php +++ b/core/modules/views/src/Plugin/views/filter/InOperator.php @@ -158,7 +158,7 @@ public function operatorOptions($which = 'title') { protected function operatorValues($values = 1) { $options = array(); foreach ($this->operators() as $id => $info) { - if (isset($info['values']) && $info['values'] == $values) { + if (isset($info['values']) && $info['values'] === $values) { $options[] = $id; } } @@ -218,7 +218,7 @@ protected function valueForm(&$form, FormStateInterface $form_state) { } } - if ($which == 'all' || $which == 'value') { + if ($which === 'all' || $which === 'value') { $form['value'] = array( '#type' => $this->valueFormType, '#title' => $this->value_title, @@ -234,7 +234,7 @@ protected function valueForm(&$form, FormStateInterface $form_state) { $form_state->setUserInput($user_input); } - if ($which == 'all') { + if ($which === 'all') { if (!$exposed && (in_array($this->valueFormType, ['checkbox', 'checkboxes', 'radios', 'select']))) { $form['value']['#prefix'] = '
    '; $form['value']['#suffix'] = '
    '; @@ -291,7 +291,7 @@ public function acceptExposedInput($input) { // participate, but using the default settings, *if* 'limit is true. if (empty($this->options['expose']['multiple']) && empty($this->options['expose']['required']) && !empty($this->options['expose']['limit'])) { $identifier = $this->options['expose']['identifier']; - if ($input[$identifier] == 'All') { + if ($input[$identifier] === 'All') { return TRUE; } } @@ -337,10 +337,10 @@ public function adminSummary() { } } // Choose different kind of ouput for 0, a single and multiple values. - if (count($this->value) == 0) { + if (count($this->value) === 0) { $values = t('Unknown'); } - else if (count($this->value) == 1) { + else if (count($this->value) === 1) { // If any, use the 'single' short name of the operator instead. if (isset($info[$this->operator]['short_single'])) { $operator = UtilityString::checkPlain($info[$this->operator]['short_single']); @@ -394,7 +394,7 @@ protected function opSimple() { protected function opEmpty() { $this->ensureMyTable(); - if ($this->operator == 'empty') { + if ($this->operator === 'empty') { $operator = "IS NULL"; } else { @@ -437,11 +437,11 @@ public function validate() { } } // Choose different kind of ouput for 0, a single and multiple values. - if (count($this->value) == 0) { + if (count($this->value) === 0) { $errors[] = t('No valid values found on filter: @filter.', array('@filter' => $this->adminLabel(TRUE))); } } - elseif (!empty($this->value) && ($this->operator == 'in' || $this->operator == 'not in')) { + elseif (!empty($this->value) && ($this->operator === 'in' || $this->operator === 'not in')) { $errors[] = t('The value @value is not an array for @operator on filter: @filter', array('@value' => var_export($this->value), '@operator' => $this->operator, '@filter' => $this->adminLabel(TRUE))); } return $errors; diff --git a/core/modules/views/src/Plugin/views/filter/ManyToOne.php b/core/modules/views/src/Plugin/views/filter/ManyToOne.php index bd5c1ee..670534b 100644 --- a/core/modules/views/src/Plugin/views/filter/ManyToOne.php +++ b/core/modules/views/src/Plugin/views/filter/ManyToOne.php @@ -123,7 +123,7 @@ protected function valueForm(&$form, FormStateInterface $form_state) { public function ensureMyTable() { // Defer to helper if the operator specifies it. $info = $this->operators(); - if (isset($info[$this->operator]['ensure_my_table']) && $info[$this->operator]['ensure_my_table'] == 'helper') { + if (isset($info[$this->operator]['ensure_my_table']) && $info[$this->operator]['ensure_my_table'] === 'helper') { return $this->helper->ensureMyTable(); } diff --git a/core/modules/views/src/Plugin/views/filter/Numeric.php b/core/modules/views/src/Plugin/views/filter/Numeric.php index 5579158..22cbc8d 100644 --- a/core/modules/views/src/Plugin/views/filter/Numeric.php +++ b/core/modules/views/src/Plugin/views/filter/Numeric.php @@ -130,7 +130,7 @@ public function operatorOptions($which = 'title') { protected function operatorValues($values = 1) { $options = array(); foreach ($this->operators() as $id => $info) { - if ($info['values'] == $values) { + if ($info['values'] === $values) { $options[] = $id; } } @@ -165,7 +165,7 @@ protected function valueForm(&$form, FormStateInterface $form_state) { } $user_input = $form_state->getUserInput(); - if ($which == 'all') { + if ($which === 'all') { $form['value']['value'] = array( '#type' => 'textfield', '#title' => !$exposed ? t('Value') : '', @@ -183,7 +183,7 @@ protected function valueForm(&$form, FormStateInterface $form_state) { $form_state->setUserInput($user_input); } } - elseif ($which == 'value') { + elseif ($which === 'value') { // When exposed we drop the value-value and just do value if // the operator is locked. $form['value'] = array( @@ -198,7 +198,7 @@ protected function valueForm(&$form, FormStateInterface $form_state) { } } - if ($which == 'all' || $which == 'minmax') { + if ($which === 'all' || $which === 'minmax') { $form['value']['min'] = array( '#type' => 'textfield', '#title' => !$exposed ? t('Min') : '', @@ -211,7 +211,7 @@ protected function valueForm(&$form, FormStateInterface $form_state) { '#size' => 30, '#default_value' => $this->value['max'], ); - if ($which == 'all') { + if ($which === 'all') { $states = array(); // Setup #states for all operators with two values. foreach ($this->operatorValues(2) as $operator) { @@ -250,7 +250,7 @@ public function query() { } protected function opBetween($field) { - if ($this->operator == 'between') { + if ($this->operator === 'between') { $this->query->addWhere($this->options['group'], $field, array($this->value['min'], $this->value['max']), 'BETWEEN'); } else { @@ -263,7 +263,7 @@ protected function opSimple($field) { } protected function opEmpty($field) { - if ($this->operator == 'empty') { + if ($this->operator === 'empty') { $operator = "IS NULL"; } else { diff --git a/core/modules/views/src/Plugin/views/filter/String.php b/core/modules/views/src/Plugin/views/filter/String.php index a93c907..b3bf85c 100644 --- a/core/modules/views/src/Plugin/views/filter/String.php +++ b/core/modules/views/src/Plugin/views/filter/String.php @@ -173,7 +173,7 @@ public function adminSummary() { protected function operatorValues($values = 1) { $options = array(); foreach ($this->operators() as $id => $info) { - if (isset($info['values']) && $info['values'] == $values) { + if (isset($info['values']) && $info['values'] === $values) { $options[] = $id; } } @@ -205,7 +205,7 @@ protected function valueForm(&$form, FormStateInterface $form_state) { } } - if ($which == 'all' || $which == 'value') { + if ($which === 'all' || $which === 'value') { $form['value'] = array( '#type' => 'textfield', '#title' => t('Value'), @@ -218,7 +218,7 @@ protected function valueForm(&$form, FormStateInterface $form_state) { $form_state->setUserInput($user_input); } - if ($which == 'all') { + if ($which === 'all') { // Setup #states for all operators with one value. foreach ($this->operatorValues(1) as $operator) { $form['value']['#states']['visible'][] = array( @@ -238,7 +238,7 @@ protected function valueForm(&$form, FormStateInterface $form_state) { } function operator() { - return $this->operator == '=' ? 'LIKE' : 'NOT LIKE'; + return $this->operator === '=' ? 'LIKE' : 'NOT LIKE'; } /** @@ -267,7 +267,7 @@ protected function opContains($field) { } protected function opContainsWord($field) { - $where = $this->operator == 'word' ? db_or() : db_and(); + $where = $this->operator === 'word' ? db_or() : db_and(); // Don't filter on empty strings. if (empty($this->value)) { @@ -278,7 +278,7 @@ protected function opContainsWord($field) { foreach ($matches as $match) { $phrase = FALSE; // Strip off phrase quotes - if ($match[2]{0} == '"') { + if ($match[2]{0} === '"') { $match[2] = substr($match[2], 1, -1); $phrase = TRUE; } @@ -339,7 +339,7 @@ protected function opRegex($field) { } protected function opEmpty($field) { - if ($this->operator == 'empty') { + if ($this->operator === 'empty') { $operator = "IS NULL"; } else { diff --git a/core/modules/views/src/Plugin/views/join/JoinPluginBase.php b/core/modules/views/src/Plugin/views/join/JoinPluginBase.php index d282f39..38647b0 100644 --- a/core/modules/views/src/Plugin/views/join/JoinPluginBase.php +++ b/core/modules/views/src/Plugin/views/join/JoinPluginBase.php @@ -221,7 +221,7 @@ public function buildJoin($select_query, $table, $view_query) { elseif (isset($info['table'])) { // If we're aware of a table alias for this table, use the table // alias instead of the table name. - if (isset($left) && $left['table'] == $info['table']) { + if (isset($left) && $left['table'] === $info['table']) { $join_table = $left['alias'] . '.'; } else { @@ -231,12 +231,12 @@ public function buildJoin($select_query, $table, $view_query) { // Convert a single-valued array of values to the single-value case, // and transform from IN() notation to = notation - if (is_array($info['value']) && count($info['value']) == 1) { + if (is_array($info['value']) && count($info['value']) === 1) { if (empty($info['operator'])) { $operator = '='; } else { - $operator = $info['operator'] == 'NOT IN' ? '!=' : '='; + $operator = $info['operator'] === 'NOT IN' ? '!=' : '='; } $info['value'] = array_shift($info['value']); } @@ -270,7 +270,7 @@ public function buildJoin($select_query, $table, $view_query) { } if ($extras) { - if (count($extras) == 1) { + if (count($extras) === 1) { $condition .= ' AND ' . array_shift($extras); } else { diff --git a/core/modules/views/src/Plugin/views/join/Subquery.php b/core/modules/views/src/Plugin/views/join/Subquery.php index 69b25f3..052ee5e 100644 --- a/core/modules/views/src/Plugin/views/join/Subquery.php +++ b/core/modules/views/src/Plugin/views/join/Subquery.php @@ -76,9 +76,9 @@ public function buildJoin($select_query, $table, $view_query) { if (is_array($info['value'])) { $operator = !empty($info['operator']) ? $info['operator'] : 'IN'; // Transform from IN() notation to = notation if just one value. - if (count($info['value']) == 1) { + if (count($info['value']) === 1) { $info['value'] = array_shift($info['value']); - $operator = $operator == 'NOT IN' ? '!=' : '='; + $operator = $operator === 'NOT IN' ? '!=' : '='; } } else { @@ -90,7 +90,7 @@ public function buildJoin($select_query, $table, $view_query) { } if ($extras) { - if (count($extras) == 1) { + if (count($extras) === 1) { $condition .= ' AND ' . array_shift($extras); } else { diff --git a/core/modules/views/src/Plugin/views/pager/SqlBase.php b/core/modules/views/src/Plugin/views/pager/SqlBase.php index 8a4a8e5..d9fb4c3 100644 --- a/core/modules/views/src/Plugin/views/pager/SqlBase.php +++ b/core/modules/views/src/Plugin/views/pager/SqlBase.php @@ -188,7 +188,7 @@ public function validateOptionsForm(&$form, FormStateInterface $form_state) { $options = explode(',', $exposed_options); if (!$error && is_array($options)) { foreach ($options as $option) { - if (!is_numeric($option) || intval($option) == 0) { + if (!is_numeric($option) || intval($option) === 0) { $error = TRUE; } } @@ -218,7 +218,7 @@ public function query() { if ($items_per_page > 0) { $this->options['items_per_page'] = $items_per_page; } - elseif ($items_per_page == 'All' && $this->options['expose']['items_per_page_options_all']) { + elseif ($items_per_page === 'All' && $this->options['expose']['items_per_page_options_all']) { $this->options['items_per_page'] = 0; } } diff --git a/core/modules/views/src/Plugin/views/query/QueryPluginBase.php b/core/modules/views/src/Plugin/views/query/QueryPluginBase.php index 4097efa..2253148 100644 --- a/core/modules/views/src/Plugin/views/query/QueryPluginBase.php +++ b/core/modules/views/src/Plugin/views/query/QueryPluginBase.php @@ -278,7 +278,7 @@ public function getEntityTableInfo() { // Determine which of the tables are revision tables. foreach ($entity_tables as $table_alias => $table) { $entity_type = \Drupal::entityManager()->getDefinition($table['entity_type']); - if ($entity_type->getRevisionTable() == $table['base']) { + if ($entity_type->getRevisionTable() === $table['base']) { $entity_tables[$table_alias]['revision'] = TRUE; } } diff --git a/core/modules/views/src/Plugin/views/query/Sql.php b/core/modules/views/src/Plugin/views/query/Sql.php index c52ccac..717aa0b 100644 --- a/core/modules/views/src/Plugin/views/query/Sql.php +++ b/core/modules/views/src/Plugin/views/query/Sql.php @@ -404,8 +404,8 @@ public function queueTable($table, $relationship = NULL, JoinPluginBase $join = return FALSE; } - if (!$alias && $join && $relationship && !empty($join->adjusted) && $table != $join->table) { - if ($relationship == $this->view->storage->get('base_table')) { + if (!$alias && $join && $relationship && !empty($join->adjusted) && $table !== $join->table) { + if ($relationship === $this->view->storage->get('base_table')) { $alias = $table; } else { @@ -428,7 +428,7 @@ public function queueTable($table, $relationship = NULL, JoinPluginBase $join = // If this is a relationship based table, add a marker with // the relationship as a primary table for the alias. - if ($table != $alias) { + if ($table !== $alias) { $this->markTable($alias, $this->view->storage->get('base_table'), $alias); } @@ -458,7 +458,7 @@ protected function markTable($table, $relationship, $alias) { if (empty($this->tables[$relationship][$table])) { if (!isset($alias)) { $alias = ''; - if ($relationship != $this->view->storage->get('base_table')) { + if ($relationship !== $this->view->storage->get('base_table')) { // double underscore will help prevent accidental name // space collisions. $alias = $relationship . '__'; @@ -505,7 +505,7 @@ public function ensureTable($table, $relationship = NULL, JoinPluginBase $join = // link back from an alias. We store all aliases along with the primary table // to detect this state, because eventually it'll hit a table we already // have and that's when we want to stop. - if ($relationship == $this->view->storage->get('base_table') && !empty($this->tables[$relationship][$table])) { + if ($relationship === $this->view->storage->get('base_table') && !empty($this->tables[$relationship][$table])) { return $this->tables[$relationship][$table]['alias']; } @@ -513,7 +513,7 @@ public function ensureTable($table, $relationship = NULL, JoinPluginBase $join = return FALSE; } - if ($table == $this->relationships[$relationship]['base']) { + if ($table === $this->relationships[$relationship]['base']) { return $relationship; } @@ -555,10 +555,10 @@ public function ensureTable($table, $relationship = NULL, JoinPluginBase $join = // There are a couple possible "improvements" but we should do // some performance testing before picking one. foreach ($this->tableQueue as $queued_table) { - // In PHP 4 and 5, the == operation returns TRUE for two objects + // In PHP 4 and 5, the === operation returns TRUE for two objects // if they are instances of the same class and have the same // attributes and values. - if ($queued_table['relationship'] == $relationship && $queued_table['join'] == $join) { + if ($queued_table['relationship'] === $relationship && $queued_table['join'] === $join) { return $queued_table['alias']; } } @@ -595,8 +595,8 @@ protected function ensurePath($table, $relationship = NULL, $join = NULL, $trace // Does a table along this path exist? if (isset($this->tables[$relationship][$table]) || - ($join && $join->leftTable == $relationship) || - ($join && $join->leftTable == $this->relationships[$relationship]['table'])) { + ($join && $join->leftTable === $relationship) || + ($join && $join->leftTable === $this->relationships[$relationship]['table'])) { // Make sure that we're linking to the correct table for our relationship. foreach (array_reverse($add) as $table => $path_join) { @@ -636,7 +636,7 @@ protected function adjustJoin($join, $relationship) { } // Adjusts the left table for our relationship. - if ($relationship != $this->view->storage->get('base_table')) { + if ($relationship !== $this->view->storage->get('base_table')) { // If we're linking to the primary table, the relationship to use will // be the prior relationship. Unless it's a direct link. @@ -644,14 +644,14 @@ protected function adjustJoin($join, $relationship) { $join = clone $join; // Do we need to try to ensure a path? - if ($join->leftTable != $this->relationships[$relationship]['table'] && - $join->leftTable != $this->relationships[$relationship]['base'] && + if ($join->leftTable !== $this->relationships[$relationship]['table'] && + $join->leftTable !== $this->relationships[$relationship]['base'] && !isset($this->tables[$relationship][$join->leftTable]['alias'])) { $this->ensureTable($join->leftTable, $relationship); } // First, if this is our link point/anchor table, just use the relationship - if ($join->leftTable == $this->relationships[$relationship]['table']) { + if ($join->leftTable === $this->relationships[$relationship]['table']) { $join->leftTable = $relationship; } // then, try the base alias. @@ -732,7 +732,7 @@ public function getTableInfo($table) { */ public function addField($table, $field, $alias = '', $params = array()) { // We check for this specifically because it gets a special alias. - if ($table == $this->view->storage->get('base_table') && $field == $this->view->storage->get('base_field') && empty($alias)) { + if ($table === $this->view->storage->get('base_table') && $field === $this->view->storage->get('base_field') && empty($alias)) { $alias = $this->view->storage->get('base_field'); } @@ -765,7 +765,7 @@ public function addField($table, $field, $alias = '', $params = array()) { // to do some automatic alias collision detection: $base = $alias; $counter = 0; - while (!empty($this->fields[$alias]) && $this->fields[$alias] != $field_info) { + while (!empty($this->fields[$alias]) && $this->fields[$alias] !== $field_info) { $field_info['alias'] = $alias = $base . '_' . ++$counter; } @@ -938,7 +938,7 @@ public function addHavingExpression($group, $snippet, $args = array()) { public function addOrderBy($table, $field = NULL, $order = 'ASC', $alias = '', $params = array()) { // Only ensure the table if it's not the special random key. // @todo: Maybe it would make sense to just add an addOrderByRand or something similar. - if ($table && $table != 'rand') { + if ($table && $table !== 'rand') { $this->ensureTable($table); } @@ -1024,12 +1024,12 @@ protected function buildCondition($where = 'where') { $has_filter = FALSE; $main_group = db_and(); - $filter_group = $this->groupOperator == 'OR' ? db_or() : db_and(); + $filter_group = $this->groupOperator === 'OR' ? db_or() : db_and(); foreach ($this->$where as $group => $info) { if (!empty($info['conditions'])) { - $sub_group = $info['type'] == 'OR' ? db_or() : db_and(); + $sub_group = $info['type'] === 'OR' ? db_or() : db_and(); foreach ($info['conditions'] as $clause) { // DBTNG doesn't support to add the same subquery twice to the main // query and the count query, so clone the subquery to have two instances @@ -1037,7 +1037,7 @@ protected function buildCondition($where = 'where') { if (is_object($clause['value']) && $clause['value'] instanceof SelectQuery) { $clause['value'] = clone $clause['value']; } - if ($clause['operator'] == 'formula') { + if ($clause['operator'] === 'formula') { $has_condition = TRUE; $sub_group->where($clause['field'], $clause['value']); } @@ -1048,7 +1048,7 @@ protected function buildCondition($where = 'where') { } // Add the item to the filter group. - if ($group != 0) { + if ($group !== 0) { $has_filter = TRUE; $filter_group->condition($sub_group); } @@ -1283,7 +1283,7 @@ public function query($get_count = FALSE) { // we only add the orderby if we're not counting. if ($this->orderby) { foreach ($this->orderby as $order) { - if ($order['field'] == 'rand_') { + if ($order['field'] === 'rand_') { $query->orderRandom(); } else { @@ -1483,7 +1483,7 @@ function loadEntities(&$results) { foreach ($results as $index => $result) { // Store the entity id if it was found. - if (isset($result->{$id_alias}) && $result->{$id_alias} != '') { + if (isset($result->{$id_alias}) && $result->{$id_alias} !== '') { $ids_by_type[$entity_type][$index] = $result->$id_alias; } } @@ -1516,7 +1516,7 @@ function loadEntities(&$results) { $entity = NULL; } - if ($relationship_id == 'none') { + if ($relationship_id === 'none') { $results[$index]->_entity = $entity; } else { @@ -1667,10 +1667,10 @@ public function setupTimezone() { $offset = '+00:00'; static $already_set = FALSE; if (!$already_set) { - if ($db_type == 'pgsql') { + if ($db_type === 'pgsql') { Database::getConnection()->query("SET TIME ZONE INTERVAL '$offset' HOUR TO MINUTE"); } - elseif ($db_type == 'mysql') { + elseif ($db_type === 'mysql') { Database::getConnection()->query("SET @@session.time_zone = '$offset'"); } diff --git a/core/modules/views/src/Plugin/views/relationship/GroupwiseMax.php b/core/modules/views/src/Plugin/views/relationship/GroupwiseMax.php index e6d67f6..19afcd8 100644 --- a/core/modules/views/src/Plugin/views/relationship/GroupwiseMax.php +++ b/core/modules/views/src/Plugin/views/relationship/GroupwiseMax.php @@ -127,10 +127,10 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { // Only get views that are suitable: // - base must the base that our relationship joins towards // - must have fields. - if ($view->base_table == $this->definition['base'] && !empty($view->display['default']['display_options']['fields'])) { + if ($view->base_table === $this->definition['base'] && !empty($view->display['default']['display_options']['fields'])) { // TODO: check the field is the correct sort? // or let users hang themselves at this stage and check later? - if ($view->type == 'Default') { + if ($view->type === 'Default') { $views[t('Default Views')][$view->storage->id()] = $view->storage->id(); } else { @@ -246,7 +246,7 @@ protected function leftQuery($options) { $fields = &$subquery->getFields(); foreach (array_keys($fields) as $field_name) { // The base id for this subquery is stored in our definition. - if ($field_name != $this->definition['field']) { + if ($field_name !== $this->definition['field']) { unset($fields[$field_name]); } } diff --git a/core/modules/views/src/Plugin/views/row/OpmlFields.php b/core/modules/views/src/Plugin/views/row/OpmlFields.php index 2e936f5..84d93b0 100644 --- a/core/modules/views/src/Plugin/views/row/OpmlFields.php +++ b/core/modules/views/src/Plugin/views/row/OpmlFields.php @@ -157,7 +157,7 @@ public function validate() { $errors[] = $this->t('Row style plugin requires specifying which views field to use for OPML text attribute.'); } if (!empty($this->options['type_field'])) { - if ($this->options['type_field'] == 'rss') { + if ($this->options['type_field'] === 'rss') { if (empty($this->options['xml_url_field'])) { $errors[] = $this->t('Row style plugin requires specifying which views field to use for XML URL attribute.'); } @@ -182,7 +182,7 @@ public function render($row) { $item['created'] = $this->getField($row_index, $this->options['created_field']); if ($this->options['type_field']) { $item['type'] = $this->options['type_field']; - if ($item['type'] == 'rss') { + if ($item['type'] === 'rss') { $item['description'] = $this->getField($row_index, $this->options['description_field']); $item['language'] = $this->getField($row_index, $this->options['language_field']); $item['xmlUrl'] = $this->getField($row_index, $this->options['xml_url_field']); diff --git a/core/modules/views/src/Plugin/views/row/RowPluginBase.php b/core/modules/views/src/Plugin/views/row/RowPluginBase.php index 459a768..ebefcd0 100644 --- a/core/modules/views/src/Plugin/views/row/RowPluginBase.php +++ b/core/modules/views/src/Plugin/views/row/RowPluginBase.php @@ -95,7 +95,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { // If this relationship is valid for this type, add it to the list. $data = Views::viewsData()->get($relationship['table']); $base = $data[$relationship['field']]['relationship']['base']; - if ($base == $this->base_table) { + if ($base === $this->base_table) { $relationship_handler->init($executable, $relationship); $relationship_options[$relationship['id']] = $relationship_handler->adminLabel(); } diff --git a/core/modules/views/src/Plugin/views/style/Table.php b/core/modules/views/src/Plugin/views/style/Table.php index 92012fe..6ae87ab 100644 --- a/core/modules/views/src/Plugin/views/style/Table.php +++ b/core/modules/views/src/Plugin/views/style/Table.php @@ -90,7 +90,7 @@ protected function defineOptions() { */ public function buildSort() { $order = $this->view->getRequest()->query->get('order'); - if (!isset($order) && ($this->options['default'] == -1 || empty($this->view->field[$this->options['default']]))) { + if (!isset($order) && ($this->options['default'] === -1 || empty($this->view->field[$this->options['default']]))) { return TRUE; } @@ -135,7 +135,7 @@ public function buildSortPost() { } // Ensure $this->order is valid. - if ($this->order != 'asc' && $this->order != 'desc') { + if ($this->order !== 'asc' && $this->order !== 'desc') { $this->order = 'asc'; } @@ -190,7 +190,7 @@ public function sanitizeColumns($columns, $fields = NULL) { // If the field is the column, mark it so, or the column // it's set to is a column, that's ok - if ($field == $column || $columns[$column] == $column && !empty($sanitized[$column])) { + if ($field === $column || $columns[$column] === $column && !empty($sanitized[$column])) { $sanitized[$field] = $column; } // Since we set the field to itself initially, ignoring diff --git a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php index a989be7..17e838a 100644 --- a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php +++ b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php @@ -135,7 +135,7 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition $entity_types = \Drupal::entityManager()->getDefinitions(); foreach ($entity_types as $entity_type_id => $entity_type) { - if ($this->base_table == $entity_type->getBaseTable()) { + if ($this->base_table === $entity_type->getBaseTable()) { $this->entityType = $entity_type; $this->entityTypeId = $entity_type_id; } @@ -526,7 +526,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { */ public static function getSelected(FormStateInterface $form_state, $parents, $default_value, $element) { // For now, don't trust this to work on anything but a #select element. - if (!isset($element['#type']) || $element['#type'] != 'select' || !isset($element['#options'])) { + if (!isset($element['#type']) || $element['#type'] !== 'select' || !isset($element['#options'])) { return $default_value; } @@ -585,7 +585,7 @@ protected function buildFormStyle(array &$form, FormStateInterface $form_state, ); // For the block display, the default value should be "titles (linked)", // if it's available (since that's the most common use case). - $block_with_linked_titles_available = ($type == 'block' && isset($options['titles_linked'])); + $block_with_linked_titles_available = ($type === 'block' && isset($options['titles_linked'])); $default_value = $block_with_linked_titles_available ? 'titles_linked' : key($options); $style_form['row_plugin']['#default_value'] = static::getSelected($form_state, array($type, 'style', 'row_plugin'), $default_value, $style_form['row_plugin']); // Changing this dropdown updates the individual row options via AJAX. @@ -918,7 +918,7 @@ protected function defaultDisplayFilters($form, FormStateInterface $form_state) protected function defaultDisplayFiltersUser(array $form, FormStateInterface $form_state) { $filters = array(); - if (($type = $form_state->getValue(array('show', 'type'))) && $type != 'all') { + if (($type = $form_state->getValue(array('show', 'type'))) && $type !== 'all') { $bundle_key = $this->entityType->getKey('bundle'); // Figure out the table where $bundle_key lives. It may not be the same as // the base table for the view; the taxonomy vocabulary machine_name, for @@ -940,7 +940,7 @@ protected function defaultDisplayFiltersUser(array $form, FormStateInterface $fo // If the 'in' operator is being used, map the values to an array. $handler = $table_data[$bundle_key]['filter']['id']; $handler_definition = Views::pluginManager('filter')->getDefinition($handler); - if ($handler == 'in_operator' || is_subclass_of($handler_definition['class'], 'Drupal\\views\\Plugin\\views\\filter\\InOperator')) { + if ($handler === 'in_operator' || is_subclass_of($handler_definition['class'], 'Drupal\\views\\Plugin\\views\\filter\\InOperator')) { $value = array($type => $type); } // Otherwise, use just a single value. @@ -1005,7 +1005,7 @@ protected function defaultDisplaySortsUser($form, FormStateInterface $form_state // Don't add a sort if there is no form value or the user set the sort to // 'none'. - if (($sort_type = $form_state->getValue(array('show', 'sort'))) && $sort_type != 'none') { + if (($sort_type = $form_state->getValue(array('show', 'sort'))) && $sort_type !== 'none') { list($column, $sort) = explode(':', $sort_type); // Column either be a column-name or the table-columnn-ame. $column = explode('-', $column); diff --git a/core/modules/views/src/Tests/Entity/RowEntityRenderersTest.php b/core/modules/views/src/Tests/Entity/RowEntityRenderersTest.php index f53b53e..6f2a5f4 100644 --- a/core/modules/views/src/Tests/Entity/RowEntityRenderersTest.php +++ b/core/modules/views/src/Tests/Entity/RowEntityRenderersTest.php @@ -87,7 +87,7 @@ public function testRenderers() { // Ensure we have a predictable result order. $values[$i][$langcode] = $i . '-' . $langcode . '-' . $this->randomMachineName(); - if ($langcode != $default_langcode) { + if ($langcode !== $default_langcode) { $node->addTranslation($langcode, array('title' => $values[$i][$langcode])); } else { diff --git a/core/modules/views/src/Tests/Handler/AreaEntityTest.php b/core/modules/views/src/Tests/Handler/AreaEntityTest.php index af44b44..271b2ba 100644 --- a/core/modules/views/src/Tests/Handler/AreaEntityTest.php +++ b/core/modules/views/src/Tests/Handler/AreaEntityTest.php @@ -80,7 +80,7 @@ public function testEntityArea() { $entity_test = $this->container->get('entity.manager')->getStorage('entity_test')->create($data); $entity_test->save(); $entities[] = $entity_test; - \Drupal::state()->set('entity_test_entity_access.view.' . $entity_test->id(), $i != 2); + \Drupal::state()->set('entity_test_entity_access.view.' . $entity_test->id(), $i !== 2); } $view = Views::getView('test_entity_area'); diff --git a/core/modules/views/src/Tests/Handler/HandlerAllTest.php b/core/modules/views/src/Tests/Handler/HandlerAllTest.php index ba83c54..d9d374d 100644 --- a/core/modules/views/src/Tests/Handler/HandlerAllTest.php +++ b/core/modules/views/src/Tests/Handler/HandlerAllTest.php @@ -66,7 +66,7 @@ public function testHandlers() { // Go through all fields and there through all handler types. foreach ($info as $field => $field_info) { // Table is a reserved key for the metainformation. - if ($field != 'table' && !in_array("$base_table:$field", $exclude)) { + if ($field !== 'table' && !in_array("$base_table:$field", $exclude)) { $item = array( 'table' => $base_table, 'field' => $field, @@ -74,7 +74,7 @@ public function testHandlers() { foreach ($object_types as $type) { if (isset($field_info[$type]['id'])) { $options = array(); - if ($type == 'filter') { + if ($type === 'filter') { $handler = $this->container->get("plugin.manager.views.$type")->getHandler($item); if ($handler instanceof InOperator) { $options['value'] = array(1); diff --git a/core/modules/views/src/Tests/Handler/HandlerTest.php b/core/modules/views/src/Tests/Handler/HandlerTest.php index b182dee..7df2a3d 100644 --- a/core/modules/views/src/Tests/Handler/HandlerTest.php +++ b/core/modules/views/src/Tests/Handler/HandlerTest.php @@ -226,7 +226,7 @@ protected function assertEqualValue($expected, $handler, $message = '', $group = $message = t('Comparing @first and @second', array('@first' => implode(',', $expected), '@second' => implode(',', $handler->value))); } - return $this->assert($expected == $handler->value, $message, $group); + return $this->assert($expected === $handler->value, $message, $group); } /** diff --git a/core/modules/views/src/Tests/Handler/RelationshipTest.php b/core/modules/views/src/Tests/Handler/RelationshipTest.php index d361a39..a55fe94 100644 --- a/core/modules/views/src/Tests/Handler/RelationshipTest.php +++ b/core/modules/views/src/Tests/Handler/RelationshipTest.php @@ -121,7 +121,7 @@ public function testRelationshipQuery() { // Alter the expected result to contain the right uids. foreach ($expected_result as &$row) { // Only John has an existing author. - if ($row['name'] == 'John') { + if ($row['name'] === 'John') { $row['uid'] = 1; } else { diff --git a/core/modules/views/src/Tests/ViewExecutableTest.php b/core/modules/views/src/Tests/ViewExecutableTest.php index fd7f628..59cd5ed 100644 --- a/core/modules/views/src/Tests/ViewExecutableTest.php +++ b/core/modules/views/src/Tests/ViewExecutableTest.php @@ -120,7 +120,7 @@ public function testInitMethods() { $handler_types = array_keys(ViewExecutable::getHandlerTypes()); foreach ($handler_types as $type) { // The views_test integration doesn't have relationships. - if ($type == 'relationship') { + if ($type === 'relationship') { continue; } $this->assertTrue(count($view->$type), format_string('Make sure a %type instance got instantiated.', array('%type' => $type))); @@ -395,7 +395,7 @@ public function testGetHandlerTypes() { // @todo The key on the display should be footers, headers and empties // or something similar instead of the singular, but so long check for // this special case. - if (isset($types[$type]['type']) && $types[$type]['type'] == 'area') { + if (isset($types[$type]['type']) && $types[$type]['type'] === 'area') { $this->assertEqual($types[$type]['plural'], $type); } else { diff --git a/core/modules/views/src/Tests/ViewTestBase.php b/core/modules/views/src/Tests/ViewTestBase.php index 82e42e2..2f5dfbb 100644 --- a/core/modules/views/src/Tests/ViewTestBase.php +++ b/core/modules/views/src/Tests/ViewTestBase.php @@ -195,7 +195,7 @@ protected function assertIdenticalResultsetHelper(ViewExecutable $view, $expecte protected function orderResultSet($result_set, $column, $reverse = FALSE) { $order = $reverse ? -1 : 1; usort($result_set, function ($a, $b) use ($column, $order) { - if ($a[$column] == $b[$column]) { + if ($a[$column] === $b[$column]) { return 0; } return $order * (($a[$column] < $b[$column]) ? -1 : 1); diff --git a/core/modules/views/src/Tests/ViewUnitTestBase.php b/core/modules/views/src/Tests/ViewUnitTestBase.php index fa14ec9..a5ba302 100644 --- a/core/modules/views/src/Tests/ViewUnitTestBase.php +++ b/core/modules/views/src/Tests/ViewUnitTestBase.php @@ -205,7 +205,7 @@ protected function assertIdenticalResultsetHelper($view, $expected_result, $colu protected function orderResultSet($result_set, $column, $reverse = FALSE) { $order = $reverse ? -1 : 1; usort($result_set, function ($a, $b) use ($column, $order) { - if ($a[$column] == $b[$column]) { + if ($a[$column] === $b[$column]) { return 0; } return $order * (($a[$column] < $b[$column]) ? -1 : 1); diff --git a/core/modules/views/src/ViewAccessControlHandler.php b/core/modules/views/src/ViewAccessControlHandler.php index 96d130e..64bfc13 100644 --- a/core/modules/views/src/ViewAccessControlHandler.php +++ b/core/modules/views/src/ViewAccessControlHandler.php @@ -23,7 +23,7 @@ class ViewAccessControlHandler extends EntityAccessControlHandler { * {@inheritdoc} */ public function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { - if ($operation == 'view') { + if ($operation === 'view') { return AccessResult::allowed(); } else { diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php index 34f7500..f009bbf 100644 --- a/core/modules/views/src/ViewExecutable.php +++ b/core/modules/views/src/ViewExecutable.php @@ -698,7 +698,7 @@ public function setDisplay($display_id = NULL) { // Reset if the display has changed. It could be called multiple times for // the same display, especially in the UI. - if ($this->current_display != $display_id) { + if ($this->current_display !== $display_id) { // Set the current display. $this->current_display = $display_id; @@ -1012,7 +1012,7 @@ public function getQuery() { public function initQuery() { if (!empty($this->query)) { $class = get_class($this->query); - if ($class && $class != 'stdClass') { + if ($class && $class !== 'stdClass') { // return if query is already initialized. return TRUE; } @@ -1409,7 +1409,7 @@ public function render($display_id = NULL) { * If you simply want to view the display, use View::preview() instead. */ public function executeDisplay($display_id = NULL, $args = array()) { - if (empty($this->current_display) || $this->current_display != $this->chooseDisplay($display_id)) { + if (empty($this->current_display) || $this->current_display !== $this->chooseDisplay($display_id)) { if (!$this->setDisplay($display_id)) { return NULL; } @@ -1437,7 +1437,7 @@ public function executeDisplay($display_id = NULL, $args = array()) { * views_embed_view() instead. */ public function preview($display_id = NULL, $args = array()) { - if (empty($this->current_display) || ((!empty($display_id)) && $this->current_display != $display_id)) { + if (empty($this->current_display) || ((!empty($display_id)) && $this->current_display !== $display_id)) { if (!$this->setDisplay($display_id)) { return FALSE; } @@ -1699,7 +1699,7 @@ public function getUrl($args = NULL, $path = NULL) { $argument_keys = isset($this->argument) ? array_keys($this->argument) : array(); $id = current($argument_keys); foreach (explode('/', $path) as $piece) { - if ($piece != '%') { + if ($piece !== '%') { $pieces[] = $piece; } else { @@ -2119,7 +2119,7 @@ public function buildThemeFunctions($hook) { $themes[] = $hook . '__' . preg_replace('/[^a-z0-9]/', '_', strtolower($tag)); } - if ($display['id'] != $display['display_plugin']) { + if ($display['id'] !== $display['display_plugin']) { $themes[] = $hook . '__' . $id . '__' . $display['display_plugin']; $themes[] = $hook . '__' . $display['display_plugin']; } diff --git a/core/modules/views/src/Views.php b/core/modules/views/src/Views.php index 525177f..f917021 100644 --- a/core/modules/views/src/Views.php +++ b/core/modules/views/src/Views.php @@ -335,13 +335,13 @@ public static function getViewsAsOptions($views_only = FALSE, $filter = 'all', $ foreach ($views as $view) { $id = $view->id(); // Return only views. - if ($views_only && $id != $exclude_view_name) { + if ($views_only && $id !== $exclude_view_name) { $options[$id] = $view->label(); } // Return views with display ids. else { foreach ($view->get('display') as $display_id => $display) { - if (!($id == $exclude_view_name && $display_id == $exclude_view_display)) { + if (!($id === $exclude_view_name && $display_id === $exclude_view_display)) { if ($optgroup) { $options[$id][$id . ':' . $display['id']] = t('@view : @display', array('@view' => $id, '@display' => $display['id'])); } @@ -376,7 +376,7 @@ public static function pluginList() { foreach (static::getEnabledViews() as $view) { foreach ($view->get('display') as $display) { foreach ($plugin_data as $type => $info) { - if ($type == 'display' && isset($display['display_plugin'])) { + if ($type === 'display' && isset($display['display_plugin'])) { $name = $display['display_plugin']; } elseif (isset($display['display_options']["{$type}_plugin"])) { @@ -517,7 +517,7 @@ public static function getPluginTypes($type = NULL) { } return array_keys(array_filter(static::$plugins, function($plugin_type) use ($type) { - return $plugin_type == $type; + return $plugin_type === $type; })); } diff --git a/core/modules/views/src/ViewsData.php b/core/modules/views/src/ViewsData.php index bd65aa8..b5bb211 100644 --- a/core/modules/views/src/ViewsData.php +++ b/core/modules/views/src/ViewsData.php @@ -291,10 +291,10 @@ public function fetchBaseTables() { // Sorts by the 'weight' and then by 'title' element. uasort($tables, function ($a, $b) { - if ($a['weight'] != $b['weight']) { + if ($a['weight'] !== $b['weight']) { return $a['weight'] < $b['weight'] ? -1 : 1; } - if ($a['title'] != $b['title']) { + if ($a['title'] !== $b['title']) { return $a['title'] < $b['title'] ? -1 : 1; } return 0; diff --git a/core/modules/views/src/ViewsDataHelper.php b/core/modules/views/src/ViewsDataHelper.php index b986746..231b5ef 100644 --- a/core/modules/views/src/ViewsDataHelper.php +++ b/core/modules/views/src/ViewsDataHelper.php @@ -74,7 +74,7 @@ public function fetchFields($base, $type, $grouping = FALSE, $sub_type = NULL) { $skip_bases = array(); foreach ($table_data as $field => $info) { // Collect table data from this table - if ($field == 'table') { + if ($field === 'table') { // calculate what tables this table can join to. if (!empty($info['join'])) { $bases = array_keys($info['join']); @@ -115,7 +115,7 @@ public function fetchFields($base, $type, $grouping = FALSE, $sub_type = NULL) { $strings[$field][$key][$string] = $table_data['table'][$string]; } else { - if ($string != 'base' && $string != 'base') { + if ($string !== 'base' && $string !== 'base') { $strings[$field][$key][$string] = String::format("Error: missing @component", array('@component' => $string)); } } @@ -172,13 +172,13 @@ public function fetchFields($base, $type, $grouping = FALSE, $sub_type = NULL) { protected static function fetchedFieldSort($a, $b) { $a_group = Unicode::strtolower($a['group']); $b_group = Unicode::strtolower($b['group']); - if ($a_group != $b_group) { + if ($a_group !== $b_group) { return $a_group < $b_group ? -1 : 1; } $a_title = Unicode::strtolower($a['title']); $b_title = Unicode::strtolower($b['title']); - if ($a_title != $b_title) { + if ($a_title !== $b_title) { return $a_title < $b_title ? -1 : 1; } diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php index 5a1b61b..92c3503 100644 --- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php +++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php @@ -139,7 +139,7 @@ public function match($element, $condition) { $value = $element[$condition['field']]; switch ($condition['operator']) { case '=': - return $value == $condition['value']; + return $value === $condition['value']; case 'IN': return in_array($value, $condition['value']); } diff --git a/core/modules/views/tests/modules/views_test_data/views_test_data.module b/core/modules/views/tests/modules/views_test_data/views_test_data.module index 61c7fdb..0264e1b 100644 --- a/core/modules/views/tests/modules/views_test_data/views_test_data.module +++ b/core/modules/views/tests/modules/views_test_data/views_test_data.module @@ -59,7 +59,7 @@ function views_test_data_handler_test_access_callback_argument($argument = FALSE * Implements hook_preprocess_HOOK() for views table templates. */ function views_test_data_preprocess_views_view_table(&$variables) { - if ($variables['view']->storage->id() == 'test_view_render') { + if ($variables['view']->storage->id() === 'test_view_render') { $views_render_test = \Drupal::state()->get('views_render.test'); $views_render_test++; \Drupal::state()->set('views_render.test', $views_render_test); diff --git a/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc b/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc index 1675be5..050dc8a 100644 --- a/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc +++ b/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc @@ -46,7 +46,7 @@ function views_test_data_field_views_data_alter(&$data, FieldStorageConfigInterf function views_test_data_views_pre_render(ViewExecutable $view) { \Drupal::state()->set('views_hook_test_views_pre_render', TRUE); - if (isset($view) && ($view->storage->id() == 'test_cache_header_storage')) { + if (isset($view) && ($view->storage->id() === 'test_cache_header_storage')) { $path = drupal_get_path('module', 'views_test_data'); $view->element['#attached']['js'][] = "$path/views_cache.test.js"; $view->element['#attached']['css'][] = "$path/views_cache.test.css"; @@ -75,11 +75,11 @@ function views_test_data_views_pre_build(ViewExecutable $view) { function views_test_data_views_post_build(ViewExecutable $view) { \Drupal::state()->set('views_hook_test_views_post_build', TRUE); - if (isset($view) && ($view->storage->id() == 'test_page_display')) { - if ($view->current_display == 'page_1') { + if (isset($view) && ($view->storage->id() === 'test_page_display')) { + if ($view->current_display === 'page_1') { $view->build_info['denied'] = TRUE; } - elseif ($view->current_display == 'page_2') { + elseif ($view->current_display === 'page_2') { $view->build_info['fail'] = TRUE; } } diff --git a/core/modules/views/tests/src/Unit/Entity/ViewTest.php b/core/modules/views/tests/src/Unit/Entity/ViewTest.php index 8af4e6d..ea01a09 100644 --- a/core/modules/views/tests/src/Unit/Entity/ViewTest.php +++ b/core/modules/views/tests/src/Unit/Entity/ViewTest.php @@ -74,7 +74,7 @@ class TestView extends View { */ protected function drupalGetSchema($table = NULL, $rebuild = FALSE) { $result = array(); - if ($table == 'node') { + if ($table === 'node') { $result['module'] = 'node'; } return $result; diff --git a/core/modules/views/views.api.php b/core/modules/views/views.api.php index 5534df6..a85886f 100644 --- a/core/modules/views/views.api.php +++ b/core/modules/views/views.api.php @@ -81,7 +81,7 @@ function hook_views_analyze(Drupal\views\ViewExecutable $view) { $messages = array(); - if ($view->display_handler->options['pager']['type'] == 'none') { + if ($view->display_handler->options['pager']['type'] === 'none') { $messages[] = Drupal\views\Analyzer::formatMessage(t('This view has no pager. This could cause performance issues when the view contains many items.'), 'warning'); } @@ -616,7 +616,7 @@ function hook_views_pre_view(ViewExecutable $view, $display_id, array &$args) { // Modify contextual filters for my_special_view if user has 'my special permission'. $account = \Drupal::currentUser(); - if ($view->name == 'my_special_view' && $account->hasPermission('my special permission') && $display_id == 'public_display') { + if ($view->name === 'my_special_view' && $account->hasPermission('my special permission') && $display_id === 'public_display') { $args[0] = 'custom value'; } } @@ -636,7 +636,7 @@ function hook_views_pre_build(ViewExecutable $view) { // Because of some unexplicable business logic, we should remove all // attachments from all views on Mondays. // (This alter could be done later in the execution process as well.) - if (date('D') == 'Mon') { + if (date('D') === 'Mon') { unset($view->attachment_before); unset($view->attachment_after); } @@ -659,7 +659,7 @@ function hook_views_post_build(ViewExecutable $view) { // assumptions about both exposed filter settings and the fields in the view. // Also note that this alter could be done at any point before the view being // rendered.) - if ($view->name == 'my_view' && isset($view->exposed_raw_input['type']) && $view->exposed_raw_input['type'] != 'All') { + if ($view->name === 'my_view' && isset($view->exposed_raw_input['type']) && $view->exposed_raw_input['type'] !== 'All') { // 'Type' should be interpreted as content type. if (isset($view->field['type'])) { $view->field['type']->options['exclude'] = TRUE; @@ -790,13 +790,13 @@ function hook_views_query_alter(ViewExecutable $view, QueryPluginBase $query) { // (Example assuming a view with an exposed filter on node title.) // If the input for the title filter is a positive integer, filter against // node ID instead of node title. - if ($view->name == 'my_view' && is_numeric($view->exposed_raw_input['title']) && $view->exposed_raw_input['title'] > 0) { + if ($view->name === 'my_view' && is_numeric($view->exposed_raw_input['title']) && $view->exposed_raw_input['title'] > 0) { // Traverse through the 'where' part of the query. foreach ($query->where as &$condition_group) { foreach ($condition_group['conditions'] as &$condition) { // If this is the part of the query filtering on title, chang the // condition to filter on node ID. - if ($condition['field'] == 'node.title') { + if ($condition['field'] === 'node.title') { $condition = array( 'field' => 'node.nid', 'value' => $view->exposed_raw_input['title'], diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 3ba93f5..725640e 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -188,7 +188,7 @@ function views_theme($existing, $type, $theme, $path) { ); // For the views module we ensure views.theme.inc is included. - if ($def['provider'] == 'views') { + if ($def['provider'] === 'views') { $def['theme_file'] = 'views.theme.inc'; } // We always use the module directory as base dir. @@ -255,7 +255,7 @@ function views_preprocess_node(&$variables) { // prevent drupal from accidentally setting the $page variable: if (!empty($variables['view']->current_display) && $variables['page'] - && $variables['view_mode'] == 'full' + && $variables['view_mode'] === 'full' && !$variables['view']->display_handler->hasPath()) { $variables['page'] = FALSE; } @@ -428,7 +428,7 @@ function views_add_contextual_links(&$render_element, $location, ViewExecutable if (!isset($plugin['contextual_links_locations'])) { $plugin['contextual_links_locations'] = array('view'); } - elseif ($plugin['contextual_links_locations'] == array() || $plugin['contextual_links_locations'] == array('')) { + elseif ($plugin['contextual_links_locations'] === array() || $plugin['contextual_links_locations'] === array('')) { $plugin['contextual_links_locations'] = array(); } else { diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index 81df6a1..7192234 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -450,12 +450,12 @@ function template_preprocess_views_view_table(&$variables) { // Create a second variable so we can easily find what fields we have and // what the CSS classes should be. $variables['fields'][$field] = drupal_clean_css_identifier($field); - if ($active == $field) { + if ($active === $field) { $variables['fields'][$field] .= ' active'; } // Render the header labels. - if ($field == $column && empty($fields[$field]->options['exclude'])) { + if ($field === $column && empty($fields[$field]->options['exclude'])) { $label = String::checkPlain(!empty($fields[$field]) ? $fields[$field]->label() : ''); if (empty($options['info'][$field]['sortable']) || !$fields[$field]->clickSortable()) { $variables['header'][$field]['content'] = $label; @@ -463,12 +463,12 @@ function template_preprocess_views_view_table(&$variables) { else { $initial = !empty($options['info'][$field]['default_sort_order']) ? $options['info'][$field]['default_sort_order'] : 'asc'; - if ($active == $field) { - $initial = ($order == 'asc') ? 'desc' : 'asc'; + if ($active === $field) { + $initial = ($order === 'asc') ? 'desc' : 'asc'; } $title = t('sort by @s', array('@s' => $label)); - if ($active == $field) { + if ($active === $field) { $tablesort_indicator = array( '#theme' => 'tablesort_indicator', '#style' => $initial, @@ -756,7 +756,7 @@ function template_preprocess_views_view_grid(&$variables) { // Increase, decrease or reset appropriate integers. if ($horizontal) { - if ($col == 0 && $col != ($options['columns'] - 1)) { + if ($col === 0 && $col !== ($options['columns'] - 1)) { $col++; } elseif ($col >= ($options['columns'] - 1)) { @@ -769,11 +769,11 @@ function template_preprocess_views_view_grid(&$variables) { } else { $row++; - if (!$remainders && $row == $num_rows) { + if (!$remainders && $row === $num_rows) { $row = 0; $col++; } - elseif ($remainders && $row == $num_rows + 1) { + elseif ($remainders && $row === $num_rows + 1) { $row = 0; $col++; $remainders--; @@ -897,7 +897,7 @@ function template_preprocess_views_view_rss(&$variables) { // Compare the link to the default home page; if it's the default home page, // just use $base_url. - if ($path == $config->get('page.front')) { + if ($path === $config->get('page.front')) { $path = ''; } diff --git a/core/modules/views/views.tokens.inc b/core/modules/views/views.tokens.inc index f6e2539..b6667a1 100644 --- a/core/modules/views/views.tokens.inc +++ b/core/modules/views/views.tokens.inc @@ -79,7 +79,7 @@ function views_tokens($type, $tokens, array $data = array(), array $options = ar $replacements = array(); - if ($type == 'view' && !empty($data['view'])) { + if ($type === 'view' && !empty($data['view'])) { $view = $data['view']; foreach ($tokens as $name => $original) { diff --git a/core/modules/views/views.views.inc b/core/modules/views/views.views.inc index 34167b0..2a9022f 100644 --- a/core/modules/views/views.views.inc +++ b/core/modules/views/views.views.inc @@ -142,7 +142,7 @@ function views_views_data() { // Registers an action bulk form per entity. foreach (\Drupal::entityManager()->getDefinitions() as $entity_type => $entity_info) { $actions = array_filter(\Drupal::entityManager()->getStorage('action')->loadMultiple(), function (ActionConfigEntityInterface $action) use ($entity_type) { - return $action->getType() == $entity_type; + return $action->getType() === $entity_type; }); if (empty($actions)) { continue; diff --git a/core/modules/views_ui/admin.inc b/core/modules/views_ui/admin.inc index b8b758d..fcfb31c 100644 --- a/core/modules/views_ui/admin.inc +++ b/core/modules/views_ui/admin.inc @@ -143,7 +143,7 @@ function views_ui_add_limited_validation($element, FormStateInterface $form_stat // as we did to the element itself, to ensure that #limit_validation_errors // will actually be set in the correct place. $clicked_button = &$form_state->getTriggeringElement(); - if ($clicked_button && $clicked_button['#name'] == $element['#name'] && $clicked_button['#value'] == $element['#value']) { + if ($clicked_button && $clicked_button['#name'] === $element['#name'] && $clicked_button['#value'] === $element['#value']) { $clicked_button['#limit_validation_errors'] = $element['#limit_validation_errors']; } diff --git a/core/modules/views_ui/src/Form/Ajax/AddHandler.php b/core/modules/views_ui/src/Form/Ajax/AddHandler.php index afcfa43..e24f97c 100644 --- a/core/modules/views_ui/src/Form/Ajax/AddHandler.php +++ b/core/modules/views_ui/src/Form/Ajax/AddHandler.php @@ -176,7 +176,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { // Remove the default submit function. $form['actions']['submit']['#submit'] = array_filter($form['actions']['submit']['#submit'], function($var) { - return !(is_array($var) && isset($var[1]) && $var[1] == 'standardSubmit'); + return !(is_array($var) && isset($var[1]) && $var[1] === 'standardSubmit'); }); $form['actions']['submit']['#submit'][] = array($view, 'submitItemAdd'); diff --git a/core/modules/views_ui/src/Form/Ajax/ConfigHandler.php b/core/modules/views_ui/src/Form/Ajax/ConfigHandler.php index 90de6d9..15b1553 100644 --- a/core/modules/views_ui/src/Form/Ajax/ConfigHandler.php +++ b/core/modules/views_ui/src/Form/Ajax/ConfigHandler.php @@ -93,7 +93,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { foreach ($relationships as $relationship) { // relationships can't link back to self. But also, due to ordering, // relationships can only link to prior relationships. - if ($type == 'relationship' && $id == $relationship['id']) { + if ($type === 'relationship' && $id === $relationship['id']) { break; } $relationship_handler = Views::handlerManager('relationship')->getHandler($relationship); @@ -274,7 +274,7 @@ public function remove(&$form, FormStateInterface $form_state) { list($was_defaulted, $is_defaulted) = $view->getOverrideValues($form, $form_state); $executable = $view->getExecutable(); // If the display selection was changed toggle the override value. - if ($was_defaulted != $is_defaulted) { + if ($was_defaulted !== $is_defaulted) { $display = &$executable->displayHandlers->get($display_id); $display->optionsOverride($form, $form_state); } diff --git a/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php b/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php index 58f869a..dd53788 100644 --- a/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php +++ b/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php @@ -118,7 +118,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { ); $form['remove_groups'][$id] = array(); // to prevent a notice - if ($id != 1) { + if ($id !== 1) { $form['remove_groups'][$id] = array( '#type' => 'submit', '#value' => $this->t('Remove group @group', array('@group' => $id)), @@ -129,7 +129,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#group' => $id, ); } - $group_options[$id] = $id == 1 ? $this->t('Default group') : $this->t('Group @group', array('@group' => $id)); + $group_options[$id] = $id === 1 ? $this->t('Default group') : $this->t('Group @group', array('@group' => $id)); $form['#group_renders'][$id] = array(); } @@ -152,7 +152,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { // If not grouping and the handler is set ungroupable, move it back to // the default group to prevent weird errors from having it be in its // own group: - if (!$grouping && $field['group'] == 'ungroupable') { + if (!$grouping && $field['group'] === 'ungroupable') { $field['group'] = 1; } @@ -260,7 +260,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // either adding or removing a group, not actually updating the filters. $clicked_button = $form_state->get('clicked_button'); if (!empty($clicked_button['#group'])) { - if ($clicked_button['#group'] == 'add') { + if ($clicked_button['#group'] === 'add') { // Add a new group $groups['groups'][] = 'AND'; } diff --git a/core/modules/views_ui/src/Form/Ajax/ReorderDisplays.php b/core/modules/views_ui/src/Form/Ajax/ReorderDisplays.php index 173202c..97aa3b1 100644 --- a/core/modules/views_ui/src/Form/Ajax/ReorderDisplays.php +++ b/core/modules/views_ui/src/Form/Ajax/ReorderDisplays.php @@ -50,7 +50,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { // Sort the displays. uasort($displays, function ($display1, $display2) { - if ($display1['position'] != $display2['position']) { + if ($display1['position'] !== $display2['position']) { return $display1['position'] < $display2['position'] ? -1 : 1; } return 0; diff --git a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php index 9ab629c..7fa1702 100644 --- a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php +++ b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php @@ -106,7 +106,7 @@ public function getForm(ViewStorageInterface $view, $display_id, $js) { list($key, $top) = each($view->stack); unset($view->stack[$key]); - if (array_shift($top) != $identifier) { + if (array_shift($top) !== $identifier) { $view->stack = array(); } } @@ -114,7 +114,7 @@ public function getForm(ViewStorageInterface $view, $display_id, $js) { // Automatically remove the form cache if it is set and the key does // not match. This way navigating away from the form without hitting // update will work. - if (isset($view->form_cache) && $view->form_cache['key'] != $key) { + if (isset($view->form_cache) && $view->form_cache['key'] !== $key) { unset($view->form_cache); } diff --git a/core/modules/views_ui/src/Tests/DisplayFeedTest.php b/core/modules/views_ui/src/Tests/DisplayFeedTest.php index 7dd358b..e44407b 100644 --- a/core/modules/views_ui/src/Tests/DisplayFeedTest.php +++ b/core/modules/views_ui/src/Tests/DisplayFeedTest.php @@ -60,7 +60,7 @@ protected function checkFeedViewUi($view_name) { $options = array(); foreach ($result as $value) { foreach ($value->input->attributes() as $attribute => $value) { - if ($attribute == 'value') { + if ($attribute === 'value') { $options[] = (string) $value; } } diff --git a/core/modules/views_ui/src/Tests/FieldUITest.php b/core/modules/views_ui/src/Tests/FieldUITest.php index fac6e46..0b1b9c5 100644 --- a/core/modules/views_ui/src/Tests/FieldUITest.php +++ b/core/modules/views_ui/src/Tests/FieldUITest.php @@ -43,20 +43,20 @@ public function testFieldUI() { $edit_handler_url = 'admin/structure/views/nojs/handler/test_view/default/field/age'; $this->drupalGet($edit_handler_url); $result = $this->xpath('//details[@id="edit-options-alter-help"]/div[@class="details-wrapper"]/div[@class="item-list"]/fields/li'); - $this->assertEqual((string) $result[0], '[age] == Age'); + $this->assertEqual((string) $result[0], '[age] === Age'); $edit_handler_url = 'admin/structure/views/nojs/handler/test_view/default/field/id'; $this->drupalGet($edit_handler_url); $result = $this->xpath('//details[@id="edit-options-alter-help"]/div[@class="details-wrapper"]/div[@class="item-list"]/fields/li'); - $this->assertEqual((string) $result[0], '[age] == Age'); - $this->assertEqual((string) $result[1], '[id] == ID'); + $this->assertEqual((string) $result[0], '[age] === Age'); + $this->assertEqual((string) $result[1], '[id] === ID'); $edit_handler_url = 'admin/structure/views/nojs/handler/test_view/default/field/name'; $this->drupalGet($edit_handler_url); $result = $this->xpath('//details[@id="edit-options-alter-help"]/div[@class="details-wrapper"]/div[@class="item-list"]/fields/li'); - $this->assertEqual((string) $result[0], '[age] == Age'); - $this->assertEqual((string) $result[1], '[id] == ID'); - $this->assertEqual((string) $result[2], '[name] == Name'); + $this->assertEqual((string) $result[0], '[age] === Age'); + $this->assertEqual((string) $result[1], '[id] === ID'); + $this->assertEqual((string) $result[2], '[name] === Name'); } /** diff --git a/core/modules/views_ui/src/Tests/HandlerTest.php b/core/modules/views_ui/src/Tests/HandlerTest.php index 034106d..7f97f18 100644 --- a/core/modules/views_ui/src/Tests/HandlerTest.php +++ b/core/modules/views_ui/src/Tests/HandlerTest.php @@ -79,7 +79,7 @@ public function testUICRUD() { $id = 'area'; $edit_handler_url = "admin/structure/views/nojs/handler/test_view_empty/default/$type/$id"; } - elseif ($type == 'relationship') { + elseif ($type === 'relationship') { $this->drupalPostForm($add_handler_url, array('name[views_test_data.uid]' => TRUE), t('Add and configure @handler', array('@handler' => $type_info['ltitle']))); $id = 'uid'; $edit_handler_url = "admin/structure/views/nojs/handler/test_view_empty/default/$type/$id"; diff --git a/core/modules/views_ui/src/Tests/PreviewTest.php b/core/modules/views_ui/src/Tests/PreviewTest.php index c681ec4..ab6a857 100644 --- a/core/modules/views_ui/src/Tests/PreviewTest.php +++ b/core/modules/views_ui/src/Tests/PreviewTest.php @@ -111,7 +111,7 @@ public function testPreviewWithPagersUI() { $this->assertTrue(!empty($elements), 'Full pager found.'); // Verify elements and links to pages. - // We expect to find 5 elements: current page == 1, links to pages 2 and + // We expect to find 5 elements: current page === 1, links to pages 2 and // and 3, links to 'next >' and 'last >>' pages. $this->assertClass($elements[0], 'pager-current', 'Element for current page has .pager-current class.'); $this->assertFalse(isset($elements[0]->a), 'Element for current page has no link.'); @@ -138,7 +138,7 @@ public function testPreviewWithPagersUI() { // Verify elements and links to pages. // We expect to find 7 elements: links to '<< first' and '< previous' - // pages, link to page 1, current page == 2, link to page 3 and links + // pages, link to page 1, current page === 2, link to page 3 and links // to 'next >' and 'last >>' pages. $this->assertClass($elements[0], 'pager-first', "Element for next page has .pager-first class."); $this->assertTrue($elements[0]->a, "Link to first page found."); diff --git a/core/modules/views_ui/src/ViewEditForm.php b/core/modules/views_ui/src/ViewEditForm.php index eda64cc..8e57a9d 100644 --- a/core/modules/views_ui/src/ViewEditForm.php +++ b/core/modules/views_ui/src/ViewEditForm.php @@ -317,7 +317,7 @@ public function save(array $form, FormStateInterface $form_state) { continue; } - if (($display->getPluginId() == 'page') && ($old_path == $destination) && ($old_path != $view->getExecutable()->displayHandlers->get($id)->getOption('path'))) { + if (($display->getPluginId() === 'page') && ($old_path === $destination) && ($old_path !== $view->getExecutable()->displayHandlers->get($id)->getOption('path'))) { $destination = $view->getExecutable()->displayHandlers->get($id)->getOption('path'); $query->remove('destination'); } @@ -390,11 +390,11 @@ public function getDisplayDetails($view, $display) { $is_display_deleted = !empty($display['deleted']); // The master display cannot be duplicated. - $is_default = $display['id'] == 'default'; + $is_default = $display['id'] === 'default'; // @todo: Figure out why getOption doesn't work here. $is_enabled = $view->getExecutable()->displayHandlers->get($display['id'])->isEnabled(); - if ($display['id'] != 'default') { + if ($display['id'] !== 'default') { $build['top']['#theme_wrappers'] = array('container'); $build['top']['#attributes']['id'] = 'edit-display-settings-top'; $build['top']['#attributes']['class'] = array('views-ui-display-tab-actions', 'views-ui-display-tab-bucket', 'clearfix'); @@ -455,7 +455,7 @@ public function getDisplayDetails($view, $display) { ); foreach (Views::fetchPluginNames('display', NULL, array($view->get('storage')->get('base_table'))) as $type => $label) { - if ($type == $display['display_plugin']) { + if ($type === $display['display_plugin']) { continue; } @@ -724,8 +724,8 @@ public function renderDisplayTop(ViewUI $view) { // Let other modules add additional links here. \Drupal::moduleHandler()->alter('views_ui_display_top_links', $element['extra_actions']['#links'], $view, $display_id); - if (isset($view->type) && $view->type != $this->t('Default')) { - if ($view->type == $this->t('Overridden')) { + if (isset($view->type) && $view->type !== $this->t('Default')) { + if ($view->type === $this->t('Overridden')) { $element['extra_actions']['#links']['revert'] = array( 'title' => $this->t('Revert view'), 'href' => "admin/structure/views/view/{$view->id()}/revert", @@ -1000,7 +1000,7 @@ public function getFormBucket(ViewUI $view, $type, $display) { ); if ($count_handlers > 0) { // Create the rearrange text variable for the rearrange action. - $rearrange_text = $type == 'filter' ? $this->t('And/Or Rearrange filter criteria') : $this->t('Rearrange @type', array('@type' => $types[$type]['ltitle'])); + $rearrange_text = $type === 'filter' ? $this->t('And/Or Rearrange filter criteria') : $this->t('Rearrange @type', array('@type' => $types[$type]['ltitle'])); $actions['rearrange'] = array( 'title' => $rearrange_text, @@ -1040,12 +1040,12 @@ public function getFormBucket(ViewUI $view, $type, $display) { // Filters can now be grouped so we do a little bit extra: $groups = array(); $grouping = FALSE; - if ($type == 'filter') { + if ($type === 'filter') { $group_info = $executable->display_handler->getOption('filter_groups'); // If there is only one group but it is using the "OR" filter, we still // treat it as a group for display purposes, since we want to display the // "OR" label next to items within the group. - if (!empty($group_info['groups']) && (count($group_info['groups']) > 1 || current($group_info['groups']) == 'OR')) { + if (!empty($group_info['groups']) && (count($group_info['groups']) > 1 || current($group_info['groups']) === 'OR')) { $grouping = TRUE; $groups = array(0 => array()); } @@ -1102,7 +1102,7 @@ public function getFormBucket(ViewUI $view, $type, $display) { } // If using grouping, re-order fields so that they show up properly in the list. - if ($type == 'filter' && $grouping) { + if ($type === 'filter' && $grouping) { $store = $build['fields']; $build['fields'] = array(); foreach ($groups as $gid => $contents) { @@ -1111,15 +1111,15 @@ public function getFormBucket(ViewUI $view, $type, $display) { $build['fields'][] = array( '#theme' => 'views_ui_display_tab_setting', '#class' => array('views-group-text'), - '#link' => ($group_info['operator'] == 'OR' ? $this->t('OR') : $this->t('AND')), + '#link' => ($group_info['operator'] === 'OR' ? $this->t('OR') : $this->t('AND')), ); } // Display an operator between each pair of filters within the group. $keys = array_keys($contents); $last = end($keys); foreach ($contents as $key => $pid) { - if ($key != $last) { - $store[$pid]['#link'] .= '  ' . ($group_info['groups'][$gid] == 'OR' ? $this->t('OR') : $this->t('AND')); + if ($key !== $last) { + $store[$pid]['#link'] .= '  ' . ($group_info['groups'][$gid] === 'OR' ? $this->t('OR') : $this->t('AND')); } $build['fields'][$pid] = $store[$pid]; } diff --git a/core/modules/views_ui/src/ViewFormBase.php b/core/modules/views_ui/src/ViewFormBase.php index 9544040..43ff8cd 100644 --- a/core/modules/views_ui/src/ViewFormBase.php +++ b/core/modules/views_ui/src/ViewFormBase.php @@ -134,7 +134,7 @@ public function getDisplayTabs(ViewUI $view) { } // If the default display isn't supposed to be shown, don't display its tab, unless it's the only display. - if ((!$this->isDefaultDisplayShown($view) && $display_id != 'default') && count($tabs) > 1) { + if ((!$this->isDefaultDisplayShown($view) && $display_id !== 'default') && count($tabs) > 1) { $tabs['default']['#access'] = FALSE; } @@ -161,7 +161,7 @@ public function isDefaultDisplayShown(ViewUI $view) { $advanced_mode = \Drupal::config('views.settings')->get('ui.show.master_display'); // For other users, show the default display only if there are no others, and // hide it if there's at least one "real" display. - $additional_displays = (count($view->getExecutable()->displayHandlers) == 1); + $additional_displays = (count($view->getExecutable()->displayHandlers) === 1); return $advanced_mode || $additional_displays; } @@ -173,7 +173,7 @@ public function isDefaultDisplayShown(ViewUI $view) { */ public function getDisplayLabel(ViewUI $view, $display_id, $check_changed = TRUE) { $display = $view->get('display'); - $title = $display_id == 'default' ? $this->t('Master') : $display[$display_id]['display_title']; + $title = $display_id === 'default' ? $this->t('Master') : $display[$display_id]['display_title']; $title = views_ui_truncate($title, 25); if ($check_changed && !empty($view->changed_display[$display_id])) { diff --git a/core/modules/views_ui/src/ViewUI.php b/core/modules/views_ui/src/ViewUI.php index 7e1bc27..5ba74c2 100644 --- a/core/modules/views_ui/src/ViewUI.php +++ b/core/modules/views_ui/src/ViewUI.php @@ -822,7 +822,7 @@ public function cacheSet() { * TRUE if the view is locked, FALSE otherwise. */ public function isLocked() { - return is_object($this->lock) && ($this->lock->owner != \Drupal::currentUser()->id()); + return is_object($this->lock) && ($this->lock->owner !== \Drupal::currentUser()->id()); } /** diff --git a/core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php b/core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php index c31306a..2a919dd 100644 --- a/core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php +++ b/core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php @@ -43,7 +43,7 @@ public function testEntityDecoration() { // ConfigEntityInterface::calculateDependencies() are only used for // dependency management. if (!in_array($reflection_method->getName(), ['isNew', 'isSyncing', 'isUninstalling', 'getConfigDependencyName', 'calculateDependencies'])) { - if (count($reflection_method->getParameters()) == 0) { + if (count($reflection_method->getParameters()) === 0) { $method_args[$reflection_method->getName()] = array(); } } diff --git a/core/modules/views_ui/views_ui.module b/core/modules/views_ui/views_ui.module index 3960294..32abce5 100644 --- a/core/modules/views_ui/views_ui.module +++ b/core/modules/views_ui/views_ui.module @@ -317,7 +317,7 @@ function views_ui_views_analyze(ViewExecutable $view) { } if ($display->hasPath() && $path = $display->getOption('path')) { $normal_path = \Drupal::service('path.alias_manager')->getPathByAlias($path); - if ($path != $normal_path) { + if ($path !== $normal_path) { $ret[] = Analyzer::formatMessage(t('You have configured display %display with a path which is an path alias as well. This might lead to unwanted effects so better use an internal path.', array('%display' => $display->display['display_title'])), 'warning'); } } diff --git a/core/modules/views_ui/views_ui.theme.inc b/core/modules/views_ui/views_ui.theme.inc index ce5bcd1..9180e83 100644 --- a/core/modules/views_ui/views_ui.theme.inc +++ b/core/modules/views_ui/views_ui.theme.inc @@ -152,7 +152,7 @@ function theme_views_ui_build_group_filter_form($variables) { drupal_render($form['default_group']['All']), '', array( - 'data' => \Drupal::config('views.settings')->get('ui.exposed_filter_any_label') == 'old_any' ? t('<Any>') : t('- Any -'), + 'data' => \Drupal::config('views.settings')->get('ui.exposed_filter_any_label') === 'old_any' ? t('<Any>') : t('- Any -'), 'colspan' => 4, 'class' => array('class' => 'any-default-radios-row'), ), @@ -250,7 +250,7 @@ function template_preprocess_views_ui_rearrange_filter_form(&$variables) { // When JavaScript is enabled, the button for removing the group (if it's // present) should be hidden, since it will be replaced by a link on the // client side. - if (!empty($form['remove_groups'][$group_id]['#type']) && $form['remove_groups'][$group_id]['#type'] == 'submit') { + if (!empty($form['remove_groups'][$group_id]['#type']) && $form['remove_groups'][$group_id]['#type'] === 'submit') { $form['remove_groups'][$group_id]['#attributes']['class'][] = 'js-hide'; } $row[] = array( diff --git a/core/tests/Drupal/Tests/Component/Serialization/JsonTest.php b/core/tests/Drupal/Tests/Component/Serialization/JsonTest.php index bb2d27a3..4916d28 100644 --- a/core/tests/Drupal/Tests/Component/Serialization/JsonTest.php +++ b/core/tests/Drupal/Tests/Component/Serialization/JsonTest.php @@ -84,9 +84,9 @@ public function testEncodingLength() { public function testEncodingStartEnd() { $json = Json::encode($this->string); // The first and last characters should be ", and no others. - $this->assertTrue($json[0] == '"', 'A JSON encoded string begins with ".'); - $this->assertTrue($json[strlen($json) - 1] == '"', 'A JSON encoded string ends with ".'); - $this->assertTrue(substr_count($json, '"') == 2, 'A JSON encoded string contains exactly two ".'); + $this->assertTrue($json[0] === '"', 'A JSON encoded string begins with ".'); + $this->assertTrue($json[strlen($json) - 1] === '"', 'A JSON encoded string ends with ".'); + $this->assertTrue(substr_count($json, '"') === 2, 'A JSON encoded string contains exactly two ".'); } /** diff --git a/core/tests/Drupal/Tests/Component/Utility/RandomTest.php b/core/tests/Drupal/Tests/Component/Utility/RandomTest.php index cda119e..24705cb 100644 --- a/core/tests/Drupal/Tests/Component/Utility/RandomTest.php +++ b/core/tests/Drupal/Tests/Component/Utility/RandomTest.php @@ -162,7 +162,7 @@ public function testRandomStringValidator() { public function _RandomStringValidate($string) { // Return FALSE for the first generated string and any string that is the // same, as the test expects a different string to be returned. - if (empty($this->firstStringGenerated) || $string == $this->firstStringGenerated) { + if (empty($this->firstStringGenerated) || $string === $this->firstStringGenerated) { $this->firstStringGenerated = $string; return FALSE; } diff --git a/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php b/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php index 4465c49..dfacf7f 100644 --- a/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php @@ -186,7 +186,7 @@ public function testSetChecksWithDynamicAccessChecker() { ->method('applies') ->with($this->isInstanceOf('Symfony\Component\Routing\Route')) ->will($this->returnCallback(function (Route $route) { - return $route->getRequirement('_bar') == 2; + return $route->getRequirement('_bar') === 2; })); $this->accessManager->setChecks($collection); diff --git a/core/tests/Drupal/Tests/Core/Access/CustomAccessCheckTest.php b/core/tests/Drupal/Tests/Core/Access/CustomAccessCheckTest.php index 73cd223..93cea8c 100644 --- a/core/tests/Drupal/Tests/Core/Access/CustomAccessCheckTest.php +++ b/core/tests/Drupal/Tests/Core/Access/CustomAccessCheckTest.php @@ -108,7 +108,7 @@ public function accessDeny() { } public function accessParameter($parameter) { - return AccessResult::allowedIf($parameter == 'TRUE'); + return AccessResult::allowedIf($parameter === 'TRUE'); } } diff --git a/core/tests/Drupal/Tests/Core/Ajax/AjaxResponseRendererTest.php b/core/tests/Drupal/Tests/Core/Ajax/AjaxResponseRendererTest.php index 035c1e4..ff209c3 100644 --- a/core/tests/Drupal/Tests/Core/Ajax/AjaxResponseRendererTest.php +++ b/core/tests/Drupal/Tests/Core/Ajax/AjaxResponseRendererTest.php @@ -117,7 +117,7 @@ protected function drupalRender(&$elements, $is_recursive_call = FALSE) { * {@inheritdoc} */ protected function elementInfo($type) { - if ($type == 'ajax') { + if ($type === 'ajax') { return array( '#header' => TRUE, '#commands' => array(), diff --git a/core/tests/Drupal/Tests/Core/Datetime/DateTest.php b/core/tests/Drupal/Tests/Core/Datetime/DateTest.php index a2653bb..ba87a4b 100644 --- a/core/tests/Drupal/Tests/Core/Datetime/DateTest.php +++ b/core/tests/Drupal/Tests/Core/Datetime/DateTest.php @@ -65,7 +65,7 @@ public function testFormatInterval($interval, $granularity, $expected, $langcode ->method('formatPlural') ->with($this->anything(), $this->anything(), $this->anything(), array(), array('langcode' => $langcode)) ->will($this->returnCallback(function($count, $one, $multiple) { - return $count == 1 ? $one : str_replace('@count', $count, $multiple); + return $count === 1 ? $one : str_replace('@count', $count, $multiple); })); // Check if the granularity is specified. diff --git a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php index 60d5838..0cdd595 100644 --- a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php @@ -274,11 +274,11 @@ public function testIsTranslatable() { $this->languageManager->expects($this->any()) ->method('isMultilingual') ->will($this->returnValue(TRUE)); - $this->assertTrue($this->entity->language()->id == 'en'); + $this->assertTrue($this->entity->language()->id === 'en'); $this->assertFalse($this->entity->language()->locked); $this->assertTrue($this->entity->isTranslatable()); - $this->assertTrue($this->entityUnd->language()->id == LanguageInterface::LANGCODE_NOT_SPECIFIED); + $this->assertTrue($this->entityUnd->language()->id === LanguageInterface::LANGCODE_NOT_SPECIFIED); $this->assertTrue($this->entityUnd->language()->locked); $this->assertFalse($this->entityUnd->isTranslatable()); } diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php index a324bf8..c033dc7 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php @@ -436,7 +436,7 @@ protected function setupEntityTypes() { $this->entityManager->expects($this->any()) ->method('getDefinition') ->will($this->returnCallback(function ($entity_type) use ($definition) { - if ($entity_type == 'entity_test') { + if ($entity_type === 'entity_test') { return $definition; } else { diff --git a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php index 3109adc..cdbb32f 100644 --- a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php @@ -794,10 +794,10 @@ protected function setUpEntitySchemaHandler(array $expected = array()) { ->method('createTable') ->with( $this->callback(function($table_name) use (&$invocation_count, $expected_table_names) { - return $expected_table_names[$invocation_count] == $table_name; + return $expected_table_names[$invocation_count] === $table_name; }), $this->callback(function($table_schema) use (&$invocation_count, $expected_table_schemas) { - return $expected_table_schemas[$invocation_count] == $table_schema; + return $expected_table_schemas[$invocation_count] === $table_schema; }) ) ->will($this->returnCallback(function() use (&$invocation_count) { diff --git a/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php b/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php index 269674b..b9928ac 100644 --- a/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php +++ b/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php @@ -116,7 +116,7 @@ public function providerTestLog() { // No request or account. $cases [] = array( function ($context) { - return $context['channel'] == 'test' && empty($contex['uid']) && empty($context['ip']); + return $context['channel'] === 'test' && empty($contex['uid']) && empty($context['ip']); }, ); // With account but not request. Since the request is not available the diff --git a/core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php b/core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php index c436d6f..d9429e8 100644 --- a/core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php @@ -175,7 +175,7 @@ public function testDeleteOverrides($ids, array $old_definitions, array $new_def ->will($this->returnValue($old_definitions)); // Only save if the definitions changes. - if ($old_definitions != $new_definitions) { + if ($old_definitions !== $new_definitions) { $config->expects($this->at(1)) ->method('set') ->with('definitions', $new_definitions) diff --git a/core/tests/Drupal/Tests/Core/Page/HtmlPageTest.php b/core/tests/Drupal/Tests/Core/Page/HtmlPageTest.php index f2305db..93072c7 100644 --- a/core/tests/Drupal/Tests/Core/Page/HtmlPageTest.php +++ b/core/tests/Drupal/Tests/Core/Page/HtmlPageTest.php @@ -27,7 +27,7 @@ public function testMetatagAlterability() { $metatags = $page->getMetaElements(); foreach ($metatags as $tag) { - if ($tag->getName() == 'example') { + if ($tag->getName() === 'example') { $tag->setContent('hello'); } } @@ -47,7 +47,7 @@ public function testMetatagRemovability() { $metatags =& $page->getMetaElements(); foreach ($metatags as $key => $tag) { - if ($tag->getName() == 'example') { + if ($tag->getName() === 'example') { unset($metatags[$key]); } } diff --git a/core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php b/core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php index 36919a6..f0fabf7 100644 --- a/core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php +++ b/core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php @@ -54,7 +54,7 @@ public function testApplies(array $definition, $name, Route $route, $applies) { $this->entityManager->expects($this->any()) ->method('hasDefinition') ->willReturnCallback(function($entity_type) { - return 'entity_test' == $entity_type; + return 'entity_test' === $entity_type; }); $this->assertEquals($applies, $this->entityConverter->applies($definition, $name, $route)); } diff --git a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginBagTest.php b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginBagTest.php index 5e96ec4..5bab98e 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginBagTest.php +++ b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginBagTest.php @@ -81,7 +81,7 @@ public function providerTestSortHelper() { */ public function testSortHelper($plugin_id_1, $plugin_id_2, $expected) { $this->setupPluginBag($this->any()); - if ($expected != 0) { + if ($expected !== 0) { $expected = $expected > 0 ? 1 : -1; } $this->assertEquals($expected, $this->defaultPluginBag->sortHelper($plugin_id_1, $plugin_id_2)); diff --git a/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php b/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php index aff98962..edece35 100644 --- a/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php @@ -208,7 +208,7 @@ public function testRebuildWithProviderBasedRoutes() { ->method('getControllerFromDefinition') ->will($this->returnCallback(function ($controller) use ($container) { $count = substr_count($controller, ':'); - if ($count == 1) { + if ($count === 1) { list($service, $method) = explode(':', $controller, 2); $object = $container->get($service); } diff --git a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php index d53d984..a9ee72a 100644 --- a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php @@ -288,27 +288,27 @@ public function testPathBasedURLGeneration() { $base = ($absolute ? $base_url . '/' : $base_path . '/') . $script_path; $url = $base . 'node/123'; $result = $this->generator->generateFromPath('node/123', array('absolute' => $absolute)); - $this->assertEquals($url, $result, "$url == $result"); + $this->assertEquals($url, $result, "$url === $result"); $url = $base . 'node/123#foo'; $result = $this->generator->generateFromPath('node/123', array('fragment' => 'foo', 'absolute' => $absolute)); - $this->assertEquals($url, $result, "$url == $result"); + $this->assertEquals($url, $result, "$url === $result"); $url = $base . 'node/123?foo'; $result = $this->generator->generateFromPath('node/123', array('query' => array('foo' => NULL), 'absolute' => $absolute)); - $this->assertEquals($url, $result, "$url == $result"); + $this->assertEquals($url, $result, "$url === $result"); $url = $base . 'node/123?foo=bar&bar=baz'; $result = $this->generator->generateFromPath('node/123', array('query' => array('foo' => 'bar', 'bar' => 'baz'), 'absolute' => $absolute)); - $this->assertEquals($url, $result, "$url == $result"); + $this->assertEquals($url, $result, "$url === $result"); $url = $base . 'node/123?foo#bar'; $result = $this->generator->generateFromPath('node/123', array('query' => array('foo' => NULL), 'fragment' => 'bar', 'absolute' => $absolute)); - $this->assertEquals($url, $result, "$url == $result"); + $this->assertEquals($url, $result, "$url === $result"); $url = $base; $result = $this->generator->generateFromPath('', array('absolute' => $absolute)); - $this->assertEquals($url, $result, "$url == $result"); + $this->assertEquals($url, $result, "$url === $result"); } } } diff --git a/core/tests/Drupal/Tests/Core/Template/AttributeTest.php b/core/tests/Drupal/Tests/Core/Template/AttributeTest.php index 9f2cb50..e210e1a 100644 --- a/core/tests/Drupal/Tests/Core/Template/AttributeTest.php +++ b/core/tests/Drupal/Tests/Core/Template/AttributeTest.php @@ -195,11 +195,11 @@ public function testIterate() { $counter = 0; foreach ($attribute as $key => $value) { - if ($counter == 0) { + if ($counter === 0) { $this->assertEquals('class', $key); $this->assertEquals(new AttributeArray('class', array('example-class')), $value); } - if ($counter == 1) { + if ($counter === 1) { $this->assertEquals('id', $key); $this->assertEquals(new AttributeString('id', 'example-id'), $value); } diff --git a/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php b/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php index eb8881d..7bbdc35 100644 --- a/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php +++ b/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php @@ -115,7 +115,7 @@ protected function init($theme_name = NULL) { } protected function getPath($module) { - if ($module == 'theme_test') { + if ($module === 'theme_test') { return 'core/modules/system/tests/modules/theme_test'; } } diff --git a/core/tests/Drupal/Tests/Core/UrlTest.php b/core/tests/Drupal/Tests/Core/UrlTest.php index 133a73c..aa90663 100644 --- a/core/tests/Drupal/Tests/Core/UrlTest.php +++ b/core/tests/Drupal/Tests/Core/UrlTest.php @@ -121,7 +121,7 @@ public function testCreateFromPath() { */ protected function getRequestConstraint($path) { return $this->callback(function (Request $request) use ($path) { - return $request->getPathInfo() == $path; + return $request->getPathInfo() === $path; }); } diff --git a/core/themes/bartik/bartik.theme b/core/themes/bartik/bartik.theme index 27f8973..740009b 100644 --- a/core/themes/bartik/bartik.theme +++ b/core/themes/bartik/bartik.theme @@ -129,7 +129,7 @@ function bartik_preprocess_node(&$variables) { */ function bartik_preprocess_block(&$variables) { // Add a clearfix class to system branding blocks. - if ($variables['plugin_id'] == 'system_branding_block') { + if ($variables['plugin_id'] === 'system_branding_block') { $variables['attributes']['class'][] = 'clearfix'; } } @@ -157,9 +157,9 @@ function bartik_menu_tree__shortcut_default($variables) { */ function bartik_preprocess_field(&$variables) { $element = $variables['element']; - if ($element['#field_type'] == 'taxonomy_term_reference') { + if ($element['#field_type'] === 'taxonomy_term_reference') { $variables['title_attributes']['class'][] = 'field-label'; - if ($variables['element']['#label_display'] == 'inline') { + if ($variables['element']['#label_display'] === 'inline') { $variables['title_attributes']['class'][] = 'inline'; } } diff --git a/core/themes/engines/twig/twig.engine b/core/themes/engines/twig/twig.engine index e0cfcc2..d10f902 100644 --- a/core/themes/engines/twig/twig.engine +++ b/core/themes/engines/twig/twig.engine @@ -88,7 +88,7 @@ function twig_render_template($template_file, $variables) { } foreach ($suggestions as &$suggestion) { $template = strtr($suggestion, '_', '-') . $extension; - $prefix = ($template == $current_template) ? 'x' : '*'; + $prefix = ($template === $current_template) ? 'x' : '*'; $suggestion = $prefix . ' ' . $template; } $output['debug_info'] .= "\n"; @@ -126,7 +126,7 @@ function twig_render_var($arg) { } // Return early for NULL and also true for empty arrays. - if ($arg == NULL) { + if ($arg === NULL) { return NULL; } @@ -212,7 +212,7 @@ function twig_drupal_escape_filter(\Twig_Environment $env, $string, $strategy = } // Return early for NULL or an empty array. - if ($string == NULL) { + if ($string === NULL) { return NULL; } @@ -242,7 +242,7 @@ function twig_drupal_escape_filter(\Twig_Environment $env, $string, $strategy = } // Drupal only supports the HTML escaping strategy, so provide a // fallback for other strategies. - if ($strategy == 'html') { + if ($strategy === 'html') { return String::checkPlain($return); } return twig_escape_filter($env, $return, $strategy, $charset, $autoescape);