-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Reintroduce support for PHP 7.1 and 7.2 #4386
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -229,13 +229,12 @@ public function getDropIndexSQL($index, $table = null) | |
} | ||
|
||
return sprintf( | ||
<<<SQL | ||
" | ||
IF EXISTS (SELECT * FROM sysobjects WHERE name = '%s') | ||
ALTER TABLE %s DROP CONSTRAINT %s | ||
ELSE | ||
DROP INDEX %s ON %s | ||
SQL | ||
, | ||
", | ||
$index, | ||
$table, | ||
$index, | ||
|
@@ -1691,12 +1690,11 @@ private function generateIdentifierName($identifier) | |
protected function getCommentOnTableSQL(string $tableName, ?string $comment): string | ||
{ | ||
return sprintf( | ||
<<<'SQL' | ||
" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this change necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HEREDOCs were added in PHP 7.3 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correction, moving the closing tag for now/heredocs to the same indentation as starting was added in 7.3 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't moving the heredoc terminator to the beginning of the line have more or less the same effect? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It applies a tab more for every line, but works. return sprintf(
<<<SQL
EXEC sys.sp_addextendedproperty @name=N'MS_Description',
@value=N%s, @level0type=N'SCHEMA', @level0name=N'dbo',
@level1type=N'TABLE', @level1name=N%s
SQL,
$this->quoteStringLiteral((string) $comment),
$this->quoteStringLiteral($tableName)
); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @beberlei you could use |
||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', | ||
@value=N%s, @level0type=N'SCHEMA', @level0name=N'dbo', | ||
@level1type=N'TABLE', @level1name=N%s | ||
SQL | ||
, | ||
", | ||
$this->quoteStringLiteral((string) $comment), | ||
$this->quoteStringLiteral($tableName) | ||
); | ||
|
@@ -1705,16 +1703,15 @@ protected function getCommentOnTableSQL(string $tableName, ?string $comment): st | |
public function getListTableMetadataSQL(string $table): string | ||
{ | ||
return sprintf( | ||
<<<'SQL' | ||
" | ||
SELECT | ||
p.value AS [table_comment] | ||
FROM | ||
sys.tables AS tbl | ||
INNER JOIN sys.extended_properties AS p ON p.major_id=tbl.object_id AND p.minor_id=0 AND p.class=1 | ||
WHERE | ||
(tbl.name=N%s and SCHEMA_NAME(tbl.schema_id)=N'dbo' and p.name=N'MS_Description') | ||
SQL | ||
, | ||
", | ||
$this->quoteStringLiteral($table) | ||
); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\DBAL; | ||
|
||
trait AssertionCompatibility | ||
{ | ||
/** | ||
* @param array<mixed> $arguments | ||
* | ||
* @return mixed | ||
*/ | ||
public static function __callStatic(string $name, array $arguments) | ||
{ | ||
if ($name === 'assertMatchesRegularExpression') { | ||
self::assertRegExp(...$arguments); | ||
} elseif ($name === 'assertFileDoesNotExist') { | ||
self::assertFileNotExists(...$arguments); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
/** | ||
* @param array<mixed> $arguments | ||
* | ||
* @return mixed | ||
*/ | ||
public function __call(string $method, array $arguments) | ||
{ | ||
if ($method === 'createStub') { | ||
return $this->getMockBuilder(...$arguments) | ||
->disableOriginalConstructor() | ||
->disableOriginalClone() | ||
->disableArgumentCloning() | ||
->disallowMockingUnknownTypes() | ||
->getMock(); | ||
} | ||
|
||
return null; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\DBAL; | ||
|
||
use PHPUnit\Framework\MockObject\MockBuilder; | ||
|
||
use function method_exists; | ||
|
||
/** | ||
* @template T | ||
*/ | ||
class MockBuilderProxy | ||
{ | ||
/** @var MockBuilder<T> */ | ||
private $originalMockBuilder; | ||
|
||
/** | ||
* @param MockBuilder<T> $originalMockBuilder | ||
*/ | ||
public function __construct(MockBuilder $originalMockBuilder) | ||
{ | ||
$this->originalMockBuilder = $originalMockBuilder; | ||
} | ||
|
||
/** | ||
* @param array<string> $methods | ||
* | ||
* @return MockBuilder<T> | ||
*/ | ||
public function onlyMethods(array $methods): MockBuilder | ||
{ | ||
if (method_exists(MockBuilder::class, 'onlyMethods')) { | ||
return $this->originalMockBuilder->onlyMethods($methods); | ||
} | ||
|
||
return $this->originalMockBuilder->setMethods($methods); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
W/o the platform fixed, all dependency updates will have to be made on the lowest supported version. Otherwise, there's a risk of locking the dependencies that are not compatible with it.
It might be better to unset the platform version on CI before the update but have it committed in the repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When supporting this range of versions, you need to "composer update" anyways to get to the right packages. So the solution is probably rather to remove composer.lock in this step. With this setting in, you cannot get the code running locally with 7.1 and 7.2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But without this setting, the one performing a dependency update will have to use PHP 7.1. Otherwise, they will learn that the new resolution doesn't work with PHP 7.1 only on CI. Is there a Composer CLI switch to pass
config.platform.php
at runtime?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This point is not relevant anymore since ce3421e composer.lock is not committed anymore and the Ci always fetches the latest packeges matching all constraints.