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

fixes #30 #31

Open
wants to merge 1 commit into
base: release_8
Choose a base branch
from
Open

Conversation

okaufman
Copy link
Contributor

@okaufman okaufman commented Sep 3, 2024

I added a check with array_key_exists() to fix #30

@@ -525,20 +525,24 @@ protected function setStyleFromProps(ilTemplate $tpl, array $properties)
$tpl->setVariable('RATIO', $ratio);
$tpl->setVariable('MAX-WIDTH', $properties[self::PROP_WIDTH]);
$tpl->setVariable('MAX-HEIGHT', $properties[self::PROP_HEIGHT]);
if ($properties[self::PROP_RESPONSIVE] != false) {
$tpl->setVariable('WIDTH', 'width:100%;');
if (array_key_exists(self::PROP_RESPONSIVE, $properties)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to use a Null Coalescing Operator:

if ((bool)($properties[self::PROP_RESPONSIVE] ?? false) === true) {
    $tpl->setVariable('WIDTH', 'width:100%;');
}

as well as a more strict type handling, and last but not least turning the logic from != false to === true which is more readable.

$tpl->setVariable('CONTAINER_STYLE', 'text-align:left;');
break;
if (array_key_exists(self::PROP_POSITION, $properties)) {
switch ($properties[self::PROP_POSITION]) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, instead of using array_key_exists you can just use

switch ($properties[self::PROP_POSITION] ?? null) {

@rfcmaXi
Copy link
Contributor

rfcmaXi commented Sep 25, 2024

Can we fix the error and transfer it to the production version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants