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

Utils/CustomPrefixes: minor improvements #357

Merged
merged 2 commits into from
Dec 14, 2023
Merged
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
28 changes: 14 additions & 14 deletions Yoast/Utils/CustomPrefixesTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
trait CustomPrefixesTrait {

/**
* The prefix which are allowed to be used.
* The prefixes which are allowed to be used.
*
* The prefix(es) should be in the exact case as expected.
*
Expand All @@ -21,16 +21,16 @@ trait CustomPrefixesTrait {
* hook names are being deprecated and the new hooks put in place -,
* two prefixes (old and new) will be allowed.
* At a future point in time, this property should be changed
* to allow only a single string.}}
* to allow only a single string.}
*
* @var string[]|string
* @var array<string>
*/
public $prefixes = [];

/**
* Target prefixes after validation.
*
* @var string[]
* @var array<string>
*/
protected $validated_prefixes = [];

Expand All @@ -39,7 +39,7 @@ trait CustomPrefixesTrait {
*
* Prevents having to do the same prefix validation over and over again.
*
* @var string[]
* @var array<string>
*/
protected $previous_prefixes = [];

Expand All @@ -52,7 +52,7 @@ trait CustomPrefixesTrait {
*
* @return void
*/
protected function validate_prefixes() {
final protected function validate_prefixes() {
if ( $this->previous_prefixes === $this->prefixes ) {
return;
}
Expand Down Expand Up @@ -94,9 +94,9 @@ protected function validate_prefixes() {
/**
* Overloadable method to do custom prefix filtering prior to validation.
*
* @param string[] $prefixes The unvalidated prefixes.
* @param array<string> $prefixes The unvalidated prefixes.
*
* @return string[]
* @return array<string>
*/
protected function filter_prefixes( $prefixes ) {
return $prefixes;
Expand All @@ -105,11 +105,11 @@ protected function filter_prefixes( $prefixes ) {
/**
* Filter out all prefixes which don't contain a namespace separator.
*
* @param string[] $prefixes The unvalidated prefixes.
* @param array<string> $prefixes The unvalidated prefixes.
*
* @return string[]
* @return array<string>
*/
protected function filter_allow_only_namespace_prefixes( $prefixes ) {
final protected function filter_allow_only_namespace_prefixes( $prefixes ) {
$filtered = [];
foreach ( $prefixes as $prefix ) {
if ( \strpos( $prefix, '\\' ) === false ) {
Expand All @@ -125,11 +125,11 @@ protected function filter_allow_only_namespace_prefixes( $prefixes ) {
/**
* Filter out all prefixes which only contain lowercase characters.
*
* @param string[] $prefixes The unvalidated prefixes.
* @param array<string> $prefixes The unvalidated prefixes.
*
* @return string[]
* @return array<string>
*/
protected function filter_exclude_lowercase_prefixes( $prefixes ) {
final protected function filter_exclude_lowercase_prefixes( $prefixes ) {
$filtered = [];
foreach ( $prefixes as $prefix ) {
if ( \strtolower( $prefix ) === $prefix ) {
Expand Down