Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH PHP 8.1 compatibility #230

Merged
merged 1 commit into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 3 additions & 3 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($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 Expand Up @@ -788,7 +788,7 @@ public function save($data, $form)
$form->loadDataFrom($record);
$extra = ['record' => ['id' => $record->ID]];
$response = $this->getSchemaResponse($schemaId, $form, $errors, $extra);
$response->addHeader('X-Status', rawurlencode($message));
$response->addHeader('X-Status', rawurlencode($message ?? ''));
return $response;
}

Expand Down
8 changes: 4 additions & 4 deletions tests/behat/src/FixtureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function assertMessageBoxContainsText($text)
$mainContext = $this->getMainContext();
$mainContext
->assertSession()
->elementTextContains('css', '.message-box', str_replace('\\"', '"', $text));
->elementTextContains('css', '.message-box', str_replace('\\"', '"', $text ?? ''));
}

/**
Expand Down Expand Up @@ -180,7 +180,7 @@ public function iClickTheGalleryItem($name)
public function iSeeTheCampaignItem($negate, $name)
{
$item = $this->getCampaignItem($name);
$shouldSee = !trim($negate);
$shouldSee = !trim($negate ?? '');

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

preg_match_all(
'/"(?<content_class>[^"]+)"\s*=\s*"(?<identifier>[^"]+)"/',
$data,
$data ?? '',
$matches
);
$itemMap = array_combine($matches['content_class'], $matches['identifier']);
$itemMap = array_combine($matches['content_class'] ?? [], $matches['identifier'] ?? []);
foreach ($itemMap as $contentClass => $identifier) {
$class = $this->convertTypeToClass($contentClass);
$record = $this->getFixtureFactory()->get($class, $identifier);
Expand Down