Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.

PhpDocs update #127

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
],
"require": {
"php": ">=7.3",
"ext-json": "*",
"nesk/rialto": "^1.2.0",
"psr/log": "^1.0",
"vierbergenlars/php-semver": "^3.0.2"
Expand All @@ -28,7 +29,8 @@
"monolog/monolog": "^2.0",
"phpunit/phpunit": "^9.0",
"symfony/process": "^4.0|^5.0",
"symfony/console": "^4.0|^5.0"
"symfony/console": "^4.0|^5.0",
"phpstan/phpstan": "^0.12"
xtrime-ru marked this conversation as resolved.
Show resolved Hide resolved
},
"autoload": {
"psr-4": {
Expand All @@ -42,7 +44,9 @@
},
"scripts": {
"post-install-cmd": "npm install",
"test": "./vendor/bin/phpunit"
"test": "./vendor/bin/phpunit",
"phpstan": "vendor/bin/phpstan analyse --configuration=phpstan.neon",
"update-docs": "php bin/console doc:generate"
},
"config": {
"sort-packages": true
Expand Down
9 changes: 9 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
parameters:
level: max
paths:
- src
fileExtensions:
- php
parallel:
maximumNumberOfProcesses: 4
tipsOfTheDay: false
18 changes: 16 additions & 2 deletions src/Command/GenerateDocumentationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ protected function configure(): void
*/
private static function buildDocumentationGenerator(): void
{
self::rmdirRecursive(self::BUILD_DIR);
$process = new Process([
self::NODE_MODULES_DIR.'/.bin/tsc',
'--outDir',
Expand All @@ -60,7 +61,7 @@ private static function getDocumentation(string $puppeteerPath, array $resourceN
['node', self::BUILD_DIR.'/'.self::DOC_FILE_NAME.'.js', 'php'],
$commonFiles,
$nodeFiles,
['--resources-namespace', self::RESOURCES_NAMESPACE, '--resources'],
['--resources-namespace', '', '--resources'],
$resourceNames
)
);
Expand Down Expand Up @@ -155,7 +156,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

// Handle the specific Puppeteer class
$classDocumentation = $documentation['Puppeteer'] ?? null;
$classDocumentation = array_replace_recursive($documentation['Puppeteer'], $documentation['PuppeteerNode']);
unset($documentation['Puppeteer'], $documentation['PuppeteerNode']);
if ($classDocumentation !== null) {
$phpDoc = self::generatePhpDocWithDocumentation($classDocumentation);
if ($phpDoc !== null) {
Expand All @@ -175,4 +177,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int

return 0;
}

private static function rmdirRecursive(string $dir): bool {
$files = scandir($dir);
if (!is_array($files)) {
return false;
}
$files = array_diff($files, array('.','..'));
foreach ($files as $file) {
(is_dir("$dir/$file")) ? self::rmdirRecursive("$dir/$file") : unlink("$dir/$file");
}
return rmdir($dir);
}
}
9 changes: 8 additions & 1 deletion src/Puppeteer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Nesk\Puphpeteer;

use Nesk\Puphpeteer\Resources\Browser;
use Nesk\Puphpeteer\Resources\BrowserFetcher;
use Psr\Log\LoggerInterface;
use Symfony\Component\Process\Process;
use Nesk\Rialto\AbstractEntryPoint;
Expand All @@ -10,11 +12,16 @@
/**
* @property-read mixed devices
* @property-read mixed errors
* @method \Nesk\Puphpeteer\Resources\Browser connect(array<string, mixed> $options)
* @property-read string product
* @method Browser connect(array $options)
* @method void registerCustomQueryHandler(string $name, mixed $queryHandler)
* @method void unregisterCustomQueryHandler(string $name)
* @method string[] customQueryHandlerNames()
* @method void clearCustomQueryHandlers()
* @method Browser launch(array $options = [])
* @method string executablePath()
* @method string[] defaultArgs(array $options = [])
* @method BrowserFetcher createBrowserFetcher(array $options)
*/
class Puppeteer extends AbstractEntryPoint
{
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/Accessibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Nesk\Rialto\Data\BasicResource;

/**
* @method mixed snapshot(array<string, mixed> $options = null)
* @method mixed snapshot(array $options = [])
*/
class Accessibility extends BasicResource
{
Expand Down
16 changes: 8 additions & 8 deletions src/Resources/Browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

/**
* @method mixed|null process()
* @method \Nesk\Puphpeteer\Resources\BrowserContext createIncognitoBrowserContext()
* @method \Nesk\Puphpeteer\Resources\BrowserContext[] browserContexts()
* @method \Nesk\Puphpeteer\Resources\BrowserContext defaultBrowserContext()
* @method BrowserContext createIncognitoBrowserContext()
* @method BrowserContext[] browserContexts()
* @method BrowserContext defaultBrowserContext()
xtrime-ru marked this conversation as resolved.
Show resolved Hide resolved
* @method string wsEndpoint()
* @method \Nesk\Puphpeteer\Resources\Page newPage()
* @method \Nesk\Puphpeteer\Resources\Target[] targets()
* @method \Nesk\Puphpeteer\Resources\Target target()
* @method \Nesk\Puphpeteer\Resources\Target waitForTarget(callable(\Nesk\Puphpeteer\Resources\Target $x): bool $predicate, array<string, mixed> $options = null)
* @method \Nesk\Puphpeteer\Resources\Page[] pages()
* @method Page newPage()
* @method Target[] targets()
* @method Target target()
* @method Target waitForTarget(\Nesk\Rialto\Data\JsFunction $predicate, array $options = [])
* @method Page[] pages()
* @method string version()
* @method string userAgent()
* @method void close()
Expand Down
10 changes: 5 additions & 5 deletions src/Resources/BrowserContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
namespace Nesk\Puphpeteer\Resources;

/**
* @method \Nesk\Puphpeteer\Resources\Target[] targets()
* @method \Nesk\Puphpeteer\Resources\Target waitForTarget(callable(\Nesk\Puphpeteer\Resources\Target $x): bool $predicate, array{ timeout: float } $options = null)
* @method \Nesk\Puphpeteer\Resources\Page[] pages()
* @method Target[] targets()
* @method Target waitForTarget(\Nesk\Rialto\Data\JsFunction $predicate, array $options = [])
* @method Page[] pages()
* @method bool isIncognito()
* @method void overridePermissions(string $origin, string[] $permissions)
* @method void clearPermissionOverrides()
* @method \Nesk\Puphpeteer\Resources\Page newPage()
* @method \Nesk\Puphpeteer\Resources\Browser browser()
* @method Page newPage()
* @method Browser browser()
* @method void close()
*/
class BrowserContext extends EventEmitter
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/BrowserFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @method mixed product()
* @method string host()
* @method bool canDownload(string $revision)
* @method mixed download(string $revision, callable(float $x, float $y): void $progressCallback = null)
* @method mixed download(string $revision, \Nesk\Rialto\Data\JsFunction $progressCallback = null)
* @method string[] localRevisions()
* @method void remove(string $revision)
* @method mixed revisionInfo(string $revision)
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/ConsoleMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* @method mixed type()
* @method string text()
* @method \Nesk\Puphpeteer\Resources\JSHandle[] args()
* @method JSHandle[] args()
* @method mixed location()
* @method mixed[] stackTrace()
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/Coverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use Nesk\Rialto\Data\BasicResource;

/**
* @method void startJSCoverage(array<string, mixed> $options = null)
* @method void startJSCoverage(array $options = [])
* @method mixed[] stopJSCoverage()
* @method void startCSSCoverage(array<string, mixed> $options = null)
* @method void startCSSCoverage(array $options = [])
nesk marked this conversation as resolved.
Show resolved Hide resolved
* @method mixed[] stopCSSCoverage()
*/
class Coverage extends BasicResource
Expand Down
12 changes: 6 additions & 6 deletions src/Resources/ElementHandle.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
use Nesk\Puphpeteer\Traits\AliasesEvaluationMethods;

/**
* @method \Nesk\Puphpeteer\Resources\ElementHandle<mixed>|null asElement()
* @method \Nesk\Puphpeteer\Resources\Frame|null contentFrame()
* @method ElementHandle|mixed[]|null asElement()
* @method Frame|null contentFrame()
* @method void hover()
* @method void click(array<string, mixed> $options = null)
* @method void click(array $options = [])
* @method string[] select(string ...$values)
* @method void uploadFile(string ...$filePaths)
* @method void tap()
* @method void focus()
* @method void type(string $text, array{ delay: float } $options = null)
* @method void press(mixed $key, array<string, mixed> $options = null)
* @method void type(string $text, array $options = [])
* @method void press(mixed $key, array $options = [])
* @method mixed|null boundingBox()
* @method mixed|null boxModel()
* @method string|mixed|null screenshot(array{ } $options = null)
* @method string|mixed|null screenshot(array $options = [])
* @method bool isIntersectingViewport()
*/
class ElementHandle extends JSHandle
Expand Down
12 changes: 6 additions & 6 deletions src/Resources/EventEmitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
use Nesk\Rialto\Data\BasicResource;

/**
* @method \Nesk\Puphpeteer\Resources\EventEmitter on(mixed $event, mixed $handler)
* @method \Nesk\Puphpeteer\Resources\EventEmitter off(mixed $event, mixed $handler)
* @method \Nesk\Puphpeteer\Resources\EventEmitter removeListener(mixed $event, mixed $handler)
* @method \Nesk\Puphpeteer\Resources\EventEmitter addListener(mixed $event, mixed $handler)
* @method EventEmitter on(mixed $event, mixed $handler)
* @method EventEmitter off(mixed $event, mixed $handler)
* @method EventEmitter removeListener(mixed $event, mixed $handler)
* @method EventEmitter addListener(mixed $event, mixed $handler)
* @method bool emit(mixed $event, mixed $eventData = null)
* @method \Nesk\Puphpeteer\Resources\EventEmitter once(mixed $event, mixed $handler)
* @method EventEmitter once(mixed $event, mixed $handler)
* @method float listenerCount(mixed $event)
* @method \Nesk\Puphpeteer\Resources\EventEmitter removeAllListeners(mixed $event = null)
* @method EventEmitter removeAllListeners(mixed $event = null)
*/
class EventEmitter extends BasicResource
{
Expand Down
8 changes: 4 additions & 4 deletions src/Resources/ExecutionContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
use Nesk\Rialto\Data\BasicResource;

/**
* @method \Nesk\Puphpeteer\Resources\Frame|null frame()
* @method mixed evaluate(callable|string $pageFunction, mixed ...$args)
* @method \Nesk\Puphpeteer\Resources\JSHandle|\Nesk\Puphpeteer\Resources\ElementHandle evaluateHandle(callable|string $pageFunction, int|float|string|bool|null|array|\Nesk\Puphpeteer\Resources\JSHandle ...$args)
* @method \Nesk\Puphpeteer\Resources\JSHandle queryObjects(\Nesk\Puphpeteer\Resources\JSHandle $prototypeHandle)
* @method Frame|null frame()
* @method mixed evaluate(\Nesk\Rialto\Data\JsFunction|string $pageFunction, mixed ...$args)
* @method JSHandle|ElementHandle evaluateHandle(\Nesk\Rialto\Data\JsFunction|string $pageFunction, int|float|string|bool|null|array|JSHandle ...$args)
* @method JSHandle queryObjects(JSHandle $prototypeHandle)
*/
class ExecutionContext extends BasicResource
{
Expand Down
32 changes: 16 additions & 16 deletions src/Resources/Frame.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@
use Nesk\Puphpeteer\Traits\AliasesEvaluationMethods;

/**
* @method \Nesk\Puphpeteer\Resources\HTTPResponse|null goto(string $url, array{ referer: string, timeout: float, waitUntil: string|string[] } $options = null)
* @method \Nesk\Puphpeteer\Resources\HTTPResponse|null waitForNavigation(array{ timeout: float, waitUntil: string|string[] } $options = null)
* @method \Nesk\Puphpeteer\Resources\ExecutionContext executionContext()
* @method mixed evaluateHandle(callable|string $pageFunction, int|float|string|bool|null|array|\Nesk\Puphpeteer\Resources\JSHandle ...$args)
* @method mixed evaluate(mixed $pageFunction, int|float|string|bool|null|array|\Nesk\Puphpeteer\Resources\JSHandle ...$args)
* @method HTTPResponse|null goto(string $url, array $options = [])
* @method HTTPResponse|null waitForNavigation(array $options = [])
* @method ExecutionContext executionContext()
* @method mixed evaluateHandle(\Nesk\Rialto\Data\JsFunction|string $pageFunction, int|float|string|bool|null|array|JSHandle ...$args)
* @method mixed evaluate(\Nesk\Rialto\Data\JsFunction $pageFunction, int|float|string|bool|null|array|JSHandle ...$args)
* @method string content()
* @method void setContent(string $html, array{ timeout: float, waitUntil: string|string[] } $options = null)
* @method void setContent(string $html, array $options = [])
* @method string name()
* @method string url()
* @method \Nesk\Puphpeteer\Resources\Frame|null parentFrame()
* @method \Nesk\Puphpeteer\Resources\Frame[] childFrames()
* @method Frame|null parentFrame()
* @method Frame[] childFrames()
* @method bool isDetached()
* @method \Nesk\Puphpeteer\Resources\ElementHandle addScriptTag(array<string, mixed> $options)
* @method \Nesk\Puphpeteer\Resources\ElementHandle addStyleTag(array<string, mixed> $options)
* @method void click(string $selector, array{ delay: float, button: mixed, clickCount: float } $options = null)
* @method ElementHandle addScriptTag(array $options)
* @method ElementHandle addStyleTag(array $options)
* @method void click(string $selector, array $options = [])
* @method void focus(string $selector)
* @method void hover(string $selector)
* @method string[] select(string $selector, string ...$values)
* @method void tap(string $selector)
* @method void type(string $selector, string $text, array{ delay: float } $options = null)
* @method \Nesk\Puphpeteer\Resources\JSHandle|null waitFor(string|float|callable $selectorOrFunctionOrTimeout, array<string, mixed> $options = null, int|float|string|bool|null|array|\Nesk\Puphpeteer\Resources\JSHandle ...$args)
* @method void type(string $selector, string $text, array $options = [])
* @method JSHandle|null waitFor(string|float|\Nesk\Rialto\Data\JsFunction $selectorOrFunctionOrTimeout, array|string[]|mixed[] $options = null, int|float|string|bool|null|array|JSHandle ...$args)
* @method void waitForTimeout(float $milliseconds)
* @method \Nesk\Puphpeteer\Resources\ElementHandle|null waitForSelector(string $selector, array<string, mixed> $options = null)
* @method \Nesk\Puphpeteer\Resources\ElementHandle|null waitForXPath(string $xpath, array<string, mixed> $options = null)
* @method \Nesk\Puphpeteer\Resources\JSHandle waitForFunction(callable|string $pageFunction, array<string, mixed> $options = null, int|float|string|bool|null|array|\Nesk\Puphpeteer\Resources\JSHandle ...$args)
* @method ElementHandle|null waitForSelector(string $selector, array $options = [])
* @method ElementHandle|null waitForXPath(string $xpath, array $options = [])
* @method JSHandle waitForFunction(\Nesk\Rialto\Data\JsFunction|string $pageFunction, array $options = [], int|float|string|bool|null|array|JSHandle ...$args)
* @method string title()
*/
class Frame extends BasicResource
Expand Down
10 changes: 5 additions & 5 deletions src/Resources/HTTPRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
* @method string resourceType()
* @method string method()
* @method string|null postData()
* @method array<string, string> headers()
* @method \Nesk\Puphpeteer\Resources\HTTPResponse|null response()
* @method \Nesk\Puphpeteer\Resources\Frame|null frame()
* @method array|string[]|string[] headers()
* @method HTTPResponse|null response()
* @method Frame|null frame()
* @method bool isNavigationRequest()
* @method \Nesk\Puphpeteer\Resources\HTTPRequest[] redirectChain()
* @method array{ errorText: string }|null failure()
* @method HTTPRequest[] redirectChain()
* @method array|null failure()
* @method void continue(mixed $overrides = null)
* @method void respond(mixed $response)
* @method void abort(mixed $errorCode = null)
Expand Down
8 changes: 4 additions & 4 deletions src/Resources/HTTPResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
* @method bool ok()
* @method float status()
* @method string statusText()
* @method array<string, string> headers()
* @method \Nesk\Puphpeteer\Resources\SecurityDetails|null securityDetails()
* @method array|string[]|string[] headers()
* @method SecurityDetails|null securityDetails()
* @method mixed buffer()
* @method string text()
* @method mixed json()
* @method \Nesk\Puphpeteer\Resources\HTTPRequest request()
* @method HTTPRequest request()
* @method bool fromCache()
* @method bool fromServiceWorker()
* @method \Nesk\Puphpeteer\Resources\Frame|null frame()
* @method Frame|null frame()
*/
class HTTPResponse extends BasicResource
{
Expand Down
14 changes: 7 additions & 7 deletions src/Resources/JSHandle.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
use Nesk\Rialto\Data\BasicResource;

/**
* @method \Nesk\Puphpeteer\Resources\ExecutionContext executionContext()
* @method mixed evaluate(mixed|string $pageFunction, int|float|string|bool|null|array|\Nesk\Puphpeteer\Resources\JSHandle ...$args)
* @method \Nesk\Puphpeteer\Resources\JSHandle|\Nesk\Puphpeteer\Resources\ElementHandle evaluateHandle(callable|string $pageFunction, int|float|string|bool|null|array|\Nesk\Puphpeteer\Resources\JSHandle ...$args)
* @method \Nesk\Puphpeteer\Resources\JSHandle|null getProperty(string $propertyName)
* @method array<string, \Nesk\Puphpeteer\Resources\JSHandle> getProperties()
* @method array<string, mixed> jsonValue()
* @method \Nesk\Puphpeteer\Resources\ElementHandle|null asElement()
* @method ExecutionContext executionContext()
* @method mixed evaluate(\Nesk\Rialto\Data\JsFunction $pageFunction, int|float|string|bool|null|array|JSHandle ...$args)
* @method JSHandle|ElementHandle evaluateHandle(\Nesk\Rialto\Data\JsFunction|string $pageFunction, int|float|string|bool|null|array|JSHandle ...$args)
* @method JSHandle|null getProperty(string $propertyName)
* @method array|string[]|JSHandle[] getProperties()
* @method array|string[]|mixed[] jsonValue()
* @method ElementHandle|null asElement()
* @method void dispose()
* @method string toString()
*/
Expand Down
6 changes: 3 additions & 3 deletions src/Resources/Keyboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
use Nesk\Rialto\Data\BasicResource;

/**
* @method void down(mixed $key, array{ text: string } $options = null)
* @method void down(mixed $key, array $options = [])
* @method void up(mixed $key)
* @method void sendCharacter(string $char)
* @method void type(string $text, array{ delay: float } $options = null)
* @method void press(mixed $key, array{ delay: float, text: string } $options = null)
* @method void type(string $text, array $options = [])
* @method void press(mixed $key, array $options = [])
*/
class Keyboard extends BasicResource
{
Expand Down
10 changes: 5 additions & 5 deletions src/Resources/Mouse.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
use Nesk\Rialto\Data\BasicResource;

/**
* @method void move(float $x, float $y, array{ steps: float } $options = null)
* @method void click(float $x, float $y, array<string, mixed>&array{ delay: float } $options = null)
* @method void down(array<string, mixed> $options = null)
* @method void up(array<string, mixed> $options = null)
* @method void wheel(array<string, mixed> $options = null)
* @method void move(float $x, float $y, array $options = [])
* @method void click(float $x, float $y, array $options = [])
* @method void down(array $options = [])
* @method void up(array $options = [])
* @method void wheel(array $options = [])
*/
class Mouse extends BasicResource
{
Expand Down
Loading