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

Re-adding PHP 7.0 support, which works for most commands #155

Merged
merged 1 commit into from
Apr 19, 2018

Conversation

weaverryan
Copy link
Member

PHP 7.0 support was removed when I updated the make:entity command. This is because the make:entity command generates PHP 7.1+ compatible code only (it uses nullable ?).

But, having 7.0 support is easy... because 7.1 is only needed for this one command.

@@ -110,6 +110,10 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma

public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator)
{
if (version_compare(PHP_VERSION, '7.1.0') < 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use \PHP_VERSION_ID instead, as done in Symfony.


class MakerTestCase extends TestCase
{
protected function executeMakerCommand(MakerTestDetails $testDetails)
{
if ($testDetails->getMaker() instanceof MakeEntity && version_compare(PHP_VERSION, '7.1.0') < 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This MakerTestCase is a reusable one for any maker (including third-party ones). Hardcoding a special case for MakeEntity looks weird to me. I suggest adding a way to mark the test as skipped in MakerTestDetails instead.

@@ -504,7 +504,11 @@ private function addStatementToConstructor(Node\Stmt $stmt)
$this->updateSourceCodeFromNewStmts();
}

private function getConstructorNode(): ?Node\Stmt\ClassMethod
/**
* @return null|Node\Stmt\ClassMethod
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we generally put |null at the end in Symfony.

if ($testDetails->getMaker() instanceof MakeEntity && version_compare(PHP_VERSION, '7.1.0') < 0) {
$this->markTestSkipped('MakeEntity tests require 7.1 or higher');
if (!$testDetails->isSupportedByCurrentPhpVersion()) {
$this->markTestSkipped();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skipping should have a message.

@@ -245,4 +254,9 @@ public function isCommandAllowedToFail(): bool
{
return $this->commandAllowedToFail;
}

public function isSupportedByCurrentPhpVersion()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

: bool

@weaverryan weaverryan merged commit 043efcf into symfony:master Apr 19, 2018
weaverryan added a commit that referenced this pull request Apr 19, 2018
…weaverryan)

This PR was squashed before being merged into the 1.0-dev branch (closes #155).

Discussion
----------

Re-adding PHP 7.0 support, which works for most commands

PHP 7.0 support was removed when I updated the make:entity command. This is because the make:entity command generates PHP 7.1+ compatible code only (it uses nullable ?).

But, having 7.0 support is easy... because 7.1 is only needed for this one command.

Commits
-------

043efcf Re-adding PHP 7.0 support, which works for most commands
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.

3 participants