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) {
* 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;
......
......@@ -203,7 +203,7 @@ public static function createFromFormat($format, $time, $timezone = NULL, $setti
$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 @@ public static function createFromFormat($format, $time, $timezone = NULL, $setti
// 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 @@ protected function prepareTime($time) {
*/
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 @@ protected function prepareTimezone($timezone) {
// 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);
......
......@@ -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;
}
/**
......
......@@ -27,7 +27,7 @@ public function compile($configs) {
$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 {
......
......@@ -277,10 +277,10 @@ function __clone() {
$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']);
}
}
......
......@@ -447,7 +447,7 @@ public static function ampm($required = FALSE) {
* 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 @@ public static function daysInMonth($date = NULL) {
* 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 @@ public static function daysInYear($date = NULL) {
* 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 @@ public static function dayOfWeek($date = NULL) {
* 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);
......
......@@ -66,7 +66,7 @@ protected static function datetimeRangeYears($string, $date = NULL) {
$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);
......
......@@ -67,7 +67,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form
}
$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 @@ public static function valueCallback(&$element, $input, FormStateInterface $form
$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 @@ public static function processDatelist(&$element, FormStateInterface $form_state
$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 @@ public static function processDatelist(&$element, FormStateInterface $form_state
}
$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 @@ public static function validateDatelist(&$element, FormStateInterface $form_stat
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 @@ protected static function checkEmptyInputs($input, $parts) {
*/
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);
......
......@@ -101,7 +101,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form
}
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 @@ public static function processDatetime(&$element, FormStateInterface $form_state
$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 @@ public static function processDatetime(&$element, FormStateInterface $form_state
);
// 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);
......
......@@ -87,7 +87,7 @@ public function &conditions() {
*/
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']);
}
}
......
......@@ -37,7 +37,7 @@ public function compile($conditionContainer) {
$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;
......
......@@ -30,7 +30,7 @@ public function compile($conditionContainer) {
$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;
......
......@@ -52,7 +52,7 @@ public function __construct(UnroutedUrlAssemblerInterface $url_assembler, Reques
*/
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 @@ public function checkRedirectUrl(FilterResponseEvent $event) {
// 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
......
......@@ -119,7 +119,7 @@ public function offsetSet($name, $value) {
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 @@ public function addClass() {
}
// 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 @@ public function removeAttribute() {
*/
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 @@ public function removeClass() {
* 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 {
......
......@@ -415,7 +415,7 @@ public function escapeFilter(\Twig_Environment $env, $arg, $strategy = 'html', $
}
// 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;
}
......
......@@ -263,7 +263,7 @@ protected function actions(array $form, FormStateInterface $form_state) {
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 {
......
......@@ -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;
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;
}
}
......
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