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 isset() and replaced with array_key_exists() #184

Merged
merged 2 commits into from
Jan 4, 2024
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
8 changes: 5 additions & 3 deletions src/Services/View/Component/Component_Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ class Component_Compiler {
*/
private array $component_aliases = array();

/** @param array<string, string> $component_aliases */
/**
* @param array<string, string> $component_aliases
*/
public function __construct( string $component_base_path = '', array $component_aliases = array() ) {
$this->component_base_path = $component_base_path;
$this->component_aliases = \apply_filters( Hooks::COMPONENT_ALIASES, $component_aliases );
Expand All @@ -76,7 +78,7 @@ private function get_component_path( Component $component ): string {
// Check aliases.
$aliases = \apply_filters( Hooks::COMPONENT_ALIASES, $this->component_aliases );

if ( isset( $aliases[ get_class( $component ) ] ) ) {
if ( \array_key_exists( get_class( $component ), $this->component_aliases ) ) {
return esc_attr( $aliases[ get_class( $component ) ] );
}

Expand Down Expand Up @@ -104,7 +106,7 @@ private function get_component_path( Component $component ): string {
/**
* Attempts to extract a defined Annotation from component class doc block.
*
* @param string $annotation
* @param string $annotation
* @param Component $component
* @return string|null
*/
Expand Down
2 changes: 2 additions & 0 deletions tests/Fixtures/views/components/alias-dir/some-view.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- This is the same as the P tag, just a unique path -->
<p class="<?php echo $class; ?>">ALIAS <?php $this->component( $span ); ?></p>
Loading