Skip to content

Handle templates by php version#857

Closed
camilledejoye wants to merge 8 commits intophpactor:developfrom
camilledejoye:handle-templates-by-php-version
Closed

Handle templates by php version#857
camilledejoye wants to merge 8 commits intophpactor:developfrom
camilledejoye:handle-templates-by-php-version

Conversation

@camilledejoye
Copy link
Copy Markdown
Contributor

@camilledejoye camilledejoye commented Dec 7, 2019

It goes along with phpactor/code-builder#16 and need it to be merged first.

The code transform extension is still in the monolith so there is a bit of that here :)

Reorder the templates path by priority so we can override phpactor's
templates.
For information it didn't seem to be the case before, we could add new
templates but not override an existing one.
For each defined template path we will look for directories which name
is a number of 5 digit and consider this name as a PHP version ID.
For each of these directory which corresponds to a version under or
equal to the current PHP version ID we will add them as a loader to
Twig, ordered by ascendant version.

This way we will have something like:
<project_root>/.phpactor/templates
<xdg_config>/phpactor/templates
<app>/templates/70400
<app>/templates/70200
<app>/templates

Which represent the priority in which the templates will be looked for.

Easy to tests, I added `70400/Property.php.twig` in the `code-builder`
packages.
Override the `php.version_id` to 70200 and try to complete a constructor
parameters: the properies added will have a phpdoc block if they had a
type
Do the same thing with `php.verion_id` to 70400: the propery will have a
type and no phpdoc block
@dantleech dantleech closed this Jan 11, 2020
@dantleech
Copy link
Copy Markdown
Collaborator

Taken over as #869

@camilledejoye camilledejoye deleted the handle-templates-by-php-version branch March 21, 2020 09:33
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