From 1cd13a8f5328c0b51f662532436fc605d26094ea Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Fri, 9 Oct 2015 16:39:35 +0100 Subject: [PATCH] Issue #2515018 by joshi.rohit100, sdstyles, joelpittet: Lowercase the instances of camelcase'd instanceOf in core for consistency --- core/includes/theme.inc | 2 +- core/lib/Drupal/Component/Datetime/DateTimePlus.php | 10 +++++----- core/lib/Drupal/Component/Utility/SafeMarkup.php | 2 +- .../Drupal/Core/Config/Entity/Query/Condition.php | 2 +- core/lib/Drupal/Core/Database/Query/Condition.php | 4 ++-- core/lib/Drupal/Core/Datetime/DateHelper.php | 8 ++++---- .../Drupal/Core/Datetime/Element/DateElementBase.php | 2 +- core/lib/Drupal/Core/Datetime/Element/Datelist.php | 12 ++++++------ core/lib/Drupal/Core/Datetime/Element/Datetime.php | 6 +++--- .../Core/Entity/Query/ConditionFundamentals.php | 2 +- core/lib/Drupal/Core/Entity/Query/Sql/Condition.php | 2 +- .../Core/Entity/Query/Sql/ConditionAggregate.php | 2 +- .../EventSubscriber/RedirectResponseSubscriber.php | 4 ++-- core/lib/Drupal/Core/Template/Attribute.php | 8 ++++---- core/lib/Drupal/Core/Template/TwigExtension.php | 2 +- core/modules/comment/src/CommentForm.php | 2 +- core/modules/datetime/src/DateTimeComputed.php | 2 +- 17 files changed, 36 insertions(+), 36 deletions(-) diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 106d30cbb15d..72369635f6d9 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -385,7 +385,7 @@ function theme_get_setting($setting_name, $theme = NULL) { * https://www.drupal.org/node/2575065 */ function theme_render_and_autoescape($arg) { - if ($arg instanceOf MarkupInterface) { + if ($arg instanceof MarkupInterface) { return (string) $arg; } $return = NULL; diff --git a/core/lib/Drupal/Component/Datetime/DateTimePlus.php b/core/lib/Drupal/Component/Datetime/DateTimePlus.php index 114d68cea276..4540b3b615d4 100644 --- a/core/lib/Drupal/Component/Datetime/DateTimePlus.php +++ b/core/lib/Drupal/Component/Datetime/DateTimePlus.php @@ -203,7 +203,7 @@ class DateTimePlus { $datetimeplus = new static('', $timezone, $settings); $date = \DateTime::createFromFormat($format, $time, $datetimeplus->getTimezone()); - if (!$date instanceOf \DateTime) { + if (!$date instanceof \DateTime) { throw new \Exception('The date cannot be created from a format.'); } else { @@ -212,10 +212,10 @@ class DateTimePlus { // re-creating the date/time formatted string and comparing it to the input. For // instance, an input value of '11' using a format of Y (4 digits) gets // created as '0011' instead of '2011'. - if ($date instanceOf DateTimePlus) { + if ($date instanceof DateTimePlus) { $test_time = $date->format($format, $settings); } - elseif ($date instanceOf \DateTime) { + elseif ($date instanceof \DateTime) { $test_time = $date->format($format); } $datetimeplus->setTimestamp($date->getTimestamp()); @@ -345,7 +345,7 @@ class DateTimePlus { */ protected function prepareTimezone($timezone) { // If the input timezone is a valid timezone object, use it. - if ($timezone instanceOf \DateTimezone) { + if ($timezone instanceof \DateTimezone) { $timezone_adjusted = $timezone; } @@ -356,7 +356,7 @@ class DateTimePlus { // Default to the system timezone when not explicitly provided. // If the system timezone is missing, use 'UTC'. - if (empty($timezone_adjusted) || !$timezone_adjusted instanceOf \DateTimezone) { + if (empty($timezone_adjusted) || !$timezone_adjusted instanceof \DateTimezone) { $system_timezone = date_default_timezone_get(); $timezone_name = !empty($system_timezone) ? $system_timezone : 'UTC'; $timezone_adjusted = new \DateTimeZone($timezone_name); diff --git a/core/lib/Drupal/Component/Utility/SafeMarkup.php b/core/lib/Drupal/Component/Utility/SafeMarkup.php index 8d6387c1172e..cd24daa713f9 100644 --- a/core/lib/Drupal/Component/Utility/SafeMarkup.php +++ b/core/lib/Drupal/Component/Utility/SafeMarkup.php @@ -41,7 +41,7 @@ class SafeMarkup { * \Drupal\Component\Render\MarkupInterface. */ public static function isSafe($string, $strategy = 'html') { - return $string instanceOf MarkupInterface; + return $string instanceof MarkupInterface; } /** diff --git a/core/lib/Drupal/Core/Config/Entity/Query/Condition.php b/core/lib/Drupal/Core/Config/Entity/Query/Condition.php index e6d2d523cd4b..3d378b9ec5a1 100644 --- a/core/lib/Drupal/Core/Config/Entity/Query/Condition.php +++ b/core/lib/Drupal/Core/Config/Entity/Query/Condition.php @@ -27,7 +27,7 @@ class Condition extends ConditionBase { $single_conditions = array(); $condition_groups = array(); foreach ($this->conditions as $condition) { - if ($condition['field'] instanceOf ConditionInterface) { + if ($condition['field'] instanceof ConditionInterface) { $condition_groups[] = $condition; } else { diff --git a/core/lib/Drupal/Core/Database/Query/Condition.php b/core/lib/Drupal/Core/Database/Query/Condition.php index 2b9574e3d422..fe9ac4f07caf 100644 --- a/core/lib/Drupal/Core/Database/Query/Condition.php +++ b/core/lib/Drupal/Core/Database/Query/Condition.php @@ -277,10 +277,10 @@ class Condition implements ConditionInterface, \Countable { $this->changed = TRUE; foreach ($this->conditions as $key => $condition) { if ($key !== '#conjunction') { - if ($condition['field'] instanceOf ConditionInterface) { + if ($condition['field'] instanceof ConditionInterface) { $this->conditions[$key]['field'] = clone($condition['field']); } - if ($condition['value'] instanceOf SelectInterface) { + if ($condition['value'] instanceof SelectInterface) { $this->conditions[$key]['value'] = clone($condition['value']); } } diff --git a/core/lib/Drupal/Core/Datetime/DateHelper.php b/core/lib/Drupal/Core/Datetime/DateHelper.php index 4ab47768b03b..0bc8fdb23029 100644 --- a/core/lib/Drupal/Core/Datetime/DateHelper.php +++ b/core/lib/Drupal/Core/Datetime/DateHelper.php @@ -447,7 +447,7 @@ class DateHelper { * The number of days in the month. */ public static function daysInMonth($date = NULL) { - if (!$date instanceOf DrupalDateTime) { + if (!$date instanceof DrupalDateTime) { $date = new DrupalDateTime($date); } if (!$date->hasErrors()) { @@ -467,7 +467,7 @@ class DateHelper { * The number of days in the year. */ public static function daysInYear($date = NULL) { - if (!$date instanceOf DrupalDateTime) { + if (!$date instanceof DrupalDateTime) { $date = new DrupalDateTime($date); } if (!$date->hasErrors()) { @@ -492,7 +492,7 @@ class DateHelper { * The number of the day in the week. */ public static function dayOfWeek($date = NULL) { - if (!$date instanceOf DrupalDateTime) { + if (!$date instanceof DrupalDateTime) { $date = new DrupalDateTime($date); } if (!$date->hasErrors()) { @@ -515,7 +515,7 @@ class DateHelper { * The name of the day in the week for that date. */ public static function dayOfWeekName($date = NULL, $abbr = TRUE) { - if (!$date instanceOf DrupalDateTime) { + if (!$date instanceof DrupalDateTime) { $date = new DrupalDateTime($date); } $dow = self::dayOfWeek($date); diff --git a/core/lib/Drupal/Core/Datetime/Element/DateElementBase.php b/core/lib/Drupal/Core/Datetime/Element/DateElementBase.php index 8e359158d549..16d0a176f150 100644 --- a/core/lib/Drupal/Core/Datetime/Element/DateElementBase.php +++ b/core/lib/Drupal/Core/Datetime/Element/DateElementBase.php @@ -66,7 +66,7 @@ abstract class DateElementBase extends FormElement { $min_year = $temp; } // If there is a current value, stretch the range to include it. - $value_year = $date instanceOf DrupalDateTime ? $date->format('Y') : ''; + $value_year = $date instanceof DrupalDateTime ? $date->format('Y') : ''; if (!empty($value_year)) { $min_year = min($value_year, $min_year); $max_year = max($value_year, $max_year); diff --git a/core/lib/Drupal/Core/Datetime/Element/Datelist.php b/core/lib/Drupal/Core/Datetime/Element/Datelist.php index 2caa4cad6b96..15ce2f362a52 100644 --- a/core/lib/Drupal/Core/Datetime/Element/Datelist.php +++ b/core/lib/Drupal/Core/Datetime/Element/Datelist.php @@ -67,7 +67,7 @@ class Datelist extends DateElementBase { } $timezone = !empty($element['#date_timezone']) ? $element['#date_timezone'] : NULL; $date = DrupalDateTime::createFromArray($input, $timezone); - if ($date instanceOf DrupalDateTime && !$date->hasErrors()) { + if ($date instanceof DrupalDateTime && !$date->hasErrors()) { static::incrementRound($date, $increment); } } @@ -76,7 +76,7 @@ class Datelist extends DateElementBase { $return = array_fill_keys($parts, ''); if (!empty($element['#default_value'])) { $date = $element['#default_value']; - if ($date instanceOf DrupalDateTime && !$date->hasErrors()) { + if ($date instanceof DrupalDateTime && !$date->hasErrors()) { static::incrementRound($date, $increment); foreach ($parts as $part) { switch ($part) { @@ -184,7 +184,7 @@ class Datelist extends DateElementBase { $date = !empty($element['#value']['object']) ? $element['#value']['object'] : NULL; // Set a fallback timezone. - if ($date instanceOf DrupalDateTime) { + if ($date instanceof DrupalDateTime) { $element['#date_timezone'] = $date->getTimezone()->getName(); } elseif (!empty($element['#timezone'])) { @@ -253,7 +253,7 @@ class Datelist extends DateElementBase { } $default = isset($element['#value'][$part]) && trim($element['#value'][$part]) != '' ? $element['#value'][$part] : ''; - $value = $date instanceOf DrupalDateTime && !$date->hasErrors() ? $date->format($format) : $default; + $value = $date instanceof DrupalDateTime && !$date->hasErrors() ? $date->format($format) : $default; if (!empty($value) && $part != 'ampm') { $value = intval($value); } @@ -320,7 +320,7 @@ class Datelist extends DateElementBase { else { // If the input is valid, set it. $date = $input['object']; - if ($date instanceOf DrupalDateTime && !$date->hasErrors()) { + if ($date instanceof DrupalDateTime && !$date->hasErrors()) { $form_state->setValueForElement($element, $date); } // If the input is invalid, set an error. @@ -364,7 +364,7 @@ class Datelist extends DateElementBase { */ protected static function incrementRound(&$date, $increment) { // Round minutes and seconds, if necessary. - if ($date instanceOf DrupalDateTime && $increment > 1) { + if ($date instanceof DrupalDateTime && $increment > 1) { $day = intval($date->format('j')); $hour = intval($date->format('H')); $second = intval(round(intval($date->format('s')) / $increment) * $increment); diff --git a/core/lib/Drupal/Core/Datetime/Element/Datetime.php b/core/lib/Drupal/Core/Datetime/Element/Datetime.php index 3eb7c844638d..a68927ab99a8 100644 --- a/core/lib/Drupal/Core/Datetime/Element/Datetime.php +++ b/core/lib/Drupal/Core/Datetime/Element/Datetime.php @@ -101,7 +101,7 @@ class Datetime extends DateElementBase { } else { $date = $element['#default_value']; - if ($date instanceOf DrupalDateTime && !$date->hasErrors()) { + if ($date instanceof DrupalDateTime && !$date->hasErrors()) { $input = array( 'date' => $date->format($element['#date_date_format']), 'time' => $date->format($element['#date_time_format']), @@ -223,7 +223,7 @@ class Datetime extends DateElementBase { $date = !empty($element['#value']['object']) ? $element['#value']['object'] : NULL; // Set a fallback timezone. - if ($date instanceOf DrupalDateTime) { + if ($date instanceof DrupalDateTime) { $element['#date_timezone'] = $date->getTimezone()->getName(); } elseif (empty($element['#timezone'])) { @@ -246,7 +246,7 @@ class Datetime extends DateElementBase { ); // Adds the HTML5 date attributes. - if ($date instanceOf DrupalDateTime && !$date->hasErrors()) { + if ($date instanceof DrupalDateTime && !$date->hasErrors()) { $html5_min = clone($date); $range = static::datetimeRangeYears($element['#date_year_range'], $date); $html5_min->setDate($range[0], 1, 1)->setTime(0, 0, 0); diff --git a/core/lib/Drupal/Core/Entity/Query/ConditionFundamentals.php b/core/lib/Drupal/Core/Entity/Query/ConditionFundamentals.php index b93e192c2b70..21667a7b7d20 100644 --- a/core/lib/Drupal/Core/Entity/Query/ConditionFundamentals.php +++ b/core/lib/Drupal/Core/Entity/Query/ConditionFundamentals.php @@ -87,7 +87,7 @@ abstract class ConditionFundamentals { */ public function __clone() { foreach ($this->conditions as $key => $condition) { - if ($condition['field'] instanceOf ConditionInterface) { + if ($condition['field'] instanceof ConditionInterface) { $this->conditions[$key]['field'] = clone($condition['field']); } } diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php b/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php index 1ee2c3da8444..53c611276261 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php @@ -37,7 +37,7 @@ class Condition extends ConditionBase { $sql_query = $conditionContainer instanceof SelectInterface ? $conditionContainer : $conditionContainer->sqlQuery; $tables = $this->query->getTables($sql_query); foreach ($this->conditions as $condition) { - if ($condition['field'] instanceOf ConditionInterface) { + if ($condition['field'] instanceof ConditionInterface) { $sql_condition = new SqlCondition($condition['field']->getConjunction()); // Add the SQL query to the object before calling this method again. $sql_condition->sqlQuery = $sql_query; diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php b/core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php index 9db67ea737cd..1f6965d1230c 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php @@ -30,7 +30,7 @@ class ConditionAggregate extends ConditionAggregateBase { $sql_query = ($conditionContainer instanceof SelectInterface) ? $conditionContainer : $conditionContainer->sqlQuery; $tables = new Tables($sql_query); foreach ($this->conditions as $condition) { - if ($condition['field'] instanceOf ConditionAggregateInterface) { + if ($condition['field'] instanceof ConditionAggregateInterface) { $sql_condition = new SqlCondition($condition['field']->getConjunction()); // Add the SQL query to the object before calling this method again. $sql_condition->sqlQuery = $sql_query; diff --git a/core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php index 09540eada8c0..435246d71b02 100644 --- a/core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php @@ -52,7 +52,7 @@ class RedirectResponseSubscriber implements EventSubscriberInterface { */ public function checkRedirectUrl(FilterResponseEvent $event) { $response = $event->getResponse(); - if ($response instanceOf RedirectResponse) { + if ($response instanceof RedirectResponse) { $request = $event->getRequest(); // Let the 'destination' query parameter override the redirect target. @@ -71,7 +71,7 @@ class RedirectResponseSubscriber implements EventSubscriberInterface { // Regardless of whether the target is the original one or the overridden // destination, ensure that all redirects are safe. - if (!($response instanceOf SecuredRedirectResponse)) { + if (!($response instanceof SecuredRedirectResponse)) { try { // SecuredRedirectResponse is an abstract class that requires a // concrete implementation. Default to LocalRedirectResponse, which diff --git a/core/lib/Drupal/Core/Template/Attribute.php b/core/lib/Drupal/Core/Template/Attribute.php index a794142798a8..611c13391e62 100644 --- a/core/lib/Drupal/Core/Template/Attribute.php +++ b/core/lib/Drupal/Core/Template/Attribute.php @@ -119,7 +119,7 @@ class Attribute implements \ArrayAccess, \IteratorAggregate, MarkupInterface { protected function createAttributeValue($name, $value) { // If the value is already an AttributeValueBase object, return it // straight away. - if ($value instanceOf AttributeValueBase) { + if ($value instanceof AttributeValueBase) { return $value; } // An array value or 'class' attribute name are forced to always be an @@ -184,7 +184,7 @@ class Attribute implements \ArrayAccess, \IteratorAggregate, MarkupInterface { } // Merge if there are values, just add them otherwise. - if (isset($this->storage['class']) && $this->storage['class'] instanceOf AttributeArray) { + if (isset($this->storage['class']) && $this->storage['class'] instanceof AttributeArray) { // Merge the values passed in from the class value array. $classes = array_merge($this->storage['class']->value(), $classes); $this->storage['class']->exchangeArray($classes); @@ -248,7 +248,7 @@ class Attribute implements \ArrayAccess, \IteratorAggregate, MarkupInterface { */ public function removeClass() { // With no class attribute, there is no need to remove. - if (isset($this->storage['class']) && $this->storage['class'] instanceOf AttributeArray) { + if (isset($this->storage['class']) && $this->storage['class'] instanceof AttributeArray) { $args = func_get_args(); $classes = array(); foreach ($args as $arg) { @@ -276,7 +276,7 @@ class Attribute implements \ArrayAccess, \IteratorAggregate, MarkupInterface { * Returns TRUE if the class exists, or FALSE otherwise. */ public function hasClass($class) { - if (isset($this->storage['class']) && $this->storage['class'] instanceOf AttributeArray) { + if (isset($this->storage['class']) && $this->storage['class'] instanceof AttributeArray) { return in_array($class, $this->storage['class']->value()); } else { diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php index 52291c3eee63..9d6dd1a4467a 100644 --- a/core/lib/Drupal/Core/Template/TwigExtension.php +++ b/core/lib/Drupal/Core/Template/TwigExtension.php @@ -415,7 +415,7 @@ class TwigExtension extends \Twig_Extension { } // Keep Twig_Markup objects intact to support autoescaping. - if ($autoescape && ($arg instanceOf \Twig_Markup || $arg instanceOf MarkupInterface)) { + if ($autoescape && ($arg instanceof \Twig_Markup || $arg instanceof MarkupInterface)) { return $arg; } diff --git a/core/modules/comment/src/CommentForm.php b/core/modules/comment/src/CommentForm.php index f89dfa2753bc..df59363c04fd 100644 --- a/core/modules/comment/src/CommentForm.php +++ b/core/modules/comment/src/CommentForm.php @@ -263,7 +263,7 @@ class CommentForm extends ContentEntityForm { public function buildEntity(array $form, FormStateInterface $form_state) { /** @var \Drupal\comment\CommentInterface $comment */ $comment = parent::buildEntity($form, $form_state); - if (!$form_state->isValueEmpty('date') && $form_state->getValue('date') instanceOf DrupalDateTime) { + if (!$form_state->isValueEmpty('date') && $form_state->getValue('date') instanceof DrupalDateTime) { $comment->setCreatedTime($form_state->getValue('date')->getTimestamp()); } else { diff --git a/core/modules/datetime/src/DateTimeComputed.php b/core/modules/datetime/src/DateTimeComputed.php index 184a490de063..fd150585079a 100644 --- a/core/modules/datetime/src/DateTimeComputed.php +++ b/core/modules/datetime/src/DateTimeComputed.php @@ -51,7 +51,7 @@ class DateTimeComputed extends TypedData { $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()) { + if ($date instanceof DrupalDateTime && !$date->hasErrors()) { $this->date = $date; } }