Code Clean up, more testing

Remove unused code and classes.
Clean up code to remove all named constant from them and throw
deprecation alerts if used.
Add basic psalm setup in root folder and remove from www folder
This commit is contained in:
Clemens Schwaighofer
2023-03-09 15:55:57 +09:00
parent d952c5f774
commit 03fbcaecfb
149 changed files with 3406 additions and 1937 deletions

View File

@@ -22,6 +22,8 @@ class ComposerAutoloaderInitdd705c6e8ab22e0d642372dec7767718
return self::$loader;
}
require __DIR__ . '/platform_check.php';
spl_autoload_register(array('ComposerAutoloaderInitdd705c6e8ab22e0d642372dec7767718', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitdd705c6e8ab22e0d642372dec7767718', 'loadClassLoader'));

View File

@@ -277,17 +277,17 @@
},
{
"name": "microsoft/tolerant-php-parser",
"version": "v0.1.1",
"version_normalized": "0.1.1.0",
"version": "v0.1.2",
"version_normalized": "0.1.2.0",
"source": {
"type": "git",
"url": "https://github.com/microsoft/tolerant-php-parser.git",
"reference": "6a965617cf484355048ac6d2d3de7b6ec93abb16"
"reference": "3eccfd273323aaf69513e2f1c888393f5947804b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/microsoft/tolerant-php-parser/zipball/6a965617cf484355048ac6d2d3de7b6ec93abb16",
"reference": "6a965617cf484355048ac6d2d3de7b6ec93abb16",
"url": "https://api.github.com/repos/microsoft/tolerant-php-parser/zipball/3eccfd273323aaf69513e2f1c888393f5947804b",
"reference": "3eccfd273323aaf69513e2f1c888393f5947804b",
"shasum": ""
},
"require": {
@@ -296,7 +296,7 @@
"require-dev": {
"phpunit/phpunit": "^8.5.15"
},
"time": "2021-07-16T21:28:12+00:00",
"time": "2022-10-05T17:30:19+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@@ -319,7 +319,7 @@
"description": "Tolerant PHP-to-AST parser designed for IDE usage scenarios",
"support": {
"issues": "https://github.com/microsoft/tolerant-php-parser/issues",
"source": "https://github.com/microsoft/tolerant-php-parser/tree/v0.1.1"
"source": "https://github.com/microsoft/tolerant-php-parser/tree/v0.1.2"
},
"install-path": "../microsoft/tolerant-php-parser"
},
@@ -379,17 +379,17 @@
},
{
"name": "phan/phan",
"version": "5.4.1",
"version_normalized": "5.4.1.0",
"version": "5.4.2",
"version_normalized": "5.4.2.0",
"source": {
"type": "git",
"url": "https://github.com/phan/phan.git",
"reference": "fef40178a952bcfcc3f69b76989dd613c3d5c759"
"reference": "4f2870ed6fea320f62f3c3c63f3274d357a7980e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phan/phan/zipball/fef40178a952bcfcc3f69b76989dd613c3d5c759",
"reference": "fef40178a952bcfcc3f69b76989dd613c3d5c759",
"url": "https://api.github.com/repos/phan/phan/zipball/4f2870ed6fea320f62f3c3c63f3274d357a7980e",
"reference": "4f2870ed6fea320f62f3c3c63f3274d357a7980e",
"shasum": ""
},
"require": {
@@ -399,7 +399,7 @@
"ext-json": "*",
"ext-tokenizer": "*",
"felixfbecker/advanced-json-rpc": "^3.0.4",
"microsoft/tolerant-php-parser": "0.1.1",
"microsoft/tolerant-php-parser": "0.1.2",
"netresearch/jsonmapper": "^1.6.0|^2.0|^3.0|^4.0",
"php": "^7.2.0|^8.0.0",
"sabre/event": "^5.1.3",
@@ -419,7 +419,7 @@
"ext-tokenizer": "Needed for fallback/polyfill parser support and file/line-based suppressions.",
"ext-var_representation": "Suggested for converting values to strings in issue messages"
},
"time": "2022-08-26T00:49:07+00:00",
"time": "2023-03-03T17:20:24+00:00",
"bin": [
"phan",
"phan_client",
@@ -455,7 +455,7 @@
],
"support": {
"issues": "https://github.com/phan/phan/issues",
"source": "https://github.com/phan/phan/tree/5.4.1"
"source": "https://github.com/phan/phan/tree/5.4.2"
},
"install-path": "../phan/phan"
},
@@ -922,17 +922,17 @@
},
{
"name": "symfony/console",
"version": "v6.2.5",
"version_normalized": "6.2.5.0",
"version": "v6.2.7",
"version_normalized": "6.2.7.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "3e294254f2191762c1d137aed4b94e966965e985"
"reference": "cbad09eb8925b6ad4fb721c7a179344dc4a19d45"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/3e294254f2191762c1d137aed4b94e966965e985",
"reference": "3e294254f2191762c1d137aed4b94e966965e985",
"url": "https://api.github.com/repos/symfony/console/zipball/cbad09eb8925b6ad4fb721c7a179344dc4a19d45",
"reference": "cbad09eb8925b6ad4fb721c7a179344dc4a19d45",
"shasum": ""
},
"require": {
@@ -967,7 +967,7 @@
"symfony/lock": "",
"symfony/process": ""
},
"time": "2023-01-01T08:38:09+00:00",
"time": "2023-02-25T17:00:03+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@@ -1001,7 +1001,7 @@
"terminal"
],
"support": {
"source": "https://github.com/symfony/console/tree/v6.2.5"
"source": "https://github.com/symfony/console/tree/v6.2.7"
},
"funding": [
{
@@ -1021,23 +1021,23 @@
},
{
"name": "symfony/deprecation-contracts",
"version": "v3.2.0",
"version_normalized": "3.2.0.0",
"version": "v3.2.1",
"version_normalized": "3.2.1.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "1ee04c65529dea5d8744774d474e7cbd2f1206d3"
"reference": "e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/1ee04c65529dea5d8744774d474e7cbd2f1206d3",
"reference": "1ee04c65529dea5d8744774d474e7cbd2f1206d3",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e",
"reference": "e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e",
"shasum": ""
},
"require": {
"php": ">=8.1"
},
"time": "2022-11-25T10:21:52+00:00",
"time": "2023-03-01T10:25:55+00:00",
"type": "library",
"extra": {
"branch-alias": {
@@ -1071,7 +1071,7 @@
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.2.0"
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.2.1"
},
"funding": [
{
@@ -1519,17 +1519,17 @@
},
{
"name": "symfony/service-contracts",
"version": "v3.2.0",
"version_normalized": "3.2.0.0",
"version": "v3.2.1",
"version_normalized": "3.2.1.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/service-contracts.git",
"reference": "aac98028c69df04ee77eb69b96b86ee51fbf4b75"
"reference": "a8c9cedf55f314f3a186041d19537303766df09a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/aac98028c69df04ee77eb69b96b86ee51fbf4b75",
"reference": "aac98028c69df04ee77eb69b96b86ee51fbf4b75",
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/a8c9cedf55f314f3a186041d19537303766df09a",
"reference": "a8c9cedf55f314f3a186041d19537303766df09a",
"shasum": ""
},
"require": {
@@ -1542,7 +1542,7 @@
"suggest": {
"symfony/service-implementation": ""
},
"time": "2022-11-25T10:21:52+00:00",
"time": "2023-03-01T10:32:47+00:00",
"type": "library",
"extra": {
"branch-alias": {
@@ -1587,7 +1587,7 @@
"standards"
],
"support": {
"source": "https://github.com/symfony/service-contracts/tree/v3.2.0"
"source": "https://github.com/symfony/service-contracts/tree/v3.2.1"
},
"funding": [
{
@@ -1607,17 +1607,17 @@
},
{
"name": "symfony/string",
"version": "v6.2.5",
"version_normalized": "6.2.5.0",
"version": "v6.2.7",
"version_normalized": "6.2.7.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "b2dac0fa27b1ac0f9c0c0b23b43977f12308d0b0"
"reference": "67b8c1eec78296b85dc1c7d9743830160218993d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/b2dac0fa27b1ac0f9c0c0b23b43977f12308d0b0",
"reference": "b2dac0fa27b1ac0f9c0c0b23b43977f12308d0b0",
"url": "https://api.github.com/repos/symfony/string/zipball/67b8c1eec78296b85dc1c7d9743830160218993d",
"reference": "67b8c1eec78296b85dc1c7d9743830160218993d",
"shasum": ""
},
"require": {
@@ -1637,7 +1637,7 @@
"symfony/translation-contracts": "^2.0|^3.0",
"symfony/var-exporter": "^5.4|^6.0"
},
"time": "2023-01-01T08:38:09+00:00",
"time": "2023-02-24T10:42:00+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@@ -1676,7 +1676,7 @@
"utf8"
],
"support": {
"source": "https://github.com/symfony/string/tree/v6.2.5"
"source": "https://github.com/symfony/string/tree/v6.2.7"
},
"funding": [
{

View File

@@ -1,24 +1,15 @@
<?php return array(
'root' => array(
'name' => '__root__',
'name' => 'egrajp/development-corelibs-dev',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '44f37b7f74e1fcbfbbdf26036117d14404011abd',
'reference' => NULL,
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev' => true,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '44f37b7f74e1fcbfbbdf26036117d14404011abd',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev_requirement' => false,
),
'composer/pcre' => array(
'pretty_version' => '3.1.0',
'version' => '3.1.0.0',
@@ -46,6 +37,15 @@
'aliases' => array(),
'dev_requirement' => true,
),
'egrajp/development-corelibs-dev' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => NULL,
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev_requirement' => false,
),
'felixfbecker/advanced-json-rpc' => array(
'pretty_version' => 'v3.2.1',
'version' => '3.2.1.0',
@@ -56,9 +56,9 @@
'dev_requirement' => true,
),
'microsoft/tolerant-php-parser' => array(
'pretty_version' => 'v0.1.1',
'version' => '0.1.1.0',
'reference' => '6a965617cf484355048ac6d2d3de7b6ec93abb16',
'pretty_version' => 'v0.1.2',
'version' => '0.1.2.0',
'reference' => '3eccfd273323aaf69513e2f1c888393f5947804b',
'type' => 'library',
'install_path' => __DIR__ . '/../microsoft/tolerant-php-parser',
'aliases' => array(),
@@ -74,9 +74,9 @@
'dev_requirement' => true,
),
'phan/phan' => array(
'pretty_version' => '5.4.1',
'version' => '5.4.1.0',
'reference' => 'fef40178a952bcfcc3f69b76989dd613c3d5c759',
'pretty_version' => '5.4.2',
'version' => '5.4.2.0',
'reference' => '4f2870ed6fea320f62f3c3c63f3274d357a7980e',
'type' => 'project',
'install_path' => __DIR__ . '/../phan/phan',
'aliases' => array(),
@@ -161,18 +161,18 @@
'dev_requirement' => true,
),
'symfony/console' => array(
'pretty_version' => 'v6.2.5',
'version' => '6.2.5.0',
'reference' => '3e294254f2191762c1d137aed4b94e966965e985',
'pretty_version' => 'v6.2.7',
'version' => '6.2.7.0',
'reference' => 'cbad09eb8925b6ad4fb721c7a179344dc4a19d45',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/console',
'aliases' => array(),
'dev_requirement' => true,
),
'symfony/deprecation-contracts' => array(
'pretty_version' => 'v3.2.0',
'version' => '3.2.0.0',
'reference' => '1ee04c65529dea5d8744774d474e7cbd2f1206d3',
'pretty_version' => 'v3.2.1',
'version' => '3.2.1.0',
'reference' => 'e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/deprecation-contracts',
'aliases' => array(),
@@ -224,18 +224,18 @@
'dev_requirement' => true,
),
'symfony/service-contracts' => array(
'pretty_version' => 'v3.2.0',
'version' => '3.2.0.0',
'reference' => 'aac98028c69df04ee77eb69b96b86ee51fbf4b75',
'pretty_version' => 'v3.2.1',
'version' => '3.2.1.0',
'reference' => 'a8c9cedf55f314f3a186041d19537303766df09a',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/service-contracts',
'aliases' => array(),
'dev_requirement' => true,
),
'symfony/string' => array(
'pretty_version' => 'v6.2.5',
'version' => '6.2.5.0',
'reference' => 'b2dac0fa27b1ac0f9c0c0b23b43977f12308d0b0',
'pretty_version' => 'v6.2.7',
'version' => '6.2.7.0',
'reference' => '67b8c1eec78296b85dc1c7d9743830160218993d',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/string',
'aliases' => array(),

26
vendor/composer/platform_check.php vendored Normal file
View File

@@ -0,0 +1,26 @@
<?php
// platform_check.php @generated by Composer
$issues = array();
if (!(PHP_VERSION_ID >= 80100)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 8.1.0". You are running ' . PHP_VERSION . '.';
}
if ($issues) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
} elseif (!headers_sent()) {
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
}
}
trigger_error(
'Composer detected issues in your platform: ' . implode(' ', $issues),
E_USER_ERROR
);
}

View File

@@ -1,7 +0,0 @@
parameters:
level: 2
paths:
- src/
ignoreErrors:
# phpstan issue, see: https://github.com/phpstan/phpstan/issues/1306
- "/Variable .unaryExpression might not be defined./"

View File

@@ -31,7 +31,7 @@ trait NamespacedNameTrait {
return ResolvedName::buildName($this->getNameParts(), $content);
}
if ($namespaceDefinition->name !== null) {
if ($namespaceDefinition->name instanceof QualifiedName) {
$resolvedName = ResolvedName::buildName($namespaceDefinition->name->nameParts, $content);
} else {
$resolvedName = ResolvedName::buildName([], $content);
@@ -47,4 +47,4 @@ trait NamespacedNameTrait {
}
return $resolvedName;
}
}
}

View File

@@ -91,7 +91,7 @@ abstract class Node implements \JsonSerializable {
* Gets first child that is an instance of one of the provided classes.
* Returns null if there is no match.
*
* @param array ...$classNames
* @param string ...$classNames
* @return Node|null
*/
public function getFirstChildNode(...$classNames) {
@@ -117,7 +117,7 @@ abstract class Node implements \JsonSerializable {
* Gets first descendant node that is an instance of one of the provided classes.
* Returns null if there is no match.
*
* @param array ...$classNames
* @param string ...$classNames
* @return Node|null
*/
public function getFirstDescendantNode(...$classNames) {
@@ -417,7 +417,7 @@ abstract class Node implements \JsonSerializable {
return $this->getRoot()->fileContents;
}
public function getUri() : string {
public function getUri() : ?string {
return $this->getRoot()->uri;
}

View File

@@ -8,10 +8,11 @@ namespace Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Node\DelimitedList;
use Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Node\QualifiedName;
use Microsoft\PhpParser\Token;
class CallExpression extends Expression {
/** @var Expression */
/** @var QualifiedName|Expression */
public $callableExpression;
/** @var Token */

View File

@@ -14,7 +14,7 @@ class YieldExpression extends Expression {
/** @var Token */
public $yieldOrYieldFromKeyword;
/** @var ArrayElement */
/** @var ArrayElement|null */
public $arrayElement;
const CHILD_NAMES = ['yieldOrYieldFromKeyword', 'arrayElement'];

View File

@@ -0,0 +1,29 @@
<?php
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
namespace Microsoft\PhpParser\Node;
use Microsoft\PhpParser\MissingToken;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Node\DelimitedList\QualifiedNameList;
use Microsoft\PhpParser\Token;
class ParenthesizedIntersectionType extends Node{
/** @var Token */
public $openParen;
/** @var QualifiedNameList|MissingToken */
public $children;
/** @var Token */
public $closeParen;
const CHILD_NAMES = [
'openParen',
'children',
'closeParen'
];
}

View File

@@ -13,7 +13,7 @@ class SourceFileNode extends Node {
/** @var string */
public $fileContents;
/** @var string */
/** @var ?string */
public $uri;
/** @var Node[] */

View File

@@ -22,9 +22,12 @@ class ClassDeclaration extends StatementNode implements NamespacedNameInterface,
/** @var AttributeGroup[]|null */
public $attributes;
/** @var Token */
/** @var Token abstract/final/readonly modifier */
public $abstractOrFinalModifier;
/** @var Token[] additional abstract/final/readonly modifiers */
public $modifiers;
/** @var Token */
public $classKeyword;
@@ -43,6 +46,7 @@ class ClassDeclaration extends StatementNode implements NamespacedNameInterface,
const CHILD_NAMES = [
'attributes',
'abstractOrFinalModifier',
'modifiers',
'classKeyword',
'name',
'classBaseClause',

View File

@@ -0,0 +1,45 @@
<?php
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
namespace Microsoft\PhpParser\Node\Statement;
use Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Token;
class HaltCompilerStatement extends Expression {
/** @var Token */
public $haltCompilerKeyword;
/** @var Token */
public $openParen;
/** @var Token */
public $closeParen;
/** @var Token (there is an implicit ')' before php close tags (`?>`)) */
public $semicolonOrCloseTag;
/** @var Token|null TokenKind::InlineHtml data unless there are no bytes (This is optional if there is nothing after the semicolon) */
public $data;
const CHILD_NAMES = [
'haltCompilerKeyword',
'openParen',
'closeParen',
'semicolonOrCloseTag',
'data',
];
/**
* @return int
*/
public function getHaltCompilerOffset() {
// This accounts for the fact that PHP close tags may include a single newline,
// and that $this->data may be null.
return $this->semicolonOrCloseTag->getEndPosition();
}
}

View File

@@ -6,6 +6,7 @@
namespace Microsoft\PhpParser;
use Closure;
use Microsoft\PhpParser\Node\AnonymousFunctionUseClause;
use Microsoft\PhpParser\Node\ArrayElement;
use Microsoft\PhpParser\Node\Attribute;
@@ -70,6 +71,7 @@ use Microsoft\PhpParser\Node\MissingMemberDeclaration;
use Microsoft\PhpParser\Node\NamespaceAliasingClause;
use Microsoft\PhpParser\Node\NamespaceUseGroupClause;
use Microsoft\PhpParser\Node\NumericLiteral;
use Microsoft\PhpParser\Node\ParenthesizedIntersectionType;
use Microsoft\PhpParser\Node\PropertyDeclaration;
use Microsoft\PhpParser\Node\ReservedWord;
use Microsoft\PhpParser\Node\StringLiteral;
@@ -95,6 +97,7 @@ use Microsoft\PhpParser\Node\Statement\{
ForStatement,
FunctionDeclaration,
GotoStatement,
HaltCompilerStatement,
IfStatementNode,
InlineHtml,
InterfaceDeclaration,
@@ -144,8 +147,9 @@ class Parser {
[TokenKind::ArrayKeyword, TokenKind::CallableKeyword, TokenKind::BoolReservedWord,
TokenKind::FloatReservedWord, TokenKind::IntReservedWord, TokenKind::StringReservedWord,
TokenKind::ObjectReservedWord, TokenKind::NullReservedWord, TokenKind::FalseReservedWord,
TokenKind::IterableReservedWord, TokenKind::MixedReservedWord]; // TODO update spec
$this->returnTypeDeclarationTokens = \array_merge([TokenKind::VoidReservedWord, TokenKind::NullReservedWord, TokenKind::FalseReservedWord, TokenKind::StaticKeyword], $this->parameterTypeDeclarationTokens);
TokenKind::TrueReservedWord, TokenKind::IterableReservedWord, TokenKind::MixedReservedWord,
TokenKind::VoidReservedWord, TokenKind::NeverReservedWord]; // TODO update spec
$this->returnTypeDeclarationTokens = \array_merge([TokenKind::StaticKeyword], $this->parameterTypeDeclarationTokens);
}
/**
@@ -557,10 +561,8 @@ class Parser {
// class-declaration
case TokenKind::FinalKeyword:
case TokenKind::AbstractKeyword:
if (!$this->lookahead(TokenKind::ClassKeyword)) {
$this->advanceToken();
return new SkippedToken($token);
}
case TokenKind::ReadonlyKeyword:
// fallthrough
case TokenKind::ClassKeyword:
return $this->parseClassDeclaration($parentNode);
@@ -614,6 +616,15 @@ class Parser {
case TokenKind::UnsetKeyword:
return $this->parseUnsetStatement($parentNode);
case TokenKind::HaltCompilerKeyword:
if ($parentNode instanceof SourceFileNode) {
return $this->parseHaltCompilerStatement($parentNode);
}
// __halt_compiler is a fatal compile error anywhere other than the top level.
// It won't be seen elsewhere in other programs - warn about the token being unexpected.
$this->advanceToken();
return new SkippedToken($token);
}
$expressionStatement = new ExpressionStatement();
@@ -657,10 +668,20 @@ class Parser {
};
}
/** @return Token[] */
private function parseClassModifiers(): array {
$modifiers = [];
while ($token = $this->eatOptional(TokenKind::AbstractKeyword, TokenKind::FinalKeyword, TokenKind::ReadonlyKeyword)) {
$modifiers[] = $token;
}
return $modifiers;
}
private function parseClassDeclaration($parentNode) : Node {
$classNode = new ClassDeclaration(); // TODO verify not nested
$classNode->parent = $parentNode;
$classNode->abstractOrFinalModifier = $this->eatOptional(TokenKind::AbstractKeyword, TokenKind::FinalKeyword);
$classNode->abstractOrFinalModifier = $this->eatOptional(TokenKind::AbstractKeyword, TokenKind::FinalKeyword, TokenKind::ReadonlyKeyword);
$classNode->modifiers = $this->parseClassModifiers();
$classNode->classKeyword = $this->eat1(TokenKind::ClassKeyword);
$classNode->name = $this->eat($this->nameOrReservedWordTokens); // TODO should be any
$classNode->name->kind = TokenKind::Name;
@@ -838,9 +859,6 @@ class Parser {
if (end($children) instanceof MissingToken && ($children[\count($children) - 2]->kind ?? null) === TokenKind::AmpersandToken) {
array_pop($parameter->typeDeclarationList->children);
$parameter->byRefToken = array_pop($parameter->typeDeclarationList->children);
if (!$parameter->typeDeclarationList->children) {
unset($parameter->typeDeclarationList);
}
}
} elseif ($parameter->questionToken) {
// TODO ParameterType?
@@ -882,27 +900,22 @@ class Parser {
/**
* Attempt to parse the return type after the `:` and optional `?` token.
*
* TODO: Consider changing the return type to a new class TypeList in a future major release?
* ParenthesizedIntersectionType is not a qualified name.
* @return DelimitedList\QualifiedNameList|null
*/
private function parseReturnTypeDeclarationList($parentNode) {
$result = $this->parseDelimitedList(
DelimitedList\QualifiedNameList::class,
self::TYPE_DELIMITER_TOKENS,
function ($token) {
return \in_array($token->kind, $this->returnTypeDeclarationTokens, true) || $this->isQualifiedNameStart($token);
return $this->parseUnionTypeDeclarationList(
$parentNode,
function ($token): bool {
return \in_array($token->kind, $this->returnTypeDeclarationTokens, true) ||
$this->isQualifiedNameStart($token);
},
function ($parentNode) {
return $this->parseReturnTypeDeclaration($parentNode);
},
$parentNode,
false);
// Add a MissingToken so that this will warn about `function () : T| {}`
// TODO: Make this a reusable abstraction?
if ($result && in_array(end($result->children)->kind ?? null, self::TYPE_DELIMITER_TOKENS)) {
$result->children[] = new MissingToken(TokenKind::ReturnType, $this->token->fullStart);
}
return $result;
TokenKind::ReturnType
);
}
private function parseReturnTypeDeclaration($parentNode) {
@@ -917,28 +930,109 @@ class Parser {
}
/**
* Parse a union type such as A, A|B, A&B, A|(B&C), rejecting invalid syntax combinations.
*
* @param Node $parentNode
* @param Closure(Token):bool $isTypeStart
* @param Closure(Node):(Node|Token|null) $parseType
* @param int $expectedTypeKind expected kind for token type
* @return DelimitedList\QualifiedNameList|null
*/
private function parseUnionTypeDeclarationList($parentNode, Closure $isTypeStart, Closure $parseType, int $expectedTypeKind) {
$result = new DelimitedList\QualifiedNameList();
$token = $this->getCurrentToken();
$delimiter = self::TYPE_DELIMITER_TOKENS;
do {
if ($token->kind === TokenKind::OpenParenToken || $isTypeStart($token)) {
// Forbid mixing A&(B&C) if '&' was already seen
$openParen = in_array(TokenKind::BarToken, $delimiter, true)
? $this->eatOptional(TokenKind::OpenParenToken)
: null;
if ($openParen) {
$element = $this->parseParenthesizedIntersectionType($result, $openParen, $isTypeStart, $parseType);
// Forbid mixing (A&B)&C by forbidding `&` separator after a parenthesized intersection type.
$delimiter = [TokenKind::BarToken];
} else {
$element = $parseType($result);
}
$result->addElement($element);
} else {
break;
}
$delimiterToken = $this->eatOptional($delimiter);
if ($delimiterToken !== null) {
$result->addElement($delimiterToken);
$delimiter = [$delimiterToken->kind];
}
$token = $this->getCurrentToken();
} while ($delimiterToken !== null);
$result->parent = $parentNode;
if ($result->children === null) {
return null;
}
if (in_array(end($result->children)->kind ?? null, $delimiter, true)) {
// Add a MissingToken so that this will warn about `function () : T| {}`
$result->children[] = new MissingToken($expectedTypeKind, $this->token->fullStart);
} elseif (count($result->children) === 1 && $result->children[0] instanceof ParenthesizedIntersectionType) {
// dnf types with parenthesized intersection types are a union type of at least 2 types.
$result->children[] = new MissingToken(TokenKind::BarToken, $this->token->fullStart);
}
return $result;
}
/**
* @param Node $parentNode
* @param Token $openParen
* @param Closure(Token):bool $isTypeStart
* @param Closure(Node):(Node|Token|null) $parseType
*/
private function parseParenthesizedIntersectionType($parentNode, Token $openParen, Closure $isTypeStart, Closure $parseType): ParenthesizedIntersectionType {
$node = new ParenthesizedIntersectionType();
$node->parent = $parentNode;
$node->openParen = $openParen;
$node->children = $this->parseDelimitedList(
DelimitedList\QualifiedNameList::class,
TokenKind::AmpersandToken,
$isTypeStart,
$parseType,
$node,
true);
if ($node->children) {
// https://wiki.php.net/rfc/dnf_types
if ((end($node->children->children)->kind ?? null) === TokenKind::OpenParenToken) {
// Add a MissingToken so that this will Warn about `function (A|(B&) $x) {}`
$node->children->children[] = new MissingToken(TokenKind::Name, $this->token->fullStart);
} elseif (count($node->children->children) === 1) {
// Must have at least 2 parts for A|(B&C)
$node->children->children[] = new MissingToken(TokenKind::AmpersandToken, $this->token->fullStart);
}
} else {
// Having less than 2 types (no types) in A|() is a parse error
$node->children = new MissingToken(TokenKind::Name, $this->token->fullStart);
}
$node->closeParen = $this->eat(TokenKind::CloseParenToken);
return $node;
}
/**
* @param Node|null $parentNode
* @return DelimitedList\QualifiedNameList|null
*/
private function tryParseParameterTypeDeclarationList($parentNode) {
$result = $this->parseDelimitedList(
DelimitedList\QualifiedNameList::class,
self::TYPE_DELIMITER_TOKENS,
return $this->parseUnionTypeDeclarationList(
$parentNode,
function ($token) {
return \in_array($token->kind, $this->parameterTypeDeclarationTokens, true) || $this->isQualifiedNameStart($token);
return \in_array($token->kind, $this->parameterTypeDeclarationTokens, true) ||
$this->isQualifiedNameStart($token);
},
function ($parentNode) {
return $this->tryParseParameterTypeDeclaration($parentNode);
},
$parentNode,
true);
// Add a MissingToken so that this will Warn about `function (T| $x) {}`
// TODO: Make this a reusable abstraction?
if ($result && in_array(end($result->children)->kind ?? null, self::TYPE_DELIMITER_TOKENS)) {
$result->children[] = new MissingToken(TokenKind::Name, $this->token->fullStart);
}
return $result;
TokenKind::Name
);
}
private function parseCompoundStatement($parentNode) {
@@ -950,12 +1044,6 @@ class Parser {
return $compoundStatement;
}
private function array_push_list(& $array, $list) {
foreach ($list as $item) {
$array[] = $item;
}
}
private function isClassMemberDeclarationStart(Token $token) {
switch ($token->kind) {
// const-modifier
@@ -1036,6 +1124,7 @@ class Parser {
case TokenKind::ClassKeyword:
case TokenKind::AbstractKeyword:
case TokenKind::FinalKeyword:
case TokenKind::ReadonlyKeyword:
// interface-declaration
case TokenKind::InterfaceKeyword:
@@ -1062,6 +1151,9 @@ class Parser {
// attributes
case TokenKind::AttributeToken:
// __halt_compiler
case TokenKind::HaltCompilerKeyword:
return true;
default:
@@ -1324,8 +1416,6 @@ class Parser {
case TokenKind::DollarOpenBraceToken:
case TokenKind::OpenBraceDollarToken:
$expression->children[] = $this->eat(TokenKind::DollarOpenBraceToken, TokenKind::OpenBraceDollarToken);
// TODO: Reject ${var->prop} and ${(var->prop)} without rejecting ${var+otherVar}
// Currently, this fails to reject ${var->prop} (because `var` has TokenKind::Name instead of StringVarname)
if ($this->getCurrentToken()->kind === TokenKind::StringVarname) {
$expression->children[] = $this->parseComplexDollarTemplateStringExpression($expression);
} else {
@@ -1536,6 +1626,9 @@ class Parser {
case TokenKind::ProtectedKeyword:
case TokenKind::PrivateKeyword:
case TokenKind::AttributeToken:
// dnf types (A&B)|C
case TokenKind::OpenParenToken:
return true;
}
@@ -1546,7 +1639,7 @@ class Parser {
/**
* @param string $className (name of subclass of DelimitedList)
* @param int $delimiter
* @param int|int[] $delimiter
* @param callable $isElementStartFn
* @param callable $parseElementFn
* @param Node $parentNode
@@ -1560,7 +1653,7 @@ class Parser {
do {
if ($isElementStartFn($token)) {
$node->addElement($parseElementFn($node));
} elseif (!$allowEmptyElements || ($allowEmptyElements && !$this->checkToken($delimiter))) {
} elseif (!$allowEmptyElements || ($allowEmptyElements && !$this->checkAnyToken($delimiter))) {
break;
}
@@ -1572,7 +1665,6 @@ class Parser {
// TODO ERROR CASE - no delimiter, but a param follows
} while ($delimiterToken !== null);
$node->parent = $parentNode;
if ($node->children === null) {
return null;
@@ -1772,10 +1864,17 @@ class Parser {
return $succeeded;
}
/** @param int $expectedKind */
private function checkToken($expectedKind) : bool {
return $this->getCurrentToken()->kind === $expectedKind;
}
/** @param int|int[] $expectedKind */
private function checkAnyToken($expectedKind) : bool {
$kind = $this->getCurrentToken()->kind;
return \is_array($expectedKind) ? \in_array($kind, $expectedKind, true) : $kind === $expectedKind;
}
private function parseIfStatement($parentNode) {
$ifStatement = new IfStatementNode();
$ifStatement->parent = $parentNode;
@@ -2114,7 +2213,7 @@ class Parser {
}
break;
case TokenKind::QuestionToken:
if ($parentNode instanceof TernaryExpression) {
if ($parentNode instanceof TernaryExpression && !isset($parentNode->questionToken)) {
// Workaround to parse "a ? b : c ? d : e" as "(a ? b : c) ? d : e"
break 2;
}
@@ -2122,6 +2221,7 @@ class Parser {
}
if ($shouldOperatorTakePrecedenceOverUnary) {
/** @var UnaryOpExpression $unaryExpression */
$unaryExpression = $leftOperand;
$leftOperand = $unaryExpression->operand;
}
@@ -2143,6 +2243,7 @@ class Parser {
// Rebuild the unary expression if we deconstructed it earlier.
if ($shouldOperatorTakePrecedenceOverUnary) {
/** @var UnaryOpExpression $unaryExpression */
$leftOperand->parent = $unaryExpression;
$unaryExpression->operand = $leftOperand;
$leftOperand = $unaryExpression;
@@ -2269,6 +2370,14 @@ class Parser {
// InstanceOf has other remaining issues, but this heuristic is an improvement for many common cases such as `$x && $y = $z`
];
/**
* @param Token|Node $leftOperand
* @param Token $operatorToken
* @param Token|null $byRefToken
* @param Token|Node $rightOperand
* @param Node $parentNode
* @return BinaryExpression|AssignmentExpression
*/
private function makeBinaryExpression($leftOperand, $operatorToken, $byRefToken, $rightOperand, $parentNode) {
$assignmentExpression = $operatorToken->kind === TokenKind::EqualsToken;
if ($assignmentExpression || \array_key_exists($operatorToken->kind, self::KNOWN_ASSIGNMENT_TOKEN_SET)) {
@@ -2283,8 +2392,12 @@ class Parser {
}
$binaryExpression = $assignmentExpression ? new AssignmentExpression() : new BinaryExpression();
$binaryExpression->parent = $parentNode;
$leftOperand->parent = $binaryExpression;
$rightOperand->parent = $binaryExpression;
if ($leftOperand instanceof Node) {
$leftOperand->parent = $binaryExpression;
}
if ($rightOperand instanceof Node) {
$rightOperand->parent = $binaryExpression;
}
$binaryExpression->leftOperand = $leftOperand;
$binaryExpression->operator = $operatorToken;
if ($binaryExpression instanceof AssignmentExpression && isset($byRefToken)) {
@@ -2744,6 +2857,30 @@ class Parser {
return $unsetStatement;
}
private function parseHaltCompilerStatement($parentNode) {
$haltCompilerStatement = new HaltCompilerStatement();
$haltCompilerStatement->parent = $parentNode;
$haltCompilerStatement->haltCompilerKeyword = $this->eat1(TokenKind::HaltCompilerKeyword);
$haltCompilerStatement->openParen = $this->eat1(TokenKind::OpenParenToken);
$haltCompilerStatement->closeParen = $this->eat1(TokenKind::CloseParenToken);
// There is an implicit ';' before the closing php tag.
$haltCompilerStatement->semicolonOrCloseTag = $this->eat(TokenKind::SemicolonToken, TokenKind::ScriptSectionEndTag);
// token_get_all() will return up to 3 tokens after __halt_compiler regardless of whether they're the right ones.
// For invalid php snippets, combine the remaining tokens into InlineHtml
$remainingTokens = [];
while ($this->token->kind !== TokenKind::EndOfFileToken) {
$remainingTokens[] = $this->token;
$this->advanceToken();
}
if ($remainingTokens) {
$firstToken = $remainingTokens[0];
$lastToken = end($remainingTokens);
$haltCompilerStatement->data = new Token(TokenKind::InlineHtml, $firstToken->fullStart, $firstToken->fullStart, $lastToken->fullStart + $lastToken->length - $firstToken->fullStart);
}
return $haltCompilerStatement;
}
private function parseArrayCreationExpression($parentNode) {
$arrayExpression = new ArrayCreationExpression();
$arrayExpression->parent = $parentNode;
@@ -3207,7 +3344,7 @@ class Parser {
if ($classBaseClause->extendsKeyword === null) {
return null;
}
$classBaseClause->baseClass = $this->parseQualifiedName($classBaseClause);
$classBaseClause->baseClass = $this->parseQualifiedName($classBaseClause) ?? new MissingToken(TokenKind::QualifiedName, $this->token->fullStart);
return $classBaseClause;
}
@@ -3278,6 +3415,8 @@ class Parser {
}
/**
* Parse a comma separated qualified name list (e.g. interfaces implemented by a class)
*
* @param Node $parentNode
* @return DelimitedList\QualifiedNameList
*/
@@ -3291,6 +3430,7 @@ class Parser {
}
private function parseQualifiedNameCatchList($parentNode) {
// catch blocks don't support intersection types.
$result = $this->parseDelimitedList(
DelimitedList\QualifiedNameList::class,
TokenKind::BarToken,
@@ -3397,12 +3537,18 @@ class Parser {
$namespaceDefinition->namespaceKeyword = $this->eat1(TokenKind::NamespaceKeyword);
if (!$this->checkToken(TokenKind::NamespaceKeyword)) {
$namespaceDefinition->name = $this->parseQualifiedName($namespaceDefinition); // TODO only optional with compound statement block
$namespaceDefinition->name = $this->parseQualifiedName($namespaceDefinition);
}
$namespaceDefinition->compoundStatementOrSemicolon =
$this->checkToken(TokenKind::OpenBraceToken) ?
$this->parseCompoundStatement($namespaceDefinition) : $this->eatSemicolonOrAbortStatement();
if ($this->checkToken(TokenKind::OpenBraceToken)) {
$namespaceDefinition->compoundStatementOrSemicolon = $this->parseCompoundStatement($namespaceDefinition);
} else {
if (!$namespaceDefinition->name) {
// only optional with compound statement block
$namespaceDefinition->name = new MissingToken(TokenKind::QualifiedName, $this->token->fullStart);
}
$namespaceDefinition->compoundStatementOrSemicolon = $this->eatSemicolonOrAbortStatement();
}
return $namespaceDefinition;
}
@@ -3428,13 +3574,17 @@ class Parser {
$namespaceUseClause = new NamespaceUseClause();
$namespaceUseClause->parent = $parentNode;
$namespaceUseClause->namespaceName = $this->parseQualifiedName($namespaceUseClause);
if ($this->checkToken(TokenKind::AsKeyword)) {
$namespaceUseClause->namespaceAliasingClause = $this->parseNamespaceAliasingClause($namespaceUseClause);
}
elseif ($this->checkToken(TokenKind::OpenBraceToken)) {
if ($this->checkToken(TokenKind::OpenBraceToken)) {
$namespaceUseClause->openBrace = $this->eat1(TokenKind::OpenBraceToken);
$namespaceUseClause->groupClauses = $this->parseNamespaceUseGroupClauseList($namespaceUseClause);
$namespaceUseClause->closeBrace = $this->eat1(TokenKind::CloseBraceToken);
} else {
if (!$namespaceUseClause->namespaceName) {
$namespaceUseClause->namespaceName = new MissingToken(TokenKind::QualifiedName, $this->token->fullStart);
}
if ($this->checkToken(TokenKind::AsKeyword)) {
$namespaceUseClause->namespaceAliasingClause = $this->parseNamespaceAliasingClause($namespaceUseClause);
}
}
return $namespaceUseClause;
@@ -3455,7 +3605,7 @@ class Parser {
$namespaceUseGroupClause->parent = $parentNode;
$namespaceUseGroupClause->functionOrConst = $this->eatOptional(TokenKind::FunctionKeyword, TokenKind::ConstKeyword);
$namespaceUseGroupClause->namespaceName = $this->parseQualifiedName($namespaceUseGroupClause);
$namespaceUseGroupClause->namespaceName = $this->parseQualifiedName($namespaceUseGroupClause) ?? new MissingToken(TokenKind::QualifiedName, $this->token->fullStart);
if ($this->checkToken(TokenKind::AsKeyword)) {
$namespaceUseGroupClause->namespaceAliasingClause = $this->parseNamespaceAliasingClause($namespaceUseGroupClause);
}
@@ -3513,6 +3663,7 @@ class Parser {
case TokenKind::AbstractKeyword:
case TokenKind::FinalKeyword:
case TokenKind::ReadonlyKeyword:
case TokenKind::ConstKeyword:
// method-declaration
case TokenKind::FunctionKeyword:
@@ -3533,6 +3684,9 @@ class Parser {
$token = $this->getCurrentToken();
switch ($token->kind) {
case TokenKind::ConstKeyword:
return $this->parseClassConstDeclaration($parentNode, $modifiers);
case TokenKind::FunctionKeyword:
return $this->parseMethodDeclaration($parentNode, $modifiers);

View File

@@ -228,7 +228,6 @@ class PhpTokenizer implements TokenStreamProviderInterface {
T_DIR => TokenKind::Name,
T_FILE => TokenKind::Name,
T_FUNC_C => TokenKind::Name,
T_HALT_COMPILER => TokenKind::Name,
T_METHOD_C => TokenKind::Name,
T_NS_C => TokenKind::Name,
T_TRAIT_C => TokenKind::Name,
@@ -274,6 +273,7 @@ class PhpTokenizer implements TokenStreamProviderInterface {
T_FUNCTION => TokenKind::FunctionKeyword,
T_GLOBAL => TokenKind::GlobalKeyword,
T_GOTO => TokenKind::GotoKeyword,
T_HALT_COMPILER => TokenKind::HaltCompilerKeyword,
T_IF => TokenKind::IfKeyword,
T_IMPLEMENTS => TokenKind::ImplementsKeyword,
T_INCLUDE => TokenKind::IncludeKeyword,

View File

@@ -18,7 +18,7 @@ class Token implements \JsonSerializable {
public $fullStart;
/** @var int */
public $start;
/** @var int */
/** @var int the length is equal to $this->getEndPosition() - $this->fullStart. */
public $length;
/**

View File

@@ -91,6 +91,7 @@ class TokenKind {
const IterableKeyword = self::IterableReservedWord;
const EnumKeyword = 171;
const ReadonlyKeyword = 172;
const HaltCompilerKeyword = 173;
const OpenBracketToken = 201;
const CloseBracketToken = 202;
@@ -175,6 +176,7 @@ class TokenKind {
const NullReservedWord = 322;
const MixedReservedWord = 340;
const IterableReservedWord = 170;
const NeverReservedWord = 341;
const ScriptSectionStartTag = 323;
const ScriptSectionEndTag = 324;

View File

@@ -57,6 +57,7 @@ class TokenStringMaps {
"interface" => TokenKind::InterfaceKeyword,
"isset" => TokenKind::IsSetKeyword,
"list" => TokenKind::ListKeyword,
"match" => TokenKind::MatchKeyword,
"namespace" => TokenKind::NamespaceKeyword,
"new" => TokenKind::NewKeyword,
"or" => TokenKind::OrKeyword,
@@ -108,6 +109,7 @@ class TokenStringMaps {
"void" => TokenKind::VoidReservedWord,
"iterable" => TokenKind::IterableReservedWord,
"mixed" => TokenKind::MixedReservedWord,
"never" => TokenKind::NeverReservedWord,
];
const OPERATORS_AND_PUNCTUATORS = [

View File

@@ -0,0 +1,163 @@
<?php
// These stubs were generated by the phan stub generator.
// @phan-stub-for-extension zip@1.15.6
namespace {
class ZipArchive implements \Countable {
// constants
const CREATE = 1;
const EXCL = 2;
const CHECKCONS = 4;
const OVERWRITE = 8;
const RDONLY = 16;
const FL_NOCASE = 1;
const FL_NODIR = 2;
const FL_COMPRESSED = 4;
const FL_UNCHANGED = 8;
const FL_ENC_GUESS = 0;
const FL_ENC_RAW = 64;
const FL_ENC_STRICT = 128;
const FL_ENC_UTF_8 = 2048;
const FL_ENC_CP437 = 4096;
const CM_DEFAULT = -1;
const CM_STORE = 0;
const CM_SHRINK = 1;
const CM_REDUCE_1 = 2;
const CM_REDUCE_2 = 3;
const CM_REDUCE_3 = 4;
const CM_REDUCE_4 = 5;
const CM_IMPLODE = 6;
const CM_DEFLATE = 8;
const CM_DEFLATE64 = 9;
const CM_PKWARE_IMPLODE = 10;
const CM_BZIP2 = 12;
const CM_LZMA = 14;
const CM_LZMA2 = 33;
const CM_XZ = 95;
const CM_TERSE = 18;
const CM_LZ77 = 19;
const CM_WAVPACK = 97;
const CM_PPMD = 98;
const ER_OK = 0;
const ER_MULTIDISK = 1;
const ER_RENAME = 2;
const ER_CLOSE = 3;
const ER_SEEK = 4;
const ER_READ = 5;
const ER_WRITE = 6;
const ER_CRC = 7;
const ER_ZIPCLOSED = 8;
const ER_NOENT = 9;
const ER_EXISTS = 10;
const ER_OPEN = 11;
const ER_TMPOPEN = 12;
const ER_ZLIB = 13;
const ER_MEMORY = 14;
const ER_CHANGED = 15;
const ER_COMPNOTSUPP = 16;
const ER_EOF = 17;
const ER_INVAL = 18;
const ER_NOZIP = 19;
const ER_INTERNAL = 20;
const ER_INCONS = 21;
const ER_REMOVE = 22;
const ER_DELETED = 23;
const ER_ENCRNOTSUPP = 24;
const ER_RDONLY = 25;
const ER_NOPASSWD = 26;
const ER_WRONGPASSWD = 27;
const ER_OPNOTSUPP = 28;
const ER_INUSE = 29;
const ER_TELL = 30;
const ER_COMPRESSED_DATA = 31;
const ER_CANCELLED = 32;
const OPSYS_DOS = 0;
const OPSYS_AMIGA = 1;
const OPSYS_OPENVMS = 2;
const OPSYS_UNIX = 3;
const OPSYS_VM_CMS = 4;
const OPSYS_ATARI_ST = 5;
const OPSYS_OS_2 = 6;
const OPSYS_MACINTOSH = 7;
const OPSYS_Z_SYSTEM = 8;
const OPSYS_Z_CPM = 9;
const OPSYS_CPM = 9;
const OPSYS_WINDOWS_NTFS = 10;
const OPSYS_MVS = 11;
const OPSYS_VSE = 12;
const OPSYS_ACORN_RISC = 13;
const OPSYS_VFAT = 14;
const OPSYS_ALTERNATE_MVS = 15;
const OPSYS_BEOS = 16;
const OPSYS_TANDEM = 17;
const OPSYS_OS_400 = 18;
const OPSYS_OS_X = 19;
const OPSYS_DEFAULT = 3;
const EM_NONE = 0;
const EM_AES_128 = 257;
const EM_AES_192 = 258;
const EM_AES_256 = 259;
const LIBZIP_VERSION = '1.9.2';
// properties
public $comment;
public $filename;
public $numFiles;
public $status;
public $statusSys;
// methods
public function open($filename, $flags = null) {}
public function setPassword($password) {}
public function close() {}
public function count() {}
public function getStatusString() {}
public function addEmptyDir($dirname) {}
public function addFromString($name, $content) {}
public function addFile($filepath, $entryname = null, $start = null, $length = null) {}
public function addGlob($pattern, $flags = null, $options = null) {}
public function addPattern($pattern, $path = null, $options = null) {}
public function renameIndex($index, $new_name) {}
public function renameName($name, $new_name) {}
public function setArchiveComment($comment) {}
public function getArchiveComment($flags = null) {}
public function setCommentIndex($index, $comment) {}
public function setCommentName($name, $comment) {}
public function getCommentIndex($index, $flags = null) {}
public function getCommentName($name, $flags = null) {}
public function deleteIndex($index) {}
public function deleteName($name) {}
public function statName($filename, $flags = null) {}
public function statIndex($index, $flags = null) {}
public function locateName($filename, $flags = null) {}
public function getNameIndex($index, $flags = null) {}
public function unchangeArchive() {}
public function unchangeAll() {}
public function unchangeIndex($index) {}
public function unchangeName($name) {}
public function extractTo($pathto, $files = null) {}
public function getFromName($entryname, $len = null, $flags = null) {}
public function getFromIndex($index, $len = null, $flags = null) {}
public function getStream($entryname) {}
public function setExternalAttributesName($name, $opsys, $attr, $flags = null) {}
public function setExternalAttributesIndex($index, $opsys, $attr, $flags = null) {}
public function getExternalAttributesName($name, &$opsys, &$attr, $flags = null) {}
public function getExternalAttributesIndex($index, &$opsys, &$attr, $flags = null) {}
public function setCompressionName($name, $method, $compflags = null) {}
public function setCompressionIndex($index, $method, $compflags = null) {}
public function setEncryptionName($name, $method, $password = null) {}
public function setEncryptionIndex($index, $method, $password = null) {}
}
function zip_close($zip) {}
function zip_entry_close($zip_ent) {}
function zip_entry_compressedsize($zip_entry) {}
function zip_entry_compressionmethod($zip_entry) {}
function zip_entry_filesize($zip_entry) {}
function zip_entry_name($zip_entry) {}
function zip_entry_open($zip_dp, $zip_entry, $mode = null) {}
function zip_entry_read($zip_entry, $len = null) {}
function zip_open($filename) {}
function zip_read($zip) {}
}

View File

@@ -114,7 +114,7 @@ final class EmptyStatementListVisitor extends PluginAwarePostAnalysisVisitor
$this->code_base,
(clone $this->context)->withLineNumberStart($last_if_elem->children['stmts']->lineno ?? $last_if_elem->lineno),
'PhanPluginEmptyStatementIf',
'Empty statement list statement detected for the last if/elseif statement',
'Empty statement list detected for the last if/elseif statement',
[]
);
}
@@ -191,7 +191,7 @@ final class EmptyStatementListVisitor extends PluginAwarePostAnalysisVisitor
$this->code_base,
(clone $this->context)->withLineNumberStart($stmts_node->lineno ?? $node->lineno),
'PhanPluginEmptyStatementForLoop',
'Empty statement list statement detected for the for loop',
'Empty statement list detected for the for loop',
[]
);
}
@@ -219,7 +219,7 @@ final class EmptyStatementListVisitor extends PluginAwarePostAnalysisVisitor
$this->code_base,
(clone $this->context)->withLineNumberStart($stmts_node->lineno ?? $node->lineno),
'PhanPluginEmptyStatementWhileLoop',
'Empty statement list statement detected for the while loop',
'Empty statement list detected for the while loop',
[]
);
}
@@ -247,7 +247,7 @@ final class EmptyStatementListVisitor extends PluginAwarePostAnalysisVisitor
$this->code_base,
(clone $this->context)->withLineNumberStart($stmts_node->lineno),
'PhanPluginEmptyStatementDoWhileLoop',
'Empty statement list statement detected for the do-while loop',
'Empty statement list detected for the do-while loop',
[]
);
}
@@ -276,7 +276,7 @@ final class EmptyStatementListVisitor extends PluginAwarePostAnalysisVisitor
$this->code_base,
(clone $this->context)->withLineNumberStart($stmts_node->lineno),
'PhanPluginEmptyStatementForeachLoop',
'Empty statement list statement detected for the foreach loop',
'Empty statement list detected for the foreach loop',
[]
);
}
@@ -295,7 +295,7 @@ final class EmptyStatementListVisitor extends PluginAwarePostAnalysisVisitor
$this->code_base,
(clone $this->context)->withLineNumberStart($try_node->lineno),
'PhanPluginEmptyStatementTryBody',
'Empty statement list statement detected for the try statement\'s body',
'Empty statement list detected for the try statement\'s body',
[]
);
}
@@ -315,7 +315,7 @@ final class EmptyStatementListVisitor extends PluginAwarePostAnalysisVisitor
$this->code_base,
(clone $this->context)->withLineNumberStart($finally_node->lineno),
'PhanPluginEmptyStatementTryFinally',
'Empty statement list statement detected for the try\'s finally body',
'Empty statement list detected for the try\'s finally body',
[]
);
}

View File

@@ -216,15 +216,15 @@ By default, this plugin won't warn if it can find a TODO/FIXME/"Deliberately emp
(This may miss some TODOs due to `php-ast` not providing the end line numbers)
The setting `'plugin_config' => ['empty_statement_list_ignore_todos' => true]` can be used to make it unconditionally warn about empty statement lists.
- **PhanPluginEmptyStatementDoWhileLoop** `Empty statement list statement detected for the do-while loop`
- **PhanPluginEmptyStatementForLoop** `Empty statement list statement detected for the for loop`
- **PhanPluginEmptyStatementForeachLoop** `Empty statement list statement detected for the foreach loop`
- **PhanPluginEmptyStatementIf**: `Empty statement list statement detected for the last if/elseif statement`
- **PhanPluginEmptyStatementDoWhileLoop** `Empty statement list detected for the do-while loop`
- **PhanPluginEmptyStatementForLoop** `Empty statement list detected for the for loop`
- **PhanPluginEmptyStatementForeachLoop** `Empty statement list detected for the foreach loop`
- **PhanPluginEmptyStatementIf**: `Empty statement list detected for the last if/elseif statement`
- **PhanPluginEmptyStatementSwitch** `No side effects seen for any cases of this switch statement`
- **PhanPluginEmptyStatementTryBody** `Empty statement list statement detected for the try statement's body`
- **PhanPluginEmptyStatementTryBody** `Empty statement list detected for the try statement's body`
- **PhanPluginEmptyStatementPossiblyNonThrowingTryBody**: `Found a try block that looks like it might not throw. Note that this check is a heuristic prone to false positives, especially because error handlers, signal handlers, destructors, and other things may all lead to throwing.`
- **PhanPluginEmptyStatementTryFinally** `Empty statement list statement detected for the try's finally body`
- **PhanPluginEmptyStatementWhileLoop** `Empty statement list statement detected for the while loop`
- **PhanPluginEmptyStatementTryFinally** `Empty statement list detected for the try's finally body`
- **PhanPluginEmptyStatementWhileLoop** `Empty statement list detected for the while loop`
### LoopVariableReusePlugin.php

View File

@@ -1,5 +1,20 @@
Phan NEWS
Mar 03 2023, Phan 5.4.2
-----------------------
Miscellaneous:
- Fix wording in EmptyStatementListPlugin issue messages.
- Add a few more functions where the return value should be used.
- Fix signature of exif_read_data() #4759
- Make allow_missing_properties setting aware of AllowDynamicProperties attribute for PHP 8.2
Maintenance:
- Require php-ast 1.1.0 or newer in PHP 8.2+ if php-ast is installed.
This release of php-ast makes the parsing of `AST_ARROW_FUNC` in php 8.2 match older php versions.
- Support parsing of PHP 8.2 syntax such as disjunctive normal form types and `readonly` classes in the polyfill/fallback parser.
- Fix bugs parsing `__halt_compiler()` in the polyfill/fallback parser.
Aug 25 2022, Phan 5.4.1
-----------------------
@@ -14,6 +29,11 @@ New Features(Analysis):
Miscellaneous:
- Allow `array_filter` `$callback` to be null (#4715)
Bug fixes:
- Fix false positive warning in PHP < 8.0 for inferring the method signature of `new SoapFault`. (#4724)
(The constructor was internally declared in reflection as `SoapFault::SoapFault` until php 8.0)
Adjust the method signature of `SoapFault::__construct` to match the documentation/implementation.
Aug 08 2022, Phan 5.4.0
-----------------------

View File

@@ -29,7 +29,7 @@
"composer/semver": "^1.4|^2.0|^3.0",
"composer/xdebug-handler": "^2.0|^3.0",
"felixfbecker/advanced-json-rpc": "^3.0.4",
"microsoft/tolerant-php-parser": "0.1.1",
"microsoft/tolerant-php-parser": "0.1.2",
"netresearch/jsonmapper": "^1.6.0|^2.0|^3.0|^4.0",
"sabre/event": "^5.1.3",
"symfony/console": "^3.2|^4.0|^5.0|^6.0",

232
vendor/phan/phan/composer.lock generated vendored
View File

@@ -4,20 +4,20 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "62f4c0f1a6e50535b7c03182832d5c4e",
"content-hash": "301a32dbdfef414765074fc7e60effbb",
"packages": [
{
"name": "composer/pcre",
"version": "2.0.0",
"version": "2.1.0",
"source": {
"type": "git",
"url": "https://github.com/composer/pcre.git",
"reference": "c8e9d27cfc5ed22643c19c160455b473ffd8aabe"
"reference": "3fdb2807b31a78a40ad89570e30ec77466c98717"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/pcre/zipball/c8e9d27cfc5ed22643c19c160455b473ffd8aabe",
"reference": "c8e9d27cfc5ed22643c19c160455b473ffd8aabe",
"url": "https://api.github.com/repos/composer/pcre/zipball/3fdb2807b31a78a40ad89570e30ec77466c98717",
"reference": "3fdb2807b31a78a40ad89570e30ec77466c98717",
"shasum": ""
},
"require": {
@@ -59,7 +59,7 @@
],
"support": {
"issues": "https://github.com/composer/pcre/issues",
"source": "https://github.com/composer/pcre/tree/2.0.0"
"source": "https://github.com/composer/pcre/tree/2.1.0"
},
"funding": [
{
@@ -75,7 +75,7 @@
"type": "tidelift"
}
],
"time": "2022-02-25T20:05:29+00:00"
"time": "2022-11-16T18:32:04+00:00"
},
{
"name": "composer/semver",
@@ -271,16 +271,16 @@
},
{
"name": "microsoft/tolerant-php-parser",
"version": "v0.1.1",
"version": "v0.1.2",
"source": {
"type": "git",
"url": "https://github.com/microsoft/tolerant-php-parser.git",
"reference": "6a965617cf484355048ac6d2d3de7b6ec93abb16"
"reference": "3eccfd273323aaf69513e2f1c888393f5947804b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/microsoft/tolerant-php-parser/zipball/6a965617cf484355048ac6d2d3de7b6ec93abb16",
"reference": "6a965617cf484355048ac6d2d3de7b6ec93abb16",
"url": "https://api.github.com/repos/microsoft/tolerant-php-parser/zipball/3eccfd273323aaf69513e2f1c888393f5947804b",
"reference": "3eccfd273323aaf69513e2f1c888393f5947804b",
"shasum": ""
},
"require": {
@@ -310,22 +310,22 @@
"description": "Tolerant PHP-to-AST parser designed for IDE usage scenarios",
"support": {
"issues": "https://github.com/microsoft/tolerant-php-parser/issues",
"source": "https://github.com/microsoft/tolerant-php-parser/tree/v0.1.1"
"source": "https://github.com/microsoft/tolerant-php-parser/tree/v0.1.2"
},
"time": "2021-07-16T21:28:12+00:00"
"time": "2022-10-05T17:30:19+00:00"
},
{
"name": "netresearch/jsonmapper",
"version": "v4.0.0",
"version": "v4.1.0",
"source": {
"type": "git",
"url": "https://github.com/cweiske/jsonmapper.git",
"reference": "8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d"
"reference": "cfa81ea1d35294d64adb9c68aa4cb9e92400e53f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d",
"reference": "8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d",
"url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/cfa81ea1d35294d64adb9c68aa4cb9e92400e53f",
"reference": "cfa81ea1d35294d64adb9c68aa4cb9e92400e53f",
"shasum": ""
},
"require": {
@@ -361,9 +361,9 @@
"support": {
"email": "cweiske@cweiske.de",
"issues": "https://github.com/cweiske/jsonmapper/issues",
"source": "https://github.com/cweiske/jsonmapper/tree/v4.0.0"
"source": "https://github.com/cweiske/jsonmapper/tree/v4.1.0"
},
"time": "2020-12-01T19:48:11+00:00"
"time": "2022-12-08T20:46:14+00:00"
},
{
"name": "phpdocumentor/reflection-common",
@@ -691,16 +691,16 @@
},
{
"name": "symfony/console",
"version": "v5.4.11",
"version": "v5.4.21",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "535846c7ee6bc4dd027ca0d93220601456734b10"
"reference": "c77433ddc6cdc689caf48065d9ea22ca0853fbd9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/535846c7ee6bc4dd027ca0d93220601456734b10",
"reference": "535846c7ee6bc4dd027ca0d93220601456734b10",
"url": "https://api.github.com/repos/symfony/console/zipball/c77433ddc6cdc689caf48065d9ea22ca0853fbd9",
"reference": "c77433ddc6cdc689caf48065d9ea22ca0853fbd9",
"shasum": ""
},
"require": {
@@ -770,7 +770,7 @@
"terminal"
],
"support": {
"source": "https://github.com/symfony/console/tree/v5.4.11"
"source": "https://github.com/symfony/console/tree/v5.4.21"
},
"funding": [
{
@@ -786,7 +786,7 @@
"type": "tidelift"
}
],
"time": "2022-07-22T10:42:43+00:00"
"time": "2023-02-25T16:59:41+00:00"
},
{
"name": "symfony/deprecation-contracts",
@@ -857,16 +857,16 @@
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.26.0",
"version": "v1.27.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4"
"reference": "5bbc823adecdae860bb64756d639ecfec17b050a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4",
"reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a",
"reference": "5bbc823adecdae860bb64756d639ecfec17b050a",
"shasum": ""
},
"require": {
@@ -881,7 +881,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.26-dev"
"dev-main": "1.27-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -919,7 +919,7 @@
"portable"
],
"support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.26.0"
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0"
},
"funding": [
{
@@ -935,20 +935,20 @@
"type": "tidelift"
}
],
"time": "2022-05-24T11:49:31+00:00"
"time": "2022-11-03T14:55:06+00:00"
},
{
"name": "symfony/polyfill-intl-grapheme",
"version": "v1.26.0",
"version": "v1.27.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-grapheme.git",
"reference": "433d05519ce6990bf3530fba6957499d327395c2"
"reference": "511a08c03c1960e08a883f4cffcacd219b758354"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/433d05519ce6990bf3530fba6957499d327395c2",
"reference": "433d05519ce6990bf3530fba6957499d327395c2",
"url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/511a08c03c1960e08a883f4cffcacd219b758354",
"reference": "511a08c03c1960e08a883f4cffcacd219b758354",
"shasum": ""
},
"require": {
@@ -960,7 +960,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.26-dev"
"dev-main": "1.27-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -1000,7 +1000,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.26.0"
"source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.27.0"
},
"funding": [
{
@@ -1016,20 +1016,20 @@
"type": "tidelift"
}
],
"time": "2022-05-24T11:49:31+00:00"
"time": "2022-11-03T14:55:06+00:00"
},
{
"name": "symfony/polyfill-intl-normalizer",
"version": "v1.26.0",
"version": "v1.27.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-normalizer.git",
"reference": "219aa369ceff116e673852dce47c3a41794c14bd"
"reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/219aa369ceff116e673852dce47c3a41794c14bd",
"reference": "219aa369ceff116e673852dce47c3a41794c14bd",
"url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/19bd1e4fcd5b91116f14d8533c57831ed00571b6",
"reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6",
"shasum": ""
},
"require": {
@@ -1041,7 +1041,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.26-dev"
"dev-main": "1.27-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -1084,7 +1084,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.26.0"
"source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.27.0"
},
"funding": [
{
@@ -1100,20 +1100,20 @@
"type": "tidelift"
}
],
"time": "2022-05-24T11:49:31+00:00"
"time": "2022-11-03T14:55:06+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.26.0",
"version": "v1.27.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e"
"reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e",
"reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534",
"reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534",
"shasum": ""
},
"require": {
@@ -1128,7 +1128,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.26-dev"
"dev-main": "1.27-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -1167,7 +1167,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.26.0"
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0"
},
"funding": [
{
@@ -1183,20 +1183,20 @@
"type": "tidelift"
}
],
"time": "2022-05-24T11:49:31+00:00"
"time": "2022-11-03T14:55:06+00:00"
},
{
"name": "symfony/polyfill-php73",
"version": "v1.26.0",
"version": "v1.27.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php73.git",
"reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85"
"reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/e440d35fa0286f77fb45b79a03fedbeda9307e85",
"reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85",
"url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/9e8ecb5f92152187c4799efd3c96b78ccab18ff9",
"reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9",
"shasum": ""
},
"require": {
@@ -1205,7 +1205,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.26-dev"
"dev-main": "1.27-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -1246,7 +1246,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php73/tree/v1.26.0"
"source": "https://github.com/symfony/polyfill-php73/tree/v1.27.0"
},
"funding": [
{
@@ -1262,20 +1262,20 @@
"type": "tidelift"
}
],
"time": "2022-05-24T11:49:31+00:00"
"time": "2022-11-03T14:55:06+00:00"
},
{
"name": "symfony/polyfill-php80",
"version": "v1.26.0",
"version": "v1.27.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php80.git",
"reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace"
"reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/cfa0ae98841b9e461207c13ab093d76b0fa7bace",
"reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936",
"reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936",
"shasum": ""
},
"require": {
@@ -1284,7 +1284,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.26-dev"
"dev-main": "1.27-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -1329,7 +1329,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php80/tree/v1.26.0"
"source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0"
},
"funding": [
{
@@ -1345,7 +1345,7 @@
"type": "tidelift"
}
],
"time": "2022-05-10T07:21:04+00:00"
"time": "2022-11-03T14:55:06+00:00"
},
{
"name": "symfony/service-contracts",
@@ -1432,16 +1432,16 @@
},
{
"name": "symfony/string",
"version": "v5.4.11",
"version": "v5.4.21",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "5eb661e49ad389e4ae2b6e4df8d783a8a6548322"
"reference": "edac10d167b78b1d90f46a80320d632de0bd9f2f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/5eb661e49ad389e4ae2b6e4df8d783a8a6548322",
"reference": "5eb661e49ad389e4ae2b6e4df8d783a8a6548322",
"url": "https://api.github.com/repos/symfony/string/zipball/edac10d167b78b1d90f46a80320d632de0bd9f2f",
"reference": "edac10d167b78b1d90f46a80320d632de0bd9f2f",
"shasum": ""
},
"require": {
@@ -1498,7 +1498,7 @@
"utf8"
],
"support": {
"source": "https://github.com/symfony/string/tree/v5.4.11"
"source": "https://github.com/symfony/string/tree/v5.4.21"
},
"funding": [
{
@@ -1514,34 +1514,42 @@
"type": "tidelift"
}
],
"time": "2022-07-24T16:15:25+00:00"
"time": "2023-02-22T08:00:55+00:00"
},
{
"name": "tysonandre/var_representation_polyfill",
"version": "0.1.2",
"version": "0.1.3",
"source": {
"type": "git",
"url": "https://github.com/TysonAndre/var_representation_polyfill.git",
"reference": "e925b7b0806b39f26aa899202ee065decbabafdb"
"reference": "e9116c2c352bb0835ca428b442dde7767c11ad32"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/TysonAndre/var_representation_polyfill/zipball/e925b7b0806b39f26aa899202ee065decbabafdb",
"reference": "e925b7b0806b39f26aa899202ee065decbabafdb",
"url": "https://api.github.com/repos/TysonAndre/var_representation_polyfill/zipball/e9116c2c352bb0835ca428b442dde7767c11ad32",
"reference": "e9116c2c352bb0835ca428b442dde7767c11ad32",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"php": "^7.2.0|^8.0.0"
},
"provide": {
"ext-var_representation": "*"
},
"require-dev": {
"phan/phan": "^5.1",
"phan/phan": "^5.4.1",
"phpunit/phpunit": "^8.5.0"
},
"suggest": {
"ext-var_representation": "*"
"ext-var_representation": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "0.1.3-dev"
}
},
"autoload": {
"files": [
"src/var_representation.php"
@@ -1566,9 +1574,9 @@
],
"support": {
"issues": "https://github.com/TysonAndre/var_representation_polyfill/issues",
"source": "https://github.com/TysonAndre/var_representation_polyfill/tree/0.1.2"
"source": "https://github.com/TysonAndre/var_representation_polyfill/tree/0.1.3"
},
"time": "2022-08-11T12:33:19+00:00"
"time": "2022-08-31T12:59:22+00:00"
},
{
"name": "webmozart/assert",
@@ -1632,30 +1640,30 @@
"packages-dev": [
{
"name": "doctrine/instantiator",
"version": "1.4.1",
"version": "1.5.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
"reference": "10dcfce151b967d20fde1b34ae6640712c3891bc"
"reference": "0a0fa9780f5d4e507415a065172d26a98d02047b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc",
"reference": "10dcfce151b967d20fde1b34ae6640712c3891bc",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b",
"reference": "0a0fa9780f5d4e507415a065172d26a98d02047b",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
"doctrine/coding-standard": "^9",
"doctrine/coding-standard": "^9 || ^11",
"ext-pdo": "*",
"ext-phar": "*",
"phpbench/phpbench": "^0.16 || ^1",
"phpstan/phpstan": "^1.4",
"phpstan/phpstan-phpunit": "^1",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
"vimeo/psalm": "^4.22"
"vimeo/psalm": "^4.30 || ^5.4"
},
"type": "library",
"autoload": {
@@ -1682,7 +1690,7 @@
],
"support": {
"issues": "https://github.com/doctrine/instantiator/issues",
"source": "https://github.com/doctrine/instantiator/tree/1.4.1"
"source": "https://github.com/doctrine/instantiator/tree/1.5.0"
},
"funding": [
{
@@ -1698,7 +1706,7 @@
"type": "tidelift"
}
],
"time": "2022-03-03T08:28:38+00:00"
"time": "2022-12-30T00:15:36+00:00"
},
{
"name": "myclabs/deep-copy",
@@ -2169,16 +2177,16 @@
},
{
"name": "phpunit/phpunit",
"version": "8.5.29",
"version": "8.5.33",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "e8c563c47a9a303662955518ca532b022b337f4d"
"reference": "7d1ff0e8c6b35db78ff13e3e05517d7cbf7aa32e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e8c563c47a9a303662955518ca532b022b337f4d",
"reference": "e8c563c47a9a303662955518ca532b022b337f4d",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/7d1ff0e8c6b35db78ff13e3e05517d7cbf7aa32e",
"reference": "7d1ff0e8c6b35db78ff13e3e05517d7cbf7aa32e",
"shasum": ""
},
"require": {
@@ -2197,10 +2205,10 @@
"phpunit/php-file-iterator": "^2.0.4",
"phpunit/php-text-template": "^1.2.1",
"phpunit/php-timer": "^2.1.2",
"sebastian/comparator": "^3.0.2",
"sebastian/comparator": "^3.0.5",
"sebastian/diff": "^3.0.2",
"sebastian/environment": "^4.2.3",
"sebastian/exporter": "^3.1.2",
"sebastian/exporter": "^3.1.5",
"sebastian/global-state": "^3.0.0",
"sebastian/object-enumerator": "^3.0.3",
"sebastian/resource-operations": "^2.0.1",
@@ -2246,7 +2254,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"source": "https://github.com/sebastianbergmann/phpunit/tree/8.5.29"
"source": "https://github.com/sebastianbergmann/phpunit/tree/8.5.33"
},
"funding": [
{
@@ -2256,9 +2264,13 @@
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit",
"type": "tidelift"
}
],
"time": "2022-08-22T13:59:39+00:00"
"time": "2023-02-27T13:04:50+00:00"
},
{
"name": "sebastian/code-unit-reverse-lookup",
@@ -2317,16 +2329,16 @@
},
{
"name": "sebastian/comparator",
"version": "3.0.3",
"version": "3.0.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/comparator.git",
"reference": "1071dfcef776a57013124ff35e1fc41ccd294758"
"reference": "1dc7ceb4a24aede938c7af2a9ed1de09609ca770"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1071dfcef776a57013124ff35e1fc41ccd294758",
"reference": "1071dfcef776a57013124ff35e1fc41ccd294758",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1dc7ceb4a24aede938c7af2a9ed1de09609ca770",
"reference": "1dc7ceb4a24aede938c7af2a9ed1de09609ca770",
"shasum": ""
},
"require": {
@@ -2379,7 +2391,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/comparator/issues",
"source": "https://github.com/sebastianbergmann/comparator/tree/3.0.3"
"source": "https://github.com/sebastianbergmann/comparator/tree/3.0.5"
},
"funding": [
{
@@ -2387,7 +2399,7 @@
"type": "github"
}
],
"time": "2020-11-30T08:04:30+00:00"
"time": "2022-09-14T12:31:48+00:00"
},
{
"name": "sebastian/diff",
@@ -2520,16 +2532,16 @@
},
{
"name": "sebastian/exporter",
"version": "3.1.4",
"version": "3.1.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git",
"reference": "0c32ea2e40dbf59de29f3b49bf375176ce7dd8db"
"reference": "73a9676f2833b9a7c36968f9d882589cd75511e6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/0c32ea2e40dbf59de29f3b49bf375176ce7dd8db",
"reference": "0c32ea2e40dbf59de29f3b49bf375176ce7dd8db",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/73a9676f2833b9a7c36968f9d882589cd75511e6",
"reference": "73a9676f2833b9a7c36968f9d882589cd75511e6",
"shasum": ""
},
"require": {
@@ -2585,7 +2597,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/exporter/issues",
"source": "https://github.com/sebastianbergmann/exporter/tree/3.1.4"
"source": "https://github.com/sebastianbergmann/exporter/tree/3.1.5"
},
"funding": [
{
@@ -2593,7 +2605,7 @@
"type": "github"
}
],
"time": "2021-11-11T13:51:24+00:00"
"time": "2022-09-14T06:00:17+00:00"
},
{
"name": "sebastian/global-state",
@@ -3055,5 +3067,5 @@
"platform-overrides": {
"php": "7.2.24"
},
"plugin-api-version": "2.3.0"
"plugin-api-version": "2.0.0"
}

View File

@@ -1269,6 +1269,9 @@ class TolerantASTConverter
$variableName !== null ? self::getStartLine($variableName) : $start_line
);
},
'Microsoft\PhpParser\Node\Statement\HaltCompilerStatement' => static function (PhpParser\Node\Statement\HaltCompilerStatement $n, int $start_line): ast\Node {
return new ast\Node(ast\AST_HALT_COMPILER, 0, ['offset' => $n->getHaltCompilerOffset()], $start_line);
},
'Microsoft\PhpParser\Node\Statement\InterfaceDeclaration' => static function (PhpParser\Node\Statement\InterfaceDeclaration $n, int $start_line): ast\Node {
if ($n->interfaceKeyword) {
$start_line = self::getStartLine($n->interfaceKeyword);
@@ -1294,7 +1297,7 @@ class TolerantASTConverter
$end_line = static::getEndLine($n);
$base_class = $n->classBaseClause->baseClass ?? null;
return static::astStmtClass(
static::phpParserClassModifierToAstClassFlags($n->abstractOrFinalModifier),
static::phpParserClassModifiersToAstClassFlags($n->abstractOrFinalModifier, $n->modifiers),
static::tokenToString($n->name),
static::phpParserAttributeGroupsToAstAttributeList($n->attributes),
$base_class !== null ? static::phpParserNonValueNodeToAstNode($base_class) : null,
@@ -1940,6 +1943,23 @@ class TolerantASTConverter
return new ast\Node($is_intersection ? ast\AST_TYPE_INTERSECTION : ast\AST_TYPE_UNION, 0, $types, $types[0]->lineno);
}
protected static function phpParserParenthesizedIntersectionTypeToAstNode(PhpParser\Node\ParenthesizedIntersectionType $n, int $start_line): ?ast\Node {
$children = [];
foreach ($n->children->children ?? [] as $c) {
if ($c instanceof Token && $c->kind === TokenKind::AmpersandToken) {
continue;
}
$result = self::phpParserTypeToAstNode($c, $start_line);
if ($result) {
$children[] = $result;
}
}
if (count($children) <= 1) {
return $children[0] ?? null;
}
return new ast\Node(ast\AST_TYPE_INTERSECTION, 0, $children, $start_line);
}
/**
* @param PhpParser\Node\QualifiedName|Token|null $type
*/
@@ -1951,7 +1971,12 @@ class TolerantASTConverter
$original_type = $type;
if ($type instanceof PhpParser\Node\QualifiedName) {
$type = static::phpParserNameToString($type);
} elseif ($type instanceof PhpParser\Node\ParenthesizedIntersectionType) {
return static::phpParserParenthesizedIntersectionTypeToAstNode($type, $line);
} elseif ($type instanceof Token) {
if (get_class($type) !== Token::class) {
return null;
}
$type = static::tokenToString($type);
}
if (\is_string($type)) {
@@ -2283,24 +2308,35 @@ class TolerantASTConverter
);
}
/**
* @param ?Token $flags
* @throws InvalidArgumentException if the class flags were unexpected
*/
private static function phpParserClassModifierToAstClassFlags(?Token $flags): int
private static function phpParserClassModifierToAstClassFlags(?Token $modifier): int
{
if ($flags === null) {
if ($modifier === null) {
return 0;
}
switch ($flags->kind) {
switch ($modifier->kind) {
case TokenKind::AbstractKeyword:
return flags\CLASS_ABSTRACT;
case TokenKind::FinalKeyword:
return flags\CLASS_FINAL;
case TokenKind::ReadonlyKeyword:
return flags\CLASS_READONLY;
default:
throw new InvalidArgumentException("Unexpected kind '" . Token::getTokenKindNameFromValue($flags->kind) . "'");
throw new InvalidArgumentException("Unexpected kind '" . Token::getTokenKindNameFromValue($modifier->kind) . "'");
}
}
/**
* @param ?Token $modifier
* @param list<Token> $modifiers
* @throws InvalidArgumentException if the class flags were unexpected
*/
private static function phpParserClassModifiersToAstClassFlags(?Token $modifier, array $modifiers): int
{
$flags = self::phpParserClassModifierToAstClassFlags($modifier);
foreach ($modifiers as $extra_modifier) {
$flags |= self::phpParserClassModifierToAstClassFlags($extra_modifier);
}
return $flags;
}
private static function interfaceBaseClauseToNode(?\Microsoft\PhpParser\Node\InterfaceBaseClause $node): ?\ast\Node
{

View File

@@ -146,8 +146,8 @@ if (extension_loaded('ast')) {
exit(1);
};
if (PHP_VERSION_ID >= 80200 && version_compare($ast_version, '1.0.15') < 0) {
$phan_output_ast_too_old_and_exit('1.0.15', '8.2');
if (PHP_VERSION_ID >= 80200 && version_compare($ast_version, '1.1.0') < 0) {
$phan_output_ast_too_old_and_exit('1.1.0', '8.2');
} elseif (PHP_VERSION_ID >= 80100 && version_compare($ast_version, '1.0.14') < 0) {
$phan_output_ast_too_old_and_exit('1.0.14', '8.1');
} elseif (PHP_VERSION_ID >= 80000 && version_compare($ast_version, '1.0.11') < 0) {
@@ -360,6 +360,7 @@ function phan_error_handler(int $errno, string $errstr, string $errfile, int $er
}
if ($errno === E_DEPRECATED) {
// Because php 7.2 is used in CI we're stuck on an unmaintained paratest version.
// NOTE: Known issues with dynamic properties in tolerant-php-parser are fixed in `main` (but not 0.1.1) but there may be remaining unknown ones.
if (preg_match('/^Creation of dynamic property (ParaTest\\\\Runners|Microsoft\\\\PhpParser|Phan\\\\LanguageServer\\\\LanguageServer::)/', $errstr)) {
return true;
}

View File

@@ -84,7 +84,7 @@ class CLI
/**
* This should be updated to x.y.z-dev after every release, and x.y.z before a release.
*/
public const PHAN_VERSION = '5.4.1';
public const PHAN_VERSION = '5.4.2';
/**
* List of short flags passed to getopt

View File

@@ -488,6 +488,10 @@ class Clazz extends AddressableElement
foreach ($method_list as $method) {
$clazz->addMethod($code_base, $method, None::instance());
}
if (\PHP_VERSION_ID < 80000 && $reflection_method->isConstructor() && \strcasecmp($reflection_method->name, '__construct') !== 0) {
// E.g. SoapFault::SoapFault and other soap classes before PHP 8.0
$clazz->addMethod($code_base, Method::defaultConstructorForClass($clazz, $code_base), None::instance());
}
}
return $clazz;
@@ -2298,6 +2302,11 @@ class Clazz extends AddressableElement
*/
public function hasDynamicProperties(CodeBase $code_base): bool
{
foreach($this->attribute_list as $attr) {
if ((string)$attr === '\AllowDynamicProperties') {
return true;
}
}
return $this->hasFlagsRecursive($code_base, Flags::CLASS_HAS_DYNAMIC_PROPERTIES);
}
@@ -2979,6 +2988,16 @@ class Clazz extends AddressableElement
$this->warnAboutAmbiguousInheritance($code_base, $class, $next_class_fqsen);
}
if ($attribute_list = $class->getAttributeList()) {
foreach($attribute_list as $attr) {
if ((string)$attr === "\AllowDynamicProperties") {
$new_attribute_list = $this->getAttributeList();
$new_attribute_list[] = $attr;
$this->setAttributeList($new_attribute_list);
break;
}
}
}
// Constants should have been imported earlier, but call it again just in case
$this->importConstantsFromAncestorClass($code_base, $class);

View File

@@ -3074,7 +3074,7 @@ return [
'Exception::getTraceAsString' => ['string'],
'exec' => ['string', 'command'=>'string', '&w_output='=>'array', '&w_result_code='=>'int'],
'exif_imagetype' => ['int|false', 'filename'=>'string'],
'exif_read_data' => ['array<string,mixed>|false', 'file'=>'string', 'required_sections='=>'string', 'as_arrays='=>'bool', 'read_thumbnail='=>'bool'],
'exif_read_data' => ['array<string,mixed>|false', 'file'=>'resource|string', 'required_sections='=>'string', 'as_arrays='=>'bool', 'read_thumbnail='=>'bool'],
'exif_tagname' => ['string|false', 'index'=>'int'],
'exif_thumbnail' => ['string|false', 'file'=>'string', '&w_width='=>'int', '&w_height='=>'int', '&w_image_type='=>'int'],
'exit' => ['', 'status'=>'string|int'],
@@ -13136,7 +13136,7 @@ return [
'SoapClient::__soapCall' => ['', 'name'=>'string', 'args'=>'array', 'options='=>'array', 'inputHeaders='=>'SoapHeader|array', '&w_outputHeaders='=>'array'],
'SoapClient::SoapClient' => ['object', 'wsdl'=>'mixed', 'options='=>'array'],
'SoapFault::__clone' => ['void'],
'SoapFault::__construct' => ['void', 'code'=>'string', 'string'=>'string', 'actor='=>'string', 'details='=>'string', 'name='=>'string', 'headerFault='=>'string'],
'SoapFault::__construct' => ['void', 'code'=>'?string|?array{0:string,1:string}', 'string'=>'string', 'actor='=>'string', 'details='=>'mixed', 'name='=>'string', 'headerFault='=>'string'],
'SoapFault::__toString' => ['string'],
'SoapFault::__wakeup' => ['void'],
'SoapFault::getCode' => ['int'],
@@ -13146,7 +13146,7 @@ return [
'SoapFault::getPrevious' => ['?Exception|?Throwable'],
'SoapFault::getTrace' => ['array'],
'SoapFault::getTraceAsString' => ['string'],
'SoapFault::SoapFault' => ['object', 'faultcode'=>'string', 'faultstring'=>'string', 'faultactor='=>'string', 'detail='=>'string', 'faultname='=>'string', 'headerfault='=>'string'],
'SoapFault::SoapFault' => ['void', 'code'=>'?string|?array{0:string,1:string}', 'string'=>'string', 'actor='=>'string', 'details='=>'mixed', 'name='=>'string', 'headerFault='=>'string'],
'SoapHeader::__construct' => ['void', 'namespace'=>'string', 'name'=>'string', 'data='=>'mixed', 'mustUnderstand='=>'bool', 'actor='=>'string'],
'SoapHeader::SoapHeader' => ['object', 'namespace'=>'string', 'name'=>'string', 'data='=>'mixed', 'mustunderstand='=>'bool', 'actor='=>'string'],
'SoapParam::__construct' => ['void', 'data'=>'mixed', 'name'=>'string'],

View File

@@ -131,6 +131,10 @@ return [
'ZipArchive::setEncryptionName' => ['bool', 'name'=>'string', 'method'=>'int', 'password='=>'string'],
],
'changed' => [
'exif_read_data' => [
'old' => ['array<string,mixed>|false', 'file'=>'string', 'required_sections='=>'string', 'as_arrays='=>'bool', 'read_thumbnail='=>'bool'],
'new' => ['array<string,mixed>|false', 'file'=>'resource|string', 'required_sections='=>'string', 'as_arrays='=>'bool', 'read_thumbnail='=>'bool'],
],
'hash_copy' => [
'old' => ['resource', 'context'=>'resource'],
'new' => ['HashContext', 'context'=>'HashContext'],

View File

@@ -417,6 +417,7 @@ class UseReturnValuePlugin extends PluginV3 implements PostAnalyzeNodeCapability
'gethostname' => true,
'getimagesize' => true,
'get_include_path' => true,
'get_mangled_object_vars' => true,
'get_magic_quotes_gpc' => true,
'get_magic_quotes_gpc_runtime' => true,
'getmypid' => true,
@@ -457,7 +458,9 @@ class UseReturnValuePlugin extends PluginV3 implements PostAnalyzeNodeCapability
'hypot' => true,
'iconv_strlen' => true,
'iconv' => true,
'imagecreate' => self::MUST_USE_WITH_SIDE_EFFECTS,
'imagecreatetruecolor' => self::MUST_USE_WITH_SIDE_EFFECTS,
'imagecreatefromtga' => self::MUST_USE_WITH_SIDE_EFFECTS,
'imagetypes' => true,
'implode' => true,
'in_array' => true,
@@ -624,10 +627,12 @@ class UseReturnValuePlugin extends PluginV3 implements PostAnalyzeNodeCapability
'openssl_encrypt' => true,
'openssl_error_string' => true,
'openssl_random_pseudo_bytes' => true,
'openssl_x509_verify' => true,
'ord' => true,
'pack' => true,
'parse_ini_file' => true,
'parse_url' => true,
'password_algos' => true,
'pathinfo' => true,
'pdo::getattribute' => true,
'pdo::prepare' => true,
@@ -742,6 +747,8 @@ class UseReturnValuePlugin extends PluginV3 implements PostAnalyzeNodeCapability
'reflectionproperty::getvalue' => true,
'reflectionproperty::ispublic' => true,
'reflectionproperty::isstatic' => true,
'reflectionreference::fromarrayelement' => true,
'reflectionreference::getid' => true,
'reflectiontype::__tostring' => true,
'resourcebundle::geterrorcode' => true,
'round' => true,

View File

@@ -15,6 +15,7 @@
# The resulting tags file may be combined with tags for JS, CSS, etc.
function usage() {
echo "Usage: $0 [options for phpctags]" 1>&2
echo "You may wish to run ./phan --dump-ctags=basic instead" 1>&2
}
if ! type phpctags ; then

View File

@@ -87,7 +87,7 @@ class Application implements ResetInterface
private string $defaultCommand;
private bool $singleCommand = false;
private bool $initialized = false;
private SignalRegistry $signalRegistry;
private ?SignalRegistry $signalRegistry = null;
private array $signalsToDispatchEvent = [];
public function __construct(string $name = 'UNKNOWN', string $version = 'UNKNOWN')

View File

@@ -123,8 +123,6 @@ class ProgressIndicator
/**
* Finish the indicator with message.
*
* @param $message
*/
public function finish(string $message)
{

View File

@@ -36,10 +36,10 @@ class InputArgument
private string $description;
/**
* @param string $name The argument name
* @param int|null $mode The argument mode: self::REQUIRED or self::OPTIONAL
* @param string $description A description text
* @param string|bool|int|float|array|null $default The default value (for self::OPTIONAL mode only)
* @param string $name The argument name
* @param int|null $mode The argument mode: self::REQUIRED or self::OPTIONAL
* @param string $description A description text
* @param string|bool|int|float|array|null $default The default value (for self::OPTIONAL mode only)
* @param array|\Closure(CompletionInput,CompletionSuggestions):list<string|Suggestion> $suggestedValues The values used for input completion
*
* @throws InvalidArgumentException When argument mode is not valid

View File

@@ -58,9 +58,9 @@ class InputOption
private string $description;
/**
* @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
* @param int|null $mode The option mode: One of the VALUE_* constants
* @param string|bool|int|float|array|null $default The default value (must be null for self::VALUE_NONE)
* @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
* @param int|null $mode The option mode: One of the VALUE_* constants
* @param string|bool|int|float|array|null $default The default value (must be null for self::VALUE_NONE)
* @param array|\Closure(CompletionInput,CompletionSuggestions):list<string|Suggestion> $suggestedValues The values used for input completion
*
* @throws InvalidArgumentException If option mode is invalid or incompatible

View File

@@ -1,4 +1,4 @@
Copyright (c) 2004-2023 Fabien Potencier
Copyright (c) 2004-present Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -115,7 +115,8 @@ class ConsoleSectionOutput extends StreamOutput
// re-add the line break (that has been removed in the above `explode()` for
// - every line that is not the last line
// - if $newline is required, also add it to the last line
if ($i < $count || $newline) {
// - if it's not new line, but input ending with `\PHP_EOL`
if ($i < $count || $newline || str_ends_with($input, \PHP_EOL)) {
$lineContent .= \PHP_EOL;
}
@@ -149,6 +150,15 @@ class ConsoleSectionOutput extends StreamOutput
return $linesAdded;
}
/**
* @internal
*/
public function addNewLineOfInputSubmit()
{
$this->content[] = \PHP_EOL;
++$this->lines;
}
protected function doWrite(string $message, bool $newline)
{
if (!$this->isDecorated()) {

View File

@@ -23,6 +23,7 @@ use Symfony\Component\Console\Helper\TableCell;
use Symfony\Component\Console\Helper\TableSeparator;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Output\ConsoleSectionOutput;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\TrimmedBufferOutput;
use Symfony\Component\Console\Question\ChoiceQuestion;
@@ -298,6 +299,11 @@ class SymfonyStyle extends OutputStyle
$answer = $this->questionHelper->ask($this->input, $this, $question);
if ($this->input->isInteractive()) {
if ($this->output instanceof ConsoleSectionOutput) {
// add the new line of the `return` to submit the input to ConsoleSectionOutput, because ConsoleSectionOutput is holding all it's lines.
// this is relevant when a `ConsoleSectionOutput::clear` is called.
$this->output->addNewLineOfInputSubmit();
}
$this->newLine();
$this->bufferedOutput->write("\n");
}

View File

@@ -1,4 +1,4 @@
Copyright (c) 2020-2022 Fabien Potencier
Copyright (c) 2020-present Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -22,5 +22,5 @@ trigger_deprecation('symfony/blockchain', '8.9', 'Using "%s" is deprecated, use
This will generate the following message:
`Since symfony/blockchain 8.9: Using "bitcoin" is deprecated, use "fabcoin" instead.`
While not necessarily recommended, the deprecation notices can be completely ignored by declaring an empty
While not recommended, the deprecation notices can be completely ignored by declaring an empty
`function trigger_deprecation() {}` in your application.

View File

@@ -1,4 +1,4 @@
Copyright (c) 2018-2022 Fabien Potencier
Copyright (c) 2018-present Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -3,7 +3,7 @@ Symfony Service Contracts
A set of abstractions extracted out of the Symfony components.
Can be used to build on semantics that the Symfony components proved useful - and
Can be used to build on semantics that the Symfony components proved useful and
that already have battle tested implementations.
See https://github.com/symfony/contracts/blob/main/README.md for more information.

View File

@@ -26,5 +26,8 @@ namespace Symfony\Contracts\Service;
*/
interface ResetInterface
{
/**
* @return void
*/
public function reset();
}

View File

@@ -19,7 +19,7 @@ use Psr\Container\ContainerInterface;
* @author Nicolas Grekas <p@tchwork.com>
* @author Mateusz Sip <mateusz.sip@gmail.com>
*
* @template T of mixed
* @template-covariant T of mixed
*/
interface ServiceProviderInterface extends ContainerInterface
{

View File

@@ -66,12 +66,13 @@ trait ServiceSubscriberTrait
#[Required]
public function setContainer(ContainerInterface $container): ?ContainerInterface
{
$this->container = $container;
$ret = null;
if (method_exists(get_parent_class(self::class) ?: '', __FUNCTION__)) {
return parent::setContainer($container);
$ret = parent::setContainer($container);
}
return null;
$this->container = $container;
return $ret;
}
}

View File

@@ -37,8 +37,8 @@ abstract class AbstractUnicodeString extends AbstractString
private const ASCII = "\x20\x65\x69\x61\x73\x6E\x74\x72\x6F\x6C\x75\x64\x5D\x5B\x63\x6D\x70\x27\x0A\x67\x7C\x68\x76\x2E\x66\x62\x2C\x3A\x3D\x2D\x71\x31\x30\x43\x32\x2A\x79\x78\x29\x28\x4C\x39\x41\x53\x2F\x50\x22\x45\x6A\x4D\x49\x6B\x33\x3E\x35\x54\x3C\x44\x34\x7D\x42\x7B\x38\x46\x77\x52\x36\x37\x55\x47\x4E\x3B\x4A\x7A\x56\x23\x48\x4F\x57\x5F\x26\x21\x4B\x3F\x58\x51\x25\x59\x5C\x09\x5A\x2B\x7E\x5E\x24\x40\x60\x7F\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F";
// the subset of folded case mappings that is not in lower case mappings
private const FOLD_FROM = ['İ', 'µ', 'ſ', "\xCD\x85", 'ς', 'ϐ', 'ϑ', 'ϕ', 'ϖ', 'ϰ', 'ϱ', 'ϵ', 'ẛ', "\xE1\xBE\xBE", 'ß', 'İ', 'ʼn', 'ǰ', 'ΐ', 'ΰ', 'և', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'ẚ', 'ẞ', 'ὐ', 'ὒ', 'ὔ', 'ὖ', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', 'ᾍ', 'ᾎ', 'ᾏ', 'ᾐ', 'ᾑ', 'ᾒ', 'ᾓ', 'ᾔ', 'ᾕ', 'ᾖ', 'ᾗ', 'ᾘ', 'ᾙ', 'ᾚ', 'ᾛ', 'ᾜ', 'ᾝ', 'ᾞ', 'ᾟ', 'ᾠ', 'ᾡ', 'ᾢ', 'ᾣ', 'ᾤ', 'ᾥ', 'ᾦ', 'ᾧ', 'ᾨ', 'ᾩ', 'ᾪ', 'ᾫ', 'ᾬ', 'ᾭ', 'ᾮ', 'ᾯ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'ᾼ', 'ῂ', 'ῃ', 'ῄ', 'ῆ', 'ῇ', 'ῌ', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'ῢ', 'ΰ', 'ῤ', 'ῦ', 'ῧ', 'ῲ', 'ῳ', 'ῴ', 'ῶ', 'ῷ', 'ῼ', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'ſt', 'st', 'ﬓ', 'ﬔ', 'ﬕ', 'ﬖ', 'ﬗ'];
private const FOLD_TO = ['i̇', 'μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', 'ṡ', 'ι', 'ss', 'i̇', 'ʼn', 'ǰ', 'ΐ', 'ΰ', 'եւ', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'aʾ', 'ss', 'ὐ', 'ὒ', 'ὔ', 'ὖ', 'ἀι', 'ἁι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἀι', 'ἁι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὰι', 'αι', 'άι', 'ᾶ', 'ᾶι', 'αι', 'ὴι', 'ηι', 'ήι', 'ῆ', 'ῆι', 'ηι', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'ῢ', 'ΰ', 'ῤ', 'ῦ', 'ῧ', 'ὼι', 'ωι', 'ώι', 'ῶ', 'ῶι', 'ωι', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'st', 'st', 'մն', 'մե', 'մի', 'վն', 'մխ'];
private const FOLD_FROM = ['İ', 'µ', 'ſ', "\xCD\x85", 'ς', 'ϐ', 'ϑ', 'ϕ', 'ϖ', 'ϰ', 'ϱ', 'ϵ', 'ẛ', "\xE1\xBE\xBE", 'ß', 'ʼn', 'ǰ', 'ΐ', 'ΰ', 'և', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'ẚ', 'ẞ', 'ὐ', 'ὒ', 'ὔ', 'ὖ', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', 'ᾍ', 'ᾎ', 'ᾏ', 'ᾐ', 'ᾑ', 'ᾒ', 'ᾓ', 'ᾔ', 'ᾕ', 'ᾖ', 'ᾗ', 'ᾘ', 'ᾙ', 'ᾚ', 'ᾛ', 'ᾜ', 'ᾝ', 'ᾞ', 'ᾟ', 'ᾠ', 'ᾡ', 'ᾢ', 'ᾣ', 'ᾤ', 'ᾥ', 'ᾦ', 'ᾧ', 'ᾨ', 'ᾩ', 'ᾪ', 'ᾫ', 'ᾬ', 'ᾭ', 'ᾮ', 'ᾯ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'ᾼ', 'ῂ', 'ῃ', 'ῄ', 'ῆ', 'ῇ', 'ῌ', 'ῒ', 'ῖ', 'ῗ', 'ῢ', 'ῤ', 'ῦ', 'ῧ', 'ῲ', 'ῳ', 'ῴ', 'ῶ', 'ῷ', 'ῼ', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'ſt', 'st', 'ﬓ', 'ﬔ', 'ﬕ', 'ﬖ', 'ﬗ'];
private const FOLD_TO = ['i̇', 'μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', 'ṡ', 'ι', 'ss', 'ʼn', 'ǰ', 'ΐ', 'ΰ', 'եւ', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'aʾ', 'ss', 'ὐ', 'ὒ', 'ὔ', 'ὖ', 'ἀι', 'ἁι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἀι', 'ἁι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὰι', 'αι', 'άι', 'ᾶ', 'ᾶι', 'αι', 'ὴι', 'ηι', 'ήι', 'ῆ', 'ῆι', 'ηι', 'ῒ', 'ῖ', 'ῗ', 'ῢ', 'ῤ', 'ῦ', 'ῧ', 'ὼι', 'ωι', 'ώι', 'ῶ', 'ῶι', 'ωι', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'st', 'st', 'մն', 'մե', 'մի', 'վն', 'մխ'];
// the subset of upper case mappings that map one code point to many code points
private const UPPER_FROM = ['ß', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'ſt', 'st', 'և', 'ﬓ', 'ﬔ', 'ﬕ', 'ﬖ', 'ﬗ', 'ʼn', 'ΐ', 'ΰ', 'ǰ', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'ẚ', 'ὐ', 'ὒ', 'ὔ', 'ὖ', 'ᾶ', 'ῆ', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'ῢ', 'ΰ', 'ῤ', 'ῦ', 'ῧ', 'ῶ'];

View File

@@ -1,4 +1,4 @@
Copyright (c) 2019-2023 Fabien Potencier
Copyright (c) 2019-present Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal