Commit 1cd13a8f authored by alexpott's avatar alexpott

Issue #2515018 by joshi.rohit100, sdstyles, joelpittet: Lowercase the...

Issue #2515018 by joshi.rohit100, sdstyles, joelpittet: Lowercase the instances of camelcase'd instanceOf in core for consistency
parent 70d81c54
...@@ -385,7 +385,7 @@ function theme_get_setting($setting_name, $theme = NULL) { ...@@ -385,7 +385,7 @@ function theme_get_setting($setting_name, $theme = NULL) {
* https://www.drupal.org/node/2575065 * https://www.drupal.org/node/2575065
*/ */
function theme_render_and_autoescape($arg) { function theme_render_and_autoescape($arg) {
if ($arg instanceOf MarkupInterface) { if ($arg instanceof MarkupInterface) {
return (string) $arg; return (string) $arg;
} }
$return = NULL; $return = NULL;
......
...@@ -203,7 +203,7 @@ public static function createFromFormat($format, $time, $timezone = NULL, $setti ...@@ -203,7 +203,7 @@ public static function createFromFormat($format, $time, $timezone = NULL, $setti
$datetimeplus = new static('', $timezone, $settings); $datetimeplus = new static('', $timezone, $settings);
$date = \DateTime::createFromFormat($format, $time, $datetimeplus->getTimezone()); $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.'); throw new \Exception('The date cannot be created from a format.');
} }
else { else {
...@@ -212,10 +212,10 @@ public static function createFromFormat($format, $time, $timezone = NULL, $setti ...@@ -212,10 +212,10 @@ public static function createFromFormat($format, $time, $timezone = NULL, $setti
// re-creating the date/time formatted string and comparing it to the input. For // 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 // instance, an input value of '11' using a format of Y (4 digits) gets
// created as '0011' instead of '2011'. // created as '0011' instead of '2011'.
if ($date instanceOf DateTimePlus) { if ($date instanceof DateTimePlus) {
$test_time = $date->format($format, $settings); $test_time = $date->format($format, $settings);
} }
elseif ($date instanceOf \DateTime) { elseif ($date instanceof \DateTime) {
$test_time = $date->format($format); $test_time = $date->format($format);
} }
$datetimeplus->setTimestamp($date->getTimestamp()); $datetimeplus->setTimestamp($date->getTimestamp());
...@@ -345,7 +345,7 @@ protected function prepareTime($time) { ...@@ -345,7 +345,7 @@ protected function prepareTime($time) {
*/ */
protected function prepareTimezone($timezone) { protected function prepareTimezone($timezone) {
// If the input timezone is a valid timezone object, use it. // If the input timezone is a valid timezone object, use it.
if ($timezone instanceOf \DateTimezone) { if ($timezone instanceof \DateTimezone) {
$timezone_adjusted = $timezone; $timezone_adjusted = $timezone;
} }
...@@ -356,7 +356,7 @@ protected function prepareTimezone($timezone) { ...@@ -356,7 +356,7 @@ protected function prepareTimezone($timezone) {
// Default to the system timezone when not explicitly provided. // Default to the system timezone when not explicitly provided.
// If the system timezone is missing, use 'UTC'. // 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(); $system_timezone = date_default_timezone_get();
$timezone_name = !empty($system_timezone) ? $system_timezone : 'UTC'; $timezone_name = !empty($system_timezone) ? $system_timezone : 'UTC';
$timezone_adjusted = new \DateTimeZone($timezone_name); $timezone_adjusted = new \DateTimeZone($timezone_name);
......
...@@ -41,7 +41,7 @@ class SafeMarkup { ...@@ -41,7 +41,7 @@ class SafeMarkup {
* \Drupal\Component\Render\MarkupInterface. * \Drupal\Component\Render\MarkupInterface.
*/ */
public static function isSafe($string, $strategy = 'html') { public static function isSafe($string, $strategy = 'html') {
return $string instanceOf MarkupInterface; return $string instanceof MarkupInterface;
} }
/** /**
......
...@@ -27,7 +27,7 @@ public function compile($configs) { ...@@ -27,7 +27,7 @@ public function compile($configs) {
$single_conditions = array(); $single_conditions = array();
$condition_groups = array(); $condition_groups = array();
foreach ($this->conditions as $condition) { foreach ($this->conditions as $condition) {
if ($condition['field'] instanceOf ConditionInterface) { if ($condition['field'] instanceof ConditionInterface) {
$condition_groups[] = $condition; $condition_groups[] = $condition;
} }
else { else {
......
...@@ -277,10 +277,10 @@ function __clone() { ...@@ -277,10 +277,10 @@ function __clone() {
$this->changed = TRUE; $this->changed = TRUE;
foreach ($this->conditions as $key => $condition) { foreach ($this->conditions as $key => $condition) {
if ($key !== '#conjunction') { if ($key !== '#conjunction') {
if ($condition['field'] instanceOf ConditionInterface) { if ($condition['field'] instanceof ConditionInterface) {
$this->conditions[$key]['field'] = clone($condition['field']); $this->conditions[$key]['field'] = clone($condition['field']);
} }
if ($condition['value'] instanceOf SelectInterface) { if ($condition['value'] instanceof SelectInterface) {
$this->conditions[$key]['value'] = clone($condition['value']); $this->conditions[$key]['value'] = clone($condition['value']);
} }
} }
......
...@@ -447,7 +447,7 @@ public static function ampm($required = FALSE) { ...@@ -447,7 +447,7 @@ public static function ampm($required = FALSE) {
* The number of days in the month. * The number of days in the month.
*/ */
public static function daysInMonth($date = NULL) { public static function daysInMonth($date = NULL) {
if (!$date instanceOf DrupalDateTime) { if (!$date instanceof DrupalDateTime) {
$date = new DrupalDateTime($date); $date = new DrupalDateTime($date);
} }
if (!$date->hasErrors()) { if (!$date->hasErrors()) {
...@@ -467,7 +467,7 @@ public static function daysInMonth($date = NULL) { ...@@ -467,7 +467,7 @@ public static function daysInMonth($date = NULL) {
* The number of days in the year. * The number of days in the year.
*/ */
public static function daysInYear($date = NULL) { public static function daysInYear($date = NULL) {
if (!$date instanceOf DrupalDateTime) { if (!$date instanceof DrupalDateTime) {
$date = new DrupalDateTime($date); $date = new DrupalDateTime($date);
} }
if (!$date->hasErrors()) { if (!$date->hasErrors()) {
...@@ -492,7 +492,7 @@ public static function daysInYear($date = NULL) { ...@@ -492,7 +492,7 @@ public static function daysInYear($date = NULL) {
* The number of the day in the week. * The number of the day in the week.
*/ */
public static function dayOfWeek($date = NULL) { public static function dayOfWeek($date = NULL) {
if (!$date instanceOf DrupalDateTime) { if (!$date instanceof DrupalDateTime) {
$date = new DrupalDateTime($date); $date = new DrupalDateTime($date);
} }
if (!$date->hasErrors()) { if (!$date->hasErrors()) {
...@@ -515,7 +515,7 @@ public static function dayOfWeek($date = NULL) { ...@@ -515,7 +515,7 @@ public static function dayOfWeek($date = NULL) {
* The name of the day in the week for that date. * The name of the day in the week for that date.
*/ */
public static function dayOfWeekName($date = NULL, $abbr = TRUE) { public static function dayOfWeekName($date = NULL, $abbr = TRUE) {
if (!$date instanceOf DrupalDateTime) { if (!$date instanceof DrupalDateTime) {
$date = new DrupalDateTime($date); $date = new DrupalDateTime($date);
} }
$dow = self::dayOfWeek($date); $dow = self::dayOfWeek($date);
......
...@@ -66,7 +66,7 @@ protected static function datetimeRangeYears($string, $date = NULL) { ...@@ -66,7 +66,7 @@ protected static function datetimeRangeYears($string, $date = NULL) {
$min_year = $temp; $min_year = $temp;
} }
// If there is a current value, stretch the range to include it. // 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)) { if (!empty($value_year)) {
$min_year = min($value_year, $min_year); $min_year = min($value_year, $min_year);
$max_year = max($value_year, $max_year); $max_year = max($value_year, $max_year);
......
...@@ -67,7 +67,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form ...@@ -67,7 +67,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form
} }
$timezone = !empty($element['#date_timezone']) ? $element['#date_timezone'] : NULL; $timezone = !empty($element['#date_timezone']) ? $element['#date_timezone'] : NULL;
$date = DrupalDateTime::createFromArray($input, $timezone); $date = DrupalDateTime::createFromArray($input, $timezone);
if ($date instanceOf DrupalDateTime && !$date->hasErrors()) { if ($date instanceof DrupalDateTime && !$date->hasErrors()) {
static::incrementRound($date, $increment); static::incrementRound($date, $increment);
} }
} }
...@@ -76,7 +76,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form ...@@ -76,7 +76,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form
$return = array_fill_keys($parts, ''); $return = array_fill_keys($parts, '');
if (!empty($element['#default_value'])) { if (!empty($element['#default_value'])) {
$date = $element['#default_value']; $date = $element['#default_value'];
if ($date instanceOf DrupalDateTime && !$date->hasErrors()) { if ($date instanceof DrupalDateTime && !$date->hasErrors()) {
static::incrementRound($date, $increment); static::incrementRound($date, $increment);
foreach ($parts as $part) { foreach ($parts as $part) {
switch ($part) { switch ($part) {
...@@ -184,7 +184,7 @@ public static function processDatelist(&$element, FormStateInterface $form_state ...@@ -184,7 +184,7 @@ public static function processDatelist(&$element, FormStateInterface $form_state
$date = !empty($element['#value']['object']) ? $element['#value']['object'] : NULL; $date = !empty($element['#value']['object']) ? $element['#value']['object'] : NULL;
// Set a fallback timezone. // Set a fallback timezone.
if ($date instanceOf DrupalDateTime) { if ($date instanceof DrupalDateTime) {
$element['#date_timezone'] = $date->getTimezone()->getName(); $element['#date_timezone'] = $date->getTimezone()->getName();
} }
elseif (!empty($element['#timezone'])) { elseif (!empty($element['#timezone'])) {
...@@ -253,7 +253,7 @@ public static function processDatelist(&$element, FormStateInterface $form_state ...@@ -253,7 +253,7 @@ public static function processDatelist(&$element, FormStateInterface $form_state
} }
$default = isset($element['#value'][$part]) && trim($element['#value'][$part]) != '' ? $element['#value'][$part] : ''; $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') { if (!empty($value) && $part != 'ampm') {
$value = intval($value); $value = intval($value);
} }
...@@ -320,7 +320,7 @@ public static function validateDatelist(&$element, FormStateInterface $form_stat ...@@ -320,7 +320,7 @@ public static function validateDatelist(&$element, FormStateInterface $form_stat
else { else {
// If the input is valid, set it. // If the input is valid, set it.
$date = $input['object']; $date = $input['object'];
if ($date instanceOf DrupalDateTime && !$date->hasErrors()) { if ($date instanceof DrupalDateTime && !$date->hasErrors()) {
$form_state->setValueForElement($element, $date); $form_state->setValueForElement($element, $date);
} }
// If the input is invalid, set an error. // If the input is invalid, set an error.
...@@ -364,7 +364,7 @@ protected static function checkEmptyInputs($input, $parts) { ...@@ -364,7 +364,7 @@ protected static function checkEmptyInputs($input, $parts) {
*/ */
protected static function incrementRound(&$date, $increment) { protected static function incrementRound(&$date, $increment) {
// Round minutes and seconds, if necessary. // Round minutes and seconds, if necessary.
if ($date instanceOf DrupalDateTime && $increment > 1) { if ($date instanceof DrupalDateTime && $increment > 1) {
$day = intval($date->format('j')); $day = intval($date->format('j'));
$hour = intval($date->format('H')); $hour = intval($date->format('H'));
$second = intval(round(intval($date->format('s')) / $increment) * $increment); $second = intval(round(intval($date->format('s')) / $increment) * $increment);
......
...@@ -101,7 +101,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form ...@@ -101,7 +101,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form
} }
else { else {
$date = $element['#default_value']; $date = $element['#default_value'];
if ($date instanceOf DrupalDateTime && !$date->hasErrors()) { if ($date instanceof DrupalDateTime && !$date->hasErrors()) {
$input = array( $input = array(
'date' => $date->format($element['#date_date_format']), 'date' => $date->format($element['#date_date_format']),
'time' => $date->format($element['#date_time_format']), 'time' => $date->format($element['#date_time_format']),
...@@ -223,7 +223,7 @@ public static function processDatetime(&$element, FormStateInterface $form_state ...@@ -223,7 +223,7 @@ public static function processDatetime(&$element, FormStateInterface $form_state
$date = !empty($element['#value']['object']) ? $element['#value']['object'] : NULL; $date = !empty($element['#value']['object']) ? $element['#value']['object'] : NULL;
// Set a fallback timezone. // Set a fallback timezone.
if ($date instanceOf DrupalDateTime) { if ($date instanceof DrupalDateTime) {
$element['#date_timezone'] = $date->getTimezone()->getName(); $element['#date_timezone'] = $date->getTimezone()->getName();
} }
elseif (empty($element['#timezone'])) { elseif (empty($element['#timezone'])) {
...@@ -246,7 +246,7 @@ public static function processDatetime(&$element, FormStateInterface $form_state ...@@ -246,7 +246,7 @@ public static function processDatetime(&$element, FormStateInterface $form_state
); );
// Adds the HTML5 date attributes. // Adds the HTML5 date attributes.
if ($date instanceOf DrupalDateTime && !$date->hasErrors()) { if ($date instanceof DrupalDateTime && !$date->hasErrors()) {
$html5_min = clone($date); $html5_min = clone($date);
$range = static::datetimeRangeYears($element['#date_year_range'], $date); $range = static::datetimeRangeYears($element['#date_year_range'], $date);
$html5_min->setDate($range[0], 1, 1)->setTime(0, 0, 0); $html5_min->setDate($range[0], 1, 1)->setTime(0, 0, 0);
......
...@@ -87,7 +87,7 @@ public function &conditions() { ...@@ -87,7 +87,7 @@ public function &conditions() {
*/ */
public function __clone() { public function __clone() {
foreach ($this->conditions as $key => $condition) { foreach ($this->conditions as $key => $condition) {
if ($condition['field'] instanceOf ConditionInterface) { if ($condition['field'] instanceof ConditionInterface) {
$this->conditions[$key]['field'] = clone($condition['field']); $this->conditions[$key]['field'] = clone($condition['field']);
} }
} }
......
...@@ -37,7 +37,7 @@ public function compile($conditionContainer) { ...@@ -37,7 +37,7 @@ public function compile($conditionContainer) {
$sql_query = $conditionContainer instanceof SelectInterface ? $conditionContainer : $conditionContainer->sqlQuery; $sql_query = $conditionContainer instanceof SelectInterface ? $conditionContainer : $conditionContainer->sqlQuery;
$tables = $this->query->getTables($sql_query); $tables = $this->query->getTables($sql_query);
foreach ($this->conditions as $condition) { foreach ($this->conditions as $condition) {
if ($condition['field'] instanceOf ConditionInterface) { if ($condition['field'] instanceof ConditionInterface) {
$sql_condition = new SqlCondition($condition['field']->getConjunction()); $sql_condition = new SqlCondition($condition['field']->getConjunction());
// Add the SQL query to the object before calling this method again. // Add the SQL query to the object before calling this method again.
$sql_condition->sqlQuery = $sql_query; $sql_condition->sqlQuery = $sql_query;
......
...@@ -30,7 +30,7 @@ public function compile($conditionContainer) { ...@@ -30,7 +30,7 @@ public function compile($conditionContainer) {
$sql_query = ($conditionContainer instanceof SelectInterface) ? $conditionContainer : $conditionContainer->sqlQuery; $sql_query = ($conditionContainer instanceof SelectInterface) ? $conditionContainer : $conditionContainer->sqlQuery;
$tables = new Tables($sql_query); $tables = new Tables($sql_query);
foreach ($this->conditions as $condition) { foreach ($this->conditions as $condition) {
if ($condition['field'] instanceOf ConditionAggregateInterface) { if ($condition['field'] instanceof ConditionAggregateInterface) {
$sql_condition = new SqlCondition($condition['field']->getConjunction()); $sql_condition = new SqlCondition($condition['field']->getConjunction());
// Add the SQL query to the object before calling this method again. // Add the SQL query to the object before calling this method again.
$sql_condition->sqlQuery = $sql_query; $sql_condition->sqlQuery = $sql_query;
......
...@@ -52,7 +52,7 @@ public function __construct(UnroutedUrlAssemblerInterface $url_assembler, Reques ...@@ -52,7 +52,7 @@ public function __construct(UnroutedUrlAssemblerInterface $url_assembler, Reques
*/ */
public function checkRedirectUrl(FilterResponseEvent $event) { public function checkRedirectUrl(FilterResponseEvent $event) {
$response = $event->getResponse(); $response = $event->getResponse();
if ($response instanceOf RedirectResponse) { if ($response instanceof RedirectResponse) {
$request = $event->getRequest(); $request = $event->getRequest();
// Let the 'destination' query parameter override the redirect target. // Let the 'destination' query parameter override the redirect target.
...@@ -71,7 +71,7 @@ public function checkRedirectUrl(FilterResponseEvent $event) { ...@@ -71,7 +71,7 @@ public function checkRedirectUrl(FilterResponseEvent $event) {
// Regardless of whether the target is the original one or the overridden // Regardless of whether the target is the original one or the overridden
// destination, ensure that all redirects are safe. // destination, ensure that all redirects are safe.
if (!($response instanceOf SecuredRedirectResponse)) { if (!($response instanceof SecuredRedirectResponse)) {
try { try {
// SecuredRedirectResponse is an abstract class that requires a // SecuredRedirectResponse is an abstract class that requires a
// concrete implementation. Default to LocalRedirectResponse, which // concrete implementation. Default to LocalRedirectResponse, which
......
...@@ -119,7 +119,7 @@ public function offsetSet($name, $value) { ...@@ -119,7 +119,7 @@ public function offsetSet($name, $value) {
protected function createAttributeValue($name, $value) { protected function createAttributeValue($name, $value) {
// If the value is already an AttributeValueBase object, return it // If the value is already an AttributeValueBase object, return it
// straight away. // straight away.
if ($value instanceOf AttributeValueBase) { if ($value instanceof AttributeValueBase) {
return $value; return $value;
} }
// An array value or 'class' attribute name are forced to always be an // An array value or 'class' attribute name are forced to always be an
...@@ -184,7 +184,7 @@ public function addClass() { ...@@ -184,7 +184,7 @@ public function addClass() {
} }
// Merge if there are values, just add them otherwise. // 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. // Merge the values passed in from the class value array.
$classes = array_merge($this->storage['class']->value(), $classes); $classes = array_merge($this->storage['class']->value(), $classes);
$this->storage['class']->exchangeArray($classes); $this->storage['class']->exchangeArray($classes);
...@@ -248,7 +248,7 @@ public function removeAttribute() { ...@@ -248,7 +248,7 @@ public function removeAttribute() {
*/ */
public function removeClass() { public function removeClass() {
// With no class attribute, there is no need to remove. // 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(); $args = func_get_args();
$classes = array(); $classes = array();
foreach ($args as $arg) { foreach ($args as $arg) {
...@@ -276,7 +276,7 @@ public function removeClass() { ...@@ -276,7 +276,7 @@ public function removeClass() {
* Returns TRUE if the class exists, or FALSE otherwise. * Returns TRUE if the class exists, or FALSE otherwise.
*/ */
public function hasClass($class) { 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()); return in_array($class, $this->storage['class']->value());
} }
else { else {
......
...@@ -415,7 +415,7 @@ public function escapeFilter(\Twig_Environment $env, $arg, $strategy = 'html', $ ...@@ -415,7 +415,7 @@ public function escapeFilter(\Twig_Environment $env, $arg, $strategy = 'html', $
} }
// Keep Twig_Markup objects intact to support autoescaping. // 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; return $arg;
} }
......
...@@ -263,7 +263,7 @@ protected function actions(array $form, FormStateInterface $form_state) { ...@@ -263,7 +263,7 @@ protected function actions(array $form, FormStateInterface $form_state) {
public function buildEntity(array $form, FormStateInterface $form_state) { public function buildEntity(array $form, FormStateInterface $form_state) {
/** @var \Drupal\comment\CommentInterface $comment */ /** @var \Drupal\comment\CommentInterface $comment */
$comment = parent::buildEntity($form, $form_state); $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()); $comment->setCreatedTime($form_state->getValue('date')->getTimestamp());
} }
else { else {
......
...@@ -51,7 +51,7 @@ public function getValue($langcode = NULL) { ...@@ -51,7 +51,7 @@ public function getValue($langcode = NULL) {
$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 { try {
$date = DrupalDateTime::createFromFormat($storage_format, $value, DATETIME_STORAGE_TIMEZONE); $date = DrupalDateTime::createFromFormat($storage_format, $value, DATETIME_STORAGE_TIMEZONE);
if ($date instanceOf DrupalDateTime && !$date->hasErrors()) { if ($date instanceof DrupalDateTime && !$date->hasErrors()) {
$this->date = $date; $this->date = $date;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment