Skip to content

Commit

Permalink
Patch PDO stub
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed May 26, 2020
1 parent e678115 commit 3734c3f
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
43 changes: 43 additions & 0 deletions compiler/patches/stubs/PDO/PDO.stub.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
--- PDO.stub 2019-12-05 17:56:26.000000000 +0100
+++ PDO2.stub 2020-05-26 14:16:32.000000000 +0200
@@ -268,7 +268,6 @@
* As <b>PDO::FETCH_INTO</b> but object is provided as a serialized string.
* Available since PHP 5.1.0. Since PHP 5.3.0 the class constructor is never called if this
* flag is set.
- * @since 5.1 Available
* @link https://php.net/manual/en/pdo.constants.php#pdo.constants.fetch-serialize
*/
const FETCH_SERIALIZE = 524288;
@@ -727,7 +726,7 @@
* <p>
* Note, this constant can only be used in the driver_options array when constructing a new database handle.
* </p>
- * @since 5.5.21 and 5.6.5
+ * @since 5.5.21
* @link https://php.net/manual/en/ref.pdo-mysql.php#pdo.constants.mysql-attr-multi-statements
*/
const MYSQL_ATTR_MULTI_STATEMENTS = 1015;
@@ -747,6 +746,7 @@
*/
const PGSQL_ASSOC = 1;
const PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT = 1000;
+ const PGSQL_ATTR_DISABLE_PREPARES = 1000;
const PGSQL_BAD_RESPONSE = 5;
const PGSQL_BOTH = 3;
const PGSQL_TRANSACTION_IDLE = 0;
@@ -839,6 +839,15 @@
*/
const SQLITE_ATTR_EXTENDED_RESULT_CODES = 2;

+ const FB_ATTR_DATE_FORMAT = 1;
+ const FB_ATTR_TIME_FORMAT = 2;
+ const FB_ATTR_TIMESTAMP_FORMAT = 3;
+
+ const OCI_ATTR_ACTION = 1;
+ const OCI_ATTR_CLIENT_INFO = 2;
+ const OCI_ATTR_CLIENT_IDENTIFIER = 3;
+ const OCI_ATTR_MODULE = 4;
+
/**
* (PHP 5 &gt;= 5.1.0, PHP 7, PECL pdo &gt;= 0.1.0)<br/>
* Creates a PDO instance representing a connection to a database
16 changes: 16 additions & 0 deletions compiler/src/Console/CompileCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
);
$this->fixComposerJson($this->buildDir);
$this->renamePhpStormStubs();
$this->patchPhpStormStubs($output);
$this->transformSource();

$this->processFactory->create(['php', 'box.phar', 'compile', '--no-parallel'], $this->dataDir);
Expand Down Expand Up @@ -125,6 +126,21 @@ private function renamePhpStormStubs(): void
}
}

private function patchPhpStormStubs(OutputInterface $output): void
{
$stubFinder = \Symfony\Component\Finder\Finder::create();
$stubsDirectory = __DIR__ . '/../../../vendor/jetbrains/phpstorm-stubs';
foreach ($stubFinder->files()->name('*.patch')->in(__DIR__ . '/../../patches/stubs') as $patchFile) {
$absolutePatchPath = $patchFile->getPathname();
$patchPath = $patchFile->getRelativePathname();
$stubPath = realpath($stubsDirectory . '/' . dirname($patchPath) . '/' . basename($patchPath, '.patch'));
if ($stubPath === false) {
throw new \PHPStan\ShouldNotHappenException(sprintf('Stub %s not found.', $stubPath));
}
$this->patchFile($output, $stubPath, $absolutePatchPath);
}
}

private function buildPreloadScript(): void
{
$vendorDir = $this->buildDir . '/vendor';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(

public function hasClass(string $className): bool
{
if ($className !== 'PDO' && array_key_exists($className, \JetBrains\PHPStormStub\PhpStormStubsMap::CLASSES)) {
if (array_key_exists($className, \JetBrains\PHPStormStub\PhpStormStubsMap::CLASSES)) {
return false;
}

Expand Down

0 comments on commit 3734c3f

Please sign in to comment.