Skip to content

Commit

Permalink
ENH PHP 8.1 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Apr 4, 2022
1 parent 419f673 commit 2463cb6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/AddToCampaignHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected function getAvailableChangeSets()
*/
protected function getInChangeSets($object)
{
$inChangeSetIDs = array_unique(ChangeSetItem::get_for_object($object)->column('ChangeSetID'));
$inChangeSetIDs = array_unique(ChangeSetItem::get_for_object($object)->column('ChangeSetID') ?: []);
if ($inChangeSetIDs > 0) {
$changeSets = $this->getAvailableChangeSets()->filter([
'ID' => $inChangeSetIDs,
Expand Down
4 changes: 2 additions & 2 deletions src/CampaignAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ protected function getPlaceholderGroups()
$classes = Config::inst()->get(ChangeSet::class, 'important_classes');

foreach ($classes as $class) {
if (!class_exists($class)) {
if (!class_exists((string) $class)) {
continue;
}
/** @var DataObject $item */
Expand Down Expand Up @@ -441,7 +441,7 @@ public function readCampaign(HTTPRequest $request)
$accepts = $request->getAcceptMimetypes();

//accept 'text/json' for legacy reasons
if (in_array('application/json', $accepts) || in_array('text/json', $accepts)) {
if (in_array('application/json', $accepts ?: []) || in_array('text/json', $accepts ?: [])) {
$response->addHeader('Content-Type', 'application/json');
if (!$request->param('Name')) {
return (new HTTPResponse(null, 400));
Expand Down
4 changes: 2 additions & 2 deletions tests/behat/src/FixtureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function iClickTheGalleryItem($name)
public function iSeeTheCampaignItem($negate, $name)
{
$item = $this->getCampaignItem($name);
$shouldSee = !trim($negate);
$shouldSee = !trim((string) $negate);

if ($shouldSee) {
Assert::assertNotNull($item, sprintf('Item "%s" could not be found', $name));
Expand Down Expand Up @@ -219,7 +219,7 @@ public function stepCreateCampaignWithItems($id, $data)

preg_match_all(
'/"(?<content_class>[^"]+)"\s*=\s*"(?<identifier>[^"]+)"/',
$data,
(string) $data,
$matches
);
$itemMap = array_combine($matches['content_class'], $matches['identifier']);
Expand Down

0 comments on commit 2463cb6

Please sign in to comment.