SugarClub
SugarClub
  • User
  • Site
  • Search
  • User
  • Groups & Discussions
    Groups & Discussions
    • Product Forums
      Product-focused Q&A, discussions, best practices, fixes, and help
      Product Forums
      • Sugar Market
      • Sugar Sell & Enterprise
      • Sugar Serve
      • sales-i
    • User Groups
      Professional, Industry, Language
    • Get Involved
      Learn how to become a Raving Fan
    • Social Club
      Live, interactive, virtual meetups with other Sugar customers and Sugar’s Subject Matter experts!
    • Leadership Lounge
      Network with fellow organizational leaders, ask questions, and share insights
    • Developers
      Visit DevClub, the SugarClub group for Sugar Developers
      Developers
      • DevClub
      • Mobile Developers
      • Developer Builds
        Supplemental access level required. Inquiries: developers@sugarcrm.com
    • Additional Groups (Access Required)
      Groups that require special access will be displayed here. Contact sugarclub@sugarcrm.com for assistance. Click here to see all groups
      Additional Groups (Access Required)
      • SugarCloud Platform
  • Product Information
    Product Information
    • Release Central
      Find release-specific content to prepare for your next Sugar update
    • Documentation & Resources
      Looking to expand your Sugar knowledge? Explore our in-depth documentation and other helpful resources!
    • Product Update Blogs
      Updates about each Sugar product
    • Customer Stories »
      Case Studies by SugarCRM
  • Training & Certification
    Training & Certification
    • Training & Certification Home
      Live & On-Demand classes, Quick Videos, Sugar Certifications, and more!
    • Quick Videos
      Short videos about using Sugar
    • My SugarU Dashboard »
    • SugarU News & Updates
  • Adoption
    Adoption
    • Grow Adoption Framework
      Get started on your adoption journey and review the adoption resources from SugarCRM
  • Calendar
  • News
    News
    • Sugar News
    • SugarCRM.com News »
    • Dev Blog
    • SugarCRM Marketplace Blog
  • Help
    Help
    • Welcome to Sugar!
      New to Sugar? Get started here!
    • SugarClub Help & Instructions
      Learn more about SugarClub and find answers to questions about this site
    • New to SugarClub?
      Start your community journey here
    • Technical Support
      Sugar's support resources
      Technical Support
      • Case Portal »
        Access the SugarCRM Case Portal
      • Working with Sugar Support »
        Find out more about engaging with the SugarCRM Support team
      • SugarCloud Information
        Find information about SugarCloud service updates and site status. Contact sugarclub@sugarcrm.com to request access
  • More from Sugar
    More from Sugar
    • DevClub
    • PartnerClub
    • Support
    • SugarOutfitters Marketplace
    • sugarcrm.com
  • DevClub
  • PartnerClub
  • Support
  • Marketplace
  • sugarcrm.com
DevClub
DevClub
Dev Tutorials Automated PHP Compatibility Tool
  • Dev Blog
  • Answers & Best Practices
  • Developer On-boarding
  • Dev Tutorials
  • Developer Events
  • Event Recaps
  • Members
  • Developer Suggestions
  • Sub-Groups
  • More
  • Cancel
  • New
Click here to join this group and curate your SugarClub experience.
  • +On-Boarding Framework
  • +Customization Guides
  • +Modern UI Technical Guide
  • -Automated PHP Compatibility Tool
    • Rector Basic Setup
    • Prepare Rector for MLP/Addon
    • Prepare Rector for Customizations
    • Executing Rector
    • Keeping Compatibility
    • Troubleshooting Rector
    • PHP 7.4 Warnings to PHP8.2 Errors
  • Did you know? Copying related records is a breeze!
  • How to write code for SugarCloud webinar Q&A
  • HOW TO: enforce ACL on Tags
  • Programatically manage Dropdown List
  • Remove custom fields created via package installation
  • Sugar Developer Tools
  • Tutorial:  How to register custom platforms in Sugar instances via Platform extension
  • Adding a google reCAPTCHA in a Web-to-Lead form
  • Sugar Developer Blog Style Guide

Automated PHP Compatibility Tool

Why an Automated Compatibility Tool?

PHP is a rapidly evolving language, and new versions are regularly released with new features and security improvements. However, with each new version, there may be changes to the language syntax, behavior, and functionality that can cause compatibility issues with code written in earlier versions. It is crucial to keep the codebase clean and organized and maintain PHP compatibility when making customizations.

What's Rector and How can it help?

Rector is a powerful tool that automates the process of refactoring PHP code. It simplifies the codebase, making it easier to read, understand, and maintain.

By incorporating Rector into the customization process, you can save time and effort and reduce the risk of introducing bugs or coding standard violations. Rector can also help ensure that your customizations are aligned with the latest PHP versions and best practices, which can result in better performance, increased security, and a more stable system.

How does Rector work with Sugar?

Rector is not a grep, search and replace tool, it traverses the entire object hierarchies to "understand" what can and cannot be changed without impacting the code's functionality.

For example, if you extend a SugarBean, Rector needs the entire SugarBean class hierarchy loaded to make a decision in its ruling engine.

Having that in mind, Rector will need a working Sugar instance to execute and make recommendations (you can dry-run before it actually changes any code) and update your code automagically.

Who uses Rector?

Rector has been used by Sugar Engineering group for a few years now and has proven to be to work very well in our massive codebase to keep the code simple, clean and multi-php-version compatible. You as a developer must analyze what the tool presents to you as suggestions and make a decision to incorporate those changes. Remember, it's an automated tool that does what is told, so use it with caution.

Best Practices

  • Sugar recommends developers code their customizations in the latest Sugar Supported PHP version and keep it backward compatible using Rector.
  • Use git to keep track of updated files before you run Rector.
  • Run a first pass in your customizations using --dry-run so you can see exactly what Rector is/will change and decide to keep it.
  • Make a copy of your project/customization and run it. If you forget the --dry-run argument, it will change your files and can become pretty difficult to track.
  • Don't use this tool directly in production!

You can move on to the Basic Setup Phase:

  • Rector Basic Setup
  • Prepare Rector for MLP/Addon
  • Prepare Rector for Customizations
  • Executing Rector
  • Keeping Compatibility
  • Troubleshooting Rector

  • Share
  • History
  • More
  • Cancel
  • Sign in to reply
Related
Recommended