Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add support for rewriting method signatures #175

Open
robbieaverill opened this issue Jun 14, 2019 · 1 comment
Open

Add support for rewriting method signatures #175

robbieaverill opened this issue Jun 14, 2019 · 1 comment

Comments

@robbieaverill
Copy link
Contributor

robbieaverill commented Jun 14, 2019

I'm not sure if this is doable yet, but assuming we start adding PHP 7 type hints etc to our existing API for SilverStripe 5, it'd be nice to be able to have the upgrader automatically rewrite methods for people's child classes. For example:

# SilverStripe 4: SiteTree
public function getCMSFields()

# SilverStripe 5: SiteTree
public function getCMSFields(): FieldList

Possible upgrader rule:

rules:
  signature_replacements:
    SilverStripe\CMS\Model\SiteTree:
      'getCMSFields()': 'getCMSFields(): FieldList'

It'd also need to import namespaces that may not exist yet, although I assume that getCMSFields(): \SilverStripe\Forms\FieldList would parse correctly when the parent's signature says getCMSFields(): FieldList with an imported namespace, so maybe that's a nice to have.

This will be important to discuss before we start implementing PHP7 changes in SilverStripe 5 for existing APIs.

@maxime-rainville
Copy link
Contributor

I can see the benefit. It will probably require a bit of hair pulling to pull it off.

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

No branches or pull requests

2 participants