Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

(Future work) Define statement-level helper (Top) to bypass prefixing #176

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

totten
Copy link
Member

@totten totten commented Aug 7, 2023

This is a draft towards simplify scoper.inc.php. I don't need the simplification at quite this minute, and it would need some more work/testing. But I want to keep the patch around as a reminder for how to do it (*the next that scoper.inc.php comes to mind).

Before

  • Bootstrap.php and CmsBootstrap.php need to reference various UF symbols (drupal_foobar, JFactory, wp_*, etc.)
  • scoper.inc.php has a bunch of exclusions so that namespace-prefixes are not applied to these symbols.
  • The exclusions are sync'd up between cv.git and civix.git.

After

  • Bootstrap.php and CmsBootstrap.php' reference various UF symbols ( Top::call('drupal_foobar'), Top::call('JFactory::getUser')`, etc)
  • scoper.inc.php don't need those exclusions.
  • Since he exclusions aren't needed, they don't need to be sync'd.

TODO

Patch currently defines the Top helper. Next: Swap the various calls in Bootstrap.php and CmsBootstrap.php to use Top. Remove the rules. Re-tests both cv and civix.

Currently, `cv` has a list of php-scoper rules to exclude certain classes from prefixing.
The same list has to be adapted to use in `civix` - so, presumbly, they'll have to be
sync'd over time.

The main reason for this is to allow the PHAR to call-out to the UF during bootstrap -- and
each UF has a different list of rules.

In theory, we could drop these rules -- and replace any lines like
`drupal_bootstrap()` with `Top::call('drupal_bootstrap')`. Then there would be no
need to keep the rules in sync.

Additionally, it would allow `cv.phar` to take advantage of libraries (like `symfony/event`)
that might be dual-purpose. (Ex: cv.phar and UF both have `EventDispatcher`s; and you want
to add listeners to both of them.)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant