diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index baaa2c12..cc0fd6d8 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -4,8 +4,8 @@ ARG XDEBUG_MODE=coverage RUN apt update -y && apt install -y git composer php-cli php-dom php-curl php-xdebug vim WORKDIR /app RUN git config --global --add safe.directory /app && \ - git config --global --add safe.directory /app/generator/doc/doc-en/en && \ - git config --global --add safe.directory /app/generator/doc/doc-en/doc-base -CMD cd /app/generator/doc && ./update.sh && \ - cd /app && composer install && \ - cd /app/generator && composer install && php ./safe.php generate + git config --global --add safe.directory /app/generator/docs +CMD cd /app && composer install && \ + cd /app/generator && composer install && \ + php ./safe.php download-docs && \ + php ./safe.php generate diff --git a/.github/workflows/auto-regenerate.yml b/.github/workflows/auto-regenerate.yml index 57386ba8..ed6c3886 100644 --- a/.github/workflows/auto-regenerate.yml +++ b/.github/workflows/auto-regenerate.yml @@ -22,14 +22,14 @@ jobs: - name: "Check out salathe/phpdoc-base" uses: "actions/checkout@v4" with: - path: "generator/doc/doc-en/doc-base" + path: "generator/docs/salathe/phpdoc-base" repository: "salathe/phpdoc-base" fetch-depth: 0 - name: "Check out php/doc-en" uses: "actions/checkout@v4" with: - path: "generator/doc/doc-en/en" + path: "generator/docs" repository: "php/doc-en" fetch-depth: 0 diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index de329980..7700b5d6 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -18,27 +18,31 @@ jobs: steps: - name: "Checkout" uses: "actions/checkout@v4" + - name: "Get current date for the daily cache" id: "date" run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT + - name: "Cache the php documentation" - id: cache-php-doc + id: cache-php-docs uses: "actions/cache@v4" with: - path: "generator/doc/doc-en" - key: php-doc-${{ steps.date.outputs.date }} + path: "generator/docs" + key: php-docs-${{ steps.date.outputs.date }} + - name: "Check out salathe/phpdoc-base" uses: "actions/checkout@v4" - if: steps.cache-php-doc.outputs.cache-hit != 'true' + if: steps.cache-php-docs.outputs.cache-hit != 'true' with: - path: "generator/doc/doc-en/doc-base" + path: "generator/docs/salathe/phpdoc-base" repository: "salathe/phpdoc-base" fetch-depth: 0 + - name: "Check out php/doc-en" uses: "actions/checkout@v4" - if: steps.cache-php-doc.outputs.cache-hit != 'true' + if: steps.cache-php-docs.outputs.cache-hit != 'true' with: - path: "generator/doc/doc-en/en" + path: "generator/docs/php/doc-en" repository: "php/doc-en" fetch-depth: 0 @@ -61,11 +65,11 @@ jobs: coverage: "pcov" php-version: "${{ matrix.php-version }}" - name: "Fetch cached docs" - id: cache-php-doc + id: cache-docs uses: "actions/cache@v4" with: - path: "generator/doc/doc-en" - key: php-doc-${{ needs.fetch_defs.outputs.date }} + path: "generator/docs" + key: php-docs-${{ needs.fetch_defs.outputs.date }} fail-on-cache-miss: true - name: "Cache dependencies installed with composer" uses: "actions/cache@v4" @@ -140,11 +144,11 @@ jobs: coverage: "pcov" php-version: "8.4" - name: "Fetch cached docs" - id: cache-php-doc + id: cache-php-docs uses: "actions/cache@v4" with: - path: "generator/doc/doc-en" - key: php-doc-${{ needs.fetch_defs.outputs.date }} + path: "generator/docs" + key: php-docs-${{ needs.fetch_defs.outputs.date }} fail-on-cache-miss: true - name: "Cache dependencies installed with composer" uses: "actions/cache@v4" diff --git a/.gitignore b/.gitignore index 84a3c6ed..37a1d8b4 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ vendor/ /generator/tests/rector/composer.lock .phpunit.result.cache .phpunit.cache +docs/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8614a964..c9c11075 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -91,12 +91,10 @@ generator, as well as some handy shortcut shell scripts. You can use The first step is to download the PHP documentation project locally, using git. ```bash -$ cd generator/doc -$ sh update.sh +$ generator/safe.php download-docs ``` -The script can be used to both install the doc and to update it. -All it does is pull from theses mirrors: +This will download the PHP documentation from the official repository. https://github.com/salathe/phpdoc-base diff --git a/generator/composer.json b/generator/composer.json index 356c3277..c049c3c5 100644 --- a/generator/composer.json +++ b/generator/composer.json @@ -14,7 +14,8 @@ "phpstan/phpstan": "^2", "symfony/console": "^7", "symfony/process": "^7", - "symfony/finder": "^7" + "symfony/finder": "^7", + "symfony/filesystem": "^7.2" }, "require-dev": { "phpunit/phpunit": "^12", diff --git a/generator/composer.lock b/generator/composer.lock index 0bd65a4f..21a7e56c 100644 --- a/generator/composer.lock +++ b/generator/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9248a405e94bae2f2709e35a62b3893d", + "content-hash": "b628bc891f673d526b80563911c6318e", "packages": [ { "name": "phpstan/phpstan", @@ -277,6 +277,72 @@ ], "time": "2024-09-25T14:20:29+00:00" }, + { + "name": "symfony/filesystem", + "version": "v7.2.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "b8dce482de9d7c9fe2891155035a7248ab5c7fdb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/b8dce482de9d7c9fe2891155035a7248ab5c7fdb", + "reference": "b8dce482de9d7c9fe2891155035a7248ab5c7fdb", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.8" + }, + "require-dev": { + "symfony/process": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/filesystem/tree/v7.2.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-10-25T15:15:23+00:00" + }, { "name": "symfony/finder", "version": "v7.2.2", diff --git a/generator/doc/entities/.gitkeep b/generator/doc/entities/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/generator/doc/update.sh b/generator/doc/update.sh deleted file mode 100755 index 2baaff72..00000000 --- a/generator/doc/update.sh +++ /dev/null @@ -1,11 +0,0 @@ -if [ ! -d "doc-en" ]; then - mkdir doc-en - cd doc-en - git clone https://github.com/salathe/phpdoc-base doc-base - git clone https://github.com/php/doc-en en -else - cd doc-en/en - git pull - cd ../doc-base - git pull -fi \ No newline at end of file diff --git a/generator/safe.php b/generator/safe.php index b8601752..cb450a85 100755 --- a/generator/safe.php +++ b/generator/safe.php @@ -7,11 +7,13 @@ use Safe\Commands\FunctionInfoCommand; use Safe\Commands\GenerateCommand; use Safe\Commands\ScanObjectsCommand; +use Safe\Commands\DownloadDocsCommand; use Symfony\Component\Console\Application; $application = new Application(); $application->addCommands([new GenerateCommand()]); $application->addCommands([new ScanObjectsCommand()]); $application->addCommands([new FunctionInfoCommand()]); +$application->addCommands([new DownloadDocsCommand()]); $application->run(); diff --git a/generator/src/Commands/DownloadDocsCommand.php b/generator/src/Commands/DownloadDocsCommand.php new file mode 100644 index 00000000..da8d2f9b --- /dev/null +++ b/generator/src/Commands/DownloadDocsCommand.php @@ -0,0 +1,63 @@ +setName('download-docs') + ->setDescription('Download the recent version of the PHP documentation') + ; + } + + protected function initialize(InputInterface $input, OutputInterface $output): void + { + $this->io = new SymfonyStyle($input, $output); + $this->filesystem = new Filesystem(); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $this->io->title($this->getDescription()); + + // Clean up before cloning. + $this->filesystem->remove(PathHelper::docsDirectory()); + $this->filesystem->mkdir(PathHelper::docsDirectory()); + + $this->clone($output, 'salathe/phpdoc-base'); + $this->clone($output, 'php/doc-en'); + + return self::SUCCESS; + } + + private function clone(OutputInterface $output, string $repository): void + { + $progressIndicator = new ProgressIndicator($output); + $progressIndicator->start(\sprintf('Cloning %s', $repository)); + + $process = new Process(['git', 'clone', \sprintf('https://github.com/%s', $repository), \sprintf('%s/%s', PathHelper::docsDirectory(), $repository)]); + $process->start(); + + while ($process->isRunning()) { + $progressIndicator->advance(); + } + + $progressIndicator->finish(\sprintf('Downloaded %s', $repository)); + } +} diff --git a/generator/src/Commands/FunctionInfoCommand.php b/generator/src/Commands/FunctionInfoCommand.php index c3d48896..44be8022 100644 --- a/generator/src/Commands/FunctionInfoCommand.php +++ b/generator/src/Commands/FunctionInfoCommand.php @@ -32,7 +32,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $phpStanFunctionMapReader = new PhpStanFunctionMapReader(); $finder = new Finder(); - $finder->in(DocPage::findReferenceDir() . "/*/functions/")->name($targetFilename)->sortByName(); + $finder->in(DocPage::referenceDir() . "/*/functions/")->name($targetFilename)->sortByName(); foreach ($finder as $file) { $docPage = new DocPage($file->getPathname()); diff --git a/generator/src/Commands/GenerateCommand.php b/generator/src/Commands/GenerateCommand.php index 0e7efba7..074597af 100644 --- a/generator/src/Commands/GenerateCommand.php +++ b/generator/src/Commands/GenerateCommand.php @@ -4,6 +4,7 @@ namespace Safe\Commands; +use Safe\Filesystem\PathHelper; use Safe\XmlDocParser\Scanner; use Safe\XmlDocParser\DocPage; use Safe\Generator\FileCreator; @@ -34,7 +35,7 @@ protected function execute( $this->rmGenerated(); // Let's build the DTD necessary to load the XML files. - $this->checkout(DocPage::findReferenceDir(), "master"); + $this->checkout(DocPage::referenceDir(), "master"); DocPage::buildEntities(); // PHP documentation is a living document, which broadly reflects @@ -66,8 +67,8 @@ protected function execute( // Scan the documentation for a given PHP version and find all // functions that we need to generate safe wrappers for. - $this->checkout(DocPage::findReferenceDir(), $commit); - $scanner = new Scanner(DocPage::findReferenceDir()); + $this->checkout(DocPage::referenceDir(), $commit); + $scanner = new Scanner(DocPage::referenceDir()); $res = $scanner->getMethods($scanner->getFunctionsPaths(), $pastFunctionNames, $output); $output->writeln( 'Functions have been ignored and must be dealt with manually: ' . @@ -133,8 +134,8 @@ private function rmGenerated(): void } } - if (\file_exists(DocPage::findDocDir() . '/entities/generated.ent')) { - \unlink(DocPage::findDocDir() . '/entities/generated.ent'); + if (\file_exists(PathHelper::docsDirectory() . '/generated.ent')) { + \unlink(PathHelper::docsDirectory() . '/generated.ent'); } } diff --git a/generator/src/Commands/ScanObjectsCommand.php b/generator/src/Commands/ScanObjectsCommand.php index 2d8aa9b9..de0871db 100644 --- a/generator/src/Commands/ScanObjectsCommand.php +++ b/generator/src/Commands/ScanObjectsCommand.php @@ -22,7 +22,7 @@ protected function configure(): void protected function execute(InputInterface $input, OutputInterface $output): int { - $scanner = new Scanner(DocPage::findReferenceDir()); + $scanner = new Scanner(DocPage::referenceDir()); $paths = $scanner->getMethodsPaths(); diff --git a/generator/src/Filesystem/PathHelper.php b/generator/src/Filesystem/PathHelper.php new file mode 100644 index 00000000..b66fcd25 --- /dev/null +++ b/generator/src/Filesystem/PathHelper.php @@ -0,0 +1,28 @@ +path); } $strpos = \strpos($content, '?>')+2; - if (!\file_exists(DocPage::findDocDir() . '/entities/generated.ent')) { + if (!\file_exists(PathHelper::docsDirectory() . '/generated.ent')) { self::buildEntities(); } - $path = \realpath(DocPage::findDocDir() . '/entities/generated.ent'); + $path = \realpath(PathHelper::docsDirectory() . '/generated.ent'); $content = \substr($content, 0, $strpos) @@ -188,14 +184,14 @@ private function arrayFlatten(array $array): array public static function buildEntities(): void { - $file1 = \file_get_contents(DocPage::findDocDir() . '/doc-en/en/language-defs.ent') ?: ''; - $file2 = \file_get_contents(DocPage::findDocDir() . '/doc-en/en/language-snippets.ent') ?: ''; - $file3 = \file_get_contents(DocPage::findDocDir() . '/doc-en/en/extensions.ent') ?: ''; - $file4 = \file_get_contents(DocPage::findDocDir() . '/doc-en/doc-base/entities/global.ent') ?: ''; + $file1 = \file_get_contents(PathHelper::docsDirectory() . '/php/doc-en/language-defs.ent') ?: ''; + $file2 = \file_get_contents(PathHelper::docsDirectory() . '/php/doc-en/language-snippets.ent') ?: ''; + $file3 = \file_get_contents(PathHelper::docsDirectory() . '/php/doc-en/extensions.ent') ?: ''; + $file4 = \file_get_contents(PathHelper::docsDirectory() . '/salathe/phpdoc-base/entities/global.ent') ?: ''; $completeFile = $file1 . self::extractXmlHeader($file2) . self::extractXmlHeader($file3) . $file4; - \file_put_contents(DocPage::findDocDir() . '/entities/generated.ent', $completeFile); + \file_put_contents(PathHelper::docsDirectory() . '/generated.ent', $completeFile); } private static function extractXmlHeader(string $content): string diff --git a/generator/tests/Generator/WritePhpFunctionTest.php b/generator/tests/Generator/WritePhpFunctionTest.php index 213e491e..56aafd5e 100644 --- a/generator/tests/Generator/WritePhpFunctionTest.php +++ b/generator/tests/Generator/WritePhpFunctionTest.php @@ -14,7 +14,7 @@ class WritePhpFunctionTest extends TestCase { public function testGetPhpPrototypeFunctionRegular(): void { - $docPage = new DocPage(DocPage::findReferenceDir() . '/pcre/functions/preg-match.xml'); + $docPage = new DocPage(DocPage::referenceDir() . '/pcre/functions/preg-match.xml'); $xmlObject = $docPage->getMethodSynopsis(); $method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader(), ErrorType::FALSY); @@ -25,7 +25,7 @@ public function testGetPhpPrototypeFunctionRegular(): void public function testGetPhpPrototypeFunctionOverloaded(): void { - $docPage = new DocPage(DocPage::findReferenceDir() . '/filesystem/functions/file-get-contents.xml'); + $docPage = new DocPage(DocPage::referenceDir() . '/filesystem/functions/file-get-contents.xml'); $xmlObject = $docPage->getMethodSynopsis(); $method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader(), ErrorType::FALSY); diff --git a/generator/tests/XmlDocParser/DocPageTest.php b/generator/tests/XmlDocParser/DocPageTest.php index 7e4dd1e7..fa0a2f90 100644 --- a/generator/tests/XmlDocParser/DocPageTest.php +++ b/generator/tests/XmlDocParser/DocPageTest.php @@ -11,7 +11,7 @@ class DocPageTest extends TestCase // take a documentation XML file path and return an ErrorType private function d2e(string $path): ErrorType { - return (new DocPage(DocPage::findReferenceDir() . "/" . $path))->getErrorType(); + return (new DocPage(DocPage::referenceDir() . "/" . $path))->getErrorType(); } public function testErrorTypeDetection(): void diff --git a/generator/tests/XmlDocParser/MethodTest.php b/generator/tests/XmlDocParser/MethodTest.php index 0b4e508a..8b9fe2fd 100644 --- a/generator/tests/XmlDocParser/MethodTest.php +++ b/generator/tests/XmlDocParser/MethodTest.php @@ -11,7 +11,7 @@ class MethodTest extends TestCase { public function testToString(): void { - $docPage = new DocPage(DocPage::findReferenceDir() . '/pcre/functions/preg-match.xml'); + $docPage = new DocPage(DocPage::referenceDir() . '/pcre/functions/preg-match.xml'); $xmlObject = $docPage->getMethodSynopsis(); $method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader(), ErrorType::FALSY); $this->assertStringContainsString('Error type: FALSY', (string)$method); @@ -19,7 +19,7 @@ public function testToString(): void public function testGetFunctionName(): void { - $docPage = new DocPage(DocPage::findReferenceDir() . '/pcre/functions/preg-match.xml'); + $docPage = new DocPage(DocPage::referenceDir() . '/pcre/functions/preg-match.xml'); $xmlObject = $docPage->getMethodSynopsis(); $method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader(), ErrorType::FALSY); $name = $method->getFunctionName(); @@ -28,7 +28,7 @@ public function testGetFunctionName(): void public function testGetFunctionType(): void { - $docPage = new DocPage(DocPage::findReferenceDir() . '/pcre/functions/preg-match.xml'); + $docPage = new DocPage(DocPage::referenceDir() . '/pcre/functions/preg-match.xml'); $xmlObject = $docPage->getMethodSynopsis(); $method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader(), ErrorType::FALSY); $type = $method->getSignatureReturnType(); @@ -39,7 +39,7 @@ public function testGetFunctionType(): void public function testGetFunctionParam(): void { - $docPage = new DocPage(DocPage::findReferenceDir() . '/pcre/functions/preg-match.xml'); + $docPage = new DocPage(DocPage::referenceDir() . '/pcre/functions/preg-match.xml'); $xmlObject = $docPage->getMethodSynopsis(); $method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader(), ErrorType::FALSY); $params = $method->getParams(); @@ -49,7 +49,7 @@ public function testGetFunctionParam(): void public function testGetTypeHintFromResource(): void { - $docPage = new DocPage(DocPage::findReferenceDir() . '/strings/functions/sprintf.xml'); + $docPage = new DocPage(DocPage::referenceDir() . '/strings/functions/sprintf.xml'); $xmlObject = $docPage->getMethodSynopsis(); $method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader(), ErrorType::FALSY); $params = $method->getParams(); @@ -59,7 +59,7 @@ public function testGetTypeHintFromResource(): void $this->assertTrue($params[1]->isVariadic()); $this->assertEquals('', $params[1]->getSignatureType()); - $docPage = new DocPage(DocPage::findReferenceDir() . '/mbstring/functions/mb-ereg-replace-callback.xml'); + $docPage = new DocPage(DocPage::referenceDir() . '/mbstring/functions/mb-ereg-replace-callback.xml'); $xmlObject = $docPage->getMethodSynopsis(); $method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader(), ErrorType::FALSY); $params = $method->getParams(); @@ -69,7 +69,7 @@ public function testGetTypeHintFromResource(): void $this->assertEquals('callable', $params[1]->getSignatureType()); - $docPage = new DocPage(DocPage::findReferenceDir() . '/gmp/functions/gmp-export.xml'); + $docPage = new DocPage(DocPage::referenceDir() . '/gmp/functions/gmp-export.xml'); $xmlObject = $docPage->getMethodSynopsis(); $method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader(), ErrorType::FALSY); $params = $method->getParams(); @@ -78,7 +78,7 @@ public function testGetTypeHintFromResource(): void $this->assertEquals('int', $params[1]->getDocBlockType()); $this->assertEquals('int', $params[1]->getSignatureType()); - $docPage = new DocPage(DocPage::findReferenceDir() . '/hash/functions/hash-update.xml'); + $docPage = new DocPage(DocPage::referenceDir() . '/hash/functions/hash-update.xml'); $xmlObject = $docPage->getMethodSynopsis(); $method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader(), ErrorType::FALSY); $params = $method->getParams(); @@ -88,7 +88,7 @@ public function testGetTypeHintFromResource(): void public function testImapOpen5Parameter(): void { - $docPage = new DocPage(DocPage::findReferenceDir() . '/imap/functions/imap-open.xml'); + $docPage = new DocPage(DocPage::referenceDir() . '/imap/functions/imap-open.xml'); $xmlObject = $docPage->getMethodSynopsis(); $method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader(), ErrorType::FALSY); $params = $method->getParams(); @@ -98,7 +98,7 @@ public function testImapOpen5Parameter(): void public function testGetInitializer(): void { - $docPage = new DocPage(DocPage::findReferenceDir() . '/apache/functions/apache-getenv.xml'); + $docPage = new DocPage(DocPage::referenceDir() . '/apache/functions/apache-getenv.xml'); $xmlObject = $docPage->getMethodSynopsis(); $method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader(), ErrorType::FALSY); @@ -109,18 +109,18 @@ public function testGetInitializer(): void public function testGetReturnDocBlock(): void { - $docPage = new DocPage(DocPage::findReferenceDir() . '/array/functions/array-replace.xml'); + $docPage = new DocPage(DocPage::referenceDir() . '/array/functions/array-replace.xml'); $xmlObject = $docPage->getMethodSynopsis(); $method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader(), ErrorType::NULLSY); $this->assertEquals("@return array Returns an array.\n", $method->getReturnDocBlock()); - $docPage = new DocPage(DocPage::findReferenceDir() . '/shmop/functions/shmop-delete.xml'); + $docPage = new DocPage(DocPage::referenceDir() . '/shmop/functions/shmop-delete.xml'); $xmlObject = $docPage->getMethodSynopsis(); $method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader(), ErrorType::FALSY); $this->assertEquals('', $method->getReturnDocBlock()); $this->assertEquals('void', $method->getSignatureReturnType()); - $docPage = new DocPage(DocPage::findReferenceDir() . '/sqlsrv/functions/sqlsrv-next-result.xml'); + $docPage = new DocPage(DocPage::referenceDir() . '/sqlsrv/functions/sqlsrv-next-result.xml'); $xmlObject = $docPage->getMethodSynopsis(); $method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader(), ErrorType::FALSY); $this->assertEquals("@return bool|null Returns TRUE if the next result was successfully retrieved, FALSE if an error \n occurred, and NULL if there are no more results to retrieve.\n", $method->getReturnDocBlock()); @@ -129,7 +129,7 @@ public function testGetReturnDocBlock(): void public function testGetPhpDoc(): void { - $docPage = new DocPage(DocPage::findReferenceDir() . '/array/functions/array-replace.xml'); + $docPage = new DocPage(DocPage::referenceDir() . '/array/functions/array-replace.xml'); $xmlObject = $docPage->getMethodSynopsis(); $method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader(), ErrorType::NULLSY); $this->assertStringContainsString('@param array $array', $method->getPhpDoc()); @@ -137,12 +137,12 @@ public function testGetPhpDoc(): void public function testIsOverloaded(): void { - $docPage = new DocPage(DocPage::findReferenceDir() . '/array/functions/array-all.xml'); + $docPage = new DocPage(DocPage::referenceDir() . '/array/functions/array-all.xml'); $xmlObject = $docPage->getMethodSynopsis(); $method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader(), ErrorType::NULLSY); $this->assertFalse($method->isOverloaded()); - $docPage = new DocPage(DocPage::findReferenceDir() . '/filesystem/functions/file-get-contents.xml'); + $docPage = new DocPage(DocPage::referenceDir() . '/filesystem/functions/file-get-contents.xml'); $xmlObject = $docPage->getMethodSynopsis(); $method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader(), ErrorType::NULLSY); $this->assertTrue($method->isOverloaded()); @@ -150,7 +150,7 @@ public function testIsOverloaded(): void public function testOpensslCipherKeyLengthUnionTypeReturnDocBlocks(): void { - $docPage = new DocPage(DocPage::findReferenceDir() . '/openssl/functions/openssl-cipher-key-length.xml'); + $docPage = new DocPage(DocPage::referenceDir() . '/openssl/functions/openssl-cipher-key-length.xml'); $xmlObject = $docPage->getMethodSynopsis(); $method = new Method($xmlObject[0], $docPage->loadAndResolveFile(), $docPage->getModule(), new PhpStanFunctionMapReader(), ErrorType::FALSY); $this->assertEquals("@return int Returns the cipher length on success.\n", $method->getReturnDocBlock()); diff --git a/generator/tests/XmlDocParser/ScannerTest.php b/generator/tests/XmlDocParser/ScannerTest.php index 0b7a4cd5..c62ae724 100644 --- a/generator/tests/XmlDocParser/ScannerTest.php +++ b/generator/tests/XmlDocParser/ScannerTest.php @@ -12,25 +12,25 @@ class ScannerTest extends TestCase public function testGetMethodsPaths(): void { - $scanner = new Scanner(DocPage::findReferenceDir()); + $scanner = new Scanner(DocPage::referenceDir()); $paths = $scanner->getFunctionsPaths(); - $this->assertArrayHasKey(DocPage::findReferenceDir() . '/filesystem/functions/chmod.xml', $paths); - $this->assertArrayNotHasKey(DocPage::findReferenceDir() . '/spl/appenditerator/getarrayiterator.xml', $paths); + $this->assertArrayHasKey(DocPage::referenceDir() . '/filesystem/functions/chmod.xml', $paths); + $this->assertArrayNotHasKey(DocPage::referenceDir() . '/spl/appenditerator/getarrayiterator.xml', $paths); } public function testGetFunctionsPaths(): void { - $scanner = new Scanner(DocPage::findReferenceDir() . '/'); + $scanner = new Scanner(DocPage::referenceDir() . '/'); $paths = $scanner->getMethodsPaths(); - $this->assertArrayNotHasKey(DocPage::findReferenceDir() . '/filesystem/functions/chmod.xml', $paths); - $this->assertArrayHasKey(DocPage::findReferenceDir() . '/spl/appenditerator/getarrayiterator.xml', $paths); + $this->assertArrayNotHasKey(DocPage::referenceDir() . '/filesystem/functions/chmod.xml', $paths); + $this->assertArrayHasKey(DocPage::referenceDir() . '/spl/appenditerator/getarrayiterator.xml', $paths); } public function testGetMethods(): void { - $scanner = new Scanner(DocPage::findReferenceDir()); + $scanner = new Scanner(DocPage::referenceDir()); $functions = $scanner->getFunctionsPaths(); $testFunctions = []; foreach ($functions as $name => $info) {