refactor(util): clean up script-related methods in OCP\Util#61018
Draft
joshtrichards wants to merge 9 commits into
Draft
refactor(util): clean up script-related methods in OCP\Util#61018joshtrichards wants to merge 9 commits into
joshtrichards wants to merge 9 commits into
Conversation
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Also rename scriptOrderValue -> scriptPriority and misc formatting Signed-off-by: Josh <josh.t.richards@gmail.com>
Admittedly some typing/refactoring not directly related to addScript, but this class needed a little love. Signed-off-by: Josh <josh.t.richards@gmail.com>
… key is always initialized Signed-off-by: Josh <josh.t.richards@gmail.com>
addScript() states it accepts null for $file, but the implementation immediately builds a script path from it, which would become "$application/js/" or "js/". I don’t see a valid use case for that, and addInitScript() already requires a non-null filename. Tightening addScript() to string $file is technically a BC, but I believe it's really just correcting the contract to reflect reality. Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR refactors the script registration methods in
OCP\Utilfor clarity and safety. It improves docblocks and naming, adds missing type declarations, fixes a couple of array-initialization issues, and makes translation asset registration idempotent earlier in the pipeline.Changes
scriptOrderValue()toscriptPriority()UtilmethodsaddScript()’s$fileparameter from?stringtostringaddScript()andaddTranslations()isset()for$scriptDeps, local variable renames, docblock cleanup)Behavior notes
addScript()no longer acceptsnullfor$file(technically a BC, but it would have never worked anyhow)Scope note
This branch also currently contains a few small non-script-adjacent
Util.phpcleanups (getServerHostName(),numericToNumber(), and related docblocks). I can split those out if preferred.Follow-up ideas
Checklist
3. to review, feature component)stable32)AI (if applicable)