Skip to content

Conversation

@physikerwelt
Copy link
Contributor

@physikerwelt physikerwelt commented Mar 30, 2025

  • Add one use of namespaced version of Html found as well. Though, this was not checked systematically.

Bug: T166010

Summary by CodeRabbit

  • Chores
    • Enhanced internal consistency by updating media dependency references to fully qualified namespaces.
  • Tests
    • Aligned test code with the revised dependency imports for simplified class usage.

These changes improve code clarity and maintainability without affecting any visible functionality.

* Add one use of namespaced version of Html found as well. Though, this
  was not checked systematically.

Bug: T166010
@coderabbitai
Copy link

coderabbitai bot commented Mar 30, 2025

📝 Walkthrough

Walkthrough

The changes update the PHP import statements in several service and test classes to use fully qualified namespaces. The modifications explicitly specify the namespaces for classes such as Html, Title, Linker, and TitleFactory, replacing generic imports with their MediaWiki counterparts. No alterations have been made to any business logic or functionality.

Changes

File(s) Change Summary
src/Services/ImageLinkFormatter.php Replaced use Html; with use MediaWiki\Html\Html; and use Title; with use MediaWiki\Title\Title;
src/Services/ImageLinker.php, src/Services/LocalImageLinker.php Replaced use Title; with use MediaWiki\Title\Title;
src/Services/InlineImageFormatter.php Replaced use Html; with use MediaWiki\Html\Html;, use Linker; with use MediaWiki\Linker\Linker;, and use Title; with use MediaWiki\Title\Title;
src/Services/LocalMediaRdfBuilder.php Replaced use TitleFactory; with use MediaWiki\Title\TitleFactory;
tests/php/Unit/LocalImageLinkerTest.php Added use MediaWiki\Title\Title; and updated instantiation from \Title::newFromText('MyPage') to Title::newFromText('MyPage')

Possibly related PRs

Suggested reviewers

  • JeroenDeDauw
  • malberts

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9adfc7e and 15a79e7.

📒 Files selected for processing (6)
  • src/Services/ImageLinkFormatter.php (1 hunks)
  • src/Services/ImageLinker.php (1 hunks)
  • src/Services/InlineImageFormatter.php (1 hunks)
  • src/Services/LocalImageLinker.php (1 hunks)
  • src/Services/LocalMediaRdfBuilder.php (1 hunks)
  • tests/php/Unit/LocalImageLinkerTest.php (2 hunks)
🔇 Additional comments (10)
tests/php/Unit/LocalImageLinkerTest.php (2)

7-7: Update to Namespaced Title Import
The change to import MediaWiki\Title\Title instead of using the global Title improves clarity and avoids potential ambiguities. This aligns with the namespacing approach adopted across the codebase.


19-19: Using Imported Title Class Directly
Changing the instantiation from \Title::newFromText( 'MyPage' ) to Title::newFromText( 'MyPage' ) leverages the namespaced import correctly and simplifies the code.

src/Services/LocalImageLinker.php (1)

7-7: Correct Namespaced Title Import in Service
The update from use Title; to use MediaWiki\Title\Title; ensures that the proper Title class is referenced. This change increases code clarity and consistency.

src/Services/ImageLinker.php (1)

7-7: Consistent Update for Title Import
Similar to other service files, updating the import to use MediaWiki\Title\Title; removes ambiguity and guarantees that the correct Title class is used in type hints and method definitions.

src/Services/LocalMediaRdfBuilder.php (1)

8-9: Namespaced TitleFactory Import Update
Changing the import from the generic TitleFactory to MediaWiki\Title\TitleFactory makes the dependency explicit. This brings clarity and consistency when constructing title objects within the RDF builder.

src/Services/ImageLinkFormatter.php (2)

8-10: Updated Namespaced Imports for Html and Title
Replacing use Html; with use MediaWiki\Html\Html; and use Title; with use MediaWiki\Title\Title; enhances clarity by clearly indicating the source of these classes. This update aligns with the overall codebase migration to fully qualified namespaces.


38-42: Validation of Title Safety Check
The use of Title::makeTitleSafe( NS_MAIN, $fileName ) properly validates the file name and ensures a valid title is returned. The subsequent null check is an appropriate safeguard before generating the HTML element.

src/Services/InlineImageFormatter.php (3)

9-9: Use fully qualified namespace for Html.
The updated import statement (use MediaWiki\Html\Html;) correctly replaces any generic or ambiguous reference with the full namespace. This improves code clarity and ensures that the proper version of the Html class is used.


12-12: Use fully qualified namespace for Linker.
The change to use MediaWiki\Linker\Linker; ensures that the correct Linker class is referenced, reducing the risk of conflicts with similarly named classes in other namespaces.


15-15: Use fully qualified namespace for Title.
Updating the import to use MediaWiki\Title\Title; aligns with the namespaced approach. This is important since the code later calls static methods (e.g., Title::makeTitleSafe), and the full namespace guarantees the proper functionality.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@JeroenDeDauw JeroenDeDauw merged commit 581280d into ProfessionalWiki:master Mar 30, 2025
7 of 9 checks passed
@JeroenDeDauw
Copy link
Member

Releasing this in #44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants