sybrew/the-seo-framework

Remove (most) pass-by-ref variables

Closed this issue · 2 comments

sybrew commented

These variables are difficult to follow because PHP provides no structure to easily recognize them via the caller.

Follow-up from #634 (comment):

I found 13 pass-by-reference methods, and I'm unsure how you found more. These helper methods could be refactored into something more legible, but the benefit of this is arguable. Of the ones I found, I think count_down_persistent_notice() should stay until a major refactorization, and fix_generation_args() should stay indefinitely. The helper methods in inc/classes/sanitize.class.php are unused and can be deleted. The three helper methods in inc/classes/generate-title.class.php are to remain but should be slowly deprecated and replaced.

image

sybrew commented

The upcoming internal function normalize_generation_args() (formerly fix_generation_args()) will be exempted from this change for performance reasons.

Otherwise, we cannot write (either):

normalize_generation_args( $args )

isset( $args ) and normalize_generation_args( $args )

But, have to write (more expensive and difficult to read):

$args = normalize_generation_args( $args );

isset( $args ) and $args = normalize_generation_args( $args );

Only a few exceptions remain:

  1. array_walk() callbacks' first parameter (as is necessary for this function to work).
  2. \The_SEO_Framework\normalize_generation_args()'s first parameter.