The expression $segment of type null|string is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.
In PHP, under loose comparison (like ==, or !=, or switch conditions),
values of different types might be equal.
For string values, the empty string '' is a special case, in particular
the following results might be unexpected:
''==false// true''==null// true'ab'==false// false'ab'==null// false// It is often better to use strict comparison''===false// false''===null// false
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
112
{
113
$segment = isset($this->urlParams['Profile'])
114
? $this->urlParams['Profile']
115
: null;
116
if (!$segment) {
117
return null;
118
}
119
120
// url encode unless it's multibyte (already pre-encoded in the database)
121
// see https://github.com/silverstripe/silverstripe-cms/pull/2384
The expression $year of type integer|false is loosely compared to false; this is ambiguous if the integer can be zero. You might want to explicitly use === null instead.
In PHP, under loose comparison (like ==, or !=, or switch conditions),
values of different types might be equal.
For integer values, zero is a special case, in particular the following
results might be unexpected:
0==false// true0==null// true123==false// false123==null// false// It is often better to use strict comparison0===false// false0===null// false
Loading history...
237
return false;
238
}
239
240
if (preg_match('/^[0-9]{1,2}$/', $day) && checkdate($month, $day, $year)) {
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
The expression $segment of type string|null is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.
In PHP, under loose comparison (like ==, or !=, or switch conditions),
values of different types might be equal.
For string values, the empty string '' is a special case, in particular
the following results might be unexpected:
''==false// true''==null// true'ab'==false// false'ab'==null// false// It is often better to use strict comparison''===false// false''===null// false
Loading history...
286
return null;
287
}
288
289
/** @var BlogTag $tag */
290
$tag = $this
291
->data()
292
->Tags(false)// Show "no results" instead of "404"
293
->find('URLSegment', $segment);
294
return $tag;
295
}
296
297
/**
298
* Get URLSegment of selected category (not: URLEncoded based on multibyte)
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
303
{
304
$segment = isset($this->urlParams['Tag'])
305
? $this->urlParams['Tag']
306
: null;
307
308
// url encode unless it's multibyte (already pre-encoded in the database)
309
// see https://github.com/silverstripe/silverstripe-cms/pull/2384
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
The expression $segment of type string|null is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.
In PHP, under loose comparison (like ==, or !=, or switch conditions),
values of different types might be equal.
For string values, the empty string '' is a special case, in particular
the following results might be unexpected:
''==false// true''==null// true'ab'==false// false'ab'==null// false// It is often better to use strict comparison''===false// false''===null// false
Loading history...
351
return null;
352
}
353
354
/** @var BlogCategory $category */
355
$category = $this
356
->data()
357
->Categories(false)// Show "no results" instead of "404"
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
368
{
369
$segment = isset($this->urlParams['Category'])
370
? $this->urlParams['Category']
371
: null;
372
373
// url encode unless it's multibyte (already pre-encoded in the database)
374
// see https://github.com/silverstripe/silverstripe-cms/pull/2384
The expression $this->getArchiveYear() of type integer|false is loosely compared to true; this is ambiguous if the integer can be zero. You might want to explicitly use !== null instead.
In PHP, under loose comparison (like ==, or !=, or switch conditions),
values of different types might be equal.
For integer values, zero is a special case, in particular the following
results might be unexpected:
0==false// true0==null// true123==false// false123==null// false// It is often better to use strict comparison0===false// false0===null// false
The expression $items of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an
empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using empty(..) or !empty(...) instead.
It seems like $posts of type object<SilverStripe\ORM\SS_List> or array<integer,object<Sil...e\Blog\Model\BlogPost>> is incompatible with the declared type object<SilverStripe\ORM\DataList> of property $blogPosts.
Our type inference engine has found an assignment to a property that is incompatible
with the declared type of that property.
Either this assignment is in error or the assigned type should be added
to the documentation/type hint for that property..
Loading history...
504
return $this;
505
}
506
507
/**
508
* Returns a list of paginated blog posts based on the BlogPost dataList.
The expression $year of type integer|false is loosely compared to true; this is ambiguous if the integer can be zero. You might want to explicitly use !== null instead.
In PHP, under loose comparison (like ==, or !=, or switch conditions),
values of different types might be equal.
For integer values, zero is a special case, in particular the following
results might be unexpected:
0==false// true0==null// true123==false// false123==null// false// It is often better to use strict comparison0===false// false0===null// false
Loading history...
593
if ($month) {
594
$date = sprintf('%s-%s-01', $year, $month);
595
596
if ($day) {
597
$date = sprintf('%s-%s-%s', $year, $month, $day);
598
}
599
} else {
600
$date = sprintf('%s-01-01', $year);
601
}
602
603
$obj = DBDatetime::create('date');
604
$obj->setValue($date);
605
return $obj;
606
}
607
608
return null;
609
}
610
611
/**
612
* Returns a link to the RSS feed.
613
*
614
* @return string
615
*/
616
public function getRSSLink()
617
{
618
return $this->Link('rss');
619
}
620
621
/**
622
* Displays an RSS feed of the given blog posts.
623
*
624
* @param DataList $blogPosts
625
* @param string $link
626
*
627
* @return DBHTMLText
628
*/
629
protected function rssFeed($blogPosts, $link)
630
{
631
$rss = RSSFeed::create(
632
$blogPosts,
633
$link,
634
$this->getMetaTitle(),
635
$this->data()->MetaDescription
636
);
637
638
$this->extend('updateRss', $rss);
639
640
return $rss->outputToBrowser();
641
}
642
643
/**
644
* Returns true if the $Rss sub-action for categories/tags has been set to "rss"
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: