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

Remove final from render #105

Merged
merged 4 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct()
/**
* Render the component.
*/
final public function render(): mixed
public function render(): mixed
{
$alias = $this->getAlias();

Expand Down
4 changes: 3 additions & 1 deletion src/ComponentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected function requirePath(string $path): void

$__path = $path;

CompileContext::instance()->variables = (static function () use ($__path) {
$variables = (static function () use ($__path) {
require $__path;

return array_map(function (mixed $variable) {
Expand All @@ -79,9 +79,11 @@ protected function requirePath(string $path): void
: $variable;
}, get_defined_vars());
})();
CompileContext::instance()->variables = array_merge(CompileContext::instance()->variables, $variables);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this unrelated change made?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@taylorotwell sorry, yep this was needed further down the track of my implementation. The mingle lib needs a component method defined to point to the react/vue component it should render, and I wanted to add it automatically as I'm extracting the component from the blade file itself (see https://github.com/deanmcpherson/mingle/blob/main/src/Mingle.php), but variables added to the default array before this is run were getting overridden here.

} finally {
ob_get_clean();
}

}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/VoltServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected function registerTestingMacros(): void
$component = FragmentMap::get($component);
}

return $this->assertSeeLivewire($component); // @phpstan-ignore-line
return $this->assertSeeLivewire($component);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why was this change made?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The static analysis in the github action for the PR threw an error because there was nothing to ignore anymore. I suspect the original suppression was because of the use of final? Happy to revert

});

TestResponse::macro('assertDontSeeVolt', function ($component) {
Expand All @@ -126,7 +126,7 @@ protected function registerTestingMacros(): void
$component = FragmentMap::get($component);
}

return $this->assertDontSeeLivewire($component); // @phpstan-ignore-line
return $this->assertDontSeeLivewire($component);
});
}
}
Loading