-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transpile to PHP 7.0 with Rector and manual replacements (#77)
Makes the Blueprints library syntax–compatible with PHP >= 7.0 with automated transpilation and manual adjustments. The automated transpilation is done with [rector](https://github.com/rectorphp/rector), which downgrades features specific to PHP 7.2 and later features to PHP 7.1. The manual part requires using regexps and editing the files by hand. ### Automated part To transpile the code to PHP 7.1, run: ```bash # Install rector: composer require rector/rector --ignore-platform-req=php # Transpile: php vendor/bin/rector process src ``` Unfortunately, Rector does not support downgrading to PHP 7.0 yet, so we need to do the last stretch manually. ### Manual part Rector will downgrade PHP code to PHP 7.1 but not further. We need PHP 7.0 compat so here's a few additional regexps to run. Regexps are not, of course, reliable in the general case, but they seem to do the trick here. List of manual replacements * `: \?[a-zA-Z_0-9]+` -> (empty string) to remove the unsupported return type from `function(): ?SchemaResolver {}` -> `function() {}`. * `: iterable` to fix `Fatal error: Generators may only declare a return type of Generator, Iterator or Traversable`. * `\?[a-zA-Z_0-9]+ \$` -> `$` to remove the unsupported nullable type from function signatures, e.g. `function(?Schema $schema){}` -> `function($schema){}`. * `(protected|public|private) const` -> `const` as const visibility is not supported in PHP 7.0. * `: void` -> `` as `void` return type is unsupported in PHP 7.0. * `[$ns, $name] = $this->parseName($name);` -> `list($ns, $name) = $this->parseName($name);` * `foreach ($data as [$cp, $chars]) {` -> `foreach ($data as list($cp, $chars)) {` * Find or write Rector rules for downgrading to PHP 7.0
- Loading branch information
Showing
106 changed files
with
1,113 additions
and
429 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
class Request { | ||
|
||
public string $url; | ||
public $url; | ||
|
||
/** | ||
* @param string $url | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.