From f9047dd0d021b5a08615c0e3190907cc620584db Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 13 Sep 2024 13:12:14 -0400 Subject: [PATCH 001/134] Bumped version to 2.1.0 --- src/ncc/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ncc/VERSION b/src/ncc/VERSION index 6acdb44..50aea0e 100644 --- a/src/ncc/VERSION +++ b/src/ncc/VERSION @@ -1 +1 @@ -2.0.3 \ No newline at end of file +2.1.0 \ No newline at end of file From 1ba50cc7ee9022027a4e3c8dc9a9a51d266aabed Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 13 Sep 2024 13:20:12 -0400 Subject: [PATCH 002/134] Convert Versions constants to enum cases --- .../Classes/GiteaExtension/GiteaRepository.php | 10 +++++----- .../GithubExtension/GithubRepository.php | 10 +++++----- .../GitlabExtension/GitlabRepository.php | 10 +++++----- .../PackagistExtension/PackagistRepository.php | 6 +++--- src/ncc/Classes/Runtime.php | 4 ++-- src/ncc/Enums/Versions.php | 13 ++++--------- src/ncc/Interfaces/RepositoryInterface.php | 4 ++-- src/ncc/Managers/PackageManager.php | 4 ++-- src/ncc/Objects/PackageLock.php | 4 ++-- src/ncc/Objects/PackageLock/PackageEntry.php | 18 +++++++++--------- .../ProjectConfiguration/Dependency.php | 8 ++++---- src/ncc/Objects/RemotePackageInput.php | 6 +++--- src/ncc/Objects/RepositoryConfiguration.php | 4 ++-- src/ncc/Objects/Vault.php | 2 +- src/ncc/Utilities/Functions.php | 2 +- src/ncc/Utilities/extension | 2 +- 16 files changed, 51 insertions(+), 56 deletions(-) diff --git a/src/ncc/Classes/GiteaExtension/GiteaRepository.php b/src/ncc/Classes/GiteaExtension/GiteaRepository.php index 612527b..8381c12 100644 --- a/src/ncc/Classes/GiteaExtension/GiteaRepository.php +++ b/src/ncc/Classes/GiteaExtension/GiteaRepository.php @@ -47,7 +47,7 @@ /** * @inheritDoc */ - public static function fetchSourceArchive(RepositoryConfiguration $repository, string $vendor, string $project, string $version=Versions::LATEST, ?AuthenticationType $authentication=null, array $options=[]): RepositoryResult + public static function fetchSourceArchive(RepositoryConfiguration $repository, string $vendor, string $project, string $version=Versions::LATEST->value, ?AuthenticationType $authentication=null, array $options=[]): RepositoryResult { try { @@ -64,7 +64,7 @@ /** * @inheritDoc */ - public static function fetchPackage(RepositoryConfiguration $repository, string $vendor, string $project, string $version=Versions::LATEST, ?AuthenticationType $authentication=null, array $options=[]): RepositoryResult + public static function fetchPackage(RepositoryConfiguration $repository, string $vendor, string $project, string $version=Versions::LATEST->value, ?AuthenticationType $authentication=null, array $options=[]): RepositoryResult { return self::getReleasePackage($repository, $vendor, $project, $version, $authentication, $options); } @@ -162,7 +162,7 @@ */ private static function getTagArchive(RepositoryConfiguration $repository, string $group, string $project, string $tag, ?AuthenticationInterface $authentication=null): RepositoryResult { - if($tag === Versions::LATEST) + if($tag === Versions::LATEST->value) { $tag = self::getLatestTag($repository, $group, $project, $authentication); } @@ -307,7 +307,7 @@ private static function getReleasePackage(RepositoryConfiguration $repository, string $group, string $project, string $release, ?AuthenticationInterface $authentication=null, array $options=[]): RepositoryResult { /** @noinspection DuplicatedCode */ - if($release === Versions::LATEST) + if($release === Versions::LATEST->value) { $release = self::getLatestRelease($repository, $group, $project, $authentication); } @@ -409,7 +409,7 @@ private static function getReleaseArchive(RepositoryConfiguration $repository, string $group, string $project, string $release, ?AuthenticationInterface $authentication=null): RepositoryResult { /** @noinspection DuplicatedCode */ - if ($release === Versions::LATEST) + if ($release === Versions::LATEST->value) { $release = self::getLatestRelease($repository, $group, $project, $authentication); } diff --git a/src/ncc/Classes/GithubExtension/GithubRepository.php b/src/ncc/Classes/GithubExtension/GithubRepository.php index dfa2ce8..9cacc2a 100644 --- a/src/ncc/Classes/GithubExtension/GithubRepository.php +++ b/src/ncc/Classes/GithubExtension/GithubRepository.php @@ -47,7 +47,7 @@ /** * @inheritDoc */ - public static function fetchSourceArchive(RepositoryConfiguration $repository, string $vendor, string $project, string $version=Versions::LATEST, ?AuthenticationType $authentication=null, array $options=[]): RepositoryResult + public static function fetchSourceArchive(RepositoryConfiguration $repository, string $vendor, string $project, string $version=Versions::LATEST->value, ?AuthenticationType $authentication=null, array $options=[]): RepositoryResult { try { @@ -64,7 +64,7 @@ /** * @inheritDoc */ - public static function fetchPackage(RepositoryConfiguration $repository, string $vendor, string $project, string $version = Versions::LATEST, ?AuthenticationType $authentication = null, array $options=[]): RepositoryResult + public static function fetchPackage(RepositoryConfiguration $repository, string $vendor, string $project, string $version = Versions::LATEST->value, ?AuthenticationType $authentication = null, array $options=[]): RepositoryResult { return self::getReleasePackage($repository, $vendor, $project, $version, $authentication, $options); } @@ -161,7 +161,7 @@ */ private static function getTagArchive(RepositoryConfiguration $repository, string $group, string $project, string $tag, ?AuthenticationInterface $authentication = null): RepositoryResult { - if($tag === Versions::LATEST) + if($tag === Versions::LATEST->value) { $tag = self::getLatestTag($repository, $group, $project, $authentication); } @@ -307,7 +307,7 @@ private static function getReleasePackage(RepositoryConfiguration $repository, string $group, string $project, string $release, ?AuthenticationInterface $authentication=null, array $options=[]): RepositoryResult { /** @noinspection DuplicatedCode */ - if($release === Versions::LATEST) + if($release === Versions::LATEST->value) { $release = self::getLatestRelease($repository, $group, $project, $authentication); } @@ -389,7 +389,7 @@ private static function getReleaseArchive(RepositoryConfiguration $repository, string $group, string $project, string $release, ?AuthenticationInterface $authentication = null): RepositoryResult { /** @noinspection DuplicatedCode */ - if($release === Versions::LATEST) + if($release === Versions::LATEST->value) { $release = self::getLatestRelease($repository, $group, $project, $authentication); } diff --git a/src/ncc/Classes/GitlabExtension/GitlabRepository.php b/src/ncc/Classes/GitlabExtension/GitlabRepository.php index b231efe..e09c9ca 100644 --- a/src/ncc/Classes/GitlabExtension/GitlabRepository.php +++ b/src/ncc/Classes/GitlabExtension/GitlabRepository.php @@ -47,7 +47,7 @@ /** * @inheritDoc */ - public static function fetchSourceArchive(RepositoryConfiguration $repository, string $vendor, string $project, string $version=Versions::LATEST, ?AuthenticationType $authentication=null, array $options=[]): RepositoryResult + public static function fetchSourceArchive(RepositoryConfiguration $repository, string $vendor, string $project, string $version=Versions::LATEST->value, ?AuthenticationType $authentication=null, array $options=[]): RepositoryResult { try { @@ -64,7 +64,7 @@ /** * @inheritDoc */ - public static function fetchPackage(RepositoryConfiguration $repository, string $vendor, string $project, string $version=Versions::LATEST, ?AuthenticationType $authentication=null, array $options=[]): RepositoryResult + public static function fetchPackage(RepositoryConfiguration $repository, string $vendor, string $project, string $version=Versions::LATEST->value, ?AuthenticationType $authentication=null, array $options=[]): RepositoryResult { return self::getReleasePackage($repository, $vendor, $project, $version, $authentication, $options); } @@ -164,7 +164,7 @@ */ private static function getTagArchive(RepositoryConfiguration $repository, string $group, string $project, string $tag, ?AuthenticationInterface $authentication=null): RepositoryResult { - if($tag === Versions::LATEST) + if($tag === Versions::LATEST->value) { $tag = self::getLatestTag($repository, $group, $project, $authentication); } @@ -308,7 +308,7 @@ */ private static function getReleasePackage(RepositoryConfiguration $repository, string $group, string $project, string $release, ?AuthenticationInterface $authentication=null, array $options=[]): RepositoryResult { - if($release === Versions::LATEST) + if($release === Versions::LATEST->value) { $release = self::getLatestRelease($repository, $group, $project, $authentication); } @@ -393,7 +393,7 @@ private static function getReleaseArchive(RepositoryConfiguration $repository, string $group, string $project, string $release, ?AuthenticationInterface $authentication=null): RepositoryResult { /** @noinspection DuplicatedCode */ - if($release === Versions::LATEST) + if($release === Versions::LATEST->value) { $release = self::getLatestRelease($repository, $group, $project, $authentication); } diff --git a/src/ncc/Classes/PackagistExtension/PackagistRepository.php b/src/ncc/Classes/PackagistExtension/PackagistRepository.php index 98ef09b..157d721 100644 --- a/src/ncc/Classes/PackagistExtension/PackagistRepository.php +++ b/src/ncc/Classes/PackagistExtension/PackagistRepository.php @@ -46,9 +46,9 @@ /** * @inheritDoc */ - public static function fetchSourceArchive(RepositoryConfiguration $repository, string $vendor, string $project, string $version = Versions::LATEST, ?AuthenticationType $authentication = null, array $options=[]): RepositoryResult + public static function fetchSourceArchive(RepositoryConfiguration $repository, string $vendor, string $project, string $version = Versions::LATEST->value, ?AuthenticationType $authentication = null, array $options=[]): RepositoryResult { - if($version === Versions::LATEST) + if($version === Versions::LATEST->value) { $version = self::getLatestVersion($repository, $vendor, $project); } @@ -98,7 +98,7 @@ * @inheritDoc * @throws NotSupportedException */ - public static function fetchPackage(RepositoryConfiguration $repository, string $vendor, string $project, string $version = Versions::LATEST, ?AuthenticationType $authentication = null, array $options=[]): RepositoryResult + public static function fetchPackage(RepositoryConfiguration $repository, string $vendor, string $project, string $version = Versions::LATEST->value, ?AuthenticationType $authentication = null, array $options=[]): RepositoryResult { throw new NotSupportedException('Fetching ncc packages from Packagist is not supported'); } diff --git a/src/ncc/Classes/Runtime.php b/src/ncc/Classes/Runtime.php index 7800e67..ef2e9a5 100644 --- a/src/ncc/Classes/Runtime.php +++ b/src/ncc/Classes/Runtime.php @@ -121,7 +121,7 @@ * @return string * @throws ImportException */ - public static function import(string $package, string $version=Versions::LATEST): string + public static function import(string $package, string $version=Versions::LATEST->value): string { if(self::isImported($package)) { @@ -173,7 +173,7 @@ * @throws NotSupportedException * @throws PathNotFoundException */ - private static function importFromSystem(string $package, string $version=Versions::LATEST): string + private static function importFromSystem(string $package, string $version=Versions::LATEST->value): string { if(!self::getPackageManager()->getPackageLock()->entryExists($package)) { diff --git a/src/ncc/Enums/Versions.php b/src/ncc/Enums/Versions.php index ab36472..b7d1314 100644 --- a/src/ncc/Enums/Versions.php +++ b/src/ncc/Enums/Versions.php @@ -22,25 +22,20 @@ namespace ncc\Enums; - final class Versions + enum Versions : string { /** * The current version of the credentials store file format */ - public const CREDENTIALS_STORE_VERSION = '1.0.0'; - - /** - * The current version of the package structure file format - */ - public const PACKAGE_STRUCTURE_VERSION = '2.0'; + case CREDENTIALS_STORE_VERSION = '1.0.0'; /** * The current version of the package lock structure file format */ - public const PACKAGE_LOCK_VERSION = '2.0.0'; + case PACKAGE_LOCK_VERSION = '2.0.0'; /** * Generic version of the package structure file format (latest) */ - public const LATEST = 'latest'; + case LATEST = 'latest'; } \ No newline at end of file diff --git a/src/ncc/Interfaces/RepositoryInterface.php b/src/ncc/Interfaces/RepositoryInterface.php index d72845c..ee5f6f8 100644 --- a/src/ncc/Interfaces/RepositoryInterface.php +++ b/src/ncc/Interfaces/RepositoryInterface.php @@ -45,7 +45,7 @@ * @throws AuthenticationException If the authentication is invalid * @throws NetworkException If there was an error getting the source */ - public static function fetchSourceArchive(RepositoryConfiguration $repository, string $vendor, string $project, string $version=Versions::LATEST, ?AuthenticationType $authentication=null, array $options=[]): RepositoryResult; + public static function fetchSourceArchive(RepositoryConfiguration $repository, string $vendor, string $project, string $version=Versions::LATEST->value, ?AuthenticationType $authentication=null, array $options=[]): RepositoryResult; /** * Returns the archive URL for the ncc package of the specified group and project. @@ -61,5 +61,5 @@ * @throws AuthenticationException If the authentication is invalid * @throws NetworkException If there was an error getting the package */ - public static function fetchPackage(RepositoryConfiguration $repository, string $vendor, string $project, string $version=Versions::LATEST, ?AuthenticationType $authentication=null, array $options=[]): RepositoryResult; + public static function fetchPackage(RepositoryConfiguration $repository, string $vendor, string $project, string $version=Versions::LATEST->value, ?AuthenticationType $authentication=null, array $options=[]): RepositoryResult; } \ No newline at end of file diff --git a/src/ncc/Managers/PackageManager.php b/src/ncc/Managers/PackageManager.php index 25908df..375d6bd 100644 --- a/src/ncc/Managers/PackageManager.php +++ b/src/ncc/Managers/PackageManager.php @@ -206,7 +206,7 @@ { Console::outVerbose(sprintf( 'Removing symlink for %s=%s at %s', - $package_name, $this->package_lock->getEntry($package_name)->getVersion(Versions::LATEST)->getVersion(), + $package_name, $this->package_lock->getEntry($package_name)->getVersion(Versions::LATEST->value)->getVersion(), PathFinder::findBinPath() . DIRECTORY_SEPARATOR . strtolower($package_name) )); @@ -216,7 +216,7 @@ } catch(Exception $e) { - throw new IOException(sprintf('Failed to resolve symlink for %s=%s: %s', $package_name, $this->package_lock->getEntry($package_name)->getVersion(Versions::LATEST)->getVersion(), $e->getMessage()), $e); + throw new IOException(sprintf('Failed to resolve symlink for %s=%s: %s', $package_name, $this->package_lock->getEntry($package_name)->getVersion(Versions::LATEST->value)->getVersion(), $e->getMessage()), $e); } if(is_file($symlink_path)) diff --git a/src/ncc/Objects/PackageLock.php b/src/ncc/Objects/PackageLock.php index 9f6694a..a4d42b1 100644 --- a/src/ncc/Objects/PackageLock.php +++ b/src/ncc/Objects/PackageLock.php @@ -59,7 +59,7 @@ /** * Public Constructor */ - public function __construct(array $entries=[], string $package_lock_version=Versions::PACKAGE_LOCK_VERSION, ?int $last_updated_timestamp=null) + public function __construct(array $entries=[], string $package_lock_version=Versions::PACKAGE_LOCK_VERSION->value, ?int $last_updated_timestamp=null) { $this->entries = $entries; $this->package_lock_version = $package_lock_version; @@ -280,7 +280,7 @@ }, $entries_array); - $package_lock_version = Functions::array_bc($data, 'package_lock_version') ?? Versions::PACKAGE_LOCK_VERSION; + $package_lock_version = Functions::array_bc($data, 'package_lock_version') ?? Versions::PACKAGE_LOCK_VERSION->value; $last_updated_timestamp = Functions::array_bc($data, 'last_updated_timestamp') ?? time(); if($package_lock_version === null) diff --git a/src/ncc/Objects/PackageLock/PackageEntry.php b/src/ncc/Objects/PackageLock/PackageEntry.php index 5206743..4335824 100644 --- a/src/ncc/Objects/PackageLock/PackageEntry.php +++ b/src/ncc/Objects/PackageLock/PackageEntry.php @@ -183,7 +183,7 @@ */ public function versionExists(string $version): bool { - if($version === Versions::LATEST) + if($version === Versions::LATEST->value) { try { @@ -219,7 +219,7 @@ */ public function getSatisfyingVersion(string $version): string { - if($version === Versions::LATEST) + if($version === Versions::LATEST->value) { $version = $this->getLatestVersion(); } @@ -248,7 +248,7 @@ */ public function getVersion(string $version): VersionEntry { - if($version === Versions::LATEST) + if($version === Versions::LATEST->value) { $version = $this->getLatestVersion(); } @@ -354,7 +354,7 @@ * @throws IOException * @throws PathNotFoundException */ - public function getAssembly(string $version=Versions::LATEST): Assembly + public function getAssembly(string $version=Versions::LATEST->value): Assembly { $assembly_path = $this->getPath($version) . DIRECTORY_SEPARATOR . FileDescriptor::ASSEMBLY; if(!is_file($assembly_path)) @@ -375,7 +375,7 @@ * @throws PathNotFoundException * @throws NotSupportedException */ - public function getMetadata(string $version=Versions::LATEST): Metadata + public function getMetadata(string $version=Versions::LATEST->value): Metadata { $metadata_path = $this->getPath($version) . DIRECTORY_SEPARATOR . FileDescriptor::METADATA; if(!is_file($metadata_path)) @@ -394,7 +394,7 @@ * @throws IOException * @throws PathNotFoundException */ - public function getInstaller(string $version=Versions::LATEST): ?Installer + public function getInstaller(string $version=Versions::LATEST->value): ?Installer { $installer_path = $this->getPath($version) . DIRECTORY_SEPARATOR . FileDescriptor::INSTALLER; if(!is_file($installer_path)) @@ -413,7 +413,7 @@ * @throws IOException * @throws PathNotFoundException */ - public function getClassMap(string $version=Versions::LATEST): array + public function getClassMap(string $version=Versions::LATEST->value): array { $class_map_path = $this->getPath($version) . DIRECTORY_SEPARATOR . FileDescriptor::CLASS_MAP; if(!is_file($class_map_path)) @@ -434,7 +434,7 @@ * @throws IOException * @throws PathNotFoundException */ - public function getExecutionPolicy(string $policy_name, string $version=Versions::LATEST): ExecutionPolicy + public function getExecutionPolicy(string $policy_name, string $version=Versions::LATEST->value): ExecutionPolicy { $execution_policy_path = $this->getPath($version) . DIRECTORY_SEPARATOR . 'units' . DIRECTORY_SEPARATOR . $policy_name . '.policy'; if(!is_file($execution_policy_path)) @@ -453,7 +453,7 @@ * @return string * @throws IOException */ - public function getExecutionBinaryPath(string $policy_name, string $version=Versions::LATEST): string + public function getExecutionBinaryPath(string $policy_name, string $version=Versions::LATEST->value): string { $execution_binary_path = $this->getPath($version) . DIRECTORY_SEPARATOR . 'units' . DIRECTORY_SEPARATOR . $policy_name; if(!is_file($execution_binary_path)) diff --git a/src/ncc/Objects/ProjectConfiguration/Dependency.php b/src/ncc/Objects/ProjectConfiguration/Dependency.php index 5b17279..63b19af 100644 --- a/src/ncc/Objects/ProjectConfiguration/Dependency.php +++ b/src/ncc/Objects/ProjectConfiguration/Dependency.php @@ -63,7 +63,7 @@ { $this->name = $name; $this->source = $source; - $this->version = $version ?? Versions::LATEST; + $this->version = $version ?? Versions::LATEST->value; } /** @@ -115,7 +115,7 @@ */ public function getVersion(): string { - return $this->version ?? Versions::LATEST; + return $this->version ?? Versions::LATEST->value; } /** @@ -127,7 +127,7 @@ */ public function setVersion(?string $version): void { - $this->version = ($version ?? Versions::LATEST); + $this->version = ($version ?? Versions::LATEST->value); } /** @@ -140,7 +140,7 @@ throw new ConfigurationException(sprintf('Invalid dependency name "%s"', $this->name)); } - if($this->version !== Versions::LATEST && !Validate::version($this->version)) + if($this->version !== Versions::LATEST->value && !Validate::version($this->version)) { throw new ConfigurationException(sprintf('Invalid dependency version "%s"', $this->version)); } diff --git a/src/ncc/Objects/RemotePackageInput.php b/src/ncc/Objects/RemotePackageInput.php index b86b875..880ae86 100644 --- a/src/ncc/Objects/RemotePackageInput.php +++ b/src/ncc/Objects/RemotePackageInput.php @@ -66,7 +66,7 @@ { $this->package = $package; $this->vendor = $vendor; - $this->version = Versions::LATEST; + $this->version = Versions::LATEST->value; } /** @@ -126,7 +126,7 @@ */ public function setVersion(?string $version): void { - $this->version = $version ?? Versions::LATEST; + $this->version = $version ?? Versions::LATEST->value; } /** @@ -238,7 +238,7 @@ } $object = new RemotePackageInput($matches['package'], $matches['vendor']); - $object->version = empty($matches['version']) ? Versions::LATEST : $matches['version']; + $object->version = empty($matches['version']) ? Versions::LATEST->value : $matches['version']; $object->branch = empty($matches['branch']) ? null : $matches['branch']; $object->repository = empty($matches['source']) ? null : $matches['source']; diff --git a/src/ncc/Objects/RepositoryConfiguration.php b/src/ncc/Objects/RepositoryConfiguration.php index a39bc5f..245e2f0 100644 --- a/src/ncc/Objects/RepositoryConfiguration.php +++ b/src/ncc/Objects/RepositoryConfiguration.php @@ -178,7 +178,7 @@ * @throws NetworkException If there was an error getting the package * @throws NotSupportedException If the repository type does not support fetching packages */ - public function fetchPackage(string $vendor, string $project, string $version=Versions::LATEST, ?AuthenticationType $authentication=null, array $options=[]): RepositoryResult + public function fetchPackage(string $vendor, string $project, string $version=Versions::LATEST->value, ?AuthenticationType $authentication=null, array $options=[]): RepositoryResult { return match(strtolower($this->type)) { @@ -202,7 +202,7 @@ * @throws AuthenticationException If the authentication is invalid * @throws NetworkException If there was an error getting the source */ - public function fetchSourceArchive(string $vendor, string $project, string $version=Versions::LATEST, ?AuthenticationType $authentication=null, array $options=[]): RepositoryResult + public function fetchSourceArchive(string $vendor, string $project, string $version=Versions::LATEST->value, ?AuthenticationType $authentication=null, array $options=[]): RepositoryResult { return match(strtolower($this->type)) { diff --git a/src/ncc/Objects/Vault.php b/src/ncc/Objects/Vault.php index 8d8e74d..1c16fe9 100644 --- a/src/ncc/Objects/Vault.php +++ b/src/ncc/Objects/Vault.php @@ -53,7 +53,7 @@ */ public function __construct() { - $this->version = Versions::CREDENTIALS_STORE_VERSION; + $this->version = Versions::CREDENTIALS_STORE_VERSION->value; $this->entries = []; } diff --git a/src/ncc/Utilities/Functions.php b/src/ncc/Utilities/Functions.php index b6a1f9a..2f04a82 100644 --- a/src/ncc/Utilities/Functions.php +++ b/src/ncc/Utilities/Functions.php @@ -641,7 +641,7 @@ * @param string $version * @return string */ - public static function createExecutionPointer(string $package_name, string $version=Versions::LATEST): string + public static function createExecutionPointer(string $package_name, string $version=Versions::LATEST->value): string { $content = "#!/bin/sh\n"; $content .= sprintf('exec ncc exec --package "%s" --exec-version "%s" --exec-args "$@"', $package_name, $version); diff --git a/src/ncc/Utilities/extension b/src/ncc/Utilities/extension index fb81684..5240310 100644 --- a/src/ncc/Utilities/extension +++ b/src/ncc/Utilities/extension @@ -24,7 +24,7 @@ * @param array $options * @return string */ - function import(string $package, string $version=Versions::LATEST, array $options=[]): string + function import(string $package, string $version=Versions::LATEST->value, array $options=[]): string { try { From 7c9f63955a5b7cece6926884e6dfd154c87e97fc Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 13 Sep 2024 13:26:54 -0400 Subject: [PATCH 003/134] Update Scopes to enum and adjust scope checks --- src/ncc/CLI/Management/ConfigMenu.php | 2 +- src/ncc/CLI/Management/CredentialMenu.php | 4 ++-- src/ncc/CLI/Management/PackageManagerMenu.php | 8 ++++---- src/ncc/CLI/Management/ProjectMenu.php | 2 +- src/ncc/CLI/Management/RepositoryMenu.php | 4 ++-- src/ncc/Enums/Scopes.php | 6 +++--- src/ncc/Managers/ConfigurationManager.php | 2 +- src/ncc/Managers/CredentialManager.php | 6 +++--- src/ncc/Managers/PackageLockManager.php | 4 ++-- src/ncc/Managers/PackageManager.php | 6 +++--- src/ncc/Managers/ProjectManager.php | 2 +- src/ncc/Managers/RepositoryManager.php | 8 ++++---- src/ncc/Utilities/Functions.php | 4 ++-- src/ncc/Utilities/Resolver.php | 4 ++-- src/ncc/Utilities/Validate.php | 4 ++-- 15 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/ncc/CLI/Management/ConfigMenu.php b/src/ncc/CLI/Management/ConfigMenu.php index e28ab88..87a9c43 100644 --- a/src/ncc/CLI/Management/ConfigMenu.php +++ b/src/ncc/CLI/Management/ConfigMenu.php @@ -101,7 +101,7 @@ if(isset($args['v'])) { - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { Console::outError('Insufficient permissions, cannot modify configuration values', true, 1); return 1; diff --git a/src/ncc/CLI/Management/CredentialMenu.php b/src/ncc/CLI/Management/CredentialMenu.php index 1253c0d..6a9caee 100644 --- a/src/ncc/CLI/Management/CredentialMenu.php +++ b/src/ncc/CLI/Management/CredentialMenu.php @@ -187,7 +187,7 @@ { $ResolvedScope = Resolver::resolveScope(); - if($ResolvedScope !== Scopes::SYSTEM) + if($ResolvedScope !== Scopes::SYSTEM->value) { Console::outError('Insufficient permissions to add entries'); } @@ -313,7 +313,7 @@ { $ResolvedScope = Resolver::resolveScope(); - if($ResolvedScope !== Scopes::SYSTEM) + if($ResolvedScope !== Scopes::SYSTEM->value) { Console::outError('Insufficient permissions to remove entries'); } diff --git a/src/ncc/CLI/Management/PackageManagerMenu.php b/src/ncc/CLI/Management/PackageManagerMenu.php index 8af6710..a3bd820 100644 --- a/src/ncc/CLI/Management/PackageManagerMenu.php +++ b/src/ncc/CLI/Management/PackageManagerMenu.php @@ -132,7 +132,7 @@ */ private static function installPackage(array $args): int { - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { Console::outError('You cannot install packages in a user scope, please run this command as root', true, 1); return 1; @@ -388,7 +388,7 @@ */ private static function uninstallPackage($args): int { - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { Console::outError('You cannot uninstall packages in a user scope, please run this command as root', true, 1); return 1; @@ -419,7 +419,7 @@ */ private static function uninstallAllPackages(array $args): int { - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { Console::outError('You cannot uninstall all packages in a user scope, please run this command as root', true, 1); return 1; @@ -455,7 +455,7 @@ */ private static function fixBrokenPackages(array $args): int { - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { Console::outError('You cannot fix broken packages in a user scope, please run this command as root', true, 1); return 1; diff --git a/src/ncc/CLI/Management/ProjectMenu.php b/src/ncc/CLI/Management/ProjectMenu.php index 73fe108..a1562bf 100644 --- a/src/ncc/CLI/Management/ProjectMenu.php +++ b/src/ncc/CLI/Management/ProjectMenu.php @@ -134,7 +134,7 @@ */ private static function installProject(array $args): int { - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { Console::outError('You cannot install packages in a user scope, please run this command as root', true, 1); return 1; diff --git a/src/ncc/CLI/Management/RepositoryMenu.php b/src/ncc/CLI/Management/RepositoryMenu.php index 2ce5411..033e844 100644 --- a/src/ncc/CLI/Management/RepositoryMenu.php +++ b/src/ncc/CLI/Management/RepositoryMenu.php @@ -141,7 +141,7 @@ */ private static function addEntry(array $args): int { - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { Console::outError('You must be running as root to add a new repository', true, 1); return 1; @@ -230,7 +230,7 @@ */ private static function removeEntry(array $args): int { - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { Console::outError('You must be running as root to remove a repository', true, 1); return 1; diff --git a/src/ncc/Enums/Scopes.php b/src/ncc/Enums/Scopes.php index a668670..efae5ee 100644 --- a/src/ncc/Enums/Scopes.php +++ b/src/ncc/Enums/Scopes.php @@ -22,9 +22,9 @@ namespace ncc\Enums; - final class Scopes + enum Scopes : string { - public const USER = 'USER'; + case USER = 'USER'; - public const SYSTEM = 'SYSTEM'; + case SYSTEM = 'SYSTEM'; } \ No newline at end of file diff --git a/src/ncc/Managers/ConfigurationManager.php b/src/ncc/Managers/ConfigurationManager.php index 451dd18..e33efc9 100644 --- a/src/ncc/Managers/ConfigurationManager.php +++ b/src/ncc/Managers/ConfigurationManager.php @@ -89,7 +89,7 @@ { Console::outDebug(sprintf('saving configuration file to %s', PathFinder::getConfigurationFile())); - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { throw new AuthenticationException('Cannot save configuration file, insufficient permissions'); } diff --git a/src/ncc/Managers/CredentialManager.php b/src/ncc/Managers/CredentialManager.php index d2d54fc..146472e 100644 --- a/src/ncc/Managers/CredentialManager.php +++ b/src/ncc/Managers/CredentialManager.php @@ -51,7 +51,7 @@ */ public function __construct() { - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { throw new OperationException('You must have root privileges to access the credentials storage file'); } @@ -86,7 +86,7 @@ { Console::outVerbose(sprintf('Saving credentials store to %s', PathFinder::getCredentialStorage())); - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { throw new OperationException('You must have root privileges to modify the credentials storage file'); } @@ -103,7 +103,7 @@ */ public static function initializeCredentialStorage(): void { - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { throw new OperationException('You must have root privileges to initialize the credentials storage file'); } diff --git a/src/ncc/Managers/PackageLockManager.php b/src/ncc/Managers/PackageLockManager.php index 9b6c708..1bae518 100644 --- a/src/ncc/Managers/PackageLockManager.php +++ b/src/ncc/Managers/PackageLockManager.php @@ -80,7 +80,7 @@ */ public function save(): void { - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { throw new OperationException('You must be running as root to update the system package lock'); } @@ -98,7 +98,7 @@ */ public static function initializePackageLock(): void { - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { throw new OperationException('You must be running as root to update the system package lock'); } diff --git a/src/ncc/Managers/PackageManager.php b/src/ncc/Managers/PackageManager.php index 375d6bd..9ba157b 100644 --- a/src/ncc/Managers/PackageManager.php +++ b/src/ncc/Managers/PackageManager.php @@ -151,7 +151,7 @@ */ public function install(string|PackageReader $input, ?AuthenticationInterface $authentication=null, array $options=[]): array { - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { throw new OperationException('You must have root privileges to install packages'); } @@ -188,7 +188,7 @@ */ public function uninstall(string $package_name, ?string $version=null): array { - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { throw new OperationException('You must have root privileges to uninstall packages'); } @@ -285,7 +285,7 @@ */ public function uninstallAll(): array { - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { throw new OperationException('You must have root privileges to uninstall packages'); } diff --git a/src/ncc/Managers/ProjectManager.php b/src/ncc/Managers/ProjectManager.php index 6e55750..b611ff8 100644 --- a/src/ncc/Managers/ProjectManager.php +++ b/src/ncc/Managers/ProjectManager.php @@ -211,7 +211,7 @@ */ public function installDependencies(?AuthenticationInterface $authentication=null): array { - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { throw new OperationException('Unable to install dependencies, you must be running as root'); } diff --git a/src/ncc/Managers/RepositoryManager.php b/src/ncc/Managers/RepositoryManager.php index 408b95b..d70e4cb 100644 --- a/src/ncc/Managers/RepositoryManager.php +++ b/src/ncc/Managers/RepositoryManager.php @@ -109,7 +109,7 @@ */ public function addRepository(RepositoryConfiguration $source, bool $update=true): void { - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { throw new OperationException('You must be running as root to add a new repository'); } @@ -160,7 +160,7 @@ */ public function removeRepository(string $name, bool $update=true): void { - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { throw new OperationException('You must be running as root to delete a repository'); } @@ -195,7 +195,7 @@ */ public function updateDatabase(): void { - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { throw new OperationException('You must be running as root to update the repository database'); } @@ -221,7 +221,7 @@ */ public static function initializeDatabase(array $default_repositories=[]): void { - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { throw new OperationException('You must be running as root to initialize the repository database'); } diff --git a/src/ncc/Utilities/Functions.php b/src/ncc/Utilities/Functions.php index 2f04a82..27581f7 100644 --- a/src/ncc/Utilities/Functions.php +++ b/src/ncc/Utilities/Functions.php @@ -293,7 +293,7 @@ */ public static function initializeFiles(?string $install_path=null, array $default_repositories=[]): void { - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { throw new OperationException('You must be running as root to initialize ncc files'); } @@ -523,7 +523,7 @@ */ public static function finalizePermissions(): void { - if(Resolver::resolveScope() !== Scopes::SYSTEM) + if(Resolver::resolveScope() !== Scopes::SYSTEM->value) { return; } diff --git a/src/ncc/Utilities/Resolver.php b/src/ncc/Utilities/Resolver.php index f58f0e9..2c63853 100644 --- a/src/ncc/Utilities/Resolver.php +++ b/src/ncc/Utilities/Resolver.php @@ -56,10 +56,10 @@ if(self::$user_id_cache === 0) { - return Scopes::SYSTEM; + return Scopes::SYSTEM->value; } - return Scopes::USER; + return Scopes::USER->value; } /** diff --git a/src/ncc/Utilities/Validate.php b/src/ncc/Utilities/Validate.php index 0d7d540..b661aae 100644 --- a/src/ncc/Utilities/Validate.php +++ b/src/ncc/Utilities/Validate.php @@ -111,8 +111,8 @@ namespace ncc\Utilities; switch($input) { - case Scopes::SYSTEM: - case Scopes::USER: + case Scopes::SYSTEM->value: + case Scopes::USER->value: return true; default: From 69de79ccf432120bda0f23eac89d8843bd47bada Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 13 Sep 2024 13:29:40 -0400 Subject: [PATCH 004/134] Convert Runners class to enum with string cases --- src/ncc/Classes/ExecutionUnitRunner.php | 18 +++++++-------- src/ncc/Classes/PhpExtension/PhpRunner.php | 2 +- .../PhpExtension/Templates/CliTemplate.php | 2 +- src/ncc/Enums/Runners.php | 22 +++++-------------- 4 files changed, 17 insertions(+), 27 deletions(-) diff --git a/src/ncc/Classes/ExecutionUnitRunner.php b/src/ncc/Classes/ExecutionUnitRunner.php index c82ce5e..6fad2e2 100644 --- a/src/ncc/Classes/ExecutionUnitRunner.php +++ b/src/ncc/Classes/ExecutionUnitRunner.php @@ -54,11 +54,11 @@ { $bin = match($unit->getExecutionPolicy()->getRunner()) { - Runners::PHP => (new ExecutableFinder())->find('php'), - Runners::BASH => (new ExecutableFinder())->find('bash'), - Runners::PYTHON => (new ExecutableFinder())->find('python'), - Runners::LUA => (new ExecutableFinder())->find('lua'), - Runners::PERL => (new ExecutableFinder())->find('perl'), + Runners::PHP->value => (new ExecutableFinder())->find('php'), + Runners::BASH->value => (new ExecutableFinder())->find('bash'), + Runners::PYTHON->value => (new ExecutableFinder())->find('python'), + Runners::LUA->value => (new ExecutableFinder())->find('lua'), + Runners::PERL->value => (new ExecutableFinder())->find('perl'), default => throw new NotSupportedException(sprintf('The execution policy %s is not supported because it uses the %s runner', $unit->getExecutionPolicy()->getName(), $unit->getExecutionPolicy()->getRunner())) }; @@ -109,8 +109,8 @@ $execution_unit = ExecutionUnit::fromArray(ZiProto::decode(IO::fread($unit_path))); return match ($execution_unit->getExecutionPolicy()->getRunner()) { - Runners::PHP => PhpRunner::executeUnit($execution_unit, $args), - Runners::BASH => BashRunner::executeUnit($execution_unit, $args), + Runners::PHP->value => PhpRunner::executeUnit($execution_unit, $args), + Runners::BASH->value => BashRunner::executeUnit($execution_unit, $args), default => throw new NotSupportedException(sprintf('The execution policy %s is not supported because it uses the %s runner', $execution_unit->getExecutionPolicy()->getName(), $execution_unit->getExecutionPolicy()->getRunner())), }; } @@ -138,8 +138,8 @@ { return match ($execution_unit->getExecutionPolicy()->getRunner()) { - Runners::PHP => PhpRunner::executeUnit($execution_unit, $args, false), - Runners::BASH => BashRunner::executeUnit($execution_unit, $args), + Runners::PHP->value => PhpRunner::executeUnit($execution_unit, $args, false), + Runners::BASH->value => BashRunner::executeUnit($execution_unit, $args), default => throw new NotSupportedException(sprintf('The execution policy %s is not supported because it uses the %s runner', $execution_unit->getExecutionPolicy()->getName(), $execution_unit->getExecutionPolicy()->getRunner())), }; } diff --git a/src/ncc/Classes/PhpExtension/PhpRunner.php b/src/ncc/Classes/PhpExtension/PhpRunner.php index a818dd0..2f127f8 100644 --- a/src/ncc/Classes/PhpExtension/PhpRunner.php +++ b/src/ncc/Classes/PhpExtension/PhpRunner.php @@ -44,7 +44,7 @@ */ public static function executeUnit(ExecutionUnit $unit, array $args=[], bool $local=true): int { - if($unit->getExecutionPolicy()->getRunner() !== Runners::PHP) + if($unit->getExecutionPolicy()->getRunner() !== Runners::PHP->value) { throw new InvalidArgumentException(sprintf('The execution unit %s is not a php execution unit', $unit->getExecutionPolicy()->getName())); } diff --git a/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php b/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php index cb54297..33d1e4e 100644 --- a/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php +++ b/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php @@ -49,7 +49,7 @@ public static function applyTemplate(ProjectManager $project_manager): void { $project_manager->getProjectConfiguration()->addExecutionPolicy( - new ExecutionPolicy('main_policy', Runners::PHP, new ExecutionPolicy\Execute('main')) + new ExecutionPolicy('main_policy', Runners::PHP->value, new ExecutionPolicy\Execute('main')) ); $project_manager->getProjectConfiguration()->getBuild()->setMain('main_policy'); diff --git a/src/ncc/Enums/Runners.php b/src/ncc/Enums/Runners.php index e5e4ec3..ac07436 100644 --- a/src/ncc/Enums/Runners.php +++ b/src/ncc/Enums/Runners.php @@ -22,25 +22,15 @@ namespace ncc\Enums; - final class Runners + enum Runners : string { - public const PHP = 'php'; + case PHP = 'php'; - public const BASH = 'bash'; + case BASH = 'bash'; - public const PYTHON = 'python'; + case PYTHON = 'python'; - public const PERL = 'perl'; + case PERL = 'perl'; - public const LUA = 'lua'; - - public const ALL = [ - self::PHP, - self::BASH, - self::PYTHON, - self::PYTHON_3, - self::PYTHON_2, - self::PERL, - self::LUA - ]; + case LUA = 'lua'; } \ No newline at end of file From 90535a3a35d0609ffc472325cb6ee2eee90b21fe Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 13 Sep 2024 13:31:37 -0400 Subject: [PATCH 005/134] Updated CHANGELOG.md --- CHANGELOG.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index efea8e6..d893a58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.1.0] - Ongoing + +This update introduces a refactored code-base, code quality improvements, and better exception handling. + +### Changed + - Convert Versions constants to enum cases + - Update Scopes to enum and adjust scope checks + - Convert Runners class to enum with string cases + + ## [2.0.3] - 2023-10-17 This update includes enhanced support for PHP statements in AST traversal, a friendly CLI Progress Bar, and fixes @@ -20,7 +30,7 @@ The changes improve the system's efficiency, error resilience, and user experien ### Fixed - When finding package versions in the package lock, ncc will try to find a satisfying version rather than the exact - version, this is to prevent errors when the package lock contains a version that is not available in the repository. + version, this is to prevent[CHANGELOG.md](CHANGELOG.md) errors when the package lock contains a version that is not available in the repository. - Fixed issue when registering ncc's extension, when using the INSTALLER, the installation path used in the process appears to be incorrect, added a optional parameter to the `registerExtension` method to allow the installer to pass the correct installation path. From 7e5cdf4d64c3f34e5b13d5a68d3ad4721811c49f Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 13 Sep 2024 13:34:25 -0400 Subject: [PATCH 006/134] Removed EncoderType enum file, unused. --- CHANGELOG.md | 3 +++ src/ncc/Enums/Types/EncoderType.php | 28 ---------------------------- 2 files changed, 3 insertions(+), 28 deletions(-) delete mode 100644 src/ncc/Enums/Types/EncoderType.php diff --git a/CHANGELOG.md b/CHANGELOG.md index d893a58..08276e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ This update introduces a refactored code-base, code quality improvements, and be - Update Scopes to enum and adjust scope checks - Convert Runners class to enum with string cases +### Removed + - Removed EncoderType enum file, unused. + ## [2.0.3] - 2023-10-17 diff --git a/src/ncc/Enums/Types/EncoderType.php b/src/ncc/Enums/Types/EncoderType.php deleted file mode 100644 index 40d9a43..0000000 --- a/src/ncc/Enums/Types/EncoderType.php +++ /dev/null @@ -1,28 +0,0 @@ - Date: Fri, 13 Sep 2024 13:38:31 -0400 Subject: [PATCH 007/134] Convert RegexPatterns constants to enum cases --- CHANGELOG.md | 1 + src/ncc/CLI/Management/PackageManagerMenu.php | 2 +- src/ncc/Enums/RegexPatterns.php | 20 +++++++++---------- src/ncc/Managers/PackageManager.php | 2 +- .../Objects/ProjectConfiguration/Assembly.php | 4 ++-- src/ncc/Objects/RemotePackageInput.php | 2 +- src/ncc/Utilities/Validate.php | 16 +++++++-------- 7 files changed, 24 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08276e8..0642e47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ This update introduces a refactored code-base, code quality improvements, and be - Convert Versions constants to enum cases - Update Scopes to enum and adjust scope checks - Convert Runners class to enum with string cases + - Convert RegexPatterns constants to enum cases ### Removed - Removed EncoderType enum file, unused. diff --git a/src/ncc/CLI/Management/PackageManagerMenu.php b/src/ncc/CLI/Management/PackageManagerMenu.php index a3bd820..dbc9d32 100644 --- a/src/ncc/CLI/Management/PackageManagerMenu.php +++ b/src/ncc/CLI/Management/PackageManagerMenu.php @@ -199,7 +199,7 @@ $authentication_entry = $entry->getPassword(); } - if(preg_match(RegexPatterns::REMOTE_PACKAGE, $package) === 1) + if(preg_match(RegexPatterns::REMOTE_PACKAGE->value, $package) === 1) { $package_input = RemotePackageInput::fromString($package); diff --git a/src/ncc/Enums/RegexPatterns.php b/src/ncc/Enums/RegexPatterns.php index 51fc1f3..d57a677 100644 --- a/src/ncc/Enums/RegexPatterns.php +++ b/src/ncc/Enums/RegexPatterns.php @@ -26,27 +26,27 @@ * @author Zi Xing Narrakas * @copyright Copyright (C) 2022-2023. Nosial - All Rights Reserved. */ - final class RegexPatterns + enum RegexPatterns : string { - public const UUID = '{^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$}Di'; + case UUID = '{^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$}Di'; - public const PACKAGE_NAME_FORMAT = '/^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+[0-9a-z_]$/'; + case PACKAGE_NAME_FORMAT = '/^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+[0-9a-z_]$/'; - public const COMPOSER_VERSION_FORMAT = '/^([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/'; + case COMPOSER_VERSION_FORMAT = '/^([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/'; - public const PYTHON_VERSION_FORMAT = '/^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/'; + case PYTHON_VERSION_FORMAT = '/^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/'; - public const SEMANTIC_VERSIONING_2 = '/^(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)(?:-(?P(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/m'; + case SEMANTIC_VERSIONING_2 = '/^(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)(?:-(?P(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/m'; - public const UNIX_PATH = '/^(((?:\.\/|\.\.\/|\/)?(?:\.?\w+\/)*)(\.?\w+\.?\w+))$/m'; + case UNIX_PATH = '/^(((?:\.\/|\.\.\/|\/)?(?:\.?\w+\/)*)(\.?\w+\.?\w+))$/m'; - public const CONSTANT_NAME = '/^([^\x00-\x7F]|[\w_\ \.\+\-]){2,64}$/'; + case CONSTANT_NAME = '/^([^\x00-\x7F]|[\w_\ \.\+\-]){2,64}$/'; - public const EXECUTION_POLICY_NAME = '/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/m'; + case EXECUTION_POLICY_NAME = '/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/m'; /** * @author */ - public const REMOTE_PACKAGE = '/^(?[^\/\n]+)\/(?[^:=\n@]+)(?:=(?[^:@\n]+))?(?::(?[^@\n]+))?@(?.*)$/m'; + case REMOTE_PACKAGE = '/^(?[^\/\n]+)\/(?[^:=\n@]+)(?:=(?[^:@\n]+))?(?::(?[^@\n]+))?@(?.*)$/m'; } \ No newline at end of file diff --git a/src/ncc/Managers/PackageManager.php b/src/ncc/Managers/PackageManager.php index 9ba157b..f499bcd 100644 --- a/src/ncc/Managers/PackageManager.php +++ b/src/ncc/Managers/PackageManager.php @@ -169,7 +169,7 @@ } // If the input is a remote package, we can assume it's a remote package input - if(preg_match(RegexPatterns::REMOTE_PACKAGE, $input) === 1) + if(preg_match(RegexPatterns::REMOTE_PACKAGE->value, $input) === 1) { return $this->installRemotePackage(RemotePackageInput::fromString($input), $authentication, $options); } diff --git a/src/ncc/Objects/ProjectConfiguration/Assembly.php b/src/ncc/Objects/ProjectConfiguration/Assembly.php index 4c44801..684f87e 100644 --- a/src/ncc/Objects/ProjectConfiguration/Assembly.php +++ b/src/ncc/Objects/ProjectConfiguration/Assembly.php @@ -267,7 +267,7 @@ */ public function validate(): void { - if(!preg_match(RegexPatterns::UUID, $this->uuid)) + if(!preg_match(RegexPatterns::UUID->value, $this->uuid)) { throw new ConfigurationException(sprintf('The UUID is not a valid v4 UUID: %s, in property assembly.uuid', $this->uuid)); } @@ -277,7 +277,7 @@ throw new ConfigurationException(sprintf('The version number is invalid: %s, in property assembly.version', $this->version)); } - if($this->package !== null && !preg_match(RegexPatterns::PACKAGE_NAME_FORMAT, $this->package)) + if($this->package !== null && !preg_match(RegexPatterns::PACKAGE_NAME_FORMAT->value, $this->package)) { throw new ConfigurationException(sprintf('The package name is invalid: %s, in property assembly.package', $this->package)); } diff --git a/src/ncc/Objects/RemotePackageInput.php b/src/ncc/Objects/RemotePackageInput.php index 880ae86..eaa416d 100644 --- a/src/ncc/Objects/RemotePackageInput.php +++ b/src/ncc/Objects/RemotePackageInput.php @@ -230,7 +230,7 @@ */ public static function fromString(string $input): RemotePackageInput { - if (preg_match(RegexPatterns::REMOTE_PACKAGE, $input, $matches)) + if (preg_match(RegexPatterns::REMOTE_PACKAGE->value, $input, $matches)) { if ($matches['package'] === null || $matches['vendor'] === null) { diff --git a/src/ncc/Utilities/Validate.php b/src/ncc/Utilities/Validate.php index b661aae..df31364 100644 --- a/src/ncc/Utilities/Validate.php +++ b/src/ncc/Utilities/Validate.php @@ -76,17 +76,17 @@ namespace ncc\Utilities; */ public static function version(string $input): bool { - if(preg_match(RegexPatterns::SEMANTIC_VERSIONING_2, $input)) + if(preg_match(RegexPatterns::SEMANTIC_VERSIONING_2->value, $input)) { return true; } - if(preg_match(RegexPatterns::COMPOSER_VERSION_FORMAT, $input)) + if(preg_match(RegexPatterns::COMPOSER_VERSION_FORMAT->value, $input)) { return true; } - if(preg_match(RegexPatterns::PYTHON_VERSION_FORMAT, $input)) + if(preg_match(RegexPatterns::PYTHON_VERSION_FORMAT->value, $input)) { return true; } @@ -133,7 +133,7 @@ namespace ncc\Utilities; return false; } - if(!preg_match(RegexPatterns::PACKAGE_NAME_FORMAT, $input)) + if(!preg_match(RegexPatterns::PACKAGE_NAME_FORMAT->value, $input)) { return false; } @@ -175,7 +175,7 @@ namespace ncc\Utilities; */ public static function unixFilepath($input): bool { - if(preg_match(RegexPatterns::UNIX_PATH, $input)) + if(preg_match(RegexPatterns::UNIX_PATH->value, $input)) { return true; } @@ -196,7 +196,7 @@ namespace ncc\Utilities; return false; } - if(!preg_match(RegexPatterns::CONSTANT_NAME, $input)) + if(!preg_match(RegexPatterns::CONSTANT_NAME->value, $input)) { return false; } @@ -212,7 +212,7 @@ namespace ncc\Utilities; */ public static function executionPolicyName(string $input): bool { - if(!preg_match(RegexPatterns::EXECUTION_POLICY_NAME, $input)) + if(!preg_match(RegexPatterns::EXECUTION_POLICY_NAME->value, $input)) { return false; } @@ -308,7 +308,7 @@ namespace ncc\Utilities; */ public static function remotePackageInput(string $input): bool { - if(preg_match(RegexPatterns::REMOTE_PACKAGE, $input)) + if(preg_match(RegexPatterns::REMOTE_PACKAGE->value, $input)) { return true; } From 2a16b2de6b19981e9ac7cc0ed5f8319ca971bff8 Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 00:12:55 -0400 Subject: [PATCH 008/134] Convert ProjectTemplates constants to enum cases --- src/ncc/CLI/Management/ProjectMenu.php | 4 ++-- src/ncc/Enums/ProjectTemplates.php | 14 +++----------- src/ncc/Managers/ProjectManager.php | 4 ++-- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/ncc/CLI/Management/ProjectMenu.php b/src/ncc/CLI/Management/ProjectMenu.php index a1562bf..ff83171 100644 --- a/src/ncc/CLI/Management/ProjectMenu.php +++ b/src/ncc/CLI/Management/ProjectMenu.php @@ -292,9 +292,9 @@ } Console::out(PHP_EOL . 'Available Templates:'); - foreach(ProjectTemplates::ALL as $template) + foreach(ProjectTemplates::cases() as $template) { - Console::out(' ' . $template); + Console::out(' ' . $template->value); } return 0; diff --git a/src/ncc/Enums/ProjectTemplates.php b/src/ncc/Enums/ProjectTemplates.php index 306f5b5..cea4608 100644 --- a/src/ncc/Enums/ProjectTemplates.php +++ b/src/ncc/Enums/ProjectTemplates.php @@ -22,23 +22,15 @@ namespace ncc\Enums; - final class ProjectTemplates + enum ProjectTemplates : string { /** * A template that is used to create a PHP library project */ - public const PHP_LIBRARY = 'phplib'; + case PHP_LIBRARY = 'phplib'; /** * A template that is used to create a PHP CLI application project */ - public const PHP_CLI = 'phpcli'; - - /** - * An array of all the available project templates - */ - public const ALL = [ - self::PHP_LIBRARY, - self::PHP_CLI - ]; + case PHP_CLI = 'phpcli'; } \ No newline at end of file diff --git a/src/ncc/Managers/ProjectManager.php b/src/ncc/Managers/ProjectManager.php index b611ff8..e84f69e 100644 --- a/src/ncc/Managers/ProjectManager.php +++ b/src/ncc/Managers/ProjectManager.php @@ -185,11 +185,11 @@ { switch(strtolower($template_name)) { - case ProjectTemplates::PHP_CLI: + case ProjectTemplates::PHP_CLI->value: CliTemplate::applyTemplate($this); break; - case ProjectTemplates::PHP_LIBRARY: + case ProjectTemplates::PHP_LIBRARY->value: LibraryTemplate::applyTemplate($this); break; From c687d0394dabccde6976efc8d5c16c59ab42f04d Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 00:13:43 -0400 Subject: [PATCH 009/134] Convert PackageStructureVersions constants to enum cases --- src/ncc/Classes/PackageWriter.php | 2 +- src/ncc/Enums/PackageStructureVersions.php | 56 ++++++++++------------ 2 files changed, 25 insertions(+), 33 deletions(-) diff --git a/src/ncc/Classes/PackageWriter.php b/src/ncc/Classes/PackageWriter.php index a89cff1..ad8d6ee 100644 --- a/src/ncc/Classes/PackageWriter.php +++ b/src/ncc/Classes/PackageWriter.php @@ -108,7 +108,7 @@ $this->temp_file = @fopen($this->temporary_path, 'wb'); // Create a temporary data file $this->package_file = @fopen($file_path, 'wb'); $this->headers = [ - PackageStructure::FILE_VERSION => PackageStructureVersions::_2_0, + PackageStructure::FILE_VERSION => PackageStructureVersions::_2_0->value, PackageStructure::FLAGS => [], PackageStructure::DIRECTORY => [] ]; diff --git a/src/ncc/Enums/PackageStructureVersions.php b/src/ncc/Enums/PackageStructureVersions.php index 649717a..a338409 100644 --- a/src/ncc/Enums/PackageStructureVersions.php +++ b/src/ncc/Enums/PackageStructureVersions.php @@ -1,44 +1,36 @@ Date: Sat, 14 Sep 2024 00:19:53 -0400 Subject: [PATCH 010/134] Convert PackageStructure constants to enum cases --- src/ncc/Classes/PackageReader.php | 50 +++++++++++++++--------------- src/ncc/Classes/PackageWriter.php | 38 +++++++++++------------ src/ncc/Enums/PackageStructure.php | 8 ++--- 3 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/ncc/Classes/PackageReader.php b/src/ncc/Classes/PackageReader.php index 4123a1a..26ef095 100644 --- a/src/ncc/Classes/PackageReader.php +++ b/src/ncc/Classes/PackageReader.php @@ -168,7 +168,7 @@ throw new IOException(sprintf('File \'%s\' is not a valid package file (corrupted header)', $file_path), $e); } - if(!isset($this->headers[PackageStructure::FILE_VERSION])) + if(!isset($this->headers[PackageStructure::FILE_VERSION->value])) { throw new IOException(sprintf('File \'%s\' is not a valid package file (invalid header)', $file_path)); } @@ -213,7 +213,7 @@ */ public function getFileVersion(): string { - return $this->headers[PackageStructure::FILE_VERSION]; + return $this->headers[PackageStructure::FILE_VERSION->value]; } /** @@ -223,7 +223,7 @@ */ public function getFlags(): array { - return $this->headers[PackageStructure::FLAGS]; + return $this->headers[PackageStructure::FLAGS->value]; } /** @@ -234,7 +234,7 @@ */ public function getFlag(string $name): bool { - return in_array($name, $this->headers[PackageStructure::FLAGS], true); + return in_array($name, $this->headers[PackageStructure::FLAGS->value], true); } /** @@ -244,7 +244,7 @@ */ public function getDirectory(): array { - return $this->headers[PackageStructure::DIRECTORY]; + return $this->headers[PackageStructure::DIRECTORY->value]; } /** @@ -255,15 +255,15 @@ */ public function get(string $name): string { - if(!isset($this->headers[PackageStructure::DIRECTORY][$name])) + if(!isset($this->headers[PackageStructure::DIRECTORY->value][$name])) { throw new RuntimeException(sprintf('File \'%s\' not found in package', $name)); } - $location = explode(':', $this->headers[PackageStructure::DIRECTORY][$name]); + $location = explode(':', $this->headers[PackageStructure::DIRECTORY->value][$name]); fseek($this->package_file, ($this->data_offset + (int)$location[0])); - if(in_array(PackageFlags::COMPRESSION, $this->headers[PackageStructure::FLAGS], true)) + if(in_array(PackageFlags::COMPRESSION, $this->headers[PackageStructure::FLAGS->value], true)) { return gzuncompress(fread($this->package_file, (int)$location[1])); } @@ -279,12 +279,12 @@ */ public function getPointer(string $name): array { - if(!isset($this->headers[PackageStructure::DIRECTORY][$name])) + if(!isset($this->headers[PackageStructure::DIRECTORY->value[$name]])) { throw new RuntimeException(sprintf('Resource \'%s\' not found in package', $name)); } - $location = explode(':', $this->headers[PackageStructure::DIRECTORY][$name]); + $location = explode(':', $this->headers[PackageStructure::DIRECTORY->value[$name]]); return [(int)$location[0], (int)$location[1]]; } @@ -296,7 +296,7 @@ */ public function exists(string $name): bool { - return isset($this->headers[PackageStructure::DIRECTORY][$name]); + return isset($this->headers[PackageStructure::DIRECTORY->value[$name]]); } /** @@ -327,7 +327,7 @@ return $this->cache[$directory]; } - if(!isset($this->headers[PackageStructure::DIRECTORY][$directory])) + if(!isset($this->headers[PackageStructure::DIRECTORY->value[$directory]])) { throw new ConfigurationException('Package does not contain an assembly'); } @@ -353,7 +353,7 @@ return $this->cache[$directory]; } - if(!isset($this->headers[PackageStructure::DIRECTORY][$directory])) + if(!isset($this->headers[PackageStructure::DIRECTORY->value[$directory]])) { throw new ConfigurationException('Package does not contain metadata'); } @@ -382,7 +382,7 @@ return $this->cache[$directory]; } - if(!isset($this->headers[PackageStructure::DIRECTORY][$directory])) + if(!isset($this->headers[PackageStructure::DIRECTORY->value[$directory]])) { return null; } @@ -402,7 +402,7 @@ $dependencies = []; $directory = sprintf('@%s:', PackageDirectory::DEPENDENCIES); - foreach($this->headers[PackageStructure::DIRECTORY] as $name => $location) + foreach($this->headers[PackageStructure::DIRECTORY->value] as $name => $location) { if(str_starts_with($name, $directory)) { @@ -423,7 +423,7 @@ public function getDependency(string $name): Dependency { $dependency_name = sprintf('@%s:%s', PackageDirectory::DEPENDENCIES, $name); - if(!isset($this->headers[PackageStructure::DIRECTORY][$dependency_name])) + if(!isset($this->headers[PackageStructure::DIRECTORY->value[$dependency_name]])) { throw new ConfigurationException(sprintf('Dependency \'%s\' not found in package', $name)); } @@ -454,7 +454,7 @@ $execution_units = []; $directory = sprintf('@%s:', PackageDirectory::EXECUTION_UNITS); - foreach($this->headers[PackageStructure::DIRECTORY] as $name => $location) + foreach($this->headers[PackageStructure::DIRECTORY->value] as $name => $location) { if(str_starts_with($name, $directory)) { @@ -475,7 +475,7 @@ public function getExecutionUnit(string $name): ExecutionUnit { $execution_unit_name = sprintf('@%s:%s', PackageDirectory::EXECUTION_UNITS, $name); - if(!isset($this->headers[PackageStructure::DIRECTORY][$execution_unit_name])) + if(!isset($this->headers[PackageStructure::DIRECTORY->value[$execution_unit_name]])) { throw new ConfigurationException(sprintf('Execution unit \'%s\' not found in package', $name)); } @@ -506,7 +506,7 @@ $components = []; $directory = sprintf('@%s:', PackageDirectory::COMPONENTS); - foreach($this->headers[PackageStructure::DIRECTORY] as $name => $location) + foreach($this->headers[PackageStructure::DIRECTORY->value] as $name => $location) { if(str_starts_with($name, $directory)) { @@ -527,7 +527,7 @@ $class_map = []; $directory = sprintf('@%s:', PackageDirectory::CLASS_POINTER); - foreach($this->headers[PackageStructure::DIRECTORY] as $name => $location) + foreach($this->headers[PackageStructure::DIRECTORY->value] as $name => $location) { if(str_starts_with($name, $directory)) { @@ -548,7 +548,7 @@ public function getComponent(string $name): Component { $component_name = sprintf('@%s:%s', PackageDirectory::COMPONENTS, $name); - if(!isset($this->headers[PackageStructure::DIRECTORY][$component_name])) + if(!isset($this->headers[PackageStructure::DIRECTORY->value][$component_name])) { throw new ConfigurationException(sprintf('Component \'%s\' not found in package', $name)); } @@ -579,7 +579,7 @@ public function getComponentByClass(string $class): Component { $class_name = sprintf('@%s:%s', PackageDirectory::CLASS_POINTER, $class); - if(!isset($this->headers[PackageStructure::DIRECTORY][$class_name])) + if(!isset($this->headers[PackageStructure::DIRECTORY->value[$class_name]])) { throw new ConfigurationException(sprintf('Class map \'%s\' not found in package', $class)); } @@ -597,7 +597,7 @@ $resources = []; $directory = sprintf('@%s:', PackageDirectory::RESOURCES); - foreach($this->headers[PackageStructure::DIRECTORY] as $name => $location) + foreach($this->headers[PackageStructure::DIRECTORY->value] as $name => $location) { if(str_starts_with($name, $directory)) { @@ -618,7 +618,7 @@ public function getResource(string $name): Resource { $resource_name = sprintf('@%s:%s', PackageDirectory::RESOURCES, $name); - if(!isset($this->headers[PackageStructure::DIRECTORY][$resource_name])) + if(!isset($this->headers[PackageStructure::DIRECTORY->value[$resource_name]])) { throw new ConfigurationException(sprintf('Resource \'%s\' not found in package', $name)); } @@ -647,7 +647,7 @@ */ public function find(string $filename): string|false { - foreach($this->headers[PackageStructure::DIRECTORY] as $name => $location) + foreach($this->headers[PackageStructure::DIRECTORY->value] as $name => $location) { if(str_ends_with($name, $filename)) { diff --git a/src/ncc/Classes/PackageWriter.php b/src/ncc/Classes/PackageWriter.php index ad8d6ee..440bd38 100644 --- a/src/ncc/Classes/PackageWriter.php +++ b/src/ncc/Classes/PackageWriter.php @@ -108,9 +108,9 @@ $this->temp_file = @fopen($this->temporary_path, 'wb'); // Create a temporary data file $this->package_file = @fopen($file_path, 'wb'); $this->headers = [ - PackageStructure::FILE_VERSION => PackageStructureVersions::_2_0->value, - PackageStructure::FLAGS => [], - PackageStructure::DIRECTORY => [] + PackageStructure::FILE_VERSION->value => PackageStructureVersions::_2_0->value, + PackageStructure::FLAGS->value => [], + PackageStructure::DIRECTORY->value => [] ]; if($this->temp_file === false || $this->package_file === false) @@ -126,7 +126,7 @@ */ public function getFileVersion(): string { - return (string)$this->headers[PackageStructure::FILE_VERSION]; + return (string)$this->headers[PackageStructure::FILE_VERSION->value]; } /** @@ -137,7 +137,7 @@ */ public function setFileVersion(string $version): void { - $this->headers[PackageStructure::FILE_VERSION] = $version; + $this->headers[PackageStructure::FILE_VERSION->value] = $version; } /** @@ -147,7 +147,7 @@ */ public function getFlags(): array { - return (array)$this->headers[PackageStructure::FLAGS]; + return (array)$this->headers[PackageStructure::FLAGS->value]; } /** @@ -164,7 +164,7 @@ throw new IOException('Cannot set flags after data has been written to the package'); } - $this->headers[PackageStructure::FLAGS] = $flags; + $this->headers[PackageStructure::FLAGS->value] = $flags; } /** @@ -181,9 +181,9 @@ throw new IOException('Cannot add a flag after data has been written to the package'); } - if(!in_array($flag, $this->headers[PackageStructure::FLAGS], true)) + if(!in_array($flag, $this->headers[PackageStructure::FLAGS->value], true)) { - $this->headers[PackageStructure::FLAGS][] = $flag; + $this->headers[PackageStructure::FLAGS->value][] = $flag; } } @@ -201,7 +201,7 @@ throw new IOException('Cannot remove a flag after data has been written to the package'); } - $this->headers[PackageStructure::FLAGS] = array_diff($this->headers[PackageStructure::FLAGS], [$flag]); + $this->headers[PackageStructure::FLAGS->value] = array_diff($this->headers[PackageStructure::FLAGS->value], [$flag]); } /** @@ -213,22 +213,22 @@ */ public function add(string $name, string $data): array { - if(isset($this->headers[PackageStructure::DIRECTORY][$name])) + if(isset($this->headers[PackageStructure::DIRECTORY->value][$name])) { - return explode(':', $this->headers[PackageStructure::DIRECTORY][$name]); + return explode(':', $this->headers[PackageStructure::DIRECTORY->value][$name]); } - if(in_array(PackageFlags::COMPRESSION, $this->headers[PackageStructure::FLAGS], true)) + if(in_array(PackageFlags::COMPRESSION, $this->headers[PackageStructure::FLAGS->value], true)) { - if(in_array(PackageFlags::LOW_COMPRESSION, $this->headers[PackageStructure::FLAGS], true)) + if(in_array(PackageFlags::LOW_COMPRESSION, $this->headers[PackageStructure::FLAGS->value], true)) { $data = gzcompress($data, 1); } - else if(in_array(PackageFlags::MEDIUM_COMPRESSION, $this->headers[PackageStructure::FLAGS], true)) + else if(in_array(PackageFlags::MEDIUM_COMPRESSION, $this->headers[PackageStructure::FLAGS->value], true)) { $data = gzcompress($data, 6); } - else if(in_array(PackageFlags::HIGH_COMPRESSION, $this->headers[PackageStructure::FLAGS], true)) + else if(in_array(PackageFlags::HIGH_COMPRESSION, $this->headers[PackageStructure::FLAGS->value], true)) { $data = gzcompress($data, 9); } @@ -239,7 +239,7 @@ } $pointer = sprintf("%d:%d", ftell($this->temp_file), strlen($data)); - $this->headers[PackageStructure::DIRECTORY][$name] = $pointer; + $this->headers[PackageStructure::DIRECTORY->value][$name] = $pointer; $this->data_written = true; fwrite($this->temp_file, $data); @@ -256,12 +256,12 @@ */ public function addPointer(string $name, int $offset, int $length): void { - if(isset($this->headers[PackageStructure::DIRECTORY][$name])) + if(isset($this->headers[PackageStructure::DIRECTORY->value][$name])) { return; } - $this->headers[PackageStructure::DIRECTORY][$name] = sprintf("%d:%d", $offset, $length); + $this->headers[PackageStructure::DIRECTORY->value][$name] = sprintf("%d:%d", $offset, $length); } /** diff --git a/src/ncc/Enums/PackageStructure.php b/src/ncc/Enums/PackageStructure.php index 19519f1..831d707 100644 --- a/src/ncc/Enums/PackageStructure.php +++ b/src/ncc/Enums/PackageStructure.php @@ -22,11 +22,11 @@ namespace ncc\Enums; - final class PackageStructure + enum PackageStructure : int { - public const FILE_VERSION = 0x73746669; + case FILE_VERSION = 0x73746669; - public const FLAGS = 0x73736166; + case FLAGS = 0x73736166; - public const DIRECTORY = 0x6f746365; + case DIRECTORY = 0x6f746365; } \ No newline at end of file From 9885d98b5516bff0ebd4daefb40d3b9b9233b0ba Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 00:20:10 -0400 Subject: [PATCH 011/134] Removed PackageStandardVersions.php --- src/ncc/Enums/PackageStandardVersions.php | 28 ----------------------- 1 file changed, 28 deletions(-) delete mode 100644 src/ncc/Enums/PackageStandardVersions.php diff --git a/src/ncc/Enums/PackageStandardVersions.php b/src/ncc/Enums/PackageStandardVersions.php deleted file mode 100644 index 9af76b4..0000000 --- a/src/ncc/Enums/PackageStandardVersions.php +++ /dev/null @@ -1,28 +0,0 @@ - Date: Sat, 14 Sep 2024 00:20:28 -0400 Subject: [PATCH 012/134] Removed ConstantReferences.php --- src/ncc/Enums/ConstantReferences.php | 36 ---------------------------- 1 file changed, 36 deletions(-) delete mode 100644 src/ncc/Enums/ConstantReferences.php diff --git a/src/ncc/Enums/ConstantReferences.php b/src/ncc/Enums/ConstantReferences.php deleted file mode 100644 index bf33600..0000000 --- a/src/ncc/Enums/ConstantReferences.php +++ /dev/null @@ -1,36 +0,0 @@ - Date: Sat, 14 Sep 2024 00:20:46 -0400 Subject: [PATCH 013/134] Removed HttpStatusCodes.php --- src/ncc/Enums/HttpStatusCodes.php | 124 ------------------------------ 1 file changed, 124 deletions(-) delete mode 100644 src/ncc/Enums/HttpStatusCodes.php diff --git a/src/ncc/Enums/HttpStatusCodes.php b/src/ncc/Enums/HttpStatusCodes.php deleted file mode 100644 index 2580ea8..0000000 --- a/src/ncc/Enums/HttpStatusCodes.php +++ /dev/null @@ -1,124 +0,0 @@ - Date: Sat, 14 Sep 2024 00:20:59 -0400 Subject: [PATCH 014/134] Removed CompilerExtensionDefaultVersions.php --- .../CompilerExtensionDefaultVersions.php | 33 ------------------- 1 file changed, 33 deletions(-) delete mode 100644 src/ncc/Enums/CompilerExtensionDefaultVersions.php diff --git a/src/ncc/Enums/CompilerExtensionDefaultVersions.php b/src/ncc/Enums/CompilerExtensionDefaultVersions.php deleted file mode 100644 index 98e2a9e..0000000 --- a/src/ncc/Enums/CompilerExtensionDefaultVersions.php +++ /dev/null @@ -1,33 +0,0 @@ - Date: Sat, 14 Sep 2024 00:24:49 -0400 Subject: [PATCH 015/134] Convert PackageDirectory constants to enum cases --- src/ncc/Classes/PackageReader.php | 26 +++++++++++++------------- src/ncc/Classes/PackageWriter.php | 24 ++++++++++++------------ src/ncc/Classes/Runtime.php | 4 ++-- src/ncc/Enums/PackageDirectory.php | 18 +++++++++--------- src/ncc/Utilities/Resolver.php | 17 +++++++++-------- 5 files changed, 45 insertions(+), 44 deletions(-) diff --git a/src/ncc/Classes/PackageReader.php b/src/ncc/Classes/PackageReader.php index 26ef095..e61b5a8 100644 --- a/src/ncc/Classes/PackageReader.php +++ b/src/ncc/Classes/PackageReader.php @@ -320,7 +320,7 @@ */ public function getAssembly(): Assembly { - $directory = sprintf('@%s', PackageDirectory::ASSEMBLY); + $directory = sprintf('@%s', PackageDirectory::ASSEMBLY->value); if(isset($this->cache[$directory])) { @@ -346,7 +346,7 @@ */ public function getMetadata(): Metadata { - $directory = sprintf('@%s', PackageDirectory::METADATA); + $directory = sprintf('@%s', PackageDirectory::METADATA->value); if(isset($this->cache[$directory])) { @@ -375,7 +375,7 @@ */ public function getInstaller(): ?Installer { - $directory = sprintf('@%s', PackageDirectory::INSTALLER); + $directory = sprintf('@%s', PackageDirectory::INSTALLER->value); if(isset($this->cache[$directory])) { @@ -400,7 +400,7 @@ public function getDependencies(): array { $dependencies = []; - $directory = sprintf('@%s:', PackageDirectory::DEPENDENCIES); + $directory = sprintf('@%s:', PackageDirectory::DEPENDENCIES->value); foreach($this->headers[PackageStructure::DIRECTORY->value] as $name => $location) { @@ -422,7 +422,7 @@ */ public function getDependency(string $name): Dependency { - $dependency_name = sprintf('@%s:%s', PackageDirectory::DEPENDENCIES, $name); + $dependency_name = sprintf('@%s:%s', PackageDirectory::DEPENDENCIES->value, $name); if(!isset($this->headers[PackageStructure::DIRECTORY->value[$dependency_name]])) { throw new ConfigurationException(sprintf('Dependency \'%s\' not found in package', $name)); @@ -452,7 +452,7 @@ public function getExecutionUnits(): array { $execution_units = []; - $directory = sprintf('@%s:', PackageDirectory::EXECUTION_UNITS); + $directory = sprintf('@%s:', PackageDirectory::EXECUTION_UNITS->value); foreach($this->headers[PackageStructure::DIRECTORY->value] as $name => $location) { @@ -474,7 +474,7 @@ */ public function getExecutionUnit(string $name): ExecutionUnit { - $execution_unit_name = sprintf('@%s:%s', PackageDirectory::EXECUTION_UNITS, $name); + $execution_unit_name = sprintf('@%s:%s', PackageDirectory::EXECUTION_UNITS->value, $name); if(!isset($this->headers[PackageStructure::DIRECTORY->value[$execution_unit_name]])) { throw new ConfigurationException(sprintf('Execution unit \'%s\' not found in package', $name)); @@ -504,7 +504,7 @@ public function getComponents(): array { $components = []; - $directory = sprintf('@%s:', PackageDirectory::COMPONENTS); + $directory = sprintf('@%s:', PackageDirectory::COMPONENTS->value); foreach($this->headers[PackageStructure::DIRECTORY->value] as $name => $location) { @@ -525,7 +525,7 @@ public function getClassMap(): array { $class_map = []; - $directory = sprintf('@%s:', PackageDirectory::CLASS_POINTER); + $directory = sprintf('@%s:', PackageDirectory::CLASS_POINTER->value); foreach($this->headers[PackageStructure::DIRECTORY->value] as $name => $location) { @@ -547,7 +547,7 @@ */ public function getComponent(string $name): Component { - $component_name = sprintf('@%s:%s', PackageDirectory::COMPONENTS, $name); + $component_name = sprintf('@%s:%s', PackageDirectory::COMPONENTS->value, $name); if(!isset($this->headers[PackageStructure::DIRECTORY->value][$component_name])) { throw new ConfigurationException(sprintf('Component \'%s\' not found in package', $name)); @@ -578,7 +578,7 @@ */ public function getComponentByClass(string $class): Component { - $class_name = sprintf('@%s:%s', PackageDirectory::CLASS_POINTER, $class); + $class_name = sprintf('@%s:%s', PackageDirectory::CLASS_POINTER->value, $class); if(!isset($this->headers[PackageStructure::DIRECTORY->value[$class_name]])) { throw new ConfigurationException(sprintf('Class map \'%s\' not found in package', $class)); @@ -595,7 +595,7 @@ public function getResources(): array { $resources = []; - $directory = sprintf('@%s:', PackageDirectory::RESOURCES); + $directory = sprintf('@%s:', PackageDirectory::RESOURCES->value); foreach($this->headers[PackageStructure::DIRECTORY->value] as $name => $location) { @@ -617,7 +617,7 @@ */ public function getResource(string $name): Resource { - $resource_name = sprintf('@%s:%s', PackageDirectory::RESOURCES, $name); + $resource_name = sprintf('@%s:%s', PackageDirectory::RESOURCES->value, $name); if(!isset($this->headers[PackageStructure::DIRECTORY->value[$resource_name]])) { throw new ConfigurationException(sprintf('Resource \'%s\' not found in package', $name)); diff --git a/src/ncc/Classes/PackageWriter.php b/src/ncc/Classes/PackageWriter.php index 440bd38..3e53fb9 100644 --- a/src/ncc/Classes/PackageWriter.php +++ b/src/ncc/Classes/PackageWriter.php @@ -272,7 +272,7 @@ */ public function setAssembly(Assembly $assembly): array { - return $this->add(sprintf('@%s', PackageDirectory::ASSEMBLY), ZiProto::encode($assembly->toArray(true))); + return $this->add(sprintf('@%s', PackageDirectory::ASSEMBLY->value), ZiProto::encode($assembly->toArray(true))); } /** @@ -283,7 +283,7 @@ */ public function setMetadata(Metadata $metadata): array { - return $this->add(sprintf('@%s', PackageDirectory::METADATA), ZiProto::encode($metadata->toArray(true))); + return $this->add(sprintf('@%s', PackageDirectory::METADATA->value), ZiProto::encode($metadata->toArray(true))); } /** @@ -294,7 +294,7 @@ */ public function setInstaller(Installer $installer): array { - return $this->add(sprintf('@%s', PackageDirectory::INSTALLER), ZiProto::encode($installer->toArray(true))); + return $this->add(sprintf('@%s', PackageDirectory::INSTALLER->value), ZiProto::encode($installer->toArray(true))); } /** @@ -305,7 +305,7 @@ */ public function addDependencyConfiguration(Dependency $dependency): array { - return $this->add(sprintf('@%s:%s', PackageDirectory::DEPENDENCIES, $dependency->getName()), ZiProto::encode($dependency->toArray(true))); + return $this->add(sprintf('@%s:%s', PackageDirectory::DEPENDENCIES->value, $dependency->getName()), ZiProto::encode($dependency->toArray(true))); } /** @@ -316,7 +316,7 @@ */ public function addExecutionUnit(ExecutionUnit $unit): array { - return $this->add(sprintf('@%s:%s', PackageDirectory::EXECUTION_UNITS, $unit->getExecutionPolicy()->getName()), ZiProto::encode($unit->toArray(true))); + return $this->add(sprintf('@%s:%s', PackageDirectory::EXECUTION_UNITS->value, $unit->getExecutionPolicy()->getName()), ZiProto::encode($unit->toArray(true))); } /** @@ -327,7 +327,7 @@ */ public function addComponent(Component $component): array { - return $this->add(sprintf('@%s:%s', PackageDirectory::COMPONENTS, $component->getName()), ZiProto::encode($component->toArray(true))); + return $this->add(sprintf('@%s:%s', PackageDirectory::COMPONENTS->value, $component->getName()), ZiProto::encode($component->toArray(true))); } /** @@ -338,7 +338,7 @@ */ public function addResource(Resource $resource): array { - return $this->add(sprintf('@%s:%s', PackageDirectory::RESOURCES, $resource->getName()), ZiProto::encode($resource->toArray(true))); + return $this->add(sprintf('@%s:%s', PackageDirectory::RESOURCES->value, $resource->getName()), ZiProto::encode($resource->toArray(true))); } /** @@ -351,7 +351,7 @@ */ public function mapClass(string $class, int $offset, int $length): void { - $this->addPointer(sprintf('@%s:%s', PackageDirectory::CLASS_POINTER, $class), $offset, $length); + $this->addPointer(sprintf('@%s:%s', PackageDirectory::CLASS_POINTER->value, $class), $offset, $length); } /** @@ -372,10 +372,10 @@ switch((int)substr(explode(':', $name, 2)[0], 1)) { - case PackageDirectory::METADATA: - case PackageDirectory::ASSEMBLY: - case PackageDirectory::INSTALLER: - case PackageDirectory::EXECUTION_UNITS: + case PackageDirectory::METADATA->value: + case PackageDirectory::ASSEMBLY->value: + case PackageDirectory::INSTALLER->value: + case PackageDirectory::EXECUTION_UNITS->value: Console::outDebug(sprintf('Skipping %s', $name)); break; diff --git a/src/ncc/Classes/Runtime.php b/src/ncc/Classes/Runtime.php index ef2e9a5..f112f6a 100644 --- a/src/ncc/Classes/Runtime.php +++ b/src/ncc/Classes/Runtime.php @@ -480,8 +480,8 @@ return match (Resolver::componentType($acquired_file)) { - PackageDirectory::RESOURCES => self::$imported_packages[$package]->getResource(Resolver::componentName($acquired_file))->getData(), - PackageDirectory::COMPONENTS => self::$imported_packages[$package]->getComponent(Resolver::componentName($acquired_file))->getData([ComponentDecodeOptions::AS_FILE]), + PackageDirectory::RESOURCES->value => self::$imported_packages[$package]->getResource(Resolver::componentName($acquired_file))->getData(), + PackageDirectory::COMPONENTS->value => self::$imported_packages[$package]->getComponent(Resolver::componentName($acquired_file))->getData([ComponentDecodeOptions::AS_FILE]), default => throw new IOException(sprintf('Unable to acquire file "%s" from package "%s" because it is not a resource or component', $path, $package)), }; } diff --git a/src/ncc/Enums/PackageDirectory.php b/src/ncc/Enums/PackageDirectory.php index 42c2a02..8e76947 100644 --- a/src/ncc/Enums/PackageDirectory.php +++ b/src/ncc/Enums/PackageDirectory.php @@ -22,21 +22,21 @@ namespace ncc\Enums; - final class PackageDirectory + enum PackageDirectory : int { - public const ASSEMBLY = 0x61737365; + case ASSEMBLY = 0x61737365; - public const METADATA = 0x6D657461; + case METADATA = 0x6D657461; - public const INSTALLER = 0x696E7374; + case INSTALLER = 0x696E7374; - public const DEPENDENCIES = 0x64657065; + case DEPENDENCIES = 0x64657065; - public const EXECUTION_UNITS = 0x65786563; + case EXECUTION_UNITS = 0x65786563; - public const COMPONENTS = 0x636F6D70; + case COMPONENTS = 0x636F6D70; - public const RESOURCES = 0x7265736F; + case RESOURCES = 0x7265736F; - public const CLASS_POINTER = 0x636C6173; + case CLASS_POINTER = 0x636C6173; } \ No newline at end of file diff --git a/src/ncc/Utilities/Resolver.php b/src/ncc/Utilities/Resolver.php index 2c63853..ddca134 100644 --- a/src/ncc/Utilities/Resolver.php +++ b/src/ncc/Utilities/Resolver.php @@ -284,16 +284,17 @@ throw new InvalidArgumentException(sprintf('Invalid component prefix "%s"', $file_stub_code)); } + // TODO: What the hell is this? return match ((int)$file_stub_code) { - PackageDirectory::METADATA => PackageDirectory::METADATA, - PackageDirectory::ASSEMBLY => PackageDirectory::ASSEMBLY, - PackageDirectory::EXECUTION_UNITS => PackageDirectory::EXECUTION_UNITS, - PackageDirectory::INSTALLER => PackageDirectory::INSTALLER, - PackageDirectory::DEPENDENCIES => PackageDirectory::DEPENDENCIES, - PackageDirectory::CLASS_POINTER => PackageDirectory::CLASS_POINTER, - PackageDirectory::RESOURCES => PackageDirectory::RESOURCES, - PackageDirectory::COMPONENTS => PackageDirectory::COMPONENTS, + PackageDirectory::METADATA->value => PackageDirectory::METADATA->value, + PackageDirectory::ASSEMBLY->value => PackageDirectory::ASSEMBLY->value, + PackageDirectory::EXECUTION_UNITS->value => PackageDirectory::EXECUTION_UNITS->value, + PackageDirectory::INSTALLER->value => PackageDirectory::INSTALLER->value, + PackageDirectory::DEPENDENCIES->value => PackageDirectory::DEPENDENCIES->value, + PackageDirectory::CLASS_POINTER->value => PackageDirectory::CLASS_POINTER->value, + PackageDirectory::RESOURCES->value => PackageDirectory::RESOURCES->value, + PackageDirectory::COMPONENTS->value => PackageDirectory::COMPONENTS->value, default => throw new InvalidArgumentException(sprintf('Invalid component type "%s"', $component_path)), }; } From 5dd98083d65a5b437881f30fbf013eeaf43be4e5 Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 00:30:05 -0400 Subject: [PATCH 016/134] Convert LogLevel constants to enum cases --- src/ncc/CLI/Main.php | 22 +++++----- src/ncc/Classes/NccExtension/NccCompiler.php | 2 +- .../PhpExtension/ExecutableCompiler.php | 4 +- src/ncc/Enums/LogLevel.php | 26 ++++-------- src/ncc/Managers/PackageManager.php | 8 ++-- src/ncc/Utilities/Console.php | 40 +++++++++---------- src/ncc/Utilities/Resolver.php | 13 +++--- src/ncc/Utilities/Validate.php | 3 +- 8 files changed, 55 insertions(+), 63 deletions(-) diff --git a/src/ncc/CLI/Main.php b/src/ncc/CLI/Main.php index 7db755e..2ac2899 100644 --- a/src/ncc/CLI/Main.php +++ b/src/ncc/CLI/Main.php @@ -93,28 +93,28 @@ { switch(strtolower(self::$args['l'] ?? self::$args['log-level'])) { - case LogLevel::SILENT: - case LogLevel::FATAL: - case LogLevel::ERROR: - case LogLevel::WARNING: - case LogLevel::INFO: - case LogLevel::DEBUG: - case LogLevel::VERBOSE: + case LogLevel::SILENT->value: + case LogLevel::FATAL->value: + case LogLevel::ERROR->value: + case LogLevel::WARNING->value: + case LogLevel::INFO->value: + case LogLevel::DEBUG->value: + case LogLevel::VERBOSE->value: self::$log_level = strtolower(self::$args['l'] ?? self::$args['log-level']); break; default: Console::outWarning('Unknown log level: ' . (self::$args['l'] ?? self::$args['log-level']) . ', using \'info\''); - self::$log_level = LogLevel::INFO; + self::$log_level = LogLevel::INFO->value; break; } } else { - self::$log_level = LogLevel::INFO; + self::$log_level = LogLevel::INFO->value; } - if(Resolver::checkLogLevel(self::$log_level, LogLevel::DEBUG)) + if(Resolver::checkLogLevel(self::$log_level, LogLevel::DEBUG->value)) { Console::outDebug('Debug logging enabled'); @@ -236,7 +236,7 @@ { if(self::$log_level === null) { - self::$log_level = LogLevel::INFO; + self::$log_level = LogLevel::INFO->value; } return self::$log_level; diff --git a/src/ncc/Classes/NccExtension/NccCompiler.php b/src/ncc/Classes/NccExtension/NccCompiler.php index ab9f115..aeb0e31 100644 --- a/src/ncc/Classes/NccExtension/NccCompiler.php +++ b/src/ncc/Classes/NccExtension/NccCompiler.php @@ -122,7 +122,7 @@ } // Debugging information - if(Resolver::checkLogLevel(LogLevel::DEBUG, Main::getLogLevel())) + if(Resolver::checkLogLevel(LogLevel::DEBUG->value, Main::getLogLevel())) { foreach($this->project_manager->getProjectConfiguration()->getAssembly()->toArray() as $prop => $value) { diff --git a/src/ncc/Classes/PhpExtension/ExecutableCompiler.php b/src/ncc/Classes/PhpExtension/ExecutableCompiler.php index b115d8c..3b788dc 100644 --- a/src/ncc/Classes/PhpExtension/ExecutableCompiler.php +++ b/src/ncc/Classes/PhpExtension/ExecutableCompiler.php @@ -112,11 +112,11 @@ switch(Main::getLogLevel()) { - case LogLevel::VERBOSE: + case LogLevel::VERBOSE->value: $gcc_options[] = '-v'; break; - case LogLevel::DEBUG: + case LogLevel::DEBUG->value: $gcc_options[] = '-v'; $gcc_options[] = '-v'; break; diff --git a/src/ncc/Enums/LogLevel.php b/src/ncc/Enums/LogLevel.php index f44fa49..45637e0 100644 --- a/src/ncc/Enums/LogLevel.php +++ b/src/ncc/Enums/LogLevel.php @@ -22,29 +22,19 @@ namespace ncc\Enums; - final class LogLevel + enum LogLevel : string { - public const SILENT = 'silent'; + case SILENT = 'silent'; - public const VERBOSE = 'verbose'; + case VERBOSE = 'verbose'; - public const DEBUG = 'debug'; + case DEBUG = 'debug'; - public const INFO = 'info'; + case INFO = 'info'; - public const WARNING = 'warn'; + case WARNING = 'warn'; - public const ERROR = 'error'; + case ERROR = 'error'; - public const FATAL = 'fatal'; - - public const ALL = [ - self::SILENT, - self::VERBOSE, - self::DEBUG, - self::INFO, - self::WARNING, - self::ERROR, - self::FATAL, - ]; + case FATAL = 'fatal'; } \ No newline at end of file diff --git a/src/ncc/Managers/PackageManager.php b/src/ncc/Managers/PackageManager.php index f499bcd..a1fd5e7 100644 --- a/src/ncc/Managers/PackageManager.php +++ b/src/ncc/Managers/PackageManager.php @@ -665,7 +665,7 @@ { $progress_bar->setMiscText($component_name); - if(Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) + if(Resolver::checkLogLevel(LogLevel::VERBOSE->value, Main::getLogLevel())) { Console::outVerbose(sprintf('Extracting component %s to %s', $component_name, $bin_path . DIRECTORY_SEPARATOR . $component_name)); } @@ -683,7 +683,7 @@ { $progress_bar->setMiscText($resource_name); - if(Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) + if(Resolver::checkLogLevel(LogLevel::VERBOSE->value, Main::getLogLevel())) { Console::outVerbose(sprintf('Extracting resource %s to %s', $resource_name, $bin_path . DIRECTORY_SEPARATOR . $resource_name)); } @@ -701,7 +701,7 @@ { $progress_bar->setMiscText($unit); - if(Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) + if(Resolver::checkLogLevel(LogLevel::VERBOSE->value, Main::getLogLevel())) { Console::outVerbose(sprintf('Extracting execution unit %s to %s', $unit, $package_path . DIRECTORY_SEPARATOR . 'units' . DIRECTORY_SEPARATOR . $package_reader->getExecutionUnit($unit)->getExecutionPolicy()->getName() . '.unit')); } @@ -906,7 +906,7 @@ return; } - if(Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) + if(Resolver::checkLogLevel(LogLevel::VERBOSE->value, Main::getLogLevel())) { $percentage = round(($downloaded / $download_size) * 100, 2); Console::out(sprintf('Download progress %s (%s/%s) for %s', $percentage, $downloaded, $download_size, $url)); diff --git a/src/ncc/Utilities/Console.php b/src/ncc/Utilities/Console.php index 4dd7550..082d0eb 100644 --- a/src/ncc/Utilities/Console.php +++ b/src/ncc/Utilities/Console.php @@ -53,12 +53,12 @@ private static function setPrefix(string $log_level, string $input): string { $input = match ($log_level) { - LogLevel::VERBOSE => self::formatColor('VRB:', ConsoleColors::LIGHT_CYAN) . " $input", - LogLevel::DEBUG => self::formatColor('DBG:', ConsoleColors::LIGHT_MAGENTA) . " $input", - LogLevel::INFO => self::formatColor('INF:', ConsoleColors::WHITE) . " $input", - LogLevel::WARNING => self::formatColor('WRN:', ConsoleColors::YELLOW) . " $input", - LogLevel::ERROR => self::formatColor('ERR:', ConsoleColors::LIGHT_RED) . " $input", - LogLevel::FATAL => self::formatColor('FTL:', ConsoleColors::LIGHT_RED) . " $input", + LogLevel::VERBOSE->value => self::formatColor('VRB:', ConsoleColors::LIGHT_CYAN) . " $input", + LogLevel::DEBUG->value => self::formatColor('DBG:', ConsoleColors::LIGHT_MAGENTA) . " $input", + LogLevel::INFO->value => self::formatColor('INF:', ConsoleColors::WHITE) . " $input", + LogLevel::WARNING->value => self::formatColor('WRN:', ConsoleColors::YELLOW) . " $input", + LogLevel::ERROR->value => self::formatColor('ERR:', ConsoleColors::LIGHT_RED) . " $input", + LogLevel::FATAL->value => self::formatColor('FTL:', ConsoleColors::LIGHT_RED) . " $input", default => self::formatColor('MSG:', ConsoleColors::DEFAULT) . " $input", }; @@ -109,14 +109,14 @@ return; } - if(!Resolver::checkLogLevel(LogLevel::INFO, Main::getLogLevel())) + if(!Resolver::checkLogLevel(LogLevel::INFO->value, Main::getLogLevel())) { return; } - if(!$no_prefix && Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) + if(!$no_prefix && Resolver::checkLogLevel(LogLevel::VERBOSE->value, Main::getLogLevel())) { - $message = self::setPrefix(LogLevel::INFO, $message); + $message = self::setPrefix(LogLevel::INFO->value, $message); } if($newline) @@ -142,7 +142,7 @@ return; } - if(!Resolver::checkLogLevel(LogLevel::DEBUG, Main::getLogLevel())) + if(!Resolver::checkLogLevel(LogLevel::DEBUG->value, Main::getLogLevel())) { return; } @@ -161,7 +161,7 @@ $trace_msg .= ' > '; } - $message = self::setPrefix(LogLevel::DEBUG, $trace_msg . $message); + $message = self::setPrefix(LogLevel::DEBUG->value, $trace_msg . $message); self::out($message, $newline, true); } @@ -179,12 +179,12 @@ return; } - if(!Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) + if(!Resolver::checkLogLevel(LogLevel::VERBOSE->value, Main::getLogLevel())) { return; } - self::out(self::setPrefix(LogLevel::VERBOSE, $message), $newline, true); + self::out(self::setPrefix(LogLevel::VERBOSE->value, $message), $newline, true); } @@ -225,14 +225,14 @@ return; } - if(!Resolver::checkLogLevel(LogLevel::WARNING, Main::getLogLevel())) + if(!Resolver::checkLogLevel(LogLevel::WARNING->value, Main::getLogLevel())) { return; } - if(Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) + if(Resolver::checkLogLevel(LogLevel::VERBOSE->value, Main::getLogLevel())) { - self::out(self::setPrefix(LogLevel::WARNING, $message), $newline, true); + self::out(self::setPrefix(LogLevel::WARNING->value, $message), $newline, true); return; } @@ -254,14 +254,14 @@ return; } - if(!Resolver::checkLogLevel(LogLevel::ERROR, Main::getLogLevel())) + if(!Resolver::checkLogLevel(LogLevel::ERROR->value, Main::getLogLevel())) { return; } - if(Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) + if(Resolver::checkLogLevel(LogLevel::VERBOSE->value, Main::getLogLevel())) { - self::out(self::setPrefix(LogLevel::ERROR, $message), $newline, true); + self::out(self::setPrefix(LogLevel::ERROR->value, $message), $newline, true); } else { @@ -289,7 +289,7 @@ return; } - if($message !== '' && Resolver::checkLogLevel(LogLevel::ERROR, Main::getLogLevel())) + if($message !== '' && Resolver::checkLogLevel(LogLevel::ERROR->value, Main::getLogLevel())) { self::out(PHP_EOL . self::formatColor('Error: ', ConsoleColors::RED) . $message); } diff --git a/src/ncc/Utilities/Resolver.php b/src/ncc/Utilities/Resolver.php index ddca134..410ac68 100644 --- a/src/ncc/Utilities/Resolver.php +++ b/src/ncc/Utilities/Resolver.php @@ -188,12 +188,13 @@ return match ($current_level) { - LogLevel::DEBUG => in_array($input, [LogLevel::DEBUG, LogLevel::VERBOSE, LogLevel::INFO, LogLevel::WARNING, LogLevel::FATAL, LogLevel::ERROR], true), - LogLevel::VERBOSE => in_array($input, [LogLevel::VERBOSE, LogLevel::INFO, LogLevel::WARNING, LogLevel::FATAL, LogLevel::ERROR], true), - LogLevel::INFO => in_array($input, [LogLevel::INFO, LogLevel::WARNING, LogLevel::FATAL, LogLevel::ERROR], true), - LogLevel::WARNING => in_array($input, [LogLevel::WARNING, LogLevel::FATAL, LogLevel::ERROR], true), - LogLevel::ERROR => in_array($input, [LogLevel::FATAL, LogLevel::ERROR], true), - LogLevel::FATAL => $input === LogLevel::FATAL, + // TODO: Move this to the enum + LogLevel::DEBUG->value => in_array($input, [LogLevel::DEBUG->value, LogLevel::VERBOSE->value, LogLevel::INFO->value, LogLevel::WARNING->value, LogLevel::FATAL->value, LogLevel::ERROR->value], true), + LogLevel::VERBOSE->value => in_array($input, [LogLevel::VERBOSE->value, LogLevel::INFO->value, LogLevel::WARNING->value, LogLevel::FATAL->value, LogLevel::ERROR->value], true), + LogLevel::INFO->value => in_array($input, [LogLevel::INFO->value, LogLevel::WARNING->value, LogLevel::FATAL->value, LogLevel::ERROR->value], true), + LogLevel::WARNING->value => in_array($input, [LogLevel::WARNING->value, LogLevel::FATAL->value, LogLevel::ERROR->value], true), + LogLevel::ERROR->value => in_array($input, [LogLevel::FATAL->value, LogLevel::ERROR->value], true), + LogLevel::FATAL->value => $input === LogLevel::FATAL->value, default => false, }; } diff --git a/src/ncc/Utilities/Validate.php b/src/ncc/Utilities/Validate.php index df31364..c89c5ed 100644 --- a/src/ncc/Utilities/Validate.php +++ b/src/ncc/Utilities/Validate.php @@ -228,7 +228,8 @@ namespace ncc\Utilities; */ public static function checkLogLevel(string $input): bool { - if(!in_array(strtolower($input), LogLevel::ALL)) + // TODO: Fix this, it's not the proper use of cases() + if(!in_array(strtolower($input), LogLevel::cases())) { return false; } From 718c6ff8d859a8966c6b698535bd71c9b93b509f Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 00:31:43 -0400 Subject: [PATCH 017/134] Convert FileDescriptor constants to enum cases --- src/ncc/Classes/Runtime.php | 2 +- src/ncc/Enums/FileDescriptor.php | 14 +++++++------- src/ncc/Managers/PackageManager.php | 12 ++++++------ src/ncc/Objects/PackageLock/PackageEntry.php | 8 ++++---- src/ncc/Objects/PackageLock/VersionEntry.php | 8 ++++---- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/ncc/Classes/Runtime.php b/src/ncc/Classes/Runtime.php index f112f6a..2460c83 100644 --- a/src/ncc/Classes/Runtime.php +++ b/src/ncc/Classes/Runtime.php @@ -99,7 +99,7 @@ if(is_string(self::$imported_packages[$package])) { - $metadata_path = self::$imported_packages[$package] . DIRECTORY_SEPARATOR . FileDescriptor::METADATA; + $metadata_path = self::$imported_packages[$package] . DIRECTORY_SEPARATOR . FileDescriptor::METADATA->value; if(!is_file($metadata_path)) { diff --git a/src/ncc/Enums/FileDescriptor.php b/src/ncc/Enums/FileDescriptor.php index 325c76d..1a50df3 100644 --- a/src/ncc/Enums/FileDescriptor.php +++ b/src/ncc/Enums/FileDescriptor.php @@ -22,17 +22,17 @@ namespace ncc\Enums; - final class FileDescriptor + enum FileDescriptor : string { - public const ASSEMBLY = 'ASSEMBLY'; + case ASSEMBLY = 'ASSEMBLY'; - public const METADATA = 'METADATA'; + case METADATA = 'METADATA'; - public const INSTALLER = 'INSTALLER'; + case INSTALLER = 'INSTALLER'; - public const CLASS_MAP = 'CLASS_MAP'; + case CLASS_MAP = 'CLASS_MAP'; - public const UPDATE = 'UPDATE'; + case UPDATE = 'UPDATE'; - public const SHADOW_PACKAGE = 'SHADOW_PKG'; + case SHADOW_PACKAGE = 'SHADOW_PKG'; } \ No newline at end of file diff --git a/src/ncc/Managers/PackageManager.php b/src/ncc/Managers/PackageManager.php index a1fd5e7..db489f6 100644 --- a/src/ncc/Managers/PackageManager.php +++ b/src/ncc/Managers/PackageManager.php @@ -726,7 +726,7 @@ if($package_reader->getInstaller() !== null) { $progress_bar->setMiscText('installer'); - IO::fwrite($package_path . DIRECTORY_SEPARATOR . FileDescriptor::INSTALLER, ZiProto::encode($package_reader->getInstaller()?->toArray(true))); + IO::fwrite($package_path . DIRECTORY_SEPARATOR . FileDescriptor::INSTALLER->value, ZiProto::encode($package_reader->getInstaller()?->toArray(true))); } //Console::inlineProgressBar(++$current_step, $total_steps); $progress_bar->increaseValue(1, true); @@ -734,23 +734,23 @@ if(count($class_map) > 0) { $progress_bar->setMiscText('class map'); - IO::fwrite($package_path . DIRECTORY_SEPARATOR . FileDescriptor::CLASS_MAP, ZiProto::encode($class_map)); + IO::fwrite($package_path . DIRECTORY_SEPARATOR . FileDescriptor::CLASS_MAP->value, ZiProto::encode($class_map)); } //Console::inlineProgressBar(++$current_step, $total_steps); $progress_bar->increaseValue(1, true); - IO::fwrite($package_path . DIRECTORY_SEPARATOR . FileDescriptor::ASSEMBLY, ZiProto::encode($package_reader->getAssembly()->toArray(true))); - IO::fwrite($package_path . DIRECTORY_SEPARATOR . FileDescriptor::METADATA, ZiProto::encode($package_reader->getMetadata()->toArray(true))); + IO::fwrite($package_path . DIRECTORY_SEPARATOR . FileDescriptor::ASSEMBLY->value, ZiProto::encode($package_reader->getAssembly()->toArray(true))); + IO::fwrite($package_path . DIRECTORY_SEPARATOR . FileDescriptor::METADATA->value, ZiProto::encode($package_reader->getMetadata()->toArray(true))); if($package_reader->getMetadata()->getUpdateSource() !== null) { - IO::fwrite($package_path . DIRECTORY_SEPARATOR . FileDescriptor::UPDATE, ZiProto::encode($package_reader->getMetadata()->getUpdateSource()?->toArray(true))); + IO::fwrite($package_path . DIRECTORY_SEPARATOR . FileDescriptor::UPDATE->value, ZiProto::encode($package_reader->getMetadata()->getUpdateSource()?->toArray(true))); } //Console::inlineProgressBar(++$current_step, $total_steps); $progress_bar->increaseValue(1, true); $progress_bar->setMiscText('creating shadowcopy', true); - $package_reader->saveCopy($package_path . DIRECTORY_SEPARATOR . FileDescriptor::SHADOW_PACKAGE); + $package_reader->saveCopy($package_path . DIRECTORY_SEPARATOR . FileDescriptor::SHADOW_PACKAGE->value); //Console::inlineProgressBar(++$current_step, $total_steps); $progress_bar->setMiscText('done', true); diff --git a/src/ncc/Objects/PackageLock/PackageEntry.php b/src/ncc/Objects/PackageLock/PackageEntry.php index 4335824..d0a3e85 100644 --- a/src/ncc/Objects/PackageLock/PackageEntry.php +++ b/src/ncc/Objects/PackageLock/PackageEntry.php @@ -356,7 +356,7 @@ */ public function getAssembly(string $version=Versions::LATEST->value): Assembly { - $assembly_path = $this->getPath($version) . DIRECTORY_SEPARATOR . FileDescriptor::ASSEMBLY; + $assembly_path = $this->getPath($version) . DIRECTORY_SEPARATOR . FileDescriptor::ASSEMBLY->value; if(!is_file($assembly_path)) { throw new IOException(sprintf('Assembly file for package %s version %s does not exist (Expected %s)', $this->name, $version, $assembly_path)); @@ -377,7 +377,7 @@ */ public function getMetadata(string $version=Versions::LATEST->value): Metadata { - $metadata_path = $this->getPath($version) . DIRECTORY_SEPARATOR . FileDescriptor::METADATA; + $metadata_path = $this->getPath($version) . DIRECTORY_SEPARATOR . FileDescriptor::METADATA->value; if(!is_file($metadata_path)) { throw new IOException(sprintf('Metadata file for package %s version %s does not exist (Expected %s)', $this->name, $version, $metadata_path)); @@ -396,7 +396,7 @@ */ public function getInstaller(string $version=Versions::LATEST->value): ?Installer { - $installer_path = $this->getPath($version) . DIRECTORY_SEPARATOR . FileDescriptor::INSTALLER; + $installer_path = $this->getPath($version) . DIRECTORY_SEPARATOR . FileDescriptor::INSTALLER->value; if(!is_file($installer_path)) { return null; @@ -415,7 +415,7 @@ */ public function getClassMap(string $version=Versions::LATEST->value): array { - $class_map_path = $this->getPath($version) . DIRECTORY_SEPARATOR . FileDescriptor::CLASS_MAP; + $class_map_path = $this->getPath($version) . DIRECTORY_SEPARATOR . FileDescriptor::CLASS_MAP->value; if(!is_file($class_map_path)) { return []; diff --git a/src/ncc/Objects/PackageLock/VersionEntry.php b/src/ncc/Objects/PackageLock/VersionEntry.php index d678dbb..191b311 100644 --- a/src/ncc/Objects/PackageLock/VersionEntry.php +++ b/src/ncc/Objects/PackageLock/VersionEntry.php @@ -231,7 +231,7 @@ */ public function getShadowPackagePath(string $package_name): string { - return $this->getPath($package_name) . DIRECTORY_SEPARATOR . FileDescriptor::SHADOW_PACKAGE; + return $this->getPath($package_name) . DIRECTORY_SEPARATOR . FileDescriptor::SHADOW_PACKAGE->value; } /** @@ -241,17 +241,17 @@ */ public function isBroken(string $package_name): bool { - if(!is_file($this->getPath($package_name) . DIRECTORY_SEPARATOR . FileDescriptor::SHADOW_PACKAGE)) + if(!is_file($this->getPath($package_name) . DIRECTORY_SEPARATOR . FileDescriptor::SHADOW_PACKAGE->value)) { return true; } - if(!is_file($this->getPath($package_name) . DIRECTORY_SEPARATOR . FileDescriptor::ASSEMBLY)) + if(!is_file($this->getPath($package_name) . DIRECTORY_SEPARATOR . FileDescriptor::ASSEMBLY->value)) { return true; } - if(!is_file($this->getPath($package_name) . DIRECTORY_SEPARATOR . FileDescriptor::METADATA)) + if(!is_file($this->getPath($package_name) . DIRECTORY_SEPARATOR . FileDescriptor::METADATA->value)) { return true; } From e1013f6c15c6f7d910d28a836c0aa9453f09a4cf Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 00:34:12 -0400 Subject: [PATCH 018/134] Convert ExceptionCodes constants to enum cases --- src/ncc/Enums/ExceptionCodes.php | 52 ++++++------------- src/ncc/Exceptions/ArchiveException.php | 2 +- .../Exceptions/AuthenticationException.php | 2 +- src/ncc/Exceptions/BuildException.php | 2 +- src/ncc/Exceptions/ComposerException.php | 2 +- src/ncc/Exceptions/ConfigurationException.php | 2 +- src/ncc/Exceptions/GitException.php | 2 +- src/ncc/Exceptions/IOException.php | 2 +- src/ncc/Exceptions/ImportException.php | 2 +- src/ncc/Exceptions/IntegrityException.php | 2 +- src/ncc/Exceptions/NetworkException.php | 2 +- src/ncc/Exceptions/NotSupportedException.php | 2 +- src/ncc/Exceptions/OperationException.php | 2 +- src/ncc/Exceptions/PackageException.php | 2 +- src/ncc/Exceptions/PathNotFoundException.php | 2 +- src/ncc/Exceptions/RuntimeException.php | 2 +- 16 files changed, 32 insertions(+), 50 deletions(-) diff --git a/src/ncc/Enums/ExceptionCodes.php b/src/ncc/Enums/ExceptionCodes.php index e9a8bc5..c358582 100644 --- a/src/ncc/Enums/ExceptionCodes.php +++ b/src/ncc/Enums/ExceptionCodes.php @@ -26,98 +26,80 @@ * @author Zi Xing Narrakas * @copyright Copyright (C) 2022-2023. Nosial - All Rights Reserved. */ - final class ExceptionCodes + enum ExceptionCodes : int { /** * @see RuntimeException */ - public const RUNTIME = -1706; + case RUNTIME = -1706; /** * @see BuildException */ - public const BUILD_EXCEPTION = -1727; + case BUILD_EXCEPTION = -1727; /** * @see IOException */ - public const IO_EXCEPTION = -1735; + case IO_EXCEPTION = -1735; /** * @see ComposerException */ - public const COMPOSER_EXCEPTION = -1749; + case COMPOSER_EXCEPTION = -1749; /** * @see AuthenticationException */ - public const AUTHENTICATION_EXCEPTION = -1760; + case AUTHENTICATION_EXCEPTION = -1760; /** * @see NotSupportedException */ - public const NOT_SUPPORTED_EXCEPTION = -1761; + case NOT_SUPPORTED_EXCEPTION = -1761; /** * @see ArchiveException */ - public const ARCHIVE_EXCEPTION = -1764; + case ARCHIVE_EXCEPTION = -1764; /** * @see PathNotFoundException */ - public const PATH_NOT_FOUND = -1769; + case PATH_NOT_FOUND = -1769; /** * @see GitException */ - public const GIT_EXCEPTION = -1770; + case GIT_EXCEPTION = -1770; /** * @see ConfigurationException */ - public const CONFIGURATION_EXCEPTION = -1772; + case CONFIGURATION_EXCEPTION = -1772; /** * @see PackageException */ - public const PACKAGE_EXCEPTION = -1773; + case PACKAGE_EXCEPTION = -1773; /** * @see NetworkException */ - public const NETWORK_EXCEPTION = -1774; + case NETWORK_EXCEPTION = -1774; /** * @see IntegrityException */ - public const INTEGRITY_EXCEPTION = -1775; + case INTEGRITY_EXCEPTION = -1775; /** * @see OperationException */ - public const OPERATION_EXCEPTION = -1776; - - public const IMPORT_EXCEPTION = -1777; + case OPERATION_EXCEPTION = -1776; /** - * All the exception codes from NCC + * @see ImportException */ - public const All = [ - self::RUNTIME, - self::BUILD_EXCEPTION, - self::IO_EXCEPTION, - self::COMPOSER_EXCEPTION, - self::AUTHENTICATION_EXCEPTION, - self::NOT_SUPPORTED_EXCEPTION, - self::ARCHIVE_EXCEPTION, - self::PATH_NOT_FOUND, - self::GIT_EXCEPTION, - self::CONFIGURATION_EXCEPTION, - self::PACKAGE_EXCEPTION, - self::NETWORK_EXCEPTION, - self::INTEGRITY_EXCEPTION, - self::OPERATION_EXCEPTION, - self::IMPORT_EXCEPTION - ]; + case IMPORT_EXCEPTION = -1777; } \ No newline at end of file diff --git a/src/ncc/Exceptions/ArchiveException.php b/src/ncc/Exceptions/ArchiveException.php index 4ecfd0a..1f8bcd3 100644 --- a/src/ncc/Exceptions/ArchiveException.php +++ b/src/ncc/Exceptions/ArchiveException.php @@ -34,6 +34,6 @@ */ public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::ARCHIVE_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::ARCHIVE_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/AuthenticationException.php b/src/ncc/Exceptions/AuthenticationException.php index 0a1c79d..099ac17 100644 --- a/src/ncc/Exceptions/AuthenticationException.php +++ b/src/ncc/Exceptions/AuthenticationException.php @@ -34,6 +34,6 @@ */ public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::AUTHENTICATION_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::AUTHENTICATION_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/BuildException.php b/src/ncc/Exceptions/BuildException.php index 4e88a09..9d11954 100644 --- a/src/ncc/Exceptions/BuildException.php +++ b/src/ncc/Exceptions/BuildException.php @@ -34,6 +34,6 @@ namespace ncc\Exceptions; */ public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::BUILD_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::BUILD_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/ComposerException.php b/src/ncc/Exceptions/ComposerException.php index d279686..35b85e1 100644 --- a/src/ncc/Exceptions/ComposerException.php +++ b/src/ncc/Exceptions/ComposerException.php @@ -34,6 +34,6 @@ namespace ncc\Exceptions; */ public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::COMPOSER_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::COMPOSER_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/ConfigurationException.php b/src/ncc/Exceptions/ConfigurationException.php index 87ef8b9..58e5e93 100644 --- a/src/ncc/Exceptions/ConfigurationException.php +++ b/src/ncc/Exceptions/ConfigurationException.php @@ -34,6 +34,6 @@ */ public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::CONFIGURATION_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::CONFIGURATION_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/GitException.php b/src/ncc/Exceptions/GitException.php index cc6dc7e..3305ddf 100644 --- a/src/ncc/Exceptions/GitException.php +++ b/src/ncc/Exceptions/GitException.php @@ -30,6 +30,6 @@ { public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::GIT_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::GIT_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/IOException.php b/src/ncc/Exceptions/IOException.php index 2e08b2d..eb68822 100644 --- a/src/ncc/Exceptions/IOException.php +++ b/src/ncc/Exceptions/IOException.php @@ -34,6 +34,6 @@ namespace ncc\Exceptions; */ public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::IO_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::IO_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/ImportException.php b/src/ncc/Exceptions/ImportException.php index 2595198..1e3daa3 100644 --- a/src/ncc/Exceptions/ImportException.php +++ b/src/ncc/Exceptions/ImportException.php @@ -34,6 +34,6 @@ */ public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::IMPORT_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::IMPORT_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/IntegrityException.php b/src/ncc/Exceptions/IntegrityException.php index d2e7765..bc6435d 100644 --- a/src/ncc/Exceptions/IntegrityException.php +++ b/src/ncc/Exceptions/IntegrityException.php @@ -30,6 +30,6 @@ { public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::INTEGRITY_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::INTEGRITY_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/NetworkException.php b/src/ncc/Exceptions/NetworkException.php index 9967df5..f91b331 100644 --- a/src/ncc/Exceptions/NetworkException.php +++ b/src/ncc/Exceptions/NetworkException.php @@ -34,6 +34,6 @@ */ public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::NETWORK_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::NETWORK_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/NotSupportedException.php b/src/ncc/Exceptions/NotSupportedException.php index 65cb77d..bd686e7 100644 --- a/src/ncc/Exceptions/NotSupportedException.php +++ b/src/ncc/Exceptions/NotSupportedException.php @@ -34,6 +34,6 @@ */ public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::NOT_SUPPORTED_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::NOT_SUPPORTED_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/OperationException.php b/src/ncc/Exceptions/OperationException.php index b0ba020..8c2ff15 100644 --- a/src/ncc/Exceptions/OperationException.php +++ b/src/ncc/Exceptions/OperationException.php @@ -30,6 +30,6 @@ { public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::OPERATION_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::OPERATION_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/PackageException.php b/src/ncc/Exceptions/PackageException.php index edbfda4..2c08952 100644 --- a/src/ncc/Exceptions/PackageException.php +++ b/src/ncc/Exceptions/PackageException.php @@ -34,6 +34,6 @@ */ public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::PACKAGE_EXCEPTION, $previous); + parent::__construct($message, ExceptionCodes::PACKAGE_EXCEPTION->value, $previous); } } \ No newline at end of file diff --git a/src/ncc/Exceptions/PathNotFoundException.php b/src/ncc/Exceptions/PathNotFoundException.php index 25b8d96..1802f5f 100644 --- a/src/ncc/Exceptions/PathNotFoundException.php +++ b/src/ncc/Exceptions/PathNotFoundException.php @@ -41,7 +41,7 @@ */ public function __construct(string $path, ?Throwable $previous = null) { - parent::__construct(sprintf('Path "%s" not found', $path), ExceptionCodes::PATH_NOT_FOUND, $previous); + parent::__construct(sprintf('Path "%s" not found', $path), ExceptionCodes::PATH_NOT_FOUND->value, $previous); $this->path = $path; } diff --git a/src/ncc/Exceptions/RuntimeException.php b/src/ncc/Exceptions/RuntimeException.php index e38a139..71c3ce8 100644 --- a/src/ncc/Exceptions/RuntimeException.php +++ b/src/ncc/Exceptions/RuntimeException.php @@ -35,6 +35,6 @@ namespace ncc\Exceptions; */ public function __construct(string $message = "", ?Throwable $previous = null) { - parent::__construct($message, ExceptionCodes::RUNTIME, $previous); + parent::__construct($message, ExceptionCodes::RUNTIME->value, $previous); } } \ No newline at end of file From baf11f5cb9dc4e349fda84fae2dbee0034134a7e Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 00:37:03 -0400 Subject: [PATCH 019/134] Convert ConsoleColors constants to enum cases --- src/installer/installer | 8 ++--- src/ncc/CLI/Management/PackageManagerMenu.php | 6 ++-- src/ncc/CLI/Management/RepositoryMenu.php | 6 ++-- src/ncc/Enums/ConsoleColors.php | 36 +++++++++---------- src/ncc/Objects/CliHelpSection.php | 4 +-- src/ncc/Utilities/Console.php | 36 +++++++++---------- 6 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/installer/installer b/src/installer/installer index 6cf9ee7..5149901 100644 --- a/src/installer/installer +++ b/src/installer/installer @@ -181,11 +181,11 @@ { if($installed) { - Console::out("$ext ... " . Console::formatColor("installed", ConsoleColors::LIGHT_GREEN)); + Console::out("$ext ... " . Console::formatColor("installed", ConsoleColors::LIGHT_GREEN->value)); } else { - Console::out("$ext ... " . Console::formatColor("missing", ConsoleColors::LIGHT_RED)); + Console::out("$ext ... " . Console::formatColor("missing", ConsoleColors::LIGHT_RED->value)); } } @@ -210,11 +210,11 @@ try { - Console::out(Console::formatColor($full_name, ConsoleColors::GREEN) . ' Version: ' . Console::formatColor($component->getVersion(), ConsoleColors::LIGHT_MAGENTA)); + Console::out(Console::formatColor($full_name, ConsoleColors::GREEN->value) . ' Version: ' . Console::formatColor($component->getVersion(), ConsoleColors::LIGHT_MAGENTA)); } catch (Exception $e) { - Console::outWarning('Cannot determine component version of ' . Console::formatColor($full_name, ConsoleColors::GREEN)); + Console::outWarning('Cannot determine component version of ' . Console::formatColor($full_name, ConsoleColors::GREEN->value)); } } diff --git a/src/ncc/CLI/Management/PackageManagerMenu.php b/src/ncc/CLI/Management/PackageManagerMenu.php index dbc9d32..96343c4 100644 --- a/src/ncc/CLI/Management/PackageManagerMenu.php +++ b/src/ncc/CLI/Management/PackageManagerMenu.php @@ -342,9 +342,9 @@ private static function printTree($data, string $prefix=''): void { $symbols = [ - 'corner' => Console::formatColor(' └─', ConsoleColors::LIGHT_RED), - 'line' => Console::formatColor(' │ ', ConsoleColors::LIGHT_RED), - 'cross' => Console::formatColor(' ├─', ConsoleColors::LIGHT_RED), + 'corner' => Console::formatColor(' └─', ConsoleColors::LIGHT_RED->value), + 'line' => Console::formatColor(' │ ', ConsoleColors::LIGHT_RED->value), + 'cross' => Console::formatColor(' ├─', ConsoleColors::LIGHT_RED->value), ]; $keys = array_keys($data); diff --git a/src/ncc/CLI/Management/RepositoryMenu.php b/src/ncc/CLI/Management/RepositoryMenu.php index 033e844..16660ab 100644 --- a/src/ncc/CLI/Management/RepositoryMenu.php +++ b/src/ncc/CLI/Management/RepositoryMenu.php @@ -117,13 +117,13 @@ { $output = sprintf('%s (%s) [%s]', $source->getName(), - Console::formatColor($source->getHost(), ConsoleColors::GREEN), - Console::formatColor($source->getType(), ConsoleColors::YELLOW) + Console::formatColor($source->getHost(), ConsoleColors::GREEN->value), + Console::formatColor($source->getType(), ConsoleColors::YELLOW->value) ); if(!$source->isSsl()) { - $output .= Console::formatColor('*', ConsoleColors::RED); + $output .= Console::formatColor('*', ConsoleColors::RED->value); } Console::out(' - ' . $output); diff --git a/src/ncc/Enums/ConsoleColors.php b/src/ncc/Enums/ConsoleColors.php index 68f57d7..a665860 100644 --- a/src/ncc/Enums/ConsoleColors.php +++ b/src/ncc/Enums/ConsoleColors.php @@ -22,39 +22,39 @@ namespace ncc\Enums; - final class ConsoleColors + enum ConsoleColors : string { - public const DEFAULT = "\e[39m"; + case DEFAULT = "\e[39m"; - public const BLACK = "\e[30m"; + case BLACK = "\e[30m"; - public const RED = "\e[31m"; + case RED = "\e[31m"; - public const GREEN = "\e[32m"; + case GREEN = "\e[32m"; - public const YELLOW = "\e[33m"; + case YELLOW = "\e[33m"; - public const BLUE = "\e[34m"; + case BLUE = "\e[34m"; - public const MAGENTA = "\e[35m"; + case MAGENTA = "\e[35m"; - public const CYAN = "\e[36m"; + case CYAN = "\e[36m"; - public const LIGHT_GREY = "\e[37m"; + case LIGHT_GREY = "\e[37m"; - public const DARK_GREY = "\e[90m"; + case DARK_GREY = "\e[90m"; - public const LIGHT_RED = "\e[91m"; + case LIGHT_RED = "\e[91m"; - public const LIGHT_GREEN = "\e[92m"; + case LIGHT_GREEN = "\e[92m"; - public const LIGHT_YELLOW = "\e[93m"; + case LIGHT_YELLOW = "\e[93m"; - public const LIGHT_BLUE = "\e[94m"; + case LIGHT_BLUE = "\e[94m"; - public const LIGHT_MAGENTA = "\e[95m"; + case LIGHT_MAGENTA = "\e[95m"; - public const LIGHT_CYAN = "\e[96m"; + case LIGHT_CYAN = "\e[96m"; - public const WHITE = "\e[97m"; + case WHITE = "\e[97m"; } \ No newline at end of file diff --git a/src/ncc/Objects/CliHelpSection.php b/src/ncc/Objects/CliHelpSection.php index 710beef..07ad35d 100644 --- a/src/ncc/Objects/CliHelpSection.php +++ b/src/ncc/Objects/CliHelpSection.php @@ -174,7 +174,7 @@ if(!$basic) { - $result = Console::formatColor($result, ConsoleColors::GREEN); + $result = Console::formatColor($result, ConsoleColors::GREEN->value); } $out[] .= $result; @@ -185,7 +185,7 @@ } else { - $out[] .= Console::formatColor(implode(' ', $this->parameters), ConsoleColors::GREEN); + $out[] .= Console::formatColor(implode(' ', $this->parameters), ConsoleColors::GREEN->value); } } diff --git a/src/ncc/Utilities/Console.php b/src/ncc/Utilities/Console.php index 082d0eb..2734f17 100644 --- a/src/ncc/Utilities/Console.php +++ b/src/ncc/Utilities/Console.php @@ -53,13 +53,13 @@ private static function setPrefix(string $log_level, string $input): string { $input = match ($log_level) { - LogLevel::VERBOSE->value => self::formatColor('VRB:', ConsoleColors::LIGHT_CYAN) . " $input", - LogLevel::DEBUG->value => self::formatColor('DBG:', ConsoleColors::LIGHT_MAGENTA) . " $input", - LogLevel::INFO->value => self::formatColor('INF:', ConsoleColors::WHITE) . " $input", - LogLevel::WARNING->value => self::formatColor('WRN:', ConsoleColors::YELLOW) . " $input", - LogLevel::ERROR->value => self::formatColor('ERR:', ConsoleColors::LIGHT_RED) . " $input", - LogLevel::FATAL->value => self::formatColor('FTL:', ConsoleColors::LIGHT_RED) . " $input", - default => self::formatColor('MSG:', ConsoleColors::DEFAULT) . " $input", + LogLevel::VERBOSE->value => self::formatColor('VRB:', ConsoleColors::LIGHT_CYAN->value) . " $input", + LogLevel::DEBUG->value => self::formatColor('DBG:', ConsoleColors::LIGHT_MAGENTA->value) . " $input", + LogLevel::INFO->value => self::formatColor('INF:', ConsoleColors::WHITE->value) . " $input", + LogLevel::WARNING->value => self::formatColor('WRN:', ConsoleColors::YELLOW->value) . " $input", + LogLevel::ERROR->value => self::formatColor('ERR:', ConsoleColors::LIGHT_RED->value) . " $input", + LogLevel::FATAL->value => self::formatColor('FTL:', ConsoleColors::LIGHT_RED->value) . " $input", + default => self::formatColor('MSG:', ConsoleColors::DEFAULT->value) . " $input", }; $tick_time = (string)microtime(true); @@ -82,11 +82,11 @@ if ($timeDiff > 1.0) { - $fmt_tick = self::formatColor($tick_time, ConsoleColors::LIGHT_RED); + $fmt_tick = self::formatColor($tick_time, ConsoleColors::LIGHT_RED->value); } elseif ($timeDiff > 0.5) { - $fmt_tick = self::formatColor($tick_time, ConsoleColors::LIGHT_YELLOW); + $fmt_tick = self::formatColor($tick_time, ConsoleColors::LIGHT_YELLOW->value); } } @@ -155,9 +155,9 @@ $trace_msg = null; if($backtrace !== null && isset($backtrace[1])) { - $trace_msg = self::formatColor($backtrace[1]['class'], ConsoleColors::LIGHT_GREY); + $trace_msg = self::formatColor($backtrace[1]['class'], ConsoleColors::LIGHT_GREY->value); $trace_msg .= $backtrace[1]['type']; - $trace_msg .= self::formatColor($backtrace[1]['function'] . '()', ConsoleColors::LIGHT_GREEN); + $trace_msg .= self::formatColor($backtrace[1]['function'] . '()', ConsoleColors::LIGHT_GREEN->value); $trace_msg .= ' > '; } @@ -205,7 +205,7 @@ if($persist) { - return $color_code . $input . ConsoleColors::DEFAULT; + return $color_code . $input . ConsoleColors::DEFAULT->value; } return $color_code . $input; @@ -236,7 +236,7 @@ return; } - self::out(self::formatColor('Warning: ', ConsoleColors::YELLOW) . $message, $newline); + self::out(self::formatColor('Warning: ', ConsoleColors::YELLOW->value) . $message, $newline); } /** @@ -265,7 +265,7 @@ } else { - self::out(self::formatColor(ConsoleColors::RED, 'Error: ') . $message, $newline); + self::out(self::formatColor(ConsoleColors::RED->value, 'Error: ') . $message, $newline); } if($exit_code !== null) @@ -291,7 +291,7 @@ if($message !== '' && Resolver::checkLogLevel(LogLevel::ERROR->value, Main::getLogLevel())) { - self::out(PHP_EOL . self::formatColor('Error: ', ConsoleColors::RED) . $message); + self::out(PHP_EOL . self::formatColor('Error: ', ConsoleColors::RED->value) . $message); } self::out(PHP_EOL . '===== Exception Details ====='); @@ -318,8 +318,8 @@ } // Exception name without namespace - $trace_header = self::formatColor($e->getFile() . ':' . $e->getLine(), ConsoleColors::MAGENTA); - $trace_error = self::formatColor( 'Error: ', ConsoleColors::RED); + $trace_header = self::formatColor($e->getFile() . ':' . $e->getLine(), ConsoleColors::MAGENTA->value); + $trace_error = self::formatColor( 'Error: ', ConsoleColors::RED->value); self::out($trace_header . ' ' . $trace_error . $e->getMessage()); self::out(sprintf('Exception: %s', get_class($e))); self::out(sprintf('Error code: %s', $e->getCode())); @@ -329,7 +329,7 @@ self::out('Stack Trace:'); foreach($trace as $item) { - self::out( ' - ' . self::formatColor($item['file'], ConsoleColors::RED) . ':' . $item['line']); + self::out( ' - ' . self::formatColor($item['file'], ConsoleColors::RED->value) . ':' . $item['line']); } } From d884d0fbda768a21a2380678790f1cfc41989688 Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 00:39:18 -0400 Subject: [PATCH 020/134] Convert CompilerExtensions constants to enum cases --- src/ncc/Enums/CompilerExtensions.php | 8 ++------ src/ncc/Managers/ProjectManager.php | 6 +++--- src/ncc/Objects/ProjectConfiguration/Compiler.php | 5 +++-- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/ncc/Enums/CompilerExtensions.php b/src/ncc/Enums/CompilerExtensions.php index 0c280d6..04fcc60 100644 --- a/src/ncc/Enums/CompilerExtensions.php +++ b/src/ncc/Enums/CompilerExtensions.php @@ -22,11 +22,7 @@ namespace ncc\Enums; - final class CompilerExtensions + enum CompilerExtensions : string { - public const PHP = 'php'; - - public const ALL = [ - CompilerExtensions::PHP - ]; + case PHP = 'php'; } \ No newline at end of file diff --git a/src/ncc/Managers/ProjectManager.php b/src/ncc/Managers/ProjectManager.php index e84f69e..c33b5a8 100644 --- a/src/ncc/Managers/ProjectManager.php +++ b/src/ncc/Managers/ProjectManager.php @@ -160,7 +160,7 @@ return match (strtolower($this->project_configuration->getProject()->getCompiler()->getExtension())) { - CompilerExtensions::PHP => match (strtolower($configuration->getBuildType())) + CompilerExtensions::PHP->value => match (strtolower($configuration->getBuildType())) { BuildOutputType::NCC_PACKAGE => (new NccCompiler($this))->build($build_configuration, $options), BuildOutputType::EXECUTABLE => (new ExecutableCompiler($this))->build($build_configuration, $options), @@ -258,7 +258,7 @@ { return match ($this->getProjectConfiguration()->getProject()->getCompiler()->getExtension()) { - CompilerExtensions::PHP => ComponentFileExtensions::PHP, + CompilerExtensions::PHP->value => ComponentFileExtensions::PHP, default => throw new NotSupportedException( sprintf('The compiler extension \'%s\' is not supported', $this->getProjectConfiguration()->getProject()->getCompiler()->getExtension()) ), @@ -485,7 +485,7 @@ throw new IOException(sprintf('Project source directory "%s" was not created', $project_src)); } - $project = new ProjectConfiguration\Project(new ProjectConfiguration\Compiler(CompilerExtensions::PHP)); + $project = new ProjectConfiguration\Project(new ProjectConfiguration\Compiler(CompilerExtensions::PHP->value)); $assembly = new ProjectConfiguration\Assembly( Resolver::composerName($composer_json->getName()), Resolver::composerNameToPackage($composer_json->getName()), diff --git a/src/ncc/Objects/ProjectConfiguration/Compiler.php b/src/ncc/Objects/ProjectConfiguration/Compiler.php index b2017d5..a118006 100644 --- a/src/ncc/Objects/ProjectConfiguration/Compiler.php +++ b/src/ncc/Objects/ProjectConfiguration/Compiler.php @@ -77,7 +77,7 @@ /** @noinspection DegradedSwitchInspection */ switch($extension) { - case CompilerExtensions::PHP: + case CompilerExtensions::PHP->value: if($minimum_version === null) { @@ -185,7 +185,8 @@ } /** @noinspection InArrayMissUseInspection */ - if(!in_array($this->extension, CompilerExtensions::ALL, true)) + // TODO: Fix this, not a proper use of cases() + if(!in_array($this->extension, CompilerExtensions::cases(), true)) { throw new NotSupportedException('The compiler extension \'' . $this->extension . '\' is not supported'); } From 71ffed1a3f5d1d83576e69ccb6c2e8aecf38f8c7 Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 00:40:59 -0400 Subject: [PATCH 021/134] Convert RepositoryType constants to enum cases --- src/ncc/Enums/Types/RepositoryType.php | 17 +++++------------ src/ncc/Objects/RepositoryConfiguration.php | 19 ++++++++++--------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/ncc/Enums/Types/RepositoryType.php b/src/ncc/Enums/Types/RepositoryType.php index 374d2ff..13b7d15 100644 --- a/src/ncc/Enums/Types/RepositoryType.php +++ b/src/ncc/Enums/Types/RepositoryType.php @@ -22,20 +22,13 @@ namespace ncc\Enums\Types; - final class RepositoryType + enum RepositoryType : string { - public const GITLAB = 'gitlab'; + case GITLAB = 'gitlab'; - public const GITHUB = 'github'; + case GITHUB = 'github'; - public const GITEA = 'gitea'; + case GITEA = 'gitea'; - public const PACKAGIST = 'packagist'; - - public const ALL = [ - self::GITLAB, - self::GITHUB, - self::GITEA, - self::PACKAGIST - ]; + case PACKAGIST = 'packagist'; } \ No newline at end of file diff --git a/src/ncc/Objects/RepositoryConfiguration.php b/src/ncc/Objects/RepositoryConfiguration.php index 245e2f0..e5f389f 100644 --- a/src/ncc/Objects/RepositoryConfiguration.php +++ b/src/ncc/Objects/RepositoryConfiguration.php @@ -117,7 +117,8 @@ */ public function setType(string $type): void { - if(!in_array(strtolower($type), RepositoryType::ALL, true)) + // TODO: Fix this, not a proper use of cases() + if(!in_array(strtolower($type), RepositoryType::cases(), true)) { throw new InvalidArgumentException(sprintf('Invalid repository type \'%s\'', $type)); } @@ -182,10 +183,10 @@ { return match(strtolower($this->type)) { - RepositoryType::GITHUB => GithubRepository::fetchPackage($this, $vendor, $project, $version, $authentication, $options), - RepositoryType::GITLAB => GitlabRepository::fetchPackage($this, $vendor, $project, $version, $authentication, $options), - RepositoryType::GITEA => GiteaRepository::fetchPackage($this, $vendor, $project, $version, $authentication, $options), - RepositoryType::PACKAGIST => throw new NotSupportedException('Fetching ncc packages from Packagist is not supported'), + RepositoryType::GITHUB->value => GithubRepository::fetchPackage($this, $vendor, $project, $version, $authentication, $options), + RepositoryType::GITLAB->value => GitlabRepository::fetchPackage($this, $vendor, $project, $version, $authentication, $options), + RepositoryType::GITEA->value => GiteaRepository::fetchPackage($this, $vendor, $project, $version, $authentication, $options), + RepositoryType::PACKAGIST->value => throw new NotSupportedException('Fetching ncc packages from Packagist is not supported'), default => throw new InvalidArgumentException(sprintf('Invalid repository type \'%s\'', $this->type)), }; } @@ -206,10 +207,10 @@ { return match(strtolower($this->type)) { - RepositoryType::GITHUB => GithubRepository::fetchSourceArchive($this, $vendor, $project, $version, $authentication, $options), - RepositoryType::GITLAB => GitlabRepository::fetchSourceArchive($this, $vendor, $project, $version, $authentication, $options), - RepositoryType::GITEA => GiteaRepository::fetchSourceArchive($this, $vendor, $project, $version, $authentication, $options), - RepositoryType::PACKAGIST => PackagistRepository::fetchSourceArchive($this, $vendor, $project, $version, $authentication, $options), + RepositoryType::GITHUB->value => GithubRepository::fetchSourceArchive($this, $vendor, $project, $version, $authentication, $options), + RepositoryType::GITLAB->value => GitlabRepository::fetchSourceArchive($this, $vendor, $project, $version, $authentication, $options), + RepositoryType::GITEA->value => GiteaRepository::fetchSourceArchive($this, $vendor, $project, $version, $authentication, $options), + RepositoryType::PACKAGIST->value => PackagistRepository::fetchSourceArchive($this, $vendor, $project, $version, $authentication, $options), default => throw new InvalidArgumentException(sprintf('Invalid repository type \'%s\'', $this->type)), }; } From 14ec2e06b21d03b4bd0185e33978ac0458db6619 Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 00:41:27 -0400 Subject: [PATCH 022/134] Added TODO --- src/ncc/Enums/CompilerExtensionSupportedVersions.php | 1 + src/ncc/Enums/ComponentFileExtensions.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/ncc/Enums/CompilerExtensionSupportedVersions.php b/src/ncc/Enums/CompilerExtensionSupportedVersions.php index b17b61b..491b164 100644 --- a/src/ncc/Enums/CompilerExtensionSupportedVersions.php +++ b/src/ncc/Enums/CompilerExtensionSupportedVersions.php @@ -24,5 +24,6 @@ final class CompilerExtensionSupportedVersions { + // TODO: Cannot convert this to enum, try another way public const PHP = ['8.0', '8.1', '8.2']; } \ No newline at end of file diff --git a/src/ncc/Enums/ComponentFileExtensions.php b/src/ncc/Enums/ComponentFileExtensions.php index 7907198..1512a21 100644 --- a/src/ncc/Enums/ComponentFileExtensions.php +++ b/src/ncc/Enums/ComponentFileExtensions.php @@ -29,5 +29,6 @@ * * @var array */ + // TODO: Cannot convert this to enum, try another way public const PHP = ['*.php', '*.php3', '*.php4', '*.php5', '*.phtml']; } \ No newline at end of file From 5b24fe267d47ceea44e6089f5685c586c65ddfbd Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:17:45 -0400 Subject: [PATCH 023/134] Convert RepositoryResultType constants to enum cases --- src/ncc/Classes/GiteaExtension/GiteaRepository.php | 10 +++++----- src/ncc/Classes/GithubExtension/GithubRepository.php | 8 ++++---- src/ncc/Classes/GitlabExtension/GitlabRepository.php | 8 ++++---- .../Classes/PackagistExtension/PackagistRepository.php | 2 +- src/ncc/Enums/Types/RepositoryResultType.php | 6 +++--- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/ncc/Classes/GiteaExtension/GiteaRepository.php b/src/ncc/Classes/GiteaExtension/GiteaRepository.php index 8381c12..2b11774 100644 --- a/src/ncc/Classes/GiteaExtension/GiteaRepository.php +++ b/src/ncc/Classes/GiteaExtension/GiteaRepository.php @@ -198,11 +198,11 @@ if(isset($response['zipball_url'])) { - $result = new RepositoryResult($response['zipball_url'], RepositoryResultType::SOURCE, $tag); + $result = new RepositoryResult($response['zipball_url'], RepositoryResultType::SOURCE->value, $tag); } elseif(isset($response['tarball_url'])) { - $result = new RepositoryResult($response['tarball_url'], RepositoryResultType::SOURCE, $tag); + $result = new RepositoryResult($response['tarball_url'], RepositoryResultType::SOURCE->value, $tag); } else { @@ -379,7 +379,7 @@ if($asset_url) { - $result = new RepositoryResult($asset_url, RepositoryResultType::PACKAGE, $release); + $result = new RepositoryResult($asset_url, RepositoryResultType::PACKAGE->value, $release); RuntimeCache::set($endpoint, $result); return $result; @@ -445,11 +445,11 @@ if(isset($response['zipball_url'])) { - $results = new RepositoryResult($response['zipball_url'], RepositoryResultType::SOURCE, $release); + $results = new RepositoryResult($response['zipball_url'], RepositoryResultType::SOURCE->value, $release); } elseif(isset($response['tarball_url'])) { - $results = new RepositoryResult($response['tarball_url'], RepositoryResultType::SOURCE, $release); + $results = new RepositoryResult($response['tarball_url'], RepositoryResultType::SOURCE->value, $release); } else { diff --git a/src/ncc/Classes/GithubExtension/GithubRepository.php b/src/ncc/Classes/GithubExtension/GithubRepository.php index 9cacc2a..1177510 100644 --- a/src/ncc/Classes/GithubExtension/GithubRepository.php +++ b/src/ncc/Classes/GithubExtension/GithubRepository.php @@ -207,7 +207,7 @@ throw new NetworkException(sprintf('Server responded with HTTP code %s when getting tag archive for %s/%s/%s', $http_code, $group, $project, $tag)); } - $result = new RepositoryResult(curl_getinfo($curl, CURLINFO_EFFECTIVE_URL), RepositoryResultType::SOURCE, $tag); + $result = new RepositoryResult(curl_getinfo($curl, CURLINFO_EFFECTIVE_URL), RepositoryResultType::SOURCE->value, $tag); curl_close($curl); RuntimeCache::set($endpoint, $result); @@ -363,7 +363,7 @@ { $asset_url = $target_asset['browser_download_url']; - $result = new RepositoryResult($asset_url, RepositoryResultType::PACKAGE, $release); + $result = new RepositoryResult($asset_url, RepositoryResultType::PACKAGE->value, $release); RuntimeCache::set($endpoint, $result); return $result; @@ -425,11 +425,11 @@ if(isset($response['zipball_url'])) { - $result = new RepositoryResult($response['zipball_url'], RepositoryResultType::SOURCE, $release); + $result = new RepositoryResult($response['zipball_url'], RepositoryResultType::SOURCE->value, $release); } elseif(isset($response['tarball_url'])) { - $result = new RepositoryResult($response['tarball_url'], RepositoryResultType::SOURCE, $release); + $result = new RepositoryResult($response['tarball_url'], RepositoryResultType::SOURCE->value, $release); } else { diff --git a/src/ncc/Classes/GitlabExtension/GitlabRepository.php b/src/ncc/Classes/GitlabExtension/GitlabRepository.php index e09c9ca..0865dff 100644 --- a/src/ncc/Classes/GitlabExtension/GitlabRepository.php +++ b/src/ncc/Classes/GitlabExtension/GitlabRepository.php @@ -210,7 +210,7 @@ throw new NetworkException(sprintf('Server responded with HTTP code %s when getting tag archive for %s/%s/%s', $http_code, $group, $project, $tag)); } - $results = new RepositoryResult(curl_getinfo($curl, CURLINFO_EFFECTIVE_URL), RepositoryResultType::SOURCE, $tag); + $results = new RepositoryResult(curl_getinfo($curl, CURLINFO_EFFECTIVE_URL), RepositoryResultType::SOURCE->value, $tag); RuntimeCache::set($endpoint, $results); return $results; @@ -364,7 +364,7 @@ if ($asset_url) { - $result = new RepositoryResult($asset_url, RepositoryResultType::PACKAGE, $release); + $result = new RepositoryResult($asset_url, RepositoryResultType::PACKAGE->value, $release); RuntimeCache::set($endpoint, $result); return $result; @@ -440,11 +440,11 @@ if($asset['format'] === 'zip') { - $results = new RepositoryResult($asset['url'], RepositoryResultType::SOURCE, $release); + $results = new RepositoryResult($asset['url'], RepositoryResultType::SOURCE->value, $release); } elseif($asset['format'] === 'tar') { - $results = new RepositoryResult($asset['url'], RepositoryResultType::SOURCE, $release); + $results = new RepositoryResult($asset['url'], RepositoryResultType::SOURCE->value, $release); } else { diff --git a/src/ncc/Classes/PackagistExtension/PackagistRepository.php b/src/ncc/Classes/PackagistExtension/PackagistRepository.php index 157d721..902601c 100644 --- a/src/ncc/Classes/PackagistExtension/PackagistRepository.php +++ b/src/ncc/Classes/PackagistExtension/PackagistRepository.php @@ -91,7 +91,7 @@ throw new NetworkException(sprintf('Invalid response from %s/%s, version %s does not have a dist URL', $vendor, $project, $version)); } - return new RepositoryResult($response['package']['versions'][$version]['dist']['url'], RepositoryResultType::SOURCE, $version); + return new RepositoryResult($response['package']['versions'][$version]['dist']['url'], RepositoryResultType::SOURCE->value, $version); } /** diff --git a/src/ncc/Enums/Types/RepositoryResultType.php b/src/ncc/Enums/Types/RepositoryResultType.php index 1cfb4c4..1879d70 100644 --- a/src/ncc/Enums/Types/RepositoryResultType.php +++ b/src/ncc/Enums/Types/RepositoryResultType.php @@ -22,9 +22,9 @@ namespace ncc\Enums\Types; - final class RepositoryResultType + enum RepositoryResultType : string { - public const SOURCE = 'source'; + case SOURCE = 'source'; - public const PACKAGE = 'package'; + case PACKAGE = 'package'; } \ No newline at end of file From 3d44562241a00e8d52bc09c5025568f80ee3dc41 Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:18:34 -0400 Subject: [PATCH 024/134] Removed RemoteSourceType --- src/ncc/Enums/Types/RemoteSourceType.php | 56 ------------------------ 1 file changed, 56 deletions(-) delete mode 100644 src/ncc/Enums/Types/RemoteSourceType.php diff --git a/src/ncc/Enums/Types/RemoteSourceType.php b/src/ncc/Enums/Types/RemoteSourceType.php deleted file mode 100644 index 96b7a53..0000000 --- a/src/ncc/Enums/Types/RemoteSourceType.php +++ /dev/null @@ -1,56 +0,0 @@ - Date: Sat, 14 Sep 2024 08:19:50 -0400 Subject: [PATCH 025/134] Convert ProjectType constants to enum cases --- src/ncc/Enums/Types/ProjectType.php | 11 +++-------- src/ncc/Managers/PackageManager.php | 5 +++-- src/ncc/Utilities/Resolver.php | 4 ++-- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/ncc/Enums/Types/ProjectType.php b/src/ncc/Enums/Types/ProjectType.php index 3db7f63..648750f 100644 --- a/src/ncc/Enums/Types/ProjectType.php +++ b/src/ncc/Enums/Types/ProjectType.php @@ -22,14 +22,9 @@ namespace ncc\Enums\Types; - final class ProjectType + enum ProjectType : string { - public const COMPOSER = 'composer'; + case COMPOSER = 'composer'; - public const NCC = 'ncc'; - - public const ALL = [ - self::COMPOSER, - self::NCC, - ]; + case NCC = 'ncc'; } \ No newline at end of file diff --git a/src/ncc/Managers/PackageManager.php b/src/ncc/Managers/PackageManager.php index db489f6..52068fa 100644 --- a/src/ncc/Managers/PackageManager.php +++ b/src/ncc/Managers/PackageManager.php @@ -798,9 +798,10 @@ throw new OperationException(sprintf('Failed to detect project type from source %s: %s', $archive, $e->getMessage()), $e); } + // TODO: getProjectType() could return the enum case switch($project_detection->getProjectType()) { - case ProjectType::NCC: + case ProjectType::NCC->value: try { $package_path = (new ProjectManager($project_detection->getProjectFilePath()))->build( @@ -823,7 +824,7 @@ throw new OperationException(sprintf('Failed to build from source %s: %s', $archive, $e->getMessage()), $e); } - case ProjectType::COMPOSER: + case ProjectType::COMPOSER->value: try { $project_manager = ProjectManager::initializeFromComposer(dirname($project_detection->getProjectFilePath()), $options); diff --git a/src/ncc/Utilities/Resolver.php b/src/ncc/Utilities/Resolver.php index 410ac68..366fc15 100644 --- a/src/ncc/Utilities/Resolver.php +++ b/src/ncc/Utilities/Resolver.php @@ -212,12 +212,12 @@ { if(str_ends_with($file, 'project.json')) { - return new ProjectDetectionResults($file, ProjectType::NCC); + return new ProjectDetectionResults($file, ProjectType::NCC->value); } if(str_ends_with($file, 'composer.json')) { - return new ProjectDetectionResults($file, ProjectType::COMPOSER); + return new ProjectDetectionResults($file, ProjectType::COMPOSER->value); } } From 28ff80dd415a65c913efde486441e13db9dbcfc2 Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:22:25 -0400 Subject: [PATCH 026/134] Convert HttpRequestType constants to enum cases --- src/ncc/Classes/GiteaExtension/GiteaRepository.php | 10 +++++----- src/ncc/Classes/GithubExtension/GithubRepository.php | 10 +++++----- src/ncc/Classes/GitlabExtension/GitlabRepository.php | 10 +++++----- .../Classes/PackagistExtension/PackagistRepository.php | 4 ++-- src/ncc/Enums/Types/HttpRequestType.php | 10 +++++----- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/ncc/Classes/GiteaExtension/GiteaRepository.php b/src/ncc/Classes/GiteaExtension/GiteaRepository.php index 2b11774..4260a4b 100644 --- a/src/ncc/Classes/GiteaExtension/GiteaRepository.php +++ b/src/ncc/Classes/GiteaExtension/GiteaRepository.php @@ -105,7 +105,7 @@ curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); @@ -189,7 +189,7 @@ curl_setopt_array($curl, [ CURLOPT_URL => $endpoint, CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); @@ -249,7 +249,7 @@ curl_setopt_array($curl, [ CURLOPT_URL => $endpoint, CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); @@ -340,7 +340,7 @@ curl_setopt_array($curl, [ CURLOPT_URL => $endpoint, CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); @@ -436,7 +436,7 @@ curl_setopt_array($curl, [ CURLOPT_URL => $endpoint, CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); diff --git a/src/ncc/Classes/GithubExtension/GithubRepository.php b/src/ncc/Classes/GithubExtension/GithubRepository.php index 1177510..ddccce8 100644 --- a/src/ncc/Classes/GithubExtension/GithubRepository.php +++ b/src/ncc/Classes/GithubExtension/GithubRepository.php @@ -104,7 +104,7 @@ curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); @@ -186,7 +186,7 @@ curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_NOBODY => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers, CURLOPT_FOLLOWLOCATION => true ]); @@ -249,7 +249,7 @@ curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); @@ -331,7 +331,7 @@ $headers = self::injectAuthentication($authentication, $curl, $headers); } - curl_setopt_array($curl, [CURLOPT_RETURNTRANSFER => true, CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, CURLOPT_HTTPHEADER => $headers]); + curl_setopt_array($curl, [CURLOPT_RETURNTRANSFER => true, CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers]); Console::outDebug(sprintf('Fetching release package for %s/%s/%s from %s', $group, $project, $release, $endpoint)); $response = self::processHttpResponse($curl, $group, $project); @@ -415,7 +415,7 @@ curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); diff --git a/src/ncc/Classes/GitlabExtension/GitlabRepository.php b/src/ncc/Classes/GitlabExtension/GitlabRepository.php index 0865dff..e1fb48a 100644 --- a/src/ncc/Classes/GitlabExtension/GitlabRepository.php +++ b/src/ncc/Classes/GitlabExtension/GitlabRepository.php @@ -106,7 +106,7 @@ curl_setopt_array($curl, [ CURLOPT_URL => $endpoint, CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); @@ -190,7 +190,7 @@ curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_NOBODY => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers, CURLOPT_FOLLOWLOCATION => true ]); @@ -252,7 +252,7 @@ curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); @@ -335,7 +335,7 @@ curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); @@ -420,7 +420,7 @@ curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); diff --git a/src/ncc/Classes/PackagistExtension/PackagistRepository.php b/src/ncc/Classes/PackagistExtension/PackagistRepository.php index 902601c..d8d9e7d 100644 --- a/src/ncc/Classes/PackagistExtension/PackagistRepository.php +++ b/src/ncc/Classes/PackagistExtension/PackagistRepository.php @@ -72,7 +72,7 @@ curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); @@ -132,7 +132,7 @@ curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, - CURLOPT_CUSTOMREQUEST => HttpRequestType::GET, + CURLOPT_CUSTOMREQUEST => HttpRequestType::GET->value, CURLOPT_HTTPHEADER => $headers ]); diff --git a/src/ncc/Enums/Types/HttpRequestType.php b/src/ncc/Enums/Types/HttpRequestType.php index 50b3eac..6892f7b 100644 --- a/src/ncc/Enums/Types/HttpRequestType.php +++ b/src/ncc/Enums/Types/HttpRequestType.php @@ -22,10 +22,10 @@ namespace ncc\Enums\Types; - final class HttpRequestType + enum HttpRequestType : string { - public const GET = 'GET'; - public const POST = 'POST'; - public const PUT = 'PUT'; - public const DELETE = 'DELETE'; + case GET = 'GET'; + case POST = 'POST'; + case PUT = 'PUT'; + case DELETE = 'DELETE'; } \ No newline at end of file From a2149cdb6617142094ce34263d8604ff9983718d Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:22:40 -0400 Subject: [PATCH 027/134] Removed DependencySourceType --- src/ncc/Enums/Types/DependencySourceType.php | 49 -------------------- 1 file changed, 49 deletions(-) delete mode 100644 src/ncc/Enums/Types/DependencySourceType.php diff --git a/src/ncc/Enums/Types/DependencySourceType.php b/src/ncc/Enums/Types/DependencySourceType.php deleted file mode 100644 index d0b78d2..0000000 --- a/src/ncc/Enums/Types/DependencySourceType.php +++ /dev/null @@ -1,49 +0,0 @@ - Date: Sat, 14 Sep 2024 08:23:29 -0400 Subject: [PATCH 028/134] Convert ComposerStabilityTypes constants to enum cases --- src/ncc/Enums/Types/ComposerStabilityTypes.php | 12 ++++++------ src/ncc/Objects/ComposerJson.php | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ncc/Enums/Types/ComposerStabilityTypes.php b/src/ncc/Enums/Types/ComposerStabilityTypes.php index 85bf31d..9ffc9ee 100644 --- a/src/ncc/Enums/Types/ComposerStabilityTypes.php +++ b/src/ncc/Enums/Types/ComposerStabilityTypes.php @@ -22,15 +22,15 @@ namespace ncc\Enums\Types; - final class ComposerStabilityTypes + enum ComposerStabilityTypes : string { - public const DEV = 'dev'; + case DEV = 'dev'; - public const ALPHA = 'alpha'; + case ALPHA = 'alpha'; - public const BETA = 'beta'; + case BETA = 'beta'; - public const RC = 'rc'; + case RC = 'rc'; - public const STABLE ='stable'; + case STABLE ='stable'; } \ No newline at end of file diff --git a/src/ncc/Objects/ComposerJson.php b/src/ncc/Objects/ComposerJson.php index 39e6fb1..ddf93d4 100644 --- a/src/ncc/Objects/ComposerJson.php +++ b/src/ncc/Objects/ComposerJson.php @@ -192,7 +192,7 @@ public function __construct() { $this->type = ComposerPackageTypes::LIBRARY; - $this->minimum_stability = ComposerStabilityTypes::STABLE; + $this->minimum_stability = ComposerStabilityTypes::STABLE->value; $this->abandoned = false; } From 3db33006b7155b8829bf4f6f8ec1f5c13cdca9a0 Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:24:19 -0400 Subject: [PATCH 029/134] Convert ComposerPackageTypes constants to enum cases --- src/ncc/Enums/Types/ComposerPackageTypes.php | 10 +++++----- src/ncc/Objects/ComposerJson.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ncc/Enums/Types/ComposerPackageTypes.php b/src/ncc/Enums/Types/ComposerPackageTypes.php index 6ecf467..22a8868 100644 --- a/src/ncc/Enums/Types/ComposerPackageTypes.php +++ b/src/ncc/Enums/Types/ComposerPackageTypes.php @@ -22,12 +22,12 @@ namespace ncc\Enums\Types; - final class ComposerPackageTypes + enum ComposerPackageTypes : string { /** * This is the default. It will copy the files to `vendor` */ - public const LIBRARY = 'library'; + case LIBRARY = 'library'; /** * This denotes a project rather than a library. For example @@ -37,7 +37,7 @@ * to provide listings of projects to initialize when creating * a new workspace. */ - public const PROJECT = 'project'; + case PROJECT = 'project'; /** * An empty package that contains requirements and will trigger @@ -45,11 +45,11 @@ * anything to the filesystem. As such, it does not require a * a dist or source key to be installable */ - public const METAPACKAGE = 'metapackage'; + case METAPACKAGE = 'metapackage'; /** * A package of type `composer-plugin` may provide an installer * for other packages that have a custom type. */ - public const COMPOSER_PLUGIN = 'composer-plugin'; + case COMPOSER_PLUGIN = 'composer-plugin'; } \ No newline at end of file diff --git a/src/ncc/Objects/ComposerJson.php b/src/ncc/Objects/ComposerJson.php index ddf93d4..a56975a 100644 --- a/src/ncc/Objects/ComposerJson.php +++ b/src/ncc/Objects/ComposerJson.php @@ -191,7 +191,7 @@ */ public function __construct() { - $this->type = ComposerPackageTypes::LIBRARY; + $this->type = ComposerPackageTypes::LIBRARY->value; $this->minimum_stability = ComposerStabilityTypes::STABLE->value; $this->abandoned = false; } From fd928ffc99b48223d6b0d09e1e7de117dc1982c1 Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:26:16 -0400 Subject: [PATCH 030/134] Convert ComponentDataType constants to enum cases --- src/ncc/Classes/NccExtension/NccCompiler.php | 2 +- src/ncc/Classes/PhpExtension/NccCompiler.php | 4 ++-- src/ncc/Enums/Types/ComponentDataType.php | 20 +++++--------------- src/ncc/Objects/Package/Component.php | 19 +++++++++++-------- 4 files changed, 19 insertions(+), 26 deletions(-) diff --git a/src/ncc/Classes/NccExtension/NccCompiler.php b/src/ncc/Classes/NccExtension/NccCompiler.php index aeb0e31..9d66699 100644 --- a/src/ncc/Classes/NccExtension/NccCompiler.php +++ b/src/ncc/Classes/NccExtension/NccCompiler.php @@ -299,7 +299,7 @@ { $package_writer->addComponent(new Component( Functions::removeBasename($file_path, $this->project_manager->getProjectPath()), - Base64::encode(IO::fread($file_path)), ComponentDataType::BASE64_ENCODED + Base64::encode(IO::fread($file_path)), ComponentDataType::BASE64_ENCODED->value )); } diff --git a/src/ncc/Classes/PhpExtension/NccCompiler.php b/src/ncc/Classes/PhpExtension/NccCompiler.php index b1d1736..e68254a 100644 --- a/src/ncc/Classes/PhpExtension/NccCompiler.php +++ b/src/ncc/Classes/PhpExtension/NccCompiler.php @@ -57,7 +57,7 @@ $stmts, $this->getProjectManager()->getProjectConfiguration()->getAssembly()->getPackage() ); - $component = new Component($component_name, ZiProto::encode($stmts), ComponentDataType::AST); + $component = new Component($component_name, ZiProto::encode($stmts), ComponentDataType::AST->value); $component->addFlag(ComponentFlags::PHP_AST); $pointer = $package_writer->addComponent($component); @@ -73,7 +73,7 @@ Console::outWarning(sprintf('Failed to compile file "%s" with error "%s"', $file_path, $e->getMessage())); } - $component = new Component($component_name, Base64::encode(IO::fread($file_path)), ComponentDataType::BASE64_ENCODED); + $component = new Component($component_name, Base64::encode(IO::fread($file_path)), ComponentDataType::BASE64_ENCODED->value); $component->addFlag(ComponentFlags::PHP_B64); $package_writer->addComponent($component); } diff --git a/src/ncc/Enums/Types/ComponentDataType.php b/src/ncc/Enums/Types/ComponentDataType.php index a1d64b0..f3f4c00 100644 --- a/src/ncc/Enums/Types/ComponentDataType.php +++ b/src/ncc/Enums/Types/ComponentDataType.php @@ -22,35 +22,25 @@ namespace ncc\Enums\Types; - final class ComponentDataType + enum ComponentDataType : string { /** * Indicates whether the component is represented as an AST representation */ - public const AST = 'ast'; + case AST = 'ast'; /** * Indicates whether the component is represented as plaintext */ - public const PLAIN = 'plain'; + case PLAIN = 'plain'; /** * Indicates whether the component is represented as binary or executable */ - public const BINARY = 'binary'; + case BINARY = 'binary'; /** * Indicates whether the component is represented as as a base64 encoded string (Raw bytes' representation) */ - public const BASE64_ENCODED = 'b64enc'; - - /** - * All the possible data types of a component - */ - public const ALL = [ - self::AST, - self::PLAIN, - self::BINARY, - self::BASE64_ENCODED - ]; + case BASE64_ENCODED = 'b64enc'; } \ No newline at end of file diff --git a/src/ncc/Objects/Package/Component.php b/src/ncc/Objects/Package/Component.php index 20416f2..cc2e6a0 100644 --- a/src/ncc/Objects/Package/Component.php +++ b/src/ncc/Objects/Package/Component.php @@ -66,7 +66,8 @@ * @param string $data * @param string $data_type */ - public function __construct(string $name, string $data, string $data_type=ComponentDataType::PLAIN) + // TODO: $data_type Can be a enum case + public function __construct(string $name, string $data, string $data_type=ComponentDataType::PLAIN->value) { $this->name = $name; $this->flags = []; @@ -167,11 +168,11 @@ { switch($this->data_type) { - case ComponentDataType::PLAIN: - case ComponentDataType::BINARY: + case ComponentDataType::PLAIN->value: + case ComponentDataType::BINARY->value: return $this->data; - case ComponentDataType::BASE64_ENCODED: + case ComponentDataType::BASE64_ENCODED->value: if(in_array(ComponentFlags::PHP_B64, $this->flags, true)) { try @@ -191,7 +192,7 @@ return base64_decode($this->data); - case ComponentDataType::AST: + case ComponentDataType::AST->value: if(in_array(ComponentFlags::PHP_AST, $this->flags, true)) { try @@ -222,11 +223,13 @@ * @param mixed $data * @param string $data_type */ - public function setData(mixed $data, string $data_type=ComponentDataType::PLAIN): void + // TODO: $data_type can be a direct enum case + public function setData(mixed $data, string $data_type=ComponentDataType::PLAIN->value): void { $data_type = strtolower($data_type); - if(!in_array($data_type, ComponentDataType::ALL, true)) + // TODO: Update this, not a proper use of the cases() method + if(!in_array($data_type, ComponentDataType::cases(), true)) { throw new InvalidArgumentException(sprintf('Unknown component data type "%s"', $data_type)); } @@ -262,7 +265,7 @@ { $name = Functions::array_bc($data, 'name'); $component_data = Functions::array_bc($data, 'data'); - $data_type = Functions::array_bc($data, 'data_type') ?? ComponentDataType::PLAIN; + $data_type = Functions::array_bc($data, 'data_type') ?? ComponentDataType::PLAIN->value; if($name === null) { From e11f95a22ab82c3b46e3ca9e488dcce8838decf8 Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:26:30 -0400 Subject: [PATCH 031/134] Removed BuiltinRemoteSourceType --- .../Enums/Types/BuiltinRemoteSourceType.php | 37 ------------------- 1 file changed, 37 deletions(-) delete mode 100644 src/ncc/Enums/Types/BuiltinRemoteSourceType.php diff --git a/src/ncc/Enums/Types/BuiltinRemoteSourceType.php b/src/ncc/Enums/Types/BuiltinRemoteSourceType.php deleted file mode 100644 index 8371419..0000000 --- a/src/ncc/Enums/Types/BuiltinRemoteSourceType.php +++ /dev/null @@ -1,37 +0,0 @@ - Date: Sat, 14 Sep 2024 08:28:04 -0400 Subject: [PATCH 032/134] Convert BuildOutputType constants to enum cases --- .../Classes/PhpExtension/Templates/CliTemplate.php | 4 ++-- src/ncc/Enums/Types/BuildOutputType.php | 6 +++--- src/ncc/Managers/ProjectManager.php | 12 ++++++------ .../Build/BuildConfiguration.php | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php b/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php index 33d1e4e..2d834dd 100644 --- a/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php +++ b/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php @@ -59,7 +59,7 @@ $release_executable = new BuildConfiguration('release_executable', 'build' . DIRECTORY_SEPARATOR . 'release' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_NAME ); - $release_executable->setBuildType(BuildOutputType::EXECUTABLE); + $release_executable->setBuildType(BuildOutputType::EXECUTABLE->value); $release_executable->setOption(BuildConfigurationOptions::NCC_CONFIGURATION, 'release'); $project_manager->getProjectConfiguration()->getBuild()->addBuildConfiguration($release_executable); @@ -68,7 +68,7 @@ 'build' . DIRECTORY_SEPARATOR . 'debug' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_NAME ); $debug_executable->setDefinedConstant('DEBUG', '1'); - $debug_executable->setBuildType(BuildOutputType::EXECUTABLE); + $debug_executable->setBuildType(BuildOutputType::EXECUTABLE->value); $debug_executable->setOption(BuildConfigurationOptions::NCC_CONFIGURATION, 'debug'); $project_manager->getProjectConfiguration()->getBuild()->addBuildConfiguration($debug_executable); diff --git a/src/ncc/Enums/Types/BuildOutputType.php b/src/ncc/Enums/Types/BuildOutputType.php index 3bb413a..4336126 100644 --- a/src/ncc/Enums/Types/BuildOutputType.php +++ b/src/ncc/Enums/Types/BuildOutputType.php @@ -22,8 +22,8 @@ namespace ncc\Enums\Types; - final class BuildOutputType + enum BuildOutputType : string { - public const NCC_PACKAGE = 'ncc'; - public const EXECUTABLE = 'executable'; + case NCC_PACKAGE = 'ncc'; + case EXECUTABLE = 'executable'; } \ No newline at end of file diff --git a/src/ncc/Managers/ProjectManager.php b/src/ncc/Managers/ProjectManager.php index c33b5a8..f5b60ac 100644 --- a/src/ncc/Managers/ProjectManager.php +++ b/src/ncc/Managers/ProjectManager.php @@ -162,8 +162,8 @@ { CompilerExtensions::PHP->value => match (strtolower($configuration->getBuildType())) { - BuildOutputType::NCC_PACKAGE => (new NccCompiler($this))->build($build_configuration, $options), - BuildOutputType::EXECUTABLE => (new ExecutableCompiler($this))->build($build_configuration, $options), + BuildOutputType::NCC_PACKAGE->value => (new NccCompiler($this))->build($build_configuration, $options), + BuildOutputType::EXECUTABLE->value => (new ExecutableCompiler($this))->build($build_configuration, $options), default => throw new BuildException(sprintf('php cannot produce the build type \'%s\'', $configuration->getBuildType())), }, @@ -618,14 +618,14 @@ $ncc_debug_configuration = new ProjectConfiguration\Build\BuildConfiguration('debug_ncc', 'build' . DIRECTORY_SEPARATOR . 'debug' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_PACKAGE ); - $ncc_debug_configuration->setBuildType(BuildOutputType::NCC_PACKAGE); + $ncc_debug_configuration->setBuildType(BuildOutputType::NCC_PACKAGE->value); $ncc_debug_configuration->setDependencies($require_dev); $build->addBuildConfiguration($ncc_debug_configuration); $executable_debug_configuration = new ProjectConfiguration\Build\BuildConfiguration('debug_executable', 'build' . DIRECTORY_SEPARATOR . 'debug' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_NAME ); - $executable_debug_configuration->setBuildType(BuildOutputType::EXECUTABLE); + $executable_debug_configuration->setBuildType(BuildOutputType::EXECUTABLE->value); $executable_debug_configuration->setOption(BuildConfigurationOptions::NCC_CONFIGURATION, 'debug_ncc'); $executable_debug_configuration->setDependencies($require_dev); $build->addBuildConfiguration($executable_debug_configuration); @@ -634,14 +634,14 @@ $ncc_release_configuration = new ProjectConfiguration\Build\BuildConfiguration('release_ncc', 'build' . DIRECTORY_SEPARATOR . 'release' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_PACKAGE . 'ncc' ); - $ncc_release_configuration->setBuildType(BuildOutputType::NCC_PACKAGE); + $ncc_release_configuration->setBuildType(BuildOutputType::NCC_PACKAGE->value); $build->addBuildConfiguration($ncc_release_configuration); $executable_release_configuration = new ProjectConfiguration\Build\BuildConfiguration('release_executable', 'build' . DIRECTORY_SEPARATOR . 'release' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_NAME ); $executable_release_configuration->setOption(BuildConfigurationOptions::NCC_CONFIGURATION, 'release_ncc'); - $executable_release_configuration->setBuildType(BuildOutputType::EXECUTABLE); + $executable_release_configuration->setBuildType(BuildOutputType::EXECUTABLE->value); $build->addBuildConfiguration($executable_release_configuration); // Create an update source for the project diff --git a/src/ncc/Objects/ProjectConfiguration/Build/BuildConfiguration.php b/src/ncc/Objects/ProjectConfiguration/Build/BuildConfiguration.php index 94786d9..324e89b 100644 --- a/src/ncc/Objects/ProjectConfiguration/Build/BuildConfiguration.php +++ b/src/ncc/Objects/ProjectConfiguration/Build/BuildConfiguration.php @@ -107,7 +107,7 @@ public function __construct(string $name, string $output) { $this->name = $name; - $this->build_type = BuildOutputType::NCC_PACKAGE; + $this->build_type = BuildOutputType::NCC_PACKAGE->value; $this->output = $output; $this->options = []; $this->define_constants = []; @@ -462,7 +462,7 @@ $object = new BuildConfiguration($name, $output); - $object->build_type = Functions::array_bc($data, 'build_type') ?? BuildOutputType::NCC_PACKAGE; + $object->build_type = Functions::array_bc($data, 'build_type') ?? BuildOutputType::NCC_PACKAGE->value; $object->options = Functions::array_bc($data, 'options') ?? []; $object->define_constants = Functions::array_bc($data, 'define_constants') ?? []; $object->exclude_files = Functions::array_bc($data, 'exclude_files') ?? []; From e02f1f56dc6834d0755d3d316b6e6f7da69338fa Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:30:41 -0400 Subject: [PATCH 033/134] Convert AuthenticationType constants to enum cases --- src/ncc/Classes/GiteaExtension/GiteaRepository.php | 4 ++-- src/ncc/Classes/GithubExtension/GithubRepository.php | 4 ++-- src/ncc/Classes/GitlabExtension/GitlabRepository.php | 4 ++-- src/ncc/Enums/Types/AuthenticationType.php | 6 +++--- src/ncc/Objects/Vault.php | 4 ++-- src/ncc/Objects/Vault/Entry.php | 8 ++++---- src/ncc/Objects/Vault/Password/AccessToken.php | 5 +++-- src/ncc/Objects/Vault/Password/UsernamePassword.php | 5 +++-- 8 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/ncc/Classes/GiteaExtension/GiteaRepository.php b/src/ncc/Classes/GiteaExtension/GiteaRepository.php index 4260a4b..4b46dc6 100644 --- a/src/ncc/Classes/GiteaExtension/GiteaRepository.php +++ b/src/ncc/Classes/GiteaExtension/GiteaRepository.php @@ -473,7 +473,7 @@ { switch($authentication->getAuthenticationType()) { - case AuthenticationType::ACCESS_TOKEN: + case AuthenticationType::ACCESS_TOKEN->value: if($authentication instanceof AccessToken) { $headers[] = 'Authorization: token ' . $authentication->getAccessToken(); @@ -482,7 +482,7 @@ throw new AuthenticationException(sprintf('Invalid authentication type for Access Token, got %s instead', $authentication->getAuthenticationType())); - case AuthenticationType::USERNAME_PASSWORD: + case AuthenticationType::USERNAME_PASSWORD->value: if($authentication instanceof UsernamePassword) { curl_setopt($curl, CURLOPT_USERPWD, $authentication->getUsername() . ':' . $authentication->getPassword()); diff --git a/src/ncc/Classes/GithubExtension/GithubRepository.php b/src/ncc/Classes/GithubExtension/GithubRepository.php index ddccce8..2e48ca0 100644 --- a/src/ncc/Classes/GithubExtension/GithubRepository.php +++ b/src/ncc/Classes/GithubExtension/GithubRepository.php @@ -453,7 +453,7 @@ { switch($authentication->getAuthenticationType()) { - case AuthenticationType::ACCESS_TOKEN: + case AuthenticationType::ACCESS_TOKEN->value: if($authentication instanceof AccessToken) { $headers[] = 'Authorization: Bearer ' . $authentication->getAccessToken(); @@ -461,7 +461,7 @@ } throw new AuthenticationException(sprintf('Invalid authentication type for Access Token, got %s instead', $authentication->getAuthenticationType())); - case AuthenticationType::USERNAME_PASSWORD: + case AuthenticationType::USERNAME_PASSWORD->value: if($authentication instanceof UsernamePassword) { curl_setopt($curl, CURLOPT_USERPWD, $authentication->getUsername() . ':' . $authentication->getPassword()); diff --git a/src/ncc/Classes/GitlabExtension/GitlabRepository.php b/src/ncc/Classes/GitlabExtension/GitlabRepository.php index e1fb48a..4ed9b90 100644 --- a/src/ncc/Classes/GitlabExtension/GitlabRepository.php +++ b/src/ncc/Classes/GitlabExtension/GitlabRepository.php @@ -471,7 +471,7 @@ { switch($authentication->getAuthenticationType()) { - case AuthenticationType::ACCESS_TOKEN: + case AuthenticationType::ACCESS_TOKEN->value: if($authentication instanceof AccessToken) { $headers[] = 'Private-Token: ' . $authentication->getAccessToken(); @@ -480,7 +480,7 @@ throw new AuthenticationException(sprintf('Invalid authentication type for Access Token, got %s instead', $authentication->getAuthenticationType())); - case AuthenticationType::USERNAME_PASSWORD: + case AuthenticationType::USERNAME_PASSWORD->value: if($authentication instanceof UsernamePassword) { curl_setopt($curl, CURLOPT_USERPWD, $authentication->getUsername() . ':' . $authentication->getPassword()); diff --git a/src/ncc/Enums/Types/AuthenticationType.php b/src/ncc/Enums/Types/AuthenticationType.php index bae6013..8d9b8d4 100644 --- a/src/ncc/Enums/Types/AuthenticationType.php +++ b/src/ncc/Enums/Types/AuthenticationType.php @@ -22,15 +22,15 @@ namespace ncc\Enums\Types; - final class AuthenticationType + enum AuthenticationType : int { /** * A combination of a username and password is used for authentication */ - public const USERNAME_PASSWORD = 1; + case USERNAME_PASSWORD = 1; /** * A single private access token is used for authentication */ - public const ACCESS_TOKEN = 2; + case ACCESS_TOKEN = 2; } \ No newline at end of file diff --git a/src/ncc/Objects/Vault.php b/src/ncc/Objects/Vault.php index 1c16fe9..7a1a539 100644 --- a/src/ncc/Objects/Vault.php +++ b/src/ncc/Objects/Vault.php @@ -177,10 +177,10 @@ $input = []; switch($entry->getPassword()->getAuthenticationType()) { - case AuthenticationType::USERNAME_PASSWORD: + case AuthenticationType::USERNAME_PASSWORD->value: $input = ['password' => $password]; break; - case AuthenticationType::ACCESS_TOKEN: + case AuthenticationType::ACCESS_TOKEN->value: $input = ['token' => $password]; break; } diff --git a/src/ncc/Objects/Vault/Entry.php b/src/ncc/Objects/Vault/Entry.php index 29e7cb9..002a0e0 100644 --- a/src/ncc/Objects/Vault/Entry.php +++ b/src/ncc/Objects/Vault/Entry.php @@ -103,7 +103,7 @@ switch($this->password->getAuthenticationType()) { - case AuthenticationType::USERNAME_PASSWORD: + case AuthenticationType::USERNAME_PASSWORD->value: if(!($this->password instanceof UsernamePassword)) { return false; @@ -129,7 +129,7 @@ return $username === $this->password->getUsername() && $password === $this->password->getPassword(); - case AuthenticationType::ACCESS_TOKEN: + case AuthenticationType::ACCESS_TOKEN->value: if(!($this->password instanceof AccessToken)) { return false; @@ -402,8 +402,8 @@ { $self->password = match (Functions::array_bc($password, 'authentication_type')) { - AuthenticationType::USERNAME_PASSWORD => UsernamePassword::fromArray($password), - AuthenticationType::ACCESS_TOKEN => AccessToken::fromArray($password) + AuthenticationType::USERNAME_PASSWORD->value => UsernamePassword::fromArray($password), + AuthenticationType::ACCESS_TOKEN->value => AccessToken::fromArray($password) }; } } diff --git a/src/ncc/Objects/Vault/Password/AccessToken.php b/src/ncc/Objects/Vault/Password/AccessToken.php index 36d5bb1..9794a67 100644 --- a/src/ncc/Objects/Vault/Password/AccessToken.php +++ b/src/ncc/Objects/Vault/Password/AccessToken.php @@ -69,7 +69,8 @@ */ public function getAuthenticationType(): string { - return AuthenticationType::ACCESS_TOKEN; + // TODO: Could return the enum case here + return AuthenticationType::ACCESS_TOKEN->value; } /** @@ -91,7 +92,7 @@ public function toArray(bool $bytecode=false): array { return [ - ($bytecode ? Functions::cbc('authentication_type') : 'authentication_type') => AuthenticationType::ACCESS_TOKEN, + ($bytecode ? Functions::cbc('authentication_type') : 'authentication_type') => AuthenticationType::ACCESS_TOKEN->value, ($bytecode ? Functions::cbc('access_token') : 'access_token') => $this->access_token, ]; } diff --git a/src/ncc/Objects/Vault/Password/UsernamePassword.php b/src/ncc/Objects/Vault/Password/UsernamePassword.php index f88042a..29ed958 100644 --- a/src/ncc/Objects/Vault/Password/UsernamePassword.php +++ b/src/ncc/Objects/Vault/Password/UsernamePassword.php @@ -96,7 +96,8 @@ */ public function getAuthenticationType(): string { - return AuthenticationType::USERNAME_PASSWORD; + // TODO: Could return the enum here + return AuthenticationType::USERNAME_PASSWORD->value; } /** @@ -115,7 +116,7 @@ public function toArray(bool $bytecode=false): array { return [ - ($bytecode ? Functions::cbc('authentication_type') : 'authentication_type') => AuthenticationType::USERNAME_PASSWORD, + ($bytecode ? Functions::cbc('authentication_type') : 'authentication_type') => AuthenticationType::USERNAME_PASSWORD->value, ($bytecode ? Functions::cbc('username') : 'username') => $this->username, ($bytecode ? Functions::cbc('password') : 'password') => $this->password, ]; From 0d9f3d37a3328340b87d22f6bb418c9b8210b144 Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:32:13 -0400 Subject: [PATCH 034/134] Convert RuntimeConstants constants to enum cases --- src/ncc/Classes/NccExtension/ConstantCompiler.php | 10 +++++----- src/ncc/Enums/SpecialConstants/RuntimeConstants.php | 12 ++++++------ .../ProjectConfiguration/ExecutionPolicy/Execute.php | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/ncc/Classes/NccExtension/ConstantCompiler.php b/src/ncc/Classes/NccExtension/ConstantCompiler.php index c485856..14cfdcd 100644 --- a/src/ncc/Classes/NccExtension/ConstantCompiler.php +++ b/src/ncc/Classes/NccExtension/ConstantCompiler.php @@ -257,7 +257,7 @@ if(function_exists('getcwd')) { - $input = str_replace(RuntimeConstants::CWD, getcwd(), $input); + $input = str_replace(RuntimeConstants::CWD->value, getcwd(), $input); } else { @@ -266,7 +266,7 @@ if(function_exists('getmypid')) { - $input = str_replace(RuntimeConstants::PID, getmypid(), $input); + $input = str_replace(RuntimeConstants::PID->value, getmypid(), $input); } else { @@ -275,7 +275,7 @@ if(function_exists('getmyuid')) { - $input = str_replace(RuntimeConstants::UID, getmyuid(), $input); + $input = str_replace(RuntimeConstants::UID->value, getmyuid(), $input); } else { @@ -284,7 +284,7 @@ if(function_exists('getmygid')) { - $input = str_replace(RuntimeConstants::GID, getmygid(), $input); + $input = str_replace(RuntimeConstants::GID->value, getmygid(), $input); } else { @@ -293,7 +293,7 @@ if(function_exists('get_current_user')) { - $input = str_replace(RuntimeConstants::USER, get_current_user(), $input); + $input = str_replace(RuntimeConstants::USER->value, get_current_user(), $input); } else { diff --git a/src/ncc/Enums/SpecialConstants/RuntimeConstants.php b/src/ncc/Enums/SpecialConstants/RuntimeConstants.php index e9a9845..96a4ee4 100644 --- a/src/ncc/Enums/SpecialConstants/RuntimeConstants.php +++ b/src/ncc/Enums/SpecialConstants/RuntimeConstants.php @@ -22,11 +22,11 @@ namespace ncc\Enums\SpecialConstants; - final class RuntimeConstants + enum RuntimeConstants : string { - public const CWD = '%CWD%'; - public const PID = '%PID%'; - public const UID = '%UID%'; - public const GID = '%GID%'; - public const USER = '%USER%'; + case CWD = '%CWD%'; + case PID = '%PID%'; + case UID = '%UID%'; + case GID = '%GID%'; + case USER = '%USER%'; } \ No newline at end of file diff --git a/src/ncc/Objects/ProjectConfiguration/ExecutionPolicy/Execute.php b/src/ncc/Objects/ProjectConfiguration/ExecutionPolicy/Execute.php index 8ff95e2..387afa2 100644 --- a/src/ncc/Objects/ProjectConfiguration/ExecutionPolicy/Execute.php +++ b/src/ncc/Objects/ProjectConfiguration/ExecutionPolicy/Execute.php @@ -81,7 +81,7 @@ public function __construct(string $target, ?string $working_directory=null) { $this->target = $target; - $this->working_directory = $working_directory ?? RuntimeConstants::CWD; + $this->working_directory = $working_directory ?? RuntimeConstants::CWD->value; $this->options = []; $this->environment_variables = []; $this->silent = false; @@ -116,7 +116,7 @@ */ public function getWorkingDirectory(): string { - return $this->working_directory ?? RuntimeConstants::CWD; + return $this->working_directory ?? RuntimeConstants::CWD->value; } /** @@ -127,7 +127,7 @@ */ public function setWorkingDirectory(?string $working_directory): void { - $this->working_directory = $working_directory ?? RuntimeConstants::CWD; + $this->working_directory = $working_directory ?? RuntimeConstants::CWD->value; } /** From 9c06378258998394565da2baf5674f87892720e6 Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:33:13 -0400 Subject: [PATCH 035/134] Convert InstallConstants constants to enum cases --- src/ncc/Classes/NccExtension/ConstantCompiler.php | 8 ++++---- src/ncc/Enums/SpecialConstants/InstallConstants.php | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ncc/Classes/NccExtension/ConstantCompiler.php b/src/ncc/Classes/NccExtension/ConstantCompiler.php index 14cfdcd..62594b8 100644 --- a/src/ncc/Classes/NccExtension/ConstantCompiler.php +++ b/src/ncc/Classes/NccExtension/ConstantCompiler.php @@ -150,10 +150,10 @@ return str_replace( [ - InstallConstants::INSTALL_PATH, - InstallConstants::INSTALL_PATH_BIN, - InstallConstants::INSTALL_PATH_SRC, - InstallConstants::INSTALL_PATH_DATA + InstallConstants::INSTALL_PATH->value, + InstallConstants::INSTALL_PATH_BIN->value, + InstallConstants::INSTALL_PATH_SRC->value, + InstallConstants::INSTALL_PATH_DATA->value ], [ $installation_paths->getInstallationpath(), diff --git a/src/ncc/Enums/SpecialConstants/InstallConstants.php b/src/ncc/Enums/SpecialConstants/InstallConstants.php index 34c587e..5e160b5 100644 --- a/src/ncc/Enums/SpecialConstants/InstallConstants.php +++ b/src/ncc/Enums/SpecialConstants/InstallConstants.php @@ -22,13 +22,13 @@ namespace ncc\Enums\SpecialConstants; - final class InstallConstants + enum InstallConstants : string { - public const INSTALL_PATH = '%INSTALL_PATH%'; + case INSTALL_PATH = '%INSTALL_PATH%'; - public const INSTALL_PATH_BIN = '%INSTALL_PATH.BIN%'; + case INSTALL_PATH_BIN = '%INSTALL_PATH.BIN%'; - public const INSTALL_PATH_SRC = '%INSTALL_PATH.SRC%'; + case INSTALL_PATH_SRC = '%INSTALL_PATH.SRC%'; - public const INSTALL_PATH_DATA = '%INSTALL_PATH.DATA%'; + case INSTALL_PATH_DATA = '%INSTALL_PATH.DATA%'; } \ No newline at end of file From 492548d81f30a0cd696d0cf1968f8d443d12d476 Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:34:34 -0400 Subject: [PATCH 036/134] Convert DateTimeConstants constants to enum cases --- .../Classes/NccExtension/ConstantCompiler.php | 60 +++++++++--------- .../SpecialConstants/DateTimeConstants.php | 62 +++++++++---------- 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/src/ncc/Classes/NccExtension/ConstantCompiler.php b/src/ncc/Classes/NccExtension/ConstantCompiler.php index 62594b8..f551657 100644 --- a/src/ncc/Classes/NccExtension/ConstantCompiler.php +++ b/src/ncc/Classes/NccExtension/ConstantCompiler.php @@ -178,36 +178,36 @@ } return str_replace([ - DateTimeConstants::d, - DateTimeConstants::D, - DateTimeConstants::j, - DateTimeConstants::l, - DateTimeConstants::N, - DateTimeConstants::S, - DateTimeConstants::w, - DateTimeConstants::z, - DateTimeConstants::W, - DateTimeConstants::F, - DateTimeConstants::m, - DateTimeConstants::M, - DateTimeConstants::n, - DateTimeConstants::t, - DateTimeConstants::L, - DateTimeConstants::o, - DateTimeConstants::Y, - DateTimeConstants::y, - DateTimeConstants::a, - DateTimeConstants::A, - DateTimeConstants::B, - DateTimeConstants::g, - DateTimeConstants::G, - DateTimeConstants::h, - DateTimeConstants::H, - DateTimeConstants::i, - DateTimeConstants::s, - DateTimeConstants::c, - DateTimeConstants::r, - DateTimeConstants::u + DateTimeConstants::d->value, + DateTimeConstants::D->value, + DateTimeConstants::j->value, + DateTimeConstants::l->value, + DateTimeConstants::N->value, + DateTimeConstants::S->value, + DateTimeConstants::w->value, + DateTimeConstants::z->value, + DateTimeConstants::W->value, + DateTimeConstants::F->value, + DateTimeConstants::m->value, + DateTimeConstants::M->value, + DateTimeConstants::n->value, + DateTimeConstants::t->value, + DateTimeConstants::L->value, + DateTimeConstants::o->value, + DateTimeConstants::Y->value, + DateTimeConstants::y->value, + DateTimeConstants::a->value, + DateTimeConstants::A->value, + DateTimeConstants::B->value, + DateTimeConstants::g->value, + DateTimeConstants::G->value, + DateTimeConstants::h->value, + DateTimeConstants::H->value, + DateTimeConstants::i->value, + DateTimeConstants::s->value, + DateTimeConstants::c->value, + DateTimeConstants::r->value, + DateTimeConstants::u->value ], [ date('d', $timestamp), diff --git a/src/ncc/Enums/SpecialConstants/DateTimeConstants.php b/src/ncc/Enums/SpecialConstants/DateTimeConstants.php index e6125e2..6075664 100644 --- a/src/ncc/Enums/SpecialConstants/DateTimeConstants.php +++ b/src/ncc/Enums/SpecialConstants/DateTimeConstants.php @@ -22,49 +22,49 @@ namespace ncc\Enums\SpecialConstants; - final class DateTimeConstants + enum DateTimeConstants : string { // Day Format /** * Day of the month, 2 digits with leading zeros */ - public const d = '%d%'; // 01 through 31 + case d = '%d%'; // 01 through 31 /** * A textual representation of a day, three letters */ - public const D = '%D%'; // Mon through Sun + case D = '%D%'; // Mon through Sun /** * Day of the month without leading zeros */ - public const j = '%j%'; // 1 through 31 + case j = '%j%'; // 1 through 31 /** * A full textual representation of the day of the week */ - public const l = '%l%'; // Sunday through Saturday + case l = '%l%'; // Sunday through Saturday /** * ISO 8601 numeric representation of the day of the week */ - public const N = '%N%'; // 1 (Monday) to 7 (Sunday) + case N = '%N%'; // 1 (Monday) to 7 (Sunday) /** * English ordinal suffix for the day of the month, 2 characters */ - public const S = '%S%'; // st, nd, rd, th + case S = '%S%'; // st, nd, rd, th /** * Numeric representation of the day of the week */ - public const w = '%w%'; // 0 (sunday) through 6 (Saturday) + case w = '%w%'; // 0 (sunday) through 6 (Saturday) /** * The day of the year (starting from 0) */ - public const z = '%z%'; // 0 through 365 + case z = '%z%'; // 0 through 365 @@ -73,7 +73,7 @@ /** * ISO 8601 week number of year, weeks starting on Monday */ - public const W = '%W%'; // 42 (42nd week in year) + case W = '%W%'; // 42 (42nd week in year) @@ -82,27 +82,27 @@ /** * A full textual representation of a month, such as January or March */ - public const F = '%F%'; // January through December + case F = '%F%'; // January through December /** * Numeric representation of a month, with leading zeros */ - public const m = '%m%'; // 01 through 12 + case m = '%m%'; // 01 through 12 /** * A short textual representation of a month, three letters */ - public const M = '%M%'; // Jan through Dec + case M = '%M%'; // Jan through Dec /** * Numeric representation of a month, without leading zeros */ - public const n = '%n%'; // 1 through 12 + case n = '%n%'; // 1 through 12 /** * Number of days in the given month */ - public const t = '%t%'; // 28 through 31 + case t = '%t%'; // 28 through 31 @@ -110,73 +110,73 @@ /** * Whether it's a leap year */ - public const L = '%L%'; // 1 (leap year), 0 otherwise + case L = '%L%'; // 1 (leap year), 0 otherwise /** * ISO 8601 week-numbering year. This has the same value as Y, * except that if the ISO week number (W) belongs to the previous * or next year, that year is used instead. */ - public const o = '%o%'; // Same as Y, except that it use week number to decide which year it falls onto + case o = '%o%'; // Same as Y, except that it use week number to decide which year it falls onto /** * A full numeric representation of a year, at least 4 digits, with - for years BCE. */ - public const Y = '%Y%'; // 1991, 2012, 2014, ... + case Y = '%Y%'; // 1991, 2012, 2014, ... /** * A two digit representation of a year */ - public const y = '%y%'; // 91, 12, 14, ... + case y = '%y%'; // 91, 12, 14, ... // Time Format /** * Lowercase Ante meridiem and Post meridiem */ - public const a = '%a%'; // am or pm + case a = '%a%'; // am or pm /** * Uppercase Ante meridiem and Post meridiem */ - public const A = '%A%'; // AM or PM + case A = '%A%'; // AM or PM /** * Swatch Internet time */ - public const B = '%B%'; // 000 through 999 + case B = '%B%'; // 000 through 999 /** * 12-hour format of an hour without leading zeros */ - public const g = '%g%'; // 1 through 12 + case g = '%g%'; // 1 through 12 /** * 24-hour format of an hour without leading zeros */ - public const G = '%G%'; // 0 through 23 + case G = '%G%'; // 0 through 23 /** * 12-hour format of an hour with leading zeros */ - public const h = '%h%'; // 01 through 12 + case h = '%h%'; // 01 through 12 /** * 24-hour format of an hour with leading zeros */ - public const H = '%H%'; // 01 through 23 + case H = '%H%'; // 01 through 23 /** * Minutes with leading zeros */ - public const i = '%i%'; // 01 through 59 + case i = '%i%'; // 01 through 59 /** * Seconds with leading zeros */ - public const s = '%s%'; // 00 through 59 + case s = '%s%'; // 00 through 59 // DateTime format - public const c = '%c%'; // 2004-02-12T15:19:21 - public const r = '%r%'; // Thu, 21 Dec 2000 16:01:07 - public const u = '%u%'; // Unix Timestamp (seconds since Jan 1 1970 00:00:00) + case c = '%c%'; // 2004-02-12T15:19:21 + case r = '%r%'; // Thu, 21 Dec 2000 16:01:07 + case u = '%u%'; // Unix Timestamp (seconds since Jan 1 1970 00:00:00) } \ No newline at end of file From 87a8ca24a1260690fc5bfe55e8906ecb25d96015 Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:35:16 -0400 Subject: [PATCH 037/134] Convert BuildConstants constants to enum cases --- src/ncc/Classes/NccExtension/ConstantCompiler.php | 8 ++++---- src/ncc/Enums/SpecialConstants/BuildConstants.php | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ncc/Classes/NccExtension/ConstantCompiler.php b/src/ncc/Classes/NccExtension/ConstantCompiler.php index f551657..3ecb5b3 100644 --- a/src/ncc/Classes/NccExtension/ConstantCompiler.php +++ b/src/ncc/Classes/NccExtension/ConstantCompiler.php @@ -121,10 +121,10 @@ return str_replace( [ - BuildConstants::COMPILE_TIMESTAMP, - BuildConstants::NCC_BUILD_VERSION, - BuildConstants::NCC_BUILD_FLAGS, - BuildConstants::NCC_BUILD_BRANCH + BuildConstants::COMPILE_TIMESTAMP->value, + BuildConstants::NCC_BUILD_VERSION->value, + BuildConstants::NCC_BUILD_FLAGS->value, + BuildConstants::NCC_BUILD_BRANCH->value ], [ time(), diff --git a/src/ncc/Enums/SpecialConstants/BuildConstants.php b/src/ncc/Enums/SpecialConstants/BuildConstants.php index cd7f66d..21ebbd3 100644 --- a/src/ncc/Enums/SpecialConstants/BuildConstants.php +++ b/src/ncc/Enums/SpecialConstants/BuildConstants.php @@ -22,25 +22,25 @@ namespace ncc\Enums\SpecialConstants; - final class BuildConstants + enum BuildConstants : string { /** * The Unix Timestamp for when the package was compiled */ - public const COMPILE_TIMESTAMP = '%COMPILE_TIMESTAMP%'; + case COMPILE_TIMESTAMP = '%COMPILE_TIMESTAMP%'; /** * The version of NCC that was used to compile the package */ - public const NCC_BUILD_VERSION = '%NCC_BUILD_VERSION%'; + case NCC_BUILD_VERSION = '%NCC_BUILD_VERSION%'; /** * NCC Build Flags exploded into spaces */ - public const NCC_BUILD_FLAGS = '%NCC_BUILD_FLAGS%'; + case NCC_BUILD_FLAGS = '%NCC_BUILD_FLAGS%'; /** * NCC Build Branch */ - public const NCC_BUILD_BRANCH = '%NCC_BUILD_BRANCH%'; + case NCC_BUILD_BRANCH = '%NCC_BUILD_BRANCH%'; } \ No newline at end of file From 21c2405a273bb84779bd680e9fef451033befd7f Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:37:53 -0400 Subject: [PATCH 038/134] Convert AssemblyConstants constants to enum cases --- .../Classes/NccExtension/ConstantCompiler.php | 18 ++++++++--------- .../PhpExtension/Templates/CliTemplate.php | 4 ++-- .../SpecialConstants/AssemblyConstants.php | 20 +++++++++---------- src/ncc/Managers/ProjectManager.php | 12 +++++------ 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/ncc/Classes/NccExtension/ConstantCompiler.php b/src/ncc/Classes/NccExtension/ConstantCompiler.php index 3ecb5b3..27829ac 100644 --- a/src/ncc/Classes/NccExtension/ConstantCompiler.php +++ b/src/ncc/Classes/NccExtension/ConstantCompiler.php @@ -67,10 +67,10 @@ $input = str_replace( [ - AssemblyConstants::ASSEMBLY_NAME, - AssemblyConstants::ASSEMBLY_PACKAGE, - AssemblyConstants::ASSEMBLY_VERSION, - AssemblyConstants::ASSEMBLY_UID + AssemblyConstants::ASSEMBLY_NAME->value, + AssemblyConstants::ASSEMBLY_PACKAGE->value, + AssemblyConstants::ASSEMBLY_VERSION->value, + AssemblyConstants::ASSEMBLY_UID->value ], [ $assembly->getName(), @@ -81,27 +81,27 @@ if($assembly->getDescription() !== null) { - $input = str_replace(AssemblyConstants::ASSEMBLY_DESCRIPTION, $assembly->getDescription(), $input); + $input = str_replace(AssemblyConstants::ASSEMBLY_DESCRIPTION->value, $assembly->getDescription(), $input); } if($assembly->getCompany() !== null) { - $input = str_replace(AssemblyConstants::ASSEMBLY_COMPANY, $assembly->getCompany(), $input); + $input = str_replace(AssemblyConstants::ASSEMBLY_COMPANY->value, $assembly->getCompany(), $input); } if($assembly->getProduct() !== null) { - $input = str_replace(AssemblyConstants::ASSEMBLY_PRODUCT, $assembly->getProduct(), $input); + $input = str_replace(AssemblyConstants::ASSEMBLY_PRODUCT->value, $assembly->getProduct(), $input); } if($assembly->getCopyright() !== null) { - $input = str_replace(AssemblyConstants::ASSEMBLY_COPYRIGHT, $assembly->getCopyright(), $input); + $input = str_replace(AssemblyConstants::ASSEMBLY_COPYRIGHT->value, $assembly->getCopyright(), $input); } if($assembly->getTrademark() !== null) { - $input = str_replace(AssemblyConstants::ASSEMBLY_TRADEMARK, $assembly->getTrademark(), $input); + $input = str_replace(AssemblyConstants::ASSEMBLY_TRADEMARK->value, $assembly->getTrademark(), $input); } return $input; } diff --git a/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php b/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php index 2d834dd..d00766c 100644 --- a/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php +++ b/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php @@ -57,7 +57,7 @@ // Create the release build configuration $release_executable = new BuildConfiguration('release_executable', - 'build' . DIRECTORY_SEPARATOR . 'release' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_NAME + 'build' . DIRECTORY_SEPARATOR . 'release' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_NAME->value ); $release_executable->setBuildType(BuildOutputType::EXECUTABLE->value); $release_executable->setOption(BuildConfigurationOptions::NCC_CONFIGURATION, 'release'); @@ -65,7 +65,7 @@ // Create the debug build configuration $debug_executable = new BuildConfiguration('debug_executable', - 'build' . DIRECTORY_SEPARATOR . 'debug' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_NAME + 'build' . DIRECTORY_SEPARATOR . 'debug' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_NAME->value ); $debug_executable->setDefinedConstant('DEBUG', '1'); $debug_executable->setBuildType(BuildOutputType::EXECUTABLE->value); diff --git a/src/ncc/Enums/SpecialConstants/AssemblyConstants.php b/src/ncc/Enums/SpecialConstants/AssemblyConstants.php index 601fe1e..136765f 100644 --- a/src/ncc/Enums/SpecialConstants/AssemblyConstants.php +++ b/src/ncc/Enums/SpecialConstants/AssemblyConstants.php @@ -22,50 +22,50 @@ namespace ncc\Enums\SpecialConstants; - final class AssemblyConstants + enum AssemblyConstants : string { /** * Assembly's Name Property */ - public const ASSEMBLY_NAME = '%ASSEMBLY.NAME%'; + case ASSEMBLY_NAME = '%ASSEMBLY.NAME%'; /** * Assembly's Package Property */ - public const ASSEMBLY_PACKAGE = '%ASSEMBLY.PACKAGE%'; + case ASSEMBLY_PACKAGE = '%ASSEMBLY.PACKAGE%'; /** * Assembly's Description Property */ - public const ASSEMBLY_DESCRIPTION = '%ASSEMBLY.DESCRIPTION%'; + case ASSEMBLY_DESCRIPTION = '%ASSEMBLY.DESCRIPTION%'; /** * Assembly's Company Property */ - public const ASSEMBLY_COMPANY = '%ASSEMBLY.COMPANY%'; + case ASSEMBLY_COMPANY = '%ASSEMBLY.COMPANY%'; /** * Assembly's Product Property */ - public const ASSEMBLY_PRODUCT = '%ASSEMBLY.PRODUCT%'; + case ASSEMBLY_PRODUCT = '%ASSEMBLY.PRODUCT%'; /** * Assembly's Copyright Property */ - public const ASSEMBLY_COPYRIGHT = '%ASSEMBLY.COPYRIGHT%'; + case ASSEMBLY_COPYRIGHT = '%ASSEMBLY.COPYRIGHT%'; /** * Assembly's Trademark Property */ - public const ASSEMBLY_TRADEMARK = '%ASSEMBLY.TRADEMARK%'; + case ASSEMBLY_TRADEMARK = '%ASSEMBLY.TRADEMARK%'; /** * Assembly's Version Property */ - public const ASSEMBLY_VERSION = '%ASSEMBLY.VERSION%'; + case ASSEMBLY_VERSION = '%ASSEMBLY.VERSION%'; /** * Assembly's UUID property */ - public const ASSEMBLY_UID = '%ASSEMBLY.UID%'; + case ASSEMBLY_UID = '%ASSEMBLY.UID%'; } \ No newline at end of file diff --git a/src/ncc/Managers/ProjectManager.php b/src/ncc/Managers/ProjectManager.php index f5b60ac..2b24520 100644 --- a/src/ncc/Managers/ProjectManager.php +++ b/src/ncc/Managers/ProjectManager.php @@ -406,11 +406,11 @@ // Generate the Debug & Release build configurations $debug_configuration = new ProjectConfiguration\Build\BuildConfiguration('debug', - 'build' . DIRECTORY_SEPARATOR . 'debug' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_PACKAGE . '.ncc' + 'build' . DIRECTORY_SEPARATOR . 'debug' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_PACKAGE->value . '.ncc' ); $debug_configuration->setDefinedConstant('DEBUG', '1'); $build->addBuildConfiguration(new ProjectConfiguration\Build\BuildConfiguration('release', - 'build' . DIRECTORY_SEPARATOR . 'release' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_PACKAGE . '.ncc' + 'build' . DIRECTORY_SEPARATOR . 'release' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_PACKAGE->value . '.ncc' )); $build->addBuildConfiguration($debug_configuration); $build->setDefaultConfiguration('release'); @@ -616,14 +616,14 @@ // Generate debug build configuration $ncc_debug_configuration = new ProjectConfiguration\Build\BuildConfiguration('debug_ncc', - 'build' . DIRECTORY_SEPARATOR . 'debug' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_PACKAGE + 'build' . DIRECTORY_SEPARATOR . 'debug' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_PACKAGE->value ); $ncc_debug_configuration->setBuildType(BuildOutputType::NCC_PACKAGE->value); $ncc_debug_configuration->setDependencies($require_dev); $build->addBuildConfiguration($ncc_debug_configuration); $executable_debug_configuration = new ProjectConfiguration\Build\BuildConfiguration('debug_executable', - 'build' . DIRECTORY_SEPARATOR . 'debug' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_NAME + 'build' . DIRECTORY_SEPARATOR . 'debug' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_NAME->value ); $executable_debug_configuration->setBuildType(BuildOutputType::EXECUTABLE->value); $executable_debug_configuration->setOption(BuildConfigurationOptions::NCC_CONFIGURATION, 'debug_ncc'); @@ -632,13 +632,13 @@ // Generate release build configuration $ncc_release_configuration = new ProjectConfiguration\Build\BuildConfiguration('release_ncc', - 'build' . DIRECTORY_SEPARATOR . 'release' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_PACKAGE . 'ncc' + 'build' . DIRECTORY_SEPARATOR . 'release' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_PACKAGE->value . 'ncc' ); $ncc_release_configuration->setBuildType(BuildOutputType::NCC_PACKAGE->value); $build->addBuildConfiguration($ncc_release_configuration); $executable_release_configuration = new ProjectConfiguration\Build\BuildConfiguration('release_executable', - 'build' . DIRECTORY_SEPARATOR . 'release' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_NAME + 'build' . DIRECTORY_SEPARATOR . 'release' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_NAME->value ); $executable_release_configuration->setOption(BuildConfigurationOptions::NCC_CONFIGURATION, 'release_ncc'); $executable_release_configuration->setBuildType(BuildOutputType::EXECUTABLE->value); From 2efa6654e6234a583529ada633d3f26fdff417dd Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:38:10 -0400 Subject: [PATCH 039/134] Removed RuntimeImportOptions --- .../Enums/Options/RuntimeImportOptions.php | 38 ------------------- 1 file changed, 38 deletions(-) delete mode 100644 src/ncc/Enums/Options/RuntimeImportOptions.php diff --git a/src/ncc/Enums/Options/RuntimeImportOptions.php b/src/ncc/Enums/Options/RuntimeImportOptions.php deleted file mode 100644 index a861b50..0000000 --- a/src/ncc/Enums/Options/RuntimeImportOptions.php +++ /dev/null @@ -1,38 +0,0 @@ - Date: Sat, 14 Sep 2024 08:39:05 -0400 Subject: [PATCH 040/134] Convert ProjectOptions constants to enum cases --- src/ncc/Classes/PhpExtension/Templates/CliTemplate.php | 2 +- src/ncc/Enums/Options/ProjectOptions.php | 4 ++-- src/ncc/Managers/PackageManager.php | 2 +- src/ncc/Objects/ProjectConfiguration/Project.php | 1 + 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php b/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php index d00766c..d28c36c 100644 --- a/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php +++ b/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php @@ -53,7 +53,7 @@ ); $project_manager->getProjectConfiguration()->getBuild()->setMain('main_policy'); - $project_manager->getProjectConfiguration()->getProject()->addOption(ProjectOptions::CREATE_SYMLINK, true); + $project_manager->getProjectConfiguration()->getProject()->addOption(ProjectOptions::CREATE_SYMLINK->value, true); // Create the release build configuration $release_executable = new BuildConfiguration('release_executable', diff --git a/src/ncc/Enums/Options/ProjectOptions.php b/src/ncc/Enums/Options/ProjectOptions.php index 97b9248..d9d6876 100644 --- a/src/ncc/Enums/Options/ProjectOptions.php +++ b/src/ncc/Enums/Options/ProjectOptions.php @@ -22,7 +22,7 @@ namespace ncc\Enums\Options; - final class ProjectOptions + enum ProjectOptions : string { - public const CREATE_SYMLINK = 'create_symlink'; + case CREATE_SYMLINK = 'create_symlink'; } \ No newline at end of file diff --git a/src/ncc/Managers/PackageManager.php b/src/ncc/Managers/PackageManager.php index 52068fa..bcb0f54 100644 --- a/src/ncc/Managers/PackageManager.php +++ b/src/ncc/Managers/PackageManager.php @@ -453,7 +453,7 @@ throw new IOException(sprintf('Failed to add package to package lock file due to an exception: %s', $e->getMessage()), $e); } - if($package_reader->getMetadata()->getOption(ProjectOptions::CREATE_SYMLINK) === null) + if($package_reader->getMetadata()->getOption(ProjectOptions::CREATE_SYMLINK->value) === null) { // Remove the symlink if it exists if($this->package_lock->getEntry($package_reader->getAssembly()->getPackage())->isSymlinkRegistered()) diff --git a/src/ncc/Objects/ProjectConfiguration/Project.php b/src/ncc/Objects/ProjectConfiguration/Project.php index 40d91d3..f708175 100644 --- a/src/ncc/Objects/ProjectConfiguration/Project.php +++ b/src/ncc/Objects/ProjectConfiguration/Project.php @@ -105,6 +105,7 @@ */ public function addOption(string $key, mixed $value): void { + // TODO: Options here could be using ProjectOptions enum $this->options[$key] = $value; } From 87844ab00a32161f7275ce9ed015a407716293c0 Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:41:25 -0400 Subject: [PATCH 041/134] Convert InstallPackageOptions constants to enum cases --- src/ncc/CLI/Management/PackageManagerMenu.php | 6 +++--- src/ncc/Classes/GiteaExtension/GiteaRepository.php | 2 +- src/ncc/Classes/GithubExtension/GithubRepository.php | 2 +- src/ncc/Classes/GitlabExtension/GitlabRepository.php | 2 +- src/ncc/Enums/Options/InstallPackageOptions.php | 8 ++++---- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/ncc/CLI/Management/PackageManagerMenu.php b/src/ncc/CLI/Management/PackageManagerMenu.php index 96343c4..01d61e3 100644 --- a/src/ncc/CLI/Management/PackageManagerMenu.php +++ b/src/ncc/CLI/Management/PackageManagerMenu.php @@ -155,17 +155,17 @@ if(isset($args['reinstall'])) { - $options[InstallPackageOptions::REINSTALL] = true; + $options[InstallPackageOptions::REINSTALL->value] = true; } if(isset($args['prefer-static']) || isset($args['static'])) { - $options[InstallPackageOptions::PREFER_STATIC] = true; + $options[InstallPackageOptions::PREFER_STATIC->value] = true; } if(isset($args['skip-dependencies'])) { - $options[InstallPackageOptions::SKIP_DEPENDENCIES] = true; + $options[InstallPackageOptions::SKIP_DEPENDENCIES->value] = true; } if($authentication !== null) diff --git a/src/ncc/Classes/GiteaExtension/GiteaRepository.php b/src/ncc/Classes/GiteaExtension/GiteaRepository.php index 4b46dc6..1019dc4 100644 --- a/src/ncc/Classes/GiteaExtension/GiteaRepository.php +++ b/src/ncc/Classes/GiteaExtension/GiteaRepository.php @@ -355,7 +355,7 @@ $release, $group, $project)); } - $static_preferred = isset($options[InstallPackageOptions::PREFER_STATIC]); + $static_preferred = isset($options[InstallPackageOptions::PREFER_STATIC->value]); $preferred_asset = null; $fallback_asset = null; diff --git a/src/ncc/Classes/GithubExtension/GithubRepository.php b/src/ncc/Classes/GithubExtension/GithubRepository.php index 2e48ca0..f1d8c62 100644 --- a/src/ncc/Classes/GithubExtension/GithubRepository.php +++ b/src/ncc/Classes/GithubExtension/GithubRepository.php @@ -341,7 +341,7 @@ throw new NetworkException(sprintf('Failed to get release package for %s/%s/%s: No assets found', $group, $project, $release)); } - $static_preferred = isset($options[InstallPackageOptions::PREFER_STATIC]); + $static_preferred = isset($options[InstallPackageOptions::PREFER_STATIC->value]); $preferred_asset = null; $fallback_asset = null; diff --git a/src/ncc/Classes/GitlabExtension/GitlabRepository.php b/src/ncc/Classes/GitlabExtension/GitlabRepository.php index 4ed9b90..566acc6 100644 --- a/src/ncc/Classes/GitlabExtension/GitlabRepository.php +++ b/src/ncc/Classes/GitlabExtension/GitlabRepository.php @@ -340,7 +340,7 @@ ]); $response = self::processHttpResponse($curl, $group, $project); - $static_preferred = isset($options[InstallPackageOptions::PREFER_STATIC]); + $static_preferred = isset($options[InstallPackageOptions::PREFER_STATIC->value]); $preferred_asset = null; $fallback_asset = null; diff --git a/src/ncc/Enums/Options/InstallPackageOptions.php b/src/ncc/Enums/Options/InstallPackageOptions.php index b6d3311..e074245 100644 --- a/src/ncc/Enums/Options/InstallPackageOptions.php +++ b/src/ncc/Enums/Options/InstallPackageOptions.php @@ -22,7 +22,7 @@ namespace ncc\Enums\Options; - final class InstallPackageOptions + enum InstallPackageOptions : string { /** * Skips the installation of dependencies of the package @@ -30,17 +30,17 @@ * @warning This will cause the package to fail to import of * the dependencies are not met */ - public const SKIP_DEPENDENCIES = 'skip_dependencies'; + case SKIP_DEPENDENCIES = 'skip_dependencies'; /** * Reinstall all packages if they are already installed, * Including dependencies if they are being processed. */ - public const REINSTALL = 'reinstall'; + case REINSTALL = 'reinstall'; /** * Installs a static version of the package if it's available * otherwise it will install non-static version */ - public const PREFER_STATIC = 'prefer_static'; + case PREFER_STATIC = 'prefer_static'; } \ No newline at end of file From 2bd2d757fdad89911990dfcea356920dc8ce46ea Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:43:07 -0400 Subject: [PATCH 042/134] Convert InitializeProjectOptions constants to enum cases --- src/ncc/Enums/Options/InitializeProjectOptions.php | 10 +++++----- src/ncc/Managers/PackageManager.php | 4 ++-- src/ncc/Managers/ProjectManager.php | 14 +++++++------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/ncc/Enums/Options/InitializeProjectOptions.php b/src/ncc/Enums/Options/InitializeProjectOptions.php index 9115c48..0c4e408 100644 --- a/src/ncc/Enums/Options/InitializeProjectOptions.php +++ b/src/ncc/Enums/Options/InitializeProjectOptions.php @@ -22,25 +22,25 @@ namespace ncc\Enums\Options; - final class InitializeProjectOptions + enum InitializeProjectOptions : string { /** * A custom path to the project's source directory */ - public const PROJECT_SRC_PATH = 'PROJECT_SRC_PATH'; + case PROJECT_SRC_PATH = 'PROJECT_SRC_PATH'; /** * A boolean option that indicates whether to overwrite the project file if it already exists */ - public const OVERWRITE_PROJECT_FILE = 'OVERWRITE_PROJECT_FILE'; + case OVERWRITE_PROJECT_FILE = 'OVERWRITE_PROJECT_FILE'; /** * Composer Only, used to define the package's real version */ - public const COMPOSER_PACKAGE_VERSION = 'COMPOSER_PACKAGE_VERSION'; + case COMPOSER_PACKAGE_VERSION = 'COMPOSER_PACKAGE_VERSION'; /** * Composer Only, used to define the package's update source */ - public const COMPOSER_REMOTE_SOURCE = 'COMPOSER_REMOTE_SOURCE'; + case COMPOSER_REMOTE_SOURCE = 'COMPOSER_REMOTE_SOURCE'; } \ No newline at end of file diff --git a/src/ncc/Managers/PackageManager.php b/src/ncc/Managers/PackageManager.php index bcb0f54..0f037f0 100644 --- a/src/ncc/Managers/PackageManager.php +++ b/src/ncc/Managers/PackageManager.php @@ -598,8 +598,8 @@ $archive_path = $this->downloadFile($results->getUrl(), PathFinder::getCachePath()); $package_path = $this->buildFromSource($archive_path, [ - InitializeProjectOptions::COMPOSER_PACKAGE_VERSION => $results->getVersion(), - InitializeProjectOptions::COMPOSER_REMOTE_SOURCE => $input->toString() + InitializeProjectOptions::COMPOSER_PACKAGE_VERSION->value => $results->getVersion(), + InitializeProjectOptions::COMPOSER_REMOTE_SOURCE->value => $input->toString() ]); } catch(Exception $e) diff --git a/src/ncc/Managers/ProjectManager.php b/src/ncc/Managers/ProjectManager.php index 2b24520..dca3b4a 100644 --- a/src/ncc/Managers/ProjectManager.php +++ b/src/ncc/Managers/ProjectManager.php @@ -378,7 +378,7 @@ if(is_file($project_path . DIRECTORY_SEPARATOR . 'project.json')) { - if(!isset($options[InitializeProjectOptions::OVERWRITE_PROJECT_FILE])) + if(!isset($options[InitializeProjectOptions::OVERWRITE_PROJECT_FILE->value])) { throw new IOException('A project has already been initialized in \'' . $project_path . DIRECTORY_SEPARATOR . 'project.json' . '\''); } @@ -387,7 +387,7 @@ unlink($project_path . DIRECTORY_SEPARATOR . 'project.json'); } - $project_src = $options[InitializeProjectOptions::PROJECT_SRC_PATH] ?? ('src' . DIRECTORY_SEPARATOR . $name); + $project_src = $options[InitializeProjectOptions::PROJECT_SRC_PATH->value] ?? ('src' . DIRECTORY_SEPARATOR . $name); if(str_ends_with($project_src, DIRECTORY_SEPARATOR)) { $project_src = substr($project_src, 0, -1); @@ -455,7 +455,7 @@ if(is_file($project_file)) { - if(!isset($options[InitializeProjectOptions::OVERWRITE_PROJECT_FILE])) + if(!isset($options[InitializeProjectOptions::OVERWRITE_PROJECT_FILE->value])) { throw new IOException('A project has already been initialized in \'' . $project_file . '\''); } @@ -464,7 +464,7 @@ unlink($project_file); } - if(!isset($options[InitializeProjectOptions::COMPOSER_PACKAGE_VERSION])) + if(!isset($options[InitializeProjectOptions::COMPOSER_PACKAGE_VERSION->value])) { throw new OperationException('Unable to initialize project from composer.json without a version option'); } @@ -489,7 +489,7 @@ $assembly = new ProjectConfiguration\Assembly( Resolver::composerName($composer_json->getName()), Resolver::composerNameToPackage($composer_json->getName()), - $options[InitializeProjectOptions::COMPOSER_PACKAGE_VERSION] + $options[InitializeProjectOptions::COMPOSER_PACKAGE_VERSION->value] ); $assembly->setDescription($composer_json->getDescription()); @@ -645,10 +645,10 @@ $build->addBuildConfiguration($executable_release_configuration); // Create an update source for the project - if(isset($options[InitializeProjectOptions::COMPOSER_REMOTE_SOURCE])) + if(isset($options[InitializeProjectOptions::COMPOSER_REMOTE_SOURCE->value])) { $project->setUpdateSource(new ProjectConfiguration\UpdateSource( - $options[InitializeProjectOptions::COMPOSER_REMOTE_SOURCE], + $options[InitializeProjectOptions::COMPOSER_REMOTE_SOURCE->value], (new RepositoryManager())->getRepository('packagist')->getProjectRepository() )); } From d379956437ae10a9733190ec372f218efb0b65bd Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:44:06 -0400 Subject: [PATCH 043/134] Convert ComponentDecodeOptions constants to enum cases --- src/ncc/Classes/Runtime.php | 2 +- src/ncc/Enums/Options/ComponentDecodeOptions.php | 4 ++-- src/ncc/Managers/PackageManager.php | 2 +- src/ncc/Objects/Package/Component.php | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ncc/Classes/Runtime.php b/src/ncc/Classes/Runtime.php index 2460c83..e14cda4 100644 --- a/src/ncc/Classes/Runtime.php +++ b/src/ncc/Classes/Runtime.php @@ -481,7 +481,7 @@ return match (Resolver::componentType($acquired_file)) { PackageDirectory::RESOURCES->value => self::$imported_packages[$package]->getResource(Resolver::componentName($acquired_file))->getData(), - PackageDirectory::COMPONENTS->value => self::$imported_packages[$package]->getComponent(Resolver::componentName($acquired_file))->getData([ComponentDecodeOptions::AS_FILE]), + PackageDirectory::COMPONENTS->value => self::$imported_packages[$package]->getComponent(Resolver::componentName($acquired_file))->getData([ComponentDecodeOptions::AS_FILE->value]), default => throw new IOException(sprintf('Unable to acquire file "%s" from package "%s" because it is not a resource or component', $path, $package)), }; } diff --git a/src/ncc/Enums/Options/ComponentDecodeOptions.php b/src/ncc/Enums/Options/ComponentDecodeOptions.php index 0a5a217..ca7afba 100644 --- a/src/ncc/Enums/Options/ComponentDecodeOptions.php +++ b/src/ncc/Enums/Options/ComponentDecodeOptions.php @@ -22,7 +22,7 @@ namespace ncc\Enums\Options; - final class ComponentDecodeOptions + enum ComponentDecodeOptions : string { - public const AS_FILE = 'as_file'; + case AS_FILE = 'as_file'; } \ No newline at end of file diff --git a/src/ncc/Managers/PackageManager.php b/src/ncc/Managers/PackageManager.php index 0f037f0..b25cb76 100644 --- a/src/ncc/Managers/PackageManager.php +++ b/src/ncc/Managers/PackageManager.php @@ -672,7 +672,7 @@ IO::fwrite( $bin_path . DIRECTORY_SEPARATOR . $component_name, - $package_reader->getComponent($component_name)->getData([ComponentDecodeOptions::AS_FILE]), 0755 + $package_reader->getComponent($component_name)->getData([ComponentDecodeOptions::AS_FILE->value]), 0755 ); //Console::inlineProgressBar(++$current_step, $total_steps); diff --git a/src/ncc/Objects/Package/Component.php b/src/ncc/Objects/Package/Component.php index cc2e6a0..3a41d7a 100644 --- a/src/ncc/Objects/Package/Component.php +++ b/src/ncc/Objects/Package/Component.php @@ -177,7 +177,7 @@ { try { - if(in_array(ComponentDecodeOptions::AS_FILE, $options, true)) + if(in_array(ComponentDecodeOptions::AS_FILE->value, $options, true)) { return (new Standard())->prettyPrintFile(AstWalker::decodeRecursive(base64_decode($this->data))); } @@ -197,7 +197,7 @@ { try { - if(in_array(ComponentDecodeOptions::AS_FILE, $options, true)) + if(in_array(ComponentDecodeOptions::AS_FILE->value, $options, true)) { return (new Standard())->prettyPrintFile(AstWalker::decodeRecursive(ZiProto::decode($this->data))); } From ae21d98290916abf11d3a078a719c01d1adbb505 Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:45:42 -0400 Subject: [PATCH 044/134] Minor corrections for illegal array key type --- src/ncc/Managers/PackageManager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ncc/Managers/PackageManager.php b/src/ncc/Managers/PackageManager.php index b25cb76..7636d77 100644 --- a/src/ncc/Managers/PackageManager.php +++ b/src/ncc/Managers/PackageManager.php @@ -405,7 +405,7 @@ Console::out(sprintf('Installing package %s=%s', $package_reader->getAssembly()->getPackage(), $package_reader->getAssembly()->getVersion())); if($this->package_lock->entryExists($package_reader->getAssembly()->getPackage(), $package_reader->getAssembly()->getVersion())) { - if(!isset($options[InstallPackageOptions::REINSTALL])) + if(!isset($options[InstallPackageOptions::REINSTALL->value])) { Console::outVerbose(sprintf( 'Package %s=%s is already installed, skipping', @@ -505,7 +505,7 @@ $this->saveLock(); - if(!isset($options[InstallPackageOptions::SKIP_DEPENDENCIES])) + if(!isset($options[InstallPackageOptions::SKIP_DEPENDENCIES->value])) { foreach($this->checkRequiredDependencies($package_reader) as $dependency) { From c24fce2ee585d480a72aab55ed4f7c04714f5997 Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:49:53 -0400 Subject: [PATCH 045/134] Convert BuildConfigurationValues constants to enum cases --- src/ncc/CLI/Commands/BuildCommand.php | 2 +- src/ncc/Classes/NccExtension/NccCompiler.php | 6 ++++-- src/ncc/Classes/PhpExtension/ExecutableCompiler.php | 2 +- src/ncc/Enums/Options/BuildConfigurationValues.php | 6 +++--- src/ncc/Interfaces/CompilerInterface.php | 3 ++- src/ncc/Managers/PackageManager.php | 4 ++-- src/ncc/Managers/ProjectManager.php | 10 +++++----- src/ncc/Objects/ProjectConfiguration.php | 6 +++--- src/ncc/Objects/ProjectConfiguration/Build.php | 4 ++-- 9 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/ncc/CLI/Commands/BuildCommand.php b/src/ncc/CLI/Commands/BuildCommand.php index f2bff4f..c9978cd 100644 --- a/src/ncc/CLI/Commands/BuildCommand.php +++ b/src/ncc/CLI/Commands/BuildCommand.php @@ -92,7 +92,7 @@ // Build the project try { - $build_configuration = $args['config'] ?? $args['c'] ?? BuildConfigurationValues::DEFAULT; + $build_configuration = $args['config'] ?? $args['c'] ?? BuildConfigurationValues::DEFAULT->value; $output = $project_manager->build($build_configuration, $options); } catch (Exception $e) diff --git a/src/ncc/Classes/NccExtension/NccCompiler.php b/src/ncc/Classes/NccExtension/NccCompiler.php index 9d66699..2b152e5 100644 --- a/src/ncc/Classes/NccExtension/NccCompiler.php +++ b/src/ncc/Classes/NccExtension/NccCompiler.php @@ -87,7 +87,8 @@ * @throws PathNotFoundException * @noinspection UnusedFunctionResultInspection */ - public function build(string $build_configuration=BuildConfigurationValues::DEFAULT, array $options=[]): string + // TODO: $build_configuration could use enum case + public function build(string $build_configuration=BuildConfigurationValues::DEFAULT->value, array $options=[]): string { $configuration = $this->project_manager->getProjectConfiguration()->getBuild()->getBuildConfiguration($build_configuration); $configuration->setOptions(array_merge($configuration->getOptions(), $options)); @@ -327,7 +328,8 @@ * @param string $build_configuration * @return void */ - public function processMetadata(PackageWriter $package_writer, string $build_configuration=BuildConfigurationValues::DEFAULT): void + // TODO: $build_configuration could use the enum case + public function processMetadata(PackageWriter $package_writer, string $build_configuration=BuildConfigurationValues::DEFAULT->value): void { $metadata = new Metadata($this->project_manager->getProjectConfiguration()->getProject()->getCompiler()); diff --git a/src/ncc/Classes/PhpExtension/ExecutableCompiler.php b/src/ncc/Classes/PhpExtension/ExecutableCompiler.php index 3b788dc..4fa9f46 100644 --- a/src/ncc/Classes/PhpExtension/ExecutableCompiler.php +++ b/src/ncc/Classes/PhpExtension/ExecutableCompiler.php @@ -41,7 +41,7 @@ * @inheritDoc * @throws BuildException */ - public function build(string $build_configuration = BuildConfigurationValues::DEFAULT, array $options=[]): string + public function build(string $build_configuration = BuildConfigurationValues::DEFAULT->value, array $options=[]): string { $configuration = $this->getProjectManager()->getProjectConfiguration()->getBuild()->getBuildConfiguration($build_configuration); diff --git a/src/ncc/Enums/Options/BuildConfigurationValues.php b/src/ncc/Enums/Options/BuildConfigurationValues.php index 9454e26..7311b25 100644 --- a/src/ncc/Enums/Options/BuildConfigurationValues.php +++ b/src/ncc/Enums/Options/BuildConfigurationValues.php @@ -22,9 +22,9 @@ namespace ncc\Enums\Options; - final class BuildConfigurationValues + enum BuildConfigurationValues : string { - public const DEFAULT = 'default'; + case DEFAULT = 'default'; - public const ALL = 'all'; + case ALL = 'all'; } \ No newline at end of file diff --git a/src/ncc/Interfaces/CompilerInterface.php b/src/ncc/Interfaces/CompilerInterface.php index a34589a..8225603 100644 --- a/src/ncc/Interfaces/CompilerInterface.php +++ b/src/ncc/Interfaces/CompilerInterface.php @@ -41,5 +41,6 @@ * @param array $options Optional. The options to use/override for this build * @return string */ - public function build(string $build_configuration=BuildConfigurationValues::DEFAULT, array $options=[]): string; + // TODO: $build_configuration could use the enum case directly + public function build(string $build_configuration=BuildConfigurationValues::DEFAULT->value, array $options=[]): string; } \ No newline at end of file diff --git a/src/ncc/Managers/PackageManager.php b/src/ncc/Managers/PackageManager.php index 7636d77..dacade0 100644 --- a/src/ncc/Managers/PackageManager.php +++ b/src/ncc/Managers/PackageManager.php @@ -805,7 +805,7 @@ try { $package_path = (new ProjectManager($project_detection->getProjectFilePath()))->build( - BuildConfigurationValues::DEFAULT, + BuildConfigurationValues::DEFAULT->value, [BuildConfigurationOptions::OUTPUT_FILE => PathFinder::getCachePath() . DIRECTORY_SEPARATOR . hash('sha1', $archive) . '.ncc'] ); @@ -829,7 +829,7 @@ { $project_manager = ProjectManager::initializeFromComposer(dirname($project_detection->getProjectFilePath()), $options); $package_path = $project_manager->build( - BuildConfigurationValues::DEFAULT, + BuildConfigurationValues::DEFAULT->value, [BuildConfigurationOptions::OUTPUT_FILE => PathFinder::getCachePath() . DIRECTORY_SEPARATOR . hash('sha1', $archive) . '.ncc'] ); diff --git a/src/ncc/Managers/ProjectManager.php b/src/ncc/Managers/ProjectManager.php index dca3b4a..484eb05 100644 --- a/src/ncc/Managers/ProjectManager.php +++ b/src/ncc/Managers/ProjectManager.php @@ -154,7 +154,7 @@ * @throws NotSupportedException * @throws PathNotFoundException */ - public function build(string $build_configuration=BuildConfigurationValues::DEFAULT, array $options=[]): string + public function build(string $build_configuration=BuildConfigurationValues::DEFAULT->value, array $options=[]): string { $configuration = $this->project_configuration->getBuild()->getBuildConfiguration($build_configuration); @@ -275,7 +275,7 @@ * @throws IOException * @throws PathNotFoundException */ - public function getExecutionUnits(string $build_configuration=BuildConfigurationValues::DEFAULT): array + public function getExecutionUnits(string $build_configuration=BuildConfigurationValues::DEFAULT->value): array { $execution_units = []; @@ -301,7 +301,7 @@ * @return array * @throws NotSupportedException */ - public function getComponents(string $build_configuration=BuildConfigurationValues::DEFAULT): array + public function getComponents(string $build_configuration=BuildConfigurationValues::DEFAULT->value): array { $configuration = $this->project_configuration->getBuild()->getBuildConfiguration($build_configuration); @@ -317,7 +317,7 @@ * @return array * @throws NotSupportedException */ - public function getResources(string $build_configuration=BuildConfigurationValues::DEFAULT): array + public function getResources(string $build_configuration=BuildConfigurationValues::DEFAULT->value): array { $configuration = $this->project_configuration->getBuild()->getBuildConfiguration($build_configuration); @@ -334,7 +334,7 @@ * @param string $build_configuration * @return array */ - public function getRuntimeConstants(string $build_configuration=BuildConfigurationValues::DEFAULT): array + public function getRuntimeConstants(string $build_configuration=BuildConfigurationValues::DEFAULT->value): array { $configuration = $this->project_configuration->getBuild()->getBuildConfiguration($build_configuration); diff --git a/src/ncc/Objects/ProjectConfiguration.php b/src/ncc/Objects/ProjectConfiguration.php index d4121ae..882b621 100644 --- a/src/ncc/Objects/ProjectConfiguration.php +++ b/src/ncc/Objects/ProjectConfiguration.php @@ -206,7 +206,7 @@ * @return string[] * @throws ConfigurationException */ - public function getRequiredExecutionPolicies(string $build_configuration=BuildConfigurationValues::DEFAULT): array + public function getRequiredExecutionPolicies(string $build_configuration=BuildConfigurationValues::DEFAULT->value): array { if(count($this->execution_policies) === 0) { @@ -287,7 +287,7 @@ } } - if($build_configuration === BuildConfigurationValues::ALL) + if($build_configuration === BuildConfigurationValues::ALL->value) { /** @var BuildConfiguration $configuration */ foreach($this->build->getBuildConfigurations() as $configuration) @@ -424,7 +424,7 @@ throw new ConfigurationException(sprintf('Build configuration build.main points to a undefined execution policy "%s"', $this->build->getMain())); } - if($this->build->getMain() === BuildConfigurationValues::ALL) + if($this->build->getMain() === BuildConfigurationValues::ALL->value) { throw new ConfigurationException(sprintf('Build configuration build.main cannot be set to "%s"', BuildConfigurationValues::ALL)); } diff --git a/src/ncc/Objects/ProjectConfiguration/Build.php b/src/ncc/Objects/ProjectConfiguration/Build.php index 82472ae..577d7b7 100644 --- a/src/ncc/Objects/ProjectConfiguration/Build.php +++ b/src/ncc/Objects/ProjectConfiguration/Build.php @@ -115,7 +115,7 @@ public function __construct(string $source_path, ?string $default_configuration=null) { $this->source_path = $source_path; - $this->default_configuration = $default_configuration ?? BuildConfigurationValues::DEFAULT; + $this->default_configuration = $default_configuration ?? BuildConfigurationValues::DEFAULT->value; $this->exclude_files = []; $this->options = []; $this->define_constants = []; @@ -484,7 +484,7 @@ */ public function getBuildConfiguration(string $name): BuildConfiguration { - if($name === BuildConfigurationValues::DEFAULT) + if($name === BuildConfigurationValues::DEFAULT->value) { $name = $this->default_configuration; } From 66e6e1528d850f640696f8bba36a0ff32a35264d Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:53:30 -0400 Subject: [PATCH 046/134] Convert BuildConfigurationOptions constants to enum cases --- src/ncc/CLI/Commands/BuildCommand.php | 2 +- src/ncc/Classes/NccExtension/NccCompiler.php | 20 +++++++++---------- .../PhpExtension/ExecutableCompiler.php | 8 ++++---- .../PhpExtension/Templates/CliTemplate.php | 4 ++-- src/ncc/Classes/Runtime.php | 8 ++++---- .../Options/BuildConfigurationOptions.php | 12 +++++------ src/ncc/Managers/PackageManager.php | 4 ++-- src/ncc/Managers/ProjectManager.php | 6 +++--- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/ncc/CLI/Commands/BuildCommand.php b/src/ncc/CLI/Commands/BuildCommand.php index c9978cd..7abe8ea 100644 --- a/src/ncc/CLI/Commands/BuildCommand.php +++ b/src/ncc/CLI/Commands/BuildCommand.php @@ -75,7 +75,7 @@ if($output_path !== null) { - $options[BuildConfigurationOptions::OUTPUT_FILE] = $output_path; + $options[BuildConfigurationOptions::OUTPUT_FILE->value] = $output_path; } // Load the project diff --git a/src/ncc/Classes/NccExtension/NccCompiler.php b/src/ncc/Classes/NccExtension/NccCompiler.php index 2b152e5..19242b9 100644 --- a/src/ncc/Classes/NccExtension/NccCompiler.php +++ b/src/ncc/Classes/NccExtension/NccCompiler.php @@ -92,12 +92,12 @@ { $configuration = $this->project_manager->getProjectConfiguration()->getBuild()->getBuildConfiguration($build_configuration); $configuration->setOptions(array_merge($configuration->getOptions(), $options)); - $static_dependencies = isset($configuration->getOptions()[BuildConfigurationOptions::STATIC_DEPENDENCIES]); + $static_dependencies = isset($configuration->getOptions()[BuildConfigurationOptions::STATIC_DEPENDENCIES->value]); - if(isset($configuration->getOptions()[BuildConfigurationOptions::OUTPUT_FILE])) + if(isset($configuration->getOptions()[BuildConfigurationOptions::OUTPUT_FILE->value])) { $package_path = ConstantCompiler::compileConstants( - $this->project_manager->getProjectConfiguration(), $configuration->getOptions()[BuildConfigurationOptions::OUTPUT_FILE] + $this->project_manager->getProjectConfiguration(), $configuration->getOptions()[BuildConfigurationOptions::OUTPUT_FILE->value] ); } else @@ -262,10 +262,10 @@ { $package_writer = new PackageWriter($path); - if(isset($build_configuration->getOptions()[BuildConfigurationOptions::COMPRESSION])) + if(isset($build_configuration->getOptions()[BuildConfigurationOptions::COMPRESSION->value])) { $package_writer->addFlag(PackageFlags::COMPRESSION); - switch(strtolower($build_configuration->getOptions()[BuildConfigurationOptions::COMPRESSION])) + switch(strtolower($build_configuration->getOptions()[BuildConfigurationOptions::COMPRESSION->value])) { case BuildConfigurationOptions\CompressionOptions::HIGH: $package_writer->addFlag(PackageFlags::HIGH_COMPRESSION); @@ -280,7 +280,7 @@ break; default: - throw new NotSupportedException(sprintf('The compression level \'%s\' is not supported', $build_configuration->getOptions()[BuildConfigurationOptions::COMPRESSION])); + throw new NotSupportedException(sprintf('The compression level \'%s\' is not supported', $build_configuration->getOptions()[BuildConfigurationOptions::COMPRESSION->value])); } } @@ -340,16 +340,16 @@ $metadata->setInstaller($this->project_manager->getProjectConfiguration()->getInstaller()); // Strip out 'output_file' build artifact. - if(isset($metadata->getOptions()[BuildConfigurationOptions::OUTPUT_FILE])) + if(isset($metadata->getOptions()[BuildConfigurationOptions::OUTPUT_FILE->value])) { - $metadata->removeOption(BuildConfigurationOptions::OUTPUT_FILE); + $metadata->removeOption(BuildConfigurationOptions::OUTPUT_FILE->value); } // Strip out 'static' build artifact, PackageFlags::STATIC_DEPENDENCIES is used instead // Making this option redundant. - if(isset($metadata->getOptions()[BuildConfigurationOptions::STATIC_DEPENDENCIES])) + if(isset($metadata->getOptions()[BuildConfigurationOptions::STATIC_DEPENDENCIES->value])) { - $metadata->removeOption(BuildConfigurationOptions::STATIC_DEPENDENCIES); + $metadata->removeOption(BuildConfigurationOptions::STATIC_DEPENDENCIES->value); } /** @noinspection UnusedFunctionResultInspection */ diff --git a/src/ncc/Classes/PhpExtension/ExecutableCompiler.php b/src/ncc/Classes/PhpExtension/ExecutableCompiler.php index 4fa9f46..926fc0a 100644 --- a/src/ncc/Classes/PhpExtension/ExecutableCompiler.php +++ b/src/ncc/Classes/PhpExtension/ExecutableCompiler.php @@ -50,14 +50,14 @@ $configuration->setOptions(array_merge($configuration->getOptions(), $options)); } - if(!isset($configuration->getOptions()[BuildConfigurationOptions::NCC_CONFIGURATION])) + if(!isset($configuration->getOptions()[BuildConfigurationOptions::NCC_CONFIGURATION->value])) { throw new BuildException(sprintf("Unable to compile the binary, the build configuration '%s' does not have a ncc_configuration.", $build_configuration)); } // Build the ncc package first Console::outVerbose('Building ncc package.'); - $ncc_package = parent::build($configuration->getOptions()[BuildConfigurationOptions::NCC_CONFIGURATION]); + $ncc_package = parent::build($configuration->getOptions()[BuildConfigurationOptions::NCC_CONFIGURATION->value]); // Prepare the ncc package for compilation $hex_dump_file = PathFinder::getCachePath() . DIRECTORY_SEPARATOR . $this->getProjectManager()->getProjectConfiguration()->getAssembly()->getName() . '.c'; @@ -72,11 +72,11 @@ // Prepare the gcc command $gcc_path = (new ExecutableFinder())->find('gcc'); - if(isset($configuration->getOptions()[BuildConfigurationOptions::OUTPUT_FILE])) + if(isset($configuration->getOptions()[BuildConfigurationOptions::OUTPUT_FILE->value])) { $binary_path = ConstantCompiler::compileConstants( $this->getProjectManager()->getProjectConfiguration(), - $configuration->getOptions()[BuildConfigurationOptions::OUTPUT_FILE] + $configuration->getOptions()[BuildConfigurationOptions::OUTPUT_FILE->value] ); } else diff --git a/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php b/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php index d28c36c..7f9426a 100644 --- a/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php +++ b/src/ncc/Classes/PhpExtension/Templates/CliTemplate.php @@ -60,7 +60,7 @@ 'build' . DIRECTORY_SEPARATOR . 'release' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_NAME->value ); $release_executable->setBuildType(BuildOutputType::EXECUTABLE->value); - $release_executable->setOption(BuildConfigurationOptions::NCC_CONFIGURATION, 'release'); + $release_executable->setOption(BuildConfigurationOptions::NCC_CONFIGURATION->value, 'release'); $project_manager->getProjectConfiguration()->getBuild()->addBuildConfiguration($release_executable); // Create the debug build configuration @@ -69,7 +69,7 @@ ); $debug_executable->setDefinedConstant('DEBUG', '1'); $debug_executable->setBuildType(BuildOutputType::EXECUTABLE->value); - $debug_executable->setOption(BuildConfigurationOptions::NCC_CONFIGURATION, 'debug'); + $debug_executable->setOption(BuildConfigurationOptions::NCC_CONFIGURATION->value, 'debug'); $project_manager->getProjectConfiguration()->getBuild()->addBuildConfiguration($debug_executable); self::writeProgramTemplate($project_manager); diff --git a/src/ncc/Classes/Runtime.php b/src/ncc/Classes/Runtime.php index e14cda4..f9b72fb 100644 --- a/src/ncc/Classes/Runtime.php +++ b/src/ncc/Classes/Runtime.php @@ -189,9 +189,9 @@ self::$class_map[strtolower($class)] = $component_path; } - if($entry->getMetadata($version)->getOption(BuildConfigurationOptions::REQUIRE_FILES) !== null) + if($entry->getMetadata($version)->getOption(BuildConfigurationOptions::REQUIRE_FILES->value) !== null) { - foreach($entry->getMetadata($version)->getOption(BuildConfigurationOptions::REQUIRE_FILES) as $item) + foreach($entry->getMetadata($version)->getOption(BuildConfigurationOptions::REQUIRE_FILES->value) as $item) { try { @@ -273,9 +273,9 @@ } // Import the required files - if($package_reader->getMetadata()->getOption(BuildConfigurationOptions::REQUIRE_FILES) !== null) + if($package_reader->getMetadata()->getOption(BuildConfigurationOptions::REQUIRE_FILES->value) !== null) { - foreach($package_reader->getMetadata()->getOption(BuildConfigurationOptions::REQUIRE_FILES) as $item) + foreach($package_reader->getMetadata()->getOption(BuildConfigurationOptions::REQUIRE_FILES->value) as $item) { try { diff --git a/src/ncc/Enums/Options/BuildConfigurationOptions.php b/src/ncc/Enums/Options/BuildConfigurationOptions.php index 7876e20..2226c2a 100644 --- a/src/ncc/Enums/Options/BuildConfigurationOptions.php +++ b/src/ncc/Enums/Options/BuildConfigurationOptions.php @@ -22,15 +22,15 @@ namespace ncc\Enums\Options; - final class BuildConfigurationOptions + enum BuildConfigurationOptions : string { - public const COMPRESSION = 'compression'; + case COMPRESSION = 'compression'; - public const REQUIRE_FILES = 'require_files'; + case REQUIRE_FILES = 'require_files'; - public const NCC_CONFIGURATION = 'ncc_configuration'; + case NCC_CONFIGURATION = 'ncc_configuration'; - public const OUTPUT_FILE = 'output_file'; + case OUTPUT_FILE = 'output_file'; - public const STATIC_DEPENDENCIES = 'static'; + case STATIC_DEPENDENCIES = 'static'; } \ No newline at end of file diff --git a/src/ncc/Managers/PackageManager.php b/src/ncc/Managers/PackageManager.php index dacade0..3dc9487 100644 --- a/src/ncc/Managers/PackageManager.php +++ b/src/ncc/Managers/PackageManager.php @@ -806,7 +806,7 @@ { $package_path = (new ProjectManager($project_detection->getProjectFilePath()))->build( BuildConfigurationValues::DEFAULT->value, - [BuildConfigurationOptions::OUTPUT_FILE => PathFinder::getCachePath() . DIRECTORY_SEPARATOR . hash('sha1', $archive) . '.ncc'] + [BuildConfigurationOptions::OUTPUT_FILE->value => PathFinder::getCachePath() . DIRECTORY_SEPARATOR . hash('sha1', $archive) . '.ncc'] ); ShutdownHandler::declareTemporaryPath($source_directory); @@ -830,7 +830,7 @@ $project_manager = ProjectManager::initializeFromComposer(dirname($project_detection->getProjectFilePath()), $options); $package_path = $project_manager->build( BuildConfigurationValues::DEFAULT->value, - [BuildConfigurationOptions::OUTPUT_FILE => PathFinder::getCachePath() . DIRECTORY_SEPARATOR . hash('sha1', $archive) . '.ncc'] + [BuildConfigurationOptions::OUTPUT_FILE->value => PathFinder::getCachePath() . DIRECTORY_SEPARATOR . hash('sha1', $archive) . '.ncc'] ); ShutdownHandler::declareTemporaryPath($package_path); diff --git a/src/ncc/Managers/ProjectManager.php b/src/ncc/Managers/ProjectManager.php index 484eb05..62800af 100644 --- a/src/ncc/Managers/ProjectManager.php +++ b/src/ncc/Managers/ProjectManager.php @@ -611,7 +611,7 @@ $required_files[$index] = Functions::removeBasename($file, $project_path); } - $build->setOption(BuildConfigurationOptions::REQUIRE_FILES, $required_files); + $build->setOption(BuildConfigurationOptions::REQUIRE_FILES->value, $required_files); } // Generate debug build configuration @@ -626,7 +626,7 @@ 'build' . DIRECTORY_SEPARATOR . 'debug' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_NAME->value ); $executable_debug_configuration->setBuildType(BuildOutputType::EXECUTABLE->value); - $executable_debug_configuration->setOption(BuildConfigurationOptions::NCC_CONFIGURATION, 'debug_ncc'); + $executable_debug_configuration->setOption(BuildConfigurationOptions::NCC_CONFIGURATION->value, 'debug_ncc'); $executable_debug_configuration->setDependencies($require_dev); $build->addBuildConfiguration($executable_debug_configuration); @@ -640,7 +640,7 @@ $executable_release_configuration = new ProjectConfiguration\Build\BuildConfiguration('release_executable', 'build' . DIRECTORY_SEPARATOR . 'release' . DIRECTORY_SEPARATOR . AssemblyConstants::ASSEMBLY_NAME->value ); - $executable_release_configuration->setOption(BuildConfigurationOptions::NCC_CONFIGURATION, 'release_ncc'); + $executable_release_configuration->setOption(BuildConfigurationOptions::NCC_CONFIGURATION->value, 'release_ncc'); $executable_release_configuration->setBuildType(BuildOutputType::EXECUTABLE->value); $build->addBuildConfiguration($executable_release_configuration); From ac81f2f26d719defdbdb503d70bea8d092d27e4d Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:54:14 -0400 Subject: [PATCH 047/134] Convert CompressionOptions constants to enum cases --- src/ncc/Classes/NccExtension/NccCompiler.php | 6 +++--- .../BuildConfigurationOptions/CompressionOptions.php | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ncc/Classes/NccExtension/NccCompiler.php b/src/ncc/Classes/NccExtension/NccCompiler.php index 19242b9..2c62b57 100644 --- a/src/ncc/Classes/NccExtension/NccCompiler.php +++ b/src/ncc/Classes/NccExtension/NccCompiler.php @@ -267,15 +267,15 @@ $package_writer->addFlag(PackageFlags::COMPRESSION); switch(strtolower($build_configuration->getOptions()[BuildConfigurationOptions::COMPRESSION->value])) { - case BuildConfigurationOptions\CompressionOptions::HIGH: + case BuildConfigurationOptions\CompressionOptions::HIGH->value: $package_writer->addFlag(PackageFlags::HIGH_COMPRESSION); break; - case BuildConfigurationOptions\CompressionOptions::MEDIUM: + case BuildConfigurationOptions\CompressionOptions::MEDIUM->value: $package_writer->addFlag(PackageFlags::MEDIUM_COMPRESSION); break; - case BuildConfigurationOptions\CompressionOptions::LOW: + case BuildConfigurationOptions\CompressionOptions::LOW->value: $package_writer->addFlag(PackageFlags::LOW_COMPRESSION); break; diff --git a/src/ncc/Enums/Options/BuildConfigurationOptions/CompressionOptions.php b/src/ncc/Enums/Options/BuildConfigurationOptions/CompressionOptions.php index 102c2ab..6ee68f8 100644 --- a/src/ncc/Enums/Options/BuildConfigurationOptions/CompressionOptions.php +++ b/src/ncc/Enums/Options/BuildConfigurationOptions/CompressionOptions.php @@ -22,11 +22,11 @@ namespace ncc\Enums\Options\BuildConfigurationOptions; - final class CompressionOptions + enum CompressionOptions : string { - public const HIGH = 'high'; + case HIGH = 'high'; - public const MEDIUM = 'medium'; + case MEDIUM = 'medium'; - public const LOW = 'low'; + case LOW = 'low'; } \ No newline at end of file From 0c4ef17bbf28bcccf931886e88da8b11ff36a26d Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:56:40 -0400 Subject: [PATCH 048/134] Convert PackageFlags constants to enum cases --- src/ncc/Classes/NccExtension/NccCompiler.php | 10 +++++----- src/ncc/Classes/PackageReader.php | 2 +- src/ncc/Classes/PackageWriter.php | 9 +++++---- src/ncc/Classes/Runtime.php | 4 ++-- src/ncc/Enums/Flags/PackageFlags.php | 12 ++++++------ 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/ncc/Classes/NccExtension/NccCompiler.php b/src/ncc/Classes/NccExtension/NccCompiler.php index 2c62b57..1c4f9d4 100644 --- a/src/ncc/Classes/NccExtension/NccCompiler.php +++ b/src/ncc/Classes/NccExtension/NccCompiler.php @@ -119,7 +119,7 @@ { // Add the static dependencies flag so that the package manager // Won't try to resolve the dependencies from the system. - $package_writer->addFlag(PackageFlags::STATIC_DEPENDENCIES); + $package_writer->addFlag(PackageFlags::STATIC_DEPENDENCIES->value); } // Debugging information @@ -264,19 +264,19 @@ if(isset($build_configuration->getOptions()[BuildConfigurationOptions::COMPRESSION->value])) { - $package_writer->addFlag(PackageFlags::COMPRESSION); + $package_writer->addFlag(PackageFlags::COMPRESSION->value); switch(strtolower($build_configuration->getOptions()[BuildConfigurationOptions::COMPRESSION->value])) { case BuildConfigurationOptions\CompressionOptions::HIGH->value: - $package_writer->addFlag(PackageFlags::HIGH_COMPRESSION); + $package_writer->addFlag(PackageFlags::HIGH_COMPRESSION->value); break; case BuildConfigurationOptions\CompressionOptions::MEDIUM->value: - $package_writer->addFlag(PackageFlags::MEDIUM_COMPRESSION); + $package_writer->addFlag(PackageFlags::MEDIUM_COMPRESSION->value); break; case BuildConfigurationOptions\CompressionOptions::LOW->value: - $package_writer->addFlag(PackageFlags::LOW_COMPRESSION); + $package_writer->addFlag(PackageFlags::LOW_COMPRESSION->value); break; default: diff --git a/src/ncc/Classes/PackageReader.php b/src/ncc/Classes/PackageReader.php index e61b5a8..83d0857 100644 --- a/src/ncc/Classes/PackageReader.php +++ b/src/ncc/Classes/PackageReader.php @@ -263,7 +263,7 @@ $location = explode(':', $this->headers[PackageStructure::DIRECTORY->value][$name]); fseek($this->package_file, ($this->data_offset + (int)$location[0])); - if(in_array(PackageFlags::COMPRESSION, $this->headers[PackageStructure::FLAGS->value], true)) + if(in_array(PackageFlags::COMPRESSION->value, $this->headers[PackageStructure::FLAGS->value], true)) { return gzuncompress(fread($this->package_file, (int)$location[1])); } diff --git a/src/ncc/Classes/PackageWriter.php b/src/ncc/Classes/PackageWriter.php index 3e53fb9..d17f8d0 100644 --- a/src/ncc/Classes/PackageWriter.php +++ b/src/ncc/Classes/PackageWriter.php @@ -174,6 +174,7 @@ * @return void * @throws IOException */ + // TODO: Package flags should use the PackageFlags enum directly. public function addFlag(string $flag): void { if($this->data_written) @@ -218,17 +219,17 @@ return explode(':', $this->headers[PackageStructure::DIRECTORY->value][$name]); } - if(in_array(PackageFlags::COMPRESSION, $this->headers[PackageStructure::FLAGS->value], true)) + if(in_array(PackageFlags::COMPRESSION->value, $this->headers[PackageStructure::FLAGS->value], true)) { - if(in_array(PackageFlags::LOW_COMPRESSION, $this->headers[PackageStructure::FLAGS->value], true)) + if(in_array(PackageFlags::LOW_COMPRESSION->value, $this->headers[PackageStructure::FLAGS->value], true)) { $data = gzcompress($data, 1); } - else if(in_array(PackageFlags::MEDIUM_COMPRESSION, $this->headers[PackageStructure::FLAGS->value], true)) + else if(in_array(PackageFlags::MEDIUM_COMPRESSION->value, $this->headers[PackageStructure::FLAGS->value], true)) { $data = gzcompress($data, 6); } - else if(in_array(PackageFlags::HIGH_COMPRESSION, $this->headers[PackageStructure::FLAGS->value], true)) + else if(in_array(PackageFlags::HIGH_COMPRESSION->value, $this->headers[PackageStructure::FLAGS->value], true)) { $data = gzcompress($data, 9); } diff --git a/src/ncc/Classes/Runtime.php b/src/ncc/Classes/Runtime.php index f9b72fb..6675bca 100644 --- a/src/ncc/Classes/Runtime.php +++ b/src/ncc/Classes/Runtime.php @@ -209,7 +209,7 @@ } } - if(isset($entry->getMetadata($version)->getOptions()[PackageFlags::STATIC_DEPENDENCIES])) + if(isset($entry->getMetadata($version)->getOptions()[PackageFlags::STATIC_DEPENDENCIES->value])) { // Fake import the dependencies foreach($entry->getVersion($version)->getDependencies() as $dependency) @@ -288,7 +288,7 @@ } } - if($package_reader->getFlag(PackageFlags::STATIC_DEPENDENCIES)) + if($package_reader->getFlag(PackageFlags::STATIC_DEPENDENCIES->value)) { // Fake import the dependencies foreach($package_reader->getDependencies() as $dependency_name) diff --git a/src/ncc/Enums/Flags/PackageFlags.php b/src/ncc/Enums/Flags/PackageFlags.php index 7d43294..fe75366 100644 --- a/src/ncc/Enums/Flags/PackageFlags.php +++ b/src/ncc/Enums/Flags/PackageFlags.php @@ -22,15 +22,15 @@ namespace ncc\Enums\Flags; - final class PackageFlags + enum PackageFlags : string { - public const COMPRESSION = 'gzip'; + case COMPRESSION = 'gzip'; - public const LOW_COMPRESSION = 'low_gz`'; + case LOW_COMPRESSION = 'low_gz`'; - public const MEDIUM_COMPRESSION = 'medium_gz'; + case MEDIUM_COMPRESSION = 'medium_gz'; - public const HIGH_COMPRESSION = 'high_gz'; + case HIGH_COMPRESSION = 'high_gz'; - public const STATIC_DEPENDENCIES = 'static_dependencies'; + case STATIC_DEPENDENCIES = 'static_dependencies'; } \ No newline at end of file From 863dffafe751740ecced00b725bbda5f315f3d26 Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:57:21 -0400 Subject: [PATCH 049/134] Convert NccBuildFlags constants to enum cases --- src/ncc/CLI/Main.php | 4 ++-- src/ncc/Enums/Flags/NccBuildFlags.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ncc/CLI/Main.php b/src/ncc/CLI/Main.php index 2ac2899..84ad248 100644 --- a/src/ncc/CLI/Main.php +++ b/src/ncc/CLI/Main.php @@ -125,12 +125,12 @@ Console::outDebug(sprintf('args: %s', json_encode(self::$args, JSON_UNESCAPED_SLASHES))); } - if(in_array(NccBuildFlags::UNSTABLE, NCC_VERSION_FLAGS, true)) + if(in_array(NccBuildFlags::UNSTABLE->value, NCC_VERSION_FLAGS, true)) { Console::outWarning('This is an unstable build of ncc, expect some features to not work as expected'); } - if(in_array(NccBuildFlags::BETA, NCC_VERSION_FLAGS, true)) + if(in_array(NccBuildFlags::BETA->value, NCC_VERSION_FLAGS, true)) { Console::outWarning('This is a beta build of ncc, expect some features to not work as expected'); } diff --git a/src/ncc/Enums/Flags/NccBuildFlags.php b/src/ncc/Enums/Flags/NccBuildFlags.php index 9a7e869..254dfe4 100644 --- a/src/ncc/Enums/Flags/NccBuildFlags.php +++ b/src/ncc/Enums/Flags/NccBuildFlags.php @@ -22,16 +22,16 @@ namespace ncc\Enums\Flags; - final class NccBuildFlags + enum NccBuildFlags : string { /** * Indicates if the build is currently unstable and some features may not work correctly * and can cause errors */ - public const UNSTABLE = 'unstable'; + case UNSTABLE = 'unstable'; /** * Indicates if the build is currently in beta testing phase */ - public const BETA = 'beta'; + case BETA = 'beta'; } \ No newline at end of file From 039147c8a822124b4a0174c0140ae088545d0957 Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 08:58:26 -0400 Subject: [PATCH 050/134] Convert ComponentFlags constants to enum cases --- src/ncc/Classes/PhpExtension/NccCompiler.php | 4 ++-- src/ncc/Enums/Flags/ComponentFlags.php | 14 +++----------- src/ncc/Objects/Package/Component.php | 8 ++++---- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/ncc/Classes/PhpExtension/NccCompiler.php b/src/ncc/Classes/PhpExtension/NccCompiler.php index e68254a..5fe93e5 100644 --- a/src/ncc/Classes/PhpExtension/NccCompiler.php +++ b/src/ncc/Classes/PhpExtension/NccCompiler.php @@ -58,7 +58,7 @@ ); $component = new Component($component_name, ZiProto::encode($stmts), ComponentDataType::AST->value); - $component->addFlag(ComponentFlags::PHP_AST); + $component->addFlag(ComponentFlags::PHP_AST->value); $pointer = $package_writer->addComponent($component); foreach(AstWalker::extractClasses($stmts) as $class) @@ -74,7 +74,7 @@ } $component = new Component($component_name, Base64::encode(IO::fread($file_path)), ComponentDataType::BASE64_ENCODED->value); - $component->addFlag(ComponentFlags::PHP_B64); + $component->addFlag(ComponentFlags::PHP_B64->value); $package_writer->addComponent($component); } } \ No newline at end of file diff --git a/src/ncc/Enums/Flags/ComponentFlags.php b/src/ncc/Enums/Flags/ComponentFlags.php index ab70ad8..dc0770d 100644 --- a/src/ncc/Enums/Flags/ComponentFlags.php +++ b/src/ncc/Enums/Flags/ComponentFlags.php @@ -22,23 +22,15 @@ namespace ncc\Enums\Flags; - final class ComponentFlags + enum ComponentFlags : string { /** * Indicates that the component is the AST of a PHP file encoded with msgpack. */ - public const PHP_AST = 'php_ast'; + case PHP_AST = 'php_ast'; /** * Indicates that the component is a PHP file encoded with base64. */ - public const PHP_B64 = 'php_b64'; - - /** - * All the possible flags of a component - */ - public const ALL = [ - self::PHP_AST, - self::PHP_B64 - ]; + case PHP_B64 = 'php_b64'; } \ No newline at end of file diff --git a/src/ncc/Objects/Package/Component.php b/src/ncc/Objects/Package/Component.php index 3a41d7a..2c96067 100644 --- a/src/ncc/Objects/Package/Component.php +++ b/src/ncc/Objects/Package/Component.php @@ -173,7 +173,7 @@ return $this->data; case ComponentDataType::BASE64_ENCODED->value: - if(in_array(ComponentFlags::PHP_B64, $this->flags, true)) + if(in_array(ComponentFlags::PHP_B64->value, $this->flags, true)) { try { @@ -186,14 +186,14 @@ } catch(Exception $e) { - throw new OperationException(sprintf('Failed to decode component %s with data type %s because the component is corrupted: %s', $this->name, ComponentFlags::PHP_B64, $e->getMessage()), $e->getCode(), $e); + throw new OperationException(sprintf('Failed to decode component %s with data type %s because the component is corrupted: %s', $this->name, ComponentFlags::PHP_B64->value, $e->getMessage()), $e->getCode(), $e); } } return base64_decode($this->data); case ComponentDataType::AST->value: - if(in_array(ComponentFlags::PHP_AST, $this->flags, true)) + if(in_array(ComponentFlags::PHP_AST->value, $this->flags, true)) { try { @@ -206,7 +206,7 @@ } catch(Exception $e) { - throw new OperationException(sprintf('Failed to decode component %s with data type %s because the component is corrupted: %s', $this->name, ComponentFlags::PHP_AST, $e->getMessage()), $e->getCode(), $e); + throw new OperationException(sprintf('Failed to decode component %s with data type %s because the component is corrupted: %s', $this->name, ComponentFlags::PHP_AST->value, $e->getMessage()), $e->getCode(), $e); } } From 9fe2dc48fed08fa6ffa89e5701cbe300f43f396e Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 09:03:15 -0400 Subject: [PATCH 051/134] Updated CHANGELOG.md --- CHANGELOG.md | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0642e47..9b5612c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,10 +14,50 @@ This update introduces a refactored code-base, code quality improvements, and be - Update Scopes to enum and adjust scope checks - Convert Runners class to enum with string cases - Convert RegexPatterns constants to enum cases + - Convert ProjectTemplates constants to enum cases + - Convert PackageStructureVersions constants to enum cases + - Convert PackageStructure constants to enum cases + - Convert PackageDirectory constants to enum cases + - Convert LogLevel constants to enum cases + - Convert FileDescriptor constants to enum cases + - Convert ExceptionCodes constants to enum cases + - Convert ConsoleColors constants to enum cases + - Convert CompilerExtensions constants to enum cases + - Convert RepositoryType constants to enum cases + - Convert RepositoryResultType constants to enum cases + - Convert ProjectType constants to enum cases + - Convert HttpRequestType constants to enum cases + - Convert ComposerStabilityTypes constants to enum cases + - Convert ComposerPackageTypes constants to enum cases + - Convert ComponentDataType constants to enum cases + - Convert BuildOutputType constants to enum cases + - Convert AuthenticationType constants to enum cases + - Convert RuntimeConstants constants to enum cases + - Convert InstallConstants constants to enum cases + - Convert DateTimeConstants constants to enum cases + - Convert BuildConstants constants to enum cases + - Convert AssemblyConstants constants to enum cases + - Convert ProjectOptions constants to enum cases + - Convert InstallPackageOptions constants to enum cases + - Convert InitializeProjectOptions constants to enum cases + - Convert ComponentDecodeOptions constants to enum cases + - Convert BuildConfigurationValues constants to enum cases + - Convert BuildConfigurationOptions constants to enum cases + - Convert CompressionOptions constants to enum cases + - Convert PackageFlags constants to enum cases + - Convert NccBuildFlags constants to enum cases + - Convert ComponentFlags constants to enum cases ### Removed - Removed EncoderType enum file, unused. - + - Removed PackageStandardVersions.php + - Removed ConstantReferences.php + - Removed HttpStatusCodes.php + - Removed CompilerExtensionDefaultVersions.php + - Removed RemoteSourceType + - Removed DependencySourceType + - Removed BuiltinRemoteSourceType + - Removed RuntimeImportOptions ## [2.0.3] - 2023-10-17 From 6482d06ba2718305b937df497ac5377b8d0199bf Mon Sep 17 00:00:00 2001 From: netkas Date: Sat, 14 Sep 2024 09:08:21 -0400 Subject: [PATCH 052/134] Fixed Division by zero in PackageManager --- CHANGELOG.md | 3 +++ src/ncc/Managers/PackageManager.php | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b5612c..1197ac8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,9 @@ This update introduces a refactored code-base, code quality improvements, and be - Convert NccBuildFlags constants to enum cases - Convert ComponentFlags constants to enum cases +### Fixed + - Fixed Division by zero in PackageManager + ### Removed - Removed EncoderType enum file, unused. - Removed PackageStandardVersions.php diff --git a/src/ncc/Managers/PackageManager.php b/src/ncc/Managers/PackageManager.php index 3dc9487..822e924 100644 --- a/src/ncc/Managers/PackageManager.php +++ b/src/ncc/Managers/PackageManager.php @@ -897,12 +897,12 @@ ]); curl_setopt($curl, CURLOPT_PROGRESSFUNCTION, static function ($resource, $download_size, $downloaded) use ($url, &$end, $progress_bar) { - if($download_size === $downloaded && $end) + if($download_size == 0) { return; } - if($download_size === 0) + if($download_size === $downloaded && $end) { return; } @@ -917,7 +917,6 @@ $progress_bar->setMaxValue($download_size); $progress_bar->setValue($downloaded); $progress_bar->setMiscText(sprintf('%s/%s', $downloaded, $download_size)); - $progress_bar->update(); } From 8f87541a64dc4d216c034d9c0783bb62f34c5d0c Mon Sep 17 00:00:00 2001 From: netkas Date: Tue, 17 Sep 2024 15:10:19 -0400 Subject: [PATCH 053/134] Refactor flag handling to use PackageFlags enum directly Updated the NccCompiler and PackageWriter classes to utilize the PackageFlags enum directly rather than its values. This improves type safety and code readability, reducing the chances of runtime errors associated with invalid flag values. --- src/ncc/Classes/NccExtension/NccCompiler.php | 10 ++--- src/ncc/Classes/PackageWriter.php | 46 ++++++++++++++++---- 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/ncc/Classes/NccExtension/NccCompiler.php b/src/ncc/Classes/NccExtension/NccCompiler.php index 1c4f9d4..2c62b57 100644 --- a/src/ncc/Classes/NccExtension/NccCompiler.php +++ b/src/ncc/Classes/NccExtension/NccCompiler.php @@ -119,7 +119,7 @@ { // Add the static dependencies flag so that the package manager // Won't try to resolve the dependencies from the system. - $package_writer->addFlag(PackageFlags::STATIC_DEPENDENCIES->value); + $package_writer->addFlag(PackageFlags::STATIC_DEPENDENCIES); } // Debugging information @@ -264,19 +264,19 @@ if(isset($build_configuration->getOptions()[BuildConfigurationOptions::COMPRESSION->value])) { - $package_writer->addFlag(PackageFlags::COMPRESSION->value); + $package_writer->addFlag(PackageFlags::COMPRESSION); switch(strtolower($build_configuration->getOptions()[BuildConfigurationOptions::COMPRESSION->value])) { case BuildConfigurationOptions\CompressionOptions::HIGH->value: - $package_writer->addFlag(PackageFlags::HIGH_COMPRESSION->value); + $package_writer->addFlag(PackageFlags::HIGH_COMPRESSION); break; case BuildConfigurationOptions\CompressionOptions::MEDIUM->value: - $package_writer->addFlag(PackageFlags::MEDIUM_COMPRESSION->value); + $package_writer->addFlag(PackageFlags::MEDIUM_COMPRESSION); break; case BuildConfigurationOptions\CompressionOptions::LOW->value: - $package_writer->addFlag(PackageFlags::LOW_COMPRESSION->value); + $package_writer->addFlag(PackageFlags::LOW_COMPRESSION); break; default: diff --git a/src/ncc/Classes/PackageWriter.php b/src/ncc/Classes/PackageWriter.php index d17f8d0..fb6e5a1 100644 --- a/src/ncc/Classes/PackageWriter.php +++ b/src/ncc/Classes/PackageWriter.php @@ -25,6 +25,7 @@ namespace ncc\Classes; + use InvalidArgumentException; use ncc\Enums\Flags\PackageFlags; use ncc\Enums\PackageDirectory; use ncc\Enums\PackageStructure; @@ -153,7 +154,7 @@ /** * Sets the package flags * - * @param array $flags + * @param string[]|PackageFlags[] $flags * @return void * @throws IOException */ @@ -164,19 +165,39 @@ throw new IOException('Cannot set flags after data has been written to the package'); } - $this->headers[PackageStructure::FLAGS->value] = $flags; + foreach($flags as $flag) + { + if(is_string($flag)) + { + $flag = PackageFlags::tryFrom($flag); + if($flag === null) + { + throw new InvalidArgumentException(sprintf('Unexpected flag: %s', $flag)); + } + } + + $this->headers[PackageStructure::FLAGS->value] = $flag->value; + } } /** * Adds a flag to the package * - * @param string $flag + * @param PackageFlags|string $flag * @return void * @throws IOException */ - // TODO: Package flags should use the PackageFlags enum directly. - public function addFlag(string $flag): void + public function addFlag(PackageFlags|string $flag): void { + if(is_string($flag)) + { + $flag = PackageFlags::tryFrom($flag); + if($flag === null) + { + throw new InvalidArgumentException(sprintf('Unexpected flag: %s', $flag)); + } + } + if($this->data_written) { throw new IOException('Cannot add a flag after data has been written to the package'); @@ -184,7 +205,7 @@ if(!in_array($flag, $this->headers[PackageStructure::FLAGS->value], true)) { - $this->headers[PackageStructure::FLAGS->value][] = $flag; + $this->headers[PackageStructure::FLAGS->value][] = $flag->value; } } @@ -195,14 +216,23 @@ * @return void * @throws IOException */ - public function removeFlag(string $flag): void + public function removeFlag(PackageFlags|string $flag): void { + if(is_string($flag)) + { + $flag = PackageFlags::tryFrom($flag); + if($flag === null) + { + throw new InvalidArgumentException(sprintf('Unexpected flag: %s', $flag)); + } + } + if($this->data_written) { throw new IOException('Cannot remove a flag after data has been written to the package'); } - $this->headers[PackageStructure::FLAGS->value] = array_diff($this->headers[PackageStructure::FLAGS->value], [$flag]); + $this->headers[PackageStructure::FLAGS->value] = array_diff($this->headers[PackageStructure::FLAGS->value], [$flag->value]); } /** From dfa6b5029918096cbb7f12ce51225a2eaad6df3c Mon Sep 17 00:00:00 2001 From: netkas Date: Tue, 17 Sep 2024 15:28:15 -0400 Subject: [PATCH 054/134] Bumped version --- src/ncc/version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ncc/version.json b/src/ncc/version.json index bccaf4e..fb64e9d 100644 --- a/src/ncc/version.json +++ b/src/ncc/version.json @@ -1,5 +1,5 @@ { - "version": "2.0.3", + "version": "2.1.0", "branch": "stable", "flags": [], "components": [ From aa65dd73cf8cb973f287785d20fcc8a3c55652fd Mon Sep 17 00:00:00 2001 From: netkas Date: Tue, 17 Sep 2024 15:29:03 -0400 Subject: [PATCH 055/134] Refactor checkLogLevel to correctly utilize LogLevel cases --- src/ncc/Utilities/Validate.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/ncc/Utilities/Validate.php b/src/ncc/Utilities/Validate.php index c89c5ed..5ea09d3 100644 --- a/src/ncc/Utilities/Validate.php +++ b/src/ncc/Utilities/Validate.php @@ -228,13 +228,9 @@ namespace ncc\Utilities; */ public static function checkLogLevel(string $input): bool { - // TODO: Fix this, it's not the proper use of cases() - if(!in_array(strtolower($input), LogLevel::cases())) - { - return false; - } - - return true; + return in_array(strtolower($input), array_map( + fn($case) => $case->value, LogLevel::cases()), true + ); } /** From 714228ad2e08918342504f78ca2a98546311135f Mon Sep 17 00:00:00 2001 From: netkas Date: Tue, 17 Sep 2024 15:29:30 -0400 Subject: [PATCH 056/134] Refactor code to improve readability in Resolver.php --- src/ncc/Utilities/Resolver.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ncc/Utilities/Resolver.php b/src/ncc/Utilities/Resolver.php index 366fc15..e03b5de 100644 --- a/src/ncc/Utilities/Resolver.php +++ b/src/ncc/Utilities/Resolver.php @@ -169,26 +169,25 @@ */ public static function checkLogLevel(?string $input, ?string $current_level): bool { - if($input === null || $current_level === null) + if ($input === null || $current_level === null) { return false; } $input = strtolower($input); - if(!Validate::checkLogLevel($input)) + if (!Validate::checkLogLevel($input)) { return false; } $current_level = strtolower($current_level); - if(!Validate::checkLogLevel($current_level)) + if (!Validate::checkLogLevel($current_level)) { return false; } return match ($current_level) { - // TODO: Move this to the enum LogLevel::DEBUG->value => in_array($input, [LogLevel::DEBUG->value, LogLevel::VERBOSE->value, LogLevel::INFO->value, LogLevel::WARNING->value, LogLevel::FATAL->value, LogLevel::ERROR->value], true), LogLevel::VERBOSE->value => in_array($input, [LogLevel::VERBOSE->value, LogLevel::INFO->value, LogLevel::WARNING->value, LogLevel::FATAL->value, LogLevel::ERROR->value], true), LogLevel::INFO->value => in_array($input, [LogLevel::INFO->value, LogLevel::WARNING->value, LogLevel::FATAL->value, LogLevel::ERROR->value], true), From b29160414584a985f2fd503dfddca40405580c64 Mon Sep 17 00:00:00 2001 From: netkas Date: Tue, 17 Sep 2024 15:29:44 -0400 Subject: [PATCH 057/134] Fix incorrect color formatting in installer output --- src/installer/installer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/installer/installer b/src/installer/installer index 5149901..9605d44 100644 --- a/src/installer/installer +++ b/src/installer/installer @@ -210,7 +210,7 @@ try { - Console::out(Console::formatColor($full_name, ConsoleColors::GREEN->value) . ' Version: ' . Console::formatColor($component->getVersion(), ConsoleColors::LIGHT_MAGENTA)); + Console::out(Console::formatColor($full_name, ConsoleColors::GREEN->value) . ' Version: ' . Console::formatColor($component->getVersion(), ConsoleColors::LIGHT_MAGENTA->value)); } catch (Exception $e) { From 5ea023551500199f3220ab132a14a4c81c320a29 Mon Sep 17 00:00:00 2001 From: netkas Date: Tue, 17 Sep 2024 15:29:54 -0400 Subject: [PATCH 058/134] Update PHP include paths in project configuration --- .idea/php.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.idea/php.xml b/.idea/php.xml index 71b8d6f..b79a929 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -11,8 +11,8 @@ + - From 6398b2958b9af9e8d1a34b8bcd72a4a782e25ca5 Mon Sep 17 00:00:00 2001 From: netkas Date: Tue, 17 Sep 2024 15:35:20 -0400 Subject: [PATCH 059/134] Refactor logging level checks to use LogLevel enum directly --- src/ncc/CLI/Main.php | 16 +++++++++----- src/ncc/Classes/NccExtension/NccCompiler.php | 2 +- .../PhpExtension/ExecutableCompiler.php | 4 ++-- src/ncc/Managers/PackageManager.php | 8 +++---- src/ncc/Utilities/Console.php | 18 ++++++++-------- src/ncc/Utilities/Resolver.php | 21 +++++++++---------- src/ncc/Utilities/Validate.php | 7 ++++++- 7 files changed, 43 insertions(+), 33 deletions(-) diff --git a/src/ncc/CLI/Main.php b/src/ncc/CLI/Main.php index 84ad248..cda1d43 100644 --- a/src/ncc/CLI/Main.php +++ b/src/ncc/CLI/Main.php @@ -114,7 +114,7 @@ self::$log_level = LogLevel::INFO->value; } - if(Resolver::checkLogLevel(self::$log_level, LogLevel::DEBUG->value)) + if(Resolver::checkLogLevel(self::$log_level, LogLevel::DEBUG)) { Console::outDebug('Debug logging enabled'); @@ -230,15 +230,21 @@ } /** - * @return string + * @return LogLevel */ - public static function getLogLevel(): string + public static function getLogLevel(): LogLevel { if(self::$log_level === null) { - self::$log_level = LogLevel::INFO->value; + self::$log_level = LogLevel::INFO; } - return self::$log_level; + $level = LogLevel::tryFrom(self::$log_level); + if($level === null) + { + return self::$log_level = LogLevel::INFO; + } + + return $level; } } \ No newline at end of file diff --git a/src/ncc/Classes/NccExtension/NccCompiler.php b/src/ncc/Classes/NccExtension/NccCompiler.php index 2c62b57..a5bc347 100644 --- a/src/ncc/Classes/NccExtension/NccCompiler.php +++ b/src/ncc/Classes/NccExtension/NccCompiler.php @@ -123,7 +123,7 @@ } // Debugging information - if(Resolver::checkLogLevel(LogLevel::DEBUG->value, Main::getLogLevel())) + if(Resolver::checkLogLevel(LogLevel::DEBUG, Main::getLogLevel())) { foreach($this->project_manager->getProjectConfiguration()->getAssembly()->toArray() as $prop => $value) { diff --git a/src/ncc/Classes/PhpExtension/ExecutableCompiler.php b/src/ncc/Classes/PhpExtension/ExecutableCompiler.php index 926fc0a..2c6d2ce 100644 --- a/src/ncc/Classes/PhpExtension/ExecutableCompiler.php +++ b/src/ncc/Classes/PhpExtension/ExecutableCompiler.php @@ -112,11 +112,11 @@ switch(Main::getLogLevel()) { - case LogLevel::VERBOSE->value: + case LogLevel::VERBOSE: $gcc_options[] = '-v'; break; - case LogLevel::DEBUG->value: + case LogLevel::DEBUG: $gcc_options[] = '-v'; $gcc_options[] = '-v'; break; diff --git a/src/ncc/Managers/PackageManager.php b/src/ncc/Managers/PackageManager.php index 822e924..f8c9437 100644 --- a/src/ncc/Managers/PackageManager.php +++ b/src/ncc/Managers/PackageManager.php @@ -665,7 +665,7 @@ { $progress_bar->setMiscText($component_name); - if(Resolver::checkLogLevel(LogLevel::VERBOSE->value, Main::getLogLevel())) + if(Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) { Console::outVerbose(sprintf('Extracting component %s to %s', $component_name, $bin_path . DIRECTORY_SEPARATOR . $component_name)); } @@ -683,7 +683,7 @@ { $progress_bar->setMiscText($resource_name); - if(Resolver::checkLogLevel(LogLevel::VERBOSE->value, Main::getLogLevel())) + if(Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) { Console::outVerbose(sprintf('Extracting resource %s to %s', $resource_name, $bin_path . DIRECTORY_SEPARATOR . $resource_name)); } @@ -701,7 +701,7 @@ { $progress_bar->setMiscText($unit); - if(Resolver::checkLogLevel(LogLevel::VERBOSE->value, Main::getLogLevel())) + if(Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) { Console::outVerbose(sprintf('Extracting execution unit %s to %s', $unit, $package_path . DIRECTORY_SEPARATOR . 'units' . DIRECTORY_SEPARATOR . $package_reader->getExecutionUnit($unit)->getExecutionPolicy()->getName() . '.unit')); } @@ -907,7 +907,7 @@ return; } - if(Resolver::checkLogLevel(LogLevel::VERBOSE->value, Main::getLogLevel())) + if(Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) { $percentage = round(($downloaded / $download_size) * 100, 2); Console::out(sprintf('Download progress %s (%s/%s) for %s', $percentage, $downloaded, $download_size, $url)); diff --git a/src/ncc/Utilities/Console.php b/src/ncc/Utilities/Console.php index 2734f17..ed1ee1b 100644 --- a/src/ncc/Utilities/Console.php +++ b/src/ncc/Utilities/Console.php @@ -109,12 +109,12 @@ return; } - if(!Resolver::checkLogLevel(LogLevel::INFO->value, Main::getLogLevel())) + if(!Resolver::checkLogLevel(LogLevel::INFO, Main::getLogLevel())) { return; } - if(!$no_prefix && Resolver::checkLogLevel(LogLevel::VERBOSE->value, Main::getLogLevel())) + if(!$no_prefix && Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) { $message = self::setPrefix(LogLevel::INFO->value, $message); } @@ -142,7 +142,7 @@ return; } - if(!Resolver::checkLogLevel(LogLevel::DEBUG->value, Main::getLogLevel())) + if(!Resolver::checkLogLevel(LogLevel::DEBUG, Main::getLogLevel())) { return; } @@ -179,7 +179,7 @@ return; } - if(!Resolver::checkLogLevel(LogLevel::VERBOSE->value, Main::getLogLevel())) + if(!Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) { return; } @@ -225,12 +225,12 @@ return; } - if(!Resolver::checkLogLevel(LogLevel::WARNING->value, Main::getLogLevel())) + if(!Resolver::checkLogLevel(LogLevel::WARNING, Main::getLogLevel())) { return; } - if(Resolver::checkLogLevel(LogLevel::VERBOSE->value, Main::getLogLevel())) + if(Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) { self::out(self::setPrefix(LogLevel::WARNING->value, $message), $newline, true); return; @@ -254,12 +254,12 @@ return; } - if(!Resolver::checkLogLevel(LogLevel::ERROR->value, Main::getLogLevel())) + if(!Resolver::checkLogLevel(LogLevel::ERROR, Main::getLogLevel())) { return; } - if(Resolver::checkLogLevel(LogLevel::VERBOSE->value, Main::getLogLevel())) + if(Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) { self::out(self::setPrefix(LogLevel::ERROR->value, $message), $newline, true); } @@ -289,7 +289,7 @@ return; } - if($message !== '' && Resolver::checkLogLevel(LogLevel::ERROR->value, Main::getLogLevel())) + if($message !== '' && Resolver::checkLogLevel(LogLevel::ERROR, Main::getLogLevel())) { self::out(PHP_EOL . self::formatColor('Error: ', ConsoleColors::RED->value) . $message); } diff --git a/src/ncc/Utilities/Resolver.php b/src/ncc/Utilities/Resolver.php index e03b5de..deb0d4e 100644 --- a/src/ncc/Utilities/Resolver.php +++ b/src/ncc/Utilities/Resolver.php @@ -163,24 +163,23 @@ /** * Checks if the input level matches the current level * - * @param string|null $input - * @param string|null $current_level + * @param LogLevel|null $input + * @param LogLevel|null $current_level * @return bool */ - public static function checkLogLevel(?string $input, ?string $current_level): bool + public static function checkLogLevel(?LogLevel $input, ?LogLevel $current_level): bool { + // TODO: This method can be merged into the enum class instead if ($input === null || $current_level === null) { return false; } - $input = strtolower($input); if (!Validate::checkLogLevel($input)) { return false; } - $current_level = strtolower($current_level); if (!Validate::checkLogLevel($current_level)) { return false; @@ -188,12 +187,12 @@ return match ($current_level) { - LogLevel::DEBUG->value => in_array($input, [LogLevel::DEBUG->value, LogLevel::VERBOSE->value, LogLevel::INFO->value, LogLevel::WARNING->value, LogLevel::FATAL->value, LogLevel::ERROR->value], true), - LogLevel::VERBOSE->value => in_array($input, [LogLevel::VERBOSE->value, LogLevel::INFO->value, LogLevel::WARNING->value, LogLevel::FATAL->value, LogLevel::ERROR->value], true), - LogLevel::INFO->value => in_array($input, [LogLevel::INFO->value, LogLevel::WARNING->value, LogLevel::FATAL->value, LogLevel::ERROR->value], true), - LogLevel::WARNING->value => in_array($input, [LogLevel::WARNING->value, LogLevel::FATAL->value, LogLevel::ERROR->value], true), - LogLevel::ERROR->value => in_array($input, [LogLevel::FATAL->value, LogLevel::ERROR->value], true), - LogLevel::FATAL->value => $input === LogLevel::FATAL->value, + LogLevel::DEBUG => in_array($input, [LogLevel::DEBUG, LogLevel::VERBOSE, LogLevel::INFO, LogLevel::WARNING, LogLevel::FATAL, LogLevel::ERROR], true), + LogLevel::VERBOSE => in_array($input, [LogLevel::VERBOSE, LogLevel::INFO, LogLevel::WARNING, LogLevel::FATAL, LogLevel::ERROR], true), + LogLevel::INFO => in_array($input, [LogLevel::INFO, LogLevel::WARNING, LogLevel::FATAL, LogLevel::ERROR], true), + LogLevel::WARNING => in_array($input, [LogLevel::WARNING, LogLevel::FATAL, LogLevel::ERROR], true), + LogLevel::ERROR => in_array($input, [LogLevel::FATAL, LogLevel::ERROR], true), + LogLevel::FATAL => $input === LogLevel::FATAL, default => false, }; } diff --git a/src/ncc/Utilities/Validate.php b/src/ncc/Utilities/Validate.php index 5ea09d3..1e02c8e 100644 --- a/src/ncc/Utilities/Validate.php +++ b/src/ncc/Utilities/Validate.php @@ -226,8 +226,13 @@ namespace ncc\Utilities; * @param string $input * @return bool */ - public static function checkLogLevel(string $input): bool + public static function checkLogLevel(string|LogLevel $input): bool { + if($input instanceof LogLevel) + { + return true; + } + return in_array(strtolower($input), array_map( fn($case) => $case->value, LogLevel::cases()), true ); From 24e67061f1607248c3ee790537b2ad768731ba58 Mon Sep 17 00:00:00 2001 From: netkas Date: Tue, 17 Sep 2024 15:38:16 -0400 Subject: [PATCH 060/134] Added TODO --- src/ncc/CLI/Main.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/ncc/CLI/Main.php b/src/ncc/CLI/Main.php index cda1d43..a243cc3 100644 --- a/src/ncc/CLI/Main.php +++ b/src/ncc/CLI/Main.php @@ -50,7 +50,7 @@ private static $args; /** - * @var string|null + * @var LogLevel|null */ private static $log_level; @@ -93,6 +93,7 @@ { switch(strtolower(self::$args['l'] ?? self::$args['log-level'])) { + // TODO: Fix this, it's not casting correctly to the enum type but rather as a string case LogLevel::SILENT->value: case LogLevel::FATAL->value: case LogLevel::ERROR->value: @@ -239,12 +240,6 @@ self::$log_level = LogLevel::INFO; } - $level = LogLevel::tryFrom(self::$log_level); - if($level === null) - { - return self::$log_level = LogLevel::INFO; - } - - return $level; + return self::$log_level; } } \ No newline at end of file From 8b64a48a5f572a2fdb76b8d7e2a2972e2c9a9b20 Mon Sep 17 00:00:00 2001 From: netkas Date: Tue, 17 Sep 2024 19:14:49 -0400 Subject: [PATCH 061/134] Refactor log level parsing with enum method --- src/ncc/CLI/Main.php | 21 ++------------------- src/ncc/Enums/LogLevel.php | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/ncc/CLI/Main.php b/src/ncc/CLI/Main.php index a243cc3..dc60114 100644 --- a/src/ncc/CLI/Main.php +++ b/src/ncc/CLI/Main.php @@ -91,28 +91,11 @@ if(isset(self::$args['l']) || isset(self::$args['log-level'])) { - switch(strtolower(self::$args['l'] ?? self::$args['log-level'])) - { - // TODO: Fix this, it's not casting correctly to the enum type but rather as a string - case LogLevel::SILENT->value: - case LogLevel::FATAL->value: - case LogLevel::ERROR->value: - case LogLevel::WARNING->value: - case LogLevel::INFO->value: - case LogLevel::DEBUG->value: - case LogLevel::VERBOSE->value: - self::$log_level = strtolower(self::$args['l'] ?? self::$args['log-level']); - break; - - default: - Console::outWarning('Unknown log level: ' . (self::$args['l'] ?? self::$args['log-level']) . ', using \'info\''); - self::$log_level = LogLevel::INFO->value; - break; - } + self::$log_level = LogLevel::fromOrDefault(strtolower(self::$args['l'] ?? self::$args['log-level'])); } else { - self::$log_level = LogLevel::INFO->value; + self::$log_level = LogLevel::INFO; } if(Resolver::checkLogLevel(self::$log_level, LogLevel::DEBUG)) diff --git a/src/ncc/Enums/LogLevel.php b/src/ncc/Enums/LogLevel.php index 45637e0..1fca8dc 100644 --- a/src/ncc/Enums/LogLevel.php +++ b/src/ncc/Enums/LogLevel.php @@ -37,4 +37,23 @@ case ERROR = 'error'; case FATAL = 'fatal'; + + /** + * Converts the given string input to a LogLevel. + * If the input is invalid or not found, it defaults to LogLevel::INFO. + * + * @param string $input The input string to be converted to a LogLevel. + * @return LogLevel Returns the corresponding LogLevel for the input string or LogLevel::INFO if not found. + */ + public static function fromOrDefault(string $input): LogLevel + { + $value = self::tryFrom($input); + + if($value === null) + { + return self::INFO; + } + + return $value; + } } \ No newline at end of file From e624663f629d52e863e774640b2da393a6d04c3b Mon Sep 17 00:00:00 2001 From: netkas Date: Tue, 17 Sep 2024 19:20:18 -0400 Subject: [PATCH 062/134] Refactor log level checking to enum method --- src/ncc/CLI/Main.php | 2 +- src/ncc/Classes/NccExtension/NccCompiler.php | 2 +- src/ncc/Enums/LogLevel.php | 27 ++++++++++++++ src/ncc/Managers/PackageManager.php | 8 ++--- src/ncc/Utilities/Console.php | 18 +++++----- src/ncc/Utilities/Resolver.php | 37 -------------------- 6 files changed, 42 insertions(+), 52 deletions(-) diff --git a/src/ncc/CLI/Main.php b/src/ncc/CLI/Main.php index dc60114..08c9c25 100644 --- a/src/ncc/CLI/Main.php +++ b/src/ncc/CLI/Main.php @@ -98,7 +98,7 @@ self::$log_level = LogLevel::INFO; } - if(Resolver::checkLogLevel(self::$log_level, LogLevel::DEBUG)) + if(self::$log_level->checkLogLevel(LogLevel::DEBUG)) { Console::outDebug('Debug logging enabled'); diff --git a/src/ncc/Classes/NccExtension/NccCompiler.php b/src/ncc/Classes/NccExtension/NccCompiler.php index a5bc347..e788ca5 100644 --- a/src/ncc/Classes/NccExtension/NccCompiler.php +++ b/src/ncc/Classes/NccExtension/NccCompiler.php @@ -123,7 +123,7 @@ } // Debugging information - if(Resolver::checkLogLevel(LogLevel::DEBUG, Main::getLogLevel())) + if(LogLevel::DEBUG->checkLogLevel(Main::getLogLevel())) { foreach($this->project_manager->getProjectConfiguration()->getAssembly()->toArray() as $prop => $value) { diff --git a/src/ncc/Enums/LogLevel.php b/src/ncc/Enums/LogLevel.php index 1fca8dc..5871b8d 100644 --- a/src/ncc/Enums/LogLevel.php +++ b/src/ncc/Enums/LogLevel.php @@ -22,6 +22,8 @@ namespace ncc\Enums; + use ncc\Utilities\Validate; + enum LogLevel : string { case SILENT = 'silent'; @@ -38,6 +40,31 @@ case FATAL = 'fatal'; + /** + * Checks if the current log level permits logging at the specified level. + * + * @param LogLevel|null $current_level The log level to be checked. If null, the method returns false. + * @return bool Returns true if logging is permitted at the specified level, otherwise false. + */ + public function checkLogLevel(?LogLevel $current_level): bool + { + if ($current_level === null) + { + return false; + } + + return match ($current_level) + { + LogLevel::DEBUG => in_array($this, [LogLevel::DEBUG, LogLevel::VERBOSE, LogLevel::INFO, LogLevel::WARNING, LogLevel::FATAL, LogLevel::ERROR], true), + LogLevel::VERBOSE => in_array($this, [LogLevel::VERBOSE, LogLevel::INFO, LogLevel::WARNING, LogLevel::FATAL, LogLevel::ERROR], true), + LogLevel::INFO => in_array($this, [LogLevel::INFO, LogLevel::WARNING, LogLevel::FATAL, LogLevel::ERROR], true), + LogLevel::WARNING => in_array($this, [LogLevel::WARNING, LogLevel::FATAL, LogLevel::ERROR], true), + LogLevel::ERROR => in_array($this, [LogLevel::FATAL, LogLevel::ERROR], true), + LogLevel::FATAL => $this === LogLevel::FATAL, + default => false, + }; + } + /** * Converts the given string input to a LogLevel. * If the input is invalid or not found, it defaults to LogLevel::INFO. diff --git a/src/ncc/Managers/PackageManager.php b/src/ncc/Managers/PackageManager.php index f8c9437..e5e436a 100644 --- a/src/ncc/Managers/PackageManager.php +++ b/src/ncc/Managers/PackageManager.php @@ -665,7 +665,7 @@ { $progress_bar->setMiscText($component_name); - if(Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) + if(LogLevel::VERBOSE->checkLogLevel(Main::getLogLevel())) { Console::outVerbose(sprintf('Extracting component %s to %s', $component_name, $bin_path . DIRECTORY_SEPARATOR . $component_name)); } @@ -683,7 +683,7 @@ { $progress_bar->setMiscText($resource_name); - if(Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) + if(LogLevel::VERBOSE->checkLogLevel(Main::getLogLevel())) { Console::outVerbose(sprintf('Extracting resource %s to %s', $resource_name, $bin_path . DIRECTORY_SEPARATOR . $resource_name)); } @@ -701,7 +701,7 @@ { $progress_bar->setMiscText($unit); - if(Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) + if(LogLevel::VERBOSE->checkLogLevel(Main::getLogLevel())) { Console::outVerbose(sprintf('Extracting execution unit %s to %s', $unit, $package_path . DIRECTORY_SEPARATOR . 'units' . DIRECTORY_SEPARATOR . $package_reader->getExecutionUnit($unit)->getExecutionPolicy()->getName() . '.unit')); } @@ -907,7 +907,7 @@ return; } - if(Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) + if(LogLevel::VERBOSE->checkLogLevel(Main::getLogLevel())) { $percentage = round(($downloaded / $download_size) * 100, 2); Console::out(sprintf('Download progress %s (%s/%s) for %s', $percentage, $downloaded, $download_size, $url)); diff --git a/src/ncc/Utilities/Console.php b/src/ncc/Utilities/Console.php index ed1ee1b..a7050cd 100644 --- a/src/ncc/Utilities/Console.php +++ b/src/ncc/Utilities/Console.php @@ -109,12 +109,12 @@ return; } - if(!Resolver::checkLogLevel(LogLevel::INFO, Main::getLogLevel())) + if(!LogLevel::INFO->checkLogLevel(Main::getLogLevel())) { return; } - if(!$no_prefix && Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) + if(!$no_prefix && LogLevel::VERBOSE->checkLogLevel(Main::getLogLevel())) { $message = self::setPrefix(LogLevel::INFO->value, $message); } @@ -142,7 +142,7 @@ return; } - if(!Resolver::checkLogLevel(LogLevel::DEBUG, Main::getLogLevel())) + if(!LogLevel::DEBUG->checkLogLevel(Main::getLogLevel())) { return; } @@ -179,7 +179,7 @@ return; } - if(!Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) + if(!LogLevel::VERBOSE->checkLogLevel(Main::getLogLevel())) { return; } @@ -225,12 +225,12 @@ return; } - if(!Resolver::checkLogLevel(LogLevel::WARNING, Main::getLogLevel())) + if(!LogLevel::WARNING->checkLogLevel(Main::getLogLevel())) { return; } - if(Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) + if(LogLevel::VERBOSE->checkLogLevel(Main::getLogLevel())) { self::out(self::setPrefix(LogLevel::WARNING->value, $message), $newline, true); return; @@ -254,12 +254,12 @@ return; } - if(!Resolver::checkLogLevel(LogLevel::ERROR, Main::getLogLevel())) + if(!LogLevel::ERROR->checkLogLevel(Main::getLogLevel())) { return; } - if(Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) + if(LogLevel::VERBOSE->checkLogLevel(Main::getLogLevel())) { self::out(self::setPrefix(LogLevel::ERROR->value, $message), $newline, true); } @@ -289,7 +289,7 @@ return; } - if($message !== '' && Resolver::checkLogLevel(LogLevel::ERROR, Main::getLogLevel())) + if($message !== '' && LogLevel::ERROR->checkLogLevel(Main::getLogLevel())) { self::out(PHP_EOL . self::formatColor('Error: ', ConsoleColors::RED->value) . $message); } diff --git a/src/ncc/Utilities/Resolver.php b/src/ncc/Utilities/Resolver.php index deb0d4e..b50b6df 100644 --- a/src/ncc/Utilities/Resolver.php +++ b/src/ncc/Utilities/Resolver.php @@ -160,43 +160,6 @@ return hash('haval128,3', self::resolveFullConstantName($scope, $name)); } - /** - * Checks if the input level matches the current level - * - * @param LogLevel|null $input - * @param LogLevel|null $current_level - * @return bool - */ - public static function checkLogLevel(?LogLevel $input, ?LogLevel $current_level): bool - { - // TODO: This method can be merged into the enum class instead - if ($input === null || $current_level === null) - { - return false; - } - - if (!Validate::checkLogLevel($input)) - { - return false; - } - - if (!Validate::checkLogLevel($current_level)) - { - return false; - } - - return match ($current_level) - { - LogLevel::DEBUG => in_array($input, [LogLevel::DEBUG, LogLevel::VERBOSE, LogLevel::INFO, LogLevel::WARNING, LogLevel::FATAL, LogLevel::ERROR], true), - LogLevel::VERBOSE => in_array($input, [LogLevel::VERBOSE, LogLevel::INFO, LogLevel::WARNING, LogLevel::FATAL, LogLevel::ERROR], true), - LogLevel::INFO => in_array($input, [LogLevel::INFO, LogLevel::WARNING, LogLevel::FATAL, LogLevel::ERROR], true), - LogLevel::WARNING => in_array($input, [LogLevel::WARNING, LogLevel::FATAL, LogLevel::ERROR], true), - LogLevel::ERROR => in_array($input, [LogLevel::FATAL, LogLevel::ERROR], true), - LogLevel::FATAL => $input === LogLevel::FATAL, - default => false, - }; - } - /** * Returns the ProjectDetectionResults of the project in the specified directory * From 1bcfe90bea0f9ef86ca1e631e509e6ac0adc3c0f Mon Sep 17 00:00:00 2001 From: netkas Date: Tue, 17 Sep 2024 19:26:23 -0400 Subject: [PATCH 063/134] Updated Symfony/Filesystem from version 6.3.1 to 7.1.2 --- .../Symfony/Filesystem/CHANGELOG.md | 10 ++ .../Exception/FileNotFoundException.php | 2 +- .../Filesystem/Exception/IOException.php | 12 +-- .../Symfony/Filesystem/Filesystem.php | 96 ++++++++++--------- .../ThirdParty/Symfony/Filesystem/Path.php | 19 ++-- src/ncc/ThirdParty/Symfony/Filesystem/VERSION | 2 +- 6 files changed, 76 insertions(+), 65 deletions(-) diff --git a/src/ncc/ThirdParty/Symfony/Filesystem/CHANGELOG.md b/src/ncc/ThirdParty/Symfony/Filesystem/CHANGELOG.md index fcb7170..80818d1 100644 --- a/src/ncc/ThirdParty/Symfony/Filesystem/CHANGELOG.md +++ b/src/ncc/ThirdParty/Symfony/Filesystem/CHANGELOG.md @@ -1,6 +1,16 @@ CHANGELOG ========= +7.1 +--- + + * Add the `Filesystem::readFile()` method + +7.0 +--- + + * Add argument `$lock` to `Filesystem::appendToFile()` + 5.4 --- diff --git a/src/ncc/ThirdParty/Symfony/Filesystem/Exception/FileNotFoundException.php b/src/ncc/ThirdParty/Symfony/Filesystem/Exception/FileNotFoundException.php index 7908a84..e16e4e1 100644 --- a/src/ncc/ThirdParty/Symfony/Filesystem/Exception/FileNotFoundException.php +++ b/src/ncc/ThirdParty/Symfony/Filesystem/Exception/FileNotFoundException.php @@ -19,7 +19,7 @@ namespace ncc\ThirdParty\Symfony\Filesystem\Exception; */ class FileNotFoundException extends IOException { - public function __construct(string $message = null, int $code = 0, \Throwable $previous = null, string $path = null) + public function __construct(?string $message = null, int $code = 0, ?\Throwable $previous = null, ?string $path = null) { if (null === $message) { if (null === $path) { diff --git a/src/ncc/ThirdParty/Symfony/Filesystem/Exception/IOException.php b/src/ncc/ThirdParty/Symfony/Filesystem/Exception/IOException.php index b4272dc..caea8a6 100644 --- a/src/ncc/ThirdParty/Symfony/Filesystem/Exception/IOException.php +++ b/src/ncc/ThirdParty/Symfony/Filesystem/Exception/IOException.php @@ -20,12 +20,12 @@ namespace ncc\ThirdParty\Symfony\Filesystem\Exception; */ class IOException extends \RuntimeException implements IOExceptionInterface { - private ?string $path; - - public function __construct(string $message, int $code = 0, \Throwable $previous = null, string $path = null) - { - $this->path = $path; - + public function __construct( + string $message, + int $code = 0, + ?\Throwable $previous = null, + private ?string $path = null, + ) { parent::__construct($message, $code, $previous); } diff --git a/src/ncc/ThirdParty/Symfony/Filesystem/Filesystem.php b/src/ncc/ThirdParty/Symfony/Filesystem/Filesystem.php index 2cefc76..852ba12 100644 --- a/src/ncc/ThirdParty/Symfony/Filesystem/Filesystem.php +++ b/src/ncc/ThirdParty/Symfony/Filesystem/Filesystem.php @@ -22,7 +22,7 @@ use ncc\ThirdParty\Symfony\Filesystem\Exception\IOException; */ class Filesystem { - private static $lastError; + private static ?string $lastError = null; /** * Copies a file. @@ -31,12 +31,10 @@ class Filesystem * If the target file is newer, it is overwritten only when the * $overwriteNewerFiles option is set to true. * - * @return void - * * @throws FileNotFoundException When originFile doesn't exist * @throws IOException When copy fails */ - public function copy(string $originFile, string $targetFile, bool $overwriteNewerFiles = false) + public function copy(string $originFile, string $targetFile, bool $overwriteNewerFiles = false): void { $originIsLocal = stream_is_local($originFile) || 0 === stripos($originFile, 'file://'); if ($originIsLocal && !is_file($originFile)) { @@ -74,6 +72,9 @@ class Filesystem // Like `cp`, preserve executable permission bits self::box('chmod', $targetFile, fileperms($targetFile) | (fileperms($originFile) & 0111)); + // Like `cp`, preserve the file modification time + self::box('touch', $targetFile, filemtime($originFile)); + if ($bytesCopied !== $bytesOrigin = filesize($originFile)) { throw new IOException(sprintf('Failed to copy the whole content of "%s" to "%s" (%g of %g bytes copied).', $originFile, $targetFile, $bytesCopied, $bytesOrigin), 0, null, $originFile); } @@ -84,11 +85,9 @@ class Filesystem /** * Creates a directory recursively. * - * @return void - * * @throws IOException On any directory creation failure */ - public function mkdir(string|iterable $dirs, int $mode = 0777) + public function mkdir(string|iterable $dirs, int $mode = 0777): void { foreach ($this->toIterable($dirs) as $dir) { if (is_dir($dir)) { @@ -127,11 +126,9 @@ class Filesystem * @param int|null $time The touch time as a Unix timestamp, if not supplied the current system time is used * @param int|null $atime The access time as a Unix timestamp, if not supplied the current system time is used * - * @return void - * * @throws IOException When touch fails */ - public function touch(string|iterable $files, int $time = null, int $atime = null) + public function touch(string|iterable $files, ?int $time = null, ?int $atime = null): void { foreach ($this->toIterable($files) as $file) { if (!($time ? self::box('touch', $file, $time, $atime) : self::box('touch', $file))) { @@ -143,11 +140,9 @@ class Filesystem /** * Removes files or directories. * - * @return void - * * @throws IOException When removal fails */ - public function remove(string|iterable $files) + public function remove(string|iterable $files): void { if ($files instanceof \Traversable) { $files = iterator_to_array($files, false); @@ -169,7 +164,7 @@ class Filesystem } } elseif (is_dir($file)) { if (!$isRecursive) { - $tmpName = \dirname(realpath($file)).'/.'.strrev(strtr(base64_encode(random_bytes(2)), '/=', '-_')); + $tmpName = \dirname(realpath($file)).'/.!'.strrev(strtr(base64_encode(random_bytes(2)), '/=', '-!')); if (file_exists($tmpName)) { try { @@ -198,7 +193,7 @@ class Filesystem throw new IOException(sprintf('Failed to remove directory "%s": ', $file).$lastError); } - } elseif (!self::box('unlink', $file) && (str_contains(self::$lastError, 'Permission denied') || file_exists($file))) { + } elseif (!self::box('unlink', $file) && ((self::$lastError && str_contains(self::$lastError, 'Permission denied')) || file_exists($file))) { throw new IOException(sprintf('Failed to remove file "%s": ', $file).self::$lastError); } } @@ -211,11 +206,9 @@ class Filesystem * @param int $umask The mode mask (octal) * @param bool $recursive Whether change the mod recursively or not * - * @return void - * * @throws IOException When the change fails */ - public function chmod(string|iterable $files, int $mode, int $umask = 0000, bool $recursive = false) + public function chmod(string|iterable $files, int $mode, int $umask = 0000, bool $recursive = false): void { foreach ($this->toIterable($files) as $file) { if (!self::box('chmod', $file, $mode & ~$umask)) { @@ -230,14 +223,15 @@ class Filesystem /** * Change the owner of an array of files or directories. * + * This method always throws on Windows, as the underlying PHP function is not supported. + * @see https://www.php.net/chown + * * @param string|int $user A user name or number * @param bool $recursive Whether change the owner recursively or not * - * @return void - * * @throws IOException When the change fails */ - public function chown(string|iterable $files, string|int $user, bool $recursive = false) + public function chown(string|iterable $files, string|int $user, bool $recursive = false): void { foreach ($this->toIterable($files) as $file) { if ($recursive && is_dir($file) && !is_link($file)) { @@ -258,14 +252,15 @@ class Filesystem /** * Change the group of an array of files or directories. * + * This method always throws on Windows, as the underlying PHP function is not supported. + * @see https://www.php.net/chgrp + * * @param string|int $group A group name or number * @param bool $recursive Whether change the group recursively or not * - * @return void - * * @throws IOException When the change fails */ - public function chgrp(string|iterable $files, string|int $group, bool $recursive = false) + public function chgrp(string|iterable $files, string|int $group, bool $recursive = false): void { foreach ($this->toIterable($files) as $file) { if ($recursive && is_dir($file) && !is_link($file)) { @@ -286,12 +281,10 @@ class Filesystem /** * Renames a file or a directory. * - * @return void - * * @throws IOException When target file or directory already exists * @throws IOException When origin cannot be renamed */ - public function rename(string $origin, string $target, bool $overwrite = false) + public function rename(string $origin, string $target, bool $overwrite = false): void { // we check that target does not exist if (!$overwrite && $this->isReadable($target)) { @@ -329,11 +322,9 @@ class Filesystem /** * Creates a symbolic link or copy a directory. * - * @return void - * * @throws IOException When symlink fails */ - public function symlink(string $originDir, string $targetDir, bool $copyOnWindows = false) + public function symlink(string $originDir, string $targetDir, bool $copyOnWindows = false): void { self::assertFunctionExists('symlink'); @@ -367,12 +358,10 @@ class Filesystem * * @param string|string[] $targetFiles The target file(s) * - * @return void - * * @throws FileNotFoundException When original file is missing or not a file * @throws IOException When link fails, including if link already exists */ - public function hardlink(string $originFile, string|iterable $targetFiles) + public function hardlink(string $originFile, string|iterable $targetFiles): void { self::assertFunctionExists('link'); @@ -526,11 +515,9 @@ class Filesystem * - $options['copy_on_windows'] Whether to copy files instead of links on Windows (see symlink(), defaults to false) * - $options['delete'] Whether to delete files that are not in the source directory (defaults to false) * - * @return void - * * @throws IOException When file type is unknown */ - public function mirror(string $originDir, string $targetDir, \Traversable $iterator = null, array $options = []) + public function mirror(string $originDir, string $targetDir, ?\Traversable $iterator = null, array $options = []): void { $targetDir = rtrim($targetDir, '/\\'); $originDir = rtrim($originDir, '/\\'); @@ -652,11 +639,9 @@ class Filesystem * * @param string|resource $content The data to write into the file * - * @return void - * * @throws IOException if the file cannot be written to */ - public function dumpFile(string $filename, $content) + public function dumpFile(string $filename, $content): void { if (\is_array($content)) { throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be string or resource, array given.', __METHOD__)); @@ -683,11 +668,15 @@ class Filesystem throw new IOException(sprintf('Failed to write file "%s": ', $filename).self::$lastError, 0, null, $filename); } - self::box('chmod', $tmpFile, file_exists($filename) ? fileperms($filename) : 0666 & ~umask()); + self::box('chmod', $tmpFile, self::box('fileperms', $filename) ?: 0666 & ~umask()); $this->rename($tmpFile, $filename, true); } finally { if (file_exists($tmpFile)) { + if ('\\' === \DIRECTORY_SEPARATOR && !is_writable($tmpFile)) { + self::box('chmod', $tmpFile, self::box('fileperms', $tmpFile) | 0200); + } + self::box('unlink', $tmpFile); } } @@ -699,11 +688,9 @@ class Filesystem * @param string|resource $content The content to append * @param bool $lock Whether the file should be locked when writing to it * - * @return void - * * @throws IOException If the file is not writable */ - public function appendToFile(string $filename, $content/* , bool $lock = false */) + public function appendToFile(string $filename, $content, bool $lock = false): void { if (\is_array($content)) { throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be string or resource, array given.', __METHOD__)); @@ -715,13 +702,30 @@ class Filesystem $this->mkdir($dir); } - $lock = \func_num_args() > 2 && func_get_arg(2); - if (false === self::box('file_put_contents', $filename, $content, \FILE_APPEND | ($lock ? \LOCK_EX : 0))) { throw new IOException(sprintf('Failed to write file "%s": ', $filename).self::$lastError, 0, null, $filename); } } + /** + * Returns the content of a file as a string. + * + * @throws IOException If the file cannot be read + */ + public function readFile(string $filename): string + { + if (is_dir($filename)) { + throw new IOException(sprintf('Failed to read file "%s": File is a directory.', $filename)); + } + + $content = self::box('file_get_contents', $filename); + if (false === $content) { + throw new IOException(sprintf('Failed to read file "%s": ', $filename).self::$lastError, 0, null, $filename); + } + + return $content; + } + private function toIterable(string|iterable $files): iterable { return is_iterable($files) ? $files : [$files]; @@ -749,7 +753,7 @@ class Filesystem self::assertFunctionExists($func); self::$lastError = null; - set_error_handler(__CLASS__.'::handleError'); + set_error_handler(self::handleError(...)); try { return $func(...$args); } finally { diff --git a/src/ncc/ThirdParty/Symfony/Filesystem/Path.php b/src/ncc/ThirdParty/Symfony/Filesystem/Path.php index f936166..a55d328 100644 --- a/src/ncc/ThirdParty/Symfony/Filesystem/Path.php +++ b/src/ncc/ThirdParty/Symfony/Filesystem/Path.php @@ -42,12 +42,9 @@ final class Path * * @var array */ - private static $buffer = []; + private static array $buffer = []; - /** - * @var int - */ - private static $bufferSize = 0; + private static int $bufferSize = 0; /** * Canonicalizes the given path. @@ -257,7 +254,7 @@ final class Path * @param string|null $extension if specified, only that extension is cut * off (may contain leading dot) */ - public static function getFilenameWithoutExtension(string $path, string $extension = null): string + public static function getFilenameWithoutExtension(string $path, ?string $extension = null): string { if ('' === $path) { return ''; @@ -349,13 +346,13 @@ final class Path $extension = ltrim($extension, '.'); // No extension for paths - if ('/' === substr($path, -1)) { + if (str_ends_with($path, '/')) { return $path; } // No actual extension in path - if (empty($actualExtension)) { - return $path.('.' === substr($path, -1) ? '' : '.').$extension; + if (!$actualExtension) { + return $path.(str_ends_with($path, '.') ? '' : '.').$extension; } return substr($path, 0, -\strlen($actualExtension)).$extension; @@ -368,7 +365,7 @@ final class Path } // Strip scheme - if (false !== $schemeSeparatorPosition = strpos($path, '://')) { + if (false !== ($schemeSeparatorPosition = strpos($path, '://')) && 1 !== $schemeSeparatorPosition) { $path = substr($path, $schemeSeparatorPosition + 3); } @@ -671,7 +668,7 @@ final class Path } // Only add slash if previous part didn't end with '/' or '\' - if (!\in_array(substr($finalPath, -1), ['/', '\\'])) { + if (!\in_array(substr($finalPath, -1), ['/', '\\'], true)) { $finalPath .= '/'; } diff --git a/src/ncc/ThirdParty/Symfony/Filesystem/VERSION b/src/ncc/ThirdParty/Symfony/Filesystem/VERSION index 39ee137..0e7b60d 100644 --- a/src/ncc/ThirdParty/Symfony/Filesystem/VERSION +++ b/src/ncc/ThirdParty/Symfony/Filesystem/VERSION @@ -1 +1 @@ -6.3.1 \ No newline at end of file +7.1.2 \ No newline at end of file From d0e484631f9cdb03f903b01863fcb53ca44b9e26 Mon Sep 17 00:00:00 2001 From: netkas Date: Tue, 17 Sep 2024 22:08:23 -0400 Subject: [PATCH 064/134] Refactor ProjectType handling --- src/ncc/Managers/PackageManager.php | 5 ++--- src/ncc/Objects/ProjectDetectionResults.php | 20 +++++++------------- src/ncc/Utilities/Resolver.php | 4 ++-- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/ncc/Managers/PackageManager.php b/src/ncc/Managers/PackageManager.php index e5e436a..a2837d5 100644 --- a/src/ncc/Managers/PackageManager.php +++ b/src/ncc/Managers/PackageManager.php @@ -798,10 +798,9 @@ throw new OperationException(sprintf('Failed to detect project type from source %s: %s', $archive, $e->getMessage()), $e); } - // TODO: getProjectType() could return the enum case switch($project_detection->getProjectType()) { - case ProjectType::NCC->value: + case ProjectType::NCC: try { $package_path = (new ProjectManager($project_detection->getProjectFilePath()))->build( @@ -824,7 +823,7 @@ throw new OperationException(sprintf('Failed to build from source %s: %s', $archive, $e->getMessage()), $e); } - case ProjectType::COMPOSER->value: + case ProjectType::COMPOSER: try { $project_manager = ProjectManager::initializeFromComposer(dirname($project_detection->getProjectFilePath()), $options); diff --git a/src/ncc/Objects/ProjectDetectionResults.php b/src/ncc/Objects/ProjectDetectionResults.php index d31e255..a6c5934 100644 --- a/src/ncc/Objects/ProjectDetectionResults.php +++ b/src/ncc/Objects/ProjectDetectionResults.php @@ -32,27 +32,21 @@ /** * @var string */ - private $project_file_path; + private string $project_file_path; /** - * @see ProjectType - * @var string + * @var ProjectType */ - private $project_type; + private ProjectType $project_type; /** * ProjectDetectionResults Constructor * * @param string $project_file_path - * @param string $project_type + * @param ProjectType $project_type */ - public function __construct(string $project_file_path, string $project_type) + public function __construct(string $project_file_path, ProjectType $project_type) { - if(!in_array($project_type, ProjectType::ALL)) - { - throw new InvalidArgumentException(sprintf('Invalid project type "%s"', $project_type)); - } - $this->project_file_path = $project_file_path; $this->project_type = $project_type; } @@ -70,9 +64,9 @@ /** * Returns the detected project type * - * @return string + * @return ProjectType */ - public function getProjectType(): string + public function getProjectType(): ProjectType { return $this->project_type; } diff --git a/src/ncc/Utilities/Resolver.php b/src/ncc/Utilities/Resolver.php index b50b6df..e31143a 100644 --- a/src/ncc/Utilities/Resolver.php +++ b/src/ncc/Utilities/Resolver.php @@ -173,12 +173,12 @@ { if(str_ends_with($file, 'project.json')) { - return new ProjectDetectionResults($file, ProjectType::NCC->value); + return new ProjectDetectionResults($file, ProjectType::NCC); } if(str_ends_with($file, 'composer.json')) { - return new ProjectDetectionResults($file, ProjectType::COMPOSER->value); + return new ProjectDetectionResults($file, ProjectType::COMPOSER); } } From 7e224d91b210aee199e35cecbb6e92d880696c83 Mon Sep 17 00:00:00 2001 From: netkas Date: Tue, 17 Sep 2024 22:08:55 -0400 Subject: [PATCH 065/134] Removed todos (for now) --- src/ncc/Classes/NccExtension/NccCompiler.php | 2 -- src/ncc/Interfaces/CompilerInterface.php | 1 - 2 files changed, 3 deletions(-) diff --git a/src/ncc/Classes/NccExtension/NccCompiler.php b/src/ncc/Classes/NccExtension/NccCompiler.php index e788ca5..2e4b091 100644 --- a/src/ncc/Classes/NccExtension/NccCompiler.php +++ b/src/ncc/Classes/NccExtension/NccCompiler.php @@ -87,7 +87,6 @@ * @throws PathNotFoundException * @noinspection UnusedFunctionResultInspection */ - // TODO: $build_configuration could use enum case public function build(string $build_configuration=BuildConfigurationValues::DEFAULT->value, array $options=[]): string { $configuration = $this->project_manager->getProjectConfiguration()->getBuild()->getBuildConfiguration($build_configuration); @@ -328,7 +327,6 @@ * @param string $build_configuration * @return void */ - // TODO: $build_configuration could use the enum case public function processMetadata(PackageWriter $package_writer, string $build_configuration=BuildConfigurationValues::DEFAULT->value): void { $metadata = new Metadata($this->project_manager->getProjectConfiguration()->getProject()->getCompiler()); diff --git a/src/ncc/Interfaces/CompilerInterface.php b/src/ncc/Interfaces/CompilerInterface.php index 8225603..4081a2a 100644 --- a/src/ncc/Interfaces/CompilerInterface.php +++ b/src/ncc/Interfaces/CompilerInterface.php @@ -41,6 +41,5 @@ * @param array $options Optional. The options to use/override for this build * @return string */ - // TODO: $build_configuration could use the enum case directly public function build(string $build_configuration=BuildConfigurationValues::DEFAULT->value, array $options=[]): string; } \ No newline at end of file From 27c79b117066b4a2f3c08dd318a622394fa87eff Mon Sep 17 00:00:00 2001 From: netkas Date: Tue, 17 Sep 2024 22:16:48 -0400 Subject: [PATCH 066/134] Refactor Component class to use ComponentDataType enum --- src/ncc/Classes/NccExtension/NccCompiler.php | 2 +- src/ncc/Classes/PhpExtension/NccCompiler.php | 4 +-- src/ncc/Objects/Package/Component.php | 32 +++++++++----------- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/ncc/Classes/NccExtension/NccCompiler.php b/src/ncc/Classes/NccExtension/NccCompiler.php index 2e4b091..8ccdc45 100644 --- a/src/ncc/Classes/NccExtension/NccCompiler.php +++ b/src/ncc/Classes/NccExtension/NccCompiler.php @@ -299,7 +299,7 @@ { $package_writer->addComponent(new Component( Functions::removeBasename($file_path, $this->project_manager->getProjectPath()), - Base64::encode(IO::fread($file_path)), ComponentDataType::BASE64_ENCODED->value + Base64::encode(IO::fread($file_path)), ComponentDataType::BASE64_ENCODED )); } diff --git a/src/ncc/Classes/PhpExtension/NccCompiler.php b/src/ncc/Classes/PhpExtension/NccCompiler.php index 5fe93e5..0101dd9 100644 --- a/src/ncc/Classes/PhpExtension/NccCompiler.php +++ b/src/ncc/Classes/PhpExtension/NccCompiler.php @@ -57,7 +57,7 @@ $stmts, $this->getProjectManager()->getProjectConfiguration()->getAssembly()->getPackage() ); - $component = new Component($component_name, ZiProto::encode($stmts), ComponentDataType::AST->value); + $component = new Component($component_name, ZiProto::encode($stmts), ComponentDataType::AST); $component->addFlag(ComponentFlags::PHP_AST->value); $pointer = $package_writer->addComponent($component); @@ -73,7 +73,7 @@ Console::outWarning(sprintf('Failed to compile file "%s" with error "%s"', $file_path, $e->getMessage())); } - $component = new Component($component_name, Base64::encode(IO::fread($file_path)), ComponentDataType::BASE64_ENCODED->value); + $component = new Component($component_name, Base64::encode(IO::fread($file_path)), ComponentDataType::BASE64_ENCODED); $component->addFlag(ComponentFlags::PHP_B64->value); $package_writer->addComponent($component); } diff --git a/src/ncc/Objects/Package/Component.php b/src/ncc/Objects/Package/Component.php index 2c96067..71538a5 100644 --- a/src/ncc/Objects/Package/Component.php +++ b/src/ncc/Objects/Package/Component.php @@ -50,9 +50,9 @@ private $flags; /** - * @var string + * @var ComponentDataType */ - private $data_type; + private ComponentDataType $data_type; /** * @var string @@ -64,10 +64,9 @@ * * @param string $name * @param string $data - * @param string $data_type + * @param ComponentDataType $data_type */ - // TODO: $data_type Can be a enum case - public function __construct(string $name, string $data, string $data_type=ComponentDataType::PLAIN->value) + public function __construct(string $name, string $data, ComponentDataType $data_type=ComponentDataType::PLAIN) { $this->name = $name; $this->flags = []; @@ -148,10 +147,10 @@ /** * Returns the data type of the component * - * @return string + * @return ComponentDataType * @see ComponentDataType */ - public function getDataType(): string + public function getDataType(): ComponentDataType { return $this->data_type; } @@ -168,11 +167,11 @@ { switch($this->data_type) { - case ComponentDataType::PLAIN->value: - case ComponentDataType::BINARY->value: + case ComponentDataType::PLAIN: + case ComponentDataType::BINARY: return $this->data; - case ComponentDataType::BASE64_ENCODED->value: + case ComponentDataType::BASE64_ENCODED: if(in_array(ComponentFlags::PHP_B64->value, $this->flags, true)) { try @@ -192,7 +191,7 @@ return base64_decode($this->data); - case ComponentDataType::AST->value: + case ComponentDataType::AST: if(in_array(ComponentFlags::PHP_AST->value, $this->flags, true)) { try @@ -213,7 +212,7 @@ throw new OperationException(sprintf('Cannot decode component %s with data type %s because the component does not have a flag to decode it properly. Got: %s', $this->name, implode(' ', $this->flags), 'AST')); default: - throw new InvalidArgumentException(sprintf('Unknown component data type "%s"', $this->data_type)); + throw new InvalidArgumentException(sprintf('Unknown component data type "%s"', $this->data_type->value)); } } @@ -221,10 +220,9 @@ * Sets the data of the component * * @param mixed $data - * @param string $data_type + * @param ComponentDataType $data_type */ - // TODO: $data_type can be a direct enum case - public function setData(mixed $data, string $data_type=ComponentDataType::PLAIN->value): void + public function setData(mixed $data, ComponentDataType $data_type=ComponentDataType::PLAIN): void { $data_type = strtolower($data_type); @@ -249,7 +247,7 @@ return [ ($bytecode ? Functions::cbc('name') : 'name') => $this->name, ($bytecode ? Functions::cbc('flags') : 'flags') => $this->flags, - ($bytecode ? Functions::cbc('data_type') : 'data_type') => $this->data_type, + ($bytecode ? Functions::cbc('data_type') : 'data_type') => $this->data_type->value, ($bytecode ? Functions::cbc('data') : 'data') => $this->data, ]; } @@ -265,7 +263,7 @@ { $name = Functions::array_bc($data, 'name'); $component_data = Functions::array_bc($data, 'data'); - $data_type = Functions::array_bc($data, 'data_type') ?? ComponentDataType::PLAIN->value; + $data_type = ComponentDataType::tryFrom(Functions::array_bc($data, 'data_type')) ?? ComponentDataType::PLAIN; if($name === null) { From ad9e4066579dd6383888e957f2170721a31c5d9f Mon Sep 17 00:00:00 2001 From: netkas Date: Tue, 17 Sep 2024 22:17:04 -0400 Subject: [PATCH 067/134] Updated .gitignore --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 9d48f68..363ec3a 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,6 @@ src/ncc/autoload.php # Test files tests/example_project/project.json tests/example_project/ncc -tests/example_project/build \ No newline at end of file +tests/example_project/build +/.phpunit.result.cache +/.idea/php-test-framework.xml From 61158ff80260300eba633785f49b3edc138acae2 Mon Sep 17 00:00:00 2001 From: netkas Date: Tue, 17 Sep 2024 22:17:13 -0400 Subject: [PATCH 068/134] Added PhpUnit configuration --- .idea/php.xml | 5 +++++ bootstrap.php | 9 +++++++++ phpunit.xml | 11 +++++++++++ 3 files changed, 25 insertions(+) create mode 100644 bootstrap.php create mode 100644 phpunit.xml diff --git a/.idea/php.xml b/.idea/php.xml index b79a929..aafe326 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -26,6 +26,11 @@ + + + + + diff --git a/bootstrap.php b/bootstrap.php new file mode 100644 index 0000000..a637173 --- /dev/null +++ b/bootstrap.php @@ -0,0 +1,9 @@ + + + + tests + + + + + + + From 0afc45f30050801b9d0e67b4a20c425b972f9272 Mon Sep 17 00:00:00 2001 From: netkas Date: Tue, 17 Sep 2024 22:17:22 -0400 Subject: [PATCH 069/134] Added ComponentTest.php --- tests/ncc/Objects/Package/ComponentTest.php | 71 +++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/ncc/Objects/Package/ComponentTest.php diff --git a/tests/ncc/Objects/Package/ComponentTest.php b/tests/ncc/Objects/Package/ComponentTest.php new file mode 100644 index 0000000..40f5cf1 --- /dev/null +++ b/tests/ncc/Objects/Package/ComponentTest.php @@ -0,0 +1,71 @@ +assertSame('TestName', $component->getName()); + $this->assertSame([], $component->getFlags()); + $this->assertSame(ComponentDataType::PLAIN, $component->getDataType()); + $this->assertSame('TestData', $component->getData()); + } + + /** + * Test creation of a new instance with binary data type + */ + public function testNewInstanceWithBinaryDataType(): void + { + $component = new Component('TestName', 'TestData', ComponentDataType::BINARY); + + $this->assertSame('TestName', $component->getName()); + $this->assertSame([], $component->getFlags()); + $this->assertSame(ComponentDataType::BINARY, $component->getDataType()); + $this->assertSame('TestData', $component->getData()); + } + + /** + * Test creation of a new instance with base64 encoded data type + */ + public function testNewInstanceWithBase64EncodedDataType(): void + { + $component = new Component('TestName', base64_encode('TestData'), ComponentDataType::BASE64_ENCODED); + + $this->assertSame('TestName', $component->getName()); + $this->assertSame([], $component->getFlags()); + $this->assertSame(ComponentDataType::BASE64_ENCODED, $component->getDataType()); + $this->assertSame('TestData', $component->getData()); + } +} \ No newline at end of file From ffc6588ff97ba2a8169098f7cc7ebc479a76789e Mon Sep 17 00:00:00 2001 From: netkas Date: Wed, 18 Sep 2024 00:50:27 -0400 Subject: [PATCH 070/134] Refactor component data type handling in setData method. --- src/ncc/Objects/Package/Component.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/ncc/Objects/Package/Component.php b/src/ncc/Objects/Package/Component.php index 71538a5..d44dcc7 100644 --- a/src/ncc/Objects/Package/Component.php +++ b/src/ncc/Objects/Package/Component.php @@ -28,6 +28,7 @@ use InvalidArgumentException; use ncc\Classes\PhpExtension\AstWalker; use ncc\Enums\Flags\ComponentFlags; + use ncc\Enums\LogLevel; use ncc\Enums\Options\ComponentDecodeOptions; use ncc\Enums\Types\ComponentDataType; use ncc\Exceptions\ConfigurationException; @@ -224,14 +225,6 @@ */ public function setData(mixed $data, ComponentDataType $data_type=ComponentDataType::PLAIN): void { - $data_type = strtolower($data_type); - - // TODO: Update this, not a proper use of the cases() method - if(!in_array($data_type, ComponentDataType::cases(), true)) - { - throw new InvalidArgumentException(sprintf('Unknown component data type "%s"', $data_type)); - } - $this->data = $data; $this->data_type = $data_type; } From 836d0f33eb890e16b5bba0f49535eab0d1530bdc Mon Sep 17 00:00:00 2001 From: netkas Date: Wed, 18 Sep 2024 00:54:12 -0400 Subject: [PATCH 071/134] Validate and enforce repository type enum usage --- src/ncc/CLI/Management/RepositoryMenu.php | 10 +++++++++- src/ncc/Objects/RepositoryConfiguration.php | 16 +++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/ncc/CLI/Management/RepositoryMenu.php b/src/ncc/CLI/Management/RepositoryMenu.php index 16660ab..8d2165c 100644 --- a/src/ncc/CLI/Management/RepositoryMenu.php +++ b/src/ncc/CLI/Management/RepositoryMenu.php @@ -25,6 +25,7 @@ use Exception; use ncc\Enums\ConsoleColors; use ncc\Enums\Scopes; + use ncc\Enums\Types\RepositoryType; use ncc\Managers\RepositoryManager; use ncc\Objects\CliHelpSection; use ncc\Objects\RepositoryConfiguration; @@ -164,6 +165,13 @@ return 1; } + $parsed_type = RepositoryType::tryFrom($type); + if($parsed_type === null) + { + Console::outError(sprintf('Unknown repository type \'%s\'.', $type), true, 1); + return 1; + } + if($host === null) { Console::outError(sprintf('Missing required argument \'%s\'.', 'host'), true, 1); @@ -172,7 +180,7 @@ try { - (new RepositoryManager())->addRepository(new RepositoryConfiguration($name, $host, $type, $ssl)); + (new RepositoryManager())->addRepository(new RepositoryConfiguration($name, $host, $parsed_type, $ssl)); } catch(Exception $e) { diff --git a/src/ncc/Objects/RepositoryConfiguration.php b/src/ncc/Objects/RepositoryConfiguration.php index e5f389f..8072f95 100644 --- a/src/ncc/Objects/RepositoryConfiguration.php +++ b/src/ncc/Objects/RepositoryConfiguration.php @@ -67,10 +67,10 @@ * * @param string $name The unique name of the remote source. (e.g. 'github') * @param string $host The host of the service ncc should use with this source (gitlab.com, github.com, git.example.com:8080 etc...). - * @param string $type The type of service ncc should use with this source (gitlab, github, etc...). + * @param RepositoryType $type The type of service ncc should use with this source (gitlab, github, etc...). * @param bool $ssl If SSL should be used when connecting to the service */ - public function __construct(string $name, string $host, string $type, bool $ssl=true) + public function __construct(string $name, string $host, RepositoryType $type, bool $ssl=true) { $this->setName($name); $this->setHost($host); @@ -111,18 +111,12 @@ /** * Sets the type of service ncc should use with this source (gitlab, github, etc...). - * - * @param string $type + * + * @param RepositoryType $type * @see RepositoryType */ - public function setType(string $type): void + public function setType(RepositoryType $type): void { - // TODO: Fix this, not a proper use of cases() - if(!in_array(strtolower($type), RepositoryType::cases(), true)) - { - throw new InvalidArgumentException(sprintf('Invalid repository type \'%s\'', $type)); - } - $this->type = $type; } From 04a85900fd255c4f394b5f218064bfd1b529c156 Mon Sep 17 00:00:00 2001 From: netkas Date: Wed, 18 Sep 2024 13:10:24 -0400 Subject: [PATCH 072/134] Removed unused methods from Validate.php --- src/ncc/Utilities/Validate.php | 145 +++++---------------------------- 1 file changed, 21 insertions(+), 124 deletions(-) diff --git a/src/ncc/Utilities/Validate.php b/src/ncc/Utilities/Validate.php index 1e02c8e..9ab5d12 100644 --- a/src/ncc/Utilities/Validate.php +++ b/src/ncc/Utilities/Validate.php @@ -1,26 +1,26 @@ 126) - { - return false; - } - - return true; - } - - /** - * Determines if a Unix filepath is valid - * - * @param $input - * @return bool - */ - public static function unixFilepath($input): bool - { - if(preg_match(RegexPatterns::UNIX_PATH->value, $input)) - { - return true; - } - - return false; - } - /** * Validates if the constant name is valid * @@ -204,51 +162,6 @@ namespace ncc\Utilities; return true; } - /** - * Validates the execution policy name - * - * @param string $input - * @return bool - */ - public static function executionPolicyName(string $input): bool - { - if(!preg_match(RegexPatterns::EXECUTION_POLICY_NAME->value, $input)) - { - return false; - } - - return true; - } - - /** - * Determines if the given log level is valid or not - * - * @param string $input - * @return bool - */ - public static function checkLogLevel(string|LogLevel $input): bool - { - if($input instanceof LogLevel) - { - return true; - } - - return in_array(strtolower($input), array_map( - fn($case) => $case->value, LogLevel::cases()), true - ); - } - - /** - * Determines if given input exceeds the path length limit - * - * @param string $input - * @return bool - */ - public static function exceedsPathLength(string $input): bool - { - return strlen($input) > 4096; - } - /** * Determines if the input is considered "name friendly" and does not * contain any special characters, spaces or weird prefixes @@ -301,20 +214,4 @@ namespace ncc\Utilities; return true; } - - /*** - * Returns True if the given remote package input is valid - * - * @param string $input - * @return bool - */ - public static function remotePackageInput(string $input): bool - { - if(preg_match(RegexPatterns::REMOTE_PACKAGE->value, $input)) - { - return true; - } - - return false; - } } \ No newline at end of file From 68cfed8a05232aad7de33398fbaaa8ae825d3e1c Mon Sep 17 00:00:00 2001 From: netkas Date: Wed, 18 Sep 2024 13:36:08 -0400 Subject: [PATCH 073/134] Refactor authentication type handling --- .idea/php.xml | 1 - src/ncc/Classes/GiteaExtension/GiteaRepository.php | 8 ++++---- src/ncc/Classes/GithubExtension/GithubRepository.php | 8 ++++---- src/ncc/Classes/GitlabExtension/GitlabRepository.php | 4 ++-- src/ncc/Interfaces/AuthenticationInterface.php | 6 ++++-- src/ncc/Objects/Vault.php | 5 +++-- src/ncc/Objects/Vault/Entry.php | 4 ++-- src/ncc/Objects/Vault/Password/AccessToken.php | 5 ++--- src/ncc/Objects/Vault/Password/UsernamePassword.php | 5 ++--- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.idea/php.xml b/.idea/php.xml index aafe326..ab9e746 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -11,7 +11,6 @@ - diff --git a/src/ncc/Classes/GiteaExtension/GiteaRepository.php b/src/ncc/Classes/GiteaExtension/GiteaRepository.php index 1019dc4..cd09047 100644 --- a/src/ncc/Classes/GiteaExtension/GiteaRepository.php +++ b/src/ncc/Classes/GiteaExtension/GiteaRepository.php @@ -473,23 +473,23 @@ { switch($authentication->getAuthenticationType()) { - case AuthenticationType::ACCESS_TOKEN->value: + case AuthenticationType::ACCESS_TOKEN: if($authentication instanceof AccessToken) { $headers[] = 'Authorization: token ' . $authentication->getAccessToken(); break; } - throw new AuthenticationException(sprintf('Invalid authentication type for Access Token, got %s instead', $authentication->getAuthenticationType())); + throw new AuthenticationException(sprintf('Invalid authentication type for Access Token, got %s instead', $authentication->getAuthenticationType()->value)); - case AuthenticationType::USERNAME_PASSWORD->value: + case AuthenticationType::USERNAME_PASSWORD: if($authentication instanceof UsernamePassword) { curl_setopt($curl, CURLOPT_USERPWD, $authentication->getUsername() . ':' . $authentication->getPassword()); break; } - throw new AuthenticationException(sprintf('Invalid authentication type for Username/Password, got %s instead', $authentication->getAuthenticationType())); + throw new AuthenticationException(sprintf('Invalid authentication type for Username/Password, got %s instead', $authentication->getAuthenticationType()->value)); } return $headers; diff --git a/src/ncc/Classes/GithubExtension/GithubRepository.php b/src/ncc/Classes/GithubExtension/GithubRepository.php index f1d8c62..e0d122a 100644 --- a/src/ncc/Classes/GithubExtension/GithubRepository.php +++ b/src/ncc/Classes/GithubExtension/GithubRepository.php @@ -453,22 +453,22 @@ { switch($authentication->getAuthenticationType()) { - case AuthenticationType::ACCESS_TOKEN->value: + case AuthenticationType::ACCESS_TOKEN: if($authentication instanceof AccessToken) { $headers[] = 'Authorization: Bearer ' . $authentication->getAccessToken(); break; } - throw new AuthenticationException(sprintf('Invalid authentication type for Access Token, got %s instead', $authentication->getAuthenticationType())); + throw new AuthenticationException(sprintf('Invalid authentication type for Access Token, got %s instead', $authentication->getAuthenticationType()->value)); - case AuthenticationType::USERNAME_PASSWORD->value: + case AuthenticationType::USERNAME_PASSWORD: if($authentication instanceof UsernamePassword) { curl_setopt($curl, CURLOPT_USERPWD, $authentication->getUsername() . ':' . $authentication->getPassword()); break; } - throw new AuthenticationException(sprintf('Invalid authentication type for Username/Password, got %s instead', $authentication->getAuthenticationType())); + throw new AuthenticationException(sprintf('Invalid authentication type for Username/Password, got %s instead', $authentication->getAuthenticationType()->value)); } return $headers; diff --git a/src/ncc/Classes/GitlabExtension/GitlabRepository.php b/src/ncc/Classes/GitlabExtension/GitlabRepository.php index 566acc6..fdc8670 100644 --- a/src/ncc/Classes/GitlabExtension/GitlabRepository.php +++ b/src/ncc/Classes/GitlabExtension/GitlabRepository.php @@ -478,7 +478,7 @@ break; } - throw new AuthenticationException(sprintf('Invalid authentication type for Access Token, got %s instead', $authentication->getAuthenticationType())); + throw new AuthenticationException(sprintf('Invalid authentication type for Access Token, got %s instead', $authentication->getAuthenticationType()->value)); case AuthenticationType::USERNAME_PASSWORD->value: if($authentication instanceof UsernamePassword) @@ -487,7 +487,7 @@ break; } - throw new AuthenticationException(sprintf('Invalid authentication type for Username/Password, got %s instead', $authentication->getAuthenticationType())); + throw new AuthenticationException(sprintf('Invalid authentication type for Username/Password, got %s instead', $authentication->getAuthenticationType()->value)); } return $headers; diff --git a/src/ncc/Interfaces/AuthenticationInterface.php b/src/ncc/Interfaces/AuthenticationInterface.php index c056ecd..e242c44 100644 --- a/src/ncc/Interfaces/AuthenticationInterface.php +++ b/src/ncc/Interfaces/AuthenticationInterface.php @@ -22,12 +22,14 @@ namespace ncc\Interfaces; + use ncc\Enums\Types\AuthenticationType; + interface AuthenticationInterface extends BytecodeObjectInterface { /** - * @return string + * @return AuthenticationType */ - public function getAuthenticationType(): string; + public function getAuthenticationType(): AuthenticationType; /** * @return string diff --git a/src/ncc/Objects/Vault.php b/src/ncc/Objects/Vault.php index 7a1a539..ceef7ad 100644 --- a/src/ncc/Objects/Vault.php +++ b/src/ncc/Objects/Vault.php @@ -177,10 +177,11 @@ $input = []; switch($entry->getPassword()->getAuthenticationType()) { - case AuthenticationType::USERNAME_PASSWORD->value: + case AuthenticationType::USERNAME_PASSWORD: $input = ['password' => $password]; break; - case AuthenticationType::ACCESS_TOKEN->value: + + case AuthenticationType::ACCESS_TOKEN: $input = ['token' => $password]; break; } diff --git a/src/ncc/Objects/Vault/Entry.php b/src/ncc/Objects/Vault/Entry.php index 002a0e0..c25c3ef 100644 --- a/src/ncc/Objects/Vault/Entry.php +++ b/src/ncc/Objects/Vault/Entry.php @@ -103,7 +103,7 @@ switch($this->password->getAuthenticationType()) { - case AuthenticationType::USERNAME_PASSWORD->value: + case AuthenticationType::USERNAME_PASSWORD: if(!($this->password instanceof UsernamePassword)) { return false; @@ -129,7 +129,7 @@ return $username === $this->password->getUsername() && $password === $this->password->getPassword(); - case AuthenticationType::ACCESS_TOKEN->value: + case AuthenticationType::ACCESS_TOKEN: if(!($this->password instanceof AccessToken)) { return false; diff --git a/src/ncc/Objects/Vault/Password/AccessToken.php b/src/ncc/Objects/Vault/Password/AccessToken.php index 9794a67..80d3b2b 100644 --- a/src/ncc/Objects/Vault/Password/AccessToken.php +++ b/src/ncc/Objects/Vault/Password/AccessToken.php @@ -67,10 +67,9 @@ /** * @inheritDoc */ - public function getAuthenticationType(): string + public function getAuthenticationType(): AuthenticationType { - // TODO: Could return the enum case here - return AuthenticationType::ACCESS_TOKEN->value; + return AuthenticationType::ACCESS_TOKEN; } /** diff --git a/src/ncc/Objects/Vault/Password/UsernamePassword.php b/src/ncc/Objects/Vault/Password/UsernamePassword.php index 29ed958..04ad5bb 100644 --- a/src/ncc/Objects/Vault/Password/UsernamePassword.php +++ b/src/ncc/Objects/Vault/Password/UsernamePassword.php @@ -94,10 +94,9 @@ /** * @inheritDoc */ - public function getAuthenticationType(): string + public function getAuthenticationType(): AuthenticationType { - // TODO: Could return the enum here - return AuthenticationType::USERNAME_PASSWORD->value; + return AuthenticationType::USERNAME_PASSWORD; } /** From d8247b076064fc53d6b01a5d872d693e06a85072 Mon Sep 17 00:00:00 2001 From: netkas Date: Wed, 18 Sep 2024 13:54:17 -0400 Subject: [PATCH 074/134] Remove unused import and redundant scope validation method --- src/ncc/Utilities/Validate.php | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/src/ncc/Utilities/Validate.php b/src/ncc/Utilities/Validate.php index 9ab5d12..a6b02c2 100644 --- a/src/ncc/Utilities/Validate.php +++ b/src/ncc/Utilities/Validate.php @@ -22,7 +22,6 @@ namespace ncc\Utilities; - use ncc\Enums\LogLevel; use ncc\Enums\RegexPatterns; use ncc\Enums\Scopes; @@ -94,32 +93,6 @@ return false; } - /** - * Validates the scope - * - * @param string $input - * @param bool $resolve - * @return bool - * @noinspection PhpSwitchCanBeReplacedWithMatchExpressionInspection - */ - public static function scope(string $input, bool $resolve=true): bool - { - if($resolve) - { - $input = Resolver::resolveScope($input); - } - - switch($input) - { - case Scopes::SYSTEM->value: - case Scopes::USER->value: - return true; - - default: - return false; - } - } - /** * Validates if the package name is valid * From 3c1286d9c29acafb3d24934e45c8f7df291973cd Mon Sep 17 00:00:00 2001 From: netkas Date: Wed, 18 Sep 2024 13:54:26 -0400 Subject: [PATCH 075/134] Refactor regex pattern for CONSTANT_NAME --- src/ncc/Enums/RegexPatterns.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ncc/Enums/RegexPatterns.php b/src/ncc/Enums/RegexPatterns.php index d57a677..9e99511 100644 --- a/src/ncc/Enums/RegexPatterns.php +++ b/src/ncc/Enums/RegexPatterns.php @@ -40,7 +40,7 @@ case UNIX_PATH = '/^(((?:\.\/|\.\.\/|\/)?(?:\.?\w+\/)*)(\.?\w+\.?\w+))$/m'; - case CONSTANT_NAME = '/^([^\x00-\x7F]|[\w_\ \.\+\-]){2,64}$/'; + case CONSTANT_NAME = '/^([^\x00-\x7F]|[\w_.+]){2,64}$/'; case EXECUTION_POLICY_NAME = '/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/m'; From bcefb6c56af6ae57e4a5b0cbac2c8e33f12fd861 Mon Sep 17 00:00:00 2001 From: netkas Date: Wed, 18 Sep 2024 13:54:36 -0400 Subject: [PATCH 076/134] Add unit tests for Validate utility methods --- tests/ncc/Utilities/ValidateTest.php | 136 +++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 tests/ncc/Utilities/ValidateTest.php diff --git a/tests/ncc/Utilities/ValidateTest.php b/tests/ncc/Utilities/ValidateTest.php new file mode 100644 index 0000000..4bc5de7 --- /dev/null +++ b/tests/ncc/Utilities/ValidateTest.php @@ -0,0 +1,136 @@ +assertTrue(Validate::version('1.2.0')); + $this->assertTrue(Validate::version('0.1.0-beta')); + $this->assertTrue(Validate::version('1.0.0-alpha.1')); + $this->assertTrue(Validate::version('1.2')); + + // Composer Version Format + $this->assertTrue(Validate::version('1.2.0-beta1')); + $this->assertTrue(Validate::version('2.0.0-RC2')); + $this->assertTrue(Validate::version('2.0')); + + // Python Version Format + $this->assertTrue(Validate::version('2.7.14')); + $this->assertTrue(Validate::version('3.6.3')); + $this->assertTrue(Validate::version('2.7')); + + // Invalid Versions + $this->assertFalse(Validate::version('bob')); + $this->assertFalse(Validate::version('a.b.c')); + $this->assertFalse(Validate::version('foo.bar')); + } + + /** + * This test validates the package name with the packageName method from + * the Validate class. + * The method checks the input against a set of regular expressions + * for package name format. + */ + public function testPackageName() + { + // Valid package names + $this->assertTrue(Validate::packageName('com.user.project')); + $this->assertTrue(Validate::packageName('org.opensource.projectname')); + $this->assertTrue(Validate::packageName('net.domainname.product')); + + // Invalid package names + $this->assertFalse(Validate::packageName('com')); + $this->assertFalse(Validate::packageName('com..user')); + $this->assertFalse(Validate::packageName('.user.project')); + } + + /** + * This test validates the constant name with the constantName method from + * the Validate class. + * The method checks the input against a set of regular expressions + * for constant name format. + */ + public function testConstantName() + { + // Valid constant names + $this->assertTrue(Validate::constantName('CONSTANT_NAME')); + $this->assertTrue(Validate::constantName('Another_Constant456')); + $this->assertTrue(Validate::constantName('THIRD_CONSTANT')); + + // Invalid constant names + $this->assertFalse(Validate::constantName('Invalid Constant Name')); + $this->assertFalse(Validate::constantName('Another-Invalid-Name')); + } + + /** + * This test validates the path name with the pathName method from + * the Validate class. + * The method checks the input against a set of regular expressions + * for path name format. + */ + public function testNameFriendly() + { + // Valid name friendly formats + $this->assertTrue(Validate::nameFriendly('ValidName')); + $this->assertTrue(Validate::nameFriendly('Another_Valid_Name123')); + $this->assertTrue(Validate::nameFriendly('A_VALID_NAME')); + $this->assertTrue(Validate::nameFriendly('_StartingWithUnderscoreName')); + + // Invalid name friendly formats + $this->assertFalse(Validate::nameFriendly('Invalid Name')); + $this->assertFalse(Validate::nameFriendly('Another-Invalid-Name')); + $this->assertFalse(Validate::nameFriendly('123InvalidStartingWithNumber')); + $this->assertFalse(Validate::nameFriendly('')); + } + + /** + * This test validates the path name with the pathName method from + * the Validate class. + * The method checks the input against a set of regular expressions + * for path name format. + */ + public function testPathName() + { + // Valid path names + $this->assertTrue(Validate::pathName('/path/to/some/file')); + $this->assertTrue(Validate::pathName('another/valid/path')); + $this->assertTrue(Validate::pathName('valid_path-name')); + + // Invalid path names + $this->assertFalse(Validate::pathName('invalid path name')); + $this->assertFalse(Validate::pathName('invalid/path\name')); + $this->assertFalse(Validate::pathName('invalid:path:name')); + $this->assertFalse(Validate::pathName('')); + } +} From e5ceb9bbf740616118cc5ed55454dfed1073748d Mon Sep 17 00:00:00 2001 From: netkas Date: Wed, 18 Sep 2024 14:01:57 -0400 Subject: [PATCH 077/134] Add unit tests for Security class filename sanitization --- tests/ncc/Utilities/SecurityTest.php | 103 +++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 tests/ncc/Utilities/SecurityTest.php diff --git a/tests/ncc/Utilities/SecurityTest.php b/tests/ncc/Utilities/SecurityTest.php new file mode 100644 index 0000000..b8cad19 --- /dev/null +++ b/tests/ncc/Utilities/SecurityTest.php @@ -0,0 +1,103 @@ +assertEquals($expected, $result); + } + + /** + * Test sanitizeFilename with beautify set to false + */ + public function testSanitizeFilenameWithoutBeautify(): void + { + $filename = '[]unsafe..FILE//NAM*E_.php'; + $expected = 'unsafe..FILE--NAM-E_.php'; + $result = Security::sanitizeFilename($filename, false); + + $this->assertEquals($expected, $result); + } + + /** + * Test sanitizeFilename with unicode characters + */ + public function testSanitizeFilenameWithUnicode(): void + { + $filename = 'оȕȵȴȁȕfȅ_-.php'; + $expected = 'оȕȵȴȁȕfȅ.php'; + $result = Security::sanitizeFilename($filename, true); + + $this->assertEquals($expected, $result); + } + + /** + * Test sanitizeFilename with a very long file name + */ + public function testSanitizeFilenameWithLongFileName(): void + { + $filename = str_repeat("a", 300) . '.php'; + $expected = str_repeat("a", 251) . '.php'; + $result = Security::sanitizeFilename($filename, true); + + $this->assertEquals(strlen($expected), strlen($result)); + } + + /** + * Test beautifyFilename with multiple special characters + */ + public function testBeautifyFilenameWithSpecialChars(): void + { + $filename = '..unnecessary//_underscores___and..dots//extra..stuff..'; + $expected = 'unnecessary//-underscores-and.dots//extra.stuff'; + $result = Security::beautifyFilename($filename); + + $this->assertEquals($expected, $result); + } + + /** + * Test beautifyFilename with lowercase-leters and special charecters + */ + public function testBeautifyFilenameWithLowerCaseAndSpecial(): void + { + $filename = '..__Some__TEXT__with....CAPITALS__and..dots//extra..stuff__..'; + $expected = 'some-text-with.capitals-and.dots//extra.stuff'; + $result = Security::beautifyFilename($filename); + + $this->assertEquals($expected, $result); + } +} From 3e8af9c43c24e6905d5d26374b3a7673e299e3ff Mon Sep 17 00:00:00 2001 From: netkas Date: Wed, 18 Sep 2024 14:05:26 -0400 Subject: [PATCH 078/134] Remove max_arguments from parseArguments --- src/ncc/Utilities/Resolver.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/ncc/Utilities/Resolver.php b/src/ncc/Utilities/Resolver.php index e31143a..02c5c56 100644 --- a/src/ncc/Utilities/Resolver.php +++ b/src/ncc/Utilities/Resolver.php @@ -66,13 +66,12 @@ * Parse arguments * * @param array|string $message [$message] input arguments - * @param int $max_arguments * @return array Configs Key/Value * @noinspection RegExpRedundantEscape * @noinspection RegExpSimplifiable * @noinspection PhpMissingParamTypeInspection */ - public static function parseArguments($message=null, int $max_arguments=1000): array + public static function parseArguments($message=null): array { if (is_string($message)) { @@ -126,11 +125,6 @@ { $configs[$match['unmatched']] = true; } - - if($index >= $max_arguments) - { - break; - } } return $configs; From b6cdb2a78cb7d182130b92f1d63deec6f0a2e755 Mon Sep 17 00:00:00 2001 From: netkas Date: Wed, 18 Sep 2024 14:07:08 -0400 Subject: [PATCH 079/134] Add ResolverTest for parseArguments method --- tests/ncc/Utilities/ResolverTest.php | 61 ++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 tests/ncc/Utilities/ResolverTest.php diff --git a/tests/ncc/Utilities/ResolverTest.php b/tests/ncc/Utilities/ResolverTest.php new file mode 100644 index 0000000..37712a3 --- /dev/null +++ b/tests/ncc/Utilities/ResolverTest.php @@ -0,0 +1,61 @@ + 'bar', + 'baz' => 'bat' + ]; + + $result = Resolver::parseArguments($input); + $this->assertEquals($expected, $result); + } + + /** + * Test parseArguments with array input + */ + public function testParseArgumentsWithArray(): void + { + $input = ['--foo=bar', '--baz=bat']; + $expected = [ + 'foo' => 'bar', + 'baz' => 'bat' + ]; + + $result = Resolver::parseArguments($input); + $this->assertEquals($expected, $result); + } +} From ae8021bb3aa1994971a813cdcbb2500cbb2f284c Mon Sep 17 00:00:00 2001 From: netkas Date: Wed, 18 Sep 2024 15:17:53 -0400 Subject: [PATCH 080/134] Fix misplacement of accessor in PackageReader declarations --- src/ncc/Classes/PackageReader.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/ncc/Classes/PackageReader.php b/src/ncc/Classes/PackageReader.php index 83d0857..6903037 100644 --- a/src/ncc/Classes/PackageReader.php +++ b/src/ncc/Classes/PackageReader.php @@ -279,12 +279,12 @@ */ public function getPointer(string $name): array { - if(!isset($this->headers[PackageStructure::DIRECTORY->value[$name]])) + if(!isset($this->headers[PackageStructure::DIRECTORY->value][$name])) { throw new RuntimeException(sprintf('Resource \'%s\' not found in package', $name)); } - $location = explode(':', $this->headers[PackageStructure::DIRECTORY->value[$name]]); + $location = explode(':', $this->headers[PackageStructure::DIRECTORY->value][$name]); return [(int)$location[0], (int)$location[1]]; } @@ -296,7 +296,7 @@ */ public function exists(string $name): bool { - return isset($this->headers[PackageStructure::DIRECTORY->value[$name]]); + return isset($this->headers[PackageStructure::DIRECTORY->value][$name]); } /** @@ -327,7 +327,7 @@ return $this->cache[$directory]; } - if(!isset($this->headers[PackageStructure::DIRECTORY->value[$directory]])) + if(!isset($this->headers[PackageStructure::DIRECTORY->value][$directory])) { throw new ConfigurationException('Package does not contain an assembly'); } @@ -353,7 +353,7 @@ return $this->cache[$directory]; } - if(!isset($this->headers[PackageStructure::DIRECTORY->value[$directory]])) + if(!isset($this->headers[PackageStructure::DIRECTORY->value][$directory])) { throw new ConfigurationException('Package does not contain metadata'); } @@ -382,7 +382,7 @@ return $this->cache[$directory]; } - if(!isset($this->headers[PackageStructure::DIRECTORY->value[$directory]])) + if(!isset($this->headers[PackageStructure::DIRECTORY->value][$directory])) { return null; } @@ -423,7 +423,7 @@ public function getDependency(string $name): Dependency { $dependency_name = sprintf('@%s:%s', PackageDirectory::DEPENDENCIES->value, $name); - if(!isset($this->headers[PackageStructure::DIRECTORY->value[$dependency_name]])) + if(!isset($this->headers[PackageStructure::DIRECTORY->value][$dependency_name])) { throw new ConfigurationException(sprintf('Dependency \'%s\' not found in package', $name)); } @@ -475,7 +475,7 @@ public function getExecutionUnit(string $name): ExecutionUnit { $execution_unit_name = sprintf('@%s:%s', PackageDirectory::EXECUTION_UNITS->value, $name); - if(!isset($this->headers[PackageStructure::DIRECTORY->value[$execution_unit_name]])) + if(!isset($this->headers[PackageStructure::DIRECTORY->value][$execution_unit_name])) { throw new ConfigurationException(sprintf('Execution unit \'%s\' not found in package', $name)); } @@ -579,7 +579,7 @@ public function getComponentByClass(string $class): Component { $class_name = sprintf('@%s:%s', PackageDirectory::CLASS_POINTER->value, $class); - if(!isset($this->headers[PackageStructure::DIRECTORY->value[$class_name]])) + if(!isset($this->headers[PackageStructure::DIRECTORY->value][$class_name])) { throw new ConfigurationException(sprintf('Class map \'%s\' not found in package', $class)); } @@ -618,7 +618,7 @@ public function getResource(string $name): Resource { $resource_name = sprintf('@%s:%s', PackageDirectory::RESOURCES->value, $name); - if(!isset($this->headers[PackageStructure::DIRECTORY->value[$resource_name]])) + if(!isset($this->headers[PackageStructure::DIRECTORY->value][$resource_name])) { throw new ConfigurationException(sprintf('Resource \'%s\' not found in package', $name)); } From 3160ddfa27cec9f5d0d7550c2a54ee8301720edf Mon Sep 17 00:00:00 2001 From: netkas Date: Wed, 18 Sep 2024 15:18:07 -0400 Subject: [PATCH 081/134] Refactor type handling for CompilerExtensions and RepositoryType --- src/ncc/CLI/Management/ProjectMenu.php | 8 ++- src/ncc/Managers/ProjectManager.php | 14 ++--- .../Objects/ProjectConfiguration/Compiler.php | 51 ++++++++----------- .../Objects/ProjectConfiguration/Project.php | 14 +++-- .../UpdateSource/Repository.php | 18 ++++--- src/ncc/Objects/RepositoryConfiguration.php | 43 ++++++++-------- 6 files changed, 76 insertions(+), 72 deletions(-) diff --git a/src/ncc/CLI/Management/ProjectMenu.php b/src/ncc/CLI/Management/ProjectMenu.php index ff83171..bb77bb0 100644 --- a/src/ncc/CLI/Management/ProjectMenu.php +++ b/src/ncc/CLI/Management/ProjectMenu.php @@ -23,6 +23,7 @@ namespace ncc\CLI\Management; use Exception; + use ncc\Enums\CompilerExtensions; use ncc\Enums\ProjectTemplates; use ncc\Enums\Scopes; use ncc\Managers\CredentialManager; @@ -102,7 +103,12 @@ if(isset($args['ext'])) { - $compiler_extension = $args['ext']; + $compiler_extension = CompilerExtensions::tryFrom($args['ext']); + if($compiler_extension === null) + { + Console::outError('Invalid compiler extension, please specify a valid compiler extension', true, 1); + return 1; + } } else { diff --git a/src/ncc/Managers/ProjectManager.php b/src/ncc/Managers/ProjectManager.php index 62800af..ebecf03 100644 --- a/src/ncc/Managers/ProjectManager.php +++ b/src/ncc/Managers/ProjectManager.php @@ -158,16 +158,16 @@ { $configuration = $this->project_configuration->getBuild()->getBuildConfiguration($build_configuration); - return match (strtolower($this->project_configuration->getProject()->getCompiler()->getExtension())) + return match ($this->project_configuration->getProject()->getCompiler()->getExtension()) { - CompilerExtensions::PHP->value => match (strtolower($configuration->getBuildType())) + CompilerExtensions::PHP => match (strtolower($configuration->getBuildType())) { BuildOutputType::NCC_PACKAGE->value => (new NccCompiler($this))->build($build_configuration, $options), BuildOutputType::EXECUTABLE->value => (new ExecutableCompiler($this))->build($build_configuration, $options), default => throw new BuildException(sprintf('php cannot produce the build type \'%s\'', $configuration->getBuildType())), }, - default => throw new NotSupportedException(sprintf('The compiler extension \'%s\' is not supported', $this->project_configuration->getProject()->getCompiler()->getExtension())), + default => throw new NotSupportedException(sprintf('The compiler extension \'%s\' is not supported', $this->project_configuration->getProject()->getCompiler()->getExtension()->value)), }; } @@ -361,7 +361,7 @@ * @param string $project_path The directory for the project to be initialized in * @param string $name The name of the project eg; ProjectLib * @param string $package The standard package name eg; com.example.project - * @param string $compiler The compiler to use for this project + * @param CompilerExtensions $extension The compiler to use for this project * @param array $options An array of options to use when initializing the project * @return ProjectManager * @throws ConfigurationException @@ -369,7 +369,7 @@ * @throws NotSupportedException * @throws PathNotFoundException */ - public static function initializeProject(string $project_path, string $name, string $package, string $compiler, array $options=[]): ProjectManager + public static function initializeProject(string $project_path, string $name, string $package, CompilerExtensions $extension, array $options=[]): ProjectManager { if(str_ends_with($project_path, DIRECTORY_SEPARATOR)) { @@ -416,7 +416,7 @@ $build->setDefaultConfiguration('release'); $project_configuration = new ProjectConfiguration( - new ProjectConfiguration\Project($compiler), + new ProjectConfiguration\Project($extension), new ProjectConfiguration\Assembly($name, $package), $build ); @@ -485,7 +485,7 @@ throw new IOException(sprintf('Project source directory "%s" was not created', $project_src)); } - $project = new ProjectConfiguration\Project(new ProjectConfiguration\Compiler(CompilerExtensions::PHP->value)); + $project = new ProjectConfiguration\Project(CompilerExtensions::PHP); $assembly = new ProjectConfiguration\Assembly( Resolver::composerName($composer_json->getName()), Resolver::composerNameToPackage($composer_json->getName()), diff --git a/src/ncc/Objects/ProjectConfiguration/Compiler.php b/src/ncc/Objects/ProjectConfiguration/Compiler.php index a118006..318a9da 100644 --- a/src/ncc/Objects/ProjectConfiguration/Compiler.php +++ b/src/ncc/Objects/ProjectConfiguration/Compiler.php @@ -44,40 +44,38 @@ /** * The compiler extension that the project uses * - * @var string + * @var CompilerExtensions */ - private $extension; + private CompilerExtensions $extension; /** * The minimum version that is supported * - * @var string + * @var string|null */ - private $minimum_version; + private ?string $minimum_version; /** * The maximum version that is supported * - * @var string + * @var string|null */ - private $maximum_version; + private ?string $maximum_version; /** * Compiler constructor. * - * @param string $extension + * @param CompilerExtensions $extension * @param string|null $minimum_version * @param string|null $maximum_version * @throws NotSupportedException */ - public function __construct(string $extension, ?string $minimum_version=null, ?string $maximum_version=null) + public function __construct(CompilerExtensions $extension, ?string $minimum_version=null, ?string $maximum_version=null) { - $extension = strtolower($extension); - /** @noinspection DegradedSwitchInspection */ switch($extension) { - case CompilerExtensions::PHP->value: + case CompilerExtensions::PHP: if($minimum_version === null) { @@ -92,7 +90,7 @@ break; default: - throw new NotSupportedException(sprintf('The compiler extension \'%s\' is not supported in ncc', $extension)); + throw new NotSupportedException(sprintf('The compiler extension \'%s\' is not supported in ncc', $extension->value)); } $this->extension = $extension; @@ -101,17 +99,18 @@ } /** - * @return string + * @return CompilerExtensions */ - public function getExtension(): string + public function getExtension(): CompilerExtensions { + // TODO: Update usages from here return $this->extension; } /** - * @param string $extension + * @param CompilerExtensions $extension */ - public function setExtension(string $extension): void + public function setExtension(CompilerExtensions $extension): void { $this->extension = $extension; } @@ -157,11 +156,6 @@ */ public function validate(): bool { - if($this->extension === null) - { - throw new ConfigurationException('The property \'extension\' must not be null.'); - } - if($this->minimum_version === null) { throw new ConfigurationException('The property \'minimum_version\' must not be null.'); @@ -184,11 +178,9 @@ throw new ConfigurationException('Version comparison failed: ' . $e->getMessage()); } - /** @noinspection InArrayMissUseInspection */ - // TODO: Fix this, not a proper use of cases() if(!in_array($this->extension, CompilerExtensions::cases(), true)) { - throw new NotSupportedException('The compiler extension \'' . $this->extension . '\' is not supported'); + throw new NotSupportedException('The compiler extension \'' . $this->extension->value . '\' is not supported'); } /** @noinspection DegradedSwitchInspection */ @@ -198,19 +190,19 @@ if(!in_array($this->maximum_version, CompilerExtensionSupportedVersions::PHP, true)) { - throw new NotSupportedException('The property "project.compiler.maximum_version" does not support version ' . $this->maximum_version . ' for the extension ' . $this->extension); + throw new NotSupportedException('The property "project.compiler.maximum_version" does not support version ' . $this->maximum_version . ' for the extension ' . $this->extension->value); } if(!in_array($this->minimum_version, CompilerExtensionSupportedVersions::PHP, true)) { - throw new NotSupportedException('The property "project.compiler.minimum_version" does not support version ' . $this->minimum_version . ' for the extension ' . $this->extension); + throw new NotSupportedException('The property "project.compiler.minimum_version" does not support version ' . $this->minimum_version . ' for the extension ' . $this->extension->value); } break; default: - throw new NotSupportedException('The compiler extension "' . $this->extension . '" is not supported by ncc'); + throw new NotSupportedException('The compiler extension "' . $this->extension->value . '" is not supported by ncc'); } return True; @@ -222,10 +214,7 @@ public function toArray(bool $bytecode = false): array { $results = []; - if($this->extension !== null && $this->extension !== '') - { - $results[($bytecode ? Functions::cbc('extension') : 'extension')] = $this->extension; - } + $results[($bytecode ? Functions::cbc('extension') : 'extension')] = $this->extension->value; if($this->minimum_version !== null && $this->minimum_version !== '') { diff --git a/src/ncc/Objects/ProjectConfiguration/Project.php b/src/ncc/Objects/ProjectConfiguration/Project.php index f708175..5246028 100644 --- a/src/ncc/Objects/ProjectConfiguration/Project.php +++ b/src/ncc/Objects/ProjectConfiguration/Project.php @@ -24,6 +24,7 @@ namespace ncc\Objects\ProjectConfiguration; + use ncc\Enums\CompilerExtensions; use ncc\Exceptions\ConfigurationException; use ncc\Exceptions\NotSupportedException; use ncc\Interfaces\BytecodeObjectInterface; @@ -52,17 +53,20 @@ /** * Public Constructor - * @param string|Compiler $compiler + * @param CompilerExtensions|Compiler $extension * @throws NotSupportedException */ - public function __construct(string|Compiler $compiler) + public function __construct(CompilerExtensions|Compiler $extension) { - if(is_string($compiler)) + if($extension instanceof Compiler) { - $compiler = new Compiler($compiler); + $this->compiler = $extension; + } + else + { + $this->compiler = new Compiler($extension); } - $this->compiler = $compiler; $this->options = []; } diff --git a/src/ncc/Objects/ProjectConfiguration/UpdateSource/Repository.php b/src/ncc/Objects/ProjectConfiguration/UpdateSource/Repository.php index e7d7ff8..ca8c119 100644 --- a/src/ncc/Objects/ProjectConfiguration/UpdateSource/Repository.php +++ b/src/ncc/Objects/ProjectConfiguration/UpdateSource/Repository.php @@ -24,6 +24,7 @@ namespace ncc\Objects\ProjectConfiguration\UpdateSource; + use ncc\Enums\Types\RepositoryType; use ncc\Exceptions\ConfigurationException; use ncc\Interfaces\BytecodeObjectInterface; use ncc\Utilities\Functions; @@ -40,7 +41,7 @@ /** * The type of client that is used to connect to the remote source * - * @var string|null + * @var RepositoryType|null */ private $type; @@ -58,7 +59,7 @@ */ private $ssl; - public function __construct(string $name, string $host, ?string $type=null, bool $ssl=false) + public function __construct(string $name, string $host, ?RepositoryType $type=null, bool $ssl=false) { $this->name = $name; $this->host = $host; @@ -83,17 +84,17 @@ } /** - * @return string|null + * @return RepositoryType|null */ - public function getType(): ?string + public function getType(): ?RepositoryType { return $this->type; } /** - * @param string|null $type + * @param RepositoryType|null $type */ - public function setType(?string $type): void + public function setType(?RepositoryType $type): void { $this->type = $type; } @@ -137,7 +138,8 @@ { return [ ($bytecode ? Functions::cbc('name') : 'name') => $this->name, - ($bytecode ? Functions::cbc('type') : 'type') => $this->type, + // TODO: Review the ? logic here to see if makes sense + ($bytecode ? Functions::cbc('type') : 'type') => ($this->type ? null : $this->type->value), ($bytecode ? Functions::cbc('host') : 'host') => $this->host, ($bytecode ? Functions::cbc('ssl') : 'ssl') => $this->ssl ]; @@ -150,7 +152,7 @@ public static function fromArray(array $data): Repository { $name = Functions::array_bc($data, 'name'); - $type = Functions::array_bc($data, 'type'); + $type = RepositoryType::tryFrom(Functions::array_bc($data, 'type')); $host = Functions::array_bc($data, 'host'); $ssl = Functions::array_bc($data, 'ssl') ?? false; diff --git a/src/ncc/Objects/RepositoryConfiguration.php b/src/ncc/Objects/RepositoryConfiguration.php index 8072f95..d74d46d 100644 --- a/src/ncc/Objects/RepositoryConfiguration.php +++ b/src/ncc/Objects/RepositoryConfiguration.php @@ -52,8 +52,7 @@ private $host; /** - * @var string - * @see RepositoryType + * @var RepositoryType */ private $type; @@ -100,11 +99,10 @@ /** * Returns the type of service ncc should use with this source (gitlab, github, etc...). - * - * @return string - * @see RepositoryType + * + * @return RepositoryType */ - public function getType(): string + public function getType(): RepositoryType { return $this->type; } @@ -175,13 +173,13 @@ */ public function fetchPackage(string $vendor, string $project, string $version=Versions::LATEST->value, ?AuthenticationType $authentication=null, array $options=[]): RepositoryResult { - return match(strtolower($this->type)) + return match($this->type) { - RepositoryType::GITHUB->value => GithubRepository::fetchPackage($this, $vendor, $project, $version, $authentication, $options), - RepositoryType::GITLAB->value => GitlabRepository::fetchPackage($this, $vendor, $project, $version, $authentication, $options), - RepositoryType::GITEA->value => GiteaRepository::fetchPackage($this, $vendor, $project, $version, $authentication, $options), - RepositoryType::PACKAGIST->value => throw new NotSupportedException('Fetching ncc packages from Packagist is not supported'), - default => throw new InvalidArgumentException(sprintf('Invalid repository type \'%s\'', $this->type)), + RepositoryType::GITHUB => GithubRepository::fetchPackage($this, $vendor, $project, $version, $authentication, $options), + RepositoryType::GITLAB => GitlabRepository::fetchPackage($this, $vendor, $project, $version, $authentication, $options), + RepositoryType::GITEA => GiteaRepository::fetchPackage($this, $vendor, $project, $version, $authentication, $options), + RepositoryType::PACKAGIST => throw new NotSupportedException('Fetching ncc packages from Packagist is not supported'), + default => throw new InvalidArgumentException(sprintf('Invalid repository type \'%s\'', $this->type->value)), }; } @@ -199,13 +197,13 @@ */ public function fetchSourceArchive(string $vendor, string $project, string $version=Versions::LATEST->value, ?AuthenticationType $authentication=null, array $options=[]): RepositoryResult { - return match(strtolower($this->type)) + return match($this->type) { - RepositoryType::GITHUB->value => GithubRepository::fetchSourceArchive($this, $vendor, $project, $version, $authentication, $options), - RepositoryType::GITLAB->value => GitlabRepository::fetchSourceArchive($this, $vendor, $project, $version, $authentication, $options), - RepositoryType::GITEA->value => GiteaRepository::fetchSourceArchive($this, $vendor, $project, $version, $authentication, $options), - RepositoryType::PACKAGIST->value => PackagistRepository::fetchSourceArchive($this, $vendor, $project, $version, $authentication, $options), - default => throw new InvalidArgumentException(sprintf('Invalid repository type \'%s\'', $this->type)), + RepositoryType::GITHUB => GithubRepository::fetchSourceArchive($this, $vendor, $project, $version, $authentication, $options), + RepositoryType::GITLAB => GitlabRepository::fetchSourceArchive($this, $vendor, $project, $version, $authentication, $options), + RepositoryType::GITEA => GiteaRepository::fetchSourceArchive($this, $vendor, $project, $version, $authentication, $options), + RepositoryType::PACKAGIST => PackagistRepository::fetchSourceArchive($this, $vendor, $project, $version, $authentication, $options), + default => throw new InvalidArgumentException(sprintf('Invalid repository type \'%s\'', $this->type->value)), }; } @@ -226,7 +224,7 @@ { return [ ($bytecode ? Functions::cbc('name') : 'name') => $this->name, - ($bytecode ? Functions::cbc('type') : 'type') => $this->type, + ($bytecode ? Functions::cbc('type') : 'type') => ($this->type ? null : $this->type->value), ($bytecode ? Functions::cbc('host') : 'host') => $this->host, ($bytecode ? Functions::cbc('ssl') : 'ssl') => $this->ssl ]; @@ -238,10 +236,15 @@ public static function fromArray(array $data): self { $name = Functions::array_bc($data, 'name'); - $type = Functions::array_bc($data, 'type'); + $type = RepositoryType::tryFrom(Functions::array_bc($data, 'type')); $host = Functions::array_bc($data, 'host'); $ssl = Functions::array_bc($data, 'ssl') ?? true; + if($type === null) + { + throw new InvalidArgumentException(sprintf("Unrecognized repository type %s", Functions::array_bc($data, 'type'))); + } + return new self($name, $host, $type, $ssl); } } \ No newline at end of file From 3adc1b81fbaad5a4c4b263237a39cee886c34a3e Mon Sep 17 00:00:00 2001 From: netkas Date: Wed, 18 Sep 2024 15:20:04 -0400 Subject: [PATCH 082/134] Improve error handling for compiler extensions --- src/ncc/Objects/ProjectConfiguration/Compiler.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ncc/Objects/ProjectConfiguration/Compiler.php b/src/ncc/Objects/ProjectConfiguration/Compiler.php index 318a9da..1c12dff 100644 --- a/src/ncc/Objects/ProjectConfiguration/Compiler.php +++ b/src/ncc/Objects/ProjectConfiguration/Compiler.php @@ -103,7 +103,6 @@ */ public function getExtension(): CompilerExtensions { - // TODO: Update usages from here return $this->extension; } @@ -243,9 +242,12 @@ throw new ConfigurationException('The property \'project.compiler.extension\' must not be null.'); } - return new self(Functions::array_bc($data, 'extension'), - Functions::array_bc($data, 'maximum_version'), - Functions::array_bc($data, 'minimum_version') - ); + $extension = CompilerExtensions::tryFrom(Functions::array_bc($data, 'extension')); + if($extension === null) + { + throw new ConfigurationException('The property \'project.compiler.extension\' is not a valid extension'); + } + + return new self($extension, Functions::array_bc($data, 'maximum_version'), Functions::array_bc($data, 'minimum_version')); } } \ No newline at end of file From 8e6acbbc70a79b24197d61c10b7845e90542a496 Mon Sep 17 00:00:00 2001 From: netkas Date: Wed, 18 Sep 2024 15:28:53 -0400 Subject: [PATCH 083/134] Handle missing 'file' in stack trace --- src/ncc/Utilities/Console.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ncc/Utilities/Console.php b/src/ncc/Utilities/Console.php index a7050cd..a35516a 100644 --- a/src/ncc/Utilities/Console.php +++ b/src/ncc/Utilities/Console.php @@ -329,6 +329,12 @@ self::out('Stack Trace:'); foreach($trace as $item) { + if(!isset($item['file'])) + { + self::out(' - ' . self::formatColor(json_encode($item), ConsoleColors::RED->value)); + continue; + } + self::out( ' - ' . self::formatColor($item['file'], ConsoleColors::RED->value) . ':' . $item['line']); } } From 46fd39c51c81d78416399521d14fecb49d37dd04 Mon Sep 17 00:00:00 2001 From: netkas Date: Wed, 18 Sep 2024 15:30:44 -0400 Subject: [PATCH 084/134] Improve error messages in Repository configuration --- .../Objects/ProjectConfiguration/UpdateSource/Repository.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ncc/Objects/ProjectConfiguration/UpdateSource/Repository.php b/src/ncc/Objects/ProjectConfiguration/UpdateSource/Repository.php index ca8c119..b74d84d 100644 --- a/src/ncc/Objects/ProjectConfiguration/UpdateSource/Repository.php +++ b/src/ncc/Objects/ProjectConfiguration/UpdateSource/Repository.php @@ -163,12 +163,12 @@ if($type === null) { - throw new ConfigurationException("The UpdateSource's Repository property requires 'type'"); + throw new ConfigurationException(sprintf("The UpdateSource's Repository %s property requires 'type' got '%s' instead", $name, Functions::array_bc($data, 'type'))); } if($host === null) { - throw new ConfigurationException("The UpdateSource's Repository property requires 'host'"); + throw new ConfigurationException(sprintf("The UpdateSource's Repository %s property requires 'host'", $name)); } return new self($name, $host, $type, $ssl); From bdcf5160deb4f6e4bba6be1fbd4ffca09d19badd Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 00:17:49 -0400 Subject: [PATCH 085/134] Update Console color formatting method --- src/ncc/CLI/Management/PackageManagerMenu.php | 6 +-- src/ncc/CLI/Management/RepositoryMenu.php | 6 +-- src/ncc/Objects/CliHelpSection.php | 4 +- src/ncc/Utilities/Console.php | 44 +++++++++---------- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/ncc/CLI/Management/PackageManagerMenu.php b/src/ncc/CLI/Management/PackageManagerMenu.php index 01d61e3..58dc746 100644 --- a/src/ncc/CLI/Management/PackageManagerMenu.php +++ b/src/ncc/CLI/Management/PackageManagerMenu.php @@ -342,9 +342,9 @@ private static function printTree($data, string $prefix=''): void { $symbols = [ - 'corner' => Console::formatColor(' └─', ConsoleColors::LIGHT_RED->value), - 'line' => Console::formatColor(' │ ', ConsoleColors::LIGHT_RED->value), - 'cross' => Console::formatColor(' ├─', ConsoleColors::LIGHT_RED->value), + 'corner' => Console::formatColor(' └─', ConsoleColors::LIGHT_RED), + 'line' => Console::formatColor(' │ ', ConsoleColors::LIGHT_RED), + 'cross' => Console::formatColor(' ├─', ConsoleColors::LIGHT_RED), ]; $keys = array_keys($data); diff --git a/src/ncc/CLI/Management/RepositoryMenu.php b/src/ncc/CLI/Management/RepositoryMenu.php index 8d2165c..8a986f6 100644 --- a/src/ncc/CLI/Management/RepositoryMenu.php +++ b/src/ncc/CLI/Management/RepositoryMenu.php @@ -118,13 +118,13 @@ { $output = sprintf('%s (%s) [%s]', $source->getName(), - Console::formatColor($source->getHost(), ConsoleColors::GREEN->value), - Console::formatColor($source->getType(), ConsoleColors::YELLOW->value) + Console::formatColor($source->getHost(), ConsoleColors::GREEN), + Console::formatColor($source->getType(), ConsoleColors::YELLOW) ); if(!$source->isSsl()) { - $output .= Console::formatColor('*', ConsoleColors::RED->value); + $output .= Console::formatColor('*', ConsoleColors::RED); } Console::out(' - ' . $output); diff --git a/src/ncc/Objects/CliHelpSection.php b/src/ncc/Objects/CliHelpSection.php index 07ad35d..710beef 100644 --- a/src/ncc/Objects/CliHelpSection.php +++ b/src/ncc/Objects/CliHelpSection.php @@ -174,7 +174,7 @@ if(!$basic) { - $result = Console::formatColor($result, ConsoleColors::GREEN->value); + $result = Console::formatColor($result, ConsoleColors::GREEN); } $out[] .= $result; @@ -185,7 +185,7 @@ } else { - $out[] .= Console::formatColor(implode(' ', $this->parameters), ConsoleColors::GREEN->value); + $out[] .= Console::formatColor(implode(' ', $this->parameters), ConsoleColors::GREEN); } } diff --git a/src/ncc/Utilities/Console.php b/src/ncc/Utilities/Console.php index a35516a..2deeb22 100644 --- a/src/ncc/Utilities/Console.php +++ b/src/ncc/Utilities/Console.php @@ -53,13 +53,13 @@ private static function setPrefix(string $log_level, string $input): string { $input = match ($log_level) { - LogLevel::VERBOSE->value => self::formatColor('VRB:', ConsoleColors::LIGHT_CYAN->value) . " $input", - LogLevel::DEBUG->value => self::formatColor('DBG:', ConsoleColors::LIGHT_MAGENTA->value) . " $input", - LogLevel::INFO->value => self::formatColor('INF:', ConsoleColors::WHITE->value) . " $input", - LogLevel::WARNING->value => self::formatColor('WRN:', ConsoleColors::YELLOW->value) . " $input", - LogLevel::ERROR->value => self::formatColor('ERR:', ConsoleColors::LIGHT_RED->value) . " $input", - LogLevel::FATAL->value => self::formatColor('FTL:', ConsoleColors::LIGHT_RED->value) . " $input", - default => self::formatColor('MSG:', ConsoleColors::DEFAULT->value) . " $input", + LogLevel::VERBOSE->value => self::formatColor('VRB:', ConsoleColors::LIGHT_CYAN) . " $input", + LogLevel::DEBUG->value => self::formatColor('DBG:', ConsoleColors::LIGHT_MAGENTA) . " $input", + LogLevel::INFO->value => self::formatColor('INF:', ConsoleColors::WHITE) . " $input", + LogLevel::WARNING->value => self::formatColor('WRN:', ConsoleColors::YELLOW) . " $input", + LogLevel::ERROR->value => self::formatColor('ERR:', ConsoleColors::LIGHT_RED) . " $input", + LogLevel::FATAL->value => self::formatColor('FTL:', ConsoleColors::LIGHT_RED) . " $input", + default => self::formatColor('MSG:', ConsoleColors::DEFAULT) . " $input", }; $tick_time = (string)microtime(true); @@ -82,11 +82,11 @@ if ($timeDiff > 1.0) { - $fmt_tick = self::formatColor($tick_time, ConsoleColors::LIGHT_RED->value); + $fmt_tick = self::formatColor($tick_time, ConsoleColors::LIGHT_RED); } elseif ($timeDiff > 0.5) { - $fmt_tick = self::formatColor($tick_time, ConsoleColors::LIGHT_YELLOW->value); + $fmt_tick = self::formatColor($tick_time, ConsoleColors::LIGHT_YELLOW); } } @@ -155,9 +155,9 @@ $trace_msg = null; if($backtrace !== null && isset($backtrace[1])) { - $trace_msg = self::formatColor($backtrace[1]['class'], ConsoleColors::LIGHT_GREY->value); + $trace_msg = self::formatColor($backtrace[1]['class'], ConsoleColors::LIGHT_GREY); $trace_msg .= $backtrace[1]['type']; - $trace_msg .= self::formatColor($backtrace[1]['function'] . '()', ConsoleColors::LIGHT_GREEN->value); + $trace_msg .= self::formatColor($backtrace[1]['function'] . '()', ConsoleColors::LIGHT_GREEN); $trace_msg .= ' > '; } @@ -192,11 +192,11 @@ * Formats the text to have a different color and returns the formatted value * * @param string $input The input of the text value - * @param string $color_code The color code of the escaped character (\e[91m) + * @param ConsoleColors $color_code The color code of the escaped character (\e[91m) * @param bool $persist If true, the formatting will terminate in the default color * @return string */ - public static function formatColor(string $input, string $color_code, bool $persist=true): string + public static function formatColor(string $input, ConsoleColors $color_code, bool $persist=true): string { if(isset(Main::getArgs()['no-color'])) { @@ -205,10 +205,10 @@ if($persist) { - return $color_code . $input . ConsoleColors::DEFAULT->value; + return $color_code->value . $input . ConsoleColors::DEFAULT->value; } - return $color_code . $input; + return $color_code->value . $input; } /** @@ -236,7 +236,7 @@ return; } - self::out(self::formatColor('Warning: ', ConsoleColors::YELLOW->value) . $message, $newline); + self::out(self::formatColor('Warning: ', ConsoleColors::YELLOW) . $message, $newline); } /** @@ -265,7 +265,7 @@ } else { - self::out(self::formatColor(ConsoleColors::RED->value, 'Error: ') . $message, $newline); + self::out(self::formatColor('Error: ', ConsoleColors::RED) . $message, $newline); } if($exit_code !== null) @@ -291,7 +291,7 @@ if($message !== '' && LogLevel::ERROR->checkLogLevel(Main::getLogLevel())) { - self::out(PHP_EOL . self::formatColor('Error: ', ConsoleColors::RED->value) . $message); + self::out(PHP_EOL . self::formatColor('Error: ', ConsoleColors::RED) . $message); } self::out(PHP_EOL . '===== Exception Details ====='); @@ -318,8 +318,8 @@ } // Exception name without namespace - $trace_header = self::formatColor($e->getFile() . ':' . $e->getLine(), ConsoleColors::MAGENTA->value); - $trace_error = self::formatColor( 'Error: ', ConsoleColors::RED->value); + $trace_header = self::formatColor($e->getFile() . ':' . $e->getLine(), ConsoleColors::MAGENTA); + $trace_error = self::formatColor( 'Error: ', ConsoleColors::RED); self::out($trace_header . ' ' . $trace_error . $e->getMessage()); self::out(sprintf('Exception: %s', get_class($e))); self::out(sprintf('Error code: %s', $e->getCode())); @@ -331,11 +331,11 @@ { if(!isset($item['file'])) { - self::out(' - ' . self::formatColor(json_encode($item), ConsoleColors::RED->value)); + self::out(' - ' . self::formatColor(json_encode($item), ConsoleColors::RED)); continue; } - self::out( ' - ' . self::formatColor($item['file'], ConsoleColors::RED->value) . ':' . $item['line']); + self::out( ' - ' . self::formatColor($item['file'], ConsoleColors::RED) . ':' . $item['line']); } } From 943048785dfcc1022cf214c42cccd68e7414fb71 Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 00:19:06 -0400 Subject: [PATCH 086/134] Refactor Console color formatting --- src/installer/installer | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/installer/installer b/src/installer/installer index 9605d44..6cf9ee7 100644 --- a/src/installer/installer +++ b/src/installer/installer @@ -181,11 +181,11 @@ { if($installed) { - Console::out("$ext ... " . Console::formatColor("installed", ConsoleColors::LIGHT_GREEN->value)); + Console::out("$ext ... " . Console::formatColor("installed", ConsoleColors::LIGHT_GREEN)); } else { - Console::out("$ext ... " . Console::formatColor("missing", ConsoleColors::LIGHT_RED->value)); + Console::out("$ext ... " . Console::formatColor("missing", ConsoleColors::LIGHT_RED)); } } @@ -210,11 +210,11 @@ try { - Console::out(Console::formatColor($full_name, ConsoleColors::GREEN->value) . ' Version: ' . Console::formatColor($component->getVersion(), ConsoleColors::LIGHT_MAGENTA->value)); + Console::out(Console::formatColor($full_name, ConsoleColors::GREEN) . ' Version: ' . Console::formatColor($component->getVersion(), ConsoleColors::LIGHT_MAGENTA)); } catch (Exception $e) { - Console::outWarning('Cannot determine component version of ' . Console::formatColor($full_name, ConsoleColors::GREEN->value)); + Console::outWarning('Cannot determine component version of ' . Console::formatColor($full_name, ConsoleColors::GREEN)); } } From da8a6fac01ea39e5a409466316391998f06830d0 Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 00:31:57 -0400 Subject: [PATCH 087/134] Update repository type handling in verbose output --- src/ncc/Managers/RepositoryManager.php | 2 +- src/ncc/Objects/ProjectConfiguration/UpdateSource.php | 1 - src/ncc/Objects/RepositoryConfiguration.php | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ncc/Managers/RepositoryManager.php b/src/ncc/Managers/RepositoryManager.php index d70e4cb..e3a7558 100644 --- a/src/ncc/Managers/RepositoryManager.php +++ b/src/ncc/Managers/RepositoryManager.php @@ -119,7 +119,7 @@ throw new InvalidArgumentException(sprintf('The remote source \'%s\' already exists', $source->getName())); } - Console::outVerbose(sprintf('Adding repository \'%s\' as %s (type: %s)', $source->getHost(), $source->getName(), $source->getType())); + Console::outVerbose(sprintf('Adding repository \'%s\' as %s (type: %s)', $source->getHost(), $source->getName(), $source->getType()->value)); $this->repositories[] = $source; if($update) diff --git a/src/ncc/Objects/ProjectConfiguration/UpdateSource.php b/src/ncc/Objects/ProjectConfiguration/UpdateSource.php index db8e64d..ddb222c 100644 --- a/src/ncc/Objects/ProjectConfiguration/UpdateSource.php +++ b/src/ncc/Objects/ProjectConfiguration/UpdateSource.php @@ -116,7 +116,6 @@ $repository = Repository::fromArray($repository); } - return new self($source, $repository); } } \ No newline at end of file diff --git a/src/ncc/Objects/RepositoryConfiguration.php b/src/ncc/Objects/RepositoryConfiguration.php index d74d46d..313df4b 100644 --- a/src/ncc/Objects/RepositoryConfiguration.php +++ b/src/ncc/Objects/RepositoryConfiguration.php @@ -224,7 +224,7 @@ { return [ ($bytecode ? Functions::cbc('name') : 'name') => $this->name, - ($bytecode ? Functions::cbc('type') : 'type') => ($this->type ? null : $this->type->value), + ($bytecode ? Functions::cbc('type') : 'type') => ($this->type?->value), ($bytecode ? Functions::cbc('host') : 'host') => $this->host, ($bytecode ? Functions::cbc('ssl') : 'ssl') => $this->ssl ]; From 3950655024bac24e2d48e292aef2fd50a0f7b186 Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 00:41:31 -0400 Subject: [PATCH 088/134] Remove PACKAGE_LOCK_VERSION constant from Versions enum --- src/ncc/Enums/Versions.php | 5 ----- src/ncc/Objects/PackageLock.php | 16 +++++++++------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/ncc/Enums/Versions.php b/src/ncc/Enums/Versions.php index b7d1314..a2ac68b 100644 --- a/src/ncc/Enums/Versions.php +++ b/src/ncc/Enums/Versions.php @@ -29,11 +29,6 @@ */ case CREDENTIALS_STORE_VERSION = '1.0.0'; - /** - * The current version of the package lock structure file format - */ - case PACKAGE_LOCK_VERSION = '2.0.0'; - /** * Generic version of the package structure file format (latest) */ diff --git a/src/ncc/Objects/PackageLock.php b/src/ncc/Objects/PackageLock.php index a4d42b1..24bbb4a 100644 --- a/src/ncc/Objects/PackageLock.php +++ b/src/ncc/Objects/PackageLock.php @@ -35,10 +35,12 @@ class PackageLock implements BytecodeObjectInterface { + private const string PACKAGE_LOCK_VERSION = '2.0.0'; + /** * The version of package lock file structure * - * @var string + * @var Versions */ private $package_lock_version; @@ -59,11 +61,11 @@ /** * Public Constructor */ - public function __construct(array $entries=[], string $package_lock_version=Versions::PACKAGE_LOCK_VERSION->value, ?int $last_updated_timestamp=null) + public function __construct(array $entries=[], ?int $last_updated_timestamp=null) { $this->entries = $entries; - $this->package_lock_version = $package_lock_version; - $this->last_updated_timestamp = $last_updated_timestamp ?? time(); + $this->package_lock_version = self::PACKAGE_LOCK_VERSION; + $this->last_updated_timestamp = $last_updated_timestamp ? null : time(); } /** @@ -93,7 +95,7 @@ */ private function update(): void { - $this->package_lock_version = Versions::PACKAGE_LOCK_VERSION; + $this->package_lock_version = self::PACKAGE_LOCK_VERSION; $this->last_updated_timestamp = time(); } @@ -280,7 +282,7 @@ }, $entries_array); - $package_lock_version = Functions::array_bc($data, 'package_lock_version') ?? Versions::PACKAGE_LOCK_VERSION->value; + $package_lock_version = Functions::array_bc($data, 'package_lock_version') ?? self::PACKAGE_LOCK_VERSION; $last_updated_timestamp = Functions::array_bc($data, 'last_updated_timestamp') ?? time(); if($package_lock_version === null) @@ -288,6 +290,6 @@ throw new ConfigurationException('Package lock version is missing'); } - return new self($entries, $package_lock_version, $last_updated_timestamp); + return new self($entries, $last_updated_timestamp); } } \ No newline at end of file From 604e1fd3e7567a71cbc533bb7f11e2713472fdbd Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 00:41:39 -0400 Subject: [PATCH 089/134] Update PHP language level to 8.3 --- .idea/php.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.idea/php.xml b/.idea/php.xml index ab9e746..7faa7db 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -14,7 +14,7 @@ - + From b2d2a1ea154ab4afa199605e2995003a0b27386f Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 00:50:00 -0400 Subject: [PATCH 090/134] Simplify optional type value retrieval --- .../Objects/ProjectConfiguration/UpdateSource/Repository.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ncc/Objects/ProjectConfiguration/UpdateSource/Repository.php b/src/ncc/Objects/ProjectConfiguration/UpdateSource/Repository.php index b74d84d..393517c 100644 --- a/src/ncc/Objects/ProjectConfiguration/UpdateSource/Repository.php +++ b/src/ncc/Objects/ProjectConfiguration/UpdateSource/Repository.php @@ -138,8 +138,7 @@ { return [ ($bytecode ? Functions::cbc('name') : 'name') => $this->name, - // TODO: Review the ? logic here to see if makes sense - ($bytecode ? Functions::cbc('type') : 'type') => ($this->type ? null : $this->type->value), + ($bytecode ? Functions::cbc('type') : 'type') => $this->type?->value, ($bytecode ? Functions::cbc('host') : 'host') => $this->host, ($bytecode ? Functions::cbc('ssl') : 'ssl') => $this->ssl ]; From 3aedd2d94dac9d59c9f3f36642efe8c40280917d Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 00:57:52 -0400 Subject: [PATCH 091/134] Remove ComponentFileExtensions enum --- src/ncc/Enums/ComponentFileExtensions.php | 34 ----------------------- src/ncc/Managers/ProjectManager.php | 6 +--- 2 files changed, 1 insertion(+), 39 deletions(-) delete mode 100644 src/ncc/Enums/ComponentFileExtensions.php diff --git a/src/ncc/Enums/ComponentFileExtensions.php b/src/ncc/Enums/ComponentFileExtensions.php deleted file mode 100644 index 1512a21..0000000 --- a/src/ncc/Enums/ComponentFileExtensions.php +++ /dev/null @@ -1,34 +0,0 @@ -getProjectConfiguration()->getProject()->getCompiler()->getExtension()) { - CompilerExtensions::PHP->value => ComponentFileExtensions::PHP, - default => throw new NotSupportedException( - sprintf('The compiler extension \'%s\' is not supported', $this->getProjectConfiguration()->getProject()->getCompiler()->getExtension()) - ), + CompilerExtensions::PHP => ['*.php', '*.php3', '*.php4', '*.php5', '*.phtml'] }; } From 16ad69b9f241336b0cfc999be96e56e0de8fea89 Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 01:02:08 -0400 Subject: [PATCH 092/134] Remove RuntimeInterface.php --- src/ncc/Interfaces/RuntimeInterface.php | 37 ------------------------- 1 file changed, 37 deletions(-) delete mode 100644 src/ncc/Interfaces/RuntimeInterface.php diff --git a/src/ncc/Interfaces/RuntimeInterface.php b/src/ncc/Interfaces/RuntimeInterface.php deleted file mode 100644 index e0be6a0..0000000 --- a/src/ncc/Interfaces/RuntimeInterface.php +++ /dev/null @@ -1,37 +0,0 @@ - Date: Thu, 19 Sep 2024 13:16:58 -0400 Subject: [PATCH 093/134] Add support for runtime constants --- src/ncc/Classes/NccExtension/NccCompiler.php | 3 ++ src/ncc/Classes/Runtime.php | 30 +++++++++++++++++ src/ncc/Managers/ProjectManager.php | 13 ++------ src/ncc/Objects/Package/Metadata.php | 34 ++++++++++++++++++++ 4 files changed, 70 insertions(+), 10 deletions(-) diff --git a/src/ncc/Classes/NccExtension/NccCompiler.php b/src/ncc/Classes/NccExtension/NccCompiler.php index 8ccdc45..c079ddc 100644 --- a/src/ncc/Classes/NccExtension/NccCompiler.php +++ b/src/ncc/Classes/NccExtension/NccCompiler.php @@ -333,6 +333,8 @@ $metadata->addOptions($this->project_manager->getProjectConfiguration()->getBuild()->getOptions($build_configuration)); $metadata->addOptions($this->project_manager->getProjectConfiguration()->getProject()->getOptions()); + $metadata->addConstants($this->project_manager->getRuntimeConstants($build_configuration)); + $metadata->addConstants($this->project_manager->getRuntimeConstants()); $metadata->setUpdateSource($this->project_manager->getProjectConfiguration()->getProject()->getUpdateSource()); $metadata->setMainExecutionPolicy($this->project_manager->getProjectConfiguration()->getBuild()->getMain()); $metadata->setInstaller($this->project_manager->getProjectConfiguration()->getInstaller()); @@ -350,6 +352,7 @@ $metadata->removeOption(BuildConfigurationOptions::STATIC_DEPENDENCIES->value); } + /** @noinspection UnusedFunctionResultInspection */ $package_writer->setMetadata($metadata); } diff --git a/src/ncc/Classes/Runtime.php b/src/ncc/Classes/Runtime.php index 6675bca..a324a2d 100644 --- a/src/ncc/Classes/Runtime.php +++ b/src/ncc/Classes/Runtime.php @@ -44,9 +44,11 @@ use ncc\Utilities\Console; use ncc\Utilities\IO; use ncc\Utilities\Resolver; + use ncc\Utilities\RuntimeCache; use ncc\Utilities\Validate; use RuntimeException; use Throwable; + use function trigger_error; class Runtime { @@ -209,6 +211,34 @@ } } + $safe_package_name = strtoupper($entry->getAssembly($version)->getName()); + foreach($entry->getMetadata($version)->getConstants() as $constant => $value) + { + $constant_full_name = sprintf("%s_%s", $safe_package_name, $constant); + + // Skip if already defined. + if(defined($constant_full_name)) + { + if(RuntimeCache::get(sprintf("defined_%s", $constant_full_name))) + { + continue; + } + + trigger_error(sprintf('Cannot define constant %s from package %s because the constant is already defined', $constant_full_name, $package), E_USER_WARNING); + continue; + } + + if(!Validate::constantName($constant_full_name)) + { + // trigger warning only + trigger_error(sprintf('Cannot define constant %s from package %s because the constant name is invalid', $constant_full_name, $package), E_USER_WARNING); + continue; + } + + RuntimeCache::set(sprintf("defined_%s", $constant_full_name), true); + define($constant_full_name, $value); + } + if(isset($entry->getMetadata($version)->getOptions()[PackageFlags::STATIC_DEPENDENCIES->value])) { // Fake import the dependencies diff --git a/src/ncc/Managers/ProjectManager.php b/src/ncc/Managers/ProjectManager.php index 5b7dfe8..58c2b82 100644 --- a/src/ncc/Managers/ProjectManager.php +++ b/src/ncc/Managers/ProjectManager.php @@ -203,11 +203,10 @@ * * @param AuthenticationInterface|null $authentication * @return array Array of installed packages - * @throws OperationException - * @throws IOException * @throws ConfigurationException + * @throws IOException + * @throws OperationException * @throws PathNotFoundException - * @throws NotSupportedException */ public function installDependencies(?AuthenticationInterface $authentication=null): array { @@ -295,7 +294,6 @@ * * @param string $build_configuration * @return array - * @throws NotSupportedException */ public function getComponents(string $build_configuration=BuildConfigurationValues::DEFAULT->value): array { @@ -311,7 +309,6 @@ * * @param string $build_configuration * @return array - * @throws NotSupportedException */ public function getResources(string $build_configuration=BuildConfigurationValues::DEFAULT->value): array { @@ -333,11 +330,7 @@ public function getRuntimeConstants(string $build_configuration=BuildConfigurationValues::DEFAULT->value): array { $configuration = $this->project_configuration->getBuild()->getBuildConfiguration($build_configuration); - - return array_merge( - $configuration->getDefineConstants(), - $this->project_configuration->getBuild()->getDefineConstants() - ); + return array_merge($configuration->getDefineConstants(), $this->project_configuration->getBuild()->getDefineConstants()); } /** diff --git a/src/ncc/Objects/Package/Metadata.php b/src/ncc/Objects/Package/Metadata.php index 1d75e34..95265ea 100644 --- a/src/ncc/Objects/Package/Metadata.php +++ b/src/ncc/Objects/Package/Metadata.php @@ -59,6 +59,11 @@ */ private $main_execution_policy; + /** + * @var array + */ + private $constants; + /** * @var Installer|null */ @@ -74,6 +79,7 @@ { $this->compiler_extension = $compiler; $this->compiler_version = NCC_VERSION_NUMBER; + $this->constants = []; $this->options = []; } @@ -117,6 +123,27 @@ $this->compiler_version = $compiler_version; } + /** + * Returns the constants associated with the class + * + * @return array + */ + public function getConstants(): array + { + return $this->constants; + } + + /** + * Sets an array of constants to be used within the package + * + * @param array $constants + * @return void + */ + public function addConstants(array $constants): void + { + $this->constants = array_merge($this->constants, $constants); + } + /** * Returns an array of options associated with the package * @@ -258,6 +285,7 @@ ($bytecode ? Functions::cbc('update_source') : 'update_source') => ($this->update_source?->toArray($bytecode)), ($bytecode ? Functions::cbc('installer') : 'installer') => ($this->installer?->toArray($bytecode)), ($bytecode ? Functions::cbc('main_execution_policy') : 'main_execution_policy') => $this->main_execution_policy, + ($bytecode ? Functions::cbc('constants') : 'constants') => $this->constants, ($bytecode ? Functions::cbc('options') : 'options') => $this->options, ]; } @@ -284,8 +312,14 @@ $object->options = Functions::array_bc($data, 'options'); $object->update_source = Functions::array_bc($data, 'update_source'); $object->main_execution_policy = Functions::array_bc($data, 'main_execution_policy'); + $object->constants = Functions::array_bc($data, 'constants'); $object->installer = Functions::array_bc($data, 'installer'); + if($object->constants === null) + { + $object->constants = []; + } + if($object->update_source !== null) { $object->update_source = UpdateSource::fromArray($object->update_source); From bcb26d1eec115e7de29553d33bcb609b2655b36a Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 13:29:02 -0400 Subject: [PATCH 094/134] Updated Composer/Semver to 3.4.3 --- .../PackagistRepository.php | 4 +- src/ncc/Objects/ComposerJson/PackageLink.php | 2 +- src/ncc/Objects/PackageLock/PackageEntry.php | 2 +- .../ThirdParty/composer/semver/CHANGELOG.md | 229 ++++++++++++++++++ .../composer/semver/CompilingMatcher.php | 2 +- src/ncc/ThirdParty/composer/semver/VERSION | 2 +- .../composer/semver/VersionParser.php | 5 + 7 files changed, 240 insertions(+), 6 deletions(-) create mode 100644 src/ncc/ThirdParty/composer/semver/CHANGELOG.md diff --git a/src/ncc/Classes/PackagistExtension/PackagistRepository.php b/src/ncc/Classes/PackagistExtension/PackagistRepository.php index d8d9e7d..a6b29a7 100644 --- a/src/ncc/Classes/PackagistExtension/PackagistRepository.php +++ b/src/ncc/Classes/PackagistExtension/PackagistRepository.php @@ -35,8 +35,8 @@ use ncc\Interfaces\RepositoryInterface; use ncc\Objects\RepositoryConfiguration; use ncc\Objects\RepositoryResult; - use ncc\ThirdParty\composer\Semver\Comparator; - use ncc\ThirdParty\composer\Semver\Semver; + use ncc\ThirdParty\composer\semver\Comparator; + use ncc\ThirdParty\composer\semver\Semver; use ncc\Utilities\Console; use ncc\Utilities\RuntimeCache; use RuntimeException; diff --git a/src/ncc/Objects/ComposerJson/PackageLink.php b/src/ncc/Objects/ComposerJson/PackageLink.php index 792d2ab..a10c4ab 100644 --- a/src/ncc/Objects/ComposerJson/PackageLink.php +++ b/src/ncc/Objects/ComposerJson/PackageLink.php @@ -26,7 +26,7 @@ namespace ncc\Objects\ComposerJson; use ncc\Interfaces\SerializableObjectInterface; - use ncc\ThirdParty\composer\Semver\VersionParser; + use ncc\ThirdParty\composer\semver\VersionParser; class PackageLink implements SerializableObjectInterface { diff --git a/src/ncc/Objects/PackageLock/PackageEntry.php b/src/ncc/Objects/PackageLock/PackageEntry.php index d0a3e85..12445dc 100644 --- a/src/ncc/Objects/PackageLock/PackageEntry.php +++ b/src/ncc/Objects/PackageLock/PackageEntry.php @@ -39,7 +39,7 @@ use ncc\Objects\ProjectConfiguration\ExecutionPolicy; use ncc\Objects\ProjectConfiguration\Installer; use ncc\Objects\ProjectConfiguration\UpdateSource; - use ncc\ThirdParty\composer\Semver\Semver; + use ncc\ThirdParty\composer\semver\Semver; use ncc\ThirdParty\jelix\Version\VersionComparator; use ncc\Utilities\Functions; use ncc\Utilities\IO; diff --git a/src/ncc/ThirdParty/composer/semver/CHANGELOG.md b/src/ncc/ThirdParty/composer/semver/CHANGELOG.md new file mode 100644 index 0000000..bad46cd --- /dev/null +++ b/src/ncc/ThirdParty/composer/semver/CHANGELOG.md @@ -0,0 +1,229 @@ +# Change Log + +All notable changes to this project will be documented in this file. +This project adheres to [Semantic Versioning](http://semver.org/). + +### [3.4.3] 2024-09-19 + + * Fixed some type annotations + +### [3.4.2] 2024-07-12 + + * Fixed PHP 5.3 syntax error + +### [3.4.1] 2024-07-12 + + * Fixed normalizeStability's return type to enforce valid stabilities + +### [3.4.0] 2023-08-31 + + * Support larger major version numbers (#149) + +### [3.3.2] 2022-04-01 + + * Fixed handling of non-string values (#134) + +### [3.3.1] 2022-03-16 + + * Fixed possible cache key clash in the CompilingMatcher memoization (#132) + +### [3.3.0] 2022-03-15 + + * Improved performance of CompilingMatcher by memoizing more (#131) + * Added CompilingMatcher::clear to clear all memoization caches + +### [3.2.9] 2022-02-04 + + * Revert #129 (Fixed MultiConstraint with MatchAllConstraint) which caused regressions + +### [3.2.8] 2022-02-04 + + * Updates to latest phpstan / CI by @Seldaek in https://github.com/composer/semver/pull/130 + * Fixed MultiConstraint with MatchAllConstraint by @Toflar in https://github.com/composer/semver/pull/129 + +### [3.2.7] 2022-01-04 + + * Fixed: typo in type definition of Intervals class causing issues with Psalm scanning vendors + +### [3.2.6] 2021-10-25 + + * Fixed: type improvements to parseStability + +### [3.2.5] 2021-05-24 + + * Fixed: issue comparing disjunctive MultiConstraints to conjunctive ones (#127) + * Fixed: added complete type information using phpstan annotations + +### [3.2.4] 2020-11-13 + + * Fixed: code clean-up + +### [3.2.3] 2020-11-12 + + * Fixed: constraints in the form of `X || Y, >=Y.1` and other such complex constructs were in some cases being optimized into a more restrictive constraint + +### [3.2.2] 2020-10-14 + + * Fixed: internal code cleanups + +### [3.2.1] 2020-09-27 + + * Fixed: accidental validation of broken constraints combining ^/~ and wildcards, and -dev suffix allowing weird cases + * Fixed: normalization of beta0 and such which was dropping the 0 + +### [3.2.0] 2020-09-09 + + * Added: support for `x || @dev`, not very useful but seen in the wild and failed to validate with 1.5.2/1.6.0 + * Added: support for `foobar-dev` being equal to `dev-foobar`, dev-foobar is the official way to write it but we need to support the other for BC and convenience + +### [3.1.0] 2020-09-08 + + * Added: support for constraints like `^2.x-dev` and `~2.x-dev`, not very useful but seen in the wild and failed to validate with 3.0.1 + * Fixed: invalid aliases will no longer throw, unless explicitly validated by Composer in the root package + +### [3.0.1] 2020-09-08 + + * Fixed: handling of some invalid -dev versions which were seen as valid + +### [3.0.0] 2020-05-26 + + * Break: Renamed `EmptyConstraint`, replace it with `MatchAllConstraint` + * Break: Unlikely to affect anyone but strictly speaking a breaking change, `*.*` and such variants will not match all `dev-*` versions anymore, only `*` does + * Break: ConstraintInterface is now considered internal/private and not meant to be implemented by third parties anymore + * Added `Intervals` class to check if a constraint is a subsets of another one, and allow compacting complex MultiConstraints into simpler ones + * Added `CompilingMatcher` class to speed up constraint matching against simple Constraint instances + * Added `MatchAllConstraint` and `MatchNoneConstraint` which match everything and nothing + * Added more advanced optimization of contiguous constraints inside MultiConstraint + * Added tentative support for PHP 8 + * Fixed ConstraintInterface::matches to be commutative in all cases + +### [2.0.0] 2020-04-21 + + * Break: `dev-master`, `dev-trunk` and `dev-default` now normalize to `dev-master`, `dev-trunk` and `dev-default` instead of `9999999-dev` in 1.x + * Break: Removed the deprecated `AbstractConstraint` + * Added `getUpperBound` and `getLowerBound` to ConstraintInterface. They return `Composer\Semver\Constraint\Bound` instances + * Added `MultiConstraint::create` to create the most-optimal form of ConstraintInterface from an array of constraint strings + +### [1.7.2] 2020-12-03 + + * Fixed: Allow installing on php 8 + +### [1.7.1] 2020-09-27 + + * Fixed: accidental validation of broken constraints combining ^/~ and wildcards, and -dev suffix allowing weird cases + * Fixed: normalization of beta0 and such which was dropping the 0 + +### [1.7.0] 2020-09-09 + + * Added: support for `x || @dev`, not very useful but seen in the wild and failed to validate with 1.5.2/1.6.0 + * Added: support for `foobar-dev` being equal to `dev-foobar`, dev-foobar is the official way to write it but we need to support the other for BC and convenience + +### [1.6.0] 2020-09-08 + + * Added: support for constraints like `^2.x-dev` and `~2.x-dev`, not very useful but seen in the wild and failed to validate with 1.5.2 + * Fixed: invalid aliases will no longer throw, unless explicitly validated by Composer in the root package + +### [1.5.2] 2020-09-08 + + * Fixed: handling of some invalid -dev versions which were seen as valid + * Fixed: some doctypes + +### [1.5.1] 2020-01-13 + + * Fixed: Parsing of aliased version was not validating the alias to be a valid version + +### [1.5.0] 2019-03-19 + + * Added: some support for date versions (e.g. 201903) in `~` operator + * Fixed: support for stabilities in `~` operator was inconsistent + +### [1.4.2] 2016-08-30 + + * Fixed: collapsing of complex constraints lead to buggy constraints + +### [1.4.1] 2016-06-02 + + * Changed: branch-like requirements no longer strip build metadata - [composer/semver#38](https://github.com/composer/semver/pull/38). + +### [1.4.0] 2016-03-30 + + * Added: getters on MultiConstraint - [composer/semver#35](https://github.com/composer/semver/pull/35). + +### [1.3.0] 2016-02-25 + + * Fixed: stability parsing - [composer/composer#1234](https://github.com/composer/composer/issues/4889). + * Changed: collapse contiguous constraints when possible. + +### [1.2.0] 2015-11-10 + + * Changed: allow multiple numerical identifiers in 'pre-release' version part. + * Changed: add more 'v' prefix support. + +### [1.1.0] 2015-11-03 + + * Changed: dropped redundant `test` namespace. + * Changed: minor adjustment in datetime parsing normalization. + * Changed: `ConstraintInterface` relaxed, setPrettyString is not required anymore. + * Changed: `AbstractConstraint` marked deprecated, will be removed in 2.0. + * Changed: `Constraint` is now extensible. + +### [1.0.0] 2015-09-21 + + * Break: `VersionConstraint` renamed to `Constraint`. + * Break: `SpecificConstraint` renamed to `AbstractConstraint`. + * Break: `LinkConstraintInterface` renamed to `ConstraintInterface`. + * Break: `VersionParser::parseNameVersionPairs` was removed. + * Changed: `VersionParser::parseConstraints` allows (but ignores) build metadata now. + * Changed: `VersionParser::parseConstraints` allows (but ignores) prefixing numeric versions with a 'v' now. + * Changed: Fixed namespace(s) of test files. + * Changed: `Comparator::compare` no longer throws `InvalidArgumentException`. + * Changed: `Constraint` now throws `InvalidArgumentException`. + +### [0.1.0] 2015-07-23 + + * Added: `Composer\Semver\Comparator`, various methods to compare versions. + * Added: various documents such as README.md, LICENSE, etc. + * Added: configuration files for Git, Travis, php-cs-fixer, phpunit. + * Break: the following namespaces were renamed: + - Namespace: `Composer\Package\Version` -> `Composer\Semver` + - Namespace: `Composer\Package\LinkConstraint` -> `Composer\Semver\Constraint` + - Namespace: `Composer\Test\Package\Version` -> `Composer\Test\Semver` + - Namespace: `Composer\Test\Package\LinkConstraint` -> `Composer\Test\Semver\Constraint` + * Changed: code style using php-cs-fixer. + +[3.4.3]: https://github.com/composer/semver/compare/3.4.2...3.4.3 +[3.4.2]: https://github.com/composer/semver/compare/3.4.1...3.4.2 +[3.4.1]: https://github.com/composer/semver/compare/3.4.0...3.4.1 +[3.4.0]: https://github.com/composer/semver/compare/3.3.2...3.4.0 +[3.3.2]: https://github.com/composer/semver/compare/3.3.1...3.3.2 +[3.3.1]: https://github.com/composer/semver/compare/3.3.0...3.3.1 +[3.3.0]: https://github.com/composer/semver/compare/3.2.9...3.3.0 +[3.2.9]: https://github.com/composer/semver/compare/3.2.8...3.2.9 +[3.2.8]: https://github.com/composer/semver/compare/3.2.7...3.2.8 +[3.2.7]: https://github.com/composer/semver/compare/3.2.6...3.2.7 +[3.2.6]: https://github.com/composer/semver/compare/3.2.5...3.2.6 +[3.2.5]: https://github.com/composer/semver/compare/3.2.4...3.2.5 +[3.2.4]: https://github.com/composer/semver/compare/3.2.3...3.2.4 +[3.2.3]: https://github.com/composer/semver/compare/3.2.2...3.2.3 +[3.2.2]: https://github.com/composer/semver/compare/3.2.1...3.2.2 +[3.2.1]: https://github.com/composer/semver/compare/3.2.0...3.2.1 +[3.2.0]: https://github.com/composer/semver/compare/3.1.0...3.2.0 +[3.1.0]: https://github.com/composer/semver/compare/3.0.1...3.1.0 +[3.0.1]: https://github.com/composer/semver/compare/3.0.0...3.0.1 +[3.0.0]: https://github.com/composer/semver/compare/2.0.0...3.0.0 +[2.0.0]: https://github.com/composer/semver/compare/1.5.1...2.0.0 +[1.7.2]: https://github.com/composer/semver/compare/1.7.1...1.7.2 +[1.7.1]: https://github.com/composer/semver/compare/1.7.0...1.7.1 +[1.7.0]: https://github.com/composer/semver/compare/1.6.0...1.7.0 +[1.6.0]: https://github.com/composer/semver/compare/1.5.2...1.6.0 +[1.5.2]: https://github.com/composer/semver/compare/1.5.1...1.5.2 +[1.5.1]: https://github.com/composer/semver/compare/1.5.0...1.5.1 +[1.5.0]: https://github.com/composer/semver/compare/1.4.2...1.5.0 +[1.4.2]: https://github.com/composer/semver/compare/1.4.1...1.4.2 +[1.4.1]: https://github.com/composer/semver/compare/1.4.0...1.4.1 +[1.4.0]: https://github.com/composer/semver/compare/1.3.0...1.4.0 +[1.3.0]: https://github.com/composer/semver/compare/1.2.0...1.3.0 +[1.2.0]: https://github.com/composer/semver/compare/1.1.0...1.2.0 +[1.1.0]: https://github.com/composer/semver/compare/1.0.0...1.1.0 +[1.0.0]: https://github.com/composer/semver/compare/0.1.0...1.0.0 +[0.1.0]: https://github.com/composer/semver/compare/5e0b9a4da...0.1.0 diff --git a/src/ncc/ThirdParty/composer/semver/CompilingMatcher.php b/src/ncc/ThirdParty/composer/semver/CompilingMatcher.php index 3e1c224..42647d1 100644 --- a/src/ncc/ThirdParty/composer/semver/CompilingMatcher.php +++ b/src/ncc/ThirdParty/composer/semver/CompilingMatcher.php @@ -64,7 +64,7 @@ class CompilingMatcher * @phpstan-param Constraint::OP_* $operator * @param string $version * - * @return mixed + * @return bool */ public static function match(ConstraintInterface $constraint, $operator, $version) { diff --git a/src/ncc/ThirdParty/composer/semver/VERSION b/src/ncc/ThirdParty/composer/semver/VERSION index fbcbf73..8a0feb9 100644 --- a/src/ncc/ThirdParty/composer/semver/VERSION +++ b/src/ncc/ThirdParty/composer/semver/VERSION @@ -1 +1 @@ -3.4.0 \ No newline at end of file +3.4.3 \ No newline at end of file diff --git a/src/ncc/ThirdParty/composer/semver/VersionParser.php b/src/ncc/ThirdParty/composer/semver/VersionParser.php index 4ff22b0..e550cc6 100644 --- a/src/ncc/ThirdParty/composer/semver/VersionParser.php +++ b/src/ncc/ThirdParty/composer/semver/VersionParser.php @@ -82,11 +82,16 @@ class VersionParser * @param string $stability * * @return string + * @phpstan-return 'stable'|'RC'|'beta'|'alpha'|'dev' */ public static function normalizeStability($stability) { $stability = strtolower((string) $stability); + if (!in_array($stability, array('stable', 'rc', 'beta', 'alpha', 'dev'), true)) { + throw new \InvalidArgumentException('Invalid stability string "'.$stability.'", expected one of stable, RC, beta, alpha or dev'); + } + return $stability === 'rc' ? 'RC' : $stability; } From 91a25390fa9a0f8d532f6df6b95fdaf015b0f426 Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 13:42:56 -0400 Subject: [PATCH 095/134] Rename 'semver' directory to 'Semver' in composer package --- .gitignore | 2 +- src/ncc/ThirdParty/composer/{semver => Semver}/CHANGELOG.md | 0 src/ncc/ThirdParty/composer/{semver => Semver}/Comparator.php | 0 .../ThirdParty/composer/{semver => Semver}/CompilingMatcher.php | 0 .../ThirdParty/composer/{semver => Semver}/Constraint/Bound.php | 0 .../composer/{semver => Semver}/Constraint/Constraint.php | 0 .../{semver => Semver}/Constraint/ConstraintInterface.php | 0 .../{semver => Semver}/Constraint/MatchAllConstraint.php | 0 .../{semver => Semver}/Constraint/MatchNoneConstraint.php | 0 .../composer/{semver => Semver}/Constraint/MultiConstraint.php | 0 src/ncc/ThirdParty/composer/{semver => Semver}/Interval.php | 0 src/ncc/ThirdParty/composer/{semver => Semver}/Intervals.php | 0 src/ncc/ThirdParty/composer/{semver => Semver}/LICENSE | 0 src/ncc/ThirdParty/composer/{semver => Semver}/README.md | 0 src/ncc/ThirdParty/composer/{semver => Semver}/Semver.php | 0 src/ncc/ThirdParty/composer/{semver => Semver}/VERSION | 0 .../ThirdParty/composer/{semver => Semver}/VersionParser.php | 0 17 files changed, 1 insertion(+), 1 deletion(-) rename src/ncc/ThirdParty/composer/{semver => Semver}/CHANGELOG.md (100%) rename src/ncc/ThirdParty/composer/{semver => Semver}/Comparator.php (100%) rename src/ncc/ThirdParty/composer/{semver => Semver}/CompilingMatcher.php (100%) rename src/ncc/ThirdParty/composer/{semver => Semver}/Constraint/Bound.php (100%) rename src/ncc/ThirdParty/composer/{semver => Semver}/Constraint/Constraint.php (100%) rename src/ncc/ThirdParty/composer/{semver => Semver}/Constraint/ConstraintInterface.php (100%) rename src/ncc/ThirdParty/composer/{semver => Semver}/Constraint/MatchAllConstraint.php (100%) rename src/ncc/ThirdParty/composer/{semver => Semver}/Constraint/MatchNoneConstraint.php (100%) rename src/ncc/ThirdParty/composer/{semver => Semver}/Constraint/MultiConstraint.php (100%) rename src/ncc/ThirdParty/composer/{semver => Semver}/Interval.php (100%) rename src/ncc/ThirdParty/composer/{semver => Semver}/Intervals.php (100%) rename src/ncc/ThirdParty/composer/{semver => Semver}/LICENSE (100%) rename src/ncc/ThirdParty/composer/{semver => Semver}/README.md (100%) rename src/ncc/ThirdParty/composer/{semver => Semver}/Semver.php (100%) rename src/ncc/ThirdParty/composer/{semver => Semver}/VERSION (100%) rename src/ncc/ThirdParty/composer/{semver => Semver}/VersionParser.php (100%) diff --git a/.gitignore b/.gitignore index 363ec3a..05a17c6 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ build # Autoload files -src/ncc/ThirdParty/composer/semver/autoload_spl.php +src/ncc/ThirdParty/composer/Semver/autoload_spl.php src/ncc/ThirdParty/defuse/php-encryption/autoload_spl.php src/ncc/ThirdParty/jelix/version/autoload_spl.php src/ncc/ThirdParty/nikic/PhpParser/autoload_spl.php diff --git a/src/ncc/ThirdParty/composer/semver/CHANGELOG.md b/src/ncc/ThirdParty/composer/Semver/CHANGELOG.md similarity index 100% rename from src/ncc/ThirdParty/composer/semver/CHANGELOG.md rename to src/ncc/ThirdParty/composer/Semver/CHANGELOG.md diff --git a/src/ncc/ThirdParty/composer/semver/Comparator.php b/src/ncc/ThirdParty/composer/Semver/Comparator.php similarity index 100% rename from src/ncc/ThirdParty/composer/semver/Comparator.php rename to src/ncc/ThirdParty/composer/Semver/Comparator.php diff --git a/src/ncc/ThirdParty/composer/semver/CompilingMatcher.php b/src/ncc/ThirdParty/composer/Semver/CompilingMatcher.php similarity index 100% rename from src/ncc/ThirdParty/composer/semver/CompilingMatcher.php rename to src/ncc/ThirdParty/composer/Semver/CompilingMatcher.php diff --git a/src/ncc/ThirdParty/composer/semver/Constraint/Bound.php b/src/ncc/ThirdParty/composer/Semver/Constraint/Bound.php similarity index 100% rename from src/ncc/ThirdParty/composer/semver/Constraint/Bound.php rename to src/ncc/ThirdParty/composer/Semver/Constraint/Bound.php diff --git a/src/ncc/ThirdParty/composer/semver/Constraint/Constraint.php b/src/ncc/ThirdParty/composer/Semver/Constraint/Constraint.php similarity index 100% rename from src/ncc/ThirdParty/composer/semver/Constraint/Constraint.php rename to src/ncc/ThirdParty/composer/Semver/Constraint/Constraint.php diff --git a/src/ncc/ThirdParty/composer/semver/Constraint/ConstraintInterface.php b/src/ncc/ThirdParty/composer/Semver/Constraint/ConstraintInterface.php similarity index 100% rename from src/ncc/ThirdParty/composer/semver/Constraint/ConstraintInterface.php rename to src/ncc/ThirdParty/composer/Semver/Constraint/ConstraintInterface.php diff --git a/src/ncc/ThirdParty/composer/semver/Constraint/MatchAllConstraint.php b/src/ncc/ThirdParty/composer/Semver/Constraint/MatchAllConstraint.php similarity index 100% rename from src/ncc/ThirdParty/composer/semver/Constraint/MatchAllConstraint.php rename to src/ncc/ThirdParty/composer/Semver/Constraint/MatchAllConstraint.php diff --git a/src/ncc/ThirdParty/composer/semver/Constraint/MatchNoneConstraint.php b/src/ncc/ThirdParty/composer/Semver/Constraint/MatchNoneConstraint.php similarity index 100% rename from src/ncc/ThirdParty/composer/semver/Constraint/MatchNoneConstraint.php rename to src/ncc/ThirdParty/composer/Semver/Constraint/MatchNoneConstraint.php diff --git a/src/ncc/ThirdParty/composer/semver/Constraint/MultiConstraint.php b/src/ncc/ThirdParty/composer/Semver/Constraint/MultiConstraint.php similarity index 100% rename from src/ncc/ThirdParty/composer/semver/Constraint/MultiConstraint.php rename to src/ncc/ThirdParty/composer/Semver/Constraint/MultiConstraint.php diff --git a/src/ncc/ThirdParty/composer/semver/Interval.php b/src/ncc/ThirdParty/composer/Semver/Interval.php similarity index 100% rename from src/ncc/ThirdParty/composer/semver/Interval.php rename to src/ncc/ThirdParty/composer/Semver/Interval.php diff --git a/src/ncc/ThirdParty/composer/semver/Intervals.php b/src/ncc/ThirdParty/composer/Semver/Intervals.php similarity index 100% rename from src/ncc/ThirdParty/composer/semver/Intervals.php rename to src/ncc/ThirdParty/composer/Semver/Intervals.php diff --git a/src/ncc/ThirdParty/composer/semver/LICENSE b/src/ncc/ThirdParty/composer/Semver/LICENSE similarity index 100% rename from src/ncc/ThirdParty/composer/semver/LICENSE rename to src/ncc/ThirdParty/composer/Semver/LICENSE diff --git a/src/ncc/ThirdParty/composer/semver/README.md b/src/ncc/ThirdParty/composer/Semver/README.md similarity index 100% rename from src/ncc/ThirdParty/composer/semver/README.md rename to src/ncc/ThirdParty/composer/Semver/README.md diff --git a/src/ncc/ThirdParty/composer/semver/Semver.php b/src/ncc/ThirdParty/composer/Semver/Semver.php similarity index 100% rename from src/ncc/ThirdParty/composer/semver/Semver.php rename to src/ncc/ThirdParty/composer/Semver/Semver.php diff --git a/src/ncc/ThirdParty/composer/semver/VERSION b/src/ncc/ThirdParty/composer/Semver/VERSION similarity index 100% rename from src/ncc/ThirdParty/composer/semver/VERSION rename to src/ncc/ThirdParty/composer/Semver/VERSION diff --git a/src/ncc/ThirdParty/composer/semver/VersionParser.php b/src/ncc/ThirdParty/composer/Semver/VersionParser.php similarity index 100% rename from src/ncc/ThirdParty/composer/semver/VersionParser.php rename to src/ncc/ThirdParty/composer/Semver/VersionParser.php From 5e173b7cc06db9ca29edfca1a692884f207f7132 Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 13:45:33 -0400 Subject: [PATCH 096/134] Fix case sensitivity for "Semver" in paths and package name --- Makefile | 2 +- src/autoload/autoload.php | 2 +- src/ncc/version.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index fe96810..b92de60 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ DEBIAN_PACKAGE_BUILD_PATH := $(BUILD_PATH)/ncc_$(BUILD_VERSION)_all.deb # List of paths for autoloading AUTOLOAD_PATHS := $(addprefix $(SRC_PATH)/ncc/ThirdParty/, \ - composer/semver \ + composer/Semver \ defuse/php-encryption \ jelix/version \ nikic/PhpParser \ diff --git a/src/autoload/autoload.php b/src/autoload/autoload.php index 5ba02c1..9ab6a69 100644 --- a/src/autoload/autoload.php +++ b/src/autoload/autoload.php @@ -13,7 +13,7 @@ $third_party_path = __DIR__ . DIRECTORY_SEPARATOR . 'ThirdParty' . DIRECTORY_SEPARATOR; $target_files = [ __DIR__ . DIRECTORY_SEPARATOR . 'autoload_spl.php', - $third_party_path . 'composer' . DIRECTORY_SEPARATOR . 'semver' . DIRECTORY_SEPARATOR . 'autoload_spl.php', + $third_party_path . 'composer' . DIRECTORY_SEPARATOR . 'Semver' . DIRECTORY_SEPARATOR . 'autoload_spl.php', $third_party_path . 'defuse' . DIRECTORY_SEPARATOR . 'php-encryption' . DIRECTORY_SEPARATOR . 'autoload_spl.php', $third_party_path . 'jelix' . DIRECTORY_SEPARATOR . 'version' . DIRECTORY_SEPARATOR . 'autoload_spl.php', $third_party_path . 'nikic' . DIRECTORY_SEPARATOR . 'PhpParser' . DIRECTORY_SEPARATOR . 'autoload_spl.php', diff --git a/src/ncc/version.json b/src/ncc/version.json index fb64e9d..bfc71c3 100644 --- a/src/ncc/version.json +++ b/src/ncc/version.json @@ -5,7 +5,7 @@ "components": [ { "vendor": "composer", - "package_name": "semver" + "package_name": "Semver" }, { "vendor": "defuse", From 272fc8524e1297abe73cc97eb294896d4c862620 Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 13:52:20 -0400 Subject: [PATCH 097/134] Fixed version filtering and sorting in PackagistRepository --- .../PackagistExtension/PackagistRepository.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/ncc/Classes/PackagistExtension/PackagistRepository.php b/src/ncc/Classes/PackagistExtension/PackagistRepository.php index a6b29a7..a8cee67 100644 --- a/src/ncc/Classes/PackagistExtension/PackagistRepository.php +++ b/src/ncc/Classes/PackagistExtension/PackagistRepository.php @@ -163,23 +163,21 @@ { $versions = self::getVersions($repository, $vendor, $project); - /** @noinspection KeysFragmentationWithArrayFunctionsInspection */ + // Filter out pre-release versions such as alpha, beta, rc, dev $versions = array_filter($versions, static function($version) { return !preg_match('/-alpha|-beta|-rc|dev/i', $version); }); - usort($versions, static function($a, $b) - { - return Comparator::lessThanOrEqualTo($a, $b) ? 1 : -1; - }); + // Sort versions in descending order using Semver::rsort + $versions = Semver::rsort($versions); - if($versions[0] === null) + if (!isset($versions[0])) { throw new NetworkException(sprintf('Failed to resolve latest version for %s/%s', $vendor, $project)); } - return $versions[0]; + return $versions[0]; // The first version in the sorted array is the latest } /** From c7b007c704c2d351a0eac4e41da0e1f7ecb54d73 Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 14:17:16 -0400 Subject: [PATCH 098/134] Refactor project constants handling in NccCompiler --- src/ncc/Classes/NccExtension/NccCompiler.php | 10 ++++++++-- src/ncc/Managers/ProjectManager.php | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ncc/Classes/NccExtension/NccCompiler.php b/src/ncc/Classes/NccExtension/NccCompiler.php index c079ddc..ea18d14 100644 --- a/src/ncc/Classes/NccExtension/NccCompiler.php +++ b/src/ncc/Classes/NccExtension/NccCompiler.php @@ -333,8 +333,7 @@ $metadata->addOptions($this->project_manager->getProjectConfiguration()->getBuild()->getOptions($build_configuration)); $metadata->addOptions($this->project_manager->getProjectConfiguration()->getProject()->getOptions()); - $metadata->addConstants($this->project_manager->getRuntimeConstants($build_configuration)); - $metadata->addConstants($this->project_manager->getRuntimeConstants()); + $metadata->addConstants($this->project_manager->getConstants($build_configuration)); $metadata->setUpdateSource($this->project_manager->getProjectConfiguration()->getProject()->getUpdateSource()); $metadata->setMainExecutionPolicy($this->project_manager->getProjectConfiguration()->getBuild()->getMain()); $metadata->setInstaller($this->project_manager->getProjectConfiguration()->getInstaller()); @@ -352,6 +351,13 @@ $metadata->removeOption(BuildConfigurationOptions::STATIC_DEPENDENCIES->value); } + $compiled_constants = []; + foreach($this->project_manager->getConstants() as $constant => $value) + { + $compiled_constants[$constant] = ConstantCompiler::compileConstants($this->project_manager->getProjectConfiguration(), $value); + } + + $metadata->addConstants($compiled_constants); /** @noinspection UnusedFunctionResultInspection */ $package_writer->setMetadata($metadata); diff --git a/src/ncc/Managers/ProjectManager.php b/src/ncc/Managers/ProjectManager.php index 58c2b82..5f09005 100644 --- a/src/ncc/Managers/ProjectManager.php +++ b/src/ncc/Managers/ProjectManager.php @@ -327,7 +327,7 @@ * @param string $build_configuration * @return array */ - public function getRuntimeConstants(string $build_configuration=BuildConfigurationValues::DEFAULT->value): array + public function getConstants(string $build_configuration=BuildConfigurationValues::DEFAULT->value): array { $configuration = $this->project_configuration->getBuild()->getBuildConfiguration($build_configuration); return array_merge($configuration->getDefineConstants(), $this->project_configuration->getBuild()->getDefineConstants()); From 4e174821fce07157280b814262fd2a957c962311 Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 14:23:00 -0400 Subject: [PATCH 099/134] Updated CHANGELOG.md --- CHANGELOG.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1197ac8..9ba1310 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 This update introduces a refactored code-base, code quality improvements, and better exception handling. +### Added + - Added Test unit tests/ncc/Objects/Package/ComponentTest.php + - Added Test unit tests/ncc/Utilities/ResolverTest.php + - Added Test unit tests/ncc/Utilities/SecurityTest.php + - Added Test unit tests/ncc/Utilities/ValidateTest.php + - Add support for runtime constants + ### Changed - Convert Versions constants to enum cases - Update Scopes to enum and adjust scope checks @@ -47,6 +54,19 @@ This update introduces a refactored code-base, code quality improvements, and be - Convert PackageFlags constants to enum cases - Convert NccBuildFlags constants to enum cases - Convert ComponentFlags constants to enum cases + - Refactor flag handling to use PackageFlags enum directly + - Refactor checkLogLevel to correctly utilize LogLevel cases + - Refactor code to improve readability in Resolver.php + - Update PHP include paths in project configuration + - Refactor logging level checks to use LogLevel enum directly + - Refactor log level parsing with enum method + - Refactor log level checking to enum method + - Updated Symfony/Filesystem from version 6.3.1 to 7.1.2 + - Refactor ProjectType handling + - Validate and enforce repository type enum usage + - Updated Composer/Semver to 3.4.3 + - Rename 'semver' directory to 'Semver' in composer package + - Refactor project constants handling in NccCompiler ### Fixed - Fixed Division by zero in PackageManager @@ -61,6 +81,8 @@ This update introduces a refactored code-base, code quality improvements, and be - Removed DependencySourceType - Removed BuiltinRemoteSourceType - Removed RuntimeImportOptions + - Remove ComponentFileExtensions enum + - Remove unused import and redundant scope validation method ## [2.0.3] - 2023-10-17 From d59f5fb6e01dcda0a47c5c7a95f636293fcf06c1 Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 15:06:13 -0400 Subject: [PATCH 100/134] Updated Symfony/Yaml to version 7.1.4 --- .github/workflows/ci.yml | 0 CHANGELOG.md | 1 + src/ncc/ThirdParty/Symfony/Yaml/CHANGELOG.md | 10 ++++ .../Symfony/Yaml/Command/LintCommand.php | 9 +-- src/ncc/ThirdParty/Symfony/Yaml/Dumper.php | 10 ++-- src/ncc/ThirdParty/Symfony/Yaml/Escaper.php | 2 +- .../Symfony/Yaml/Exception/ParseException.php | 33 ++++------ src/ncc/ThirdParty/Symfony/Yaml/Inline.php | 60 ++++++++++++------- src/ncc/ThirdParty/Symfony/Yaml/Parser.php | 28 ++++----- .../Symfony/Yaml/Tag/TaggedValue.php | 11 ++-- src/ncc/ThirdParty/Symfony/Yaml/VERSION | 2 +- 11 files changed, 89 insertions(+), 77 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e69de29 diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ba1310..db2b043 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ This update introduces a refactored code-base, code quality improvements, and be - Updated Composer/Semver to 3.4.3 - Rename 'semver' directory to 'Semver' in composer package - Refactor project constants handling in NccCompiler + - Updated Symfony/Yaml to version 7.1.4 ### Fixed - Fixed Division by zero in PackageManager diff --git a/src/ncc/ThirdParty/Symfony/Yaml/CHANGELOG.md b/src/ncc/ThirdParty/Symfony/Yaml/CHANGELOG.md index 0c2021f..74b0a71 100644 --- a/src/ncc/ThirdParty/Symfony/Yaml/CHANGELOG.md +++ b/src/ncc/ThirdParty/Symfony/Yaml/CHANGELOG.md @@ -1,6 +1,16 @@ CHANGELOG ========= +7.1 +--- + + * Add support for getting all the enum cases with `!php/enum Foo` + +7.0 +--- + + * Remove the `!php/const:` tag, use `!php/const` instead (without the colon) + 6.3 --- diff --git a/src/ncc/ThirdParty/Symfony/Yaml/Command/LintCommand.php b/src/ncc/ThirdParty/Symfony/Yaml/Command/LintCommand.php index 8833f9f..718f90d 100644 --- a/src/ncc/ThirdParty/Symfony/Yaml/Command/LintCommand.php +++ b/src/ncc/ThirdParty/Symfony/Yaml/Command/LintCommand.php @@ -42,7 +42,7 @@ class LintCommand extends Command private ?\Closure $directoryIteratorProvider; private ?\Closure $isReadableProvider; - public function __construct(string $name = null, callable $directoryIteratorProvider = null, callable $isReadableProvider = null) + public function __construct(?string $name = null, ?callable $directoryIteratorProvider = null, ?callable $isReadableProvider = null) { parent::__construct($name); @@ -50,10 +50,7 @@ class LintCommand extends Command $this->isReadableProvider = null === $isReadableProvider ? null : $isReadableProvider(...); } - /** - * @return void - */ - protected function configure() + protected function configure(): void { $this ->addArgument('filename', InputArgument::IS_ARRAY, 'A file, a directory or "-" for reading from STDIN') @@ -127,7 +124,7 @@ EOF return $this->display($io, $filesInfo); } - private function validate(string $content, int $flags, string $file = null): array + private function validate(string $content, int $flags, ?string $file = null): array { $prevErrorHandler = set_error_handler(function ($level, $message, $file, $line) use (&$prevErrorHandler) { if (\E_USER_DEPRECATED === $level) { diff --git a/src/ncc/ThirdParty/Symfony/Yaml/Dumper.php b/src/ncc/ThirdParty/Symfony/Yaml/Dumper.php index 6b4bb1e..d1be722 100644 --- a/src/ncc/ThirdParty/Symfony/Yaml/Dumper.php +++ b/src/ncc/ThirdParty/Symfony/Yaml/Dumper.php @@ -51,10 +51,10 @@ class Dumper $dumpObjectAsInlineMap = true; if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($input instanceof \ArrayObject || $input instanceof \stdClass)) { - $dumpObjectAsInlineMap = empty((array) $input); + $dumpObjectAsInlineMap = !(array) $input; } - if ($inline <= 0 || (!\is_array($input) && !$input instanceof TaggedValue && $dumpObjectAsInlineMap) || empty($input)) { + if ($inline <= 0 || (!\is_array($input) && !$input instanceof TaggedValue && $dumpObjectAsInlineMap) || !$input) { $output .= $prefix.Inline::dump($input, $flags); } elseif ($input instanceof TaggedValue) { $output .= $this->dumpTaggedValue($input, $inline, $indent, $flags, $prefix); @@ -121,10 +121,10 @@ class Dumper $dumpObjectAsInlineMap = true; if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \ArrayObject || $value instanceof \stdClass)) { - $dumpObjectAsInlineMap = empty((array) $value); + $dumpObjectAsInlineMap = !(array) $value; } - $willBeInlined = $inline - 1 <= 0 || !\is_array($value) && $dumpObjectAsInlineMap || empty($value); + $willBeInlined = $inline - 1 <= 0 || !\is_array($value) && $dumpObjectAsInlineMap || !$value; $output .= sprintf('%s%s%s%s', $prefix, @@ -169,7 +169,7 @@ class Dumper // http://www.yaml.org/spec/1.2/spec.html#id2793979 foreach ($lines as $line) { if ('' !== trim($line, ' ')) { - return (' ' === substr($line, 0, 1)) ? (string) $this->indentation : ''; + return str_starts_with($line, ' ') ? (string) $this->indentation : ''; } } diff --git a/src/ncc/ThirdParty/Symfony/Yaml/Escaper.php b/src/ncc/ThirdParty/Symfony/Yaml/Escaper.php index 8cbfc1b..24a6bb7 100644 --- a/src/ncc/ThirdParty/Symfony/Yaml/Escaper.php +++ b/src/ncc/ThirdParty/Symfony/Yaml/Escaper.php @@ -80,7 +80,7 @@ class Escaper // Determines if the PHP value contains any single characters that would // cause it to require single quoting in YAML. - return 0 < preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` \p{Zs}]/xu', $value); + return 0 < preg_match('/[\s\'"\:\{\}\[\],&\*\#\?] | \A[\-?|<>=!%@`\p{Zs}]/xu', $value); } /** diff --git a/src/ncc/ThirdParty/Symfony/Yaml/Exception/ParseException.php b/src/ncc/ThirdParty/Symfony/Yaml/Exception/ParseException.php index 64b9397..8f56674 100644 --- a/src/ncc/ThirdParty/Symfony/Yaml/Exception/ParseException.php +++ b/src/ncc/ThirdParty/Symfony/Yaml/Exception/ParseException.php @@ -18,24 +18,19 @@ namespace ncc\ThirdParty\Symfony\Yaml\Exception; */ class ParseException extends RuntimeException { - private ?string $parsedFile; - private int $parsedLine; - private ?string $snippet; - private string $rawMessage; - /** - * @param string $message The error message + * @param string $rawMessage The error message * @param int $parsedLine The line where the error occurred * @param string|null $snippet The snippet of code near the problem * @param string|null $parsedFile The file name where the error occurred */ - public function __construct(string $message, int $parsedLine = -1, string $snippet = null, string $parsedFile = null, \Throwable $previous = null) - { - $this->parsedFile = $parsedFile; - $this->parsedLine = $parsedLine; - $this->snippet = $snippet; - $this->rawMessage = $message; - + public function __construct( + private string $rawMessage, + private int $parsedLine = -1, + private ?string $snippet = null, + private ?string $parsedFile = null, + ?\Throwable $previous = null, + ) { $this->updateRepr(); parent::__construct($this->message, 0, $previous); @@ -51,10 +46,8 @@ class ParseException extends RuntimeException /** * Sets the snippet of code near the error. - * - * @return void */ - public function setSnippet(string $snippet) + public function setSnippet(string $snippet): void { $this->snippet = $snippet; @@ -73,10 +66,8 @@ class ParseException extends RuntimeException /** * Sets the filename where the error occurred. - * - * @return void */ - public function setParsedFile(string $parsedFile) + public function setParsedFile(string $parsedFile): void { $this->parsedFile = $parsedFile; @@ -93,10 +84,8 @@ class ParseException extends RuntimeException /** * Sets the line where the error occurred. - * - * @return void */ - public function setParsedLine(int $parsedLine) + public function setParsedLine(int $parsedLine): void { $this->parsedLine = $parsedLine; diff --git a/src/ncc/ThirdParty/Symfony/Yaml/Inline.php b/src/ncc/ThirdParty/Symfony/Yaml/Inline.php index 9fd7306..5b7f3ff 100644 --- a/src/ncc/ThirdParty/Symfony/Yaml/Inline.php +++ b/src/ncc/ThirdParty/Symfony/Yaml/Inline.php @@ -34,7 +34,7 @@ class Inline private static bool $objectForMap = false; private static bool $constantSupport = false; - public static function initialize(int $flags, int $parsedLineNumber = null, string $parsedFilename = null): void + public static function initialize(int $flags, ?int $parsedLineNumber = null, ?string $parsedFilename = null): void { self::$exceptionOnInvalidType = (bool) (Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE & $flags); self::$objectSupport = (bool) (Yaml::PARSE_OBJECT & $flags); @@ -55,7 +55,7 @@ class Inline * * @throws ParseException */ - public static function parse(string $value = null, int $flags = 0, array &$references = []): mixed + public static function parse(string $value, int $flags = 0, array &$references = []): mixed { self::initialize($flags); @@ -116,7 +116,7 @@ class Inline default => 'Y-m-d\TH:i:s.uP', }); case $value instanceof \UnitEnum: - return sprintf('!php/const %s::%s', $value::class, $value->name); + return sprintf('!php/enum %s::%s', $value::class, $value->name); case \is_object($value): if ($value instanceof TaggedValue) { return '!'.$value->getTag().' '.self::dump($value->getValue(), $flags); @@ -157,7 +157,7 @@ class Inline } elseif (floor($value) == $value && $repr == $value) { // Preserve float data type since storing a whole number will result in integer value. if (!str_contains($repr, 'E')) { - $repr = $repr.'.0'; + $repr .= '.0'; } } } else { @@ -267,7 +267,7 @@ class Inline * * @throws ParseException When malformed inline YAML string is parsed */ - public static function parseScalar(string $scalar, int $flags = 0, array $delimiters = null, int &$i = 0, bool $evaluate = true, array &$references = [], bool &$isQuoted = null): mixed + public static function parseScalar(string $scalar, int $flags = 0, ?array $delimiters = null, int &$i = 0, bool $evaluate = true, array &$references = [], ?bool &$isQuoted = null): mixed { if (\in_array($scalar[$i], ['"', "'"], true)) { // quoted scalar @@ -353,11 +353,18 @@ class Inline ++$i; // [foo, bar, ...] + $lastToken = null; while ($i < $len) { if (']' === $sequence[$i]) { return $output; } if (',' === $sequence[$i] || ' ' === $sequence[$i]) { + if (',' === $sequence[$i] && (null === $lastToken || 'separator' === $lastToken)) { + $output[] = null; + } elseif (',' === $sequence[$i]) { + $lastToken = 'separator'; + } + ++$i; continue; @@ -401,6 +408,7 @@ class Inline $output[] = $value; + $lastToken = 'value'; ++$i; } @@ -527,7 +535,7 @@ class Inline if ('<<' === $key) { $output += $value; } elseif ($allowOverwrite || !isset($output[$key])) { - if (!$isValueQuoted && \is_string($value) && '' !== $value && '&' === $value[0] && Parser::preg_match(Parser::REFERENCE_PATTERN, $value, $matches)) { + if (!$isValueQuoted && \is_string($value) && '' !== $value && '&' === $value[0] && !self::isBinaryString($value) && Parser::preg_match(Parser::REFERENCE_PATTERN, $value, $matches)) { $references[$matches['ref']] = $matches['value']; $value = $matches['value']; } @@ -556,7 +564,7 @@ class Inline * * @throws ParseException when object parsing support was disabled and the parser detected a PHP object or when a reference could not be resolved */ - private static function evaluateScalar(string $scalar, int $flags, array &$references = [], bool &$isQuotedString = null): mixed + private static function evaluateScalar(string $scalar, int $flags, array &$references = [], ?bool &$isQuotedString = null): mixed { $isQuotedString = false; $scalar = trim($scalar); @@ -643,24 +651,31 @@ class Inline } $i = 0; - $enum = self::parseScalar(substr($scalar, 10), 0, null, $i, false); - if ($useValue = str_ends_with($enum, '->value')) { - $enum = substr($enum, 0, -7); - } - if (!\defined($enum)) { + $enumName = self::parseScalar(substr($scalar, 10), 0, null, $i, false); + $useName = str_contains($enumName, '::'); + $enum = $useName ? strstr($enumName, '::', true) : $enumName; + + if (!enum_exists($enum)) { throw new ParseException(sprintf('The enum "%s" is not defined.', $enum), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); } - - $value = \constant($enum); - - if (!$value instanceof \UnitEnum) { - throw new ParseException(sprintf('The string "%s" is not the name of a valid enum.', $enum), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); + if (!$useName) { + return $enum::cases(); } + if ($useValue = str_ends_with($enumName, '->value')) { + $enumName = substr($enumName, 0, -7); + } + + if (!\defined($enumName)) { + throw new ParseException(sprintf('The string "%s" is not the name of a valid enum.', $enumName), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); + } + + $value = \constant($enumName); + if (!$useValue) { return $value; } if (!$value instanceof \BackedEnum) { - throw new ParseException(sprintf('The enum "%s" defines no value next to its name.', $enum), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); + throw new ParseException(sprintf('The enum "%s" defines no value next to its name.', $enumName), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); } return $value->value; @@ -709,8 +724,13 @@ class Inline case Parser::preg_match('/^(-|\+)?[0-9][0-9_]*(\.[0-9_]+)?$/', $scalar): return (float) str_replace('_', '', $scalar); case Parser::preg_match(self::getTimestampRegex(), $scalar): - // When no timezone is provided in the parsed date, YAML spec says we must assume UTC. - $time = new \DateTimeImmutable($scalar, new \DateTimeZone('UTC')); + try { + // When no timezone is provided in the parsed date, YAML spec says we must assume UTC. + $time = new \DateTimeImmutable($scalar, new \DateTimeZone('UTC')); + } catch (\Exception $e) { + // Some dates accepted by the regex are not valid dates. + throw new ParseException(\sprintf('The date "%s" could not be parsed as it is an invalid date.', $scalar), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename, $e); + } if (Yaml::PARSE_DATETIME & $flags) { return $time; diff --git a/src/ncc/ThirdParty/Symfony/Yaml/Parser.php b/src/ncc/ThirdParty/Symfony/Yaml/Parser.php index 863375e..b70ccea 100644 --- a/src/ncc/ThirdParty/Symfony/Yaml/Parser.php +++ b/src/ncc/ThirdParty/Symfony/Yaml/Parser.php @@ -182,9 +182,8 @@ class Parser || self::preg_match('#^(?P'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P.+?))?\s*$#u', $this->trimTag($values['value']), $matches) ) ) { - // this is a compact notation element, add to next block and parse $block = $values['value']; - if ($this->isNextLineIndented()) { + if ($this->isNextLineIndented() || isset($matches['value']) && '>-' === $matches['value']) { $block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + \strlen($values['leadspaces']) + 1); } @@ -198,14 +197,9 @@ class Parser array_pop($this->refsBeingParsed); } } elseif ( - // @todo in 7.0 remove legacy "(?:!?!php/const:)?" - self::preg_match('#^(?P(?:![^\s]++\s++)?(?:'.Inline::REGEX_QUOTED_STRING.'|(?:!?!php/const:)?[^ \'"\[\{!].*?)) *\:(( |\t)++(?P.+))?$#u', rtrim($this->currentLine), $values) + self::preg_match('#^(?P(?:![^\s]++\s++)?(?:'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{!].*?)) *\:(( |\t)++(?P.+))?$#u', rtrim($this->currentLine), $values) && (!str_contains($values['key'], ' #') || \in_array($values['key'][0], ['"', "'"])) ) { - if (str_starts_with($values['key'], '!php/const:')) { - trigger_deprecation('symfony/yaml', '6.2', 'YAML syntax for key "%s" is deprecated and replaced by "!php/const %s".', $values['key'], substr($values['key'], 11)); - } - if ($context && 'sequence' == $context) { throw new ParseException('You cannot define a mapping item when in a sequence.', $this->currentLineNb + 1, $this->currentLine, $this->filename); } @@ -413,7 +407,7 @@ class Parser throw new ParseException('Multiple documents are not supported.', $this->currentLineNb + 1, $this->currentLine, $this->filename); } - if ($deprecatedUsage = (isset($this->currentLine[1]) && '?' === $this->currentLine[0] && ' ' === $this->currentLine[1])) { + if (isset($this->currentLine[1]) && '?' === $this->currentLine[0] && ' ' === $this->currentLine[1]) { throw new ParseException('Complex mappings are not supported.', $this->getRealCurrentLineNb() + 1, $this->currentLine); } @@ -443,7 +437,7 @@ class Parser continue; } // If the indentation is not consistent at offset 0, it is to be considered as a ParseError - if (0 === $this->offset && !$deprecatedUsage && isset($line[0]) && ' ' === $line[0]) { + if (0 === $this->offset && isset($line[0]) && ' ' === $line[0]) { throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename); } @@ -500,7 +494,7 @@ class Parser $data = $object; } - return empty($data) ? null : $data; + return $data ?: null; } private function parseBlock(int $offset, string $yaml, int $flags): mixed @@ -562,7 +556,7 @@ class Parser * * @throws ParseException When indentation problem are detected */ - private function getNextEmbedBlock(int $indentation = null, bool $inSequence = false): string + private function getNextEmbedBlock(?int $indentation = null, bool $inSequence = false): string { $oldLineIndentation = $this->getCurrentLineIndentation(); @@ -639,12 +633,12 @@ class Parser } if ($this->isCurrentLineBlank()) { - $data[] = substr($this->currentLine, $newIndent); + $data[] = substr($this->currentLine, $newIndent ?? 0); continue; } if ($indent >= $newIndent) { - $data[] = substr($this->currentLine, $newIndent); + $data[] = substr($this->currentLine, $newIndent ?? 0); } elseif ($this->isCurrentLineComment()) { $data[] = $this->currentLine; } elseif (0 == $indent) { @@ -932,6 +926,10 @@ class Parser } while (!$EOF && ($this->isCurrentLineEmpty() || $this->isCurrentLineComment())); if ($EOF) { + for ($i = 0; $i < $movements; ++$i) { + $this->moveToPreviousLine(); + } + return false; } @@ -1040,7 +1038,7 @@ class Parser * * @internal */ - public static function preg_match(string $pattern, string $subject, array &$matches = null, int $flags = 0, int $offset = 0): int + public static function preg_match(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int { if (false === $ret = preg_match($pattern, $subject, $matches, $flags, $offset)) { throw new ParseException(preg_last_error_msg()); diff --git a/src/ncc/ThirdParty/Symfony/Yaml/Tag/TaggedValue.php b/src/ncc/ThirdParty/Symfony/Yaml/Tag/TaggedValue.php index 6fb607c..669bf60 100644 --- a/src/ncc/ThirdParty/Symfony/Yaml/Tag/TaggedValue.php +++ b/src/ncc/ThirdParty/Symfony/Yaml/Tag/TaggedValue.php @@ -17,13 +17,10 @@ namespace ncc\ThirdParty\Symfony\Yaml\Tag; */ final class TaggedValue { - private string $tag; - private mixed $value; - - public function __construct(string $tag, mixed $value) - { - $this->tag = $tag; - $this->value = $value; + public function __construct( + private string $tag, + private mixed $value, + ) { } public function getTag(): string diff --git a/src/ncc/ThirdParty/Symfony/Yaml/VERSION b/src/ncc/ThirdParty/Symfony/Yaml/VERSION index d9b300f..334b5ce 100644 --- a/src/ncc/ThirdParty/Symfony/Yaml/VERSION +++ b/src/ncc/ThirdParty/Symfony/Yaml/VERSION @@ -1 +1 @@ -6.3.3 \ No newline at end of file +7.1.4 \ No newline at end of file From 910477df8e1c9b2afeff644d5bf6239fc16ad758 Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 15:10:40 -0400 Subject: [PATCH 101/134] Updated Symfony/Uid to version 7.1.4 --- CHANGELOG.md | 1 + .../ThirdParty/Symfony/Uid/AbstractUid.php | 29 ++++++++++++++--- src/ncc/ThirdParty/Symfony/Uid/BinaryUtil.php | 18 +++++++++-- src/ncc/ThirdParty/Symfony/Uid/CHANGELOG.md | 6 ++++ .../Uid/Command/GenerateUlidCommand.php | 11 +++---- .../Uid/Command/GenerateUuidCommand.php | 11 +++---- .../Uid/Command/InspectUuidCommand.php | 3 +- .../Uid/Factory/NameBasedUuidFactory.php | 11 +++---- .../Uid/Factory/RandomBasedUuidFactory.php | 11 ++++--- .../Uid/Factory/TimeBasedUuidFactory.php | 16 +++++----- .../Symfony/Uid/Factory/UlidFactory.php | 2 +- .../Symfony/Uid/Factory/UuidFactory.php | 6 ++-- src/ncc/ThirdParty/Symfony/Uid/Ulid.php | 13 ++++++-- src/ncc/ThirdParty/Symfony/Uid/Uuid.php | 11 +++++-- src/ncc/ThirdParty/Symfony/Uid/UuidV1.php | 20 +++++++++--- src/ncc/ThirdParty/Symfony/Uid/UuidV4.php | 21 ++++++++----- src/ncc/ThirdParty/Symfony/Uid/UuidV6.php | 31 +++++++++++++++++-- src/ncc/ThirdParty/Symfony/Uid/UuidV7.php | 17 ++++++++-- src/ncc/ThirdParty/Symfony/Uid/VERSION | 2 +- 19 files changed, 170 insertions(+), 70 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db2b043..27033e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,7 @@ This update introduces a refactored code-base, code quality improvements, and be - Rename 'semver' directory to 'Semver' in composer package - Refactor project constants handling in NccCompiler - Updated Symfony/Yaml to version 7.1.4 + - Updated Symfony/Uid to version 7.1.4 ### Fixed - Fixed Division by zero in PackageManager diff --git a/src/ncc/ThirdParty/Symfony/Uid/AbstractUid.php b/src/ncc/ThirdParty/Symfony/Uid/AbstractUid.php index 00700d8..d61ac27 100644 --- a/src/ncc/ThirdParty/Symfony/Uid/AbstractUid.php +++ b/src/ncc/ThirdParty/Symfony/Uid/AbstractUid.php @@ -14,12 +14,12 @@ namespace ncc\ThirdParty\Symfony\Uid; /** * @author Nicolas Grekas */ -abstract class AbstractUid implements \JsonSerializable +abstract class AbstractUid implements \JsonSerializable, \Stringable { /** * The identifier in its canonic representation. */ - protected $uid; + protected string $uid; /** * Whether the passed value is valid for the constructor of the current class. @@ -70,6 +70,8 @@ abstract class AbstractUid implements \JsonSerializable } /** + * @param string $uid A valid RFC 9562/4122 uid + * * @throws \InvalidArgumentException When the passed value is not valid */ public static function fromRfc4122(string $uid): static @@ -87,7 +89,9 @@ abstract class AbstractUid implements \JsonSerializable abstract public function toBinary(): string; /** - * Returns the identifier as a base58 case sensitive string. + * Returns the identifier as a base58 case-sensitive string. + * + * @example 2AifFTC3zXgZzK5fPrrprL (len=22) */ public function toBase58(): string { @@ -95,7 +99,11 @@ abstract class AbstractUid implements \JsonSerializable } /** - * Returns the identifier as a base32 case insensitive string. + * Returns the identifier as a base32 case-insensitive string. + * + * @see https://tools.ietf.org/html/rfc4648#section-6 + * + * @example 09EJ0S614A9FXVG9C5537Q9ZE1 (len=26) */ public function toBase32(): string { @@ -114,7 +122,11 @@ abstract class AbstractUid implements \JsonSerializable } /** - * Returns the identifier as a RFC4122 case insensitive string. + * Returns the identifier as a RFC 9562/4122 case-insensitive string. + * + * @see https://tools.ietf.org/html/rfc4122#section-3 + * + * @example 09748193-048a-4bfb-b825-8528cf74fdc1 (len=36) */ public function toRfc4122(): string { @@ -129,6 +141,8 @@ abstract class AbstractUid implements \JsonSerializable /** * Returns the identifier as a prefixed hexadecimal case insensitive string. + * + * @example 0x09748193048a4bfbb8258528cf74fdc1 (len=34) */ public function toHex(): string { @@ -152,6 +166,11 @@ abstract class AbstractUid implements \JsonSerializable return (\strlen($this->uid) - \strlen($other->uid)) ?: ($this->uid <=> $other->uid); } + final public function toString(): string + { + return $this->__toString(); + } + public function __toString(): string { return $this->uid; diff --git a/src/ncc/ThirdParty/Symfony/Uid/BinaryUtil.php b/src/ncc/ThirdParty/Symfony/Uid/BinaryUtil.php index 2f278d7..5a7b2e6 100644 --- a/src/ncc/ThirdParty/Symfony/Uid/BinaryUtil.php +++ b/src/ncc/ThirdParty/Symfony/Uid/BinaryUtil.php @@ -36,7 +36,7 @@ class BinaryUtil 'u' => 52, 'v' => 53, 'w' => 54, 'x' => 55, 'y' => 56, 'z' => 57, ]; - // https://tools.ietf.org/html/rfc4122#section-4.1.4 + // https://datatracker.ietf.org/doc/html/rfc9562#section-5.1 // 0x01b21dd213814000 is the number of 100-ns intervals between the // UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00. private const TIME_OFFSET_INT = 0x01B21DD213814000; @@ -118,8 +118,10 @@ class BinaryUtil /** * @param string $time Count of 100-nanosecond intervals since the UUID epoch 1582-10-15 00:00:00 in hexadecimal + * + * @return string Count of 100-nanosecond intervals since the UUID epoch 1582-10-15 00:00:00 as a numeric string */ - public static function hexToDateTime(string $time): \DateTimeImmutable + public static function hexToNumericString(string $time): string { if (\PHP_INT_SIZE >= 8) { $time = (string) (hexdec($time) - self::TIME_OFFSET_INT); @@ -140,7 +142,17 @@ class BinaryUtil $time = '-' === $time[0] ? '-'.str_pad(substr($time, 1), 8, '0', \STR_PAD_LEFT) : str_pad($time, 8, '0', \STR_PAD_LEFT); } - return \DateTimeImmutable::createFromFormat('U.u?', substr_replace($time, '.', -7, 0)); + return $time; + } + + /** + * Sub-microseconds are lost since they are not handled by \DateTimeImmutable. + * + * @param string $time Count of 100-nanosecond intervals since the UUID epoch 1582-10-15 00:00:00 in hexadecimal + */ + public static function hexToDateTime(string $time): \DateTimeImmutable + { + return \DateTimeImmutable::createFromFormat('U.u?', substr_replace(self::hexToNumericString($time), '.', -7, 0)); } /** diff --git a/src/ncc/ThirdParty/Symfony/Uid/CHANGELOG.md b/src/ncc/ThirdParty/Symfony/Uid/CHANGELOG.md index b821337..8fea6eb 100644 --- a/src/ncc/ThirdParty/Symfony/Uid/CHANGELOG.md +++ b/src/ncc/ThirdParty/Symfony/Uid/CHANGELOG.md @@ -1,6 +1,12 @@ CHANGELOG ========= +7.1 +--- + + * Add `UuidV1::toV6()`, `UuidV1::toV7()` and `UuidV6::toV7()` + * Add `AbstractUid::toString()` + 6.2 --- diff --git a/src/ncc/ThirdParty/Symfony/Uid/Command/GenerateUlidCommand.php b/src/ncc/ThirdParty/Symfony/Uid/Command/GenerateUlidCommand.php index 88e3c85..b06e7f3 100644 --- a/src/ncc/ThirdParty/Symfony/Uid/Command/GenerateUlidCommand.php +++ b/src/ncc/ThirdParty/Symfony/Uid/Command/GenerateUlidCommand.php @@ -25,12 +25,9 @@ use ncc\ThirdParty\Symfony\Uid\Factory\UlidFactory; #[AsCommand(name: 'ulid:generate', description: 'Generate a ULID')] class GenerateUlidCommand extends Command { - private UlidFactory $factory; - - public function __construct(UlidFactory $factory = null) - { - $this->factory = $factory ?? new UlidFactory(); - + public function __construct( + private UlidFactory $factory = new UlidFactory(), + ) { parent::__construct(); } @@ -79,7 +76,7 @@ EOF $formatOption = $input->getOption('format'); - if (\in_array($formatOption, $this->getAvailableFormatOptions())) { + if (\in_array($formatOption, $this->getAvailableFormatOptions(), true)) { $format = 'to'.ucfirst($formatOption); } else { $io->error(sprintf('Invalid format "%s", supported formats are "%s".', $formatOption, implode('", "', $this->getAvailableFormatOptions()))); diff --git a/src/ncc/ThirdParty/Symfony/Uid/Command/GenerateUuidCommand.php b/src/ncc/ThirdParty/Symfony/Uid/Command/GenerateUuidCommand.php index 6032f34..e1026b4 100644 --- a/src/ncc/ThirdParty/Symfony/Uid/Command/GenerateUuidCommand.php +++ b/src/ncc/ThirdParty/Symfony/Uid/Command/GenerateUuidCommand.php @@ -26,12 +26,9 @@ use ncc\ThirdParty\Symfony\Uid\Uuid; #[AsCommand(name: 'uuid:generate', description: 'Generate a UUID')] class GenerateUuidCommand extends Command { - private UuidFactory $factory; - - public function __construct(UuidFactory $factory = null) - { - $this->factory = $factory ?? new UuidFactory(); - + public function __construct( + private UuidFactory $factory = new UuidFactory(), + ) { parent::__construct(); } @@ -168,7 +165,7 @@ EOF $formatOption = $input->getOption('format'); - if (\in_array($formatOption, $this->getAvailableFormatOptions())) { + if (\in_array($formatOption, $this->getAvailableFormatOptions(), true)) { $format = 'to'.ucfirst($formatOption); } else { $io->error(sprintf('Invalid format "%s", supported formats are "%s".', $formatOption, implode('", "', $this->getAvailableFormatOptions()))); diff --git a/src/ncc/ThirdParty/Symfony/Uid/Command/InspectUuidCommand.php b/src/ncc/ThirdParty/Symfony/Uid/Command/InspectUuidCommand.php index 49bc807..4208528 100644 --- a/src/ncc/ThirdParty/Symfony/Uid/Command/InspectUuidCommand.php +++ b/src/ncc/ThirdParty/Symfony/Uid/Command/InspectUuidCommand.php @@ -49,7 +49,6 @@ EOF $io = new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output); try { - /** @var Uuid $uuid */ $uuid = Uuid::fromString($input->getArgument('uuid')); } catch (\InvalidArgumentException $e) { $io->error($e->getMessage()); @@ -62,7 +61,7 @@ EOF } elseif (new MaxUuid() == $uuid) { $version = 'max'; } else { - $version = uuid_type($uuid); + $version = hexdec($uuid->toRfc4122()[14]); } $rows = [ diff --git a/src/ncc/ThirdParty/Symfony/Uid/Factory/NameBasedUuidFactory.php b/src/ncc/ThirdParty/Symfony/Uid/Factory/NameBasedUuidFactory.php index 2e64bab..4ef2d22 100644 --- a/src/ncc/ThirdParty/Symfony/Uid/Factory/NameBasedUuidFactory.php +++ b/src/ncc/ThirdParty/Symfony/Uid/Factory/NameBasedUuidFactory.php @@ -17,13 +17,10 @@ use ncc\ThirdParty\Symfony\Uid\UuidV5; class NameBasedUuidFactory { - private string $class; - private Uuid $namespace; - - public function __construct(string $class, Uuid $namespace) - { - $this->class = $class; - $this->namespace = $namespace; + public function __construct( + private string $class, + private Uuid $namespace, + ) { } public function create(string $name): UuidV5|UuidV3 diff --git a/src/ncc/ThirdParty/Symfony/Uid/Factory/RandomBasedUuidFactory.php b/src/ncc/ThirdParty/Symfony/Uid/Factory/RandomBasedUuidFactory.php index 3c42c13..60ec51a 100644 --- a/src/ncc/ThirdParty/Symfony/Uid/Factory/RandomBasedUuidFactory.php +++ b/src/ncc/ThirdParty/Symfony/Uid/Factory/RandomBasedUuidFactory.php @@ -15,11 +15,12 @@ use ncc\ThirdParty\Symfony\Uid\UuidV4; class RandomBasedUuidFactory { - private string $class; - - public function __construct(string $class) - { - $this->class = $class; + /** + * @param class-string $class + */ + public function __construct( + private string $class, + ) { } public function create(): UuidV4 diff --git a/src/ncc/ThirdParty/Symfony/Uid/Factory/TimeBasedUuidFactory.php b/src/ncc/ThirdParty/Symfony/Uid/Factory/TimeBasedUuidFactory.php index 7429a7f..fa94bdc 100644 --- a/src/ncc/ThirdParty/Symfony/Uid/Factory/TimeBasedUuidFactory.php +++ b/src/ncc/ThirdParty/Symfony/Uid/Factory/TimeBasedUuidFactory.php @@ -16,16 +16,16 @@ use ncc\ThirdParty\Symfony\Uid\Uuid; class TimeBasedUuidFactory { - private string $class; - private ?Uuid $node; - - public function __construct(string $class, Uuid $node = null) - { - $this->class = $class; - $this->node = $node; + /** + * @param class-string $class + */ + public function __construct( + private string $class, + private ?Uuid $node = null, + ) { } - public function create(\DateTimeInterface $time = null): Uuid&TimeBasedUidInterface + public function create(?\DateTimeInterface $time = null): Uuid&TimeBasedUidInterface { $class = $this->class; diff --git a/src/ncc/ThirdParty/Symfony/Uid/Factory/UlidFactory.php b/src/ncc/ThirdParty/Symfony/Uid/Factory/UlidFactory.php index d056bff..065ed7f 100644 --- a/src/ncc/ThirdParty/Symfony/Uid/Factory/UlidFactory.php +++ b/src/ncc/ThirdParty/Symfony/Uid/Factory/UlidFactory.php @@ -15,7 +15,7 @@ use ncc\ThirdParty\Symfony\Uid\Ulid; class UlidFactory { - public function create(\DateTimeInterface $time = null): Ulid + public function create(?\DateTimeInterface $time = null): Ulid { return new Ulid(null === $time ? null : Ulid::generate($time)); } diff --git a/src/ncc/ThirdParty/Symfony/Uid/Factory/UuidFactory.php b/src/ncc/ThirdParty/Symfony/Uid/Factory/UuidFactory.php index 79ec95c..86d733b 100644 --- a/src/ncc/ThirdParty/Symfony/Uid/Factory/UuidFactory.php +++ b/src/ncc/ThirdParty/Symfony/Uid/Factory/UuidFactory.php @@ -26,7 +26,7 @@ class UuidFactory private ?Uuid $timeBasedNode; private ?Uuid $nameBasedNamespace; - public function __construct(string|int $defaultClass = UuidV6::class, string|int $timeBasedClass = UuidV6::class, string|int $nameBasedClass = UuidV5::class, string|int $randomBasedClass = UuidV4::class, Uuid|string $timeBasedNode = null, Uuid|string $nameBasedNamespace = null) + public function __construct(string|int $defaultClass = UuidV6::class, string|int $timeBasedClass = UuidV6::class, string|int $nameBasedClass = UuidV5::class, string|int $randomBasedClass = UuidV4::class, Uuid|string|null $timeBasedNode = null, Uuid|string|null $nameBasedNamespace = null) { if (null !== $timeBasedNode && !$timeBasedNode instanceof Uuid) { $timeBasedNode = Uuid::fromString($timeBasedNode); @@ -56,7 +56,7 @@ class UuidFactory return new RandomBasedUuidFactory($this->randomBasedClass); } - public function timeBased(Uuid|string $node = null): TimeBasedUuidFactory + public function timeBased(Uuid|string|null $node = null): TimeBasedUuidFactory { $node ??= $this->timeBasedNode; @@ -67,7 +67,7 @@ class UuidFactory return new TimeBasedUuidFactory($this->timeBasedClass, $node); } - public function nameBased(Uuid|string $namespace = null): NameBasedUuidFactory + public function nameBased(Uuid|string|null $namespace = null): NameBasedUuidFactory { $namespace ??= $this->nameBasedNamespace; diff --git a/src/ncc/ThirdParty/Symfony/Uid/Ulid.php b/src/ncc/ThirdParty/Symfony/Uid/Ulid.php index 1d87c59..3ed5e65 100644 --- a/src/ncc/ThirdParty/Symfony/Uid/Ulid.php +++ b/src/ncc/ThirdParty/Symfony/Uid/Ulid.php @@ -26,7 +26,7 @@ class Ulid extends AbstractUid implements TimeBasedUidInterface private static string $time = ''; private static array $rand = []; - public function __construct(string $ulid = null) + public function __construct(?string $ulid = null) { if (null === $ulid) { $this->uid = static::generate(); @@ -59,7 +59,7 @@ class Ulid extends AbstractUid implements TimeBasedUidInterface public static function fromString(string $ulid): static { if (36 === \strlen($ulid) && preg_match('{^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$}Di', $ulid)) { - $ulid = uuid_parse($ulid); + $ulid = hex2bin(str_replace('-', '', $ulid)); } elseif (22 === \strlen($ulid) && 22 === strspn($ulid, BinaryUtil::BASE58[''])) { $ulid = str_pad(BinaryUtil::fromBase($ulid, BinaryUtil::BASE58), 16, "\0", \STR_PAD_LEFT); } @@ -114,6 +114,13 @@ class Ulid extends AbstractUid implements TimeBasedUidInterface return hex2bin($ulid); } + /** + * Returns the identifier as a base32 case insensitive string. + * + * @see https://tools.ietf.org/html/rfc4648#section-6 + * + * @example 09EJ0S614A9FXVG9C5537Q9ZE1 (len=26) + */ public function toBase32(): string { return $this->uid; @@ -141,7 +148,7 @@ class Ulid extends AbstractUid implements TimeBasedUidInterface return \DateTimeImmutable::createFromFormat('U.u', substr_replace($time, '.', -3, 0)); } - public static function generate(\DateTimeInterface $time = null): string + public static function generate(?\DateTimeInterface $time = null): string { if (null === $mtime = $time) { $time = microtime(false); diff --git a/src/ncc/ThirdParty/Symfony/Uid/Uuid.php b/src/ncc/ThirdParty/Symfony/Uid/Uuid.php index 27ed4b0..9eaeb3c 100644 --- a/src/ncc/ThirdParty/Symfony/Uid/Uuid.php +++ b/src/ncc/ThirdParty/Symfony/Uid/Uuid.php @@ -14,7 +14,7 @@ namespace ncc\ThirdParty\Symfony\Uid; /** * @author Grégoire Pineau * - * @see https://tools.ietf.org/html/rfc4122#appendix-C for details about namespaces + * @see https://datatracker.ietf.org/doc/html/rfc9562/#section-6.6 for details about namespaces */ class Uuid extends AbstractUid { @@ -149,9 +149,16 @@ class Uuid extends AbstractUid public function toBinary(): string { - return uuid_parse($this->uid); + return hex2bin(str_replace('-', '', $this->uid)); } + /** + * Returns the identifier as a RFC4122 case insensitive string. + * + * @see https://tools.ietf.org/html/rfc4122#section-3 + * + * @example 09748193-048a-4bfb-b825-8528cf74fdc1 (len=36) + */ public function toRfc4122(): string { return $this->uid; diff --git a/src/ncc/ThirdParty/Symfony/Uid/UuidV1.php b/src/ncc/ThirdParty/Symfony/Uid/UuidV1.php index 0709042..d2925bc 100644 --- a/src/ncc/ThirdParty/Symfony/Uid/UuidV1.php +++ b/src/ncc/ThirdParty/Symfony/Uid/UuidV1.php @@ -22,10 +22,10 @@ class UuidV1 extends Uuid implements TimeBasedUidInterface private static string $clockSeq; - public function __construct(string $uuid = null) + public function __construct(?string $uuid = null) { if (null === $uuid) { - $this->uid = uuid_create(static::TYPE); + $this->uid = strtolower(uuid_create(static::TYPE)); } else { parent::__construct($uuid, true); } @@ -38,10 +38,22 @@ class UuidV1 extends Uuid implements TimeBasedUidInterface public function getNode(): string { - return uuid_mac($this->uid); + return substr($this->uid, -12); } - public static function generate(\DateTimeInterface $time = null, Uuid $node = null): string + public function toV6(): UuidV6 + { + $uuid = $this->uid; + + return new UuidV6(substr($uuid, 15, 3).substr($uuid, 9, 4).$uuid[0].'-'.substr($uuid, 1, 4).'-6'.substr($uuid, 5, 3).substr($uuid, 18, 6).substr($uuid, 24)); + } + + public function toV7(): UuidV7 + { + return $this->toV6()->toV7(); + } + + public static function generate(?\DateTimeInterface $time = null, ?Uuid $node = null): string { $uuid = !$time || !$node ? uuid_create(static::TYPE) : parent::NIL; diff --git a/src/ncc/ThirdParty/Symfony/Uid/UuidV4.php b/src/ncc/ThirdParty/Symfony/Uid/UuidV4.php index 6cf8097..88d1127 100644 --- a/src/ncc/ThirdParty/Symfony/Uid/UuidV4.php +++ b/src/ncc/ThirdParty/Symfony/Uid/UuidV4.php @@ -20,15 +20,22 @@ class UuidV4 extends Uuid { protected const TYPE = 4; - public function __construct(string $uuid = null) + public function __construct(?string $uuid = null) { if (null === $uuid) { - $uuid = random_bytes(16); - $uuid[6] = $uuid[6] & "\x0F" | "\x40"; - $uuid[8] = $uuid[8] & "\x3F" | "\x80"; - $uuid = bin2hex($uuid); - - $this->uid = substr($uuid, 0, 8).'-'.substr($uuid, 8, 4).'-'.substr($uuid, 12, 4).'-'.substr($uuid, 16, 4).'-'.substr($uuid, 20, 12); + // Generate 36 random hex characters (144 bits) + // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + $uuid = bin2hex(random_bytes(18)); + // Insert dashes to match the UUID format + // xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + $uuid[8] = $uuid[13] = $uuid[18] = $uuid[23] = '-'; + // Set the UUID version to 4 + // xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx + $uuid[14] = '4'; + // Set the UUID variant: the 19th char must be in [8, 9, a, b] + // xxxxxxxx-xxxx-4xxx-?xxx-xxxxxxxxxxxx + $uuid[19] = ['8', '9', 'a', 'b', '8', '9', 'a', 'b', 'c' => '8', 'd' => '9', 'e' => 'a', 'f' => 'b'][$uuid[19]] ?? $uuid[19]; + $this->uid = $uuid; } else { parent::__construct($uuid, true); } diff --git a/src/ncc/ThirdParty/Symfony/Uid/UuidV6.php b/src/ncc/ThirdParty/Symfony/Uid/UuidV6.php index ae43bb4..d65d673 100644 --- a/src/ncc/ThirdParty/Symfony/Uid/UuidV6.php +++ b/src/ncc/ThirdParty/Symfony/Uid/UuidV6.php @@ -24,7 +24,7 @@ class UuidV6 extends Uuid implements TimeBasedUidInterface private static string $node; - public function __construct(string $uuid = null) + public function __construct(?string $uuid = null) { if (null === $uuid) { $this->uid = static::generate(); @@ -43,7 +43,34 @@ class UuidV6 extends Uuid implements TimeBasedUidInterface return substr($this->uid, 24); } - public static function generate(\DateTimeInterface $time = null, Uuid $node = null): string + public function toV7(): UuidV7 + { + $uuid = $this->uid; + $time = BinaryUtil::hexToNumericString('0'.substr($uuid, 0, 8).substr($uuid, 9, 4).substr($uuid, 15, 3)); + if ('-' === $time[0]) { + throw new \InvalidArgumentException('Cannot convert UUID to v7: its timestamp is before the Unix epoch.'); + } + + $ms = \strlen($time) > 4 ? substr($time, 0, -4) : '0'; + $time = dechex(10000 * hexdec(substr($uuid, 20, 3)) + substr($time, -4)); + + if (\strlen($time) > 6) { + $uuid[29] = dechex(hexdec($uuid[29]) ^ hexdec($time[0])); + $time = substr($time, 1); + } + + return new UuidV7(substr_replace(sprintf( + '%012s-7%s-%s%s-%s%06s', + \PHP_INT_SIZE >= 8 ? dechex($ms) : bin2hex(BinaryUtil::fromBase($ms, BinaryUtil::BASE10)), + substr($uuid, -6, 3), + $uuid[19], + substr($uuid, -3), + substr($uuid, -12, 6), + $time + ), '-', 8, 0)); + } + + public static function generate(?\DateTimeInterface $time = null, ?Uuid $node = null): string { $uuidV1 = UuidV1::generate($time, $node); $uuid = substr($uuidV1, 15, 3).substr($uuidV1, 9, 4).$uuidV1[0].'-'.substr($uuidV1, 1, 4).'-6'.substr($uuidV1, 5, 3).substr($uuidV1, 18, 6); diff --git a/src/ncc/ThirdParty/Symfony/Uid/UuidV7.php b/src/ncc/ThirdParty/Symfony/Uid/UuidV7.php index 236fae4..c5a0433 100644 --- a/src/ncc/ThirdParty/Symfony/Uid/UuidV7.php +++ b/src/ncc/ThirdParty/Symfony/Uid/UuidV7.php @@ -28,7 +28,7 @@ class UuidV7 extends Uuid implements TimeBasedUidInterface private static array $seedParts; private static int $seedIndex = 0; - public function __construct(string $uuid = null) + public function __construct(?string $uuid = null) { if (null === $uuid) { $this->uid = static::generate(); @@ -49,7 +49,7 @@ class UuidV7 extends Uuid implements TimeBasedUidInterface return \DateTimeImmutable::createFromFormat('U.v', substr_replace($time, '.', -3, 0)); } - public static function generate(\DateTimeInterface $time = null): string + public static function generate(?\DateTimeInterface $time = null): string { if (null === $mtime = $time) { $time = microtime(false); @@ -64,6 +64,17 @@ class UuidV7 extends Uuid implements TimeBasedUidInterface self::$rand[1] &= 0x03FF; self::$time = $time; } else { + // Within the same ms, we increment the rand part by a random 24-bit number. + // Instead of getting this number from random_bytes(), which is slow, we get + // it by sha512-hashing self::$seed. This produces 64 bytes of entropy, + // which we need to split in a list of 24-bit numbers. unpack() first splits + // them into 16 x 32-bit numbers; we take the first byte of each of these + // numbers to get 5 extra 24-bit numbers. Then, we consume those numbers + // one-by-one and run this logic every 21 iterations. + // self::$rand holds the random part of the UUID, split into 5 x 16-bit + // numbers for x86 portability. We increment this random part by the next + // 24-bit number in the self::$seedParts list and decrement self::$seedIndex. + if (!self::$seedIndex) { $s = unpack('l*', self::$seed = hash('sha512', self::$seed, true)); $s[] = ($s[1] >> 8 & 0xFF0000) | ($s[2] >> 16 & 0xFF00) | ($s[3] >> 24 & 0xFF); @@ -75,7 +86,7 @@ class UuidV7 extends Uuid implements TimeBasedUidInterface self::$seedIndex = 21; } - self::$rand[5] = 0xFFFF & $carry = self::$rand[5] + (self::$seedParts[self::$seedIndex--] & 0xFFFFFF); + self::$rand[5] = 0xFFFF & $carry = self::$rand[5] + 1 + (self::$seedParts[self::$seedIndex--] & 0xFFFFFF); self::$rand[4] = 0xFFFF & $carry = self::$rand[4] + ($carry >> 16); self::$rand[3] = 0xFFFF & $carry = self::$rand[3] + ($carry >> 16); self::$rand[2] = 0xFFFF & $carry = self::$rand[2] + ($carry >> 16); diff --git a/src/ncc/ThirdParty/Symfony/Uid/VERSION b/src/ncc/ThirdParty/Symfony/Uid/VERSION index 2319a69..334b5ce 100644 --- a/src/ncc/ThirdParty/Symfony/Uid/VERSION +++ b/src/ncc/ThirdParty/Symfony/Uid/VERSION @@ -1 +1 @@ -6.3.5 \ No newline at end of file +7.1.4 \ No newline at end of file From dd48100f0652cb9bb7cdc90e4aea8e78b4058d32 Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 15:14:53 -0400 Subject: [PATCH 102/134] Updated Symfony/Process to version 7.1.3 --- CHANGELOG.md | 1 + .../ThirdParty/Symfony/Process/CHANGELOG.md | 12 + .../Exception/ProcessFailedException.php | 7 +- .../Exception/ProcessSignaledException.php | 2 +- .../Exception/ProcessStartFailedException.php | 45 ++++ .../Exception/ProcessTimedOutException.php | 19 +- .../Exception/RunProcessFailedException.php | 25 ++ .../Symfony/Process/ExecutableFinder.php | 44 ++-- .../Symfony/Process/InputStream.php | 25 +- .../Process/Messenger/RunProcessContext.php | 33 +++ .../Process/Messenger/RunProcessMessage.php | 32 +++ .../Messenger/RunProcessMessageHandler.php | 33 +++ .../Symfony/Process/PhpExecutableFinder.php | 6 +- .../ThirdParty/Symfony/Process/PhpProcess.php | 9 +- .../Symfony/Process/PhpSubprocess.php | 164 +++++++++++++ .../Symfony/Process/Pipes/AbstractPipes.php | 13 +- .../Symfony/Process/Pipes/UnixPipes.php | 8 +- .../Symfony/Process/Pipes/WindowsPipes.php | 14 +- .../ThirdParty/Symfony/Process/Process.php | 228 +++++++++++------- .../Symfony/Process/ProcessUtils.php | 3 - src/ncc/ThirdParty/Symfony/Process/VERSION | 2 +- 21 files changed, 547 insertions(+), 178 deletions(-) create mode 100644 src/ncc/ThirdParty/Symfony/Process/Exception/ProcessStartFailedException.php create mode 100644 src/ncc/ThirdParty/Symfony/Process/Exception/RunProcessFailedException.php create mode 100644 src/ncc/ThirdParty/Symfony/Process/Messenger/RunProcessContext.php create mode 100644 src/ncc/ThirdParty/Symfony/Process/Messenger/RunProcessMessage.php create mode 100644 src/ncc/ThirdParty/Symfony/Process/Messenger/RunProcessMessageHandler.php create mode 100644 src/ncc/ThirdParty/Symfony/Process/PhpSubprocess.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 27033e6..a484867 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,7 @@ This update introduces a refactored code-base, code quality improvements, and be - Refactor project constants handling in NccCompiler - Updated Symfony/Yaml to version 7.1.4 - Updated Symfony/Uid to version 7.1.4 + - Updated Symfony/Process to version 7.1.3 ### Fixed - Fixed Division by zero in PackageManager diff --git a/src/ncc/ThirdParty/Symfony/Process/CHANGELOG.md b/src/ncc/ThirdParty/Symfony/Process/CHANGELOG.md index 31b9ee6..3e33cd0 100644 --- a/src/ncc/ThirdParty/Symfony/Process/CHANGELOG.md +++ b/src/ncc/ThirdParty/Symfony/Process/CHANGELOG.md @@ -1,6 +1,18 @@ CHANGELOG ========= +7.1 +--- + + * Add `Process::setIgnoredSignals()` to disable signal propagation to the child process + +6.4 +--- + + * Add `PhpSubprocess` to handle PHP subprocesses that take over the + configuration from their parent + * Add `RunProcessMessage` and `RunProcessMessageHandler` + 5.2.0 ----- diff --git a/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessFailedException.php b/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessFailedException.php index 1a3c997..8a56df1 100644 --- a/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessFailedException.php +++ b/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessFailedException.php @@ -20,7 +20,7 @@ use ncc\ThirdParty\Symfony\Process\Process; */ class ProcessFailedException extends RuntimeException { - private $process; + private Process $process; public function __construct(Process $process) { @@ -47,10 +47,7 @@ class ProcessFailedException extends RuntimeException $this->process = $process; } - /** - * @return Process - */ - public function getProcess() + public function getProcess(): Process { return $this->process; } diff --git a/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessSignaledException.php b/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessSignaledException.php index b14e6ab..9b1efa6 100644 --- a/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessSignaledException.php +++ b/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessSignaledException.php @@ -20,7 +20,7 @@ use ncc\ThirdParty\Symfony\Process\Process; */ final class ProcessSignaledException extends RuntimeException { - private $process; + private Process $process; public function __construct(Process $process) { diff --git a/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessStartFailedException.php b/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessStartFailedException.php new file mode 100644 index 0000000..917d569 --- /dev/null +++ b/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessStartFailedException.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace ncc\ThirdParty\Symfony\Process\Exception; + +use ncc\ThirdParty\Symfony\Process\Process; + +/** + * Exception for processes failed during startup. + */ +class ProcessStartFailedException extends ProcessFailedException +{ + private Process $process; + + public function __construct(Process $process, ?string $message) + { + if ($process->isStarted()) { + throw new InvalidArgumentException('Expected a process that failed during startup, but the given process was started successfully.'); + } + + $error = sprintf('The command "%s" failed.'."\n\nWorking directory: %s\n\nError: %s", + $process->getCommandLine(), + $process->getWorkingDirectory(), + $message ?? 'unknown' + ); + + // Skip parent constructor + RuntimeException::__construct($error); + + $this->process = $process; + } + + public function getProcess(): Process + { + return $this->process; + } +} diff --git a/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessTimedOutException.php b/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessTimedOutException.php index a3a4fb4..3e2b57a 100644 --- a/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessTimedOutException.php +++ b/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessTimedOutException.php @@ -23,8 +23,8 @@ class ProcessTimedOutException extends RuntimeException public const TYPE_GENERAL = 1; public const TYPE_IDLE = 2; - private $process; - private $timeoutType; + private Process $process; + private int $timeoutType; public function __construct(Process $process, int $timeoutType) { @@ -38,26 +38,17 @@ class ProcessTimedOutException extends RuntimeException )); } - /** - * @return Process - */ - public function getProcess() + public function getProcess(): Process { return $this->process; } - /** - * @return bool - */ - public function isGeneralTimeout() + public function isGeneralTimeout(): bool { return self::TYPE_GENERAL === $this->timeoutType; } - /** - * @return bool - */ - public function isIdleTimeout() + public function isIdleTimeout(): bool { return self::TYPE_IDLE === $this->timeoutType; } diff --git a/src/ncc/ThirdParty/Symfony/Process/Exception/RunProcessFailedException.php b/src/ncc/ThirdParty/Symfony/Process/Exception/RunProcessFailedException.php new file mode 100644 index 0000000..016551e --- /dev/null +++ b/src/ncc/ThirdParty/Symfony/Process/Exception/RunProcessFailedException.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace ncc\ThirdParty\Symfony\Process\Exception; + +use ncc\ThirdParty\Symfony\Process\Messenger\RunProcessContext; + +/** + * @author Kevin Bond + */ +final class RunProcessFailedException extends RuntimeException +{ + public function __construct(ProcessFailedException $exception, public readonly RunProcessContext $context) + { + parent::__construct($exception->getMessage(), $exception->getCode()); + } +} diff --git a/src/ncc/ThirdParty/Symfony/Process/ExecutableFinder.php b/src/ncc/ThirdParty/Symfony/Process/ExecutableFinder.php index 397e8f4..c4dc3fa 100644 --- a/src/ncc/ThirdParty/Symfony/Process/ExecutableFinder.php +++ b/src/ncc/ThirdParty/Symfony/Process/ExecutableFinder.php @@ -19,24 +19,20 @@ namespace ncc\ThirdParty\Symfony\Process; */ class ExecutableFinder { - private $suffixes = ['.exe', '.bat', '.cmd', '.com']; + private array $suffixes = ['.exe', '.bat', '.cmd', '.com']; /** * Replaces default suffixes of executable. - * - * @return void */ - public function setSuffixes(array $suffixes) + public function setSuffixes(array $suffixes): void { $this->suffixes = $suffixes; } /** * Adds new possible suffix to check for executable. - * - * @return void */ - public function addSuffix(string $suffix) + public function addSuffix(string $suffix): void { $this->suffixes[] = $suffix; } @@ -48,27 +44,12 @@ class ExecutableFinder * @param string|null $default The default to return if no executable is found * @param array $extraDirs Additional dirs to check into */ - public function find(string $name, string $default = null, array $extraDirs = []): ?string + public function find(string $name, ?string $default = null, array $extraDirs = []): ?string { - if (\ini_get('open_basedir')) { - $searchPath = array_merge(explode(\PATH_SEPARATOR, \ini_get('open_basedir')), $extraDirs); - $dirs = []; - foreach ($searchPath as $path) { - // Silencing against https://bugs.php.net/69240 - if (@is_dir($path)) { - $dirs[] = $path; - } else { - if (basename($path) == $name && @is_executable($path)) { - return $path; - } - } - } - } else { - $dirs = array_merge( - explode(\PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')), - $extraDirs - ); - } + $dirs = array_merge( + explode(\PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')), + $extraDirs + ); $suffixes = ['']; if ('\\' === \DIRECTORY_SEPARATOR) { @@ -80,9 +61,18 @@ class ExecutableFinder if (@is_file($file = $dir.\DIRECTORY_SEPARATOR.$name.$suffix) && ('\\' === \DIRECTORY_SEPARATOR || @is_executable($file))) { return $file; } + + if (!@is_dir($dir) && basename($dir) === $name.$suffix && @is_executable($dir)) { + return $dir; + } } } + $command = '\\' === \DIRECTORY_SEPARATOR ? 'where' : 'command -v --'; + if (\function_exists('exec') && ($executablePath = strtok(@exec($command.' '.escapeshellarg($name)), \PHP_EOL)) && @is_executable($executablePath)) { + return $executablePath; + } + return $default; } } diff --git a/src/ncc/ThirdParty/Symfony/Process/InputStream.php b/src/ncc/ThirdParty/Symfony/Process/InputStream.php index bed86da..44116ae 100644 --- a/src/ncc/ThirdParty/Symfony/Process/InputStream.php +++ b/src/ncc/ThirdParty/Symfony/Process/InputStream.php @@ -22,19 +22,16 @@ use ncc\ThirdParty\Symfony\Process\Exception\RuntimeException; */ class InputStream implements \IteratorAggregate { - /** @var callable|null */ - private $onEmpty; - private $input = []; - private $open = true; + private ?\Closure $onEmpty = null; + private array $input = []; + private bool $open = true; /** * Sets a callback that is called when the write buffer becomes empty. - * - * @return void */ - public function onEmpty(callable $onEmpty = null) + public function onEmpty(?callable $onEmpty = null): void { - $this->onEmpty = $onEmpty; + $this->onEmpty = null !== $onEmpty ? $onEmpty(...) : null; } /** @@ -42,10 +39,8 @@ class InputStream implements \IteratorAggregate * * @param resource|string|int|float|bool|\Traversable|null $input The input to append as scalar, * stream resource or \Traversable - * - * @return void */ - public function write(mixed $input) + public function write(mixed $input): void { if (null === $input) { return; @@ -58,20 +53,16 @@ class InputStream implements \IteratorAggregate /** * Closes the write buffer. - * - * @return void */ - public function close() + public function close(): void { $this->open = false; } /** * Tells whether the write buffer is closed or not. - * - * @return bool */ - public function isClosed() + public function isClosed(): bool { return !$this->open; } diff --git a/src/ncc/ThirdParty/Symfony/Process/Messenger/RunProcessContext.php b/src/ncc/ThirdParty/Symfony/Process/Messenger/RunProcessContext.php new file mode 100644 index 0000000..54cbf9f --- /dev/null +++ b/src/ncc/ThirdParty/Symfony/Process/Messenger/RunProcessContext.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace ncc\ThirdParty\Symfony\Process\Messenger; + +use ncc\ThirdParty\Symfony\Process\Process; + +/** + * @author Kevin Bond + */ +final class RunProcessContext +{ + public readonly ?int $exitCode; + public readonly ?string $output; + public readonly ?string $errorOutput; + + public function __construct( + public readonly RunProcessMessage $message, + Process $process, + ) { + $this->exitCode = $process->getExitCode(); + $this->output = !$process->isStarted() || $process->isOutputDisabled() ? null : $process->getOutput(); + $this->errorOutput = !$process->isStarted() || $process->isOutputDisabled() ? null : $process->getErrorOutput(); + } +} diff --git a/src/ncc/ThirdParty/Symfony/Process/Messenger/RunProcessMessage.php b/src/ncc/ThirdParty/Symfony/Process/Messenger/RunProcessMessage.php new file mode 100644 index 0000000..6db0677 --- /dev/null +++ b/src/ncc/ThirdParty/Symfony/Process/Messenger/RunProcessMessage.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace ncc\ThirdParty\Symfony\Process\Messenger; + +/** + * @author Kevin Bond + */ +class RunProcessMessage implements \Stringable +{ + public function __construct( + public readonly array $command, + public readonly ?string $cwd = null, + public readonly ?array $env = null, + public readonly mixed $input = null, + public readonly ?float $timeout = 60.0, + ) { + } + + public function __toString(): string + { + return implode(' ', $this->command); + } +} diff --git a/src/ncc/ThirdParty/Symfony/Process/Messenger/RunProcessMessageHandler.php b/src/ncc/ThirdParty/Symfony/Process/Messenger/RunProcessMessageHandler.php new file mode 100644 index 0000000..a292f7f --- /dev/null +++ b/src/ncc/ThirdParty/Symfony/Process/Messenger/RunProcessMessageHandler.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace ncc\ThirdParty\Symfony\Process\Messenger; + +use ncc\ThirdParty\Symfony\Process\Exception\ProcessFailedException; +use ncc\ThirdParty\Symfony\Process\Exception\RunProcessFailedException; +use ncc\ThirdParty\Symfony\Process\Process; + +/** + * @author Kevin Bond + */ +final class RunProcessMessageHandler +{ + public function __invoke(RunProcessMessage $message): RunProcessContext + { + $process = new Process($message->command, $message->cwd, $message->env, $message->input, $message->timeout); + + try { + return new RunProcessContext($message, $process->mustRun()); + } catch (ProcessFailedException $e) { + throw new RunProcessFailedException($e, new RunProcessContext($message, $e->getProcess())); + } + } +} diff --git a/src/ncc/ThirdParty/Symfony/Process/PhpExecutableFinder.php b/src/ncc/ThirdParty/Symfony/Process/PhpExecutableFinder.php index 2fa756c..2f727cd 100644 --- a/src/ncc/ThirdParty/Symfony/Process/PhpExecutableFinder.php +++ b/src/ncc/ThirdParty/Symfony/Process/PhpExecutableFinder.php @@ -19,7 +19,7 @@ namespace ncc\ThirdParty\Symfony\Process; */ class PhpExecutableFinder { - private $executableFinder; + private ExecutableFinder $executableFinder; public function __construct() { @@ -33,8 +33,8 @@ class PhpExecutableFinder { if ($php = getenv('PHP_BINARY')) { if (!is_executable($php)) { - $command = '\\' === \DIRECTORY_SEPARATOR ? 'where' : 'command -v'; - if ($php = strtok(exec($command.' '.escapeshellarg($php)), \PHP_EOL)) { + $command = '\\' === \DIRECTORY_SEPARATOR ? 'where' : 'command -v --'; + if (\function_exists('exec') && $php = strtok(exec($command.' '.escapeshellarg($php)), \PHP_EOL)) { if (!is_executable($php)) { return false; } diff --git a/src/ncc/ThirdParty/Symfony/Process/PhpProcess.php b/src/ncc/ThirdParty/Symfony/Process/PhpProcess.php index 6923a90..ee4b3a4 100644 --- a/src/ncc/ThirdParty/Symfony/Process/PhpProcess.php +++ b/src/ncc/ThirdParty/Symfony/Process/PhpProcess.php @@ -32,7 +32,7 @@ class PhpProcess extends Process * @param int $timeout The timeout in seconds * @param array|null $php Path to the PHP binary to use with any additional arguments */ - public function __construct(string $script, string $cwd = null, array $env = null, int $timeout = 60, array $php = null) + public function __construct(string $script, ?string $cwd = null, ?array $env = null, int $timeout = 60, ?array $php = null) { if (null === $php) { $executableFinder = new PhpExecutableFinder(); @@ -50,15 +50,12 @@ class PhpProcess extends Process parent::__construct($php, $cwd, $env, $script, $timeout); } - public static function fromShellCommandline(string $command, string $cwd = null, array $env = null, mixed $input = null, ?float $timeout = 60): static + public static function fromShellCommandline(string $command, ?string $cwd = null, ?array $env = null, mixed $input = null, ?float $timeout = 60): static { throw new LogicException(sprintf('The "%s()" method cannot be called when using "%s".', __METHOD__, self::class)); } - /** - * @return void - */ - public function start(callable $callback = null, array $env = []) + public function start(?callable $callback = null, array $env = []): void { if (null === $this->getCommandLine()) { throw new RuntimeException('Unable to find the PHP executable.'); diff --git a/src/ncc/ThirdParty/Symfony/Process/PhpSubprocess.php b/src/ncc/ThirdParty/Symfony/Process/PhpSubprocess.php new file mode 100644 index 0000000..3d271a9 --- /dev/null +++ b/src/ncc/ThirdParty/Symfony/Process/PhpSubprocess.php @@ -0,0 +1,164 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace ncc\ThirdParty\Symfony\Process; + +use ncc\ThirdParty\Symfony\Process\Exception\LogicException; +use ncc\ThirdParty\Symfony\Process\Exception\RuntimeException; + +/** + * PhpSubprocess runs a PHP command as a subprocess while keeping the original php.ini settings. + * + * For this, it generates a temporary php.ini file taking over all the current settings and disables + * loading additional .ini files. Basically, your command gets prefixed using "php -n -c /tmp/temp.ini". + * + * Given your php.ini contains "memory_limit=-1" and you have a "MemoryTest.php" with the following content: + * + * run(); + * print $p->getOutput()."\n"; + * + * This will output "string(2) "-1", because the process is started with the default php.ini settings. + * + * $p = new PhpSubprocess(['MemoryTest.php'], null, null, 60, ['php', '-d', 'memory_limit=256M']); + * $p->run(); + * print $p->getOutput()."\n"; + * + * This will output "string(4) "256M"", because the process is started with the temporarily created php.ini settings. + * + * @author Yanick Witschi + * @author Partially copied and heavily inspired from composer/xdebug-handler by John Stevenson + */ +class PhpSubprocess extends Process +{ + /** + * @param array $command The command to run and its arguments listed as separate entries. They will automatically + * get prefixed with the PHP binary + * @param string|null $cwd The working directory or null to use the working dir of the current PHP process + * @param array|null $env The environment variables or null to use the same environment as the current PHP process + * @param int $timeout The timeout in seconds + * @param array|null $php Path to the PHP binary to use with any additional arguments + */ + public function __construct(array $command, ?string $cwd = null, ?array $env = null, int $timeout = 60, ?array $php = null) + { + if (null === $php) { + $executableFinder = new PhpExecutableFinder(); + $php = $executableFinder->find(false); + $php = false === $php ? null : array_merge([$php], $executableFinder->findArguments()); + } + + if (null === $php) { + throw new RuntimeException('Unable to find PHP binary.'); + } + + $tmpIni = $this->writeTmpIni($this->getAllIniFiles(), sys_get_temp_dir()); + + $php = array_merge($php, ['-n', '-c', $tmpIni]); + register_shutdown_function('unlink', $tmpIni); + + $command = array_merge($php, $command); + + parent::__construct($command, $cwd, $env, null, $timeout); + } + + public static function fromShellCommandline(string $command, ?string $cwd = null, ?array $env = null, mixed $input = null, ?float $timeout = 60): static + { + throw new LogicException(sprintf('The "%s()" method cannot be called when using "%s".', __METHOD__, self::class)); + } + + public function start(?callable $callback = null, array $env = []): void + { + if (null === $this->getCommandLine()) { + throw new RuntimeException('Unable to find the PHP executable.'); + } + + parent::start($callback, $env); + } + + private function writeTmpIni(array $iniFiles, string $tmpDir): string + { + if (false === $tmpfile = @tempnam($tmpDir, '')) { + throw new RuntimeException('Unable to create temporary ini file.'); + } + + // $iniFiles has at least one item and it may be empty + if ('' === $iniFiles[0]) { + array_shift($iniFiles); + } + + $content = ''; + + foreach ($iniFiles as $file) { + // Check for inaccessible ini files + if (($data = @file_get_contents($file)) === false) { + throw new RuntimeException('Unable to read ini: '.$file); + } + // Check and remove directives after HOST and PATH sections + if (preg_match('/^\s*\[(?:PATH|HOST)\s*=/mi', $data, $matches, \PREG_OFFSET_CAPTURE)) { + $data = substr($data, 0, $matches[0][1]); + } + + $content .= $data."\n"; + } + + // Merge loaded settings into our ini content, if it is valid + $config = parse_ini_string($content); + $loaded = ini_get_all(null, false); + + if (false === $config || false === $loaded) { + throw new RuntimeException('Unable to parse ini data.'); + } + + $content .= $this->mergeLoadedConfig($loaded, $config); + + // Work-around for https://bugs.php.net/bug.php?id=75932 + $content .= "opcache.enable_cli=0\n"; + + if (false === @file_put_contents($tmpfile, $content)) { + throw new RuntimeException('Unable to write temporary ini file.'); + } + + return $tmpfile; + } + + private function mergeLoadedConfig(array $loadedConfig, array $iniConfig): string + { + $content = ''; + + foreach ($loadedConfig as $name => $value) { + if (!\is_string($value)) { + continue; + } + + if (!isset($iniConfig[$name]) || $iniConfig[$name] !== $value) { + // Double-quote escape each value + $content .= $name.'="'.addcslashes($value, '\\"')."\"\n"; + } + } + + return $content; + } + + private function getAllIniFiles(): array + { + $paths = [(string) php_ini_loaded_file()]; + + if (false !== $scanned = php_ini_scanned_files()) { + $paths = array_merge($paths, array_map('trim', explode(',', $scanned))); + } + + return $paths; + } +} diff --git a/src/ncc/ThirdParty/Symfony/Process/Pipes/AbstractPipes.php b/src/ncc/ThirdParty/Symfony/Process/Pipes/AbstractPipes.php index 283da52..8096b60 100644 --- a/src/ncc/ThirdParty/Symfony/Process/Pipes/AbstractPipes.php +++ b/src/ncc/ThirdParty/Symfony/Process/Pipes/AbstractPipes.php @@ -22,20 +22,19 @@ abstract class AbstractPipes implements PipesInterface { public array $pipes = []; - private $inputBuffer = ''; + private string $inputBuffer = ''; + /** @var resource|string|\Iterator */ private $input; - private $blocked = true; - private $lastError; + private bool $blocked = true; + private ?string $lastError = null; /** - * @param resource|string|int|float|bool|\Iterator|null $input + * @param resource|string|\Iterator $input */ - public function __construct(mixed $input) + public function __construct($input) { if (\is_resource($input) || $input instanceof \Iterator) { $this->input = $input; - } elseif (\is_string($input)) { - $this->inputBuffer = $input; } else { $this->inputBuffer = (string) $input; } diff --git a/src/ncc/ThirdParty/Symfony/Process/Pipes/UnixPipes.php b/src/ncc/ThirdParty/Symfony/Process/Pipes/UnixPipes.php index c35f843..c617899 100644 --- a/src/ncc/ThirdParty/Symfony/Process/Pipes/UnixPipes.php +++ b/src/ncc/ThirdParty/Symfony/Process/Pipes/UnixPipes.php @@ -22,9 +22,9 @@ use ncc\ThirdParty\Symfony\Process\Process; */ class UnixPipes extends AbstractPipes { - private $ttyMode; - private $ptyMode; - private $haveReadSupport; + private ?bool $ttyMode; + private bool $ptyMode; + private bool $haveReadSupport; public function __construct(?bool $ttyMode, bool $ptyMode, mixed $input, bool $haveReadSupport) { @@ -40,7 +40,7 @@ class UnixPipes extends AbstractPipes throw new \BadMethodCallException('Cannot serialize '.__CLASS__); } - public function __wakeup() + public function __wakeup(): void { throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); } diff --git a/src/ncc/ThirdParty/Symfony/Process/Pipes/WindowsPipes.php b/src/ncc/ThirdParty/Symfony/Process/Pipes/WindowsPipes.php index 65225ae..1dc6dfe 100644 --- a/src/ncc/ThirdParty/Symfony/Process/Pipes/WindowsPipes.php +++ b/src/ncc/ThirdParty/Symfony/Process/Pipes/WindowsPipes.php @@ -26,14 +26,14 @@ use ncc\ThirdParty\Symfony\Process\Process; */ class WindowsPipes extends AbstractPipes { - private $files = []; - private $fileHandles = []; - private $lockHandles = []; - private $readBytes = [ + private array $files = []; + private array $fileHandles = []; + private array $lockHandles = []; + private array $readBytes = [ Process::STDOUT => 0, Process::STDERR => 0, ]; - private $haveReadSupport; + private bool $haveReadSupport; public function __construct(mixed $input, bool $haveReadSupport) { @@ -93,7 +93,7 @@ class WindowsPipes extends AbstractPipes throw new \BadMethodCallException('Cannot serialize '.__CLASS__); } - public function __wakeup() + public function __wakeup(): void { throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); } @@ -140,7 +140,7 @@ class WindowsPipes extends AbstractPipes if ($w) { @stream_select($r, $w, $e, 0, Process::TIMEOUT_PRECISION * 1E6); } elseif ($this->fileHandles) { - usleep(Process::TIMEOUT_PRECISION * 1E6); + usleep((int) (Process::TIMEOUT_PRECISION * 1E6)); } } foreach ($this->fileHandles as $type => $fileHandle) { diff --git a/src/ncc/ThirdParty/Symfony/Process/Process.php b/src/ncc/ThirdParty/Symfony/Process/Process.php index 38e3e8c..fc0cb34 100644 --- a/src/ncc/ThirdParty/Symfony/Process/Process.php +++ b/src/ncc/ThirdParty/Symfony/Process/Process.php @@ -15,9 +15,9 @@ use ncc\ThirdParty\Symfony\Process\Exception\InvalidArgumentException; use ncc\ThirdParty\Symfony\Process\Exception\LogicException; use ncc\ThirdParty\Symfony\Process\Exception\ProcessFailedException; use ncc\ThirdParty\Symfony\Process\Exception\ProcessSignaledException; +use ncc\ThirdParty\Symfony\Process\Exception\ProcessStartFailedException; use ncc\ThirdParty\Symfony\Process\Exception\ProcessTimedOutException; use ncc\ThirdParty\Symfony\Process\Exception\RuntimeException; -use ncc\ThirdParty\Symfony\Process\Pipes\PipesInterface; use ncc\ThirdParty\Symfony\Process\Pipes\UnixPipes; use ncc\ThirdParty\Symfony\Process\Pipes\WindowsPipes; @@ -51,44 +51,47 @@ class Process implements \IteratorAggregate public const ITER_SKIP_OUT = 4; // Use this flag to skip STDOUT while iterating public const ITER_SKIP_ERR = 8; // Use this flag to skip STDERR while iterating - private $callback; - private $hasCallback = false; - private $commandline; - private $cwd; - private $env = []; + private ?\Closure $callback = null; + private array|string $commandline; + private ?string $cwd; + private array $env = []; + /** @var resource|string|\Iterator|null */ private $input; - private $starttime; - private $lastOutputTime; - private $timeout; - private $idleTimeout; - private $exitcode; - private $fallbackStatus = []; - private $processInformation; - private $outputDisabled = false; + private ?float $starttime = null; + private ?float $lastOutputTime = null; + private ?float $timeout = null; + private ?float $idleTimeout = null; + private ?int $exitcode = null; + private array $fallbackStatus = []; + private array $processInformation; + private bool $outputDisabled = false; + /** @var resource */ private $stdout; + /** @var resource */ private $stderr; + /** @var resource|null */ private $process; - private $status = self::STATUS_READY; - private $incrementalOutputOffset = 0; - private $incrementalErrorOutputOffset = 0; - private $tty = false; - private $pty; - private $options = ['suppress_errors' => true, 'bypass_shell' => true]; + private string $status = self::STATUS_READY; + private int $incrementalOutputOffset = 0; + private int $incrementalErrorOutputOffset = 0; + private bool $tty = false; + private bool $pty; + private array $options = ['suppress_errors' => true, 'bypass_shell' => true]; + private array $ignoredSignals = []; - private $useFileHandles = false; - /** @var PipesInterface */ - private $processPipes; + private WindowsPipes|UnixPipes $processPipes; - private $latestSignal; + private ?int $latestSignal = null; + private ?int $cachedExitCode = null; - private static $sigchild; + private static ?bool $sigchild = null; /** * Exit codes translation table. * * User-defined errors must use exit codes in the 64-113 range. */ - public static $exitCodes = [ + public static array $exitCodes = [ 0 => 'OK', 1 => 'General error', 2 => 'Misuse of shell builtins', @@ -140,7 +143,7 @@ class Process implements \IteratorAggregate * * @throws LogicException When proc_open is not installed */ - public function __construct(array $command, string $cwd = null, array $env = null, mixed $input = null, ?float $timeout = 60) + public function __construct(array $command, ?string $cwd = null, ?array $env = null, mixed $input = null, ?float $timeout = 60) { if (!\function_exists('proc_open')) { throw new LogicException('The Process class relies on proc_open, which is not available on your PHP installation.'); @@ -162,7 +165,6 @@ class Process implements \IteratorAggregate $this->setInput($input); $this->setTimeout($timeout); - $this->useFileHandles = '\\' === \DIRECTORY_SEPARATOR; $this->pty = false; } @@ -187,7 +189,7 @@ class Process implements \IteratorAggregate * * @throws LogicException When proc_open is not installed */ - public static function fromShellCommandline(string $command, string $cwd = null, array $env = null, mixed $input = null, ?float $timeout = 60): static + public static function fromShellCommandline(string $command, ?string $cwd = null, ?array $env = null, mixed $input = null, ?float $timeout = 60): static { $process = new static([], $cwd, $env, $input, $timeout); $process->commandline = $command; @@ -200,7 +202,7 @@ class Process implements \IteratorAggregate throw new \BadMethodCallException('Cannot serialize '.__CLASS__); } - public function __wakeup() + public function __wakeup(): void { throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); } @@ -234,15 +236,15 @@ class Process implements \IteratorAggregate * * @return int The exit status code * - * @throws RuntimeException When process can't be launched - * @throws RuntimeException When process is already running - * @throws ProcessTimedOutException When process timed out - * @throws ProcessSignaledException When process stopped after receiving signal - * @throws LogicException In case a callback is provided and output has been disabled + * @throws ProcessStartFailedException When process can't be launched + * @throws RuntimeException When process is already running + * @throws ProcessTimedOutException When process timed out + * @throws ProcessSignaledException When process stopped after receiving signal + * @throws LogicException In case a callback is provided and output has been disabled * * @final */ - public function run(callable $callback = null, array $env = []): int + public function run(?callable $callback = null, array $env = []): int { $this->start($callback, $env); @@ -261,7 +263,7 @@ class Process implements \IteratorAggregate * * @final */ - public function mustRun(callable $callback = null, array $env = []): static + public function mustRun(?callable $callback = null, array $env = []): static { if (0 !== $this->run($callback, $env)) { throw new ProcessFailedException($this); @@ -285,13 +287,11 @@ class Process implements \IteratorAggregate * @param callable|null $callback A PHP callback to run whenever there is some * output available on STDOUT or STDERR * - * @return void - * - * @throws RuntimeException When process can't be launched - * @throws RuntimeException When process is already running - * @throws LogicException In case a callback is provided and output has been disabled + * @throws ProcessStartFailedException When process can't be launched + * @throws RuntimeException When process is already running + * @throws LogicException In case a callback is provided and output has been disabled */ - public function start(callable $callback = null, array $env = []) + public function start(?callable $callback = null, array $env = []): void { if ($this->isRunning()) { throw new RuntimeException('Process is already running.'); @@ -300,8 +300,7 @@ class Process implements \IteratorAggregate $this->resetProcessData(); $this->starttime = $this->lastOutputTime = microtime(true); $this->callback = $this->buildCallback($callback); - $this->hasCallback = null !== $callback; - $descriptors = $this->getDescriptors(); + $descriptors = $this->getDescriptors(null !== $callback); if ($this->env) { $env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->env, $env, 'strcasecmp') : $this->env; @@ -310,29 +309,25 @@ class Process implements \IteratorAggregate $env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->getDefaultEnv(), $env, 'strcasecmp') : $this->getDefaultEnv(); if (\is_array($commandline = $this->commandline)) { - $commandline = implode(' ', array_map($this->escapeArgument(...), $commandline)); - - if ('\\' !== \DIRECTORY_SEPARATOR) { - // exec is mandatory to deal with sending a signal to the process - $commandline = 'exec '.$commandline; - } + $commandline = array_values(array_map(strval(...), $commandline)); } else { $commandline = $this->replacePlaceholders($commandline, $env); } if ('\\' === \DIRECTORY_SEPARATOR) { $commandline = $this->prepareWindowsCommandLine($commandline, $env); - } elseif (!$this->useFileHandles && $this->isSigchildEnabled()) { + } elseif ($this->isSigchildEnabled()) { // last exit code is output on the fourth pipe and caught to work around --enable-sigchild $descriptors[3] = ['pipe', 'w']; + if (\is_array($commandline)) { + // exec is mandatory to deal with sending a signal to the process + $commandline = 'exec '.$this->buildShellCommandline($commandline); + } + // See https://unix.stackexchange.com/questions/71205/background-process-pipe-input $commandline = '{ ('.$commandline.') <&3 3<&- 3>/dev/null & } 3<&0;'; $commandline .= 'pid=$!; echo $pid >&3; wait $pid 2>/dev/null; code=$?; echo $code >&3; exit $code'; - - // Workaround for the bug, when PTS functionality is enabled. - // @see : https://bugs.php.net/69442 - $ptsWorkaround = fopen(__FILE__, 'r'); } $envPairs = []; @@ -346,11 +341,41 @@ class Process implements \IteratorAggregate throw new RuntimeException(sprintf('The provided cwd "%s" does not exist.', $this->cwd)); } - $this->process = @proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options); + $lastError = null; + set_error_handler(function ($type, $msg) use (&$lastError) { + $lastError = $msg; - if (!\is_resource($this->process)) { - throw new RuntimeException('Unable to launch a new process.'); + return true; + }); + + $oldMask = []; + + if ($this->ignoredSignals && \function_exists('pcntl_sigprocmask')) { + // we block signals we want to ignore, as proc_open will use fork / posix_spawn which will copy the signal mask this allow to block + // signals in the child process + pcntl_sigprocmask(\SIG_BLOCK, $this->ignoredSignals, $oldMask); } + + try { + $process = @proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options); + + // Ensure array vs string commands behave the same + if (!$process && \is_array($commandline)) { + $process = @proc_open('exec '.$this->buildShellCommandline($commandline), $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options); + } + } finally { + if ($this->ignoredSignals && \function_exists('pcntl_sigprocmask')) { + // we restore the signal mask here to avoid any side effects + pcntl_sigprocmask(\SIG_SETMASK, $oldMask); + } + + restore_error_handler(); + } + + if (!$process) { + throw new ProcessStartFailedException($this, $lastError); + } + $this->process = $process; $this->status = self::STATUS_STARTED; if (isset($descriptors[3])) { @@ -373,14 +398,14 @@ class Process implements \IteratorAggregate * @param callable|null $callback A PHP callback to run whenever there is some * output available on STDOUT or STDERR * - * @throws RuntimeException When process can't be launched - * @throws RuntimeException When process is already running + * @throws ProcessStartFailedException When process can't be launched + * @throws RuntimeException When process is already running * * @see start() * * @final */ - public function restart(callable $callback = null, array $env = []): static + public function restart(?callable $callback = null, array $env = []): static { if ($this->isRunning()) { throw new RuntimeException('Process is already running.'); @@ -407,7 +432,7 @@ class Process implements \IteratorAggregate * @throws ProcessSignaledException When process stopped after receiving signal * @throws LogicException When process is not yet started */ - public function wait(callable $callback = null): int + public function wait(?callable $callback = null): int { $this->requireProcessIsStarted(__FUNCTION__); @@ -880,7 +905,7 @@ class Process implements \IteratorAggregate * * @return int|null The exit-code of the process or null if it's not running */ - public function stop(float $timeout = 10, int $signal = null): ?int + public function stop(float $timeout = 10, ?int $signal = null): ?int { $timeoutMicro = microtime(true) + $timeout; if ($this->isRunning()) { @@ -950,7 +975,7 @@ class Process implements \IteratorAggregate */ public function getCommandLine(): string { - return \is_array($this->commandline) ? implode(' ', array_map($this->escapeArgument(...), $this->commandline)) : $this->commandline; + return $this->buildShellCommandline($this->commandline); } /** @@ -1119,7 +1144,7 @@ class Process implements \IteratorAggregate * * This content will be passed to the underlying process standard input. * - * @param string|int|float|bool|resource|\Traversable|null $input The content + * @param string|resource|\Traversable|self|null $input The content * * @return $this * @@ -1142,11 +1167,9 @@ class Process implements \IteratorAggregate * In case you run a background process (with the start method), you should * trigger this method regularly to ensure the process timeout * - * @return void - * * @throws ProcessTimedOutException In case the timeout was reached */ - public function checkTimeout() + public function checkTimeout(): void { if (self::STATUS_STARTED !== $this->status) { return; @@ -1184,10 +1207,8 @@ class Process implements \IteratorAggregate * * Enabling the "create_new_console" option allows a subprocess to continue * to run after the main process exited, on both Windows and *nix - * - * @return void */ - public function setOptions(array $options) + public function setOptions(array $options): void { if ($this->isRunning()) { throw new RuntimeException('Setting options while the process is running is not possible.'); @@ -1205,6 +1226,20 @@ class Process implements \IteratorAggregate } } + /** + * Defines a list of posix signals that will not be propagated to the process. + * + * @param list<\SIG*> $signals + */ + public function setIgnoredSignals(array $signals): void + { + if ($this->isRunning()) { + throw new RuntimeException('Setting ignored signals while the process is running is not possible.'); + } + + $this->ignoredSignals = $signals; + } + /** * Returns whether TTY is supported on the current operating system. */ @@ -1212,7 +1247,7 @@ class Process implements \IteratorAggregate { static $isTtySupported; - return $isTtySupported ??= ('/' === \DIRECTORY_SEPARATOR && stream_isatty(\STDOUT)); + return $isTtySupported ??= ('/' === \DIRECTORY_SEPARATOR && stream_isatty(\STDOUT) && @is_writable('/dev/tty')); } /** @@ -1236,15 +1271,15 @@ class Process implements \IteratorAggregate /** * Creates the descriptors needed by the proc_open. */ - private function getDescriptors(): array + private function getDescriptors(bool $hasCallback): array { if ($this->input instanceof \Iterator) { $this->input->rewind(); } if ('\\' === \DIRECTORY_SEPARATOR) { - $this->processPipes = new WindowsPipes($this->input, !$this->outputDisabled || $this->hasCallback); + $this->processPipes = new WindowsPipes($this->input, !$this->outputDisabled || $hasCallback); } else { - $this->processPipes = new UnixPipes($this->isTty(), $this->isPty(), $this->input, !$this->outputDisabled || $this->hasCallback); + $this->processPipes = new UnixPipes($this->isTty(), $this->isPty(), $this->input, !$this->outputDisabled || $hasCallback); } return $this->processPipes->getDescriptors(); @@ -1258,7 +1293,7 @@ class Process implements \IteratorAggregate * * @param callable|null $callback The user defined PHP callback */ - protected function buildCallback(callable $callback = null): \Closure + protected function buildCallback(?callable $callback = null): \Closure { if ($this->outputDisabled) { return fn ($type, $data): bool => null !== $callback && $callback($type, $data); @@ -1281,10 +1316,8 @@ class Process implements \IteratorAggregate * Updates the status of the process, reads pipes. * * @param bool $blocking Whether to use a blocking read call - * - * @return void */ - protected function updateStatus(bool $blocking) + protected function updateStatus(bool $blocking): void { if (self::STATUS_STARTED !== $this->status) { return; @@ -1293,6 +1326,19 @@ class Process implements \IteratorAggregate $this->processInformation = proc_get_status($this->process); $running = $this->processInformation['running']; + // In PHP < 8.3, "proc_get_status" only returns the correct exit status on the first call. + // Subsequent calls return -1 as the process is discarded. This workaround caches the first + // retrieved exit status for consistent results in later calls, mimicking PHP 8.3 behavior. + if (\PHP_VERSION_ID < 80300) { + if (!isset($this->cachedExitCode) && !$running && -1 !== $this->processInformation['exitcode']) { + $this->cachedExitCode = $this->processInformation['exitcode']; + } + + if (isset($this->cachedExitCode) && !$running && -1 === $this->processInformation['exitcode']) { + $this->processInformation['exitcode'] = $this->cachedExitCode; + } + } + $this->readPipes($running && $blocking, '\\' !== \DIRECTORY_SEPARATOR || !$running); if ($this->fallbackStatus && $this->isSigchildEnabled()) { @@ -1388,8 +1434,9 @@ class Process implements \IteratorAggregate private function close(): int { $this->processPipes->close(); - if (\is_resource($this->process)) { + if ($this->process) { proc_close($this->process); + $this->process = null; } $this->exitcode = $this->processInformation['exitcode']; $this->status = self::STATUS_TERMINATED; @@ -1421,7 +1468,7 @@ class Process implements \IteratorAggregate $this->callback = null; $this->exitcode = null; $this->fallbackStatus = []; - $this->processInformation = null; + $this->processInformation = []; $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+'); $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+'); $this->process = null; @@ -1443,6 +1490,11 @@ class Process implements \IteratorAggregate */ private function doSignal(int $signal, bool $throwException): bool { + // Signal seems to be send when sigchild is enable, this allow blocking the signal correctly in this case + if ($this->isSigchildEnabled() && \in_array($signal, $this->ignoredSignals)) { + return false; + } + if (null === $pid = $this->getPid()) { if ($throwException) { throw new LogicException('Cannot send signal on a non running process.'); @@ -1485,8 +1537,18 @@ class Process implements \IteratorAggregate return true; } - private function prepareWindowsCommandLine(string $cmd, array &$env): string + private function buildShellCommandline(string|array $commandline): string { + if (\is_string($commandline)) { + return $commandline; + } + + return implode(' ', array_map($this->escapeArgument(...), $commandline)); + } + + private function prepareWindowsCommandLine(string|array $cmd, array &$env): string + { + $cmd = $this->buildShellCommandline($cmd); $uid = uniqid('', true); $cmd = preg_replace_callback( '/"(?:( diff --git a/src/ncc/ThirdParty/Symfony/Process/ProcessUtils.php b/src/ncc/ThirdParty/Symfony/Process/ProcessUtils.php index fae0b5f..056539f 100644 --- a/src/ncc/ThirdParty/Symfony/Process/ProcessUtils.php +++ b/src/ncc/ThirdParty/Symfony/Process/ProcessUtils.php @@ -43,9 +43,6 @@ class ProcessUtils if (\is_resource($input)) { return $input; } - if (\is_string($input)) { - return $input; - } if (\is_scalar($input)) { return (string) $input; } diff --git a/src/ncc/ThirdParty/Symfony/Process/VERSION b/src/ncc/ThirdParty/Symfony/Process/VERSION index 9152abb..ad955e9 100644 --- a/src/ncc/ThirdParty/Symfony/Process/VERSION +++ b/src/ncc/ThirdParty/Symfony/Process/VERSION @@ -1 +1 @@ -6.3.4 \ No newline at end of file +7.1.3 \ No newline at end of file From 9831b9dca170998458beecc1e18a79e3850d2a4e Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 15:19:41 -0400 Subject: [PATCH 103/134] Updated Symfony/polyfill-ctype to version 1.31.0 --- CHANGELOG.md | 1 + src/ncc/ThirdParty/Symfony/polyfill_ctype/Ctype.php | 2 +- src/ncc/ThirdParty/Symfony/polyfill_ctype/VERSION | 2 +- src/ncc/ThirdParty/Symfony/polyfill_ctype/bootstrap.php | 2 +- src/ncc/ThirdParty/Symfony/polyfill_ctype/bootstrap80.php | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a484867..c4c1458 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,6 +70,7 @@ This update introduces a refactored code-base, code quality improvements, and be - Updated Symfony/Yaml to version 7.1.4 - Updated Symfony/Uid to version 7.1.4 - Updated Symfony/Process to version 7.1.3 + - Updated Symfony/polyfill-ctype to version 1.31.0 ### Fixed - Fixed Division by zero in PackageManager diff --git a/src/ncc/ThirdParty/Symfony/polyfill_ctype/Ctype.php b/src/ncc/ThirdParty/Symfony/polyfill_ctype/Ctype.php index 9963f55..ba75a2c 100644 --- a/src/ncc/ThirdParty/Symfony/polyfill_ctype/Ctype.php +++ b/src/ncc/ThirdParty/Symfony/polyfill_ctype/Ctype.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace ncc\ThirdParty\Symfony\polyfill_ctype; +namespace Symfony\Polyfill\Ctype; /** * Ctype implementation through regex. diff --git a/src/ncc/ThirdParty/Symfony/polyfill_ctype/VERSION b/src/ncc/ThirdParty/Symfony/polyfill_ctype/VERSION index 3c71e47..8b96872 100644 --- a/src/ncc/ThirdParty/Symfony/polyfill_ctype/VERSION +++ b/src/ncc/ThirdParty/Symfony/polyfill_ctype/VERSION @@ -1 +1 @@ -1.28.0 \ No newline at end of file +1.31.0 \ No newline at end of file diff --git a/src/ncc/ThirdParty/Symfony/polyfill_ctype/bootstrap.php b/src/ncc/ThirdParty/Symfony/polyfill_ctype/bootstrap.php index 06e1b95..d54524b 100644 --- a/src/ncc/ThirdParty/Symfony/polyfill_ctype/bootstrap.php +++ b/src/ncc/ThirdParty/Symfony/polyfill_ctype/bootstrap.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -use ncc\ThirdParty\Symfony\polyfill_ctype as p; +use Symfony\Polyfill\Ctype as p; if (\PHP_VERSION_ID >= 80000) { return require __DIR__.'/bootstrap80.php'; diff --git a/src/ncc/ThirdParty/Symfony/polyfill_ctype/bootstrap80.php b/src/ncc/ThirdParty/Symfony/polyfill_ctype/bootstrap80.php index ec1ed5f..ab2f861 100644 --- a/src/ncc/ThirdParty/Symfony/polyfill_ctype/bootstrap80.php +++ b/src/ncc/ThirdParty/Symfony/polyfill_ctype/bootstrap80.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -use ncc\ThirdParty\Symfony\polyfill_ctype as p; +use Symfony\Polyfill\Ctype as p; if (!function_exists('ctype_alnum')) { function ctype_alnum(mixed $text): bool { return p\Ctype::ctype_alnum($text); } From cdd351676602fc56fbaff3161760535580e58004 Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 15:21:32 -0400 Subject: [PATCH 104/134] Corrected ctype --- src/ncc/ThirdParty/Symfony/polyfill_ctype/Ctype.php | 2 +- src/ncc/ThirdParty/Symfony/polyfill_ctype/bootstrap.php | 2 +- src/ncc/ThirdParty/Symfony/polyfill_ctype/bootstrap80.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ncc/ThirdParty/Symfony/polyfill_ctype/Ctype.php b/src/ncc/ThirdParty/Symfony/polyfill_ctype/Ctype.php index ba75a2c..9963f55 100644 --- a/src/ncc/ThirdParty/Symfony/polyfill_ctype/Ctype.php +++ b/src/ncc/ThirdParty/Symfony/polyfill_ctype/Ctype.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Polyfill\Ctype; +namespace ncc\ThirdParty\Symfony\polyfill_ctype; /** * Ctype implementation through regex. diff --git a/src/ncc/ThirdParty/Symfony/polyfill_ctype/bootstrap.php b/src/ncc/ThirdParty/Symfony/polyfill_ctype/bootstrap.php index d54524b..06e1b95 100644 --- a/src/ncc/ThirdParty/Symfony/polyfill_ctype/bootstrap.php +++ b/src/ncc/ThirdParty/Symfony/polyfill_ctype/bootstrap.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -use Symfony\Polyfill\Ctype as p; +use ncc\ThirdParty\Symfony\polyfill_ctype as p; if (\PHP_VERSION_ID >= 80000) { return require __DIR__.'/bootstrap80.php'; diff --git a/src/ncc/ThirdParty/Symfony/polyfill_ctype/bootstrap80.php b/src/ncc/ThirdParty/Symfony/polyfill_ctype/bootstrap80.php index ab2f861..ec1ed5f 100644 --- a/src/ncc/ThirdParty/Symfony/polyfill_ctype/bootstrap80.php +++ b/src/ncc/ThirdParty/Symfony/polyfill_ctype/bootstrap80.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -use Symfony\Polyfill\Ctype as p; +use ncc\ThirdParty\Symfony\polyfill_ctype as p; if (!function_exists('ctype_alnum')) { function ctype_alnum(mixed $text): bool { return p\Ctype::ctype_alnum($text); } From e556282f61f4072b75920fe676af6d148500beba Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 15:23:08 -0400 Subject: [PATCH 105/134] Updated Symfony/polyfill-mbstring to version 1.31.0 --- CHANGELOG.md | 1 + .../Symfony/polyfill_mbstring/Mbstring.php | 136 +++++++++++++++--- .../Symfony/polyfill_mbstring/VERSION | 2 +- .../Symfony/polyfill_mbstring/bootstrap.php | 21 +++ .../Symfony/polyfill_mbstring/bootstrap80.php | 22 ++- 5 files changed, 161 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4c1458..b56869d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,7 @@ This update introduces a refactored code-base, code quality improvements, and be - Updated Symfony/Uid to version 7.1.4 - Updated Symfony/Process to version 7.1.3 - Updated Symfony/polyfill-ctype to version 1.31.0 + - Updated Symfony/polyfill-mbstring to version 1.31.0 ### Fixed - Fixed Division by zero in PackageManager diff --git a/src/ncc/ThirdParty/Symfony/polyfill_mbstring/Mbstring.php b/src/ncc/ThirdParty/Symfony/polyfill_mbstring/Mbstring.php index 481ca56..3f880a8 100644 --- a/src/ncc/ThirdParty/Symfony/polyfill_mbstring/Mbstring.php +++ b/src/ncc/ThirdParty/Symfony/polyfill_mbstring/Mbstring.php @@ -48,6 +48,11 @@ namespace ncc\ThirdParty\Symfony\polyfill_mbstring; * - mb_strstr - Finds first occurrence of a string within another * - mb_strwidth - Return width of string * - mb_substr_count - Count the number of substring occurrences + * - mb_ucfirst - Make a string's first character uppercase + * - mb_lcfirst - Make a string's first character lowercase + * - mb_trim - Strip whitespace (or other characters) from the beginning and end of a string + * - mb_ltrim - Strip whitespace (or other characters) from the beginning of a string + * - mb_rtrim - Strip whitespace (or other characters) from the end of a string * * Not implemented: * - mb_convert_kana - Convert "kana" one from another ("zen-kaku", "han-kaku" and more) @@ -80,6 +85,15 @@ final class Mbstring public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null) { + if (\is_array($s)) { + $r = []; + foreach ($s as $str) { + $r[] = self::mb_convert_encoding($str, $toEncoding, $fromEncoding); + } + + return $r; + } + if (\is_array($fromEncoding) || (null !== $fromEncoding && false !== strpos($fromEncoding, ','))) { $fromEncoding = self::mb_detect_encoding($s, $fromEncoding); } else { @@ -410,12 +424,6 @@ final class Mbstring public static function mb_check_encoding($var = null, $encoding = null) { - if (PHP_VERSION_ID < 70200 && \is_array($var)) { - trigger_error('mb_check_encoding() expects parameter 1 to be string, array given', \E_USER_WARNING); - - return null; - } - if (null === $encoding) { if (null === $var) { return false; @@ -437,7 +445,6 @@ final class Mbstring } return true; - } public static function mb_detect_encoding($str, $encodingList = null, $strict = false) @@ -827,7 +834,7 @@ final class Mbstring return $code; } - public static function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = \STR_PAD_RIGHT, string $encoding = null): string + public static function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = \STR_PAD_RIGHT, ?string $encoding = null): string { if (!\in_array($pad_type, [\STR_PAD_RIGHT, \STR_PAD_LEFT, \STR_PAD_BOTH], true)) { throw new \ValueError('mb_str_pad(): Argument #4 ($pad_type) must be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH'); @@ -835,17 +842,8 @@ final class Mbstring if (null === $encoding) { $encoding = self::mb_internal_encoding(); - } - - try { - $validEncoding = @self::mb_check_encoding('', $encoding); - } catch (\ValueError $e) { - throw new \ValueError(sprintf('mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given', $encoding)); - } - - // BC for PHP 7.3 and lower - if (!$validEncoding) { - throw new \ValueError(sprintf('mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given', $encoding)); + } else { + self::assertEncoding($encoding, 'mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given'); } if (self::mb_strlen($pad_string, $encoding) <= 0) { @@ -871,6 +869,34 @@ final class Mbstring } } + public static function mb_ucfirst(string $string, ?string $encoding = null): string + { + if (null === $encoding) { + $encoding = self::mb_internal_encoding(); + } else { + self::assertEncoding($encoding, 'mb_ucfirst(): Argument #2 ($encoding) must be a valid encoding, "%s" given'); + } + + $firstChar = mb_substr($string, 0, 1, $encoding); + $firstChar = mb_convert_case($firstChar, \MB_CASE_TITLE, $encoding); + + return $firstChar.mb_substr($string, 1, null, $encoding); + } + + public static function mb_lcfirst(string $string, ?string $encoding = null): string + { + if (null === $encoding) { + $encoding = self::mb_internal_encoding(); + } else { + self::assertEncoding($encoding, 'mb_lcfirst(): Argument #2 ($encoding) must be a valid encoding, "%s" given'); + } + + $firstChar = mb_substr($string, 0, 1, $encoding); + $firstChar = mb_convert_case($firstChar, \MB_CASE_LOWER, $encoding); + + return $firstChar.mb_substr($string, 1, null, $encoding); + } + private static function getSubpart($pos, $part, $haystack, $encoding) { if (false === $pos) { @@ -944,4 +970,76 @@ final class Mbstring return $encoding; } + + public static function mb_trim(string $string, ?string $characters = null, ?string $encoding = null): string + { + return self::mb_internal_trim('{^[%s]+|[%1$s]+$}Du', $string, $characters, $encoding, __FUNCTION__); + } + + public static function mb_ltrim(string $string, ?string $characters = null, ?string $encoding = null): string + { + return self::mb_internal_trim('{^[%s]+}Du', $string, $characters, $encoding, __FUNCTION__); + } + + public static function mb_rtrim(string $string, ?string $characters = null, ?string $encoding = null): string + { + return self::mb_internal_trim('{[%s]+$}D', $string, $characters, $encoding, __FUNCTION__); + } + + private static function mb_internal_trim(string $regex, string $string, ?string $characters, ?string $encoding, string $function): string + { + if (null === $encoding) { + $encoding = self::mb_internal_encoding(); + } else { + self::assertEncoding($encoding, $function.'(): Argument #3 ($encoding) must be a valid encoding, "%s" given'); + } + + if ('' === $characters) { + return null === $encoding ? $string : self::mb_convert_encoding($string, $encoding); + } + + if ('UTF-8' === $encoding) { + $encoding = null; + if (!preg_match('//u', $string)) { + $string = @iconv('UTF-8', 'UTF-8//IGNORE', $string); + } + if (null !== $characters && !preg_match('//u', $characters)) { + $characters = @iconv('UTF-8', 'UTF-8//IGNORE', $characters); + } + } else { + $string = iconv($encoding, 'UTF-8//IGNORE', $string); + + if (null !== $characters) { + $characters = iconv($encoding, 'UTF-8//IGNORE', $characters); + } + } + + if (null === $characters) { + $characters = "\\0 \f\n\r\t\v\u{00A0}\u{1680}\u{2000}\u{2001}\u{2002}\u{2003}\u{2004}\u{2005}\u{2006}\u{2007}\u{2008}\u{2009}\u{200A}\u{2028}\u{2029}\u{202F}\u{205F}\u{3000}\u{0085}\u{180E}"; + } else { + $characters = preg_quote($characters); + } + + $string = preg_replace(sprintf($regex, $characters), '', $string); + + if (null === $encoding) { + return $string; + } + + return iconv('UTF-8', $encoding.'//IGNORE', $string); + } + + private static function assertEncoding(string $encoding, string $errorFormat): void + { + try { + $validEncoding = @self::mb_check_encoding('', $encoding); + } catch (\ValueError $e) { + throw new \ValueError(sprintf($errorFormat, $encoding)); + } + + // BC for PHP 7.3 and lower + if (!$validEncoding) { + throw new \ValueError(sprintf($errorFormat, $encoding)); + } + } } diff --git a/src/ncc/ThirdParty/Symfony/polyfill_mbstring/VERSION b/src/ncc/ThirdParty/Symfony/polyfill_mbstring/VERSION index 3c71e47..8b96872 100644 --- a/src/ncc/ThirdParty/Symfony/polyfill_mbstring/VERSION +++ b/src/ncc/ThirdParty/Symfony/polyfill_mbstring/VERSION @@ -1 +1 @@ -1.28.0 \ No newline at end of file +1.31.0 \ No newline at end of file diff --git a/src/ncc/ThirdParty/Symfony/polyfill_mbstring/bootstrap.php b/src/ncc/ThirdParty/Symfony/polyfill_mbstring/bootstrap.php index c6da82a..b79dcd1 100644 --- a/src/ncc/ThirdParty/Symfony/polyfill_mbstring/bootstrap.php +++ b/src/ncc/ThirdParty/Symfony/polyfill_mbstring/bootstrap.php @@ -136,6 +136,27 @@ if (!function_exists('mb_str_pad')) { function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = STR_PAD_RIGHT, ?string $encoding = null): string { return p\Mbstring::mb_str_pad($string, $length, $pad_string, $pad_type, $encoding); } } +if (!function_exists('mb_ucfirst')) { + function mb_ucfirst(string $string, ?string $encoding = null): string { return p\Mbstring::mb_ucfirst($string, $encoding); } +} + +if (!function_exists('mb_lcfirst')) { + function mb_lcfirst(string $string, ?string $encoding = null): string { return p\Mbstring::mb_lcfirst($string, $encoding); } +} + +if (!function_exists('mb_trim')) { + function mb_trim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_trim($string, $characters, $encoding); } +} + +if (!function_exists('mb_ltrim')) { + function mb_ltrim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_ltrim($string, $characters, $encoding); } +} + +if (!function_exists('mb_rtrim')) { + function mb_rtrim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_rtrim($string, $characters, $encoding); } +} + + if (extension_loaded('mbstring')) { return; } diff --git a/src/ncc/ThirdParty/Symfony/polyfill_mbstring/bootstrap80.php b/src/ncc/ThirdParty/Symfony/polyfill_mbstring/bootstrap80.php index f6a3f2b..96b3ec9 100644 --- a/src/ncc/ThirdParty/Symfony/polyfill_mbstring/bootstrap80.php +++ b/src/ncc/ThirdParty/Symfony/polyfill_mbstring/bootstrap80.php @@ -93,7 +93,7 @@ if (!function_exists('mb_strstr')) { function mb_strstr(?string $haystack, ?string $needle, ?bool $before_needle = false, ?string $encoding = null): string|false { return p\Mbstring::mb_strstr((string) $haystack, (string) $needle, (bool) $before_needle, $encoding); } } if (!function_exists('mb_get_info')) { - function mb_get_info(?string $type = 'all'): array|string|int|false { return p\Mbstring::mb_get_info((string) $type); } + function mb_get_info(?string $type = 'all'): array|string|int|false|null { return p\Mbstring::mb_get_info((string) $type); } } if (!function_exists('mb_http_output')) { function mb_http_output(?string $encoding = null): string|bool { return p\Mbstring::mb_http_output($encoding); } @@ -132,6 +132,26 @@ if (!function_exists('mb_str_pad')) { function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = STR_PAD_RIGHT, ?string $encoding = null): string { return p\Mbstring::mb_str_pad($string, $length, $pad_string, $pad_type, $encoding); } } +if (!function_exists('mb_ucfirst')) { + function mb_ucfirst(string $string, ?string $encoding = null): string { return p\Mbstring::mb_ucfirst($string, $encoding); } +} + +if (!function_exists('mb_lcfirst')) { + function mb_lcfirst(string $string, ?string $encoding = null): string { return p\Mbstring::mb_lcfirst($string, $encoding); } +} + +if (!function_exists('mb_trim')) { + function mb_trim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_trim($string, $characters, $encoding); } +} + +if (!function_exists('mb_ltrim')) { + function mb_ltrim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_ltrim($string, $characters, $encoding); } +} + +if (!function_exists('mb_rtrim')) { + function mb_rtrim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_rtrim($string, $characters, $encoding); } +} + if (extension_loaded('mbstring')) { return; } From a1404490bb3dd06dc4f96beea00052fd570ef5a1 Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 15:24:32 -0400 Subject: [PATCH 106/134] Updated Symfony/polyfill-uuid to version 1.31.0 --- CHANGELOG.md | 1 + src/ncc/ThirdParty/Symfony/polyfill_uuid/VERSION | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b56869d..32e2f9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,7 @@ This update introduces a refactored code-base, code quality improvements, and be - Updated Symfony/Process to version 7.1.3 - Updated Symfony/polyfill-ctype to version 1.31.0 - Updated Symfony/polyfill-mbstring to version 1.31.0 + - Updated Symfony/polyfill-uuid to version 1.31.0 ### Fixed - Fixed Division by zero in PackageManager diff --git a/src/ncc/ThirdParty/Symfony/polyfill_uuid/VERSION b/src/ncc/ThirdParty/Symfony/polyfill_uuid/VERSION index 3c71e47..8b96872 100644 --- a/src/ncc/ThirdParty/Symfony/polyfill_uuid/VERSION +++ b/src/ncc/ThirdParty/Symfony/polyfill_uuid/VERSION @@ -1 +1 @@ -1.28.0 \ No newline at end of file +1.31.0 \ No newline at end of file From 923117999ba2f44608327683727277730f869a34 Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 19 Sep 2024 15:44:14 -0400 Subject: [PATCH 107/134] Updated nikic/PhpParser to version 5.2.0 --- CHANGELOG.md | 1 + .../ThirdParty/nikic/PhpParser/Builder.php | 5 +- .../nikic/PhpParser/Builder/ClassConst.php | 44 +- .../nikic/PhpParser/Builder/Class_.php | 71 +- .../nikic/PhpParser/Builder/Declaration.php | 15 +- .../nikic/PhpParser/Builder/EnumCase.php | 21 +- .../nikic/PhpParser/Builder/Enum_.php | 61 +- .../nikic/PhpParser/Builder/FunctionLike.php | 14 +- .../nikic/PhpParser/Builder/Function_.php | 18 +- .../nikic/PhpParser/Builder/Interface_.php | 27 +- .../nikic/PhpParser/Builder/Method.php | 35 +- .../nikic/PhpParser/Builder/Namespace_.php | 14 +- .../nikic/PhpParser/Builder/Param.php | 75 +- .../nikic/PhpParser/Builder/Property.php | 112 +- .../nikic/PhpParser/Builder/TraitUse.php | 11 +- .../PhpParser/Builder/TraitUseAdaptation.php | 57 +- .../nikic/PhpParser/Builder/Trait_.php | 31 +- .../nikic/PhpParser/Builder/Use_.php | 16 +- .../nikic/PhpParser/BuilderFactory.php | 192 +- .../nikic/PhpParser/BuilderHelpers.php | 55 +- .../ThirdParty/nikic/PhpParser/CHANGELOG.md | 1219 +++++ .../ThirdParty/nikic/PhpParser/Comment.php | 104 +- .../nikic/PhpParser/Comment/Doc.php | 3 +- .../ConstExprEvaluationException.php | 6 +- .../nikic/PhpParser/ConstExprEvaluator.php | 25 +- src/ncc/ThirdParty/nikic/PhpParser/Error.php | 59 +- .../nikic/PhpParser/ErrorHandler.php | 5 +- .../PhpParser/ErrorHandler/Collecting.php | 15 +- .../nikic/PhpParser/ErrorHandler/Throwing.php | 5 +- .../nikic/PhpParser/Internal/DiffElem.php | 18 +- .../nikic/PhpParser/Internal/Differ.php | 58 +- .../Internal/PrintableNewAnonClassNode.php | 33 +- .../PhpParser/Internal/TokenPolyfill.php | 237 + .../nikic/PhpParser/Internal/TokenStream.php | 133 +- .../nikic/PhpParser/JsonDecoder.php | 25 +- src/ncc/ThirdParty/nikic/PhpParser/Lexer.php | 590 +-- .../nikic/PhpParser/Lexer/Emulative.php | 169 +- .../AsymmetricVisibilityTokenEmulator.php | 93 + .../Lexer/TokenEmulator/AttributeEmulator.php | 29 +- .../CoaleseEqualTokenEmulator.php | 47 - .../Lexer/TokenEmulator/EnumTokenEmulator.php | 25 +- .../TokenEmulator/ExplicitOctalEmulator.php | 23 +- .../FlexibleDocStringEmulator.php | 76 - .../Lexer/TokenEmulator/FnTokenEmulator.php | 23 - .../Lexer/TokenEmulator/KeywordEmulator.php | 50 +- .../TokenEmulator/MatchTokenEmulator.php | 16 +- .../TokenEmulator/NullsafeTokenEmulator.php | 51 +- .../NumericLiteralSeparatorEmulator.php | 105 - .../TokenEmulator/PropertyTokenEmulator.php | 19 + .../ReadonlyFunctionTokenEmulator.php | 6 +- .../TokenEmulator/ReadonlyTokenEmulator.php | 25 +- .../Lexer/TokenEmulator/ReverseEmulator.php | 11 +- .../Lexer/TokenEmulator/TokenEmulator.php | 15 +- .../ThirdParty/nikic/PhpParser/Modifiers.php | 85 + .../nikic/PhpParser/NameContext.php | 49 +- src/ncc/ThirdParty/nikic/PhpParser/Node.php | 57 +- .../ThirdParty/nikic/PhpParser/Node/Arg.php | 28 +- .../nikic/PhpParser/Node/ArrayItem.php | 43 + .../nikic/PhpParser/Node/Attribute.php | 19 +- .../nikic/PhpParser/Node/AttributeGroup.php | 12 +- .../nikic/PhpParser/Node/ClosureUse.php | 36 + .../nikic/PhpParser/Node/ComplexType.php | 3 +- .../nikic/PhpParser/Node/Const_.php | 19 +- .../nikic/PhpParser/Node/DeclareItem.php | 37 + .../ThirdParty/nikic/PhpParser/Node/Expr.php | 3 +- .../PhpParser/Node/Expr/ArrayDimFetch.php | 21 +- .../nikic/PhpParser/Node/Expr/ArrayItem.php | 40 +- .../nikic/PhpParser/Node/Expr/Array_.php | 22 +- .../PhpParser/Node/Expr/ArrowFunction.php | 61 +- .../nikic/PhpParser/Node/Expr/Assign.php | 19 +- .../nikic/PhpParser/Node/Expr/AssignOp.php | 15 +- .../Node/Expr/AssignOp/BitwiseAnd.php | 5 +- .../Node/Expr/AssignOp/BitwiseOr.php | 5 +- .../Node/Expr/AssignOp/BitwiseXor.php | 5 +- .../PhpParser/Node/Expr/AssignOp/Coalesce.php | 5 +- .../PhpParser/Node/Expr/AssignOp/Concat.php | 5 +- .../PhpParser/Node/Expr/AssignOp/Div.php | 5 +- .../PhpParser/Node/Expr/AssignOp/Minus.php | 5 +- .../PhpParser/Node/Expr/AssignOp/Mod.php | 5 +- .../PhpParser/Node/Expr/AssignOp/Mul.php | 5 +- .../PhpParser/Node/Expr/AssignOp/Plus.php | 5 +- .../PhpParser/Node/Expr/AssignOp/Pow.php | 5 +- .../Node/Expr/AssignOp/ShiftLeft.php | 5 +- .../Node/Expr/AssignOp/ShiftRight.php | 5 +- .../nikic/PhpParser/Node/Expr/AssignRef.php | 19 +- .../nikic/PhpParser/Node/Expr/BinaryOp.php | 19 +- .../Node/Expr/BinaryOp/BitwiseAnd.php | 9 +- .../Node/Expr/BinaryOp/BitwiseOr.php | 9 +- .../Node/Expr/BinaryOp/BitwiseXor.php | 9 +- .../Node/Expr/BinaryOp/BooleanAnd.php | 9 +- .../Node/Expr/BinaryOp/BooleanOr.php | 9 +- .../PhpParser/Node/Expr/BinaryOp/Coalesce.php | 9 +- .../PhpParser/Node/Expr/BinaryOp/Concat.php | 9 +- .../PhpParser/Node/Expr/BinaryOp/Div.php | 9 +- .../PhpParser/Node/Expr/BinaryOp/Equal.php | 9 +- .../PhpParser/Node/Expr/BinaryOp/Greater.php | 9 +- .../Node/Expr/BinaryOp/GreaterOrEqual.php | 9 +- .../Node/Expr/BinaryOp/Identical.php | 9 +- .../Node/Expr/BinaryOp/LogicalAnd.php | 9 +- .../Node/Expr/BinaryOp/LogicalOr.php | 9 +- .../Node/Expr/BinaryOp/LogicalXor.php | 9 +- .../PhpParser/Node/Expr/BinaryOp/Minus.php | 9 +- .../PhpParser/Node/Expr/BinaryOp/Mod.php | 9 +- .../PhpParser/Node/Expr/BinaryOp/Mul.php | 9 +- .../PhpParser/Node/Expr/BinaryOp/NotEqual.php | 9 +- .../Node/Expr/BinaryOp/NotIdentical.php | 9 +- .../PhpParser/Node/Expr/BinaryOp/Plus.php | 9 +- .../PhpParser/Node/Expr/BinaryOp/Pow.php | 9 +- .../Node/Expr/BinaryOp/ShiftLeft.php | 9 +- .../Node/Expr/BinaryOp/ShiftRight.php | 9 +- .../PhpParser/Node/Expr/BinaryOp/Smaller.php | 9 +- .../Node/Expr/BinaryOp/SmallerOrEqual.php | 9 +- .../Node/Expr/BinaryOp/Spaceship.php | 9 +- .../nikic/PhpParser/Node/Expr/BitwiseNot.php | 15 +- .../nikic/PhpParser/Node/Expr/BooleanNot.php | 15 +- .../nikic/PhpParser/Node/Expr/CallLike.php | 10 +- .../nikic/PhpParser/Node/Expr/Cast.php | 11 +- .../nikic/PhpParser/Node/Expr/Cast/Array_.php | 5 +- .../nikic/PhpParser/Node/Expr/Cast/Bool_.php | 5 +- .../nikic/PhpParser/Node/Expr/Cast/Double.php | 11 +- .../nikic/PhpParser/Node/Expr/Cast/Int_.php | 5 +- .../PhpParser/Node/Expr/Cast/Object_.php | 5 +- .../PhpParser/Node/Expr/Cast/String_.php | 5 +- .../nikic/PhpParser/Node/Expr/Cast/Unset_.php | 5 +- .../PhpParser/Node/Expr/ClassConstFetch.php | 20 +- .../nikic/PhpParser/Node/Expr/Clone_.php | 15 +- .../nikic/PhpParser/Node/Expr/Closure.php | 59 +- .../nikic/PhpParser/Node/Expr/ClosureUse.php | 33 +- .../nikic/PhpParser/Node/Expr/ConstFetch.php | 15 +- .../nikic/PhpParser/Node/Expr/Empty_.php | 15 +- .../nikic/PhpParser/Node/Expr/Error.php | 11 +- .../PhpParser/Node/Expr/ErrorSuppress.php | 15 +- .../nikic/PhpParser/Node/Expr/Eval_.php | 15 +- .../nikic/PhpParser/Node/Expr/Exit_.php | 21 +- .../nikic/PhpParser/Node/Expr/FuncCall.php | 21 +- .../nikic/PhpParser/Node/Expr/Include_.php | 27 +- .../nikic/PhpParser/Node/Expr/Instanceof_.php | 22 +- .../nikic/PhpParser/Node/Expr/Isset_.php | 15 +- .../nikic/PhpParser/Node/Expr/List_.php | 20 +- .../nikic/PhpParser/Node/Expr/Match_.php | 15 +- .../nikic/PhpParser/Node/Expr/MethodCall.php | 24 +- .../nikic/PhpParser/Node/Expr/New_.php | 21 +- .../Node/Expr/NullsafeMethodCall.php | 24 +- .../Node/Expr/NullsafePropertyFetch.php | 20 +- .../nikic/PhpParser/Node/Expr/PostDec.php | 15 +- .../nikic/PhpParser/Node/Expr/PostInc.php | 15 +- .../nikic/PhpParser/Node/Expr/PreDec.php | 13 +- .../nikic/PhpParser/Node/Expr/PreInc.php | 15 +- .../nikic/PhpParser/Node/Expr/Print_.php | 15 +- .../PhpParser/Node/Expr/PropertyFetch.php | 20 +- .../nikic/PhpParser/Node/Expr/ShellExec.php | 18 +- .../nikic/PhpParser/Node/Expr/StaticCall.php | 25 +- .../Node/Expr/StaticPropertyFetch.php | 22 +- .../nikic/PhpParser/Node/Expr/Ternary.php | 25 +- .../nikic/PhpParser/Node/Expr/Throw_.php | 13 +- .../nikic/PhpParser/Node/Expr/UnaryMinus.php | 15 +- .../nikic/PhpParser/Node/Expr/UnaryPlus.php | 15 +- .../nikic/PhpParser/Node/Expr/Variable.php | 13 +- .../nikic/PhpParser/Node/Expr/YieldFrom.php | 15 +- .../nikic/PhpParser/Node/Expr/Yield_.php | 21 +- .../nikic/PhpParser/Node/FunctionLike.php | 13 +- .../nikic/PhpParser/Node/Identifier.php | 38 +- .../PhpParser/Node/InterpolatedStringPart.php | 32 + .../nikic/PhpParser/Node/IntersectionType.php | 15 +- .../nikic/PhpParser/Node/MatchArm.php | 17 +- .../ThirdParty/nikic/PhpParser/Node/Name.php | 132 +- .../PhpParser/Node/Name/FullyQualified.php | 17 +- .../nikic/PhpParser/Node/Name/Relative.php | 17 +- .../nikic/PhpParser/Node/NullableType.php | 21 +- .../ThirdParty/nikic/PhpParser/Node/Param.php | 98 +- .../nikic/PhpParser/Node/PropertyHook.php | 78 + .../nikic/PhpParser/Node/PropertyItem.php | 37 + .../nikic/PhpParser/Node/Scalar.php | 3 +- .../nikic/PhpParser/Node/Scalar/DNumber.php | 76 +- .../nikic/PhpParser/Node/Scalar/Encapsed.php | 30 +- .../Node/Scalar/EncapsedStringPart.php | 29 +- .../nikic/PhpParser/Node/Scalar/Float_.php | 78 + .../nikic/PhpParser/Node/Scalar/Int_.php | 82 + .../Node/Scalar/InterpolatedString.php | 34 + .../nikic/PhpParser/Node/Scalar/LNumber.php | 79 +- .../PhpParser/Node/Scalar/MagicConst.php | 9 +- .../Node/Scalar/MagicConst/Class_.php | 9 +- .../PhpParser/Node/Scalar/MagicConst/Dir.php | 9 +- .../PhpParser/Node/Scalar/MagicConst/File.php | 9 +- .../Node/Scalar/MagicConst/Function_.php | 9 +- .../PhpParser/Node/Scalar/MagicConst/Line.php | 9 +- .../Node/Scalar/MagicConst/Method.php | 9 +- .../Node/Scalar/MagicConst/Namespace_.php | 9 +- .../Node/Scalar/MagicConst/Property.php | 15 + .../Node/Scalar/MagicConst/Trait_.php | 9 +- .../nikic/PhpParser/Node/Scalar/String_.php | 56 +- .../nikic/PhpParser/Node/StaticVar.php | 39 + .../ThirdParty/nikic/PhpParser/Node/Stmt.php | 3 +- .../nikic/PhpParser/Node/Stmt/Block.php | 29 + .../nikic/PhpParser/Node/Stmt/Break_.php | 17 +- .../nikic/PhpParser/Node/Stmt/Case_.php | 21 +- .../nikic/PhpParser/Node/Stmt/Catch_.php | 23 +- .../nikic/PhpParser/Node/Stmt/ClassConst.php | 56 +- .../nikic/PhpParser/Node/Stmt/ClassLike.php | 26 +- .../nikic/PhpParser/Node/Stmt/ClassMethod.php | 101 +- .../nikic/PhpParser/Node/Stmt/Class_.php | 131 +- .../nikic/PhpParser/Node/Stmt/Const_.php | 15 +- .../nikic/PhpParser/Node/Stmt/Continue_.php | 17 +- .../PhpParser/Node/Stmt/DeclareDeclare.php | 33 +- .../nikic/PhpParser/Node/Stmt/Declare_.php | 24 +- .../nikic/PhpParser/Node/Stmt/Do_.php | 19 +- .../nikic/PhpParser/Node/Stmt/Echo_.php | 15 +- .../nikic/PhpParser/Node/Stmt/ElseIf_.php | 19 +- .../nikic/PhpParser/Node/Stmt/Else_.php | 15 +- .../nikic/PhpParser/Node/Stmt/EnumCase.php | 23 +- .../nikic/PhpParser/Node/Stmt/Enum_.php | 30 +- .../nikic/PhpParser/Node/Stmt/Expression.php | 15 +- .../nikic/PhpParser/Node/Stmt/Finally_.php | 15 +- .../nikic/PhpParser/Node/Stmt/For_.php | 34 +- .../nikic/PhpParser/Node/Stmt/Foreach_.php | 37 +- .../nikic/PhpParser/Node/Stmt/Function_.php | 52 +- .../nikic/PhpParser/Node/Stmt/Global_.php | 15 +- .../nikic/PhpParser/Node/Stmt/Goto_.php | 15 +- .../nikic/PhpParser/Node/Stmt/GroupUse.php | 30 +- .../PhpParser/Node/Stmt/HaltCompiler.php | 15 +- .../nikic/PhpParser/Node/Stmt/If_.php | 33 +- .../nikic/PhpParser/Node/Stmt/InlineHTML.php | 15 +- .../nikic/PhpParser/Node/Stmt/Interface_.php | 23 +- .../nikic/PhpParser/Node/Stmt/Label.php | 15 +- .../nikic/PhpParser/Node/Stmt/Namespace_.php | 23 +- .../nikic/PhpParser/Node/Stmt/Nop.php | 9 +- .../nikic/PhpParser/Node/Stmt/Property.php | 92 +- .../PhpParser/Node/Stmt/PropertyProperty.php | 33 +- .../nikic/PhpParser/Node/Stmt/Return_.php | 17 +- .../nikic/PhpParser/Node/Stmt/StaticVar.php | 36 +- .../nikic/PhpParser/Node/Stmt/Static_.php | 16 +- .../nikic/PhpParser/Node/Stmt/Switch_.php | 19 +- .../nikic/PhpParser/Node/Stmt/Throw_.php | 30 - .../nikic/PhpParser/Node/Stmt/TraitUse.php | 17 +- .../Node/Stmt/TraitUseAdaptation.php | 7 +- .../Node/Stmt/TraitUseAdaptation/Alias.php | 25 +- .../Stmt/TraitUseAdaptation/Precedence.php | 19 +- .../nikic/PhpParser/Node/Stmt/Trait_.php | 18 +- .../nikic/PhpParser/Node/Stmt/TryCatch.php | 23 +- .../nikic/PhpParser/Node/Stmt/Unset_.php | 15 +- .../nikic/PhpParser/Node/Stmt/UseUse.php | 51 +- .../nikic/PhpParser/Node/Stmt/Use_.php | 32 +- .../nikic/PhpParser/Node/Stmt/While_.php | 19 +- .../nikic/PhpParser/Node/UnionType.php | 15 +- .../nikic/PhpParser/Node/UseItem.php | 55 + .../PhpParser/Node/VarLikeIdentifier.php | 5 +- .../PhpParser/Node/VariadicPlaceholder.php | 4 +- .../nikic/PhpParser/NodeAbstract.php | 43 +- .../ThirdParty/nikic/PhpParser/NodeDumper.php | 259 +- .../ThirdParty/nikic/PhpParser/NodeFinder.php | 47 +- .../nikic/PhpParser/NodeTraverser.php | 159 +- .../PhpParser/NodeTraverserInterface.php | 11 +- .../nikic/PhpParser/NodeVisitor.php | 66 +- .../PhpParser/NodeVisitor/CloningVisitor.php | 3 +- .../NodeVisitor/CommentAnnotatingVisitor.php | 82 + .../PhpParser/NodeVisitor/FindingVisitor.php | 9 +- .../NodeVisitor/FirstFindingVisitor.php | 13 +- .../PhpParser/NodeVisitor/NameResolver.php | 69 +- .../NodeVisitor/NodeConnectingVisitor.php | 5 +- .../NodeVisitor/ParentConnectingVisitor.php | 19 +- .../nikic/PhpParser/NodeVisitorAbstract.php | 3 +- src/ncc/ThirdParty/nikic/PhpParser/Parser.php | 14 +- .../nikic/PhpParser/Parser/Multiple.php | 55 - .../nikic/PhpParser/Parser/Php5.php | 2682 ---------- .../nikic/PhpParser/Parser/Php7.php | 4631 ++++++++--------- .../nikic/PhpParser/Parser/Php8.php | 2799 ++++++++++ .../nikic/PhpParser/Parser/Tokens.php | 148 - .../nikic/PhpParser/ParserAbstract.php | 774 ++- .../nikic/PhpParser/ParserFactory.php | 68 +- .../ThirdParty/nikic/PhpParser/PhpVersion.php | 164 + .../nikic/PhpParser/PrettyPrinter.php | 51 + .../PhpParser/PrettyPrinter/Standard.php | 740 +-- .../nikic/PhpParser/PrettyPrinterAbstract.php | 968 ++-- src/ncc/ThirdParty/nikic/PhpParser/README.md | 32 +- src/ncc/ThirdParty/nikic/PhpParser/Token.php | 18 + src/ncc/ThirdParty/nikic/PhpParser/VERSION | 2 +- .../nikic/PhpParser/compatibility_tokens.php | 68 + 277 files changed, 12140 insertions(+), 10393 deletions(-) create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/CHANGELOG.md create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Internal/TokenPolyfill.php create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/AsymmetricVisibilityTokenEmulator.php delete mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/CoaleseEqualTokenEmulator.php delete mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/FlexibleDocStringEmulator.php delete mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/FnTokenEmulator.php delete mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/NumericLiteralSeparatorEmulator.php create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/PropertyTokenEmulator.php create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Modifiers.php create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Node/ArrayItem.php create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Node/ClosureUse.php create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Node/DeclareItem.php create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Node/InterpolatedStringPart.php create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Node/PropertyHook.php create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Node/PropertyItem.php create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/Float_.php create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/Int_.php create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/InterpolatedString.php create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Property.php create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Node/StaticVar.php create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Block.php delete mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Throw_.php create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Node/UseItem.php create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/CommentAnnotatingVisitor.php delete mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Parser/Multiple.php delete mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Parser/Php5.php create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Parser/Php8.php delete mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Parser/Tokens.php create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/PhpVersion.php create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/PrettyPrinter.php create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/Token.php create mode 100644 src/ncc/ThirdParty/nikic/PhpParser/compatibility_tokens.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 32e2f9b..3e2b896 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,6 +73,7 @@ This update introduces a refactored code-base, code quality improvements, and be - Updated Symfony/polyfill-ctype to version 1.31.0 - Updated Symfony/polyfill-mbstring to version 1.31.0 - Updated Symfony/polyfill-uuid to version 1.31.0 + - Updated nikic/PhpParser to version 5.2.0 ### Fixed - Fixed Division by zero in PackageManager diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder.php index b2370c3..1401416 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder.php @@ -2,12 +2,11 @@ namespace ncc\ThirdParty\nikic\PhpParser; -interface Builder -{ +interface Builder { /** * Returns the built node. * * @return Node The built node */ - public function getNode() : Node; + public function getNode(): Node; } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/ClassConst.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/ClassConst.php index 9a3b754..3beab31 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/ClassConst.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/ClassConst.php @@ -6,27 +6,29 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser; use PhpParser\BuilderHelpers; -use PhpParser\Node; -use PhpParser\Node\Const_; -use PhpParser\Node\Identifier; -use PhpParser\Node\Stmt; +use PhpParser\Modifiers; +use ncc\ThirdParty\nikic\PhpParser\Node; +use ncc\ThirdParty\nikic\PhpParser\Node\Const_; +use ncc\ThirdParty\nikic\PhpParser\Node\Identifier; +use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; -class ClassConst implements PhpParser\Builder -{ - protected $flags = 0; - protected $attributes = []; - protected $constants = []; +class ClassConst implements PhpParser\Builder { + protected int $flags = 0; + /** @var array */ + protected array $attributes = []; + /** @var list */ + protected array $constants = []; - /** @var Node\AttributeGroup[] */ - protected $attributeGroups = []; - /** @var Identifier|Node\Name|Node\ComplexType */ - protected $type; + /** @var list */ + protected array $attributeGroups = []; + /** @var Identifier|Node\Name|Node\ComplexType|null */ + protected ?Node $type = null; /** * Creates a class constant builder * - * @param string|Identifier $name Name - * @param Node\Expr|bool|null|int|float|string|array $value Value + * @param string|Identifier $name Name + * @param Node\Expr|bool|null|int|float|string|array|\UnitEnum $value Value */ public function __construct($name, $value) { $this->constants = [new Const_($name, BuilderHelpers::normalizeValue($value))]; @@ -35,8 +37,8 @@ class ClassConst implements PhpParser\Builder /** * Add another constant to const group * - * @param string|Identifier $name Name - * @param Node\Expr|bool|null|int|float|string|array $value Value + * @param string|Identifier $name Name + * @param Node\Expr|bool|null|int|float|string|array|\UnitEnum $value Value * * @return $this The builder instance (for fluid interface) */ @@ -52,7 +54,7 @@ class ClassConst implements PhpParser\Builder * @return $this The builder instance (for fluid interface) */ public function makePublic() { - $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PUBLIC); + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PUBLIC); return $this; } @@ -63,7 +65,7 @@ class ClassConst implements PhpParser\Builder * @return $this The builder instance (for fluid interface) */ public function makeProtected() { - $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PROTECTED); + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PROTECTED); return $this; } @@ -74,7 +76,7 @@ class ClassConst implements PhpParser\Builder * @return $this The builder instance (for fluid interface) */ public function makePrivate() { - $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PRIVATE); + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PRIVATE); return $this; } @@ -85,7 +87,7 @@ class ClassConst implements PhpParser\Builder * @return $this The builder instance (for fluid interface) */ public function makeFinal() { - $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_FINAL); + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::FINAL); return $this; } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Class_.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Class_.php index 08ac063..40f598f 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Class_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Class_.php @@ -4,25 +4,27 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser; use PhpParser\BuilderHelpers; -use PhpParser\Node; -use PhpParser\Node\Name; -use PhpParser\Node\Stmt; +use PhpParser\Modifiers; +use ncc\ThirdParty\nikic\PhpParser\Node; +use ncc\ThirdParty\nikic\PhpParser\Node\Name; +use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; -class Class_ extends Declaration -{ - protected $name; - - protected $extends = null; - protected $implements = []; - protected $flags = 0; - - protected $uses = []; - protected $constants = []; - protected $properties = []; - protected $methods = []; - - /** @var Node\AttributeGroup[] */ - protected $attributeGroups = []; +class Class_ extends Declaration { + protected string $name; + protected ?Name $extends = null; + /** @var list */ + protected array $implements = []; + protected int $flags = 0; + /** @var list */ + protected array $uses = []; + /** @var list */ + protected array $constants = []; + /** @var list */ + protected array $properties = []; + /** @var list */ + protected array $methods = []; + /** @var list */ + protected array $attributeGroups = []; /** * Creates a class builder. @@ -67,7 +69,7 @@ class Class_ extends Declaration * @return $this The builder instance (for fluid interface) */ public function makeAbstract() { - $this->flags = BuilderHelpers::addClassModifier($this->flags, Stmt\Class_::MODIFIER_ABSTRACT); + $this->flags = BuilderHelpers::addClassModifier($this->flags, Modifiers::ABSTRACT); return $this; } @@ -78,13 +80,18 @@ class Class_ extends Declaration * @return $this The builder instance (for fluid interface) */ public function makeFinal() { - $this->flags = BuilderHelpers::addClassModifier($this->flags, Stmt\Class_::MODIFIER_FINAL); + $this->flags = BuilderHelpers::addClassModifier($this->flags, Modifiers::FINAL); return $this; } + /** + * Makes the class readonly. + * + * @return $this The builder instance (for fluid interface) + */ public function makeReadonly() { - $this->flags = BuilderHelpers::addClassModifier($this->flags, Stmt\Class_::MODIFIER_READONLY); + $this->flags = BuilderHelpers::addClassModifier($this->flags, Modifiers::READONLY); return $this; } @@ -99,20 +106,18 @@ class Class_ extends Declaration public function addStmt($stmt) { $stmt = BuilderHelpers::normalizeNode($stmt); - $targets = [ - Stmt\TraitUse::class => &$this->uses, - Stmt\ClassConst::class => &$this->constants, - Stmt\Property::class => &$this->properties, - Stmt\ClassMethod::class => &$this->methods, - ]; - - $class = \get_class($stmt); - if (!isset($targets[$class])) { + if ($stmt instanceof Stmt\Property) { + $this->properties[] = $stmt; + } elseif ($stmt instanceof Stmt\ClassMethod) { + $this->methods[] = $stmt; + } elseif ($stmt instanceof Stmt\TraitUse) { + $this->uses[] = $stmt; + } elseif ($stmt instanceof Stmt\ClassConst) { + $this->constants[] = $stmt; + } else { throw new \LogicException(sprintf('Unexpected node of type "%s"', $stmt->getType())); } - $targets[$class][] = $stmt; - return $this; } @@ -134,7 +139,7 @@ class Class_ extends Declaration * * @return Stmt\Class_ The built class node */ - public function getNode() : PhpParser\Node { + public function getNode(): PhpParser\Node { return new Stmt\Class_($this->name, [ 'flags' => $this->flags, 'extends' => $this->extends, diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Declaration.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Declaration.php index e69b5d9..f4bd12e 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Declaration.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Declaration.php @@ -5,16 +5,23 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser; use PhpParser\BuilderHelpers; -abstract class Declaration implements PhpParser\Builder -{ - protected $attributes = []; +abstract class Declaration implements PhpParser\Builder { + /** @var array */ + protected array $attributes = []; + /** + * Adds a statement. + * + * @param \ncc\ThirdParty\nikic\PhpParser\Node\Stmt|PhpParser\Builder $stmt The statement to add + * + * @return $this The builder instance (for fluid interface) + */ abstract public function addStmt($stmt); /** * Adds multiple statements. * - * @param array $stmts The statements to add + * @param (\ncc\ThirdParty\nikic\PhpParser\Node\Stmt|PhpParser\Builder)[] $stmts The statements to add * * @return $this The builder instance (for fluid interface) */ diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/EnumCase.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/EnumCase.php index e0c48d9..991f586 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/EnumCase.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/EnumCase.php @@ -6,23 +6,24 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser; use PhpParser\BuilderHelpers; -use PhpParser\Node; -use PhpParser\Node\Identifier; -use PhpParser\Node\Stmt; +use ncc\ThirdParty\nikic\PhpParser\Node; +use ncc\ThirdParty\nikic\PhpParser\Node\Identifier; +use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; -class EnumCase implements PhpParser\Builder -{ +class EnumCase implements PhpParser\Builder { + /** @var Identifier|string */ protected $name; - protected $value = null; - protected $attributes = []; + protected ?Node\Expr $value = null; + /** @var array */ + protected array $attributes = []; - /** @var Node\AttributeGroup[] */ - protected $attributeGroups = []; + /** @var list */ + protected array $attributeGroups = []; /** * Creates an enum case builder. * - * @param string|Identifier $name Name + * @param string|Identifier $name Name */ public function __construct($name) { $this->name = $name; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Enum_.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Enum_.php index 13f92c7..3db67e5 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Enum_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Enum_.php @@ -4,25 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser; use PhpParser\BuilderHelpers; -use PhpParser\Node; -use PhpParser\Node\Identifier; -use PhpParser\Node\Name; -use PhpParser\Node\Stmt; +use ncc\ThirdParty\nikic\PhpParser\Node; +use ncc\ThirdParty\nikic\PhpParser\Node\Identifier; +use ncc\ThirdParty\nikic\PhpParser\Node\Name; +use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; -class Enum_ extends Declaration -{ - protected $name; - protected $scalarType = null; - - protected $implements = []; - - protected $uses = []; - protected $enumCases = []; - protected $constants = []; - protected $methods = []; - - /** @var Node\AttributeGroup[] */ - protected $attributeGroups = []; +class Enum_ extends Declaration { + protected string $name; + protected ?Identifier $scalarType = null; + /** @var list */ + protected array $implements = []; + /** @var list */ + protected array $uses = []; + /** @var list */ + protected array $enumCases = []; + /** @var list */ + protected array $constants = []; + /** @var list */ + protected array $methods = []; + /** @var list */ + protected array $attributeGroups = []; /** * Creates an enum builder. @@ -36,7 +37,7 @@ class Enum_ extends Declaration /** * Sets the scalar type. * - * @param string|Identifier $type + * @param string|Identifier $scalarType * * @return $this */ @@ -71,20 +72,18 @@ class Enum_ extends Declaration public function addStmt($stmt) { $stmt = BuilderHelpers::normalizeNode($stmt); - $targets = [ - Stmt\TraitUse::class => &$this->uses, - Stmt\EnumCase::class => &$this->enumCases, - Stmt\ClassConst::class => &$this->constants, - Stmt\ClassMethod::class => &$this->methods, - ]; - - $class = \get_class($stmt); - if (!isset($targets[$class])) { + if ($stmt instanceof Stmt\EnumCase) { + $this->enumCases[] = $stmt; + } elseif ($stmt instanceof Stmt\ClassMethod) { + $this->methods[] = $stmt; + } elseif ($stmt instanceof Stmt\TraitUse) { + $this->uses[] = $stmt; + } elseif ($stmt instanceof Stmt\ClassConst) { + $this->constants[] = $stmt; + } else { throw new \LogicException(sprintf('Unexpected node of type "%s"', $stmt->getType())); } - $targets[$class][] = $stmt; - return $this; } @@ -106,7 +105,7 @@ class Enum_ extends Declaration * * @return Stmt\Enum_ The built enum node */ - public function getNode() : PhpParser\Node { + public function getNode(): PhpParser\Node { return new Stmt\Enum_($this->name, [ 'scalarType' => $this->scalarType, 'implements' => $this->implements, diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/FunctionLike.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/FunctionLike.php index 3f24bb7..420064f 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/FunctionLike.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/FunctionLike.php @@ -5,13 +5,13 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser\BuilderHelpers; use ncc\ThirdParty\nikic\PhpParser\Node; -abstract class FunctionLike extends Declaration -{ - protected $returnByRef = false; - protected $params = []; +abstract class FunctionLike extends Declaration { + protected bool $returnByRef = false; + /** @var Node\Param[] */ + protected array $params = []; - /** @var string|Node\Name|Node\NullableType|null */ - protected $returnType = null; + /** @var Node\Identifier|Node\Name|Node\ComplexType|null */ + protected ?Node $returnType = null; /** * Make the function return by reference. @@ -46,7 +46,7 @@ abstract class FunctionLike extends Declaration /** * Adds multiple parameters. * - * @param array $params The parameters to add + * @param (Node\Param|Param)[] $params The parameters to add * * @return $this The builder instance (for fluid interface) */ diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Function_.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Function_.php index df3b618..eb63e34 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Function_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Function_.php @@ -4,16 +4,16 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser; use PhpParser\BuilderHelpers; -use PhpParser\Node; -use PhpParser\Node\Stmt; +use ncc\ThirdParty\nikic\PhpParser\Node; +use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; -class Function_ extends FunctionLike -{ - protected $name; - protected $stmts = []; +class Function_ extends FunctionLike { + protected string $name; + /** @var list */ + protected array $stmts = []; - /** @var Node\AttributeGroup[] */ - protected $attributeGroups = []; + /** @var list */ + protected array $attributeGroups = []; /** * Creates a function builder. @@ -55,7 +55,7 @@ class Function_ extends FunctionLike * * @return Stmt\Function_ The built function node */ - public function getNode() : Node { + public function getNode(): Node { return new Stmt\Function_($this->name, [ 'byRef' => $this->returnByRef, 'params' => $this->params, diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Interface_.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Interface_.php index cdd6170..1696950 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Interface_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Interface_.php @@ -4,19 +4,20 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser; use PhpParser\BuilderHelpers; -use PhpParser\Node; -use PhpParser\Node\Name; -use PhpParser\Node\Stmt; +use ncc\ThirdParty\nikic\PhpParser\Node; +use ncc\ThirdParty\nikic\PhpParser\Node\Name; +use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; -class Interface_ extends Declaration -{ - protected $name; - protected $extends = []; - protected $constants = []; - protected $methods = []; - - /** @var Node\AttributeGroup[] */ - protected $attributeGroups = []; +class Interface_ extends Declaration { + protected string $name; + /** @var list */ + protected array $extends = []; + /** @var list */ + protected array $constants = []; + /** @var list */ + protected array $methods = []; + /** @var list */ + protected array $attributeGroups = []; /** * Creates an interface builder. @@ -83,7 +84,7 @@ class Interface_ extends Declaration * * @return Stmt\Interface_ The built interface node */ - public function getNode() : PhpParser\Node { + public function getNode(): PhpParser\Node { return new Stmt\Interface_($this->name, [ 'extends' => $this->extends, 'stmts' => array_merge($this->constants, $this->methods), diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Method.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Method.php index b5e99d6..fe74e72 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Method.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Method.php @@ -4,19 +4,20 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser; use PhpParser\BuilderHelpers; -use PhpParser\Node; -use PhpParser\Node\Stmt; +use PhpParser\Modifiers; +use ncc\ThirdParty\nikic\PhpParser\Node; +use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; -class Method extends FunctionLike -{ - protected $name; - protected $flags = 0; +class Method extends FunctionLike { + protected string $name; - /** @var array|null */ - protected $stmts = []; + protected int $flags = 0; - /** @var Node\AttributeGroup[] */ - protected $attributeGroups = []; + /** @var list|null */ + protected ?array $stmts = []; + + /** @var list */ + protected array $attributeGroups = []; /** * Creates a method builder. @@ -33,7 +34,7 @@ class Method extends FunctionLike * @return $this The builder instance (for fluid interface) */ public function makePublic() { - $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PUBLIC); + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PUBLIC); return $this; } @@ -44,7 +45,7 @@ class Method extends FunctionLike * @return $this The builder instance (for fluid interface) */ public function makeProtected() { - $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PROTECTED); + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PROTECTED); return $this; } @@ -55,7 +56,7 @@ class Method extends FunctionLike * @return $this The builder instance (for fluid interface) */ public function makePrivate() { - $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PRIVATE); + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PRIVATE); return $this; } @@ -66,7 +67,7 @@ class Method extends FunctionLike * @return $this The builder instance (for fluid interface) */ public function makeStatic() { - $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_STATIC); + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::STATIC); return $this; } @@ -81,7 +82,7 @@ class Method extends FunctionLike throw new \LogicException('Cannot make method with statements abstract'); } - $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_ABSTRACT); + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::ABSTRACT); $this->stmts = null; // abstract methods don't have statements return $this; @@ -93,7 +94,7 @@ class Method extends FunctionLike * @return $this The builder instance (for fluid interface) */ public function makeFinal() { - $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_FINAL); + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::FINAL); return $this; } @@ -133,7 +134,7 @@ class Method extends FunctionLike * * @return Stmt\ClassMethod The built method node */ - public function getNode() : Node { + public function getNode(): Node { return new Stmt\ClassMethod($this->name, [ 'flags' => $this->flags, 'byRef' => $this->returnByRef, diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Namespace_.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Namespace_.php index fdd76af..674f860 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Namespace_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Namespace_.php @@ -4,13 +4,13 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser; use PhpParser\BuilderHelpers; -use PhpParser\Node; -use PhpParser\Node\Stmt; +use ncc\ThirdParty\nikic\PhpParser\Node; +use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; -class Namespace_ extends Declaration -{ - private $name; - private $stmts = []; +class Namespace_ extends Declaration { + private ?Node\Name $name; + /** @var Stmt[] */ + private array $stmts = []; /** * Creates a namespace builder. @@ -39,7 +39,7 @@ class Namespace_ extends Declaration * * @return Stmt\Namespace_ The built node */ - public function getNode() : Node { + public function getNode(): Node { return new Stmt\Namespace_($this->name, $this->stmts, $this->attributes); } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Param.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Param.php index 62f67fa..9a81866 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Param.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Param.php @@ -4,25 +4,19 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser; use PhpParser\BuilderHelpers; -use PhpParser\Node; +use PhpParser\Modifiers; +use ncc\ThirdParty\nikic\PhpParser\Node; -class Param implements PhpParser\Builder -{ - protected $name; - - protected $default = null; - - /** @var Node\Identifier|Node\Name|Node\NullableType|null */ - protected $type = null; - - protected $byRef = false; - - protected $variadic = false; - - protected $flags = 0; - - /** @var Node\AttributeGroup[] */ - protected $attributeGroups = []; +class Param implements PhpParser\Builder { + protected string $name; + protected ?Node\Expr $default = null; + /** @var Node\Identifier|Node\Name|Node\ComplexType|null */ + protected ?Node $type = null; + protected bool $byRef = false; + protected int $flags = 0; + protected bool $variadic = false; + /** @var list */ + protected array $attributeGroups = []; /** * Creates a parameter builder. @@ -62,19 +56,6 @@ class Param implements PhpParser\Builder return $this; } - /** - * Sets type for the parameter. - * - * @param string|Node\Name|Node\Identifier|Node\ComplexType $type Parameter type - * - * @return $this The builder instance (for fluid interface) - * - * @deprecated Use setType() instead - */ - public function setTypeHint($type) { - return $this->setType($type); - } - /** * Make the parameter accept the value by reference. * @@ -103,7 +84,7 @@ class Param implements PhpParser\Builder * @return $this The builder instance (for fluid interface) */ public function makePublic() { - $this->flags = BuilderHelpers::addModifier($this->flags, Node\Stmt\Class_::MODIFIER_PUBLIC); + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PUBLIC); return $this; } @@ -114,7 +95,7 @@ class Param implements PhpParser\Builder * @return $this The builder instance (for fluid interface) */ public function makeProtected() { - $this->flags = BuilderHelpers::addModifier($this->flags, Node\Stmt\Class_::MODIFIER_PROTECTED); + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PROTECTED); return $this; } @@ -125,7 +106,7 @@ class Param implements PhpParser\Builder * @return $this The builder instance (for fluid interface) */ public function makePrivate() { - $this->flags = BuilderHelpers::addModifier($this->flags, Node\Stmt\Class_::MODIFIER_PRIVATE); + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PRIVATE); return $this; } @@ -136,7 +117,29 @@ class Param implements PhpParser\Builder * @return $this The builder instance (for fluid interface) */ public function makeReadonly() { - $this->flags = BuilderHelpers::addModifier($this->flags, Node\Stmt\Class_::MODIFIER_READONLY); + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::READONLY); + + return $this; + } + + /** + * Gives the promoted property private(set) visibility. + * + * @return $this The builder instance (for fluid interface) + */ + public function makePrivateSet() { + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PRIVATE_SET); + + return $this; + } + + /** + * Gives the promoted property protected(set) visibility. + * + * @return $this The builder instance (for fluid interface) + */ + public function makeProtectedSet() { + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PROTECTED_SET); return $this; } @@ -159,7 +162,7 @@ class Param implements PhpParser\Builder * * @return Node\Param The built parameter node */ - public function getNode() : Node { + public function getNode(): Node { return new Node\Param( new Node\Expr\Variable($this->name), $this->default, $this->type, $this->byRef, $this->variadic, [], $this->flags, $this->attributeGroups diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Property.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Property.php index 7cfd059..66d819a 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Property.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Property.php @@ -4,25 +4,27 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser; use PhpParser\BuilderHelpers; -use PhpParser\Node; -use PhpParser\Node\Identifier; -use PhpParser\Node\Name; -use PhpParser\Node\Stmt; -use PhpParser\Node\ComplexType; +use PhpParser\Modifiers; +use ncc\ThirdParty\nikic\PhpParser\Node; +use ncc\ThirdParty\nikic\PhpParser\Node\Identifier; +use ncc\ThirdParty\nikic\PhpParser\Node\Name; +use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; +use ncc\ThirdParty\nikic\PhpParser\Node\ComplexType; -class Property implements PhpParser\Builder -{ - protected $name; +class Property implements PhpParser\Builder { + protected string $name; - protected $flags = 0; - protected $default = null; - protected $attributes = []; + protected int $flags = 0; - /** @var null|Identifier|Name|NullableType */ - protected $type; - - /** @var Node\AttributeGroup[] */ - protected $attributeGroups = []; + protected ?Node\Expr $default = null; + /** @var array */ + protected array $attributes = []; + /** @var null|Identifier|Name|ComplexType */ + protected ?Node $type = null; + /** @var list */ + protected array $attributeGroups = []; + /** @var list */ + protected array $hooks = []; /** * Creates a property builder. @@ -39,7 +41,7 @@ class Property implements PhpParser\Builder * @return $this The builder instance (for fluid interface) */ public function makePublic() { - $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PUBLIC); + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PUBLIC); return $this; } @@ -50,7 +52,7 @@ class Property implements PhpParser\Builder * @return $this The builder instance (for fluid interface) */ public function makeProtected() { - $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PROTECTED); + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PROTECTED); return $this; } @@ -61,7 +63,7 @@ class Property implements PhpParser\Builder * @return $this The builder instance (for fluid interface) */ public function makePrivate() { - $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PRIVATE); + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PRIVATE); return $this; } @@ -72,7 +74,7 @@ class Property implements PhpParser\Builder * @return $this The builder instance (for fluid interface) */ public function makeStatic() { - $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_STATIC); + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::STATIC); return $this; } @@ -83,7 +85,51 @@ class Property implements PhpParser\Builder * @return $this The builder instance (for fluid interface) */ public function makeReadonly() { - $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_READONLY); + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::READONLY); + + return $this; + } + + /** + * Makes the property abstract. Requires at least one property hook to be specified as well. + * + * @return $this The builder instance (for fluid interface) + */ + public function makeAbstract() { + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::ABSTRACT); + + return $this; + } + + /** + * Makes the property final. + * + * @return $this The builder instance (for fluid interface) + */ + public function makeFinal() { + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::FINAL); + + return $this; + } + + /** + * Gives the property private(set) visibility. + * + * @return $this The builder instance (for fluid interface) + */ + public function makePrivateSet() { + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PRIVATE_SET); + + return $this; + } + + /** + * Gives the property protected(set) visibility. + * + * @return $this The builder instance (for fluid interface) + */ + public function makeProtectedSet() { + $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PROTECTED_SET); return $this; } @@ -142,20 +188,36 @@ class Property implements PhpParser\Builder return $this; } + /** + * Adds a property hook. + * + * @return $this The builder instance (for fluid interface) + */ + public function addHook(Node\PropertyHook $hook) { + $this->hooks[] = $hook; + + return $this; + } + /** * Returns the built class node. * * @return Stmt\Property The built property node */ - public function getNode() : PhpParser\Node { + public function getNode(): PhpParser\Node { + if ($this->flags & Modifiers::ABSTRACT && !$this->hooks) { + throw new PhpParser\Error('Only hooked properties may be declared abstract'); + } + return new Stmt\Property( - $this->flags !== 0 ? $this->flags : Stmt\Class_::MODIFIER_PUBLIC, + $this->flags !== 0 ? $this->flags : Modifiers::PUBLIC, [ - new Stmt\PropertyProperty($this->name, $this->default) + new Node\PropertyItem($this->name, $this->default) ], $this->attributes, $this->type, - $this->attributeGroups + $this->attributeGroups, + $this->hooks ); } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/TraitUse.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/TraitUse.php index 4d8fac3..7ed1714 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/TraitUse.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/TraitUse.php @@ -7,10 +7,11 @@ use ncc\ThirdParty\nikic\PhpParser\BuilderHelpers; use ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; -class TraitUse implements Builder -{ - protected $traits = []; - protected $adaptations = []; +class TraitUse implements Builder { + /** @var Node\Name[] */ + protected array $traits = []; + /** @var Stmt\TraitUseAdaptation[] */ + protected array $adaptations = []; /** * Creates a trait use builder. @@ -58,7 +59,7 @@ class TraitUse implements Builder * * @return Node The built node */ - public function getNode() : Node { + public function getNode(): Node { return new Stmt\TraitUse($this->traits, $this->adaptations); } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/TraitUseAdaptation.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/TraitUseAdaptation.php index 2410612..4e181a9 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/TraitUseAdaptation.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/TraitUseAdaptation.php @@ -4,43 +4,40 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser\BuilderHelpers; +use ncc\ThirdParty\nikic\PhpParser\Modifiers; use ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; -class TraitUseAdaptation implements Builder -{ - const TYPE_UNDEFINED = 0; - const TYPE_ALIAS = 1; - const TYPE_PRECEDENCE = 2; +class TraitUseAdaptation implements Builder { + private const TYPE_UNDEFINED = 0; + private const TYPE_ALIAS = 1; + private const TYPE_PRECEDENCE = 2; - /** @var int Type of building adaptation */ - protected $type; - - protected $trait; - protected $method; - - protected $modifier = null; - protected $alias = null; - - protected $insteadof = []; + protected int $type; + protected ?Node\Name $trait; + protected Node\Identifier $method; + protected ?int $modifier = null; + protected ?Node\Identifier $alias = null; + /** @var Node\Name[] */ + protected array $insteadof = []; /** * Creates a trait use adaptation builder. * - * @param Node\Name|string|null $trait Name of adaptated trait - * @param Node\Identifier|string $method Name of adaptated method + * @param Node\Name|string|null $trait Name of adapted trait + * @param Node\Identifier|string $method Name of adapted method */ public function __construct($trait, $method) { $this->type = self::TYPE_UNDEFINED; - $this->trait = is_null($trait)? null: BuilderHelpers::normalizeName($trait); + $this->trait = is_null($trait) ? null : BuilderHelpers::normalizeName($trait); $this->method = BuilderHelpers::normalizeIdentifier($method); } /** * Sets alias of method. * - * @param Node\Identifier|string $alias Alias for adaptated method + * @param Node\Identifier|string $alias Alias for adapted method * * @return $this The builder instance (for fluid interface) */ @@ -53,37 +50,37 @@ class TraitUseAdaptation implements Builder throw new \LogicException('Cannot set alias for not alias adaptation buider'); } - $this->alias = $alias; + $this->alias = BuilderHelpers::normalizeIdentifier($alias); return $this; } /** - * Sets adaptated method public. + * Sets adapted method public. * * @return $this The builder instance (for fluid interface) */ public function makePublic() { - $this->setModifier(Stmt\Class_::MODIFIER_PUBLIC); + $this->setModifier(Modifiers::PUBLIC); return $this; } /** - * Sets adaptated method protected. + * Sets adapted method protected. * * @return $this The builder instance (for fluid interface) */ public function makeProtected() { - $this->setModifier(Stmt\Class_::MODIFIER_PROTECTED); + $this->setModifier(Modifiers::PROTECTED); return $this; } /** - * Sets adaptated method private. + * Sets adapted method private. * * @return $this The builder instance (for fluid interface) */ public function makePrivate() { - $this->setModifier(Stmt\Class_::MODIFIER_PRIVATE); + $this->setModifier(Modifiers::PRIVATE); return $this; } @@ -114,7 +111,7 @@ class TraitUseAdaptation implements Builder return $this; } - protected function setModifier(int $modifier) { + protected function setModifier(int $modifier): void { if ($this->type === self::TYPE_UNDEFINED) { $this->type = self::TYPE_ALIAS; } @@ -135,12 +132,12 @@ class TraitUseAdaptation implements Builder * * @return Node The built node */ - public function getNode() : Node { + public function getNode(): Node { switch ($this->type) { case self::TYPE_ALIAS: - return new Stmt\TraitUseAdaptation\Alias($this->trait, $this->method, $this->modifier, $this->alias); + return new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Alias($this->trait, $this->method, $this->modifier, $this->alias); case self::TYPE_PRECEDENCE: - return new Stmt\TraitUseAdaptation\Precedence($this->trait, $this->method, $this->insteadof); + return new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Precedence($this->trait, $this->method, $this->insteadof); default: throw new \LogicException('Type of adaptation is not defined'); } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Trait_.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Trait_.php index 7f5ce92..03491c4 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Trait_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Trait_.php @@ -4,18 +4,21 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser; use PhpParser\BuilderHelpers; -use PhpParser\Node; -use PhpParser\Node\Stmt; +use ncc\ThirdParty\nikic\PhpParser\Node; +use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; -class Trait_ extends Declaration -{ - protected $name; - protected $uses = []; - protected $properties = []; - protected $methods = []; - - /** @var Node\AttributeGroup[] */ - protected $attributeGroups = []; +class Trait_ extends Declaration { + protected string $name; + /** @var list */ + protected array $uses = []; + /** @var list */ + protected array $constants = []; + /** @var list */ + protected array $properties = []; + /** @var list */ + protected array $methods = []; + /** @var list */ + protected array $attributeGroups = []; /** * Creates an interface builder. @@ -42,6 +45,8 @@ class Trait_ extends Declaration $this->methods[] = $stmt; } elseif ($stmt instanceof Stmt\TraitUse) { $this->uses[] = $stmt; + } elseif ($stmt instanceof Stmt\ClassConst) { + $this->constants[] = $stmt; } else { throw new \LogicException(sprintf('Unexpected node of type "%s"', $stmt->getType())); } @@ -67,10 +72,10 @@ class Trait_ extends Declaration * * @return Stmt\Trait_ The built interface node */ - public function getNode() : PhpParser\Node { + public function getNode(): PhpParser\Node { return new Stmt\Trait_( $this->name, [ - 'stmts' => array_merge($this->uses, $this->properties, $this->methods), + 'stmts' => array_merge($this->uses, $this->constants, $this->properties, $this->methods), 'attrGroups' => $this->attributeGroups, ], $this->attributes ); diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Use_.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Use_.php index 534c73a..cba7fa4 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Use_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Use_.php @@ -7,17 +7,17 @@ use ncc\ThirdParty\nikic\PhpParser\BuilderHelpers; use ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; -class Use_ implements Builder -{ - protected $name; - protected $type; - protected $alias = null; +class Use_ implements Builder { + protected Node\Name $name; + /** @var Stmt\Use_::TYPE_* */ + protected int $type; + protected ?string $alias = null; /** * Creates a name use (alias) builder. * * @param Node\Name|string $name Name of the entity (namespace, class, function, constant) to alias - * @param int $type One of the Stmt\Use_::TYPE_* constants + * @param Stmt\Use_::TYPE_* $type One of the Stmt\Use_::TYPE_* constants */ public function __construct($name, int $type) { $this->name = BuilderHelpers::normalizeName($name); @@ -41,9 +41,9 @@ class Use_ implements Builder * * @return Stmt\Use_ The built node */ - public function getNode() : Node { + public function getNode(): Node { return new Stmt\Use_([ - new Stmt\UseUse($this->name, $this->alias) + new Node\UseItem($this->name, $this->alias) ], $this->type); } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/BuilderFactory.php b/src/ncc/ThirdParty/nikic/PhpParser/BuilderFactory.php index 124b004..e4f9f07 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/BuilderFactory.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/BuilderFactory.php @@ -10,18 +10,15 @@ use ncc\ThirdParty\nikic\PhpParser\Node\Name; use ncc\ThirdParty\nikic\PhpParser\Node\Scalar\String_; use ncc\ThirdParty\nikic\PhpParser\Node\Stmt\Use_; -class BuilderFactory -{ +class BuilderFactory { /** * Creates an attribute node. * * @param string|Name $name Name of the attribute - * @param array $args Attribute named arguments - * - * @return Node\Attribute + * @param array $args Attribute named arguments */ - public function attribute($name, array $args = []) : Node\Attribute { - return new Node\Attribute( + public function attribute($name, array $args = []): ncc\ThirdParty\nikic\PhpParser\Node\Attribute { + return new ncc\ThirdParty\nikic\PhpParser\Node\Attribute( BuilderHelpers::normalizeName($name), $this->args($args) ); @@ -30,12 +27,12 @@ class BuilderFactory /** * Creates a namespace builder. * - * @param null|string|Node\Name $name Name of the namespace + * @param null|string|ncc\ThirdParty\nikic\PhpParser\Node\Name $name Name of the namespace * - * @return Builder\Namespace_ The created namespace builder + * @return ncc\ThirdParty\nikic\PhpParser\Builder\Namespace_ The created namespace builder */ - public function namespace($name) : Builder\Namespace_ { - return new Builder\Namespace_($name); + public function namespace($name): ncc\ThirdParty\nikic\PhpParser\Builder\Namespace_ { + return new ncc\ThirdParty\nikic\PhpParser\Builder\Namespace_($name); } /** @@ -43,10 +40,10 @@ class BuilderFactory * * @param string $name Name of the class * - * @return Builder\Class_ The created class builder + * @return ncc\ThirdParty\nikic\PhpParser\Builder\Class_ The created class builder */ - public function class(string $name) : Builder\Class_ { - return new Builder\Class_($name); + public function class(string $name): ncc\ThirdParty\nikic\PhpParser\Builder\Class_ { + return new ncc\ThirdParty\nikic\PhpParser\Builder\Class_($name); } /** @@ -54,10 +51,10 @@ class BuilderFactory * * @param string $name Name of the interface * - * @return Builder\Interface_ The created interface builder + * @return ncc\ThirdParty\nikic\PhpParser\Builder\Interface_ The created interface builder */ - public function interface(string $name) : Builder\Interface_ { - return new Builder\Interface_($name); + public function interface(string $name): ncc\ThirdParty\nikic\PhpParser\Builder\Interface_ { + return new ncc\ThirdParty\nikic\PhpParser\Builder\Interface_($name); } /** @@ -65,10 +62,10 @@ class BuilderFactory * * @param string $name Name of the trait * - * @return Builder\Trait_ The created trait builder + * @return ncc\ThirdParty\nikic\PhpParser\Builder\Trait_ The created trait builder */ - public function trait(string $name) : Builder\Trait_ { - return new Builder\Trait_($name); + public function trait(string $name): ncc\ThirdParty\nikic\PhpParser\Builder\Trait_ { + return new ncc\ThirdParty\nikic\PhpParser\Builder\Trait_($name); } /** @@ -76,38 +73,38 @@ class BuilderFactory * * @param string $name Name of the enum * - * @return Builder\Enum_ The created enum builder + * @return ncc\ThirdParty\nikic\PhpParser\Builder\Enum_ The created enum builder */ - public function enum(string $name) : Builder\Enum_ { - return new Builder\Enum_($name); + public function enum(string $name): ncc\ThirdParty\nikic\PhpParser\Builder\Enum_ { + return new ncc\ThirdParty\nikic\PhpParser\Builder\Enum_($name); } /** * Creates a trait use builder. * - * @param Node\Name|string ...$traits Trait names + * @param ncc\ThirdParty\nikic\PhpParser\Node\Name|string ...$traits Trait names * - * @return Builder\TraitUse The create trait use builder + * @return ncc\ThirdParty\nikic\PhpParser\Builder\TraitUse The created trait use builder */ - public function useTrait(...$traits) : Builder\TraitUse { - return new Builder\TraitUse(...$traits); + public function useTrait(...$traits): ncc\ThirdParty\nikic\PhpParser\Builder\TraitUse { + return new ncc\ThirdParty\nikic\PhpParser\Builder\TraitUse(...$traits); } /** * Creates a trait use adaptation builder. * - * @param Node\Name|string|null $trait Trait name - * @param Node\Identifier|string $method Method name + * @param ncc\ThirdParty\nikic\PhpParser\Node\Name|string|null $trait Trait name + * @param ncc\ThirdParty\nikic\PhpParser\Node\Identifier|string $method Method name * - * @return Builder\TraitUseAdaptation The create trait use adaptation builder + * @return ncc\ThirdParty\nikic\PhpParser\Builder\TraitUseAdaptation The created trait use adaptation builder */ - public function traitUseAdaptation($trait, $method = null) : Builder\TraitUseAdaptation { + public function traitUseAdaptation($trait, $method = null): ncc\ThirdParty\nikic\PhpParser\Builder\TraitUseAdaptation { if ($method === null) { $method = $trait; $trait = null; } - return new Builder\TraitUseAdaptation($trait, $method); + return new ncc\ThirdParty\nikic\PhpParser\Builder\TraitUseAdaptation($trait, $method); } /** @@ -115,10 +112,10 @@ class BuilderFactory * * @param string $name Name of the method * - * @return Builder\Method The created method builder + * @return ncc\ThirdParty\nikic\PhpParser\Builder\Method The created method builder */ - public function method(string $name) : Builder\Method { - return new Builder\Method($name); + public function method(string $name): ncc\ThirdParty\nikic\PhpParser\Builder\Method { + return new ncc\ThirdParty\nikic\PhpParser\Builder\Method($name); } /** @@ -126,10 +123,10 @@ class BuilderFactory * * @param string $name Name of the parameter * - * @return Builder\Param The created parameter builder + * @return ncc\ThirdParty\nikic\PhpParser\Builder\Param The created parameter builder */ - public function param(string $name) : Builder\Param { - return new Builder\Param($name); + public function param(string $name): ncc\ThirdParty\nikic\PhpParser\Builder\Param { + return new ncc\ThirdParty\nikic\PhpParser\Builder\Param($name); } /** @@ -137,10 +134,10 @@ class BuilderFactory * * @param string $name Name of the property * - * @return Builder\Property The created property builder + * @return ncc\ThirdParty\nikic\PhpParser\Builder\Property The created property builder */ - public function property(string $name) : Builder\Property { - return new Builder\Property($name); + public function property(string $name): ncc\ThirdParty\nikic\PhpParser\Builder\Property { + return new ncc\ThirdParty\nikic\PhpParser\Builder\Property($name); } /** @@ -148,76 +145,74 @@ class BuilderFactory * * @param string $name Name of the function * - * @return Builder\Function_ The created function builder + * @return ncc\ThirdParty\nikic\PhpParser\Builder\Function_ The created function builder */ - public function function(string $name) : Builder\Function_ { - return new Builder\Function_($name); + public function function(string $name): ncc\ThirdParty\nikic\PhpParser\Builder\Function_ { + return new ncc\ThirdParty\nikic\PhpParser\Builder\Function_($name); } /** * Creates a namespace/class use builder. * - * @param Node\Name|string $name Name of the entity (namespace or class) to alias + * @param ncc\ThirdParty\nikic\PhpParser\Node\Name|string $name Name of the entity (namespace or class) to alias * - * @return Builder\Use_ The created use builder + * @return ncc\ThirdParty\nikic\PhpParser\Builder\Use_ The created use builder */ - public function use($name) : Builder\Use_ { - return new Builder\Use_($name, Use_::TYPE_NORMAL); + public function use($name): ncc\ThirdParty\nikic\PhpParser\Builder\Use_ { + return new ncc\ThirdParty\nikic\PhpParser\Builder\Use_($name, Use_::TYPE_NORMAL); } /** * Creates a function use builder. * - * @param Node\Name|string $name Name of the function to alias + * @param ncc\ThirdParty\nikic\PhpParser\Node\Name|string $name Name of the function to alias * - * @return Builder\Use_ The created use function builder + * @return ncc\ThirdParty\nikic\PhpParser\Builder\Use_ The created use function builder */ - public function useFunction($name) : Builder\Use_ { - return new Builder\Use_($name, Use_::TYPE_FUNCTION); + public function useFunction($name): ncc\ThirdParty\nikic\PhpParser\Builder\Use_ { + return new ncc\ThirdParty\nikic\PhpParser\Builder\Use_($name, Use_::TYPE_FUNCTION); } /** * Creates a constant use builder. * - * @param Node\Name|string $name Name of the const to alias + * @param ncc\ThirdParty\nikic\PhpParser\Node\Name|string $name Name of the const to alias * - * @return Builder\Use_ The created use const builder + * @return ncc\ThirdParty\nikic\PhpParser\Builder\Use_ The created use const builder */ - public function useConst($name) : Builder\Use_ { - return new Builder\Use_($name, Use_::TYPE_CONSTANT); + public function useConst($name): ncc\ThirdParty\nikic\PhpParser\Builder\Use_ { + return new ncc\ThirdParty\nikic\PhpParser\Builder\Use_($name, Use_::TYPE_CONSTANT); } /** * Creates a class constant builder. * - * @param string|Identifier $name Name - * @param Node\Expr|bool|null|int|float|string|array $value Value + * @param string|Identifier $name Name + * @param ncc\ThirdParty\nikic\PhpParser\Node\Expr|bool|null|int|float|string|array $value Value * - * @return Builder\ClassConst The created use const builder + * @return ncc\ThirdParty\nikic\PhpParser\Builder\ClassConst The created use const builder */ - public function classConst($name, $value) : Builder\ClassConst { - return new Builder\ClassConst($name, $value); + public function classConst($name, $value): ncc\ThirdParty\nikic\PhpParser\Builder\ClassConst { + return new ncc\ThirdParty\nikic\PhpParser\Builder\ClassConst($name, $value); } /** * Creates an enum case builder. * - * @param string|Identifier $name Name + * @param string|Identifier $name Name * - * @return Builder\EnumCase The created use const builder + * @return ncc\ThirdParty\nikic\PhpParser\Builder\EnumCase The created use const builder */ - public function enumCase($name) : Builder\EnumCase { - return new Builder\EnumCase($name); + public function enumCase($name): ncc\ThirdParty\nikic\PhpParser\Builder\EnumCase { + return new ncc\ThirdParty\nikic\PhpParser\Builder\EnumCase($name); } /** * Creates node a for a literal value. * - * @param Expr|bool|null|int|float|string|array $value $value - * - * @return Expr + * @param Expr|bool|null|int|float|string|array|\UnitEnum $value $value */ - public function val($value) : Expr { + public function val($value): Expr { return BuilderHelpers::normalizeValue($value); } @@ -225,10 +220,8 @@ class BuilderFactory * Creates variable node. * * @param string|Expr $name Name - * - * @return Expr\Variable */ - public function var($name) : Expr\Variable { + public function var($name): Expr\Variable { if (!\is_string($name) && !$name instanceof Expr) { throw new \LogicException('Variable name must be string or Expr'); } @@ -243,9 +236,9 @@ class BuilderFactory * * @param array $args List of arguments to normalize * - * @return Arg[] + * @return list */ - public function args(array $args) : array { + public function args(array $args): array { $normalizedArgs = []; foreach ($args as $key => $arg) { if (!($arg instanceof Arg)) { @@ -263,11 +256,9 @@ class BuilderFactory * Creates a function call node. * * @param string|Name|Expr $name Function name - * @param array $args Function arguments - * - * @return Expr\FuncCall + * @param array $args Function arguments */ - public function funcCall($name, array $args = []) : Expr\FuncCall { + public function funcCall($name, array $args = []): Expr\FuncCall { return new Expr\FuncCall( BuilderHelpers::normalizeNameOrExpr($name), $this->args($args) @@ -277,13 +268,11 @@ class BuilderFactory /** * Creates a method call node. * - * @param Expr $var Variable the method is called on + * @param Expr $var Variable the method is called on * @param string|Identifier|Expr $name Method name - * @param array $args Method arguments - * - * @return Expr\MethodCall + * @param array $args Method arguments */ - public function methodCall(Expr $var, $name, array $args = []) : Expr\MethodCall { + public function methodCall(Expr $var, $name, array $args = []): Expr\MethodCall { return new Expr\MethodCall( $var, BuilderHelpers::normalizeIdentifierOrExpr($name), @@ -294,13 +283,11 @@ class BuilderFactory /** * Creates a static method call node. * - * @param string|Name|Expr $class Class name - * @param string|Identifier|Expr $name Method name - * @param array $args Method arguments - * - * @return Expr\StaticCall + * @param string|Name|Expr $class Class name + * @param string|Identifier|Expr $name Method name + * @param array $args Method arguments */ - public function staticCall($class, $name, array $args = []) : Expr\StaticCall { + public function staticCall($class, $name, array $args = []): Expr\StaticCall { return new Expr\StaticCall( BuilderHelpers::normalizeNameOrExpr($class), BuilderHelpers::normalizeIdentifierOrExpr($name), @@ -312,11 +299,9 @@ class BuilderFactory * Creates an object creation node. * * @param string|Name|Expr $class Class name - * @param array $args Constructor arguments - * - * @return Expr\New_ + * @param array $args Constructor arguments */ - public function new($class, array $args = []) : Expr\New_ { + public function new($class, array $args = []): Expr\New_ { return new Expr\New_( BuilderHelpers::normalizeNameOrExpr($class), $this->args($args) @@ -327,22 +312,18 @@ class BuilderFactory * Creates a constant fetch node. * * @param string|Name $name Constant name - * - * @return Expr\ConstFetch */ - public function constFetch($name) : Expr\ConstFetch { + public function constFetch($name): Expr\ConstFetch { return new Expr\ConstFetch(BuilderHelpers::normalizeName($name)); } /** * Creates a property fetch node. * - * @param Expr $var Variable holding object + * @param Expr $var Variable holding object * @param string|Identifier|Expr $name Property name - * - * @return Expr\PropertyFetch */ - public function propertyFetch(Expr $var, $name) : Expr\PropertyFetch { + public function propertyFetch(Expr $var, $name): Expr\PropertyFetch { return new Expr\PropertyFetch($var, BuilderHelpers::normalizeIdentifierOrExpr($name)); } @@ -350,9 +331,7 @@ class BuilderFactory * Creates a class constant fetch node. * * @param string|Name|Expr $class Class name - * @param string|Identifier|Expr $name Constant name - * - * @return Expr\ClassConstFetch + * @param string|Identifier|Expr $name Constant name */ public function classConstFetch($class, $name): Expr\ClassConstFetch { return new Expr\ClassConstFetch( @@ -365,10 +344,8 @@ class BuilderFactory * Creates nested Concat nodes from a list of expressions. * * @param Expr|string ...$exprs Expressions or literal strings - * - * @return Concat */ - public function concat(...$exprs) : Concat { + public function concat(...$exprs): Concat { $numExprs = count($exprs); if ($numExprs < 2) { throw new \LogicException('Expected at least two expressions'); @@ -383,9 +360,8 @@ class BuilderFactory /** * @param string|Expr $expr - * @return Expr */ - private function normalizeStringExpr($expr) : Expr { + private function normalizeStringExpr($expr): Expr { if ($expr instanceof Expr) { return $expr; } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/BuilderHelpers.php b/src/ncc/ThirdParty/nikic/PhpParser/BuilderHelpers.php index e431440..cd56a69 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/BuilderHelpers.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/BuilderHelpers.php @@ -6,6 +6,7 @@ use ncc\ThirdParty\nikic\PhpParser\Node\ComplexType; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Identifier; use ncc\ThirdParty\nikic\PhpParser\Node\Name; +use ncc\ThirdParty\nikic\PhpParser\Node\Name\FullyQualified; use ncc\ThirdParty\nikic\PhpParser\Node\NullableType; use ncc\ThirdParty\nikic\PhpParser\Node\Scalar; use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; @@ -15,8 +16,7 @@ use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; * * @internal */ -final class BuilderHelpers -{ +final class BuilderHelpers { /** * Normalizes a node: Converts builder objects to nodes. * @@ -24,7 +24,7 @@ final class BuilderHelpers * * @return Node The normalized node */ - public static function normalizeNode($node) : Node { + public static function normalizeNode($node): Node { if ($node instanceof Builder) { return $node->getNode(); } @@ -45,7 +45,7 @@ final class BuilderHelpers * * @return Stmt The normalized statement node */ - public static function normalizeStmt($node) : Stmt { + public static function normalizeStmt($node): Stmt { $node = self::normalizeNode($node); if ($node instanceof Stmt) { return $node; @@ -65,7 +65,7 @@ final class BuilderHelpers * * @return Identifier The normalized identifier */ - public static function normalizeIdentifier($name) : Identifier { + public static function normalizeIdentifier($name): Identifier { if ($name instanceof Identifier) { return $name; } @@ -103,7 +103,7 @@ final class BuilderHelpers * * @return Name The normalized name */ - public static function normalizeName($name) : Name { + public static function normalizeName($name): Name { if ($name instanceof Name) { return $name; } @@ -215,12 +215,12 @@ final class BuilderHelpers * Normalizes a value: Converts nulls, booleans, integers, * floats, strings and arrays into their respective nodes * - * @param Node\Expr|bool|null|int|float|string|array $value The value to normalize + * @param ncc\ThirdParty\nikic\PhpParser\Node\Expr|bool|null|int|float|string|array|\UnitEnum $value The value to normalize * * @return Expr The normalized value */ - public static function normalizeValue($value) : Expr { - if ($value instanceof Node\Expr) { + public static function normalizeValue($value): Expr { + if ($value instanceof ncc\ThirdParty\nikic\PhpParser\Node\Expr) { return $value; } @@ -237,11 +237,11 @@ final class BuilderHelpers } if (is_int($value)) { - return new Scalar\LNumber($value); + return new Scalar\Int_($value); } if (is_float($value)) { - return new Scalar\DNumber($value); + return new Scalar\Float_($value); } if (is_string($value)) { @@ -254,12 +254,12 @@ final class BuilderHelpers foreach ($value as $itemKey => $itemValue) { // for consecutive, numeric keys don't generate keys if (null !== $lastKey && ++$lastKey === $itemKey) { - $items[] = new Expr\ArrayItem( + $items[] = new ncc\ThirdParty\nikic\PhpParser\Node\ArrayItem( self::normalizeValue($itemValue) ); } else { $lastKey = null; - $items[] = new Expr\ArrayItem( + $items[] = new ncc\ThirdParty\nikic\PhpParser\Node\ArrayItem( self::normalizeValue($itemValue), self::normalizeValue($itemKey) ); @@ -269,6 +269,10 @@ final class BuilderHelpers return new Expr\Array_($items); } + if ($value instanceof \UnitEnum) { + return new Expr\ClassConstFetch(new FullyQualified(\get_class($value)), new Identifier($value->name)); + } + throw new \LogicException('Invalid value'); } @@ -279,7 +283,7 @@ final class BuilderHelpers * * @return Comment\Doc The normalized doc comment */ - public static function normalizeDocComment($docComment) : Comment\Doc { + public static function normalizeDocComment($docComment): Comment\Doc { if ($docComment instanceof Comment\Doc) { return $docComment; } @@ -294,33 +298,32 @@ final class BuilderHelpers /** * Normalizes a attribute: Converts attribute to the Attribute Group if needed. * - * @param Node\Attribute|Node\AttributeGroup $attribute + * @param ncc\ThirdParty\nikic\PhpParser\Node\Attribute|ncc\ThirdParty\nikic\PhpParser\Node\AttributeGroup $attribute * - * @return Node\AttributeGroup The Attribute Group + * @return ncc\ThirdParty\nikic\PhpParser\Node\AttributeGroup The Attribute Group */ - public static function normalizeAttribute($attribute) : Node\AttributeGroup - { - if ($attribute instanceof Node\AttributeGroup) { + public static function normalizeAttribute($attribute): ncc\ThirdParty\nikic\PhpParser\Node\AttributeGroup { + if ($attribute instanceof ncc\ThirdParty\nikic\PhpParser\Node\AttributeGroup) { return $attribute; } - if (!($attribute instanceof Node\Attribute)) { + if (!($attribute instanceof ncc\ThirdParty\nikic\PhpParser\Node\Attribute)) { throw new \LogicException('Attribute must be an instance of PhpParser\Node\Attribute or PhpParser\Node\AttributeGroup'); } - return new Node\AttributeGroup([$attribute]); + return new ncc\ThirdParty\nikic\PhpParser\Node\AttributeGroup([$attribute]); } /** * Adds a modifier and returns new modifier bitmask. * * @param int $modifiers Existing modifiers - * @param int $modifier Modifier to set + * @param int $modifier Modifier to set * * @return int New modifiers */ - public static function addModifier(int $modifiers, int $modifier) : int { - Stmt\Class_::verifyModifier($modifiers, $modifier); + public static function addModifier(int $modifiers, int $modifier): int { + Modifiers::verifyModifier($modifiers, $modifier); return $modifiers | $modifier; } @@ -328,8 +331,8 @@ final class BuilderHelpers * Adds a modifier and returns new modifier bitmask. * @return int New modifiers */ - public static function addClassModifier(int $existingModifiers, int $modifierToSet) : int { - Stmt\Class_::verifyClassModifier($existingModifiers, $modifierToSet); + public static function addClassModifier(int $existingModifiers, int $modifierToSet): int { + Modifiers::verifyClassModifier($existingModifiers, $modifierToSet); return $existingModifiers | $modifierToSet; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/CHANGELOG.md b/src/ncc/ThirdParty/nikic/PhpParser/CHANGELOG.md new file mode 100644 index 0000000..0fac7ac --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/CHANGELOG.md @@ -0,0 +1,1219 @@ +Version 5.2.0 (2024-09-15) +-------------------------- + +### Added + +* [8.4] Added support for `__PROPERTY__` magic constant, represented using a + `Node\Scalar\MagicConst\Property` node. +* [8.4] Added support for property hooks, which are represented using a new `hooks` subnode on + `Node\Stmt\Property` and `Node\Param`, which contains an array of `Node\PropertyHook`. +* [8.4] Added support for asymmetric visibility modifiers. Property `flags` can now hold the + additional bits `Modifiers::PUBLIC_SET`, `Modifiers::PROTECTED_SET` and `Modifiers::PRIVATE_SET`. +* [8.4] Added support for generalized exit function. For backwards compatibility, exit without + argument or a single plain argument continues to use a `Node\Expr\Exit_` node. Otherwise (e.g. + if a named argument is used) it will be represented as a plain `Node\Expr\FuncCall`. +* Added support for passing enum values to various builder methods, like `BuilderFactory::val()`. + +### Removed + +* Removed support for alternative array syntax `$array{0}` from the PHP 8 parser. It is still + supported by the PHP 7 parser. This is necessary in order to support property hooks. + +Version 5.1.0 (2024-07-01) +-------------------------- + +### Added + +* [8.4] Added support for dereferencing `new` expressions without parentheses. + +### Fixed + +* Fixed redundant parentheses being added when pretty printing ternary expressions. + +### Changed + +* Made some phpdoc types more precise. + +Version 5.0.2 (2024-03-05) +-------------------------- + +### Fixed + +* Fix handling of indentation on next line after opening PHP tag in formatting-preserving pretty +printer. + +### Changed + +* Avoid cyclic references in `Parser` objects. This means that no longer used parser objects are + immediately destroyed now, instead of requiring cycle GC. +* Update `PhpVersion::getNewestSupported()` to report PHP 8.3 instead of PHP 8.2. + +Version 5.0.1 (2024-02-21) +-------------------------- + +### Changed + +* Added check to detect use of PHP-Parser with libraries that define `T_*` compatibility tokens + with incorrect type (such as string instead of int). This would lead to `TypeError`s down the + line. Now an `Error` will be thrown early to indicate the problem. + +Version 5.0.0 (2024-01-07) +-------------------------- + +See UPGRADE-5.0 for detailed migration instructions. + +### Fixed + +* Fixed parent class of `PropertyItem` and `UseItem`. + +Version 5.0.0-rc1 (2023-12-20) +------------------------------ + +See UPGRADE-5.0 for detailed migration instructions. + +### Fixed + +* Fixed parsing of empty files. + +### Added + +* Added support for printing additional attributes (like `kind`) in `NodeDumper`. +* Added `rawValue` attribute to `InterpolatedStringPart` and heredoc/nowdoc `String_`s, which + provides the original, unparsed value. It was previously only available for non-interpolated + single/double quoted strings. +* Added `Stmt\Block` to represent `{}` code blocks. Previously, such code blocks were flattened + into the parent statements array. `Stmt\Block` will not be created for structures that are + typically used with code blocks, for example `if ($x) { $y; }` will be represented as previously, + while `if ($x) { { $x; } }` will have an extra `Stmt\Block` wrapper. + +### Changed + +* Use visitor to assign comments. This fixes the long-standing issue where comments were assigned + to all nodes sharing a starting position. Now only the outer-most node will hold the comments. +* Don't parse unicode escape sequences when targeting PHP < 7.0. +* Improve NodeDumper performance for large dumps. + +### Removed + +* Removed `Stmt\Throw_` node, use `Expr\Throw_` inside `Stmt\Expression` instead. +* Removed `ParserFactory::create()`. + +Version 5.0.0-beta1 (2023-09-17) +-------------------------------- + +See UPGRADE-5.0 for detailed migration instructions. + +### Added + +* Visitors can now be passed directly to the `NodeTraverser` constructor. A separate call to + `addVisitor()` is no longer required. + +### Changed + +* The minimum host PHP version is now PHP 7.4. It is still possible to parse code from older + versions. Property types have been added where possible. +* The `Lexer` no longer accepts options. `Lexer\Emulative` only accepts a `PhpVersion`. The + `startLexing()`, `getTokens()` and `handleHaltCompiler()` methods have been removed. Instead, + there is a single method `tokenize()` returning the tokens. +* The `Parser::getLexer()` method has been replaced by `Parser::getTokens()`. +* Attribute handling has been moved from the lexer to the parser, and is no longer configurable. + The comments, startLine, endLine, startTokenPos, endTokenPos, startFilePos, and endFilePos + attributes will always be added. +* The pretty printer now defaults to PHP 7.4 as the target version. +* The pretty printer now indents heredoc/nowdoc strings if the target version is >= 7.3 + (flexible heredoc/nowdoc). + +### Removed + +* The deprecated `Comment::getLine()`, `Comment::getTokenPos()` and `Comment::getFilePos()` methods + have been removed. Use `Comment::getStartLine()`, `Comment::getStartTokenPos()` and + `Comment::getStartFilePos()` instead. + +### Deprecated + +* The `Node::getLine()` method has been deprecated. Use `Node::getStartLine()` instead. + +Version 5.0.0-alpha3 (2023-06-24) +--------------------------------- + +See UPGRADE-5.0 for detailed migration instructions. + +### Added + +* [PHP 8.3] Added support for typed constants. +* [PHP 8.3] Added support for readonly anonymous classes. +* Added support for `NodeVisitor::REPLACE_WITH_NULL`. +* Added support for CRLF newlines in the pretty printer, using the new `newline` option. + +### Changed + +* Use PHP 7.1 as the default target version for the pretty printer. +* Print `else if { }` instead of `else { if { } }`. +* The `leaveNode()` method on visitors is now invoked in reverse order of `enterNode()`. +* Moved `NodeTraverser::REMOVE_NODE` etc. to `NodeVisitor::REMOVE_NODE`. The old constants are still + available for compatibility. +* The `Name` subnode `parts` has been replaced by `name`, which stores the name as a string rather + than an array of parts separated by namespace separators. The `getParts()` method returns the old + representation. +* No longer accept strings for types in Node constructors. Instead, either an `Identifier`, `Name` + or `ComplexType` must be passed. +* `Comment::getReformattedText()` now normalizes CRLF newlines to LF newlines. + +### Fixed + +* Don't trim leading whitespace in formatting preserving printer. +* Treat DEL as a label character in the formatting preserving printer depending on the targeted + PHP version. +* Fix error reporting in emulative lexer without explicitly specified error handler. +* Gracefully handle non-contiguous array indices in the `Differ`. + +Version 5.0.0-alpha2 (2023-03-05) +--------------------------------- + +See UPGRADE-5.0 for detailed migration instructions. + +### Added + +* [PHP 8.3] Added support for dynamic class constant fetch. +* Added many additional type annotations. PhpStan is now used. +* Added a fuzzing target for PHP-Fuzzer, which was how a lot of pretty printer bugs were found. +* Added `isPromoted()`, `isPublic()`, `isProtected()`, `isPrivate()` and `isReadonly()` methods + on `Param`. +* Added support for class constants in trait builder. +* Added `PrettyPrinter` interface. +* Added support for formatting preservation when toggling static modifiers. +* The `php-parse` binary now accepts `-` as the file name, in which case it will read from stdin. + +### Fixed + +* The pretty printer now uses a more accurate treatment of unary operator precedence, and will only + wrap them in parentheses if required. This allowed fixing a number of other precedence related + bugs. +* The pretty printer now respects the precedence of `clone`, `throw` and arrow functions. +* The pretty printer no longer unconditionally wraps `yield` in parentheses, unless the target + version is set to older than PHP 7.0. +* Fixed formatting preservation for alternative elseif/else syntax. +* Fixed checks for when it is safe to print strings as heredoc/nowdoc to accommodate flexible + doc string semantics. +* The pretty printer now prints parentheses around new/instanceof operands in all required + situations. +* Similar, differences in allowed expressions on the LHS of `->` and `::` are now taken into account. +* Fixed various cases where `\r` at the end of a doc string could be incorrectly merged into a CRLF + sequence with a following `\n`. +* `__halt_compiler` is no longer recognized as a semi-reserved keyword, in line with PHP behavior. +* ``. + +### Fixed + +* Multiple modifiers for promoted properties are now accepted. In particular this allows something + like `public readonly` for promoted properties. +* Formatting-preserving pretty printing for comments in array literals has been fixed. + +Version 4.12.0 (2021-07-21) +--------------------------- + +### Added + +* [PHP 8.1] Added support for readonly properties (through a new `MODIFIER_READONLY`). +* [PHP 8.1] Added support for final class constants. + +### Fixed + +* Fixed compatibility with PHP 8.1. `&` tokens are now canonicalized to the + `T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG` and `T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG` tokens + used in PHP 8.1. This happens unconditionally, regardless of whether the emulative lexer is used. + +Version 4.11.0 (2021-07-03) +--------------------------- + +### Added + +* `BuilderFactory::args()` now accepts named arguments. +* `BuilderFactory::attribute()` has been added. +* An `addAttribute()` method accepting an `Attribute` or `AttributeGroup` has been adde to all + builders that accept attributes, such as `Builder\Class_`. + +### Fixed + +* `NameResolver` now handles enums. +* `PrettyPrinter` now prints backing enum type. +* Builder methods for types now property handle `never` type. + +Version 4.10.5 (2021-05-03) +--------------------------- + +### Added + +* [PHP 8.1] Added support for enums. These are represented using the `Stmt\Enum_` and + `Stmt\EnumCase` nodes. +* [PHP 8.1] Added support for never type. This type will now be returned as an `Identifier` rather + than `Name`. +* Added `ClassConst` builder. + +### Changed + +* Non-UTF-8 code units in strings will now be hex-encoded. + +### Fixed + +* Fixed precedence of arrow functions. + +Version 4.10.4 (2020-12-20) +--------------------------- + +### Fixed + +* Fixed position information for variable-variables (#741). +* Fixed position information for traits/interfaces preceded by if statement (#738). + +Version 4.10.3 (2020-12-03) +--------------------------- + +### Fixed + +* Fixed formatting-preserving pretty printing for `"{$x}"`. +* Ternary expressions are now treated as non-associative in the pretty printer, in order to + generate code that is compatible with the parentheses requirement introduced in PHP 8. +* Removed no longer necessary `error_clear_last()` call in lexer, which may interfere with fatal + error handlers if invoked during shutdown. + + +Version 4.10.2 (2020-09-26) +------------------ + +### Fixed + +* Fixed check for token emulation conflicts with other libraries. + +Version 4.10.1 (2020-09-23) +--------------------------- + +### Added + +* Added support for recovering from a missing semicolon after a property or class constant + declaration. + +### Fixed + +* Fix spurious whitespace in formatting-preserving pretty printer when both removing and adding + elements at the start of a list. +* Fix incorrect case-sensitivity in keyword token emulation. + +Version 4.10.0 (2020-09-19) +--------------------------- + +### Added + +* [PHP 8.0] Added support for attributes. These are represented using a new `AttributeGroup` node + containing `Attribute` nodes. A new `attrGroups` subnode is available on all node types that + support attributes, i.e. `Stmt\Class_`, `Stmt\Trait_`, `Stmt\Interface_`, `Stmt\Function_`, + `Stmt\ClassMethod`, `Stmt\ClassConst`, `Stmt\Property`, `Expr\Closure`, `Expr\ArrowFunction` and + `Param`. +* [PHP 8.0] Added support for nullsafe properties inside interpolated strings, in line with an + upstream change. + +### Fixed + +* Improved compatibility with other libraries that use forward compatibility defines for PHP tokens. + +Version 4.9.1 (2020-08-30) +-------------------------- + +### Added + +* Added support for removing the first element of a list to the formatting-preserving pretty + printer. + +### Fixed + +* Allow member modifiers as part of namespaced names. These were missed when support for other + keywords was added. + +Version 4.9.0 (2020-08-18) +-------------------------- + +### Added + +* [PHP 8.0] Added support for named arguments, represented using a new `name` subnode on `Arg`. +* [PHP 8.0] Added support for static return type, represented like a normal class return type. +* [PHP 8.0] Added support for throw expression, represented using a new `Expr\Throw_` node. For + backwards compatibility reasons, throw expressions in statement context continue to be + represented using `Stmt\Throw_`. +* [PHP 8.0] Added support for keywords as parts of namespaced names. + +### Fixed + +* Emit parentheses for class constant fetch with complex left-hand-side. +* Emit parentheses for new/instanceof on complex class expression. + +Version 4.8.0 (2020-08-09) +-------------------------- + +### Added + +* [PHP 8.0] Added support for nullsafe operator, represented using the new + `Expr\NullsafePropertyFetch` and `Expr\NullsafeMethodCall` nodes. +* Added `phpVersion` option to the emulative lexer, which allows controlling the target version to + emulate (defaults to the latest available, currently PHP 8.0). This is useful to parse code that + uses reserved keywords from newer PHP versions as identifiers. + +Version 4.7.0 (2020-07-25) +-------------------------- + +### Added + +* Add `ParentConnectingVisitor` and `NodeConnectingVisitor` classes. +* [PHP 8.0] Added support for match expressions. These are represented using a new `Expr\Match_` + containing `MatchArm`s. +* [PHP 8.0] Added support for trailing comma in closure use lists. + +### Fixed + +* Fixed missing error for unterminated comment with trailing newline (#688). +* Compatibility with PHP 8.0 has been restored: Namespaced names are now always represented by + `T_NAME_*` tokens, using emulationg on older PHP versions. Full support for reserved keywords + in namespaced names is not yet present. + +Version 4.6.0 (2020-07-02) +-------------------------- + +### Added + +* [PHP 8.0] Added support for trailing commas in parameter lists. +* [PHP 8.0] Added support for constructor promotion. The parameter visibility is stored in + `Node\Param::$flags`. + +### Fixed + +* Comment tokens now always follow the PHP 8 interpretation, and do not include trailing + whitespace. +* As a result of the previous change, some whitespace issues when inserting a statement into a + method containing only a comment, and using the formatting-preserving pretty printer, have been + resolved. + +Version 4.5.0 (2020-06-03) +-------------------------- + +### Added + +* [PHP 8.0] Added support for the mixed type. This means `mixed` types are now parsed as an + `Identifier` rather than a `Name`. +* [PHP 8.0] Added support for catching without capturing the exception. This means that + `Catch_::$var` may now be null. + +Version 4.4.0 (2020-04-10) +-------------------------- + +### Added + +* Added support for passing union types in builders. +* Added end line, token position and file position information for comments. +* Added `getProperty()` method to `ClassLike` nodes. + +### Fixed + +* Fixed generation of invalid code when using the formatting preserving pretty printer, and + inserting code next to certain nop statements. The formatting is still ugly though. +* `getDocComment()` no longer requires that the very last comment before a node be a doc comment. + There may not be non-doc comments between the doc comment and the declaration. +* Allowed arbitrary expressions in `isset()` and `list()`, rather than just variables. + In particular, this allows `isset(($x))`, which is legal PHP code. +* [PHP 8.0] Add support for [variable syntax tweaks RFC](https://wiki.php.net/rfc/variable_syntax_tweaks). + +Version 4.3.0 (2019-11-08) +-------------------------- + +### Added + +* [PHP 8.0] Added support for union types using a new `UnionType` node. + +Version 4.2.5 (2019-10-25) +-------------------------- + +### Changed + +* Tests and documentation are no longer included in source archives. They can still be accessed + by cloning the repository. +* php-yacc is now used to generate the parser. This has no impact on users of the library. + +Version 4.2.4 (2019-09-01) +-------------------------- + +### Added + +* Added getProperties(), getConstants() and getTraitUses() to ClassLike. (#629, #630) + +### Fixed + +* Fixed flexible heredoc emulation to check for digits after the end label. This synchronizes + behavior with the upcoming PHP 7.3.10 release. + +Version 4.2.3 (2019-08-12) +-------------------------- + +### Added + +* [PHP 7.4] Add support for numeric literal separators. (#615) + +### Fixed + +* Fixed resolution of return types for arrow functions. (#613) +* Fixed compatibility with PHP 7.4. + +Version 4.2.2 (2019-05-25) +-------------------------- + +### Added + +* [PHP 7.4] Add support for arrow functions using a new `Expr\ArrowFunction` node. (#602) +* [PHP 7.4] Add support for array spreads, using a new `unpack` subnode on `ArrayItem`. (#609) +* Added support for inserting into empty list nodes in the formatting preserving pretty printer. + +### Changed + +* `php-parse` will now print messages to stderr, so that stdout only contains the actual result of + the operation (such as a JSON dump). (#605) + +### Fixed + +* Fixed attribute assignment for zero-length nop statements, and a related assertion failure in + the formatting-preserving pretty printer. (#589) + +Version 4.2.1 (2019-02-16) +-------------------------- + +### Added + +* [PHP 7.4] Add support for `??=` operator through a new `AssignOp\Coalesce` node. (#575) + +Version 4.2.0 (2019-01-12) +-------------------------- + +### Added + +* [PHP 7.4] Add support for typed properties through a new `type` subnode of `Stmt\Property`. + Additionally `Builder\Property` now has a `setType()` method. (#567) +* Add `kind` attribute to `Cast\Double_`, which allows to distinguish between `(float)`, + `(double)` and `(real)`. The form of the cast will be preserved by the pretty printer. (#565) + +### Fixed + +* Remove assertion when pretty printing anonymous class with a name (#554). + +Version 4.1.1 (2018-12-26) +-------------------------- + +### Fixed + +* Fix "undefined offset" notice when parsing specific malformed code (#551). + +### Added + +* Support error recovery for missing return type (`function foo() : {}`) (#544). + +Version 4.1.0 (2018-10-10) +-------------------------- + +### Added + +* Added support for PHP 7.3 flexible heredoc/nowdoc strings, completing support for PHP 7.3. There + are two caveats for this feature: + * In some rare, pathological cases flexible heredoc/nowdoc strings change the interpretation of + existing doc strings. PHP-Parser will now use the new interpretation. + * Flexible heredoc/nowdoc strings require special support from the lexer. Because this is not + available on PHP versions before 7.3, support has to be emulated. This emulation is not perfect + and some cases which we do not expect to occur in practice (such as flexible doc strings being + nested within each other through abuse of variable-variable interpolation syntax) may not be + recognized correctly. +* Added `DONT_TRAVERSE_CURRENT_AND_CHILDREN` to `NodeTraverser` to skip both traversal of child + nodes, and prevent subsequent visitors from visiting the current node. + +Version 4.0.4 (2018-09-18) +-------------------------- + +### Added + +* The following methods have been added to `BuilderFactory`: + * `useTrait()` (fluent builder) + * `traitUseAdaptation()` (fluent builder) + * `useFunction()` (fluent builder) + * `useConst()` (fluent builder) + * `var()` + * `propertyFetch()` + +### Deprecated + +* `Builder\Param::setTypeHint()` has been deprecated in favor of the newly introduced + `Builder\Param::setType()`. + +Version 4.0.3 (2018-07-15) +-------------------------- + +### Fixed + +* Fixed possible undefined offset notice in formatting-preserving printer. (#513) + +### Added + +* Improved error recovery inside arrays. +* Preserve trailing comment inside classes. **Note:** This change is possibly BC breaking if your + code validates that classes can only contain certain statement types. After this change, classes + can also contain Nop statements, while this was not previously possible. (#509) + +Version 4.0.2 (2018-06-03) +-------------------------- + +### Added + +* Improved error recovery inside classes. +* Support error recovery for `foreach` without `as`. +* Support error recovery for parameters without variable (`function (Type ) {}`). +* Support error recovery for functions without body (`function ($foo)`). + +Version 4.0.1 (2018-03-25) +-------------------------- + +### Added + +* [PHP 7.3] Added support for trailing commas in function calls. +* [PHP 7.3] Added support for by-reference array destructuring. +* Added checks to node traverser to prevent replacing a statement with an expression or vice versa. + This should prevent common mistakes in the implementation of node visitors. +* Added the following methods to `BuilderFactory`, to simplify creation of expressions: + * `funcCall()` + * `methodCall()` + * `staticCall()` + * `new()` + * `constFetch()` + * `classConstFetch()` + +Version 4.0.0 (2018-02-28) +-------------------------- + +* No significant code changes since the beta 1 release. + +Version 4.0.0-beta1 (2018-01-27) +-------------------------------- + +### Fixed + +* In formatting-preserving pretty printer: Fixed indentation when inserting into lists. (#466) + +### Added + +* In formatting-preserving pretty printer: Improved formatting of elements inserted into multi-line + arrays. + +### Removed + +* The `Autoloader` class has been removed. It is now required to use the Composer autoloader. + +Version 4.0.0-alpha3 (2017-12-26) +--------------------------------- + +### Fixed + +* In the formatting-preserving pretty printer: + * Fixed comment indentation. + * Fixed handling of inline HTML in the fallback case. + * Fixed insertion into list nodes that require creation of a code block. + +### Added + +* Added support for inserting at the start of list nodes in formatting-preserving pretty printer. + +Version 4.0.0-alpha2 (2017-11-10) +--------------------------------- + +### Added + +* In the formatting-preserving pretty printer: + * Added support for changing modifiers. + * Added support for anonymous classes. + * Added support for removing from list nodes. + * Improved support for changing comments. +* Added start token offsets to comments. + +Version 4.0.0-alpha1 (2017-10-18) +--------------------------------- + +### Added + +* Added experimental support for format-preserving pretty-printing. In this mode formatting will be + preserved for parts of the code which have not been modified. +* Added `replaceNodes` option to `NameResolver`, defaulting to true. If this option is disabled, + resolved names will be added as `resolvedName` attributes, instead of replacing the original + names. +* Added `NodeFinder` class, which can be used to find nodes based on a callback or class name. This + is a utility to avoid custom node visitor implementations for simple search operations. +* Added `ClassMethod::isMagic()` method. +* Added `BuilderFactory` methods: `val()` method for creating an AST for a simple value, `concat()` + for creating concatenation trees, `args()` for preparing function arguments. +* Added `NameContext` class, which encapsulates the `NameResolver` logic independently of the actual + AST traversal. This facilitates use in other context, such as class names in doc comments. + Additionally it provides an API for getting the shortest representation of a name. +* Added `Node::setAttributes()` method. +* Added `JsonDecoder`. This allows conversion JSON back into an AST. +* Added `Name` methods `toLowerString()` and `isSpecialClassName()`. +* Added `Identifier` and `VarLikeIdentifier` nodes, which are used in place of simple strings in + many places. +* Added `getComments()`, `getStartLine()`, `getEndLine()`, `getStartTokenPos()`, `getEndTokenPos()`, + `getStartFilePos()` and `getEndFilePos()` methods to `Node`. These provide a more obvious access + point for the already existing attributes of the same name. +* Added `ConstExprEvaluator` to evaluate constant expressions to PHP values. +* Added `Expr\BinaryOp::getOperatorSigil()`, returning `+` for `Expr\BinaryOp\Plus`, etc. + +### Changed + +* Many subnodes that previously held simple strings now use `Identifier` (or `VarLikeIdentifier`) + nodes. Please see the UPGRADE-4.0 file for an exhaustive list of affected nodes and some notes on + possible impact. +* Expression statements (`expr;`) are now represented using a `Stmt\Expression` node. Previously + these statements were directly represented as their constituent expression. +* The `name` subnode of `Param` has been renamed to `var` and now contains a `Variable` rather than + a plain string. +* The `name` subnode of `StaticVar` has been renamed to `var` and now contains a `Variable` rather + than a plain string. +* The `var` subnode of `ClosureUse` now contains a `Variable` rather than a plain string. +* The `var` subnode of `Catch` now contains a `Variable` rather than a plain string. +* The `alias` subnode of `UseUse` is now `null` if no explicit alias is given. As such, + `use Foo\Bar` and `use Foo\Bar as Bar` are now represented differently. The `getAlias()` method + can be used to get the effective alias, even if it is not explicitly given. + +### Removed + +* Support for running on PHP 5 and HHVM has been removed. You can however still parse code of old + PHP versions (such as PHP 5.2), while running on PHP 7. +* Removed `type` subnode on `Class`, `ClassMethod` and `Property` nodes. Use `flags` instead. +* The `ClassConst::isStatic()` method has been removed. Constants cannot have a static modifier. +* The `NodeTraverser` no longer accepts `false` as a return value from a `leaveNode()` method. + `NodeTraverser::REMOVE_NODE` should be returned instead. +* The `Node::setLine()` method has been removed. If you really need to, you can use `setAttribute()` + instead. +* The misspelled `Class_::VISIBILITY_MODIFER_MASK` constant has been dropped in favor of + `Class_::VISIBILITY_MODIFIER_MASK`. +* The XML serializer has been removed. As such, the classes `Serializer\XML`, and + `Unserializer\XML`, as well as the interfaces `Serializer` and `Unserializer` no longer exist. +* The `BuilderAbstract` class has been removed. It's functionality is moved into `BuilderHelpers`. + However, this is an internal class and should not be used directly. + +Version 3.1.5 (2018-02-28) +-------------------------- + +### Fixed + +* Fixed duplicate comment assignment in switch statements. (#469) +* Improve compatibility with PHP-Scoper. (#477) + +Version 3.1.4 (2018-01-25) +-------------------------- + +### Fixed + +* Fixed pretty printing of `-(-$x)` and `+(+$x)`. (#459) + +Version 3.1.3 (2017-12-26) +-------------------------- + +### Fixed + +* Improve compatibility with php-scoper, by supporting prefixed namespaces in + `NodeAbstract::getType()`. + +Version 3.1.2 (2017-11-04) +-------------------------- + +### Fixed + +* Comments on empty blocks are now preserved on a `Stmt\Nop` node. (#382) + +### Added + +* Added `kind` attribute for `Stmt\Namespace_` node, which is one of `KIND_SEMICOLON` or + `KIND_BRACED`. (#417) +* Added `setDocComment()` method to namespace builder. (#437) + +Version 3.1.1 (2017-09-02) +-------------------------- + +### Fixed + +* Fixed syntax error on comment after brace-style namespace declaration. (#412) +* Added support for TraitUse statements in trait builder. (#413) + +Version 3.1.0 (2017-07-28) +-------------------------- + +### Added + +* [PHP 7.2] Added support for trailing comma in group use statements. +* [PHP 7.2] Added support for `object` type. This means `object` types will now be represented as a + builtin type (a simple `"object"` string), rather than a class `Name`. + +### Fixed + +* Floating-point numbers are now printed correctly if the LC_NUMERIC locale uses a comma as decimal + separator. + +### Changed + +* `Name::$parts` is no longer deprecated. + +Version 3.0.6 (2017-06-28) +-------------------------- + +### Fixed + +* Fixed the spelling of `Class_::VISIBILITY_MODIFIER_MASK`. The previous spelling of + `Class_::VISIBILITY_MODIFER_MASK` is preserved for backwards compatibility. +* The pretty printing will now preserve comments inside array literals and function calls by + printing the array items / function arguments on separate lines. Array literals and functions that + do not contain comments are not affected. + +### Added + +* Added `Builder\Param::makeVariadic()`. + +### Deprecated + +* The `Node::setLine()` method has been deprecated. + +Version 3.0.5 (2017-03-05) +-------------------------- + +### Fixed + +* Name resolution of `NullableType`s is now performed earlier, so that a fully resolved signature is + available when a function is entered. (#360) +* `Error` nodes are now considered empty, while previously they extended until the token where the + error occurred. This made some nodes larger than expected. (#359) +* Fixed notices being thrown during error recovery in some situations. (#362) + +Version 3.0.4 (2017-02-10) +-------------------------- + +### Fixed + +* Fixed some extensibility issues in pretty printer (`pUseType()` is now public and `pPrec()` calls + into `p()`, instead of directly dispatching to the type-specific printing method). +* Fixed notice in `bin/php-parse` script. + +### Added + +* Error recovery from missing semicolons is now supported in more cases. +* Error recovery from trailing commas in positions where PHP does not support them is now supported. + +Version 3.0.3 (2017-02-03) +-------------------------- + +### Fixed + +* In `"$foo[0]"` the `0` is now parsed as an `LNumber` rather than `String`. (#325) +* Ensure integers and floats are always pretty printed preserving semantics, even if the particular + value can only be manually constructed. +* Throw a `LogicException` when trying to pretty-print an `Error` node. Previously this resulted in + an undefined method exception or fatal error. + +### Added + +* [PHP 7.1] Added support for negative interpolated offsets: `"$foo[-1]"` +* Added `preserveOriginalNames` option to `NameResolver`. If this option is enabled, an + `originalName` attribute, containing the unresolved name, will be added to each resolved name. +* Added `php-parse --with-positions` option, which dumps nodes with position information. + +### Deprecated + +* The XML serializer has been deprecated. In particular, the classes `Serializer\XML`, + `Unserializer\XML`, as well as the interfaces `Serializer` and `Unserializer` are deprecated. + +Version 3.0.2 (2016-12-06) +-------------------------- + +### Fixed + +* Fixed name resolution of nullable types. (#324) +* Fixed pretty-printing of nullable types. + +Version 3.0.1 (2016-12-01) +-------------------------- + +### Fixed + +* Fixed handling of nested `list()`s: If the nested list was unkeyed, it was directly included in + the list items. If it was keyed, it was wrapped in `ArrayItem`. Now nested `List_` nodes are + always wrapped in `ArrayItem`s. (#321) + +Version 3.0.0 (2016-11-30) +-------------------------- + +### Added + +* Added support for dumping node positions in the NodeDumper through the `dumpPositions` option. +* Added error recovery support for `$`, `new`, `Foo::`. + +Version 3.0.0-beta2 (2016-10-29) +-------------------------------- + +This release primarily improves our support for error recovery. + +### Added + +* Added `Node::setDocComment()` method. +* Added `Error::getMessageWithColumnInfo()` method. +* Added support for recovery from lexer errors. +* Added support for recovering from "special" errors (i.e. non-syntax parse errors). +* Added precise location information for lexer errors. +* Added `ErrorHandler` interface, and `ErrorHandler\Throwing` and `ErrorHandler\Collecting` as + specific implementations. These provide a general mechanism for handling error recovery. +* Added optional `ErrorHandler` argument to `Parser::parse()`, `Lexer::startLexing()` and + `NameResolver::__construct()`. +* The `NameResolver` now adds a `namespacedName` attribute on name nodes that cannot be statically + resolved (unqualified unaliased function or constant names in namespaces). + +### Fixed + +* Fixed attribute assignment for `GroupUse` prefix and variables in interpolated strings. + +### Changed + +* The constants on `NameTraverserInterface` have been moved into the `NameTraverser` class. +* Due to the error handling changes, the `Parser` interface and `Lexer` API have changed. +* The emulative lexer now directly postprocesses tokens, instead of using `~__EMU__~` sequences. + This changes the protected API of the lexer. +* The `Name::slice()` method now returns `null` for empty slices, previously `new Name([])` was + used. `Name::concat()` now also supports concatenation with `null`. + +### Removed + +* Removed `Name::append()` and `Name::prepend()`. These mutable methods have been superseded by + the immutable `Name::concat()`. +* Removed `Error::getRawLine()` and `Error::setRawLine()`. These methods have been superseded by + `Error::getStartLine()` and `Error::setStartLine()`. +* Removed support for node cloning in the `NodeTraverser`. +* Removed `$separator` argument from `Name::toString()`. +* Removed `throw_on_error` parser option and `Parser::getErrors()` method. Use the `ErrorHandler` + mechanism instead. + +Version 3.0.0-beta1 (2016-09-16) +-------------------------------- + +### Added + +* [7.1] Function/method and parameter builders now support PHP 7.1 type hints (void, iterable and + nullable types). +* Nodes and Comments now implement `JsonSerializable`. The node kind is stored in a `nodeType` + property. +* The `InlineHTML` node now has an `hasLeadingNewline` attribute, that specifies whether the + preceding closing tag contained a newline. The pretty printer honors this attribute. +* Partial parsing of `$obj->` (with missing property name) is now supported in error recovery mode. +* The error recovery mode is now exposed in the `php-parse` script through the `--with-recovery` + or `-r` flags. + +The following changes are also part of PHP-Parser 2.1.1: + +* The PHP 7 parser will now generate a parse error for `$var =& new Obj` assignments. +* Comments on free-standing code blocks will now be retained as comments on the first statement in + the code block. + +Version 3.0.0-alpha1 (2016-07-25) +--------------------------------- + +### Added + +* [7.1] Added support for `void` and `iterable` types. These will now be represented as strings + (instead of `Name` instances) similar to other builtin types. +* [7.1] Added support for class constant visibility. The `ClassConst` node now has a `flags` subnode + holding the visibility modifier, as well as `isPublic()`, `isProtected()` and `isPrivate()` + methods. The constructor changed to accept the additional subnode. +* [7.1] Added support for nullable types. These are represented using a new `NullableType` node + with a single `type` subnode. +* [7.1] Added support for short array destructuring syntax. This means that `Array` nodes may now + appear as the left-hand-side of assignments and foreach value targets. Additionally the array + items may now contain `null` values if elements are skipped. +* [7.1] Added support for keys in list() destructuring. The `List` subnode `vars` has been renamed + to `items` and now contains `ArrayItem`s instead of plain variables. +* [7.1] Added support for multi-catch. The `Catch` subnode `type` has been renamed to `types` and + is now an array of `Name`s. +* `Name::slice()` now supports lengths and negative offsets. This brings it in line with + `array_slice()` functionality. + +### Changed + +Due to PHP 7.1 support additions described above, the node structure changed as follows: + +* `void` and `iterable` types are now stored as strings if the PHP 7 parser is used. +* The `ClassConst` constructor changed to accept an additional `flags` subnode. +* The `Array` subnode `items` may now contain `null` elements (destructuring). +* The `List` subnode `vars` has been renamed to `items` and now contains `ArrayItem`s instead of + plain variables. +* The `Catch` subnode `type` has been renamed to `types` and is now an array of `Name`s. + +Additionally the following changes were made: + +* The `type` subnode on `Class`, `ClassMethod` and `Property` has been renamed to `flags`. The + `type` subnode has retained for backwards compatibility and is populated to the same value as + `flags`. However, writes to `type` will not update `flags`. +* The `TryCatch` subnode `finallyStmts` has been replaced with a `finally` subnode that holds an + explicit `Finally` node. This allows for more accurate attribute assignment. +* The `Trait` constructor now has the same form as the `Class` and `Interface` constructors: It + takes an array of subnodes. Unlike classes/interfaces, traits can only have a `stmts` subnode. +* The `NodeDumper` now prints class/method/property/constant modifiers, as well as the include and + use type in a textual representation, instead of only showing the number. +* All methods on `PrettyPrinter\Standard` are now protected. Previously most of them were public. + +### Removed + +* Removed support for running on PHP 5.4. It is however still possible to parse PHP 5.2-5.4 code + while running on a newer version. +* The deprecated `Comment::setLine()` and `Comment::setText()` methods have been removed. +* The deprecated `Name::set()`, `Name::setFirst()` and `Name::setLast()` methods have been removed. + +Version 2.1.1 (2016-09-16) +-------------------------- + +### Changed + +* The pretty printer will now escape all control characters in the range `\x00-\x1F` inside double + quoted strings. If no special escape sequence is available, an octal escape will be used. +* The quality of the error recovery has been improved. In particular unterminated expressions should + be handled more gracefully. +* The PHP 7 parser will now generate a parse error for `$var =& new Obj` assignments. +* Comments on free-standing code blocks will no be retained as comments on the first statement in + the code block. + +Version 2.1.0 (2016-04-19) +-------------------------- + +### Fixed + +* Properly support `B""` strings (with uppercase `B`) in a number of places. +* Fixed reformatting of indented parts in a certain non-standard comment style. + +### Added + +* Added `dumpComments` option to node dumper, to enable dumping of comments associated with nodes. +* Added `Stmt\Nop` node, that is used to collect comments located at the end of a block or at the + end of a file (without a following node with which they could otherwise be associated). +* Added `kind` attribute to `Expr\Exit` to distinguish between `exit` and `die`. +* Added `kind` attribute to `Scalar\LNumber` to distinguish between decimal, binary, octal and + hexadecimal numbers. +* Added `kind` attribute to `Expr\Array` to distinguish between `array()` and `[]`. +* Added `kind` attribute to `Scalar\String` and `Scalar\Encapsed` to distinguish between + single-quoted, double-quoted, heredoc and nowdoc string. +* Added `docLabel` attribute to `Scalar\String` and `Scalar\Encapsed`, if it is a heredoc or + nowdoc string. +* Added start file offset information to `Comment` nodes. +* Added `setReturnType()` method to function and method builders. +* Added `-h` and `--help` options to `php-parse` script. + +### Changed + +* Invalid octal literals now throw a parse error in PHP 7 mode. +* The pretty printer takes all the new attributes mentioned in the previous section into account. +* The protected `AbstractPrettyPrinter::pComments()` method no longer returns a trailing newline. +* The bundled autoloader supports library files being stored in a different directory than + `PhpParser` for easier downstream distribution. + +### Deprecated + +* The `Comment::setLine()` and `Comment::setText()` methods have been deprecated. Construct new + objects instead. + +### Removed + +* The internal (but public) method `Scalar\LNumber::parse()` has been removed. A non-internal + `LNumber::fromString()` method has been added instead. + +Version 2.0.1 (2016-02-28) +-------------------------- + +### Fixed + +* `declare() {}` and `declare();` are not semantically equivalent and will now result in different + ASTs. The format case will have an empty `stmts` array, while the latter will set `stmts` to + `null`. +* Magic constants are now supported as semi-reserved keywords. +* A shebang line like `#!/usr/bin/env php` is now allowed at the start of a namespaced file. + Previously this generated an exception. +* The `prettyPrintFile()` method will not strip a trailing `?>` from the raw data that follows a + `__halt_compiler()` statement. +* The `prettyPrintFile()` method will not strip an opening `slice()` which takes a subslice of a name. + +### Changed + +* `PhpParser\Parser` is now an interface, implemented by `Parser\Php5`, `Parser\Php7` and + `Parser\Multiple`. The `Multiple` parser will try multiple parsers, until one succeeds. +* Token constants are now defined on `PhpParser\Parser\Tokens` rather than `PhpParser\Parser`. +* The `Name->set()`, `Name->append()`, `Name->prepend()` and `Name->setFirst()` methods are + deprecated in favor of `Name::concat()` and `Name->slice()`. +* The `NodeTraverser` no longer clones nodes by default. The old behavior can be restored by + passing `true` to the constructor. +* The constructor for `Scalar` nodes no longer has a default value. E.g. `new LNumber()` should now + be written as `new LNumber(0)`. + +--- + +**This changelog only includes changes from the 2.0 series. For older changes see the +[1.x series changelog](https://github.com/nikic/PHP-Parser/blob/1.x/CHANGELOG.md) and the +[0.9 series changelog](https://github.com/nikic/PHP-Parser/blob/0.9/CHANGELOG.md).** diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Comment.php b/src/ncc/ThirdParty/nikic/PhpParser/Comment.php index 779b454..78f6b73 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Comment.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Comment.php @@ -2,23 +2,22 @@ namespace ncc\ThirdParty\nikic\PhpParser; -class Comment implements \JsonSerializable -{ - protected $text; - protected $startLine; - protected $startFilePos; - protected $startTokenPos; - protected $endLine; - protected $endFilePos; - protected $endTokenPos; +class Comment implements \JsonSerializable { + protected string $text; + protected int $startLine; + protected int $startFilePos; + protected int $startTokenPos; + protected int $endLine; + protected int $endFilePos; + protected int $endTokenPos; /** * Constructs a comment node. * - * @param string $text Comment text (including comment delimiters like /*) - * @param int $startLine Line number the comment started on - * @param int $startFilePos File offset the comment started on - * @param int $startTokenPos Token offset the comment started on + * @param string $text Comment text (including comment delimiters like /*) + * @param int $startLine Line number the comment started on + * @param int $startFilePos File offset the comment started on + * @param int $startTokenPos Token offset the comment started on */ public function __construct( string $text, @@ -39,7 +38,7 @@ class Comment implements \JsonSerializable * * @return string The comment text (including comment delimiters like /*) */ - public function getText() : string { + public function getText(): string { return $this->text; } @@ -47,8 +46,9 @@ class Comment implements \JsonSerializable * Gets the line number the comment started on. * * @return int Line number (or -1 if not available) + * @phpstan-return -1|positive-int */ - public function getStartLine() : int { + public function getStartLine(): int { return $this->startLine; } @@ -57,7 +57,7 @@ class Comment implements \JsonSerializable * * @return int File offset (or -1 if not available) */ - public function getStartFilePos() : int { + public function getStartFilePos(): int { return $this->startFilePos; } @@ -66,7 +66,7 @@ class Comment implements \JsonSerializable * * @return int Token offset (or -1 if not available) */ - public function getStartTokenPos() : int { + public function getStartTokenPos(): int { return $this->startTokenPos; } @@ -74,8 +74,9 @@ class Comment implements \JsonSerializable * Gets the line number the comment ends on. * * @return int Line number (or -1 if not available) + * @phpstan-return -1|positive-int */ - public function getEndLine() : int { + public function getEndLine(): int { return $this->endLine; } @@ -84,7 +85,7 @@ class Comment implements \JsonSerializable * * @return int File offset (or -1 if not available) */ - public function getEndFilePos() : int { + public function getEndFilePos(): int { return $this->endFilePos; } @@ -93,49 +94,16 @@ class Comment implements \JsonSerializable * * @return int Token offset (or -1 if not available) */ - public function getEndTokenPos() : int { + public function getEndTokenPos(): int { return $this->endTokenPos; } - /** - * Gets the line number the comment started on. - * - * @deprecated Use getStartLine() instead - * - * @return int Line number - */ - public function getLine() : int { - return $this->startLine; - } - - /** - * Gets the file offset the comment started on. - * - * @deprecated Use getStartFilePos() instead - * - * @return int File offset - */ - public function getFilePos() : int { - return $this->startFilePos; - } - - /** - * Gets the token offset the comment started on. - * - * @deprecated Use getStartTokenPos() instead - * - * @return int Token offset - */ - public function getTokenPos() : int { - return $this->startTokenPos; - } - /** * Gets the comment text. * * @return string The comment text (including comment delimiters like /*) */ - public function __toString() : string { + public function __toString(): string { return $this->text; } @@ -144,18 +112,19 @@ class Comment implements \JsonSerializable * * "Reformatted" here means that we try to clean up the whitespace at the * starts of the lines. This is necessary because we receive the comments - * without trailing whitespace on the first line, but with trailing whitespace + * without leading whitespace on the first line, but with leading whitespace * on all subsequent lines. * - * @return mixed|string + * Additionally, this normalizes CRLF newlines to LF newlines. */ - public function getReformattedText() { - $text = trim($this->text); + public function getReformattedText(): string { + $text = str_replace("\r\n", "\n", $this->text); $newlinePos = strpos($text, "\n"); if (false === $newlinePos) { // Single line comments don't need further processing return $text; - } elseif (preg_match('((*BSR_ANYCRLF)(*ANYCRLF)^.*(?:\R\s+\*.*)+$)', $text)) { + } + if (preg_match('(^.*(?:\n\s+\*.*)+$)', $text)) { // Multi line comment of the type // // /* @@ -164,8 +133,9 @@ class Comment implements \JsonSerializable // */ // // is handled by replacing the whitespace sequences before the * by a single space - return preg_replace('(^\s+\*)m', ' *', $this->text); - } elseif (preg_match('(^/\*\*?\s*[\r\n])', $text) && preg_match('(\n(\s*)\*/$)', $text, $matches)) { + return preg_replace('(^\s+\*)m', ' *', $text); + } + if (preg_match('(^/\*\*?\s*\n)', $text) && preg_match('(\n(\s*)\*/$)', $text, $matches)) { // Multi line comment of the type // // /* @@ -177,7 +147,8 @@ class Comment implements \JsonSerializable // */ on all lines. So if the last line is " */", then " " is removed at the // start of all lines. return preg_replace('(^' . preg_quote($matches[1]) . ')m', '', $text); - } elseif (preg_match('(^/\*\*?\s*(?!\s))', $text, $matches)) { + } + if (preg_match('(^/\*\*?\s*(?!\s))', $text, $matches)) { // Multi line comment of the type // // /* Some text. @@ -204,9 +175,9 @@ class Comment implements \JsonSerializable * @param string $str String to check * @return int Length in characters. Tabs count as single characters. */ - private function getShortestWhitespacePrefixLen(string $str) : int { + private function getShortestWhitespacePrefixLen(string $str): int { $lines = explode("\n", $str); - $shortestPrefixLen = \INF; + $shortestPrefixLen = \PHP_INT_MAX; foreach ($lines as $line) { preg_match('(^\s*)', $line, $matches); $prefixLen = strlen($matches[0]); @@ -218,10 +189,9 @@ class Comment implements \JsonSerializable } /** - * @return array - * @psalm-return array{nodeType:string, text:mixed, line:mixed, filePos:mixed} + * @return array{nodeType:string, text:mixed, line:mixed, filePos:mixed} */ - public function jsonSerialize() : array { + public function jsonSerialize(): array { // Technically not a node, but we make it look like one anyway $type = $this instanceof Comment\Doc ? 'Comment_Doc' : 'Comment'; return [ diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Comment/Doc.php b/src/ncc/ThirdParty/nikic/PhpParser/Comment/Doc.php index a41d0c4..06e4f53 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Comment/Doc.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Comment/Doc.php @@ -2,6 +2,5 @@ namespace ncc\ThirdParty\nikic\PhpParser\Comment; -class Doc extends \ncc\ThirdParty\nikic\PhpParser\Comment -{ +class Doc extends \ncc\ThirdParty\nikic\PhpParser\Comment { } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/ConstExprEvaluationException.php b/src/ncc/ThirdParty/nikic/PhpParser/ConstExprEvaluationException.php index 1b272b0..88e5761 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/ConstExprEvaluationException.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/ConstExprEvaluationException.php @@ -1,6 +1,6 @@ -fallbackEvaluator = $fallbackEvaluator ?? function(Expr $expr) { + public function __construct(?callable $fallbackEvaluator = null) { + $this->fallbackEvaluator = $fallbackEvaluator ?? function (Expr $expr) { throw new ConstExprEvaluationException( "Expression of type {$expr->getType()} cannot be evaluated" ); @@ -63,7 +64,7 @@ class ConstExprEvaluator * @throws ConstExprEvaluationException if the expression cannot be evaluated or an error occurred */ public function evaluateSilently(Expr $expr) { - set_error_handler(function($num, $str, $file, $line) { + set_error_handler(function ($num, $str, $file, $line) { throw new \ErrorException($str, 0, $num, $file, $line); }); @@ -101,9 +102,10 @@ class ConstExprEvaluator return $this->evaluate($expr); } + /** @return mixed */ private function evaluate(Expr $expr) { - if ($expr instanceof Scalar\LNumber - || $expr instanceof Scalar\DNumber + if ($expr instanceof Scalar\Int_ + || $expr instanceof Scalar\Float_ || $expr instanceof Scalar\String_ ) { return $expr->value; @@ -146,7 +148,7 @@ class ConstExprEvaluator return ($this->fallbackEvaluator)($expr); } - private function evaluateArray(Expr\Array_ $expr) { + private function evaluateArray(Expr\Array_ $expr): array { $array = []; foreach ($expr->items as $item) { if (null !== $item->key) { @@ -160,6 +162,7 @@ class ConstExprEvaluator return $array; } + /** @return mixed */ private function evaluateTernary(Expr\Ternary $expr) { if (null === $expr->if) { return $this->evaluate($expr->cond) ?: $this->evaluate($expr->else); @@ -170,6 +173,7 @@ class ConstExprEvaluator : $this->evaluate($expr->else); } + /** @return mixed */ private function evaluateBinaryOp(Expr\BinaryOp $expr) { if ($expr instanceof Expr\BinaryOp\Coalesce && $expr->left instanceof Expr\ArrayDimFetch @@ -216,6 +220,7 @@ class ConstExprEvaluator throw new \Exception('Should not happen'); } + /** @return mixed */ private function evaluateConstFetch(Expr\ConstFetch $expr) { $name = $expr->name->toLowerString(); switch ($name) { diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Error.php b/src/ncc/ThirdParty/nikic/PhpParser/Error.php index 4120d4e..4a71915 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Error.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Error.php @@ -2,25 +2,20 @@ namespace ncc\ThirdParty\nikic\PhpParser; -class Error extends \RuntimeException -{ - protected $rawMessage; - protected $attributes; +class Error extends \RuntimeException { + protected string $rawMessage; + /** @var array */ + protected array $attributes; /** * Creates an Exception signifying a parse error. * - * @param string $message Error message - * @param array|int $attributes Attributes of node/token where error occurred - * (or start line of error -- deprecated) + * @param string $message Error message + * @param array $attributes Attributes of node/token where error occurred */ - public function __construct(string $message, $attributes = []) { + public function __construct(string $message, array $attributes = []) { $this->rawMessage = $message; - if (is_array($attributes)) { - $this->attributes = $attributes; - } else { - $this->attributes = ['startLine' => $attributes]; - } + $this->attributes = $attributes; $this->updateMessage(); } @@ -29,7 +24,7 @@ class Error extends \RuntimeException * * @return string Error message */ - public function getRawMessage() : string { + public function getRawMessage(): string { return $this->rawMessage; } @@ -37,8 +32,9 @@ class Error extends \RuntimeException * Gets the line the error starts in. * * @return int Error start line + * @phpstan-return -1|positive-int */ - public function getStartLine() : int { + public function getStartLine(): int { return $this->attributes['startLine'] ?? -1; } @@ -46,26 +42,27 @@ class Error extends \RuntimeException * Gets the line the error ends in. * * @return int Error end line + * @phpstan-return -1|positive-int */ - public function getEndLine() : int { + public function getEndLine(): int { return $this->attributes['endLine'] ?? -1; } /** * Gets the attributes of the node/token the error occurred at. * - * @return array + * @return array */ - public function getAttributes() : array { + public function getAttributes(): array { return $this->attributes; } /** * Sets the attributes of the node/token the error occurred at. * - * @param array $attributes + * @param array $attributes */ - public function setAttributes(array $attributes) { + public function setAttributes(array $attributes): void { $this->attributes = $attributes; $this->updateMessage(); } @@ -75,7 +72,7 @@ class Error extends \RuntimeException * * @param string $message Error message */ - public function setRawMessage(string $message) { + public function setRawMessage(string $message): void { $this->rawMessage = $message; $this->updateMessage(); } @@ -85,7 +82,7 @@ class Error extends \RuntimeException * * @param int $line Error start line */ - public function setStartLine(int $line) { + public function setStartLine(int $line): void { $this->attributes['startLine'] = $line; $this->updateMessage(); } @@ -94,10 +91,8 @@ class Error extends \RuntimeException * Returns whether the error has start and end column information. * * For column information enable the startFilePos and endFilePos in the lexer options. - * - * @return bool */ - public function hasColumnInfo() : bool { + public function hasColumnInfo(): bool { return isset($this->attributes['startFilePos'], $this->attributes['endFilePos']); } @@ -105,9 +100,8 @@ class Error extends \RuntimeException * Gets the start column (1-based) into the line where the error started. * * @param string $code Source code of the file - * @return int */ - public function getStartColumn(string $code) : int { + public function getStartColumn(string $code): int { if (!$this->hasColumnInfo()) { throw new \RuntimeException('Error does not have column information'); } @@ -119,9 +113,8 @@ class Error extends \RuntimeException * Gets the end column (1-based) into the line where the error ended. * * @param string $code Source code of the file - * @return int */ - public function getEndColumn(string $code) : int { + public function getEndColumn(string $code): int { if (!$this->hasColumnInfo()) { throw new \RuntimeException('Error does not have column information'); } @@ -136,7 +129,7 @@ class Error extends \RuntimeException * * @return string Formatted message */ - public function getMessageWithColumnInfo(string $code) : string { + public function getMessageWithColumnInfo(string $code): string { return sprintf( '%s from %d:%d to %d:%d', $this->getRawMessage(), $this->getStartLine(), $this->getStartColumn($code), @@ -148,11 +141,11 @@ class Error extends \RuntimeException * Converts a file offset into a column. * * @param string $code Source code that $pos indexes into - * @param int $pos 0-based position in $code + * @param int $pos 0-based position in $code * * @return int 1-based column (relative to start of line) */ - private function toColumn(string $code, int $pos) : int { + private function toColumn(string $code, int $pos): int { if ($pos > strlen($code)) { throw new \RuntimeException('Invalid position information'); } @@ -168,7 +161,7 @@ class Error extends \RuntimeException /** * Updates the exception message after a change to rawMessage or rawLine. */ - protected function updateMessage() { + protected function updateMessage(): void { $this->message = $this->rawMessage; if (-1 === $this->getStartLine()) { diff --git a/src/ncc/ThirdParty/nikic/PhpParser/ErrorHandler.php b/src/ncc/ThirdParty/nikic/PhpParser/ErrorHandler.php index 4c2b5ac..3a6e81a 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/ErrorHandler.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/ErrorHandler.php @@ -2,12 +2,11 @@ namespace ncc\ThirdParty\nikic\PhpParser; -interface ErrorHandler -{ +interface ErrorHandler { /** * Handle an error generated during lexing, parsing or some other operation. * * @param Error $error The error that needs to be handled */ - public function handleError(Error $error); + public function handleError(Error $error): void; } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/ErrorHandler/Collecting.php b/src/ncc/ThirdParty/nikic/PhpParser/ErrorHandler/Collecting.php index 7a98208..944d306 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/ErrorHandler/Collecting.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/ErrorHandler/Collecting.php @@ -10,12 +10,11 @@ use ncc\ThirdParty\nikic\PhpParser\ErrorHandler; * * This allows graceful handling of errors. */ -class Collecting implements ErrorHandler -{ +class Collecting implements ErrorHandler { /** @var Error[] Collected errors */ - private $errors = []; + private array $errors = []; - public function handleError(Error $error) { + public function handleError(Error $error): void { $this->errors[] = $error; } @@ -24,23 +23,21 @@ class Collecting implements ErrorHandler * * @return Error[] */ - public function getErrors() : array { + public function getErrors(): array { return $this->errors; } /** * Check whether there are any errors. - * - * @return bool */ - public function hasErrors() : bool { + public function hasErrors(): bool { return !empty($this->errors); } /** * Reset/clear collected errors. */ - public function clearErrors() { + public function clearErrors(): void { $this->errors = []; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/ErrorHandler/Throwing.php b/src/ncc/ThirdParty/nikic/PhpParser/ErrorHandler/Throwing.php index dedd176..a32b2f6 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/ErrorHandler/Throwing.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/ErrorHandler/Throwing.php @@ -10,9 +10,8 @@ use ncc\ThirdParty\nikic\PhpParser\ErrorHandler; * * This is the default strategy used by all components. */ -class Throwing implements ErrorHandler -{ - public function handleError(Error $error) { +class Throwing implements ErrorHandler { + public function handleError(Error $error): void { throw $error; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Internal/DiffElem.php b/src/ncc/ThirdParty/nikic/PhpParser/Internal/DiffElem.php index 1049b16..5980999 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Internal/DiffElem.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Internal/DiffElem.php @@ -5,20 +5,24 @@ namespace ncc\ThirdParty\nikic\PhpParser\Internal; /** * @internal */ -class DiffElem -{ - const TYPE_KEEP = 0; - const TYPE_REMOVE = 1; - const TYPE_ADD = 2; - const TYPE_REPLACE = 3; +class DiffElem { + public const TYPE_KEEP = 0; + public const TYPE_REMOVE = 1; + public const TYPE_ADD = 2; + public const TYPE_REPLACE = 3; /** @var int One of the TYPE_* constants */ - public $type; + public int $type; /** @var mixed Is null for add operations */ public $old; /** @var mixed Is null for remove operations */ public $new; + /** + * @param int $type One of the TYPE_* constants + * @param mixed $old Is null for add operations + * @param mixed $new Is null for remove operations + */ public function __construct(int $type, $old, $new) { $this->type = $type; $this->old = $old; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Internal/Differ.php b/src/ncc/ThirdParty/nikic/PhpParser/Internal/Differ.php index 76c205d..87062ff 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Internal/Differ.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Internal/Differ.php @@ -8,16 +8,17 @@ namespace ncc\ThirdParty\nikic\PhpParser\Internal; * Myers, Eugene W. "An O (ND) difference algorithm and its variations." * Algorithmica 1.1 (1986): 251-266. * + * @template T * @internal */ -class Differ -{ +class Differ { + /** @var callable(T, T): bool */ private $isEqual; /** * Create differ over the given equality relation. * - * @param callable $isEqual Equality relation with signature function($a, $b) : bool + * @param callable(T, T): bool $isEqual Equality relation */ public function __construct(callable $isEqual) { $this->isEqual = $isEqual; @@ -26,12 +27,14 @@ class Differ /** * Calculate diff (edit script) from $old to $new. * - * @param array $old Original array - * @param array $new New array + * @param T[] $old Original array + * @param T[] $new New array * * @return DiffElem[] Diff (edit script) */ - public function diff(array $old, array $new) { + public function diff(array $old, array $new): array { + $old = \array_values($old); + $new = \array_values($new); list($trace, $x, $y) = $this->calculateTrace($old, $new); return $this->extractDiff($trace, $x, $y, $old, $new); } @@ -42,32 +45,37 @@ class Differ * If a sequence of remove operations is followed by the same number of add operations, these * will be coalesced into replace operations. * - * @param array $old Original array - * @param array $new New array + * @param T[] $old Original array + * @param T[] $new New array * * @return DiffElem[] Diff (edit script), including replace operations */ - public function diffWithReplacements(array $old, array $new) { + public function diffWithReplacements(array $old, array $new): array { return $this->coalesceReplacements($this->diff($old, $new)); } - private function calculateTrace(array $a, array $b) { - $n = \count($a); - $m = \count($b); + /** + * @param T[] $old + * @param T[] $new + * @return array{array>, int, int} + */ + private function calculateTrace(array $old, array $new): array { + $n = \count($old); + $m = \count($new); $max = $n + $m; $v = [1 => 0]; $trace = []; for ($d = 0; $d <= $max; $d++) { $trace[] = $v; for ($k = -$d; $k <= $d; $k += 2) { - if ($k === -$d || ($k !== $d && $v[$k-1] < $v[$k+1])) { - $x = $v[$k+1]; + if ($k === -$d || ($k !== $d && $v[$k - 1] < $v[$k + 1])) { + $x = $v[$k + 1]; } else { - $x = $v[$k-1] + 1; + $x = $v[$k - 1] + 1; } $y = $x - $k; - while ($x < $n && $y < $m && ($this->isEqual)($a[$x], $b[$y])) { + while ($x < $n && $y < $m && ($this->isEqual)($old[$x], $new[$y])) { $x++; $y++; } @@ -81,13 +89,19 @@ class Differ throw new \Exception('Should not happen'); } - private function extractDiff(array $trace, int $x, int $y, array $a, array $b) { + /** + * @param array> $trace + * @param T[] $old + * @param T[] $new + * @return DiffElem[] + */ + private function extractDiff(array $trace, int $x, int $y, array $old, array $new): array { $result = []; for ($d = \count($trace) - 1; $d >= 0; $d--) { $v = $trace[$d]; $k = $x - $y; - if ($k === -$d || ($k !== $d && $v[$k-1] < $v[$k+1])) { + if ($k === -$d || ($k !== $d && $v[$k - 1] < $v[$k + 1])) { $prevK = $k + 1; } else { $prevK = $k - 1; @@ -97,7 +111,7 @@ class Differ $prevY = $prevX - $prevK; while ($x > $prevX && $y > $prevY) { - $result[] = new DiffElem(DiffElem::TYPE_KEEP, $a[$x-1], $b[$y-1]); + $result[] = new DiffElem(DiffElem::TYPE_KEEP, $old[$x - 1], $new[$y - 1]); $x--; $y--; } @@ -107,12 +121,12 @@ class Differ } while ($x > $prevX) { - $result[] = new DiffElem(DiffElem::TYPE_REMOVE, $a[$x-1], null); + $result[] = new DiffElem(DiffElem::TYPE_REMOVE, $old[$x - 1], null); $x--; } while ($y > $prevY) { - $result[] = new DiffElem(DiffElem::TYPE_ADD, null, $b[$y-1]); + $result[] = new DiffElem(DiffElem::TYPE_ADD, null, $new[$y - 1]); $y--; } } @@ -125,7 +139,7 @@ class Differ * @param DiffElem[] $diff * @return DiffElem[] */ - private function coalesceReplacements(array $diff) { + private function coalesceReplacements(array $diff): array { $newDiff = []; $c = \count($diff); for ($i = 0; $i < $c; $i++) { diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Internal/PrintableNewAnonClassNode.php b/src/ncc/ThirdParty/nikic/PhpParser/Internal/PrintableNewAnonClassNode.php index 684e8e2..ca89935 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Internal/PrintableNewAnonClassNode.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Internal/PrintableNewAnonClassNode.php @@ -15,23 +15,30 @@ use ncc\ThirdParty\nikic\PhpParser\Node\Expr; * * @internal */ -class PrintableNewAnonClassNode extends Expr -{ +class PrintableNewAnonClassNode extends Expr { /** @var Node\AttributeGroup[] PHP attribute groups */ - public $attrGroups; + public array $attrGroups; /** @var int Modifiers */ - public $flags; - /** @var Node\Arg[] Arguments */ - public $args; + public int $flags; + /** @var (Node\Arg|Node\VariadicPlaceholder)[] Arguments */ + public array $args; /** @var null|Node\Name Name of extended class */ - public $extends; + public ?Node\Name $extends; /** @var Node\Name[] Names of implemented interfaces */ - public $implements; + public array $implements; /** @var Node\Stmt[] Statements */ - public $stmts; + public array $stmts; + /** + * @param Node\AttributeGroup[] $attrGroups PHP attribute groups + * @param (Node\Arg|Node\VariadicPlaceholder)[] $args Arguments + * @param Node\Name|null $extends Name of extended class + * @param Node\Name[] $implements Names of implemented interfaces + * @param Node\Stmt[] $stmts Statements + * @param array $attributes Attributes + */ public function __construct( - array $attrGroups, int $flags, array $args, Node\Name $extends = null, array $implements, + array $attrGroups, int $flags, array $args, ?Node\Name $extends, array $implements, array $stmts, array $attributes ) { parent::__construct($attributes); @@ -43,7 +50,7 @@ class PrintableNewAnonClassNode extends Expr $this->stmts = $stmts; } - public static function fromNewNode(Expr\New_ $newNode) { + public static function fromNewNode(Expr\New_ $newNode): self { $class = $newNode->class; assert($class instanceof Node\Stmt\Class_); // We don't assert that $class->name is null here, to allow consumers to assign unique names @@ -54,11 +61,11 @@ class PrintableNewAnonClassNode extends Expr ); } - public function getType() : string { + public function getType(): string { return 'Expr_PrintableNewAnonClass'; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['attrGroups', 'flags', 'args', 'extends', 'implements', 'stmts']; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Internal/TokenPolyfill.php b/src/ncc/ThirdParty/nikic/PhpParser/Internal/TokenPolyfill.php new file mode 100644 index 0000000..256cd8e --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/Internal/TokenPolyfill.php @@ -0,0 +1,237 @@ += 80000) { + class TokenPolyfill extends \PhpToken { + } + return; +} + +/** + * This is a polyfill for the PhpToken class introduced in PHP 8.0. We do not actually polyfill + * PhpToken, because composer might end up picking a different polyfill implementation, which does + * not meet our requirements. + * + * @internal + */ +class TokenPolyfill { + /** @var int The ID of the token. Either a T_* constant of a character code < 256. */ + public int $id; + /** @var string The textual content of the token. */ + public string $text; + /** @var int The 1-based starting line of the token (or -1 if unknown). */ + public int $line; + /** @var int The 0-based starting position of the token (or -1 if unknown). */ + public int $pos; + + /** @var array Tokens ignored by the PHP parser. */ + private const IGNORABLE_TOKENS = [ + \T_WHITESPACE => true, + \T_COMMENT => true, + \T_DOC_COMMENT => true, + \T_OPEN_TAG => true, + ]; + + /** @var array Tokens that may be part of a T_NAME_* identifier. */ + private static array $identifierTokens; + + /** + * Create a Token with the given ID and text, as well optional line and position information. + */ + final public function __construct(int $id, string $text, int $line = -1, int $pos = -1) { + $this->id = $id; + $this->text = $text; + $this->line = $line; + $this->pos = $pos; + } + + /** + * Get the name of the token. For single-char tokens this will be the token character. + * Otherwise it will be a T_* style name, or null if the token ID is unknown. + */ + public function getTokenName(): ?string { + if ($this->id < 256) { + return \chr($this->id); + } + + $name = token_name($this->id); + return $name === 'UNKNOWN' ? null : $name; + } + + /** + * Check whether the token is of the given kind. The kind may be either an integer that matches + * the token ID, a string that matches the token text, or an array of integers/strings. In the + * latter case, the function returns true if any of the kinds in the array match. + * + * @param int|string|(int|string)[] $kind + */ + public function is($kind): bool { + if (\is_int($kind)) { + return $this->id === $kind; + } + if (\is_string($kind)) { + return $this->text === $kind; + } + if (\is_array($kind)) { + foreach ($kind as $entry) { + if (\is_int($entry)) { + if ($this->id === $entry) { + return true; + } + } elseif (\is_string($entry)) { + if ($this->text === $entry) { + return true; + } + } else { + throw new \TypeError( + 'Argument #1 ($kind) must only have elements of type string|int, ' . + gettype($entry) . ' given'); + } + } + return false; + } + throw new \TypeError( + 'Argument #1 ($kind) must be of type string|int|array, ' .gettype($kind) . ' given'); + } + + /** + * Check whether this token would be ignored by the PHP parser. Returns true for T_WHITESPACE, + * T_COMMENT, T_DOC_COMMENT and T_OPEN_TAG, and false for everything else. + */ + public function isIgnorable(): bool { + return isset(self::IGNORABLE_TOKENS[$this->id]); + } + + /** + * Return the textual content of the token. + */ + public function __toString(): string { + return $this->text; + } + + /** + * Tokenize the given source code and return an array of tokens. + * + * This performs certain canonicalizations to match the PHP 8.0 token format: + * * Bad characters are represented using T_BAD_CHARACTER rather than omitted. + * * T_COMMENT does not include trailing newlines, instead the newline is part of a following + * T_WHITESPACE token. + * * Namespaced names are represented using T_NAME_* tokens. + * + * @return static[] + */ + public static function tokenize(string $code, int $flags = 0): array { + self::init(); + + $tokens = []; + $line = 1; + $pos = 0; + $origTokens = \token_get_all($code, $flags); + + $numTokens = \count($origTokens); + for ($i = 0; $i < $numTokens; $i++) { + $token = $origTokens[$i]; + if (\is_string($token)) { + if (\strlen($token) === 2) { + // b" and B" are tokenized as single-char tokens, even though they aren't. + $tokens[] = new static(\ord('"'), $token, $line, $pos); + $pos += 2; + } else { + $tokens[] = new static(\ord($token), $token, $line, $pos); + $pos++; + } + } else { + $id = $token[0]; + $text = $token[1]; + + // Emulate PHP 8.0 comment format, which does not include trailing whitespace anymore. + if ($id === \T_COMMENT && \substr($text, 0, 2) !== '/*' && + \preg_match('/(\r\n|\n|\r)$/D', $text, $matches) + ) { + $trailingNewline = $matches[0]; + $text = \substr($text, 0, -\strlen($trailingNewline)); + $tokens[] = new static($id, $text, $line, $pos); + $pos += \strlen($text); + + if ($i + 1 < $numTokens && $origTokens[$i + 1][0] === \T_WHITESPACE) { + // Move trailing newline into following T_WHITESPACE token, if it already exists. + $origTokens[$i + 1][1] = $trailingNewline . $origTokens[$i + 1][1]; + $origTokens[$i + 1][2]--; + } else { + // Otherwise, we need to create a new T_WHITESPACE token. + $tokens[] = new static(\T_WHITESPACE, $trailingNewline, $line, $pos); + $line++; + $pos += \strlen($trailingNewline); + } + continue; + } + + // Emulate PHP 8.0 T_NAME_* tokens, by combining sequences of T_NS_SEPARATOR and + // T_STRING into a single token. + if (($id === \T_NS_SEPARATOR || isset(self::$identifierTokens[$id]))) { + $newText = $text; + $lastWasSeparator = $id === \T_NS_SEPARATOR; + for ($j = $i + 1; $j < $numTokens; $j++) { + if ($lastWasSeparator) { + if (!isset(self::$identifierTokens[$origTokens[$j][0]])) { + break; + } + $lastWasSeparator = false; + } else { + if ($origTokens[$j][0] !== \T_NS_SEPARATOR) { + break; + } + $lastWasSeparator = true; + } + $newText .= $origTokens[$j][1]; + } + if ($lastWasSeparator) { + // Trailing separator is not part of the name. + $j--; + $newText = \substr($newText, 0, -1); + } + if ($j > $i + 1) { + if ($id === \T_NS_SEPARATOR) { + $id = \T_NAME_FULLY_QUALIFIED; + } elseif ($id === \T_NAMESPACE) { + $id = \T_NAME_RELATIVE; + } else { + $id = \T_NAME_QUALIFIED; + } + $tokens[] = new static($id, $newText, $line, $pos); + $pos += \strlen($newText); + $i = $j - 1; + continue; + } + } + + $tokens[] = new static($id, $text, $line, $pos); + $line += \substr_count($text, "\n"); + $pos += \strlen($text); + } + } + return $tokens; + } + + /** Initialize private static state needed by tokenize(). */ + private static function init(): void { + if (isset(self::$identifierTokens)) { + return; + } + + // Based on semi_reserved production. + self::$identifierTokens = \array_fill_keys([ + \T_STRING, + \T_STATIC, \T_ABSTRACT, \T_FINAL, \T_PRIVATE, \T_PROTECTED, \T_PUBLIC, \T_READONLY, + \T_INCLUDE, \T_INCLUDE_ONCE, \T_EVAL, \T_REQUIRE, \T_REQUIRE_ONCE, \T_LOGICAL_OR, \T_LOGICAL_XOR, \T_LOGICAL_AND, + \T_INSTANCEOF, \T_NEW, \T_CLONE, \T_EXIT, \T_IF, \T_ELSEIF, \T_ELSE, \T_ENDIF, \T_ECHO, \T_DO, \T_WHILE, + \T_ENDWHILE, \T_FOR, \T_ENDFOR, \T_FOREACH, \T_ENDFOREACH, \T_DECLARE, \T_ENDDECLARE, \T_AS, \T_TRY, \T_CATCH, + \T_FINALLY, \T_THROW, \T_USE, \T_INSTEADOF, \T_GLOBAL, \T_VAR, \T_UNSET, \T_ISSET, \T_EMPTY, \T_CONTINUE, \T_GOTO, + \T_FUNCTION, \T_CONST, \T_RETURN, \T_PRINT, \T_YIELD, \T_LIST, \T_SWITCH, \T_ENDSWITCH, \T_CASE, \T_DEFAULT, + \T_BREAK, \T_ARRAY, \T_CALLABLE, \T_EXTENDS, \T_IMPLEMENTS, \T_NAMESPACE, \T_TRAIT, \T_INTERFACE, \T_CLASS, + \T_CLASS_C, \T_TRAIT_C, \T_FUNC_C, \T_METHOD_C, \T_LINE, \T_FILE, \T_DIR, \T_NS_C, \T_HALT_COMPILER, \T_FN, + \T_MATCH, + ], true); + } +} diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Internal/TokenStream.php b/src/ncc/ThirdParty/nikic/PhpParser/Internal/TokenStream.php index 11fc4b4..b8a630d 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Internal/TokenStream.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Internal/TokenStream.php @@ -2,22 +2,23 @@ namespace ncc\ThirdParty\nikic\PhpParser\Internal; +use ncc\ThirdParty\nikic\PhpParser\Token; + /** * Provides operations on token streams, for use by pretty printer. * * @internal */ -class TokenStream -{ - /** @var array Tokens (in token_get_all format) */ - private $tokens; +class TokenStream { + /** @var Token[] Tokens (in PhpToken::tokenize() format) */ + private array $tokens; /** @var int[] Map from position to indentation */ - private $indentMap; + private array $indentMap; /** * Create token stream instance. * - * @param array $tokens Tokens in token_get_all() format + * @param Token[] $tokens Tokens in PhpToken::tokenize() format */ public function __construct(array $tokens) { $this->tokens = $tokens; @@ -28,11 +29,9 @@ class TokenStream * Whether the given position is immediately surrounded by parenthesis. * * @param int $startPos Start position - * @param int $endPos End position - * - * @return bool + * @param int $endPos End position */ - public function haveParens(int $startPos, int $endPos) : bool { + public function haveParens(int $startPos, int $endPos): bool { return $this->haveTokenImmediatelyBefore($startPos, '(') && $this->haveTokenImmediatelyAfter($endPos, ')'); } @@ -41,11 +40,9 @@ class TokenStream * Whether the given position is immediately surrounded by braces. * * @param int $startPos Start position - * @param int $endPos End position - * - * @return bool + * @param int $endPos End position */ - public function haveBraces(int $startPos, int $endPos) : bool { + public function haveBraces(int $startPos, int $endPos): bool { return ($this->haveTokenImmediatelyBefore($startPos, '{') || $this->haveTokenImmediatelyBefore($startPos, T_CURLY_OPEN)) && $this->haveTokenImmediatelyAfter($endPos, '}'); @@ -56,21 +53,20 @@ class TokenStream * * During this check whitespace and comments are skipped. * - * @param int $pos Position before which the token should occur + * @param int $pos Position before which the token should occur * @param int|string $expectedTokenType Token to check for * * @return bool Whether the expected token was found */ - public function haveTokenImmediatelyBefore(int $pos, $expectedTokenType) : bool { + public function haveTokenImmediatelyBefore(int $pos, $expectedTokenType): bool { $tokens = $this->tokens; $pos--; for (; $pos >= 0; $pos--) { - $tokenType = $tokens[$pos][0]; - if ($tokenType === $expectedTokenType) { + $token = $tokens[$pos]; + if ($token->is($expectedTokenType)) { return true; } - if ($tokenType !== \T_WHITESPACE - && $tokenType !== \T_COMMENT && $tokenType !== \T_DOC_COMMENT) { + if (!$token->isIgnorable()) { break; } } @@ -82,28 +78,28 @@ class TokenStream * * During this check whitespace and comments are skipped. * - * @param int $pos Position after which the token should occur + * @param int $pos Position after which the token should occur * @param int|string $expectedTokenType Token to check for * * @return bool Whether the expected token was found */ - public function haveTokenImmediatelyAfter(int $pos, $expectedTokenType) : bool { + public function haveTokenImmediatelyAfter(int $pos, $expectedTokenType): bool { $tokens = $this->tokens; $pos++; - for (; $pos < \count($tokens); $pos++) { - $tokenType = $tokens[$pos][0]; - if ($tokenType === $expectedTokenType) { + for ($c = \count($tokens); $pos < $c; $pos++) { + $token = $tokens[$pos]; + if ($token->is($expectedTokenType)) { return true; } - if ($tokenType !== \T_WHITESPACE - && $tokenType !== \T_COMMENT && $tokenType !== \T_DOC_COMMENT) { + if (!$token->isIgnorable()) { break; } } return false; } - public function skipLeft(int $pos, $skipTokenType) { + /** @param int|string|(int|string)[] $skipTokenType */ + public function skipLeft(int $pos, $skipTokenType): int { $tokens = $this->tokens; $pos = $this->skipLeftWhitespace($pos); @@ -111,7 +107,7 @@ class TokenStream return $pos; } - if ($tokens[$pos][0] !== $skipTokenType) { + if (!$tokens[$pos]->is($skipTokenType)) { // Shouldn't happen. The skip token MUST be there throw new \Exception('Encountered unexpected token'); } @@ -120,7 +116,8 @@ class TokenStream return $this->skipLeftWhitespace($pos); } - public function skipRight(int $pos, $skipTokenType) { + /** @param int|string|(int|string)[] $skipTokenType */ + public function skipRight(int $pos, $skipTokenType): int { $tokens = $this->tokens; $pos = $this->skipRightWhitespace($pos); @@ -128,7 +125,7 @@ class TokenStream return $pos; } - if ($tokens[$pos][0] !== $skipTokenType) { + if (!$tokens[$pos]->is($skipTokenType)) { // Shouldn't happen. The skip token MUST be there throw new \Exception('Encountered unexpected token'); } @@ -143,11 +140,10 @@ class TokenStream * @param int $pos Token position * @return int Non-whitespace token position */ - public function skipLeftWhitespace(int $pos) { + public function skipLeftWhitespace(int $pos): int { $tokens = $this->tokens; for (; $pos >= 0; $pos--) { - $type = $tokens[$pos][0]; - if ($type !== \T_WHITESPACE && $type !== \T_COMMENT && $type !== \T_DOC_COMMENT) { + if (!$tokens[$pos]->isIgnorable()) { break; } } @@ -160,22 +156,21 @@ class TokenStream * @param int $pos Token position * @return int Non-whitespace token position */ - public function skipRightWhitespace(int $pos) { + public function skipRightWhitespace(int $pos): int { $tokens = $this->tokens; for ($count = \count($tokens); $pos < $count; $pos++) { - $type = $tokens[$pos][0]; - if ($type !== \T_WHITESPACE && $type !== \T_COMMENT && $type !== \T_DOC_COMMENT) { + if (!$tokens[$pos]->isIgnorable()) { break; } } return $pos; } - public function findRight(int $pos, $findTokenType) { + /** @param int|string|(int|string)[] $findTokenType */ + public function findRight(int $pos, $findTokenType): int { $tokens = $this->tokens; for ($count = \count($tokens); $pos < $count; $pos++) { - $type = $tokens[$pos][0]; - if ($type === $findTokenType) { + if ($tokens[$pos]->is($findTokenType)) { return $pos; } } @@ -190,22 +185,16 @@ class TokenStream * @param int|string $tokenType Token type to look for * @return bool Whether the token occurs in the given range */ - public function haveTokenInRange(int $startPos, int $endPos, $tokenType) { + public function haveTokenInRange(int $startPos, int $endPos, $tokenType): bool { $tokens = $this->tokens; for ($pos = $startPos; $pos < $endPos; $pos++) { - if ($tokens[$pos][0] === $tokenType) { + if ($tokens[$pos]->is($tokenType)) { return true; } } return false; } - public function haveBracesInRange(int $startPos, int $endPos) { - return $this->haveTokenInRange($startPos, $endPos, '{') - || $this->haveTokenInRange($startPos, $endPos, T_CURLY_OPEN) - || $this->haveTokenInRange($startPos, $endPos, '}'); - } - public function haveTagInRange(int $startPos, int $endPos): bool { return $this->haveTokenInRange($startPos, $endPos, \T_OPEN_TAG) || $this->haveTokenInRange($startPos, $endPos, \T_CLOSE_TAG); @@ -218,41 +207,37 @@ class TokenStream * * @return int Indentation depth (in spaces) */ - public function getIndentationBefore(int $pos) : int { + public function getIndentationBefore(int $pos): int { return $this->indentMap[$pos]; } /** * Get the code corresponding to a token offset range, optionally adjusted for indentation. * - * @param int $from Token start position (inclusive) - * @param int $to Token end position (exclusive) + * @param int $from Token start position (inclusive) + * @param int $to Token end position (exclusive) * @param int $indent By how much the code should be indented (can be negative as well) * * @return string Code corresponding to token range, adjusted for indentation */ - public function getTokenCode(int $from, int $to, int $indent) : string { + public function getTokenCode(int $from, int $to, int $indent): string { $tokens = $this->tokens; $result = ''; for ($pos = $from; $pos < $to; $pos++) { $token = $tokens[$pos]; - if (\is_array($token)) { - $type = $token[0]; - $content = $token[1]; - if ($type === \T_CONSTANT_ENCAPSED_STRING || $type === \T_ENCAPSED_AND_WHITESPACE) { - $result .= $content; - } else { - // TODO Handle non-space indentation - if ($indent < 0) { - $result .= str_replace("\n" . str_repeat(" ", -$indent), "\n", $content); - } elseif ($indent > 0) { - $result .= str_replace("\n", "\n" . str_repeat(" ", $indent), $content); - } else { - $result .= $content; - } - } + $id = $token->id; + $text = $token->text; + if ($id === \T_CONSTANT_ENCAPSED_STRING || $id === \T_ENCAPSED_AND_WHITESPACE) { + $result .= $text; } else { - $result .= $token; + // TODO Handle non-space indentation + if ($indent < 0) { + $result .= str_replace("\n" . str_repeat(" ", -$indent), "\n", $text); + } elseif ($indent > 0) { + $result .= str_replace("\n", "\n" . str_repeat(" ", $indent), $text); + } else { + $result .= $text; + } } } return $result; @@ -263,17 +248,21 @@ class TokenStream * * @return int[] Token position to indentation map */ - private function calcIndentMap() { + private function calcIndentMap(): array { $indentMap = []; $indent = 0; - foreach ($this->tokens as $token) { + foreach ($this->tokens as $i => $token) { $indentMap[] = $indent; - if ($token[0] === \T_WHITESPACE) { - $content = $token[1]; + if ($token->id === \T_WHITESPACE) { + $content = $token->text; $newlinePos = \strrpos($content, "\n"); if (false !== $newlinePos) { $indent = \strlen($content) - $newlinePos - 1; + } elseif ($i === 1 && $this->tokens[0]->id === \T_OPEN_TAG && + $this->tokens[0]->text[\strlen($this->tokens[0]->text) - 1] === "\n") { + // Special case: Newline at the end of opening tag followed by whitespace. + $indent = \strlen($content); } } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/JsonDecoder.php b/src/ncc/ThirdParty/nikic/PhpParser/JsonDecoder.php index 43fc34b..b0a8722 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/JsonDecoder.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/JsonDecoder.php @@ -2,11 +2,11 @@ namespace ncc\ThirdParty\nikic\PhpParser; -class JsonDecoder -{ - /** @var \ReflectionClass[] Node type to reflection class map */ - private $reflectionClassCache; +class JsonDecoder { + /** @var \ReflectionClass[] Node type to reflection class map */ + private array $reflectionClassCache; + /** @return mixed */ public function decode(string $json) { $value = json_decode($json, true); if (json_last_error()) { @@ -16,6 +16,10 @@ class JsonDecoder return $this->decodeRecursive($value); } + /** + * @param mixed $value + * @return mixed + */ private function decodeRecursive($value) { if (\is_array($value)) { if (isset($value['nodeType'])) { @@ -29,7 +33,7 @@ class JsonDecoder return $value; } - private function decodeArray(array $array) : array { + private function decodeArray(array $array): array { $decodedArray = []; foreach ($array as $key => $value) { $decodedArray[$key] = $this->decodeRecursive($value); @@ -37,14 +41,13 @@ class JsonDecoder return $decodedArray; } - private function decodeNode(array $value) : Node { + private function decodeNode(array $value): Node { $nodeType = $value['nodeType']; if (!\is_string($nodeType)) { throw new \RuntimeException('Node type must be a string'); } $reflectionClass = $this->reflectionClassFromNodeType($nodeType); - /** @var Node $node */ $node = $reflectionClass->newInstanceWithoutConstructor(); if (isset($value['attributes'])) { @@ -66,7 +69,7 @@ class JsonDecoder return $node; } - private function decodeComment(array $value) : Comment { + private function decodeComment(array $value): Comment { $className = $value['nodeType'] === 'Comment' ? Comment::class : Comment\Doc::class; if (!isset($value['text'])) { throw new \RuntimeException('Comment must have text'); @@ -79,7 +82,8 @@ class JsonDecoder ); } - private function reflectionClassFromNodeType(string $nodeType) : \ReflectionClass { + /** @return \ReflectionClass */ + private function reflectionClassFromNodeType(string $nodeType): \ReflectionClass { if (!isset($this->reflectionClassCache[$nodeType])) { $className = $this->classNameFromNodeType($nodeType); $this->reflectionClassCache[$nodeType] = new \ReflectionClass($className); @@ -87,7 +91,8 @@ class JsonDecoder return $this->reflectionClassCache[$nodeType]; } - private function classNameFromNodeType(string $nodeType) : string { + /** @return class-string */ + private function classNameFromNodeType(string $nodeType): string { $className = 'PhpParser\\Node\\' . strtr($nodeType, '_', '\\'); if (class_exists($className)) { return $className; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Lexer.php b/src/ncc/ThirdParty/nikic/PhpParser/Lexer.php index b04749d..edb7c53 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Lexer.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Lexer.php @@ -2,559 +2,115 @@ namespace ncc\ThirdParty\nikic\PhpParser; -use ncc\ThirdParty\nikic\PhpParser\Parser\Tokens; - -class Lexer -{ - protected $code; - protected $tokens; - protected $pos; - protected $line; - protected $filePos; - protected $prevCloseTagHasNewline; - - protected $tokenMap; - protected $dropTokens; - protected $identifierTokens; - - private $attributeStartLineUsed; - private $attributeEndLineUsed; - private $attributeStartTokenPosUsed; - private $attributeEndTokenPosUsed; - private $attributeStartFilePosUsed; - private $attributeEndFilePosUsed; - private $attributeCommentsUsed; +require __DIR__ . '/compatibility_tokens.php'; +class Lexer { /** - * Creates a Lexer. + * Tokenize the provided source code. * - * @param array $options Options array. Currently only the 'usedAttributes' option is supported, - * which is an array of attributes to add to the AST nodes. Possible - * attributes are: 'comments', 'startLine', 'endLine', 'startTokenPos', - * 'endTokenPos', 'startFilePos', 'endFilePos'. The option defaults to the - * first three. For more info see getNextToken() docs. - */ - public function __construct(array $options = []) { - // Create Map from internal tokens to PhpParser tokens. - $this->defineCompatibilityTokens(); - $this->tokenMap = $this->createTokenMap(); - $this->identifierTokens = $this->createIdentifierTokenMap(); - - // map of tokens to drop while lexing (the map is only used for isset lookup, - // that's why the value is simply set to 1; the value is never actually used.) - $this->dropTokens = array_fill_keys( - [\T_WHITESPACE, \T_OPEN_TAG, \T_COMMENT, \T_DOC_COMMENT, \T_BAD_CHARACTER], 1 - ); - - $defaultAttributes = ['comments', 'startLine', 'endLine']; - $usedAttributes = array_fill_keys($options['usedAttributes'] ?? $defaultAttributes, true); - - // Create individual boolean properties to make these checks faster. - $this->attributeStartLineUsed = isset($usedAttributes['startLine']); - $this->attributeEndLineUsed = isset($usedAttributes['endLine']); - $this->attributeStartTokenPosUsed = isset($usedAttributes['startTokenPos']); - $this->attributeEndTokenPosUsed = isset($usedAttributes['endTokenPos']); - $this->attributeStartFilePosUsed = isset($usedAttributes['startFilePos']); - $this->attributeEndFilePosUsed = isset($usedAttributes['endFilePos']); - $this->attributeCommentsUsed = isset($usedAttributes['comments']); - } - - /** - * Initializes the lexer for lexing the provided source code. + * The token array is in the same format as provided by the PhpToken::tokenize() method in + * PHP 8.0. The tokens are instances of PhpParser\Token, to abstract over a polyfill + * implementation in earlier PHP version. * - * This function does not throw if lexing errors occur. Instead, errors may be retrieved using - * the getErrors() method. + * The token array is terminated by a sentinel token with token ID 0. + * The token array does not discard any tokens (i.e. whitespace and comments are included). + * The token position attributes are against this token array. * - * @param string $code The source code to lex + * @param string $code The source code to tokenize. * @param ErrorHandler|null $errorHandler Error handler to use for lexing errors. Defaults to - * ErrorHandler\Throwing + * ErrorHandler\Throwing. + * @return Token[] Tokens */ - public function startLexing(string $code, ErrorHandler $errorHandler = null) { + public function tokenize(string $code, ?ErrorHandler $errorHandler = null): array { if (null === $errorHandler) { $errorHandler = new ErrorHandler\Throwing(); } - $this->code = $code; // keep the code around for __halt_compiler() handling - $this->pos = -1; - $this->line = 1; - $this->filePos = 0; - - // If inline HTML occurs without preceding code, treat it as if it had a leading newline. - // This ensures proper composability, because having a newline is the "safe" assumption. - $this->prevCloseTagHasNewline = true; - $scream = ini_set('xdebug.scream', '0'); - $this->tokens = @token_get_all($code); - $this->postprocessTokens($errorHandler); + $tokens = @Token::tokenize($code); + $this->postprocessTokens($tokens, $errorHandler); if (false !== $scream) { ini_set('xdebug.scream', $scream); } - } - private function handleInvalidCharacterRange($start, $end, $line, ErrorHandler $errorHandler) { - $tokens = []; - for ($i = $start; $i < $end; $i++) { - $chr = $this->code[$i]; - if ($chr === "\0") { - // PHP cuts error message after null byte, so need special case - $errorMsg = 'Unexpected null byte'; - } else { - $errorMsg = sprintf( - 'Unexpected character "%s" (ASCII %d)', $chr, ord($chr) - ); - } - - $tokens[] = [\T_BAD_CHARACTER, $chr, $line]; - $errorHandler->handleError(new Error($errorMsg, [ - 'startLine' => $line, - 'endLine' => $line, - 'startFilePos' => $i, - 'endFilePos' => $i, - ])); - } return $tokens; } - /** - * Check whether comment token is unterminated. - * - * @return bool - */ - private function isUnterminatedComment($token) : bool { - return ($token[0] === \T_COMMENT || $token[0] === \T_DOC_COMMENT) - && substr($token[1], 0, 2) === '/*' - && substr($token[1], -2) !== '*/'; + private function handleInvalidCharacter(Token $token, ErrorHandler $errorHandler): void { + $chr = $token->text; + if ($chr === "\0") { + // PHP cuts error message after null byte, so need special case + $errorMsg = 'Unexpected null byte'; + } else { + $errorMsg = sprintf( + 'Unexpected character "%s" (ASCII %d)', $chr, ord($chr) + ); + } + + $errorHandler->handleError(new Error($errorMsg, [ + 'startLine' => $token->line, + 'endLine' => $token->line, + 'startFilePos' => $token->pos, + 'endFilePos' => $token->pos, + ])); } - protected function postprocessTokens(ErrorHandler $errorHandler) { - // PHP's error handling for token_get_all() is rather bad, so if we want detailed - // error information we need to compute it ourselves. Invalid character errors are - // detected by finding "gaps" in the token array. Unterminated comments are detected - // by checking if a trailing comment has a "*/" at the end. - // - // Additionally, we perform a number of canonicalizations here: - // * Use the PHP 8.0 comment format, which does not include trailing whitespace anymore. - // * Use PHP 8.0 T_NAME_* tokens. + private function isUnterminatedComment(Token $token): bool { + return $token->is([\T_COMMENT, \T_DOC_COMMENT]) + && substr($token->text, 0, 2) === '/*' + && substr($token->text, -2) !== '*/'; + } + + /** + * @param list $tokens + */ + protected function postprocessTokens(array &$tokens, ErrorHandler $errorHandler): void { + // This function reports errors (bad characters and unterminated comments) in the token + // array, and performs certain canonicalizations: // * Use PHP 8.1 T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG and // T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG tokens used to disambiguate intersection types. + // * Add a sentinel token with ID 0. + + $numTokens = \count($tokens); + if ($numTokens === 0) { + // Empty input edge case: Just add the sentinel token. + $tokens[] = new Token(0, "\0", 1, 0); + return; + } - $filePos = 0; - $line = 1; - $numTokens = \count($this->tokens); for ($i = 0; $i < $numTokens; $i++) { - $token = $this->tokens[$i]; - - // Since PHP 7.4 invalid characters are represented by a T_BAD_CHARACTER token. - // In this case we only need to emit an error. - if ($token[0] === \T_BAD_CHARACTER) { - $this->handleInvalidCharacterRange($filePos, $filePos + 1, $line, $errorHandler); + $token = $tokens[$i]; + if ($token->id === \T_BAD_CHARACTER) { + $this->handleInvalidCharacter($token, $errorHandler); } - if ($token[0] === \T_COMMENT && substr($token[1], 0, 2) !== '/*' - && preg_match('/(\r\n|\n|\r)$/D', $token[1], $matches)) { - $trailingNewline = $matches[0]; - $token[1] = substr($token[1], 0, -strlen($trailingNewline)); - $this->tokens[$i] = $token; - if (isset($this->tokens[$i + 1]) && $this->tokens[$i + 1][0] === \T_WHITESPACE) { - // Move trailing newline into following T_WHITESPACE token, if it already exists. - $this->tokens[$i + 1][1] = $trailingNewline . $this->tokens[$i + 1][1]; - $this->tokens[$i + 1][2]--; - } else { - // Otherwise, we need to create a new T_WHITESPACE token. - array_splice($this->tokens, $i + 1, 0, [ - [\T_WHITESPACE, $trailingNewline, $line], - ]); - $numTokens++; - } - } - - // Emulate PHP 8 T_NAME_* tokens, by combining sequences of T_NS_SEPARATOR and T_STRING - // into a single token. - if (\is_array($token) - && ($token[0] === \T_NS_SEPARATOR || isset($this->identifierTokens[$token[0]]))) { - $lastWasSeparator = $token[0] === \T_NS_SEPARATOR; - $text = $token[1]; - for ($j = $i + 1; isset($this->tokens[$j]); $j++) { - if ($lastWasSeparator) { - if (!isset($this->identifierTokens[$this->tokens[$j][0]])) { - break; - } - $lastWasSeparator = false; - } else { - if ($this->tokens[$j][0] !== \T_NS_SEPARATOR) { - break; - } - $lastWasSeparator = true; - } - $text .= $this->tokens[$j][1]; - } - if ($lastWasSeparator) { - // Trailing separator is not part of the name. - $j--; - $text = substr($text, 0, -1); - } - if ($j > $i + 1) { - if ($token[0] === \T_NS_SEPARATOR) { - $type = \T_NAME_FULLY_QUALIFIED; - } else if ($token[0] === \T_NAMESPACE) { - $type = \T_NAME_RELATIVE; - } else { - $type = \T_NAME_QUALIFIED; - } - $token = [$type, $text, $line]; - array_splice($this->tokens, $i, $j - $i, [$token]); - $numTokens -= $j - $i - 1; - } - } - - if ($token === '&') { + if ($token->id === \ord('&')) { $next = $i + 1; - while (isset($this->tokens[$next]) && $this->tokens[$next][0] === \T_WHITESPACE) { + while (isset($tokens[$next]) && $tokens[$next]->id === \T_WHITESPACE) { $next++; } - $followedByVarOrVarArg = isset($this->tokens[$next]) && - ($this->tokens[$next][0] === \T_VARIABLE || $this->tokens[$next][0] === \T_ELLIPSIS); - $this->tokens[$i] = $token = [ - $followedByVarOrVarArg - ? \T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG - : \T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG, - '&', - $line, - ]; - } - - $tokenValue = \is_string($token) ? $token : $token[1]; - $tokenLen = \strlen($tokenValue); - - if (substr($this->code, $filePos, $tokenLen) !== $tokenValue) { - // Something is missing, must be an invalid character - $nextFilePos = strpos($this->code, $tokenValue, $filePos); - $badCharTokens = $this->handleInvalidCharacterRange( - $filePos, $nextFilePos, $line, $errorHandler); - $filePos = (int) $nextFilePos; - - array_splice($this->tokens, $i, 0, $badCharTokens); - $numTokens += \count($badCharTokens); - $i += \count($badCharTokens); - } - - $filePos += $tokenLen; - $line += substr_count($tokenValue, "\n"); - } - - if ($filePos !== \strlen($this->code)) { - if (substr($this->code, $filePos, 2) === '/*') { - // Unlike PHP, HHVM will drop unterminated comments entirely - $comment = substr($this->code, $filePos); - $errorHandler->handleError(new Error('Unterminated comment', [ - 'startLine' => $line, - 'endLine' => $line + substr_count($comment, "\n"), - 'startFilePos' => $filePos, - 'endFilePos' => $filePos + \strlen($comment), - ])); - - // Emulate the PHP behavior - $isDocComment = isset($comment[3]) && $comment[3] === '*'; - $this->tokens[] = [$isDocComment ? \T_DOC_COMMENT : \T_COMMENT, $comment, $line]; - } else { - // Invalid characters at the end of the input - $badCharTokens = $this->handleInvalidCharacterRange( - $filePos, \strlen($this->code), $line, $errorHandler); - $this->tokens = array_merge($this->tokens, $badCharTokens); - } - return; - } - - if (count($this->tokens) > 0) { - // Check for unterminated comment - $lastToken = $this->tokens[count($this->tokens) - 1]; - if ($this->isUnterminatedComment($lastToken)) { - $errorHandler->handleError(new Error('Unterminated comment', [ - 'startLine' => $line - substr_count($lastToken[1], "\n"), - 'endLine' => $line, - 'startFilePos' => $filePos - \strlen($lastToken[1]), - 'endFilePos' => $filePos, - ])); - } - } - } - - /** - * Fetches the next token. - * - * The available attributes are determined by the 'usedAttributes' option, which can - * be specified in the constructor. The following attributes are supported: - * - * * 'comments' => Array of PhpParser\Comment or PhpParser\Comment\Doc instances, - * representing all comments that occurred between the previous - * non-discarded token and the current one. - * * 'startLine' => Line in which the node starts. - * * 'endLine' => Line in which the node ends. - * * 'startTokenPos' => Offset into the token array of the first token in the node. - * * 'endTokenPos' => Offset into the token array of the last token in the node. - * * 'startFilePos' => Offset into the code string of the first character that is part of the node. - * * 'endFilePos' => Offset into the code string of the last character that is part of the node. - * - * @param mixed $value Variable to store token content in - * @param mixed $startAttributes Variable to store start attributes in - * @param mixed $endAttributes Variable to store end attributes in - * - * @return int Token id - */ - public function getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null) : int { - $startAttributes = []; - $endAttributes = []; - - while (1) { - if (isset($this->tokens[++$this->pos])) { - $token = $this->tokens[$this->pos]; - } else { - // EOF token with ID 0 - $token = "\0"; - } - - if ($this->attributeStartLineUsed) { - $startAttributes['startLine'] = $this->line; - } - if ($this->attributeStartTokenPosUsed) { - $startAttributes['startTokenPos'] = $this->pos; - } - if ($this->attributeStartFilePosUsed) { - $startAttributes['startFilePos'] = $this->filePos; - } - - if (\is_string($token)) { - $value = $token; - if (isset($token[1])) { - // bug in token_get_all - $this->filePos += 2; - $id = ord('"'); - } else { - $this->filePos += 1; - $id = ord($token); - } - } elseif (!isset($this->dropTokens[$token[0]])) { - $value = $token[1]; - $id = $this->tokenMap[$token[0]]; - if (\T_CLOSE_TAG === $token[0]) { - $this->prevCloseTagHasNewline = false !== strpos($token[1], "\n") - || false !== strpos($token[1], "\r"); - } elseif (\T_INLINE_HTML === $token[0]) { - $startAttributes['hasLeadingNewline'] = $this->prevCloseTagHasNewline; - } - - $this->line += substr_count($value, "\n"); - $this->filePos += \strlen($value); - } else { - $origLine = $this->line; - $origFilePos = $this->filePos; - $this->line += substr_count($token[1], "\n"); - $this->filePos += \strlen($token[1]); - - if (\T_COMMENT === $token[0] || \T_DOC_COMMENT === $token[0]) { - if ($this->attributeCommentsUsed) { - $comment = \T_DOC_COMMENT === $token[0] - ? new Comment\Doc($token[1], - $origLine, $origFilePos, $this->pos, - $this->line, $this->filePos - 1, $this->pos) - : new Comment($token[1], - $origLine, $origFilePos, $this->pos, - $this->line, $this->filePos - 1, $this->pos); - $startAttributes['comments'][] = $comment; - } - } - continue; - } - - if ($this->attributeEndLineUsed) { - $endAttributes['endLine'] = $this->line; - } - if ($this->attributeEndTokenPosUsed) { - $endAttributes['endTokenPos'] = $this->pos; - } - if ($this->attributeEndFilePosUsed) { - $endAttributes['endFilePos'] = $this->filePos - 1; - } - - return $id; - } - - throw new \RuntimeException('Reached end of lexer loop'); - } - - /** - * Returns the token array for current code. - * - * The token array is in the same format as provided by the - * token_get_all() function and does not discard tokens (i.e. - * whitespace and comments are included). The token position - * attributes are against this token array. - * - * @return array Array of tokens in token_get_all() format - */ - public function getTokens() : array { - return $this->tokens; - } - - /** - * Handles __halt_compiler() by returning the text after it. - * - * @return string Remaining text - */ - public function handleHaltCompiler() : string { - // text after T_HALT_COMPILER, still including (); - $textAfter = substr($this->code, $this->filePos); - - // ensure that it is followed by (); - // this simplifies the situation, by not allowing any comments - // in between of the tokens. - if (!preg_match('~^\s*\(\s*\)\s*(?:;|\?>\r?\n?)~', $textAfter, $matches)) { - throw new Error('__HALT_COMPILER must be followed by "();"'); - } - - // prevent the lexer from returning any further tokens - $this->pos = count($this->tokens); - - // return with (); removed - return substr($textAfter, strlen($matches[0])); - } - - private function defineCompatibilityTokens() { - static $compatTokensDefined = false; - if ($compatTokensDefined) { - return; - } - - $compatTokens = [ - // PHP 7.4 - 'T_BAD_CHARACTER', - 'T_FN', - 'T_COALESCE_EQUAL', - // PHP 8.0 - 'T_NAME_QUALIFIED', - 'T_NAME_FULLY_QUALIFIED', - 'T_NAME_RELATIVE', - 'T_MATCH', - 'T_NULLSAFE_OBJECT_OPERATOR', - 'T_ATTRIBUTE', - // PHP 8.1 - 'T_ENUM', - 'T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG', - 'T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG', - 'T_READONLY', - ]; - - // PHP-Parser might be used together with another library that also emulates some or all - // of these tokens. Perform a sanity-check that all already defined tokens have been - // assigned a unique ID. - $usedTokenIds = []; - foreach ($compatTokens as $token) { - if (\defined($token)) { - $tokenId = \constant($token); - $clashingToken = $usedTokenIds[$tokenId] ?? null; - if ($clashingToken !== null) { - throw new \Error(sprintf( - 'Token %s has same ID as token %s, ' . - 'you may be using a library with broken token emulation', - $token, $clashingToken - )); - } - $usedTokenIds[$tokenId] = $token; + $followedByVarOrVarArg = isset($tokens[$next]) && + $tokens[$next]->is([\T_VARIABLE, \T_ELLIPSIS]); + $token->id = $followedByVarOrVarArg + ? \T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG + : \T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG; } } - // Now define any tokens that have not yet been emulated. Try to assign IDs from -1 - // downwards, but skip any IDs that may already be in use. - $newTokenId = -1; - foreach ($compatTokens as $token) { - if (!\defined($token)) { - while (isset($usedTokenIds[$newTokenId])) { - $newTokenId--; - } - \define($token, $newTokenId); - $newTokenId--; - } + // Check for unterminated comment + $lastToken = $tokens[$numTokens - 1]; + if ($this->isUnterminatedComment($lastToken)) { + $errorHandler->handleError(new Error('Unterminated comment', [ + 'startLine' => $lastToken->line, + 'endLine' => $lastToken->getEndLine(), + 'startFilePos' => $lastToken->pos, + 'endFilePos' => $lastToken->getEndPos(), + ])); } - $compatTokensDefined = true; - } - - /** - * Creates the token map. - * - * The token map maps the PHP internal token identifiers - * to the identifiers used by the Parser. Additionally it - * maps T_OPEN_TAG_WITH_ECHO to T_ECHO and T_CLOSE_TAG to ';'. - * - * @return array The token map - */ - protected function createTokenMap() : array { - $tokenMap = []; - - // 256 is the minimum possible token number, as everything below - // it is an ASCII value - for ($i = 256; $i < 1000; ++$i) { - if (\T_DOUBLE_COLON === $i) { - // T_DOUBLE_COLON is equivalent to T_PAAMAYIM_NEKUDOTAYIM - $tokenMap[$i] = Tokens::T_PAAMAYIM_NEKUDOTAYIM; - } elseif(\T_OPEN_TAG_WITH_ECHO === $i) { - // T_OPEN_TAG_WITH_ECHO with dropped T_OPEN_TAG results in T_ECHO - $tokenMap[$i] = Tokens::T_ECHO; - } elseif(\T_CLOSE_TAG === $i) { - // T_CLOSE_TAG is equivalent to ';' - $tokenMap[$i] = ord(';'); - } elseif ('UNKNOWN' !== $name = token_name($i)) { - if ('T_HASHBANG' === $name) { - // HHVM uses a special token for #! hashbang lines - $tokenMap[$i] = Tokens::T_INLINE_HTML; - } elseif (defined($name = Tokens::class . '::' . $name)) { - // Other tokens can be mapped directly - $tokenMap[$i] = constant($name); - } - } - } - - // HHVM uses a special token for numbers that overflow to double - if (defined('T_ONUMBER')) { - $tokenMap[\T_ONUMBER] = Tokens::T_DNUMBER; - } - // HHVM also has a separate token for the __COMPILER_HALT_OFFSET__ constant - if (defined('T_COMPILER_HALT_OFFSET')) { - $tokenMap[\T_COMPILER_HALT_OFFSET] = Tokens::T_STRING; - } - - // Assign tokens for which we define compatibility constants, as token_name() does not know them. - $tokenMap[\T_FN] = Tokens::T_FN; - $tokenMap[\T_COALESCE_EQUAL] = Tokens::T_COALESCE_EQUAL; - $tokenMap[\T_NAME_QUALIFIED] = Tokens::T_NAME_QUALIFIED; - $tokenMap[\T_NAME_FULLY_QUALIFIED] = Tokens::T_NAME_FULLY_QUALIFIED; - $tokenMap[\T_NAME_RELATIVE] = Tokens::T_NAME_RELATIVE; - $tokenMap[\T_MATCH] = Tokens::T_MATCH; - $tokenMap[\T_NULLSAFE_OBJECT_OPERATOR] = Tokens::T_NULLSAFE_OBJECT_OPERATOR; - $tokenMap[\T_ATTRIBUTE] = Tokens::T_ATTRIBUTE; - $tokenMap[\T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG] = Tokens::T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG; - $tokenMap[\T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG] = Tokens::T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG; - $tokenMap[\T_ENUM] = Tokens::T_ENUM; - $tokenMap[\T_READONLY] = Tokens::T_READONLY; - - return $tokenMap; - } - - private function createIdentifierTokenMap(): array { - // Based on semi_reserved production. - return array_fill_keys([ - \T_STRING, - \T_STATIC, \T_ABSTRACT, \T_FINAL, \T_PRIVATE, \T_PROTECTED, \T_PUBLIC, \T_READONLY, - \T_INCLUDE, \T_INCLUDE_ONCE, \T_EVAL, \T_REQUIRE, \T_REQUIRE_ONCE, \T_LOGICAL_OR, \T_LOGICAL_XOR, \T_LOGICAL_AND, - \T_INSTANCEOF, \T_NEW, \T_CLONE, \T_EXIT, \T_IF, \T_ELSEIF, \T_ELSE, \T_ENDIF, \T_ECHO, \T_DO, \T_WHILE, - \T_ENDWHILE, \T_FOR, \T_ENDFOR, \T_FOREACH, \T_ENDFOREACH, \T_DECLARE, \T_ENDDECLARE, \T_AS, \T_TRY, \T_CATCH, - \T_FINALLY, \T_THROW, \T_USE, \T_INSTEADOF, \T_GLOBAL, \T_VAR, \T_UNSET, \T_ISSET, \T_EMPTY, \T_CONTINUE, \T_GOTO, - \T_FUNCTION, \T_CONST, \T_RETURN, \T_PRINT, \T_YIELD, \T_LIST, \T_SWITCH, \T_ENDSWITCH, \T_CASE, \T_DEFAULT, - \T_BREAK, \T_ARRAY, \T_CALLABLE, \T_EXTENDS, \T_IMPLEMENTS, \T_NAMESPACE, \T_TRAIT, \T_INTERFACE, \T_CLASS, - \T_CLASS_C, \T_TRAIT_C, \T_FUNC_C, \T_METHOD_C, \T_LINE, \T_FILE, \T_DIR, \T_NS_C, \T_HALT_COMPILER, \T_FN, - \T_MATCH, - ], true); + // Add sentinel token. + $tokens[] = new Token(0, "\0", $lastToken->getEndLine(), $lastToken->getEndPos()); } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/Emulative.php b/src/ncc/ThirdParty/nikic/PhpParser/Lexer/Emulative.php index 10df442..46370e1 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/Emulative.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Lexer/Emulative.php @@ -5,61 +5,48 @@ namespace ncc\ThirdParty\nikic\PhpParser\Lexer; use ncc\ThirdParty\nikic\PhpParser\Error; use ncc\ThirdParty\nikic\PhpParser\ErrorHandler; use ncc\ThirdParty\nikic\PhpParser\Lexer; +use ncc\ThirdParty\nikic\PhpParser\Lexer\TokenEmulator\AsymmetricVisibilityTokenEmulator; use ncc\ThirdParty\nikic\PhpParser\Lexer\TokenEmulator\AttributeEmulator; use ncc\ThirdParty\nikic\PhpParser\Lexer\TokenEmulator\EnumTokenEmulator; -use ncc\ThirdParty\nikic\PhpParser\Lexer\TokenEmulator\CoaleseEqualTokenEmulator; use ncc\ThirdParty\nikic\PhpParser\Lexer\TokenEmulator\ExplicitOctalEmulator; -use ncc\ThirdParty\nikic\PhpParser\Lexer\TokenEmulator\FlexibleDocStringEmulator; -use ncc\ThirdParty\nikic\PhpParser\Lexer\TokenEmulator\FnTokenEmulator; use ncc\ThirdParty\nikic\PhpParser\Lexer\TokenEmulator\MatchTokenEmulator; use ncc\ThirdParty\nikic\PhpParser\Lexer\TokenEmulator\NullsafeTokenEmulator; -use ncc\ThirdParty\nikic\PhpParser\Lexer\TokenEmulator\NumericLiteralSeparatorEmulator; +use ncc\ThirdParty\nikic\PhpParser\Lexer\TokenEmulator\PropertyTokenEmulator; use ncc\ThirdParty\nikic\PhpParser\Lexer\TokenEmulator\ReadonlyFunctionTokenEmulator; use ncc\ThirdParty\nikic\PhpParser\Lexer\TokenEmulator\ReadonlyTokenEmulator; use ncc\ThirdParty\nikic\PhpParser\Lexer\TokenEmulator\ReverseEmulator; use ncc\ThirdParty\nikic\PhpParser\Lexer\TokenEmulator\TokenEmulator; +use ncc\ThirdParty\nikic\PhpParser\PhpVersion; +use ncc\ThirdParty\nikic\PhpParser\Token; -class Emulative extends Lexer -{ - const PHP_7_3 = '7.3dev'; - const PHP_7_4 = '7.4dev'; - const PHP_8_0 = '8.0dev'; - const PHP_8_1 = '8.1dev'; - const PHP_8_2 = '8.2dev'; +class Emulative extends Lexer { + /** @var array{int, string, string}[] Patches used to reverse changes introduced in the code */ + private array $patches = []; - /** @var mixed[] Patches used to reverse changes introduced in the code */ - private $patches = []; + /** @var list */ + private array $emulators = []; - /** @var TokenEmulator[] */ - private $emulators = []; + private PhpVersion $targetPhpVersion; - /** @var string */ - private $targetPhpVersion; + private PhpVersion $hostPhpVersion; /** - * @param mixed[] $options Lexer options. In addition to the usual options, - * accepts a 'phpVersion' string that specifies the - * version to emulate. Defaults to newest supported. + * @param PhpVersion|null $phpVersion PHP version to emulate. Defaults to newest supported. */ - public function __construct(array $options = []) - { - $this->targetPhpVersion = $options['phpVersion'] ?? Emulative::PHP_8_2; - unset($options['phpVersion']); - - parent::__construct($options); + public function __construct(?PhpVersion $phpVersion = null) { + $this->targetPhpVersion = $phpVersion ?? PhpVersion::getNewestSupported(); + $this->hostPhpVersion = PhpVersion::getHostVersion(); $emulators = [ - new FlexibleDocStringEmulator(), - new FnTokenEmulator(), new MatchTokenEmulator(), - new CoaleseEqualTokenEmulator(), - new NumericLiteralSeparatorEmulator(), new NullsafeTokenEmulator(), new AttributeEmulator(), new EnumTokenEmulator(), new ReadonlyTokenEmulator(), new ExplicitOctalEmulator(), new ReadonlyFunctionTokenEmulator(), + new PropertyTokenEmulator(), + new AsymmetricVisibilityTokenEmulator(), ]; // Collect emulators that are relevant for the PHP version we're running @@ -68,21 +55,24 @@ class Emulative extends Lexer $emulatorPhpVersion = $emulator->getPhpVersion(); if ($this->isForwardEmulationNeeded($emulatorPhpVersion)) { $this->emulators[] = $emulator; - } else if ($this->isReverseEmulationNeeded($emulatorPhpVersion)) { + } elseif ($this->isReverseEmulationNeeded($emulatorPhpVersion)) { $this->emulators[] = new ReverseEmulator($emulator); } } } - public function startLexing(string $code, ErrorHandler $errorHandler = null) { - $emulators = array_filter($this->emulators, function($emulator) use($code) { + public function tokenize(string $code, ?ErrorHandler $errorHandler = null): array { + $emulators = array_filter($this->emulators, function ($emulator) use ($code) { return $emulator->isEmulationNeeded($code); }); if (empty($emulators)) { // Nothing to emulate, yay - parent::startLexing($code, $errorHandler); - return; + return parent::tokenize($code, $errorHandler); + } + + if ($errorHandler === null) { + $errorHandler = new ErrorHandler\Throwing(); } $this->patches = []; @@ -91,9 +81,9 @@ class Emulative extends Lexer } $collector = new ErrorHandler\Collecting(); - parent::startLexing($code, $collector); + $tokens = parent::tokenize($code, $collector); $this->sortPatches(); - $this->fixupTokens(); + $tokens = $this->fixupTokens($tokens); $errors = $collector->getErrors(); if (!empty($errors)) { @@ -104,90 +94,80 @@ class Emulative extends Lexer } foreach ($emulators as $emulator) { - $this->tokens = $emulator->emulate($code, $this->tokens); + $tokens = $emulator->emulate($code, $tokens); } + + return $tokens; } - private function isForwardEmulationNeeded(string $emulatorPhpVersion): bool { - return version_compare(\PHP_VERSION, $emulatorPhpVersion, '<') - && version_compare($this->targetPhpVersion, $emulatorPhpVersion, '>='); + private function isForwardEmulationNeeded(PhpVersion $emulatorPhpVersion): bool { + return $this->hostPhpVersion->older($emulatorPhpVersion) + && $this->targetPhpVersion->newerOrEqual($emulatorPhpVersion); } - private function isReverseEmulationNeeded(string $emulatorPhpVersion): bool { - return version_compare(\PHP_VERSION, $emulatorPhpVersion, '>=') - && version_compare($this->targetPhpVersion, $emulatorPhpVersion, '<'); + private function isReverseEmulationNeeded(PhpVersion $emulatorPhpVersion): bool { + return $this->hostPhpVersion->newerOrEqual($emulatorPhpVersion) + && $this->targetPhpVersion->older($emulatorPhpVersion); } - private function sortPatches() - { + private function sortPatches(): void { // Patches may be contributed by different emulators. // Make sure they are sorted by increasing patch position. - usort($this->patches, function($p1, $p2) { + usort($this->patches, function ($p1, $p2) { return $p1[0] <=> $p2[0]; }); } - private function fixupTokens() - { + /** + * @param list $tokens + * @return list + */ + private function fixupTokens(array $tokens): array { if (\count($this->patches) === 0) { - return; + return $tokens; } // Load first patch $patchIdx = 0; - list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx]; // We use a manual loop over the tokens, because we modify the array on the fly - $pos = 0; - for ($i = 0, $c = \count($this->tokens); $i < $c; $i++) { - $token = $this->tokens[$i]; - if (\is_string($token)) { - if ($patchPos === $pos) { - // Only support replacement for string tokens. - assert($patchType === 'replace'); - $this->tokens[$i] = $patchText; - - // Fetch the next patch - $patchIdx++; - if ($patchIdx >= \count($this->patches)) { - // No more patches, we're done - return; - } - list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx]; - } - - $pos += \strlen($token); - continue; - } - - $len = \strlen($token[1]); - $posDelta = 0; + $posDelta = 0; + $lineDelta = 0; + for ($i = 0, $c = \count($tokens); $i < $c; $i++) { + $token = $tokens[$i]; + $pos = $token->pos; + $token->pos += $posDelta; + $token->line += $lineDelta; + $localPosDelta = 0; + $len = \strlen($token->text); while ($patchPos >= $pos && $patchPos < $pos + $len) { $patchTextLen = \strlen($patchText); if ($patchType === 'remove') { if ($patchPos === $pos && $patchTextLen === $len) { // Remove token entirely - array_splice($this->tokens, $i, 1, []); + array_splice($tokens, $i, 1, []); $i--; $c--; } else { // Remove from token string - $this->tokens[$i][1] = substr_replace( - $token[1], '', $patchPos - $pos + $posDelta, $patchTextLen + $token->text = substr_replace( + $token->text, '', $patchPos - $pos + $localPosDelta, $patchTextLen ); - $posDelta -= $patchTextLen; + $localPosDelta -= $patchTextLen; } + $lineDelta -= \substr_count($patchText, "\n"); } elseif ($patchType === 'add') { // Insert into the token string - $this->tokens[$i][1] = substr_replace( - $token[1], $patchText, $patchPos - $pos + $posDelta, 0 + $token->text = substr_replace( + $token->text, $patchText, $patchPos - $pos + $localPosDelta, 0 ); - $posDelta += $patchTextLen; - } else if ($patchType === 'replace') { + $localPosDelta += $patchTextLen; + $lineDelta += \substr_count($patchText, "\n"); + } elseif ($patchType === 'replace') { // Replace inside the token string - $this->tokens[$i][1] = substr_replace( - $token[1], $patchText, $patchPos - $pos + $posDelta, $patchTextLen + $token->text = substr_replace( + $token->text, $patchText, $patchPos - $pos + $localPosDelta, $patchTextLen ); } else { assert(false); @@ -196,22 +176,17 @@ class Emulative extends Lexer // Fetch the next patch $patchIdx++; if ($patchIdx >= \count($this->patches)) { - // No more patches, we're done - return; + // No more patches. However, we still need to adjust position. + $patchPos = \PHP_INT_MAX; + break; } list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx]; - - // Multiple patches may apply to the same token. Reload the current one to check - // If the new patch applies - $token = $this->tokens[$i]; } - $pos += $len; + $posDelta += $localPosDelta; } - - // A patch did not apply - assert(false); + return $tokens; } /** @@ -219,7 +194,7 @@ class Emulative extends Lexer * * @param Error[] $errors */ - private function fixupErrors(array $errors) { + private function fixupErrors(array $errors): void { foreach ($errors as $error) { $attrs = $error->getAttributes(); @@ -235,7 +210,7 @@ class Emulative extends Lexer if ($patchType === 'add') { $posDelta += strlen($patchText); $lineDelta += substr_count($patchText, "\n"); - } else if ($patchType === 'remove') { + } elseif ($patchType === 'remove') { $posDelta -= strlen($patchText); $lineDelta -= substr_count($patchText, "\n"); } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/AsymmetricVisibilityTokenEmulator.php b/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/AsymmetricVisibilityTokenEmulator.php new file mode 100644 index 0000000..df6a22a --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/AsymmetricVisibilityTokenEmulator.php @@ -0,0 +1,93 @@ + \T_PUBLIC_SET, + \T_PROTECTED => \T_PROTECTED_SET, + \T_PRIVATE => \T_PRIVATE_SET, + ]; + for ($i = 0, $c = count($tokens); $i < $c; ++$i) { + $token = $tokens[$i]; + if (isset($map[$token->id]) && $i + 3 < $c && $tokens[$i + 1]->text === '(' && + $tokens[$i + 2]->id === \T_STRING && \strtolower($tokens[$i + 2]->text) === 'set' && + $tokens[$i + 3]->text === ')' && + $this->isKeywordContext($tokens, $i) + ) { + array_splice($tokens, $i, 4, [ + new Token( + $map[$token->id], $token->text . '(' . $tokens[$i + 2]->text . ')', + $token->line, $token->pos), + ]); + $c -= 3; + } + } + + return $tokens; + } + + public function reverseEmulate(string $code, array $tokens): array { + $reverseMap = [ + \T_PUBLIC_SET => \T_PUBLIC, + \T_PROTECTED_SET => \T_PROTECTED, + \T_PRIVATE_SET => \T_PRIVATE, + ]; + for ($i = 0, $c = count($tokens); $i < $c; ++$i) { + $token = $tokens[$i]; + if (isset($reverseMap[$token->id]) && + \preg_match('/(public|protected|private)\((set)\)/i', $token->text, $matches) + ) { + [, $modifier, $set] = $matches; + $modifierLen = \strlen($modifier); + array_splice($tokens, $i, 1, [ + new Token($reverseMap[$token->id], $modifier, $token->line, $token->pos), + new Token(\ord('('), '(', $token->line, $token->pos + $modifierLen), + new Token(\T_STRING, $set, $token->line, $token->pos + $modifierLen + 1), + new Token(\ord(')'), ')', $token->line, $token->pos + $modifierLen + 4), + ]); + $i += 3; + $c += 3; + } + } + + return $tokens; + } + + /** @param Token[] $tokens */ + protected function isKeywordContext(array $tokens, int $pos): bool { + $prevToken = $this->getPreviousNonSpaceToken($tokens, $pos); + if ($prevToken === null) { + return false; + } + return $prevToken->id !== \T_OBJECT_OPERATOR + && $prevToken->id !== \T_NULLSAFE_OBJECT_OPERATOR; + } + + /** @param Token[] $tokens */ + private function getPreviousNonSpaceToken(array $tokens, int $start): ?Token { + for ($i = $start - 1; $i >= 0; --$i) { + if ($tokens[$i]->id === T_WHITESPACE) { + continue; + } + + return $tokens[$i]; + } + + return null; + } +} diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/AttributeEmulator.php b/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/AttributeEmulator.php index 1db1aec..c790934 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/AttributeEmulator.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/AttributeEmulator.php @@ -2,43 +2,36 @@ namespace ncc\ThirdParty\nikic\PhpParser\Lexer\TokenEmulator; -use ncc\ThirdParty\nikic\PhpParser\Lexer\Emulative; +use ncc\ThirdParty\nikic\PhpParser\PhpVersion; +use ncc\ThirdParty\nikic\PhpParser\Token; -final class AttributeEmulator extends TokenEmulator -{ - public function getPhpVersion(): string - { - return Emulative::PHP_8_0; +final class AttributeEmulator extends TokenEmulator { + public function getPhpVersion(): PhpVersion { + return PhpVersion::fromComponents(8, 0); } - public function isEmulationNeeded(string $code) : bool - { + public function isEmulationNeeded(string $code): bool { return strpos($code, '#[') !== false; } - public function emulate(string $code, array $tokens): array - { + public function emulate(string $code, array $tokens): array { // We need to manually iterate and manage a count because we'll change // the tokens array on the way. - $line = 1; for ($i = 0, $c = count($tokens); $i < $c; ++$i) { - if ($tokens[$i] === '#' && isset($tokens[$i + 1]) && $tokens[$i + 1] === '[') { + $token = $tokens[$i]; + if ($token->text === '#' && isset($tokens[$i + 1]) && $tokens[$i + 1]->text === '[') { array_splice($tokens, $i, 2, [ - [\T_ATTRIBUTE, '#[', $line] + new Token(\T_ATTRIBUTE, '#[', $token->line, $token->pos), ]); $c--; continue; } - if (\is_array($tokens[$i])) { - $line += substr_count($tokens[$i][1], "\n"); - } } return $tokens; } - public function reverseEmulate(string $code, array $tokens): array - { + public function reverseEmulate(string $code, array $tokens): array { // TODO return $tokens; } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/CoaleseEqualTokenEmulator.php b/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/CoaleseEqualTokenEmulator.php deleted file mode 100644 index 651f833..0000000 --- a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/CoaleseEqualTokenEmulator.php +++ /dev/null @@ -1,47 +0,0 @@ -id === \T_WHITESPACE + && $tokens[$pos + 2]->id === \T_STRING; } -} \ No newline at end of file +} diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/ExplicitOctalEmulator.php b/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/ExplicitOctalEmulator.php index 97ea9f9..8a6ec4c 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/ExplicitOctalEmulator.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/ExplicitOctalEmulator.php @@ -2,11 +2,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Lexer\TokenEmulator; -use ncc\ThirdParty\nikic\PhpParser\Lexer\Emulative; +use ncc\ThirdParty\nikic\PhpParser\PhpVersion; +use ncc\ThirdParty\nikic\PhpParser\Token; class ExplicitOctalEmulator extends TokenEmulator { - public function getPhpVersion(): string { - return Emulative::PHP_8_1; + public function getPhpVersion(): PhpVersion { + return PhpVersion::fromComponents(8, 1); } public function isEmulationNeeded(string $code): bool { @@ -15,13 +16,14 @@ class ExplicitOctalEmulator extends TokenEmulator { public function emulate(string $code, array $tokens): array { for ($i = 0, $c = count($tokens); $i < $c; ++$i) { - if ($tokens[$i][0] == \T_LNUMBER && $tokens[$i][1] === '0' && - isset($tokens[$i + 1]) && $tokens[$i + 1][0] == \T_STRING && - preg_match('/[oO][0-7]+(?:_[0-7]+)*/', $tokens[$i + 1][1]) + $token = $tokens[$i]; + if ($token->id == \T_LNUMBER && $token->text === '0' && + isset($tokens[$i + 1]) && $tokens[$i + 1]->id == \T_STRING && + preg_match('/[oO][0-7]+(?:_[0-7]+)*/', $tokens[$i + 1]->text) ) { - $tokenKind = $this->resolveIntegerOrFloatToken($tokens[$i + 1][1]); + $tokenKind = $this->resolveIntegerOrFloatToken($tokens[$i + 1]->text); array_splice($tokens, $i, 2, [ - [$tokenKind, '0' . $tokens[$i + 1][1], $tokens[$i][2]], + new Token($tokenKind, '0' . $tokens[$i + 1]->text, $token->line, $token->pos), ]); $c--; } @@ -29,8 +31,7 @@ class ExplicitOctalEmulator extends TokenEmulator { return $tokens; } - private function resolveIntegerOrFloatToken(string $str): int - { + private function resolveIntegerOrFloatToken(string $str): int { $str = substr($str, 1); $str = str_replace('_', '', $str); $num = octdec($str); @@ -41,4 +42,4 @@ class ExplicitOctalEmulator extends TokenEmulator { // Explicit octals were not legal code previously, don't bother. return $tokens; } -} \ No newline at end of file +} diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/FlexibleDocStringEmulator.php b/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/FlexibleDocStringEmulator.php deleted file mode 100644 index fb8a158..0000000 --- a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/FlexibleDocStringEmulator.php +++ /dev/null @@ -1,76 +0,0 @@ -\h*)\2(?![a-zA-Z0-9_\x80-\xff])(?(?:;?[\r\n])?)/x -REGEX; - - public function getPhpVersion(): string - { - return Emulative::PHP_7_3; - } - - public function isEmulationNeeded(string $code) : bool - { - return strpos($code, '<<<') !== false; - } - - public function emulate(string $code, array $tokens): array - { - // Handled by preprocessing + fixup. - return $tokens; - } - - public function reverseEmulate(string $code, array $tokens): array - { - // Not supported. - return $tokens; - } - - public function preprocessCode(string $code, array &$patches): string { - if (!preg_match_all(self::FLEXIBLE_DOC_STRING_REGEX, $code, $matches, PREG_SET_ORDER|PREG_OFFSET_CAPTURE)) { - // No heredoc/nowdoc found - return $code; - } - - // Keep track of how much we need to adjust string offsets due to the modifications we - // already made - $posDelta = 0; - foreach ($matches as $match) { - $indentation = $match['indentation'][0]; - $indentationStart = $match['indentation'][1]; - - $separator = $match['separator'][0]; - $separatorStart = $match['separator'][1]; - - if ($indentation === '' && $separator !== '') { - // Ordinary heredoc/nowdoc - continue; - } - - if ($indentation !== '') { - // Remove indentation - $indentationLen = strlen($indentation); - $code = substr_replace($code, '', $indentationStart + $posDelta, $indentationLen); - $patches[] = [$indentationStart + $posDelta, 'add', $indentation]; - $posDelta -= $indentationLen; - } - - if ($separator === '') { - // Insert newline as separator - $code = substr_replace($code, "\n", $separatorStart + $posDelta, 0); - $patches[] = [$separatorStart + $posDelta, 'remove', "\n"]; - $posDelta += 1; - } - } - - return $code; - } -} diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/FnTokenEmulator.php b/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/FnTokenEmulator.php deleted file mode 100644 index bf6f243..0000000 --- a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/FnTokenEmulator.php +++ /dev/null @@ -1,23 +0,0 @@ -getKeywordString()) !== false; } - protected function isKeywordContext(array $tokens, int $pos): bool - { - $previousNonSpaceToken = $this->getPreviousNonSpaceToken($tokens, $pos); - return $previousNonSpaceToken === null || $previousNonSpaceToken[0] !== \T_OBJECT_OPERATOR; + /** @param Token[] $tokens */ + protected function isKeywordContext(array $tokens, int $pos): bool { + $prevToken = $this->getPreviousNonSpaceToken($tokens, $pos); + if ($prevToken === null) { + return false; + } + return $prevToken->id !== \T_OBJECT_OPERATOR + && $prevToken->id !== \T_NULLSAFE_OBJECT_OPERATOR; } - public function emulate(string $code, array $tokens): array - { + public function emulate(string $code, array $tokens): array { $keywordString = $this->getKeywordString(); foreach ($tokens as $i => $token) { - if ($token[0] === T_STRING && strtolower($token[1]) === $keywordString + if ($token->id === T_STRING && strtolower($token->text) === $keywordString && $this->isKeywordContext($tokens, $i)) { - $tokens[$i][0] = $this->getKeywordToken(); + $token->id = $this->getKeywordToken(); } } return $tokens; } - /** - * @param mixed[] $tokens - * @return array|string|null - */ - private function getPreviousNonSpaceToken(array $tokens, int $start) - { + /** @param Token[] $tokens */ + private function getPreviousNonSpaceToken(array $tokens, int $start): ?Token { for ($i = $start - 1; $i >= 0; --$i) { - if ($tokens[$i][0] === T_WHITESPACE) { + if ($tokens[$i]->id === T_WHITESPACE) { continue; } @@ -48,12 +47,11 @@ abstract class KeywordEmulator extends TokenEmulator return null; } - public function reverseEmulate(string $code, array $tokens): array - { + public function reverseEmulate(string $code, array $tokens): array { $keywordToken = $this->getKeywordToken(); - foreach ($tokens as $i => $token) { - if ($token[0] === $keywordToken) { - $tokens[$i][0] = \T_STRING; + foreach ($tokens as $token) { + if ($token->id === $keywordToken) { + $token->id = \T_STRING; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/MatchTokenEmulator.php b/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/MatchTokenEmulator.php index 516f8a3..c6e3d08 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/MatchTokenEmulator.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/MatchTokenEmulator.php @@ -2,22 +2,18 @@ namespace ncc\ThirdParty\nikic\PhpParser\Lexer\TokenEmulator; -use ncc\ThirdParty\nikic\PhpParser\Lexer\Emulative; +use ncc\ThirdParty\nikic\PhpParser\PhpVersion; -final class MatchTokenEmulator extends KeywordEmulator -{ - public function getPhpVersion(): string - { - return Emulative::PHP_8_0; +final class MatchTokenEmulator extends KeywordEmulator { + public function getPhpVersion(): PhpVersion { + return PhpVersion::fromComponents(8, 0); } - public function getKeywordString(): string - { + public function getKeywordString(): string { return 'match'; } - public function getKeywordToken(): int - { + public function getKeywordToken(): int { return \T_MATCH; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/NullsafeTokenEmulator.php b/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/NullsafeTokenEmulator.php index 20f6d8f..a4c019a 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/NullsafeTokenEmulator.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/NullsafeTokenEmulator.php @@ -2,65 +2,58 @@ namespace ncc\ThirdParty\nikic\PhpParser\Lexer\TokenEmulator; -use ncc\ThirdParty\nikic\PhpParser\Lexer\Emulative; +use ncc\ThirdParty\nikic\PhpParser\PhpVersion; +use ncc\ThirdParty\nikic\PhpParser\Token; -final class NullsafeTokenEmulator extends TokenEmulator -{ - public function getPhpVersion(): string - { - return Emulative::PHP_8_0; +final class NullsafeTokenEmulator extends TokenEmulator { + public function getPhpVersion(): PhpVersion { + return PhpVersion::fromComponents(8, 0); } - public function isEmulationNeeded(string $code): bool - { + public function isEmulationNeeded(string $code): bool { return strpos($code, '?->') !== false; } - public function emulate(string $code, array $tokens): array - { + public function emulate(string $code, array $tokens): array { // We need to manually iterate and manage a count because we'll change // the tokens array on the way - $line = 1; for ($i = 0, $c = count($tokens); $i < $c; ++$i) { - if ($tokens[$i] === '?' && isset($tokens[$i + 1]) && $tokens[$i + 1][0] === \T_OBJECT_OPERATOR) { + $token = $tokens[$i]; + if ($token->text === '?' && isset($tokens[$i + 1]) && $tokens[$i + 1]->id === \T_OBJECT_OPERATOR) { array_splice($tokens, $i, 2, [ - [\T_NULLSAFE_OBJECT_OPERATOR, '?->', $line] + new Token(\T_NULLSAFE_OBJECT_OPERATOR, '?->', $token->line, $token->pos), ]); $c--; continue; } // Handle ?-> inside encapsed string. - if ($tokens[$i][0] === \T_ENCAPSED_AND_WHITESPACE && isset($tokens[$i - 1]) - && $tokens[$i - 1][0] === \T_VARIABLE - && preg_match('/^\?->([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)/', $tokens[$i][1], $matches) + if ($token->id === \T_ENCAPSED_AND_WHITESPACE && isset($tokens[$i - 1]) + && $tokens[$i - 1]->id === \T_VARIABLE + && preg_match('/^\?->([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)/', $token->text, $matches) ) { $replacement = [ - [\T_NULLSAFE_OBJECT_OPERATOR, '?->', $line], - [\T_STRING, $matches[1], $line], + new Token(\T_NULLSAFE_OBJECT_OPERATOR, '?->', $token->line, $token->pos), + new Token(\T_STRING, $matches[1], $token->line, $token->pos + 3), ]; - if (\strlen($matches[0]) !== \strlen($tokens[$i][1])) { - $replacement[] = [ + $matchLen = \strlen($matches[0]); + if ($matchLen !== \strlen($token->text)) { + $replacement[] = new Token( \T_ENCAPSED_AND_WHITESPACE, - \substr($tokens[$i][1], \strlen($matches[0])), - $line - ]; + \substr($token->text, $matchLen), + $token->line, $token->pos + $matchLen + ); } array_splice($tokens, $i, 1, $replacement); $c += \count($replacement) - 1; continue; } - - if (\is_array($tokens[$i])) { - $line += substr_count($tokens[$i][1], "\n"); - } } return $tokens; } - public function reverseEmulate(string $code, array $tokens): array - { + public function reverseEmulate(string $code, array $tokens): array { // ?-> was not valid code previously, don't bother. return $tokens; } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/NumericLiteralSeparatorEmulator.php b/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/NumericLiteralSeparatorEmulator.php deleted file mode 100644 index fb47c49..0000000 --- a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/NumericLiteralSeparatorEmulator.php +++ /dev/null @@ -1,105 +0,0 @@ -resolveIntegerOrFloatToken($match); - $newTokens = [[$tokenKind, $match, $token[2]]]; - - $numTokens = 1; - $len = $tokenLen; - while ($matchLen > $len) { - $nextToken = $tokens[$i + $numTokens]; - $nextTokenText = \is_array($nextToken) ? $nextToken[1] : $nextToken; - $nextTokenLen = \strlen($nextTokenText); - - $numTokens++; - if ($matchLen < $len + $nextTokenLen) { - // Split trailing characters into a partial token. - assert(is_array($nextToken), "Partial token should be an array token"); - $partialText = substr($nextTokenText, $matchLen - $len); - $newTokens[] = [$nextToken[0], $partialText, $nextToken[2]]; - break; - } - - $len += $nextTokenLen; - } - - array_splice($tokens, $i, $numTokens, $newTokens); - $c -= $numTokens - \count($newTokens); - $codeOffset += $matchLen; - } - - return $tokens; - } - - private function resolveIntegerOrFloatToken(string $str): int - { - $str = str_replace('_', '', $str); - - if (stripos($str, '0b') === 0) { - $num = bindec($str); - } elseif (stripos($str, '0x') === 0) { - $num = hexdec($str); - } elseif (stripos($str, '0') === 0 && ctype_digit($str)) { - $num = octdec($str); - } else { - $num = +$str; - } - - return is_float($num) ? T_DNUMBER : T_LNUMBER; - } - - public function reverseEmulate(string $code, array $tokens): array - { - // Numeric separators were not legal code previously, don't bother. - return $tokens; - } -} diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/PropertyTokenEmulator.php b/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/PropertyTokenEmulator.php new file mode 100644 index 0000000..47f1ce6 --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/PropertyTokenEmulator.php @@ -0,0 +1,19 @@ +text === '(' || + ($tokens[$pos + 1]->id === \T_WHITESPACE && isset($tokens[$pos + 2]) && - $tokens[$pos + 2][0] === '('))); + $tokens[$pos + 2]->text === '('))); } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/ReverseEmulator.php b/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/ReverseEmulator.php index 4501f93..69bbb3b 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/ReverseEmulator.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/ReverseEmulator.php @@ -2,19 +2,20 @@ namespace ncc\ThirdParty\nikic\PhpParser\Lexer\TokenEmulator; +use ncc\ThirdParty\nikic\PhpParser\PhpVersion; + /** * Reverses emulation direction of the inner emulator. */ -final class ReverseEmulator extends TokenEmulator -{ +final class ReverseEmulator extends TokenEmulator { /** @var TokenEmulator Inner emulator */ - private $emulator; + private TokenEmulator $emulator; public function __construct(TokenEmulator $emulator) { $this->emulator = $emulator; } - public function getPhpVersion(): string { + public function getPhpVersion(): PhpVersion { return $this->emulator->getPhpVersion(); } @@ -33,4 +34,4 @@ final class ReverseEmulator extends TokenEmulator public function preprocessCode(string $code, array &$patches): string { return $code; } -} \ No newline at end of file +} diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/TokenEmulator.php b/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/TokenEmulator.php index c641057..8e03d20 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/TokenEmulator.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Lexer/TokenEmulator/TokenEmulator.php @@ -2,23 +2,28 @@ namespace ncc\ThirdParty\nikic\PhpParser\Lexer\TokenEmulator; +use ncc\ThirdParty\nikic\PhpParser\PhpVersion; +use ncc\ThirdParty\nikic\PhpParser\Token; + /** @internal */ -abstract class TokenEmulator -{ - abstract public function getPhpVersion(): string; +abstract class TokenEmulator { + abstract public function getPhpVersion(): PhpVersion; abstract public function isEmulationNeeded(string $code): bool; /** - * @return array Modified Tokens + * @param Token[] $tokens Original tokens + * @return Token[] Modified Tokens */ abstract public function emulate(string $code, array $tokens): array; /** - * @return array Modified Tokens + * @param Token[] $tokens Original tokens + * @return Token[] Modified Tokens */ abstract public function reverseEmulate(string $code, array $tokens): array; + /** @param array{int, string, string}[] $patches */ public function preprocessCode(string $code, array &$patches): string { return $code; } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Modifiers.php b/src/ncc/ThirdParty/nikic/PhpParser/Modifiers.php new file mode 100644 index 0000000..d38060b --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/Modifiers.php @@ -0,0 +1,85 @@ + 'public', + self::PROTECTED => 'protected', + self::PRIVATE => 'private', + self::STATIC => 'static', + self::ABSTRACT => 'abstract', + self::FINAL => 'final', + self::READONLY => 'readonly', + self::PUBLIC_SET => 'public(set)', + self::PROTECTED_SET => 'protected(set)', + self::PRIVATE_SET => 'private(set)', + ]; + + public static function toString(int $modifier): string { + if (!isset(self::TO_STRING_MAP[$modifier])) { + throw new \InvalidArgumentException("Unknown modifier $modifier"); + } + return self::TO_STRING_MAP[$modifier]; + } + + private static function isValidModifier(int $modifier): bool { + $isPow2 = ($modifier & ($modifier - 1)) == 0 && $modifier != 0; + return $isPow2 && $modifier <= self::PRIVATE_SET; + } + + /** + * @internal + */ + public static function verifyClassModifier(int $a, int $b): void { + assert(self::isValidModifier($b)); + if (($a & $b) != 0) { + throw new Error( + 'Multiple ' . self::toString($b) . ' modifiers are not allowed'); + } + + if ($a & 48 && $b & 48) { + throw new Error('Cannot use the final modifier on an abstract class'); + } + } + + /** + * @internal + */ + public static function verifyModifier(int $a, int $b): void { + assert(self::isValidModifier($b)); + if (($a & Modifiers::VISIBILITY_MASK && $b & Modifiers::VISIBILITY_MASK) || + ($a & Modifiers::VISIBILITY_SET_MASK && $b & Modifiers::VISIBILITY_SET_MASK) + ) { + throw new Error('Multiple access type modifiers are not allowed'); + } + + if (($a & $b) != 0) { + throw new Error( + 'Multiple ' . self::toString($b) . ' modifiers are not allowed'); + } + + if ($a & 48 && $b & 48) { + throw new Error('Cannot use the final modifier on an abstract class member'); + } + } +} diff --git a/src/ncc/ThirdParty/nikic/PhpParser/NameContext.php b/src/ncc/ThirdParty/nikic/PhpParser/NameContext.php index cc8daea..26f68e3 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/NameContext.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/NameContext.php @@ -6,19 +6,18 @@ use ncc\ThirdParty\nikic\PhpParser\Node\Name; use ncc\ThirdParty\nikic\PhpParser\Node\Name\FullyQualified; use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; -class NameContext -{ +class NameContext { /** @var null|Name Current namespace */ - protected $namespace; + protected ?Name $namespace; /** @var Name[][] Map of format [aliasType => [aliasName => originalName]] */ - protected $aliases = []; + protected array $aliases = []; /** @var Name[][] Same as $aliases but preserving original case */ - protected $origAliases = []; + protected array $origAliases = []; /** @var ErrorHandler Error handler */ - protected $errorHandler; + protected ErrorHandler $errorHandler; /** * Create a name context. @@ -36,7 +35,7 @@ class NameContext * * @param Name|null $namespace Null is the global namespace */ - public function startNamespace(Name $namespace = null) { + public function startNamespace(?Name $namespace = null): void { $this->namespace = $namespace; $this->origAliases = $this->aliases = [ Stmt\Use_::TYPE_NORMAL => [], @@ -48,12 +47,12 @@ class NameContext /** * Add an alias / import. * - * @param Name $name Original name - * @param string $aliasName Aliased name - * @param int $type One of Stmt\Use_::TYPE_* - * @param array $errorAttrs Attributes to use to report an error + * @param Name $name Original name + * @param string $aliasName Aliased name + * @param Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_* + * @param array $errorAttrs Attributes to use to report an error */ - public function addAlias(Name $name, string $aliasName, int $type, array $errorAttrs = []) { + public function addAlias(Name $name, string $aliasName, int $type, array $errorAttrs = []): void { // Constant names are case sensitive, everything else case insensitive if ($type === Stmt\Use_::TYPE_CONSTANT) { $aliasLookupName = $aliasName; @@ -87,7 +86,7 @@ class NameContext * * @return null|Name Namespace (or null if global namespace) */ - public function getNamespace() { + public function getNamespace(): ?Name { return $this->namespace; } @@ -95,11 +94,11 @@ class NameContext * Get resolved name. * * @param Name $name Name to resolve - * @param int $type One of Stmt\Use_::TYPE_{FUNCTION|CONSTANT} + * @param Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_{FUNCTION|CONSTANT} * * @return null|Name Resolved name, or null if static resolution is not possible */ - public function getResolvedName(Name $name, int $type) { + public function getResolvedName(Name $name, int $type): ?Name { // don't resolve special class names if ($type === Stmt\Use_::TYPE_NORMAL && $name->isSpecialClassName()) { if (!$name->isUnqualified()) { @@ -142,7 +141,7 @@ class NameContext * * @return Name Resolved name */ - public function getResolvedClassName(Name $name) : Name { + public function getResolvedClassName(Name $name): Name { return $this->getResolvedName($name, Stmt\Use_::TYPE_NORMAL); } @@ -150,11 +149,11 @@ class NameContext * Get possible ways of writing a fully qualified name (e.g., by making use of aliases). * * @param string $name Fully-qualified name (without leading namespace separator) - * @param int $type One of Stmt\Use_::TYPE_* + * @param Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_* * * @return Name[] Possible representations of the name */ - public function getPossibleNames(string $name, int $type) : array { + public function getPossibleNames(string $name, int $type): array { $lcName = strtolower($name); if ($type === Stmt\Use_::TYPE_NORMAL) { @@ -186,7 +185,7 @@ class NameContext // Check for relevant type-specific use statements foreach ($this->origAliases[$type] as $alias => $orig) { if ($type === Stmt\Use_::TYPE_CONSTANT) { - // Constants are are complicated-sensitive + // Constants are complicated-sensitive $normalizedOrig = $this->normalizeConstName($orig->toString()); if ($normalizedOrig === $this->normalizeConstName($name)) { $possibleNames[] = new Name($alias); @@ -206,11 +205,11 @@ class NameContext * Get shortest representation of this fully-qualified name. * * @param string $name Fully-qualified name (without leading namespace separator) - * @param int $type One of Stmt\Use_::TYPE_* + * @param Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_* * * @return Name Shortest representation */ - public function getShortName(string $name, int $type) : Name { + public function getShortName(string $name, int $type): Name { $possibleNames = $this->getPossibleNames($name, $type); // Find shortest name @@ -224,10 +223,10 @@ class NameContext } } - return $shortestName; + return $shortestName; } - private function resolveAlias(Name $name, $type) { + private function resolveAlias(Name $name, int $type): ?FullyQualified { $firstPart = $name->getFirst(); if ($name->isQualified()) { @@ -250,7 +249,7 @@ class NameContext return null; } - private function getNamespaceRelativeName(string $name, string $lcName, int $type) { + private function getNamespaceRelativeName(string $name, string $lcName, int $type): ?Name { if (null === $this->namespace) { return new Name($name); } @@ -271,7 +270,7 @@ class NameContext return null; } - private function normalizeConstName(string $name) { + private function normalizeConstName(string $name): string { $nsSep = strrpos($name, '\\'); if (false === $nsSep) { return $name; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node.php b/src/ncc/ThirdParty/nikic/PhpParser/Node.php index eff1585..6f31184 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node.php @@ -2,28 +2,31 @@ namespace ncc\ThirdParty\nikic\PhpParser; -interface Node -{ +interface Node { /** * Gets the type of the node. * + * @psalm-return non-empty-string * @return string Type of the node */ - public function getType() : string; + public function getType(): string; /** * Gets the names of the sub nodes. * - * @return array Names of sub nodes + * @return string[] Names of sub nodes */ - public function getSubNodeNames() : array; + public function getSubNodeNames(): array; /** * Gets line the node started in (alias of getStartLine). * * @return int Start line (or -1 if not available) + * @phpstan-return -1|positive-int + * + * @deprecated Use getStartLine() instead */ - public function getLine() : int; + public function getLine(): int; /** * Gets line the node started in. @@ -31,8 +34,9 @@ interface Node * Requires the 'startLine' attribute to be enabled in the lexer (enabled by default). * * @return int Start line (or -1 if not available) + * @phpstan-return -1|positive-int */ - public function getStartLine() : int; + public function getStartLine(): int; /** * Gets the line the node ended in. @@ -40,8 +44,9 @@ interface Node * Requires the 'endLine' attribute to be enabled in the lexer (enabled by default). * * @return int End line (or -1 if not available) + * @phpstan-return -1|positive-int */ - public function getEndLine() : int; + public function getEndLine(): int; /** * Gets the token offset of the first token that is part of this node. @@ -52,7 +57,7 @@ interface Node * * @return int Token start position (or -1 if not available) */ - public function getStartTokenPos() : int; + public function getStartTokenPos(): int; /** * Gets the token offset of the last token that is part of this node. @@ -63,7 +68,7 @@ interface Node * * @return int Token end position (or -1 if not available) */ - public function getEndTokenPos() : int; + public function getEndTokenPos(): int; /** * Gets the file offset of the first character that is part of this node. @@ -72,7 +77,7 @@ interface Node * * @return int File start position (or -1 if not available) */ - public function getStartFilePos() : int; + public function getStartFilePos(): int; /** * Gets the file offset of the last character that is part of this node. @@ -81,7 +86,7 @@ interface Node * * @return int File end position (or -1 if not available) */ - public function getEndFilePos() : int; + public function getEndFilePos(): int; /** * Gets all comments directly preceding this node. @@ -90,14 +95,14 @@ interface Node * * @return Comment[] */ - public function getComments() : array; + public function getComments(): array; /** * Gets the doc comment of the node. * * @return null|Comment\Doc Doc comment object or null */ - public function getDocComment(); + public function getDocComment(): ?Comment\Doc; /** * Sets the doc comment of the node. @@ -106,30 +111,24 @@ interface Node * * @param Comment\Doc $docComment Doc comment to set */ - public function setDocComment(Comment\Doc $docComment); + public function setDocComment(Comment\Doc $docComment): void; /** * Sets an attribute on a node. * - * @param string $key - * @param mixed $value + * @param mixed $value */ - public function setAttribute(string $key, $value); + public function setAttribute(string $key, $value): void; /** * Returns whether an attribute exists. - * - * @param string $key - * - * @return bool */ - public function hasAttribute(string $key) : bool; + public function hasAttribute(string $key): bool; /** * Returns the value of an attribute. * - * @param string $key - * @param mixed $default + * @param mixed $default * * @return mixed */ @@ -138,14 +137,14 @@ interface Node /** * Returns all the attributes of this node. * - * @return array + * @return array */ - public function getAttributes() : array; + public function getAttributes(): array; /** * Replaces all the attributes of this node. * - * @param array $attributes + * @param array $attributes */ - public function setAttributes(array $attributes); + public function setAttributes(array $attributes): void; } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Arg.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Arg.php index 9fd58e9..c2da86e 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Arg.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Arg.php @@ -2,32 +2,30 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node; -use ncc\ThirdParty\nikic\PhpParser\Node\VariadicPlaceholder; use ncc\ThirdParty\nikic\PhpParser\NodeAbstract; -class Arg extends NodeAbstract -{ +class Arg extends NodeAbstract { /** @var Identifier|null Parameter name (for named parameters) */ - public $name; + public ?Identifier $name; /** @var Expr Value to pass */ - public $value; + public Expr $value; /** @var bool Whether to pass by ref */ - public $byRef; + public bool $byRef; /** @var bool Whether to unpack the argument */ - public $unpack; + public bool $unpack; /** * Constructs a function call argument node. * - * @param Expr $value Value to pass - * @param bool $byRef Whether to pass by ref - * @param bool $unpack Whether to unpack the argument - * @param array $attributes Additional attributes + * @param Expr $value Value to pass + * @param bool $byRef Whether to pass by ref + * @param bool $unpack Whether to unpack the argument + * @param array $attributes Additional attributes * @param Identifier|null $name Parameter name (for named parameters) */ public function __construct( Expr $value, bool $byRef = false, bool $unpack = false, array $attributes = [], - Identifier $name = null + ?Identifier $name = null ) { $this->attributes = $attributes; $this->name = $name; @@ -36,11 +34,11 @@ class Arg extends NodeAbstract $this->unpack = $unpack; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['name', 'value', 'byRef', 'unpack']; } - - public function getType() : string { + + public function getType(): string { return 'Arg'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/ArrayItem.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/ArrayItem.php new file mode 100644 index 0000000..379eead --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/ArrayItem.php @@ -0,0 +1,43 @@ + $attributes Additional attributes + */ + public function __construct(Expr $value, ?Expr $key = null, bool $byRef = false, array $attributes = [], bool $unpack = false) { + $this->attributes = $attributes; + $this->key = $key; + $this->value = $value; + $this->byRef = $byRef; + $this->unpack = $unpack; + } + + public function getSubNodeNames(): array { + return ['key', 'value', 'byRef', 'unpack']; + } + + public function getType(): string { + return 'ArrayItem'; + } +} + +// @deprecated compatibility alias +class_alias(ArrayItem::class, Expr\ArrayItem::class); diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Attribute.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Attribute.php index 06f9151..2f5c834 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Attribute.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Attribute.php @@ -5,18 +5,17 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\NodeAbstract; -class Attribute extends NodeAbstract -{ +class Attribute extends NodeAbstract { /** @var Name Attribute name */ - public $name; + public Name $name; - /** @var Arg[] Attribute arguments */ - public $args; + /** @var list Attribute arguments */ + public array $args; /** - * @param Node\Name $name Attribute name - * @param Arg[] $args Attribute arguments - * @param array $attributes Additional node attributes + * @param Node\Name $name Attribute name + * @param list $args Attribute arguments + * @param array $attributes Additional node attributes */ public function __construct(Name $name, array $args = [], array $attributes = []) { $this->attributes = $attributes; @@ -24,11 +23,11 @@ class Attribute extends NodeAbstract $this->args = $args; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['name', 'args']; } - public function getType() : string { + public function getType(): string { return 'Attribute'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/AttributeGroup.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/AttributeGroup.php index bbfddec..82669c0 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/AttributeGroup.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/AttributeGroup.php @@ -2,28 +2,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node; -use ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\NodeAbstract; -class AttributeGroup extends NodeAbstract -{ +class AttributeGroup extends NodeAbstract { /** @var Attribute[] Attributes */ - public $attrs; + public array $attrs; /** * @param Attribute[] $attrs PHP attributes - * @param array $attributes Additional node attributes + * @param array $attributes Additional node attributes */ public function __construct(array $attrs, array $attributes = []) { $this->attributes = $attributes; $this->attrs = $attrs; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['attrs']; } - public function getType() : string { + public function getType(): string { return 'AttributeGroup'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/ClosureUse.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/ClosureUse.php new file mode 100644 index 0000000..fc027f4 --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/ClosureUse.php @@ -0,0 +1,36 @@ + $attributes Additional attributes + */ + public function __construct(Expr\Variable $var, bool $byRef = false, array $attributes = []) { + $this->attributes = $attributes; + $this->var = $var; + $this->byRef = $byRef; + } + + public function getSubNodeNames(): array { + return ['var', 'byRef']; + } + + public function getType(): string { + return 'ClosureUse'; + } +} + +// @deprecated compatibility alias +class_alias(ClosureUse::class, Expr\ClosureUse::class); diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/ComplexType.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/ComplexType.php index 7a27450..bc9ae69 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/ComplexType.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/ComplexType.php @@ -9,6 +9,5 @@ use ncc\ThirdParty\nikic\PhpParser\NodeAbstract; * * It does not provide any shared behavior and exists only for type-checking purposes. */ -abstract class ComplexType extends NodeAbstract -{ +abstract class ComplexType extends NodeAbstract { } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Const_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Const_.php index d84f4be..4779cd1 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Const_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Const_.php @@ -4,22 +4,21 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\NodeAbstract; -class Const_ extends NodeAbstract -{ +class Const_ extends NodeAbstract { /** @var Identifier Name */ - public $name; + public Identifier $name; /** @var Expr Value */ - public $value; + public Expr $value; /** @var Name|null Namespaced name (if using NameResolver) */ - public $namespacedName; + public ?Name $namespacedName; /** * Constructs a const node for use in class const and const statements. * - * @param string|Identifier $name Name - * @param Expr $value Value - * @param array $attributes Additional attributes + * @param string|Identifier $name Name + * @param Expr $value Value + * @param array $attributes Additional attributes */ public function __construct($name, Expr $value, array $attributes = []) { $this->attributes = $attributes; @@ -27,11 +26,11 @@ class Const_ extends NodeAbstract $this->value = $value; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['name', 'value']; } - public function getType() : string { + public function getType(): string { return 'Const'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/DeclareItem.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/DeclareItem.php new file mode 100644 index 0000000..6233cbf --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/DeclareItem.php @@ -0,0 +1,37 @@ +value pair node. + * + * @param string|Node\Identifier $key Key + * @param Node\Expr $value Value + * @param array $attributes Additional attributes + */ + public function __construct($key, Node\Expr $value, array $attributes = []) { + $this->attributes = $attributes; + $this->key = \is_string($key) ? new Node\Identifier($key) : $key; + $this->value = $value; + } + + public function getSubNodeNames(): array { + return ['key', 'value']; + } + + public function getType(): string { + return 'DeclareItem'; + } +} + +// @deprecated compatibility alias +class_alias(DeclareItem::class, Stmt\DeclareDeclare::class); diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr.php index ea95af8..60503af 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr.php @@ -4,6 +4,5 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\NodeAbstract; -abstract class Expr extends NodeAbstract -{ +abstract class Expr extends NodeAbstract { } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ArrayDimFetch.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ArrayDimFetch.php index b30edec..11061f3 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ArrayDimFetch.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ArrayDimFetch.php @@ -4,31 +4,30 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class ArrayDimFetch extends Expr -{ +class ArrayDimFetch extends Expr { /** @var Expr Variable */ - public $var; + public Expr $var; /** @var null|Expr Array index / dim */ - public $dim; + public ?Expr $dim; /** * Constructs an array index fetch node. * - * @param Expr $var Variable - * @param null|Expr $dim Array index / dim - * @param array $attributes Additional attributes + * @param Expr $var Variable + * @param null|Expr $dim Array index / dim + * @param array $attributes Additional attributes */ - public function __construct(Expr $var, Expr $dim = null, array $attributes = []) { + public function __construct(Expr $var, ?Expr $dim = null, array $attributes = []) { $this->attributes = $attributes; $this->var = $var; $this->dim = $dim; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['var', 'dim']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_ArrayDimFetch'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ArrayItem.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ArrayItem.php index 65398af..490ac93 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ArrayItem.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ArrayItem.php @@ -1,41 +1,3 @@ attributes = $attributes; - $this->key = $key; - $this->value = $value; - $this->byRef = $byRef; - $this->unpack = $unpack; - } - - public function getSubNodeNames() : array { - return ['key', 'value', 'byRef', 'unpack']; - } - - public function getType() : string { - return 'Expr_ArrayItem'; - } -} +require __DIR__ . '/../ArrayItem.php'; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Array_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Array_.php index bf4aa40..1fc9418 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Array_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Array_.php @@ -2,33 +2,33 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; +use ncc\ThirdParty\nikic\PhpParser\Node\ArrayItem; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class Array_ extends Expr -{ +class Array_ extends Expr { // For use in "kind" attribute - const KIND_LONG = 1; // array() syntax - const KIND_SHORT = 2; // [] syntax + public const KIND_LONG = 1; // array() syntax + public const KIND_SHORT = 2; // [] syntax - /** @var (ArrayItem|null)[] Items */ - public $items; + /** @var ArrayItem[] Items */ + public array $items; /** * Constructs an array node. * - * @param (ArrayItem|null)[] $items Items of the array - * @param array $attributes Additional attributes + * @param ArrayItem[] $items Items of the array + * @param array $attributes Additional attributes */ public function __construct(array $items = [], array $attributes = []) { $this->attributes = $attributes; $this->items = $items; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['items']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_Array'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ArrowFunction.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ArrowFunction.php index a57db81..812b0ae 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ArrowFunction.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ArrowFunction.php @@ -6,55 +6,60 @@ use ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\FunctionLike; -class ArrowFunction extends Expr implements FunctionLike -{ - /** @var bool */ - public $static; +class ArrowFunction extends Expr implements FunctionLike { + /** @var bool Whether the closure is static */ + public bool $static; - /** @var bool */ - public $byRef; + /** @var bool Whether to return by reference */ + public bool $byRef; /** @var Node\Param[] */ - public $params = []; + public array $params = []; /** @var null|Node\Identifier|Node\Name|Node\ComplexType */ - public $returnType; + public ?Node $returnType; - /** @var Expr */ - public $expr; + /** @var Expr Expression body */ + public Expr $expr; /** @var Node\AttributeGroup[] */ - public $attrGroups; + public array $attrGroups; /** - * @param array $subNodes Array of the following optional subnodes: - * 'static' => false : Whether the closure is static - * 'byRef' => false : Whether to return by reference - * 'params' => array() : Parameters - * 'returnType' => null : Return type - * 'expr' => Expr : Expression body - * 'attrGroups' => array() : PHP attribute groups - * @param array $attributes Additional attributes + * @param array{ + * expr: Expr, + * static?: bool, + * byRef?: bool, + * params?: Node\Param[], + * returnType?: null|Node\Identifier|Node\Name|Node\ComplexType, + * attrGroups?: Node\AttributeGroup[] + * } $subNodes Array of the following subnodes: + * 'expr' : Expression body + * 'static' => false : Whether the closure is static + * 'byRef' => false : Whether to return by reference + * 'params' => array() : Parameters + * 'returnType' => null : Return type + * 'attrGroups' => array() : PHP attribute groups + * @param array $attributes Additional attributes */ - public function __construct(array $subNodes = [], array $attributes = []) { + public function __construct(array $subNodes, array $attributes = []) { $this->attributes = $attributes; $this->static = $subNodes['static'] ?? false; $this->byRef = $subNodes['byRef'] ?? false; $this->params = $subNodes['params'] ?? []; - $returnType = $subNodes['returnType'] ?? null; - $this->returnType = \is_string($returnType) ? new Node\Identifier($returnType) : $returnType; + $this->returnType = $subNodes['returnType'] ?? null; $this->expr = $subNodes['expr']; $this->attrGroups = $subNodes['attrGroups'] ?? []; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['attrGroups', 'static', 'byRef', 'params', 'returnType', 'expr']; } - public function returnsByRef() : bool { + public function returnsByRef(): bool { return $this->byRef; } - public function getParams() : array { + public function getParams(): array { return $this->params; } @@ -62,18 +67,18 @@ class ArrowFunction extends Expr implements FunctionLike return $this->returnType; } - public function getAttrGroups() : array { + public function getAttrGroups(): array { return $this->attrGroups; } /** * @return Node\Stmt\Return_[] */ - public function getStmts() : array { + public function getStmts(): array { return [new Node\Stmt\Return_($this->expr)]; } - public function getType() : string { + public function getType(): string { return 'Expr_ArrowFunction'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Assign.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Assign.php index cf88b0f..161b634 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Assign.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Assign.php @@ -4,19 +4,18 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class Assign extends Expr -{ +class Assign extends Expr { /** @var Expr Variable */ - public $var; + public Expr $var; /** @var Expr Expression */ - public $expr; + public Expr $expr; /** * Constructs an assignment node. * - * @param Expr $var Variable - * @param Expr $expr Expression - * @param array $attributes Additional attributes + * @param Expr $var Variable + * @param Expr $expr Expression + * @param array $attributes Additional attributes */ public function __construct(Expr $var, Expr $expr, array $attributes = []) { $this->attributes = $attributes; @@ -24,11 +23,11 @@ class Assign extends Expr $this->expr = $expr; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['var', 'expr']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_Assign'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp.php index 3706fd1..76b6ab8 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp.php @@ -4,19 +4,18 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -abstract class AssignOp extends Expr -{ +abstract class AssignOp extends Expr { /** @var Expr Variable */ - public $var; + public Expr $var; /** @var Expr Expression */ - public $expr; + public Expr $expr; /** * Constructs a compound assignment operation node. * - * @param Expr $var Variable - * @param Expr $expr Expression - * @param array $attributes Additional attributes + * @param Expr $var Variable + * @param Expr $expr Expression + * @param array $attributes Additional attributes */ public function __construct(Expr $var, Expr $expr, array $attributes = []) { $this->attributes = $attributes; @@ -24,7 +23,7 @@ abstract class AssignOp extends Expr $this->expr = $expr; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['var', 'expr']; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/BitwiseAnd.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/BitwiseAnd.php index 06482f1..8289f63 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/BitwiseAnd.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/BitwiseAnd.php @@ -4,9 +4,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; -class BitwiseAnd extends AssignOp -{ - public function getType() : string { +class BitwiseAnd extends AssignOp { + public function getType(): string { return 'Expr_AssignOp_BitwiseAnd'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/BitwiseOr.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/BitwiseOr.php index 1455871..bee8810 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/BitwiseOr.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/BitwiseOr.php @@ -4,9 +4,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; -class BitwiseOr extends AssignOp -{ - public function getType() : string { +class BitwiseOr extends AssignOp { + public function getType(): string { return 'Expr_AssignOp_BitwiseOr'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/BitwiseXor.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/BitwiseXor.php index 82d30f8..7955566 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/BitwiseXor.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/BitwiseXor.php @@ -4,9 +4,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; -class BitwiseXor extends AssignOp -{ - public function getType() : string { +class BitwiseXor extends AssignOp { + public function getType(): string { return 'Expr_AssignOp_BitwiseXor'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Coalesce.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Coalesce.php index 2e92197..9f9ebbf 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Coalesce.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Coalesce.php @@ -4,9 +4,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; -class Coalesce extends AssignOp -{ - public function getType() : string { +class Coalesce extends AssignOp { + public function getType(): string { return 'Expr_AssignOp_Coalesce'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Concat.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Concat.php index bc329cd..602c43e 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Concat.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Concat.php @@ -4,9 +4,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; -class Concat extends AssignOp -{ - public function getType() : string { +class Concat extends AssignOp { + public function getType(): string { return 'Expr_AssignOp_Concat'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Div.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Div.php index 6744b85..a1122c3 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Div.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Div.php @@ -4,9 +4,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; -class Div extends AssignOp -{ - public function getType() : string { +class Div extends AssignOp { + public function getType(): string { return 'Expr_AssignOp_Div'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Minus.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Minus.php index 139be60..a9d6010 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Minus.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Minus.php @@ -4,9 +4,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; -class Minus extends AssignOp -{ - public function getType() : string { +class Minus extends AssignOp { + public function getType(): string { return 'Expr_AssignOp_Minus'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Mod.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Mod.php index 525b5cc..2bacf72 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Mod.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Mod.php @@ -4,9 +4,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; -class Mod extends AssignOp -{ - public function getType() : string { +class Mod extends AssignOp { + public function getType(): string { return 'Expr_AssignOp_Mod'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Mul.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Mul.php index d499939..0d2663d 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Mul.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Mul.php @@ -4,9 +4,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; -class Mul extends AssignOp -{ - public function getType() : string { +class Mul extends AssignOp { + public function getType(): string { return 'Expr_AssignOp_Mul'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Plus.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Plus.php index 4eaa010..2a51155 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Plus.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Plus.php @@ -4,9 +4,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; -class Plus extends AssignOp -{ - public function getType() : string { +class Plus extends AssignOp { + public function getType(): string { return 'Expr_AssignOp_Plus'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Pow.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Pow.php index 62d9869..6cf212c 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Pow.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/Pow.php @@ -4,9 +4,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; -class Pow extends AssignOp -{ - public function getType() : string { +class Pow extends AssignOp { + public function getType(): string { return 'Expr_AssignOp_Pow'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/ShiftLeft.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/ShiftLeft.php index 8142b19..dc26bf8 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/ShiftLeft.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/ShiftLeft.php @@ -4,9 +4,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; -class ShiftLeft extends AssignOp -{ - public function getType() : string { +class ShiftLeft extends AssignOp { + public function getType(): string { return 'Expr_AssignOp_ShiftLeft'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/ShiftRight.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/ShiftRight.php index 7c39a18..291168f 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/ShiftRight.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignOp/ShiftRight.php @@ -4,9 +4,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; -class ShiftRight extends AssignOp -{ - public function getType() : string { +class ShiftRight extends AssignOp { + public function getType(): string { return 'Expr_AssignOp_ShiftRight'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignRef.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignRef.php index 300b962..95df8a1 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignRef.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/AssignRef.php @@ -4,19 +4,18 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class AssignRef extends Expr -{ +class AssignRef extends Expr { /** @var Expr Variable reference is assigned to */ - public $var; + public Expr $var; /** @var Expr Variable which is referenced */ - public $expr; + public Expr $expr; /** * Constructs an assignment node. * - * @param Expr $var Variable - * @param Expr $expr Expression - * @param array $attributes Additional attributes + * @param Expr $var Variable + * @param Expr $expr Expression + * @param array $attributes Additional attributes */ public function __construct(Expr $var, Expr $expr, array $attributes = []) { $this->attributes = $attributes; @@ -24,11 +23,11 @@ class AssignRef extends Expr $this->expr = $expr; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['var', 'expr']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_AssignRef'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp.php index c038342..f9249ea 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp.php @@ -4,19 +4,18 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -abstract class BinaryOp extends Expr -{ +abstract class BinaryOp extends Expr { /** @var Expr The left hand side expression */ - public $left; + public Expr $left; /** @var Expr The right hand side expression */ - public $right; + public Expr $right; /** * Constructs a binary operator node. * - * @param Expr $left The left hand side expression - * @param Expr $right The right hand side expression - * @param array $attributes Additional attributes + * @param Expr $left The left hand side expression + * @param Expr $right The right hand side expression + * @param array $attributes Additional attributes */ public function __construct(Expr $left, Expr $right, array $attributes = []) { $this->attributes = $attributes; @@ -24,7 +23,7 @@ abstract class BinaryOp extends Expr $this->right = $right; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['left', 'right']; } @@ -33,8 +32,6 @@ abstract class BinaryOp extends Expr * * In the case there are multiple possible sigils for an operator, this method does not * necessarily return the one used in the parsed code. - * - * @return string */ - abstract public function getOperatorSigil() : string; + abstract public function getOperatorSigil(): string; } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php index 7efe65a..d5c6257 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class BitwiseAnd extends BinaryOp -{ - public function getOperatorSigil() : string { +class BitwiseAnd extends BinaryOp { + public function getOperatorSigil(): string { return '&'; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_BitwiseAnd'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/BitwiseOr.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/BitwiseOr.php index 5e66609..2b65e30 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/BitwiseOr.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/BitwiseOr.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class BitwiseOr extends BinaryOp -{ - public function getOperatorSigil() : string { +class BitwiseOr extends BinaryOp { + public function getOperatorSigil(): string { return '|'; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_BitwiseOr'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/BitwiseXor.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/BitwiseXor.php index aa632ac..0488609 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/BitwiseXor.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/BitwiseXor.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class BitwiseXor extends BinaryOp -{ - public function getOperatorSigil() : string { +class BitwiseXor extends BinaryOp { + public function getOperatorSigil(): string { return '^'; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_BitwiseXor'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/BooleanAnd.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/BooleanAnd.php index 592a8f4..a3ccb81 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/BooleanAnd.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/BooleanAnd.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class BooleanAnd extends BinaryOp -{ - public function getOperatorSigil() : string { +class BooleanAnd extends BinaryOp { + public function getOperatorSigil(): string { return '&&'; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_BooleanAnd'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/BooleanOr.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/BooleanOr.php index a274b8e..010f167 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/BooleanOr.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/BooleanOr.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class BooleanOr extends BinaryOp -{ - public function getOperatorSigil() : string { +class BooleanOr extends BinaryOp { + public function getOperatorSigil(): string { return '||'; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_BooleanOr'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Coalesce.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Coalesce.php index 5fcca6a..bbe862d 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Coalesce.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Coalesce.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class Coalesce extends BinaryOp -{ - public function getOperatorSigil() : string { +class Coalesce extends BinaryOp { + public function getOperatorSigil(): string { return '??'; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_Coalesce'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Concat.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Concat.php index 05b4130..f7dbbd9 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Concat.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Concat.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class Concat extends BinaryOp -{ - public function getOperatorSigil() : string { +class Concat extends BinaryOp { + public function getOperatorSigil(): string { return '.'; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_Concat'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Div.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Div.php index 37273c0..57b9e77 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Div.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Div.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class Div extends BinaryOp -{ - public function getOperatorSigil() : string { +class Div extends BinaryOp { + public function getOperatorSigil(): string { return '/'; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_Div'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Equal.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Equal.php index 8095896..b91a3f6 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Equal.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Equal.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class Equal extends BinaryOp -{ - public function getOperatorSigil() : string { +class Equal extends BinaryOp { + public function getOperatorSigil(): string { return '=='; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_Equal'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Greater.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Greater.php index c3706f0..efc8cd5 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Greater.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Greater.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class Greater extends BinaryOp -{ - public function getOperatorSigil() : string { +class Greater extends BinaryOp { + public function getOperatorSigil(): string { return '>'; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_Greater'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/GreaterOrEqual.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/GreaterOrEqual.php index 3d13407..34f7c8a 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/GreaterOrEqual.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/GreaterOrEqual.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class GreaterOrEqual extends BinaryOp -{ - public function getOperatorSigil() : string { +class GreaterOrEqual extends BinaryOp { + public function getOperatorSigil(): string { return '>='; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_GreaterOrEqual'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Identical.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Identical.php index f04ce7d..3ba9aa7 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Identical.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Identical.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class Identical extends BinaryOp -{ - public function getOperatorSigil() : string { +class Identical extends BinaryOp { + public function getOperatorSigil(): string { return '==='; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_Identical'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/LogicalAnd.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/LogicalAnd.php index a93ed2e..fab1f8e 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/LogicalAnd.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/LogicalAnd.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class LogicalAnd extends BinaryOp -{ - public function getOperatorSigil() : string { +class LogicalAnd extends BinaryOp { + public function getOperatorSigil(): string { return 'and'; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_LogicalAnd'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/LogicalOr.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/LogicalOr.php index 16c7347..7181178 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/LogicalOr.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/LogicalOr.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class LogicalOr extends BinaryOp -{ - public function getOperatorSigil() : string { +class LogicalOr extends BinaryOp { + public function getOperatorSigil(): string { return 'or'; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_LogicalOr'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/LogicalXor.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/LogicalXor.php index 557ae1b..0976e03 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/LogicalXor.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/LogicalXor.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class LogicalXor extends BinaryOp -{ - public function getOperatorSigil() : string { +class LogicalXor extends BinaryOp { + public function getOperatorSigil(): string { return 'xor'; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_LogicalXor'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Minus.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Minus.php index 08136b8..4d3796e 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Minus.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Minus.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class Minus extends BinaryOp -{ - public function getOperatorSigil() : string { +class Minus extends BinaryOp { + public function getOperatorSigil(): string { return '-'; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_Minus'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Mod.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Mod.php index 9bc9ade..cc38dc7 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Mod.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Mod.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class Mod extends BinaryOp -{ - public function getOperatorSigil() : string { +class Mod extends BinaryOp { + public function getOperatorSigil(): string { return '%'; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_Mod'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Mul.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Mul.php index e9f8ff3..138bf29 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Mul.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Mul.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class Mul extends BinaryOp -{ - public function getOperatorSigil() : string { +class Mul extends BinaryOp { + public function getOperatorSigil(): string { return '*'; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_Mul'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/NotEqual.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/NotEqual.php index f7d2954..eb05d82 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/NotEqual.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/NotEqual.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class NotEqual extends BinaryOp -{ - public function getOperatorSigil() : string { +class NotEqual extends BinaryOp { + public function getOperatorSigil(): string { return '!='; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_NotEqual'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/NotIdentical.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/NotIdentical.php index fb1c21b..79b7475 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/NotIdentical.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/NotIdentical.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class NotIdentical extends BinaryOp -{ - public function getOperatorSigil() : string { +class NotIdentical extends BinaryOp { + public function getOperatorSigil(): string { return '!=='; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_NotIdentical'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Plus.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Plus.php index 3b5ea21..a37fb8f 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Plus.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Plus.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class Plus extends BinaryOp -{ - public function getOperatorSigil() : string { +class Plus extends BinaryOp { + public function getOperatorSigil(): string { return '+'; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_Plus'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Pow.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Pow.php index 04d42f4..8bf919e 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Pow.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Pow.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class Pow extends BinaryOp -{ - public function getOperatorSigil() : string { +class Pow extends BinaryOp { + public function getOperatorSigil(): string { return '**'; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_Pow'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/ShiftLeft.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/ShiftLeft.php index b159650..6426c85 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/ShiftLeft.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/ShiftLeft.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class ShiftLeft extends BinaryOp -{ - public function getOperatorSigil() : string { +class ShiftLeft extends BinaryOp { + public function getOperatorSigil(): string { return '<<'; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_ShiftLeft'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/ShiftRight.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/ShiftRight.php index 5614c02..aefd62b 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/ShiftRight.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/ShiftRight.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class ShiftRight extends BinaryOp -{ - public function getOperatorSigil() : string { +class ShiftRight extends BinaryOp { + public function getOperatorSigil(): string { return '>>'; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_ShiftRight'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Smaller.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Smaller.php index b23ab9c..fcf31f0 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Smaller.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Smaller.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class Smaller extends BinaryOp -{ - public function getOperatorSigil() : string { +class Smaller extends BinaryOp { + public function getOperatorSigil(): string { return '<'; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_Smaller'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/SmallerOrEqual.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/SmallerOrEqual.php index 5e45812..9826496 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/SmallerOrEqual.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/SmallerOrEqual.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class SmallerOrEqual extends BinaryOp -{ - public function getOperatorSigil() : string { +class SmallerOrEqual extends BinaryOp { + public function getOperatorSigil(): string { return '<='; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_SmallerOrEqual'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Spaceship.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Spaceship.php index 455bf21..0b12be7 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Spaceship.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BinaryOp/Spaceship.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; -class Spaceship extends BinaryOp -{ - public function getOperatorSigil() : string { +class Spaceship extends BinaryOp { + public function getOperatorSigil(): string { return '<=>'; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BinaryOp_Spaceship'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BitwiseNot.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BitwiseNot.php index f3fcfb2..77b4747 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BitwiseNot.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BitwiseNot.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class BitwiseNot extends Expr -{ +class BitwiseNot extends Expr { /** @var Expr Expression */ - public $expr; + public Expr $expr; /** * Constructs a bitwise not node. * - * @param Expr $expr Expression - * @param array $attributes Additional attributes + * @param Expr $expr Expression + * @param array $attributes Additional attributes */ public function __construct(Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['expr']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BitwiseNot'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BooleanNot.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BooleanNot.php index 1e83a88..42db0bc 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BooleanNot.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/BooleanNot.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class BooleanNot extends Expr -{ +class BooleanNot extends Expr { /** @var Expr Expression */ - public $expr; + public Expr $expr; /** * Constructs a boolean not node. * - * @param Expr $expr Expression - * @param array $attributes Additional attributes + * @param Expr $expr Expression + * @param array $attributes Additional attributes */ public function __construct(Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['expr']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_BooleanNot'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/CallLike.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/CallLike.php index 338c42a..41800fe 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/CallLike.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/CallLike.php @@ -19,12 +19,8 @@ abstract class CallLike extends Expr { * Returns whether this call expression is actually a first class callable. */ public function isFirstClassCallable(): bool { - foreach ($this->getRawArgs() as $arg) { - if ($arg instanceof VariadicPlaceholder) { - return true; - } - } - return false; + $rawArgs = $this->getRawArgs(); + return count($rawArgs) === 1 && current($rawArgs) instanceof VariadicPlaceholder; } /** @@ -36,4 +32,4 @@ abstract class CallLike extends Expr { assert(!$this->isFirstClassCallable()); return $this->getRawArgs(); } -} \ No newline at end of file +} diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast.php index ddf153e..2b0c9d5 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast.php @@ -4,23 +4,22 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -abstract class Cast extends Expr -{ +abstract class Cast extends Expr { /** @var Expr Expression */ - public $expr; + public Expr $expr; /** * Constructs a cast node. * - * @param Expr $expr Expression - * @param array $attributes Additional attributes + * @param Expr $expr Expression + * @param array $attributes Additional attributes */ public function __construct(Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['expr']; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Array_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Array_.php index 2c09124..dff5aba 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Array_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Array_.php @@ -4,9 +4,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\Cast; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\Cast; -class Array_ extends Cast -{ - public function getType() : string { +class Array_ extends Cast { + public function getType(): string { return 'Expr_Cast_Array'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Bool_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Bool_.php index 29335b3..dd3feaa 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Bool_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Bool_.php @@ -4,9 +4,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\Cast; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\Cast; -class Bool_ extends Cast -{ - public function getType() : string { +class Bool_ extends Cast { + public function getType(): string { return 'Expr_Cast_Bool'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Double.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Double.php index 29f89f0..3577c9c 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Double.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Double.php @@ -4,14 +4,13 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\Cast; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\Cast; -class Double extends Cast -{ +class Double extends Cast { // For use in "kind" attribute - const KIND_DOUBLE = 1; // "double" syntax - const KIND_FLOAT = 2; // "float" syntax - const KIND_REAL = 3; // "real" syntax + public const KIND_DOUBLE = 1; // "double" syntax + public const KIND_FLOAT = 2; // "float" syntax + public const KIND_REAL = 3; // "real" syntax - public function getType() : string { + public function getType(): string { return 'Expr_Cast_Double'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Int_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Int_.php index 003de51..d9dc78d 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Int_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Int_.php @@ -4,9 +4,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\Cast; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\Cast; -class Int_ extends Cast -{ - public function getType() : string { +class Int_ extends Cast { + public function getType(): string { return 'Expr_Cast_Int'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Object_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Object_.php index 8f783d2..19773b2 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Object_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Object_.php @@ -4,9 +4,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\Cast; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\Cast; -class Object_ extends Cast -{ - public function getType() : string { +class Object_ extends Cast { + public function getType(): string { return 'Expr_Cast_Object'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/String_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/String_.php index 919328e..5fc172f 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/String_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/String_.php @@ -4,9 +4,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\Cast; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\Cast; -class String_ extends Cast -{ - public function getType() : string { +class String_ extends Cast { + public function getType(): string { return 'Expr_Cast_String'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Unset_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Unset_.php index 3bff774..7132db5 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Unset_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Cast/Unset_.php @@ -4,9 +4,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr\Cast; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\Cast; -class Unset_ extends Cast -{ - public function getType() : string { +class Unset_ extends Cast { + public function getType(): string { return 'Expr_Cast_Unset'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ClassConstFetch.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ClassConstFetch.php index ccb1abe..06b1781 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ClassConstFetch.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ClassConstFetch.php @@ -2,35 +2,35 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; +use ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Identifier; use ncc\ThirdParty\nikic\PhpParser\Node\Name; -class ClassConstFetch extends Expr -{ +class ClassConstFetch extends Expr { /** @var Name|Expr Class name */ - public $class; + public Node $class; /** @var Identifier|Expr|Error Constant name */ - public $name; + public Node $name; /** * Constructs a class const fetch node. * - * @param Name|Expr $class Class name - * @param string|Identifier|Expr|Error $name Constant name - * @param array $attributes Additional attributes + * @param Name|Expr $class Class name + * @param string|Identifier|Expr|Error $name Constant name + * @param array $attributes Additional attributes */ - public function __construct($class, $name, array $attributes = []) { + public function __construct(Node $class, $name, array $attributes = []) { $this->attributes = $attributes; $this->class = $class; $this->name = \is_string($name) ? new Identifier($name) : $name; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['class', 'name']; } - public function getType() : string { + public function getType(): string { return 'Expr_ClassConstFetch'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Clone_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Clone_.php index 7993783..b58baeb 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Clone_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Clone_.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class Clone_ extends Expr -{ +class Clone_ extends Expr { /** @var Expr Expression */ - public $expr; + public Expr $expr; /** * Constructs a clone node. * - * @param Expr $expr Expression - * @param array $attributes Additional attributes + * @param Expr $expr Expression + * @param array $attributes Additional attributes */ public function __construct(Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['expr']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_Clone'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Closure.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Closure.php index aeab4a2..be1b8a5 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Closure.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Closure.php @@ -3,38 +3,46 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node; +use ncc\ThirdParty\nikic\PhpParser\Node\ClosureUse; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\FunctionLike; -class Closure extends Expr implements FunctionLike -{ +class Closure extends Expr implements FunctionLike { /** @var bool Whether the closure is static */ - public $static; + public bool $static; /** @var bool Whether to return by reference */ - public $byRef; + public bool $byRef; /** @var Node\Param[] Parameters */ - public $params; + public array $params; /** @var ClosureUse[] use()s */ - public $uses; + public array $uses; /** @var null|Node\Identifier|Node\Name|Node\ComplexType Return type */ - public $returnType; + public ?Node $returnType; /** @var Node\Stmt[] Statements */ - public $stmts; + public array $stmts; /** @var Node\AttributeGroup[] PHP attribute groups */ - public $attrGroups; + public array $attrGroups; /** * Constructs a lambda function node. * - * @param array $subNodes Array of the following optional subnodes: - * 'static' => false : Whether the closure is static - * 'byRef' => false : Whether to return by reference - * 'params' => array(): Parameters - * 'uses' => array(): use()s - * 'returnType' => null : Return type - * 'stmts' => array(): Statements - * 'attrGroups' => array(): PHP attributes groups - * @param array $attributes Additional attributes + * @param array{ + * static?: bool, + * byRef?: bool, + * params?: Node\Param[], + * uses?: ClosureUse[], + * returnType?: null|Node\Identifier|Node\Name|Node\ComplexType, + * stmts?: Node\Stmt[], + * attrGroups?: Node\AttributeGroup[], + * } $subNodes Array of the following optional subnodes: + * 'static' => false : Whether the closure is static + * 'byRef' => false : Whether to return by reference + * 'params' => array(): Parameters + * 'uses' => array(): use()s + * 'returnType' => null : Return type + * 'stmts' => array(): Statements + * 'attrGroups' => array(): PHP attributes groups + * @param array $attributes Additional attributes */ public function __construct(array $subNodes = [], array $attributes = []) { $this->attributes = $attributes; @@ -42,21 +50,20 @@ class Closure extends Expr implements FunctionLike $this->byRef = $subNodes['byRef'] ?? false; $this->params = $subNodes['params'] ?? []; $this->uses = $subNodes['uses'] ?? []; - $returnType = $subNodes['returnType'] ?? null; - $this->returnType = \is_string($returnType) ? new Node\Identifier($returnType) : $returnType; + $this->returnType = $subNodes['returnType'] ?? null; $this->stmts = $subNodes['stmts'] ?? []; $this->attrGroups = $subNodes['attrGroups'] ?? []; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['attrGroups', 'static', 'byRef', 'params', 'uses', 'returnType', 'stmts']; } - public function returnsByRef() : bool { + public function returnsByRef(): bool { return $this->byRef; } - public function getParams() : array { + public function getParams(): array { return $this->params; } @@ -65,15 +72,15 @@ class Closure extends Expr implements FunctionLike } /** @return Node\Stmt[] */ - public function getStmts() : array { + public function getStmts(): array { return $this->stmts; } - public function getAttrGroups() : array { + public function getAttrGroups(): array { return $this->attrGroups; } - public function getType() : string { + public function getType(): string { return 'Expr_Closure'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ClosureUse.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ClosureUse.php index 8a3a81a..681ff31 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ClosureUse.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ClosureUse.php @@ -1,34 +1,3 @@ attributes = $attributes; - $this->var = $var; - $this->byRef = $byRef; - } - - public function getSubNodeNames() : array { - return ['var', 'byRef']; - } - - public function getType() : string { - return 'Expr_ClosureUse'; - } -} +require __DIR__ . '/../ClosureUse.php'; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ConstFetch.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ConstFetch.php index cd697fd..06ea949 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ConstFetch.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ConstFetch.php @@ -5,27 +5,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Name; -class ConstFetch extends Expr -{ +class ConstFetch extends Expr { /** @var Name Constant name */ - public $name; + public Name $name; /** * Constructs a const fetch node. * - * @param Name $name Constant name - * @param array $attributes Additional attributes + * @param Name $name Constant name + * @param array $attributes Additional attributes */ public function __construct(Name $name, array $attributes = []) { $this->attributes = $attributes; $this->name = $name; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['name']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_ConstFetch'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Empty_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Empty_.php index 6db60ac..a8129e2 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Empty_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Empty_.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class Empty_ extends Expr -{ +class Empty_ extends Expr { /** @var Expr Expression */ - public $expr; + public Expr $expr; /** * Constructs an empty() node. * - * @param Expr $expr Expression - * @param array $attributes Additional attributes + * @param Expr $expr Expression + * @param array $attributes Additional attributes */ public function __construct(Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['expr']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_Empty'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Error.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Error.php index f9c112d..42764c2 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Error.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Error.php @@ -10,22 +10,21 @@ use ncc\ThirdParty\nikic\PhpParser\Node\Expr; * An error node may be placed at a position where an expression is required, but an error occurred. * Error nodes will not be present if the parser is run in throwOnError mode (the default). */ -class Error extends Expr -{ +class Error extends Expr { /** * Constructs an error node. * - * @param array $attributes Additional attributes + * @param array $attributes Additional attributes */ public function __construct(array $attributes = []) { $this->attributes = $attributes; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return []; } - - public function getType() : string { + + public function getType(): string { return 'Expr_Error'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ErrorSuppress.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ErrorSuppress.php index 3f0b2f6..e9e2b49 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ErrorSuppress.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ErrorSuppress.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class ErrorSuppress extends Expr -{ +class ErrorSuppress extends Expr { /** @var Expr Expression */ - public $expr; + public Expr $expr; /** * Constructs an error suppress node. * - * @param Expr $expr Expression - * @param array $attributes Additional attributes + * @param Expr $expr Expression + * @param array $attributes Additional attributes */ public function __construct(Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['expr']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_ErrorSuppress'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Eval_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Eval_.php index d385750..8a59925 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Eval_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Eval_.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class Eval_ extends Expr -{ +class Eval_ extends Expr { /** @var Expr Expression */ - public $expr; + public Expr $expr; /** * Constructs an eval() node. * - * @param Expr $expr Expression - * @param array $attributes Additional attributes + * @param Expr $expr Expression + * @param array $attributes Additional attributes */ public function __construct(Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['expr']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_Eval'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Exit_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Exit_.php index 65cc89f..62da3c0 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Exit_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Exit_.php @@ -4,31 +4,30 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class Exit_ extends Expr -{ +class Exit_ extends Expr { /* For use in "kind" attribute */ - const KIND_EXIT = 1; - const KIND_DIE = 2; + public const KIND_EXIT = 1; + public const KIND_DIE = 2; /** @var null|Expr Expression */ - public $expr; + public ?Expr $expr; /** * Constructs an exit() node. * - * @param null|Expr $expr Expression - * @param array $attributes Additional attributes + * @param null|Expr $expr Expression + * @param array $attributes Additional attributes */ - public function __construct(Expr $expr = null, array $attributes = []) { + public function __construct(?Expr $expr = null, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['expr']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_Exit'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/FuncCall.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/FuncCall.php index 2e05814..5ec1adc 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/FuncCall.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/FuncCall.php @@ -5,31 +5,30 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class FuncCall extends CallLike -{ +class FuncCall extends CallLike { /** @var Node\Name|Expr Function name */ - public $name; + public Node $name; /** @var array Arguments */ - public $args; + public array $args; /** * Constructs a function call node. * - * @param Node\Name|Expr $name Function name - * @param array $args Arguments - * @param array $attributes Additional attributes + * @param Node\Name|Expr $name Function name + * @param array $args Arguments + * @param array $attributes Additional attributes */ - public function __construct($name, array $args = [], array $attributes = []) { + public function __construct(Node $name, array $args = [], array $attributes = []) { $this->attributes = $attributes; $this->name = $name; $this->args = $args; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['name', 'args']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_FuncCall'; } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Include_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Include_.php index 8c49e0f..711c98d 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Include_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Include_.php @@ -4,24 +4,23 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class Include_ extends Expr -{ - const TYPE_INCLUDE = 1; - const TYPE_INCLUDE_ONCE = 2; - const TYPE_REQUIRE = 3; - const TYPE_REQUIRE_ONCE = 4; +class Include_ extends Expr { + public const TYPE_INCLUDE = 1; + public const TYPE_INCLUDE_ONCE = 2; + public const TYPE_REQUIRE = 3; + public const TYPE_REQUIRE_ONCE = 4; /** @var Expr Expression */ - public $expr; + public Expr $expr; /** @var int Type of include */ - public $type; + public int $type; /** * Constructs an include node. * - * @param Expr $expr Expression - * @param int $type Type of include - * @param array $attributes Additional attributes + * @param Expr $expr Expression + * @param int $type Type of include + * @param array $attributes Additional attributes */ public function __construct(Expr $expr, int $type, array $attributes = []) { $this->attributes = $attributes; @@ -29,11 +28,11 @@ class Include_ extends Expr $this->type = $type; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['expr', 'type']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_Include'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Instanceof_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Instanceof_.php index d63c793..33df98d 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Instanceof_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Instanceof_.php @@ -2,34 +2,34 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; +use ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Name; -class Instanceof_ extends Expr -{ +class Instanceof_ extends Expr { /** @var Expr Expression */ - public $expr; + public Expr $expr; /** @var Name|Expr Class name */ - public $class; + public Node $class; /** * Constructs an instanceof check node. * - * @param Expr $expr Expression - * @param Name|Expr $class Class name - * @param array $attributes Additional attributes + * @param Expr $expr Expression + * @param Name|Expr $class Class name + * @param array $attributes Additional attributes */ - public function __construct(Expr $expr, $class, array $attributes = []) { + public function __construct(Expr $expr, Node $class, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; $this->class = $class; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['expr', 'class']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_Instanceof'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Isset_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Isset_.php index fa152a5..b356f10 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Isset_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Isset_.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class Isset_ extends Expr -{ +class Isset_ extends Expr { /** @var Expr[] Variables */ - public $vars; + public array $vars; /** * Constructs an array node. * - * @param Expr[] $vars Variables - * @param array $attributes Additional attributes + * @param Expr[] $vars Variables + * @param array $attributes Additional attributes */ public function __construct(array $vars, array $attributes = []) { $this->attributes = $attributes; $this->vars = $vars; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['vars']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_Isset'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/List_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/List_.php index e7a2e8a..ec58dc7 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/List_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/List_.php @@ -2,29 +2,33 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; +use ncc\ThirdParty\nikic\PhpParser\Node\ArrayItem; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class List_ extends Expr -{ +class List_ extends Expr { + // For use in "kind" attribute + public const KIND_LIST = 1; // list() syntax + public const KIND_ARRAY = 2; // [] syntax + /** @var (ArrayItem|null)[] List of items to assign to */ - public $items; + public array $items; /** * Constructs a list() destructuring node. * - * @param (ArrayItem|null)[] $items List of items to assign to - * @param array $attributes Additional attributes + * @param (ArrayItem|null)[] $items List of items to assign to + * @param array $attributes Additional attributes */ public function __construct(array $items, array $attributes = []) { $this->attributes = $attributes; $this->items = $items; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['items']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_List'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Match_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Match_.php index d8fb658..a78edad 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Match_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Match_.php @@ -5,15 +5,16 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\Node\MatchArm; -class Match_ extends Node\Expr -{ - /** @var Node\Expr */ - public $cond; +class Match_ extends Node\Expr { + /** @var Node\Expr Condition */ + public Node\Expr $cond; /** @var MatchArm[] */ - public $arms; + public array $arms; /** + * @param Node\Expr $cond Condition * @param MatchArm[] $arms + * @param array $attributes Additional attributes */ public function __construct(Node\Expr $cond, array $arms = [], array $attributes = []) { $this->attributes = $attributes; @@ -21,11 +22,11 @@ class Match_ extends Node\Expr $this->arms = $arms; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['cond', 'arms']; } - public function getType() : string { + public function getType(): string { return 'Expr_Match'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/MethodCall.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/MethodCall.php index b24ed82..f2e83fd 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/MethodCall.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/MethodCall.php @@ -2,27 +2,27 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; +use ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\Node\Arg; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Identifier; use ncc\ThirdParty\nikic\PhpParser\Node\VariadicPlaceholder; -class MethodCall extends CallLike -{ +class MethodCall extends CallLike { /** @var Expr Variable holding object */ - public $var; + public Expr $var; /** @var Identifier|Expr Method name */ - public $name; + public Node $name; /** @var array Arguments */ - public $args; + public array $args; /** * Constructs a function call node. * - * @param Expr $var Variable holding object - * @param string|Identifier|Expr $name Method name - * @param array $args Arguments - * @param array $attributes Additional attributes + * @param Expr $var Variable holding object + * @param string|Identifier|Expr $name Method name + * @param array $args Arguments + * @param array $attributes Additional attributes */ public function __construct(Expr $var, $name, array $args = [], array $attributes = []) { $this->attributes = $attributes; @@ -31,11 +31,11 @@ class MethodCall extends CallLike $this->args = $args; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['var', 'name', 'args']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_MethodCall'; } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/New_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/New_.php index fb2e937..526bd84 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/New_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/New_.php @@ -7,31 +7,30 @@ use ncc\ThirdParty\nikic\PhpParser\Node\Arg; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\VariadicPlaceholder; -class New_ extends CallLike -{ +class New_ extends CallLike { /** @var Node\Name|Expr|Node\Stmt\Class_ Class name */ - public $class; + public Node $class; /** @var array Arguments */ - public $args; + public array $args; /** * Constructs a function call node. * - * @param Node\Name|Expr|Node\Stmt\Class_ $class Class name (or class node for anonymous classes) - * @param array $args Arguments - * @param array $attributes Additional attributes + * @param Node\Name|Expr|Node\Stmt\Class_ $class Class name (or class node for anonymous classes) + * @param array $args Arguments + * @param array $attributes Additional attributes */ - public function __construct($class, array $args = [], array $attributes = []) { + public function __construct(Node $class, array $args = [], array $attributes = []) { $this->attributes = $attributes; $this->class = $class; $this->args = $args; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['class', 'args']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_New'; } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/NullsafeMethodCall.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/NullsafeMethodCall.php index 44ba778..0652c90 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/NullsafeMethodCall.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/NullsafeMethodCall.php @@ -2,27 +2,27 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; +use ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\Node\Arg; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Identifier; use ncc\ThirdParty\nikic\PhpParser\Node\VariadicPlaceholder; -class NullsafeMethodCall extends CallLike -{ +class NullsafeMethodCall extends CallLike { /** @var Expr Variable holding object */ - public $var; + public Expr $var; /** @var Identifier|Expr Method name */ - public $name; + public Node $name; /** @var array Arguments */ - public $args; + public array $args; /** * Constructs a nullsafe method call node. * - * @param Expr $var Variable holding object - * @param string|Identifier|Expr $name Method name - * @param array $args Arguments - * @param array $attributes Additional attributes + * @param Expr $var Variable holding object + * @param string|Identifier|Expr $name Method name + * @param array $args Arguments + * @param array $attributes Additional attributes */ public function __construct(Expr $var, $name, array $args = [], array $attributes = []) { $this->attributes = $attributes; @@ -31,11 +31,11 @@ class NullsafeMethodCall extends CallLike $this->args = $args; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['var', 'name', 'args']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_NullsafeMethodCall'; } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/NullsafePropertyFetch.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/NullsafePropertyFetch.php index ccc98ca..7a76292 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/NullsafePropertyFetch.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/NullsafePropertyFetch.php @@ -2,22 +2,22 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; +use ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Identifier; -class NullsafePropertyFetch extends Expr -{ +class NullsafePropertyFetch extends Expr { /** @var Expr Variable holding object */ - public $var; + public Expr $var; /** @var Identifier|Expr Property name */ - public $name; + public Node $name; /** * Constructs a nullsafe property fetch node. * - * @param Expr $var Variable holding object - * @param string|Identifier|Expr $name Property name - * @param array $attributes Additional attributes + * @param Expr $var Variable holding object + * @param string|Identifier|Expr $name Property name + * @param array $attributes Additional attributes */ public function __construct(Expr $var, $name, array $attributes = []) { $this->attributes = $attributes; @@ -25,11 +25,11 @@ class NullsafePropertyFetch extends Expr $this->name = \is_string($name) ? new Identifier($name) : $name; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['var', 'name']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_NullsafePropertyFetch'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/PostDec.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/PostDec.php index a6ca073..31dd949 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/PostDec.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/PostDec.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class PostDec extends Expr -{ +class PostDec extends Expr { /** @var Expr Variable */ - public $var; + public Expr $var; /** * Constructs a post decrement node. * - * @param Expr $var Variable - * @param array $attributes Additional attributes + * @param Expr $var Variable + * @param array $attributes Additional attributes */ public function __construct(Expr $var, array $attributes = []) { $this->attributes = $attributes; $this->var = $var; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['var']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_PostDec'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/PostInc.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/PostInc.php index 87e84f1..44272fb 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/PostInc.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/PostInc.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class PostInc extends Expr -{ +class PostInc extends Expr { /** @var Expr Variable */ - public $var; + public Expr $var; /** * Constructs a post increment node. * - * @param Expr $var Variable - * @param array $attributes Additional attributes + * @param Expr $var Variable + * @param array $attributes Additional attributes */ public function __construct(Expr $var, array $attributes = []) { $this->attributes = $attributes; $this->var = $var; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['var']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_PostInc'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/PreDec.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/PreDec.php index b2a8d0b..27cc20d 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/PreDec.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/PreDec.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class PreDec extends Expr -{ +class PreDec extends Expr { /** @var Expr Variable */ - public $var; + public Expr $var; /** * Constructs a pre decrement node. * - * @param Expr $var Variable - * @param array $attributes Additional attributes + * @param Expr $var Variable + * @param array $attributes Additional attributes */ public function __construct(Expr $var, array $attributes = []) { $this->attributes = $attributes; $this->var = $var; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['var']; } - public function getType() : string { + public function getType(): string { return 'Expr_PreDec'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/PreInc.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/PreInc.php index 3b30656..2d48cc3 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/PreInc.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/PreInc.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class PreInc extends Expr -{ +class PreInc extends Expr { /** @var Expr Variable */ - public $var; + public Expr $var; /** * Constructs a pre increment node. * - * @param Expr $var Variable - * @param array $attributes Additional attributes + * @param Expr $var Variable + * @param array $attributes Additional attributes */ public function __construct(Expr $var, array $attributes = []) { $this->attributes = $attributes; $this->var = $var; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['var']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_PreInc'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Print_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Print_.php index 42f5365..64d2bb4 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Print_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Print_.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class Print_ extends Expr -{ +class Print_ extends Expr { /** @var Expr Expression */ - public $expr; + public Expr $expr; /** * Constructs an print() node. * - * @param Expr $expr Expression - * @param array $attributes Additional attributes + * @param Expr $expr Expression + * @param array $attributes Additional attributes */ public function __construct(Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['expr']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_Print'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/PropertyFetch.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/PropertyFetch.php index ed086e7..dce9f58 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/PropertyFetch.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/PropertyFetch.php @@ -2,22 +2,22 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; +use ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Identifier; -class PropertyFetch extends Expr -{ +class PropertyFetch extends Expr { /** @var Expr Variable holding object */ - public $var; + public Expr $var; /** @var Identifier|Expr Property name */ - public $name; + public Node $name; /** * Constructs a function call node. * - * @param Expr $var Variable holding object - * @param string|Identifier|Expr $name Property name - * @param array $attributes Additional attributes + * @param Expr $var Variable holding object + * @param string|Identifier|Expr $name Property name + * @param array $attributes Additional attributes */ public function __construct(Expr $var, $name, array $attributes = []) { $this->attributes = $attributes; @@ -25,11 +25,11 @@ class PropertyFetch extends Expr $this->name = \is_string($name) ? new Identifier($name) : $name; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['var', 'name']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_PropertyFetch'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ShellExec.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ShellExec.php index 9b9a209..6b4fa49 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ShellExec.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/ShellExec.php @@ -3,28 +3,28 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; +use ncc\ThirdParty\nikic\PhpParser\Node\InterpolatedStringPart; -class ShellExec extends Expr -{ - /** @var array Encapsed string array */ - public $parts; +class ShellExec extends Expr { + /** @var (Expr|InterpolatedStringPart)[] Interpolated string array */ + public array $parts; /** * Constructs a shell exec (backtick) node. * - * @param array $parts Encapsed string array - * @param array $attributes Additional attributes + * @param (Expr|InterpolatedStringPart)[] $parts Interpolated string array + * @param array $attributes Additional attributes */ public function __construct(array $parts, array $attributes = []) { $this->attributes = $attributes; $this->parts = $parts; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['parts']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_ShellExec'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/StaticCall.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/StaticCall.php index 04b91e4..119472e 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/StaticCall.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/StaticCall.php @@ -8,35 +8,34 @@ use ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Identifier; use ncc\ThirdParty\nikic\PhpParser\Node\VariadicPlaceholder; -class StaticCall extends CallLike -{ +class StaticCall extends CallLike { /** @var Node\Name|Expr Class name */ - public $class; + public Node $class; /** @var Identifier|Expr Method name */ - public $name; + public Node $name; /** @var array Arguments */ - public $args; + public array $args; /** * Constructs a static method call node. * - * @param Node\Name|Expr $class Class name - * @param string|Identifier|Expr $name Method name - * @param array $args Arguments - * @param array $attributes Additional attributes + * @param Node\Name|Expr $class Class name + * @param string|Identifier|Expr $name Method name + * @param array $args Arguments + * @param array $attributes Additional attributes */ - public function __construct($class, $name, array $args = [], array $attributes = []) { + public function __construct(Node $class, $name, array $args = [], array $attributes = []) { $this->attributes = $attributes; $this->class = $class; $this->name = \is_string($name) ? new Identifier($name) : $name; $this->args = $args; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['class', 'name', 'args']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_StaticCall'; } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/StaticPropertyFetch.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/StaticPropertyFetch.php index b6453e1..ce500f9 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/StaticPropertyFetch.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/StaticPropertyFetch.php @@ -2,35 +2,35 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; +use ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Name; use ncc\ThirdParty\nikic\PhpParser\Node\VarLikeIdentifier; -class StaticPropertyFetch extends Expr -{ +class StaticPropertyFetch extends Expr { /** @var Name|Expr Class name */ - public $class; + public Node $class; /** @var VarLikeIdentifier|Expr Property name */ - public $name; + public Node $name; /** * Constructs a static property fetch node. * - * @param Name|Expr $class Class name - * @param string|VarLikeIdentifier|Expr $name Property name - * @param array $attributes Additional attributes + * @param Name|Expr $class Class name + * @param string|VarLikeIdentifier|Expr $name Property name + * @param array $attributes Additional attributes */ - public function __construct($class, $name, array $attributes = []) { + public function __construct(Node $class, $name, array $attributes = []) { $this->attributes = $attributes; $this->class = $class; $this->name = \is_string($name) ? new VarLikeIdentifier($name) : $name; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['class', 'name']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_StaticPropertyFetch'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Ternary.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Ternary.php index fc63b48..46301df 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Ternary.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Ternary.php @@ -4,35 +4,34 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class Ternary extends Expr -{ +class Ternary extends Expr { /** @var Expr Condition */ - public $cond; + public Expr $cond; /** @var null|Expr Expression for true */ - public $if; + public ?Expr $if; /** @var Expr Expression for false */ - public $else; + public Expr $else; /** * Constructs a ternary operator node. * - * @param Expr $cond Condition - * @param null|Expr $if Expression for true - * @param Expr $else Expression for false - * @param array $attributes Additional attributes + * @param Expr $cond Condition + * @param null|Expr $if Expression for true + * @param Expr $else Expression for false + * @param array $attributes Additional attributes */ - public function __construct(Expr $cond, $if, Expr $else, array $attributes = []) { + public function __construct(Expr $cond, ?Expr $if, Expr $else, array $attributes = []) { $this->attributes = $attributes; $this->cond = $cond; $this->if = $if; $this->else = $else; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['cond', 'if', 'else']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_Ternary'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Throw_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Throw_.php index 2b097e1..4c25113 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Throw_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Throw_.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node; -class Throw_ extends Node\Expr -{ +class Throw_ extends Node\Expr { /** @var Node\Expr Expression */ - public $expr; + public Node\Expr $expr; /** * Constructs a throw expression node. * - * @param Node\Expr $expr Expression - * @param array $attributes Additional attributes + * @param Node\Expr $expr Expression + * @param array $attributes Additional attributes */ public function __construct(Node\Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['expr']; } - public function getType() : string { + public function getType(): string { return 'Expr_Throw'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/UnaryMinus.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/UnaryMinus.php index ef9258c..6c0e025 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/UnaryMinus.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/UnaryMinus.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class UnaryMinus extends Expr -{ +class UnaryMinus extends Expr { /** @var Expr Expression */ - public $expr; + public Expr $expr; /** * Constructs a unary minus node. * - * @param Expr $expr Expression - * @param array $attributes Additional attributes + * @param Expr $expr Expression + * @param array $attributes Additional attributes */ public function __construct(Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['expr']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_UnaryMinus'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/UnaryPlus.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/UnaryPlus.php index 6204284..9a9a177 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/UnaryPlus.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/UnaryPlus.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class UnaryPlus extends Expr -{ +class UnaryPlus extends Expr { /** @var Expr Expression */ - public $expr; + public Expr $expr; /** * Constructs a unary plus node. * - * @param Expr $expr Expression - * @param array $attributes Additional attributes + * @param Expr $expr Expression + * @param array $attributes Additional attributes */ public function __construct(Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['expr']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_UnaryPlus'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Variable.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Variable.php index 8eed22c..e5b1f73 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Variable.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Variable.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class Variable extends Expr -{ +class Variable extends Expr { /** @var string|Expr Name */ public $name; /** * Constructs a variable node. * - * @param string|Expr $name Name - * @param array $attributes Additional attributes + * @param string|Expr $name Name + * @param array $attributes Additional attributes */ public function __construct($name, array $attributes = []) { $this->attributes = $attributes; $this->name = $name; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['name']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_Variable'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/YieldFrom.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/YieldFrom.php index 321b5c9..18876c1 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/YieldFrom.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/YieldFrom.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class YieldFrom extends Expr -{ +class YieldFrom extends Expr { /** @var Expr Expression to yield from */ - public $expr; + public Expr $expr; /** * Constructs an "yield from" node. * - * @param Expr $expr Expression - * @param array $attributes Additional attributes + * @param Expr $expr Expression + * @param array $attributes Additional attributes */ public function __construct(Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['expr']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_YieldFrom'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Yield_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Yield_.php index a8dbcaa..eb5bcd7 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Yield_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Expr/Yield_.php @@ -4,31 +4,30 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class Yield_ extends Expr -{ +class Yield_ extends Expr { /** @var null|Expr Key expression */ - public $key; + public ?Expr $key; /** @var null|Expr Value expression */ - public $value; + public ?Expr $value; /** * Constructs a yield expression node. * - * @param null|Expr $value Value expression - * @param null|Expr $key Key expression - * @param array $attributes Additional attributes + * @param null|Expr $value Value expression + * @param null|Expr $key Key expression + * @param array $attributes Additional attributes */ - public function __construct(Expr $value = null, Expr $key = null, array $attributes = []) { + public function __construct(?Expr $value = null, ?Expr $key = null, array $attributes = []) { $this->attributes = $attributes; $this->key = $key; $this->value = $value; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['key', 'value']; } - - public function getType() : string { + + public function getType(): string { return 'Expr_Yield'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/FunctionLike.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/FunctionLike.php index 3bf606b..03ebcd4 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/FunctionLike.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/FunctionLike.php @@ -4,21 +4,18 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\Node; -interface FunctionLike extends Node -{ +interface FunctionLike extends Node { /** * Whether to return by reference - * - * @return bool */ - public function returnsByRef() : bool; + public function returnsByRef(): bool; /** * List of parameters * * @return Param[] */ - public function getParams() : array; + public function getParams(): array; /** * Get the declared return type or null @@ -32,12 +29,12 @@ interface FunctionLike extends Node * * @return Stmt[]|null */ - public function getStmts(); + public function getStmts(): ?array; /** * Get PHP attribute groups. * * @return AttributeGroup[] */ - public function getAttrGroups() : array; + public function getAttrGroups(): array; } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Identifier.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Identifier.php index 7075e74..6a4c86d 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Identifier.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Identifier.php @@ -7,12 +7,15 @@ use ncc\ThirdParty\nikic\PhpParser\NodeAbstract; /** * Represents a non-namespaced name. Namespaced names are represented using Name nodes. */ -class Identifier extends NodeAbstract -{ - /** @var string Identifier as string */ - public $name; +class Identifier extends NodeAbstract { + /** + * @psalm-var non-empty-string + * @var string Identifier as string + */ + public string $name; - private static $specialClassNames = [ + /** @var array */ + private static array $specialClassNames = [ 'self' => true, 'parent' => true, 'static' => true, @@ -21,33 +24,39 @@ class Identifier extends NodeAbstract /** * Constructs an identifier node. * - * @param string $name Identifier as string - * @param array $attributes Additional attributes + * @param string $name Identifier as string + * @param array $attributes Additional attributes */ public function __construct(string $name, array $attributes = []) { + if ($name === '') { + throw new \InvalidArgumentException('Identifier name cannot be empty'); + } + $this->attributes = $attributes; $this->name = $name; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['name']; } /** * Get identifier as string. * + * @psalm-return non-empty-string * @return string Identifier as string. */ - public function toString() : string { + public function toString(): string { return $this->name; } /** * Get lowercased identifier as string. * + * @psalm-return non-empty-string * @return string Lowercased identifier as string */ - public function toLowerString() : string { + public function toLowerString(): string { return strtolower($this->name); } @@ -56,20 +65,21 @@ class Identifier extends NodeAbstract * * @return bool Whether identifier is a special class name */ - public function isSpecialClassName() : bool { + public function isSpecialClassName(): bool { return isset(self::$specialClassNames[strtolower($this->name)]); } /** * Get identifier as string. * + * @psalm-return non-empty-string * @return string Identifier as string */ - public function __toString() : string { + public function __toString(): string { return $this->name; } - - public function getType() : string { + + public function getType(): string { return 'Identifier'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/InterpolatedStringPart.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/InterpolatedStringPart.php new file mode 100644 index 0000000..1e3e5b6 --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/InterpolatedStringPart.php @@ -0,0 +1,32 @@ + $attributes Additional attributes + */ + public function __construct(string $value, array $attributes = []) { + $this->attributes = $attributes; + $this->value = $value; + } + + public function getSubNodeNames(): array { + return ['value']; + } + + public function getType(): string { + return 'InterpolatedStringPart'; + } +} + +// @deprecated compatibility alias +class_alias(InterpolatedStringPart::class, Scalar\EncapsedStringPart::class); diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/IntersectionType.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/IntersectionType.php index f223fc6..380cfb5 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/IntersectionType.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/IntersectionType.php @@ -2,29 +2,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node; -use ncc\ThirdParty\nikic\PhpParser\NodeAbstract; - -class IntersectionType extends ComplexType -{ +class IntersectionType extends ComplexType { /** @var (Identifier|Name)[] Types */ - public $types; + public array $types; /** * Constructs an intersection type. * - * @param (Identifier|Name)[] $types Types - * @param array $attributes Additional attributes + * @param (Identifier|Name)[] $types Types + * @param array $attributes Additional attributes */ public function __construct(array $types, array $attributes = []) { $this->attributes = $attributes; $this->types = $types; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['types']; } - public function getType() : string { + public function getType(): string { return 'IntersectionType'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/MatchArm.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/MatchArm.php index df3cf21..0d91e62 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/MatchArm.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/MatchArm.php @@ -5,27 +5,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\NodeAbstract; -class MatchArm extends NodeAbstract -{ - /** @var null|Node\Expr[] */ - public $conds; +class MatchArm extends NodeAbstract { + /** @var null|list */ + public ?array $conds; /** @var Node\Expr */ - public $body; + public Expr $body; /** - * @param null|Node\Expr[] $conds + * @param null|list $conds */ - public function __construct($conds, Node\Expr $body, array $attributes = []) { + public function __construct(?array $conds, Node\Expr $body, array $attributes = []) { $this->conds = $conds; $this->body = $body; $this->attributes = $attributes; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['conds', 'body']; } - public function getType() : string { + public function getType(): string { return 'MatchArm'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Name.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Name.php index 42ffd57..fbf70b1 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Name.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Name.php @@ -4,15 +4,15 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\NodeAbstract; -class Name extends NodeAbstract -{ +class Name extends NodeAbstract { /** - * @var string[] Parts of the name - * @deprecated Use getParts() instead + * @psalm-var non-empty-string + * @var string Name as string */ - public $parts; + public string $name; - private static $specialClassNames = [ + /** @var array */ + private static array $specialClassNames = [ 'self' => true, 'parent' => true, 'static' => true, @@ -21,25 +21,26 @@ class Name extends NodeAbstract /** * Constructs a name node. * - * @param string|string[]|self $name Name as string, part array or Name instance (copy ctor) - * @param array $attributes Additional attributes + * @param string|string[]|self $name Name as string, part array or Name instance (copy ctor) + * @param array $attributes Additional attributes */ - public function __construct($name, array $attributes = []) { + final public function __construct($name, array $attributes = []) { $this->attributes = $attributes; - $this->parts = self::prepareName($name); + $this->name = self::prepareName($name); } - public function getSubNodeNames() : array { - return ['parts']; + public function getSubNodeNames(): array { + return ['name']; } /** * Get parts of name (split by the namespace separator). * + * @psalm-return non-empty-list * @return string[] Parts of name */ public function getParts(): array { - return $this->parts; + return \explode('\\', $this->name); } /** @@ -47,8 +48,11 @@ class Name extends NodeAbstract * * @return string First part of the name */ - public function getFirst() : string { - return $this->parts[0]; + public function getFirst(): string { + if (false !== $pos = \strpos($this->name, '\\')) { + return \substr($this->name, 0, $pos); + } + return $this->name; } /** @@ -56,8 +60,11 @@ class Name extends NodeAbstract * * @return string Last part of the name */ - public function getLast() : string { - return $this->parts[count($this->parts) - 1]; + public function getLast(): string { + if (false !== $pos = \strrpos($this->name, '\\')) { + return \substr($this->name, $pos + 1); + } + return $this->name; } /** @@ -65,8 +72,8 @@ class Name extends NodeAbstract * * @return bool Whether the name is unqualified */ - public function isUnqualified() : bool { - return 1 === count($this->parts); + public function isUnqualified(): bool { + return false === \strpos($this->name, '\\'); } /** @@ -74,8 +81,8 @@ class Name extends NodeAbstract * * @return bool Whether the name is qualified */ - public function isQualified() : bool { - return 1 < count($this->parts); + public function isQualified(): bool { + return false !== \strpos($this->name, '\\'); } /** @@ -83,7 +90,7 @@ class Name extends NodeAbstract * * @return bool Whether the name is fully qualified */ - public function isFullyQualified() : bool { + public function isFullyQualified(): bool { return false; } @@ -92,7 +99,7 @@ class Name extends NodeAbstract * * @return bool Whether the name is relative */ - public function isRelative() : bool { + public function isRelative(): bool { return false; } @@ -100,19 +107,21 @@ class Name extends NodeAbstract * Returns a string representation of the name itself, without taking the name type into * account (e.g., not including a leading backslash for fully qualified names). * + * @psalm-return non-empty-string * @return string String representation */ - public function toString() : string { - return implode('\\', $this->parts); + public function toString(): string { + return $this->name; } /** * Returns a string representation of the name as it would occur in code (e.g., including * leading backslash for fully qualified names. * + * @psalm-return non-empty-string * @return string String representation */ - public function toCodeString() : string { + public function toCodeString(): string { return $this->toString(); } @@ -120,10 +129,11 @@ class Name extends NodeAbstract * Returns lowercased string representation of the name, without taking the name type into * account (e.g., no leading backslash for fully qualified names). * + * @psalm-return non-empty-string * @return string Lowercased string representation */ - public function toLowerString() : string { - return strtolower(implode('\\', $this->parts)); + public function toLowerString(): string { + return strtolower($this->name); } /** @@ -131,19 +141,19 @@ class Name extends NodeAbstract * * @return bool Whether identifier is a special class name */ - public function isSpecialClassName() : bool { - return count($this->parts) === 1 - && isset(self::$specialClassNames[strtolower($this->parts[0])]); + public function isSpecialClassName(): bool { + return isset(self::$specialClassNames[strtolower($this->name)]); } /** * Returns a string representation of the name by imploding the namespace parts with the * namespace separator. * + * @psalm-return non-empty-string * @return string String representation */ - public function __toString() : string { - return implode('\\', $this->parts); + public function __toString(): string { + return $this->name; } /** @@ -157,13 +167,22 @@ class Name extends NodeAbstract * * Offset and length have the same meaning as in array_slice(). * - * @param int $offset Offset to start the slice at (may be negative) + * @param int $offset Offset to start the slice at (may be negative) * @param int|null $length Length of the slice (may be negative) * * @return static|null Sliced name */ - public function slice(int $offset, int $length = null) { - $numParts = count($this->parts); + public function slice(int $offset, ?int $length = null) { + if ($offset === 1 && $length === null) { + // Short-circuit the common case. + if (false !== $pos = \strpos($this->name, '\\')) { + return new static(\substr($this->name, $pos + 1)); + } + return null; + } + + $parts = \explode('\\', $this->name); + $numParts = \count($parts); $realOffset = $offset < 0 ? $offset + $numParts : $offset; if ($realOffset < 0 || $realOffset > $numParts) { @@ -184,7 +203,7 @@ class Name extends NodeAbstract return null; } - return new static(array_slice($this->parts, $realOffset, $realLength), $this->attributes); + return new static(array_slice($parts, $realOffset, $realLength), $this->attributes); } /** @@ -198,49 +217,54 @@ class Name extends NodeAbstract * Name::concat($namespace, $shortName) * where $namespace is a Name node or null will work as expected. * - * @param string|string[]|self|null $name1 The first name - * @param string|string[]|self|null $name2 The second name - * @param array $attributes Attributes to assign to concatenated name + * @param string|string[]|self|null $name1 The first name + * @param string|string[]|self|null $name2 The second name + * @param array $attributes Attributes to assign to concatenated name * * @return static|null Concatenated name */ public static function concat($name1, $name2, array $attributes = []) { if (null === $name1 && null === $name2) { return null; - } elseif (null === $name1) { - return new static(self::prepareName($name2), $attributes); - } elseif (null === $name2) { - return new static(self::prepareName($name1), $attributes); + } + if (null === $name1) { + return new static($name2, $attributes); + } + if (null === $name2) { + return new static($name1, $attributes); } else { return new static( - array_merge(self::prepareName($name1), self::prepareName($name2)), $attributes + self::prepareName($name1) . '\\' . self::prepareName($name2), $attributes ); } } /** * Prepares a (string, array or Name node) name for use in name changing methods by converting - * it to an array. + * it to a string. * * @param string|string[]|self $name Name to prepare * - * @return string[] Prepared name + * @psalm-return non-empty-string + * @return string Prepared name */ - private static function prepareName($name) : array { + private static function prepareName($name): string { if (\is_string($name)) { if ('' === $name) { throw new \InvalidArgumentException('Name cannot be empty'); } - return explode('\\', $name); - } elseif (\is_array($name)) { + return $name; + } + if (\is_array($name)) { if (empty($name)) { throw new \InvalidArgumentException('Name cannot be empty'); } - return $name; - } elseif ($name instanceof self) { - return $name->parts; + return implode('\\', $name); + } + if ($name instanceof self) { + return $name->name; } throw new \InvalidArgumentException( @@ -248,7 +272,7 @@ class Name extends NodeAbstract ); } - public function getType() : string { + public function getType(): string { return 'Name'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Name/FullyQualified.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Name/FullyQualified.php index 345299a..5c244fe 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Name/FullyQualified.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Name/FullyQualified.php @@ -2,14 +2,13 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Name; -class FullyQualified extends \ncc\ThirdParty\nikic\PhpParser\Node\Name -{ +class FullyQualified extends \ncc\ThirdParty\nikic\PhpParser\Node\Name { /** * Checks whether the name is unqualified. (E.g. Name) * * @return bool Whether the name is unqualified */ - public function isUnqualified() : bool { + public function isUnqualified(): bool { return false; } @@ -18,7 +17,7 @@ class FullyQualified extends \ncc\ThirdParty\nikic\PhpParser\Node\Name * * @return bool Whether the name is qualified */ - public function isQualified() : bool { + public function isQualified(): bool { return false; } @@ -27,7 +26,7 @@ class FullyQualified extends \ncc\ThirdParty\nikic\PhpParser\Node\Name * * @return bool Whether the name is fully qualified */ - public function isFullyQualified() : bool { + public function isFullyQualified(): bool { return true; } @@ -36,15 +35,15 @@ class FullyQualified extends \ncc\ThirdParty\nikic\PhpParser\Node\Name * * @return bool Whether the name is relative */ - public function isRelative() : bool { + public function isRelative(): bool { return false; } - public function toCodeString() : string { + public function toCodeString(): string { return '\\' . $this->toString(); } - - public function getType() : string { + + public function getType(): string { return 'Name_FullyQualified'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Name/Relative.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Name/Relative.php index 2fd8209..ff5479a 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Name/Relative.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Name/Relative.php @@ -2,14 +2,13 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Name; -class Relative extends \ncc\ThirdParty\nikic\PhpParser\Node\Name -{ +class Relative extends \ncc\ThirdParty\nikic\PhpParser\Node\Name { /** * Checks whether the name is unqualified. (E.g. Name) * * @return bool Whether the name is unqualified */ - public function isUnqualified() : bool { + public function isUnqualified(): bool { return false; } @@ -18,7 +17,7 @@ class Relative extends \ncc\ThirdParty\nikic\PhpParser\Node\Name * * @return bool Whether the name is qualified */ - public function isQualified() : bool { + public function isQualified(): bool { return false; } @@ -27,7 +26,7 @@ class Relative extends \ncc\ThirdParty\nikic\PhpParser\Node\Name * * @return bool Whether the name is fully qualified */ - public function isFullyQualified() : bool { + public function isFullyQualified(): bool { return false; } @@ -36,15 +35,15 @@ class Relative extends \ncc\ThirdParty\nikic\PhpParser\Node\Name * * @return bool Whether the name is relative */ - public function isRelative() : bool { + public function isRelative(): bool { return true; } - public function toCodeString() : string { + public function toCodeString(): string { return 'namespace\\' . $this->toString(); } - - public function getType() : string { + + public function getType(): string { return 'Name_Relative'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/NullableType.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/NullableType.php index 988a4e9..4760468 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/NullableType.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/NullableType.php @@ -2,27 +2,28 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node; -class NullableType extends ComplexType -{ +use ncc\ThirdParty\nikic\PhpParser\Node; + +class NullableType extends ComplexType { /** @var Identifier|Name Type */ - public $type; + public Node $type; /** * Constructs a nullable type (wrapping another type). * - * @param string|Identifier|Name $type Type - * @param array $attributes Additional attributes + * @param Identifier|Name $type Type + * @param array $attributes Additional attributes */ - public function __construct($type, array $attributes = []) { + public function __construct(Node $type, array $attributes = []) { $this->attributes = $attributes; - $this->type = \is_string($type) ? new Identifier($type) : $type; + $this->type = $type; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['type']; } - - public function getType() : string { + + public function getType(): string { return 'NullableType'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Param.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Param.php index f1a1777..f53ffa6 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Param.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Param.php @@ -2,59 +2,109 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node; +use ncc\ThirdParty\nikic\PhpParser\Modifiers; +use ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\NodeAbstract; -class Param extends NodeAbstract -{ +class Param extends NodeAbstract { /** @var null|Identifier|Name|ComplexType Type declaration */ - public $type; + public ?Node $type; /** @var bool Whether parameter is passed by reference */ - public $byRef; + public bool $byRef; /** @var bool Whether this is a variadic argument */ - public $variadic; + public bool $variadic; /** @var Expr\Variable|Expr\Error Parameter variable */ - public $var; + public Expr $var; /** @var null|Expr Default value */ - public $default; - /** @var int */ - public $flags; + public ?Expr $default; + /** @var int Optional visibility flags */ + public int $flags; /** @var AttributeGroup[] PHP attribute groups */ - public $attrGroups; + public array $attrGroups; + /** @var PropertyHook[] Property hooks for promoted properties */ + public array $hooks; /** * Constructs a parameter node. * - * @param Expr\Variable|Expr\Error $var Parameter variable - * @param null|Expr $default Default value - * @param null|string|Identifier|Name|ComplexType $type Type declaration - * @param bool $byRef Whether is passed by reference - * @param bool $variadic Whether this is a variadic argument - * @param array $attributes Additional attributes - * @param int $flags Optional visibility flags - * @param AttributeGroup[] $attrGroups PHP attribute groups + * @param Expr\Variable|Expr\Error $var Parameter variable + * @param null|Expr $default Default value + * @param null|Identifier|Name|ComplexType $type Type declaration + * @param bool $byRef Whether is passed by reference + * @param bool $variadic Whether this is a variadic argument + * @param array $attributes Additional attributes + * @param int $flags Optional visibility flags + * @param list $attrGroups PHP attribute groups + * @param PropertyHook[] $hooks Property hooks for promoted properties */ public function __construct( - $var, Expr $default = null, $type = null, + Expr $var, ?Expr $default = null, ?Node $type = null, bool $byRef = false, bool $variadic = false, array $attributes = [], int $flags = 0, - array $attrGroups = [] + array $attrGroups = [], + array $hooks = [] ) { $this->attributes = $attributes; - $this->type = \is_string($type) ? new Identifier($type) : $type; + $this->type = $type; $this->byRef = $byRef; $this->variadic = $variadic; $this->var = $var; $this->default = $default; $this->flags = $flags; $this->attrGroups = $attrGroups; + $this->hooks = $hooks; } - public function getSubNodeNames() : array { - return ['attrGroups', 'flags', 'type', 'byRef', 'variadic', 'var', 'default']; + public function getSubNodeNames(): array { + return ['attrGroups', 'flags', 'type', 'byRef', 'variadic', 'var', 'default', 'hooks']; } - public function getType() : string { + public function getType(): string { return 'Param'; } + + /** + * Whether this parameter uses constructor property promotion. + */ + public function isPromoted(): bool { + return $this->flags !== 0; + } + + public function isPublic(): bool { + return (bool) ($this->flags & Modifiers::PUBLIC); + } + + public function isProtected(): bool { + return (bool) ($this->flags & Modifiers::PROTECTED); + } + + public function isPrivate(): bool { + return (bool) ($this->flags & Modifiers::PRIVATE); + } + + public function isReadonly(): bool { + return (bool) ($this->flags & Modifiers::READONLY); + } + + /** + * Whether the promoted property has explicit public(set) visibility. + */ + public function isPublicSet(): bool { + return (bool) ($this->flags & Modifiers::PUBLIC_SET); + } + + /** + * Whether the promoted property has explicit protected(set) visibility. + */ + public function isProtectedSet(): bool { + return (bool) ($this->flags & Modifiers::PROTECTED_SET); + } + + /** + * Whether the promoted property has explicit private(set) visibility. + */ + public function isPrivateSet(): bool { + return (bool) ($this->flags & Modifiers::PRIVATE_SET); + } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/PropertyHook.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/PropertyHook.php new file mode 100644 index 0000000..af4a441 --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/PropertyHook.php @@ -0,0 +1,78 @@ + false : Whether hook returns by reference + * 'params' => array(): Parameters + * 'attrGroups' => array(): PHP attribute groups + * @param array $attributes Additional attributes + */ + public function __construct($name, $body, array $subNodes = [], array $attributes = []) { + $this->attributes = $attributes; + $this->name = \is_string($name) ? new Identifier($name) : $name; + $this->body = $body; + $this->flags = $subNodes['flags'] ?? 0; + $this->byRef = $subNodes['byRef'] ?? false; + $this->params = $subNodes['params'] ?? []; + $this->attrGroups = $subNodes['attrGroups'] ?? []; + } + + public function returnsByRef(): bool { + return $this->byRef; + } + + public function getParams(): array { + return $this->params; + } + + public function getReturnType() { + return null; + } + + public function getStmts(): ?array { + if ($this->body instanceof Expr) { + return [new Return_($this->body)]; + } + return $this->body; + } + + public function getAttrGroups(): array { + return $this->attrGroups; + } + + public function getType(): string { + return 'PropertyHook'; + } + + public function getSubNodeNames(): array { + return ['attrGroups', 'flags', 'byRef', 'name', 'params', 'body']; + } +} diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/PropertyItem.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/PropertyItem.php new file mode 100644 index 0000000..19ab653 --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/PropertyItem.php @@ -0,0 +1,37 @@ + $attributes Additional attributes + */ + public function __construct($name, ?Node\Expr $default = null, array $attributes = []) { + $this->attributes = $attributes; + $this->name = \is_string($name) ? new Node\VarLikeIdentifier($name) : $name; + $this->default = $default; + } + + public function getSubNodeNames(): array { + return ['name', 'default']; + } + + public function getType(): string { + return 'PropertyItem'; + } +} + +// @deprecated compatibility alias +class_alias(PropertyItem::class, Stmt\PropertyProperty::class); diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar.php index 4468596..d4aca08 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar.php @@ -2,6 +2,5 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node; -abstract class Scalar extends Expr -{ +abstract class Scalar extends Expr { } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/DNumber.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/DNumber.php index 5520185..ad3937a 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/DNumber.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/DNumber.php @@ -1,77 +1,3 @@ attributes = $attributes; - $this->value = $value; - } - - public function getSubNodeNames() : array { - return ['value']; - } - - /** - * @param mixed[] $attributes - */ - public static function fromString(string $str, array $attributes = []): DNumber - { - $attributes['rawValue'] = $str; - $float = self::parse($str); - - return new DNumber($float, $attributes); - } - - /** - * @internal - * - * Parses a DNUMBER token like PHP would. - * - * @param string $str A string number - * - * @return float The parsed number - */ - public static function parse(string $str) : float { - $str = str_replace('_', '', $str); - - // Check whether this is one of the special integer notations. - if ('0' === $str[0]) { - // hex - if ('x' === $str[1] || 'X' === $str[1]) { - return hexdec($str); - } - - // bin - if ('b' === $str[1] || 'B' === $str[1]) { - return bindec($str); - } - - // oct, but only if the string does not contain any of '.eE'. - if (false === strpbrk($str, '.eE')) { - // substr($str, 0, strcspn($str, '89')) cuts the string at the first invalid digit - // (8 or 9) so that only the digits before that are used. - return octdec(substr($str, 0, strcspn($str, '89'))); - } - } - - // dec - return (float) $str; - } - - public function getType() : string { - return 'Scalar_DNumber'; - } -} +require __DIR__ . '/Float_.php'; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/Encapsed.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/Encapsed.php index 49daca7..c5aaf5b 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/Encapsed.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/Encapsed.php @@ -1,31 +1,3 @@ attributes = $attributes; - $this->parts = $parts; - } - - public function getSubNodeNames() : array { - return ['parts']; - } - - public function getType() : string { - return 'Scalar_Encapsed'; - } -} +require __DIR__ . '/InterpolatedString.php'; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/EncapsedStringPart.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/EncapsedStringPart.php index fb69817..990e980 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/EncapsedStringPart.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/EncapsedStringPart.php @@ -1,30 +1,3 @@ attributes = $attributes; - $this->value = $value; - } - - public function getSubNodeNames() : array { - return ['value']; - } - - public function getType() : string { - return 'Scalar_EncapsedStringPart'; - } -} +require __DIR__ . '/../InterpolatedStringPart.php'; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/Float_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/Float_.php new file mode 100644 index 0000000..96dc40c --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/Float_.php @@ -0,0 +1,78 @@ + $attributes Additional attributes + */ + public function __construct(float $value, array $attributes = []) { + $this->attributes = $attributes; + $this->value = $value; + } + + public function getSubNodeNames(): array { + return ['value']; + } + + /** + * @param mixed[] $attributes + */ + public static function fromString(string $str, array $attributes = []): Float_ { + $attributes['rawValue'] = $str; + $float = self::parse($str); + + return new Float_($float, $attributes); + } + + /** + * @internal + * + * Parses a DNUMBER token like PHP would. + * + * @param string $str A string number + * + * @return float The parsed number + */ + public static function parse(string $str): float { + $str = str_replace('_', '', $str); + + // Check whether this is one of the special integer notations. + if ('0' === $str[0]) { + // hex + if ('x' === $str[1] || 'X' === $str[1]) { + return hexdec($str); + } + + // bin + if ('b' === $str[1] || 'B' === $str[1]) { + return bindec($str); + } + + // oct, but only if the string does not contain any of '.eE'. + if (false === strpbrk($str, '.eE')) { + // substr($str, 0, strcspn($str, '89')) cuts the string at the first invalid digit + // (8 or 9) so that only the digits before that are used. + return octdec(substr($str, 0, strcspn($str, '89'))); + } + } + + // dec + return (float) $str; + } + + public function getType(): string { + return 'Scalar_Float'; + } +} + +// @deprecated compatibility alias +class_alias(Float_::class, DNumber::class); diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/Int_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/Int_.php new file mode 100644 index 0000000..150c491 --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/Int_.php @@ -0,0 +1,82 @@ + $attributes Additional attributes + */ + public function __construct(int $value, array $attributes = []) { + $this->attributes = $attributes; + $this->value = $value; + } + + public function getSubNodeNames(): array { + return ['value']; + } + + /** + * Constructs an Int node from a string number literal. + * + * @param string $str String number literal (decimal, octal, hex or binary) + * @param array $attributes Additional attributes + * @param bool $allowInvalidOctal Whether to allow invalid octal numbers (PHP 5) + * + * @return Int_ The constructed LNumber, including kind attribute + */ + public static function fromString(string $str, array $attributes = [], bool $allowInvalidOctal = false): Int_ { + $attributes['rawValue'] = $str; + + $str = str_replace('_', '', $str); + + if ('0' !== $str[0] || '0' === $str) { + $attributes['kind'] = Int_::KIND_DEC; + return new Int_((int) $str, $attributes); + } + + if ('x' === $str[1] || 'X' === $str[1]) { + $attributes['kind'] = Int_::KIND_HEX; + return new Int_(hexdec($str), $attributes); + } + + if ('b' === $str[1] || 'B' === $str[1]) { + $attributes['kind'] = Int_::KIND_BIN; + return new Int_(bindec($str), $attributes); + } + + if (!$allowInvalidOctal && strpbrk($str, '89')) { + throw new Error('Invalid numeric literal', $attributes); + } + + // Strip optional explicit octal prefix. + if ('o' === $str[1] || 'O' === $str[1]) { + $str = substr($str, 2); + } + + // use intval instead of octdec to get proper cutting behavior with malformed numbers + $attributes['kind'] = Int_::KIND_OCT; + return new Int_(intval($str, 8), $attributes); + } + + public function getType(): string { + return 'Scalar_Int'; + } +} + +// @deprecated compatibility alias +class_alias(Int_::class, LNumber::class); diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/InterpolatedString.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/InterpolatedString.php new file mode 100644 index 0000000..a550d52 --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/InterpolatedString.php @@ -0,0 +1,34 @@ + $attributes Additional attributes + */ + public function __construct(array $parts, array $attributes = []) { + $this->attributes = $attributes; + $this->parts = $parts; + } + + public function getSubNodeNames(): array { + return ['parts']; + } + + public function getType(): string { + return 'Scalar_InterpolatedString'; + } +} + +// @deprecated compatibility alias +class_alias(InterpolatedString::class, Encapsed::class); diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/LNumber.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/LNumber.php index b7866ed..cfe8c8c 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/LNumber.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/LNumber.php @@ -1,80 +1,3 @@ attributes = $attributes; - $this->value = $value; - } - - public function getSubNodeNames() : array { - return ['value']; - } - - /** - * Constructs an LNumber node from a string number literal. - * - * @param string $str String number literal (decimal, octal, hex or binary) - * @param array $attributes Additional attributes - * @param bool $allowInvalidOctal Whether to allow invalid octal numbers (PHP 5) - * - * @return LNumber The constructed LNumber, including kind attribute - */ - public static function fromString(string $str, array $attributes = [], bool $allowInvalidOctal = false) : LNumber { - $attributes['rawValue'] = $str; - - $str = str_replace('_', '', $str); - - if ('0' !== $str[0] || '0' === $str) { - $attributes['kind'] = LNumber::KIND_DEC; - return new LNumber((int) $str, $attributes); - } - - if ('x' === $str[1] || 'X' === $str[1]) { - $attributes['kind'] = LNumber::KIND_HEX; - return new LNumber(hexdec($str), $attributes); - } - - if ('b' === $str[1] || 'B' === $str[1]) { - $attributes['kind'] = LNumber::KIND_BIN; - return new LNumber(bindec($str), $attributes); - } - - if (!$allowInvalidOctal && strpbrk($str, '89')) { - throw new Error('Invalid numeric literal', $attributes); - } - - // Strip optional explicit octal prefix. - if ('o' === $str[1] || 'O' === $str[1]) { - $str = substr($str, 2); - } - - // use intval instead of octdec to get proper cutting behavior with malformed numbers - $attributes['kind'] = LNumber::KIND_OCT; - return new LNumber(intval($str, 8), $attributes); - } - - public function getType() : string { - return 'Scalar_LNumber'; - } -} +require __DIR__ . '/Int_.php'; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst.php index 56b7bca..4083f12 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst.php @@ -4,18 +4,17 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Scalar; use ncc\ThirdParty\nikic\PhpParser\Node\Scalar; -abstract class MagicConst extends Scalar -{ +abstract class MagicConst extends Scalar { /** * Constructs a magic constant node. * - * @param array $attributes Additional attributes + * @param array $attributes Additional attributes */ public function __construct(array $attributes = []) { $this->attributes = $attributes; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return []; } @@ -24,5 +23,5 @@ abstract class MagicConst extends Scalar * * @return string Name of magic constant */ - abstract public function getName() : string; + abstract public function getName(): string; } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Class_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Class_.php index 04f5965..82119c1 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Class_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Class_.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Scalar\MagicConst; use ncc\ThirdParty\nikic\PhpParser\Node\Scalar\MagicConst; -class Class_ extends MagicConst -{ - public function getName() : string { +class Class_ extends MagicConst { + public function getName(): string { return '__CLASS__'; } - - public function getType() : string { + + public function getType(): string { return 'Scalar_MagicConst_Class'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Dir.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Dir.php index 0bf4b51..5f01c8c 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Dir.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Dir.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Scalar\MagicConst; use ncc\ThirdParty\nikic\PhpParser\Node\Scalar\MagicConst; -class Dir extends MagicConst -{ - public function getName() : string { +class Dir extends MagicConst { + public function getName(): string { return '__DIR__'; } - - public function getType() : string { + + public function getType(): string { return 'Scalar_MagicConst_Dir'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/File.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/File.php index 430437f..e37ab92 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/File.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/File.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Scalar\MagicConst; use ncc\ThirdParty\nikic\PhpParser\Node\Scalar\MagicConst; -class File extends MagicConst -{ - public function getName() : string { +class File extends MagicConst { + public function getName(): string { return '__FILE__'; } - - public function getType() : string { + + public function getType(): string { return 'Scalar_MagicConst_File'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Function_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Function_.php index c1fabef..b25d57d 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Function_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Function_.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Scalar\MagicConst; use ncc\ThirdParty\nikic\PhpParser\Node\Scalar\MagicConst; -class Function_ extends MagicConst -{ - public function getName() : string { +class Function_ extends MagicConst { + public function getName(): string { return '__FUNCTION__'; } - - public function getType() : string { + + public function getType(): string { return 'Scalar_MagicConst_Function'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Line.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Line.php index cd44dfa..c2cad03 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Line.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Line.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Scalar\MagicConst; use ncc\ThirdParty\nikic\PhpParser\Node\Scalar\MagicConst; -class Line extends MagicConst -{ - public function getName() : string { +class Line extends MagicConst { + public function getName(): string { return '__LINE__'; } - - public function getType() : string { + + public function getType(): string { return 'Scalar_MagicConst_Line'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Method.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Method.php index ba089ba..b5e97cb 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Method.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Method.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Scalar\MagicConst; use ncc\ThirdParty\nikic\PhpParser\Node\Scalar\MagicConst; -class Method extends MagicConst -{ - public function getName() : string { +class Method extends MagicConst { + public function getName(): string { return '__METHOD__'; } - - public function getType() : string { + + public function getType(): string { return 'Scalar_MagicConst_Method'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Namespace_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Namespace_.php index 1b3c166..2312d57 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Namespace_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Namespace_.php @@ -4,13 +4,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Scalar\MagicConst; use ncc\ThirdParty\nikic\PhpParser\Node\Scalar\MagicConst; -class Namespace_ extends MagicConst -{ - public function getName() : string { +class Namespace_ extends MagicConst { + public function getName(): string { return '__NAMESPACE__'; } - - public function getType() : string { + + public function getType(): string { return 'Scalar_MagicConst_Namespace'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Property.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Property.php new file mode 100644 index 0000000..0f378da --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Scalar/MagicConst/Property.php @@ -0,0 +1,15 @@ + Escaped character to its decoded value */ + protected static array $replacements = [ '\\' => '\\', '$' => '$', 'n' => "\n", @@ -30,23 +30,23 @@ class String_ extends Scalar /** * Constructs a string scalar node. * - * @param string $value Value of the string - * @param array $attributes Additional attributes + * @param string $value Value of the string + * @param array $attributes Additional attributes */ public function __construct(string $value, array $attributes = []) { $this->attributes = $attributes; $this->value = $value; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['value']; } /** + * @param array $attributes * @param bool $parseUnicodeEscape Whether to parse PHP 7 \u escapes */ - public static function fromString(string $str, array $attributes = [], bool $parseUnicodeEscape = true): self - { + public static function fromString(string $str, array $attributes = [], bool $parseUnicodeEscape = true): self { $attributes['kind'] = ($str[0] === "'" || ($str[1] === "'" && ($str[0] === 'b' || $str[0] === 'B'))) ? Scalar\String_::KIND_SINGLE_QUOTED : Scalar\String_::KIND_DOUBLE_QUOTED; @@ -68,7 +68,7 @@ class String_ extends Scalar * * @return string The parsed string */ - public static function parse(string $str, bool $parseUnicodeEscape = true) : string { + public static function parse(string $str, bool $parseUnicodeEscape = true): string { $bLength = 0; if ('b' === $str[0] || 'B' === $str[0]) { $bLength = 1; @@ -92,13 +92,13 @@ class String_ extends Scalar * * Parses escape sequences in strings (all string types apart from single quoted). * - * @param string $str String without quotes + * @param string $str String without quotes * @param null|string $quote Quote type * @param bool $parseUnicodeEscape Whether to parse PHP 7 \u escapes * * @return string String with escape sequences parsed */ - public static function parseEscapeSequences(string $str, $quote, bool $parseUnicodeEscape = true) : string { + public static function parseEscapeSequences(string $str, ?string $quote, bool $parseUnicodeEscape = true): string { if (null !== $quote) { $str = str_replace('\\' . $quote, $quote, $str); } @@ -110,15 +110,19 @@ class String_ extends Scalar return preg_replace_callback( '~\\\\([\\\\$nrtfve]|[xX][0-9a-fA-F]{1,2}|[0-7]{1,3}' . $extra . ')~', - function($matches) { + function ($matches) { $str = $matches[1]; if (isset(self::$replacements[$str])) { return self::$replacements[$str]; - } elseif ('x' === $str[0] || 'X' === $str[0]) { + } + if ('x' === $str[0] || 'X' === $str[0]) { return chr(hexdec(substr($str, 1))); - } elseif ('u' === $str[0]) { - return self::codePointToUtf8(hexdec($matches[2])); + } + if ('u' === $str[0]) { + $dec = hexdec($matches[2]); + // If it overflowed to float, treat as INT_MAX, it will throw an error anyway. + return self::codePointToUtf8(\is_int($dec) ? $dec : \PHP_INT_MAX); } else { return chr(octdec($str)); } @@ -134,24 +138,24 @@ class String_ extends Scalar * * @return string UTF-8 representation of code point */ - private static function codePointToUtf8(int $num) : string { + private static function codePointToUtf8(int $num): string { if ($num <= 0x7F) { return chr($num); } if ($num <= 0x7FF) { - return chr(($num>>6) + 0xC0) . chr(($num&0x3F) + 0x80); + return chr(($num >> 6) + 0xC0) . chr(($num & 0x3F) + 0x80); } if ($num <= 0xFFFF) { - return chr(($num>>12) + 0xE0) . chr((($num>>6)&0x3F) + 0x80) . chr(($num&0x3F) + 0x80); + return chr(($num >> 12) + 0xE0) . chr((($num >> 6) & 0x3F) + 0x80) . chr(($num & 0x3F) + 0x80); } if ($num <= 0x1FFFFF) { - return chr(($num>>18) + 0xF0) . chr((($num>>12)&0x3F) + 0x80) - . chr((($num>>6)&0x3F) + 0x80) . chr(($num&0x3F) + 0x80); + return chr(($num >> 18) + 0xF0) . chr((($num >> 12) & 0x3F) + 0x80) + . chr((($num >> 6) & 0x3F) + 0x80) . chr(($num & 0x3F) + 0x80); } throw new Error('Invalid UTF-8 codepoint escape sequence: Codepoint too large'); } - public function getType() : string { + public function getType(): string { return 'Scalar_String'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/StaticVar.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/StaticVar.php new file mode 100644 index 0000000..02b89c7 --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/StaticVar.php @@ -0,0 +1,39 @@ + $attributes Additional attributes + */ + public function __construct( + Expr\Variable $var, ?Node\Expr $default = null, array $attributes = [] + ) { + $this->attributes = $attributes; + $this->var = $var; + $this->default = $default; + } + + public function getSubNodeNames(): array { + return ['var', 'default']; + } + + public function getType(): string { + return 'StaticVar'; + } +} + +// @deprecated compatibility alias +class_alias(StaticVar::class, Stmt\StaticVar::class); diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt.php index 97a9759..eab1e55 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt.php @@ -4,6 +4,5 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\NodeAbstract; -abstract class Stmt extends NodeAbstract -{ +abstract class Stmt extends NodeAbstract { } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Block.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Block.php new file mode 100644 index 0000000..83e5f0a --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Block.php @@ -0,0 +1,29 @@ + $attributes Additional attributes + */ + public function __construct(array $stmts, array $attributes = []) { + $this->attributes = $attributes; + $this->stmts = $stmts; + } + + public function getType(): string { + return 'Stmt_Block'; + } + + public function getSubNodeNames(): array { + return ['stmts']; + } +} diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Break_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Break_.php index b614b59..a1cfbf7 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Break_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Break_.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -class Break_ extends Node\Stmt -{ +class Break_ extends Node\Stmt { /** @var null|Node\Expr Number of loops to break */ - public $num; + public ?Node\Expr $num; /** * Constructs a break node. * - * @param null|Node\Expr $num Number of loops to break - * @param array $attributes Additional attributes + * @param null|Node\Expr $num Number of loops to break + * @param array $attributes Additional attributes */ - public function __construct(Node\Expr $num = null, array $attributes = []) { + public function __construct(?Node\Expr $num = null, array $attributes = []) { $this->attributes = $attributes; $this->num = $num; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['num']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_Break'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Case_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Case_.php index 88c3026..6cca673 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Case_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Case_.php @@ -4,31 +4,30 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -class Case_ extends Node\Stmt -{ +class Case_ extends Node\Stmt { /** @var null|Node\Expr Condition (null for default) */ - public $cond; + public ?Node\Expr $cond; /** @var Node\Stmt[] Statements */ - public $stmts; + public array $stmts; /** * Constructs a case node. * - * @param null|Node\Expr $cond Condition (null for default) - * @param Node\Stmt[] $stmts Statements - * @param array $attributes Additional attributes + * @param null|Node\Expr $cond Condition (null for default) + * @param Node\Stmt[] $stmts Statements + * @param array $attributes Additional attributes */ - public function __construct($cond, array $stmts = [], array $attributes = []) { + public function __construct(?Node\Expr $cond, array $stmts = [], array $attributes = []) { $this->attributes = $attributes; $this->cond = $cond; $this->stmts = $stmts; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['cond', 'stmts']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_Case'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Catch_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Catch_.php index edc0cd1..1c9da46 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Catch_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Catch_.php @@ -5,25 +5,24 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; -class Catch_ extends Node\Stmt -{ +class Catch_ extends Node\Stmt { /** @var Node\Name[] Types of exceptions to catch */ - public $types; + public array $types; /** @var Expr\Variable|null Variable for exception */ - public $var; + public ?Expr\Variable $var; /** @var Node\Stmt[] Statements */ - public $stmts; + public array $stmts; /** * Constructs a catch node. * - * @param Node\Name[] $types Types of exceptions to catch - * @param Expr\Variable|null $var Variable for exception - * @param Node\Stmt[] $stmts Statements - * @param array $attributes Additional attributes + * @param Node\Name[] $types Types of exceptions to catch + * @param Expr\Variable|null $var Variable for exception + * @param Node\Stmt[] $stmts Statements + * @param array $attributes Additional attributes */ public function __construct( - array $types, Expr\Variable $var = null, array $stmts = [], array $attributes = [] + array $types, ?Expr\Variable $var = null, array $stmts = [], array $attributes = [] ) { $this->attributes = $attributes; $this->types = $types; @@ -31,11 +30,11 @@ class Catch_ extends Node\Stmt $this->stmts = $stmts; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['types', 'var', 'stmts']; } - public function getType() : string { + public function getType(): string { return 'Stmt_Catch'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/ClassConst.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/ClassConst.php index f05a4f7..8f120e9 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/ClassConst.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/ClassConst.php @@ -2,84 +2,76 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; +use ncc\ThirdParty\nikic\PhpParser\Modifiers; use ncc\ThirdParty\nikic\PhpParser\Node; -class ClassConst extends Node\Stmt -{ +class ClassConst extends Node\Stmt { /** @var int Modifiers */ - public $flags; + public int $flags; /** @var Node\Const_[] Constant declarations */ - public $consts; + public array $consts; /** @var Node\AttributeGroup[] PHP attribute groups */ - public $attrGroups; + public array $attrGroups; /** @var Node\Identifier|Node\Name|Node\ComplexType|null Type declaration */ - public $type; + public ?Node $type; /** * Constructs a class const list node. * - * @param Node\Const_[] $consts Constant declarations - * @param int $flags Modifiers - * @param array $attributes Additional attributes - * @param Node\AttributeGroup[] $attrGroups PHP attribute groups - * @param null|string|Node\Identifier|Node\Name|Node\ComplexType $type Type declaration + * @param Node\Const_[] $consts Constant declarations + * @param int $flags Modifiers + * @param array $attributes Additional attributes + * @param list $attrGroups PHP attribute groups + * @param null|Node\Identifier|Node\Name|Node\ComplexType $type Type declaration */ public function __construct( array $consts, int $flags = 0, array $attributes = [], array $attrGroups = [], - $type = null + ?Node $type = null ) { $this->attributes = $attributes; $this->flags = $flags; $this->consts = $consts; $this->attrGroups = $attrGroups; - $this->type = \is_string($type) ? new Node\Identifier($type) : $type; + $this->type = $type; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['attrGroups', 'flags', 'type', 'consts']; } /** * Whether constant is explicitly or implicitly public. - * - * @return bool */ - public function isPublic() : bool { - return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0 - || ($this->flags & Class_::VISIBILITY_MODIFIER_MASK) === 0; + public function isPublic(): bool { + return ($this->flags & Modifiers::PUBLIC) !== 0 + || ($this->flags & Modifiers::VISIBILITY_MASK) === 0; } /** * Whether constant is protected. - * - * @return bool */ - public function isProtected() : bool { - return (bool) ($this->flags & Class_::MODIFIER_PROTECTED); + public function isProtected(): bool { + return (bool) ($this->flags & Modifiers::PROTECTED); } /** * Whether constant is private. - * - * @return bool */ - public function isPrivate() : bool { - return (bool) ($this->flags & Class_::MODIFIER_PRIVATE); + public function isPrivate(): bool { + return (bool) ($this->flags & Modifiers::PRIVATE); } /** * Whether constant is final. - * - * @return bool */ - public function isFinal() : bool { - return (bool) ($this->flags & Class_::MODIFIER_FINAL); + public function isFinal(): bool { + return (bool) ($this->flags & Modifiers::FINAL); } - public function getType() : string { + public function getType(): string { return 'Stmt_ClassConst'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/ClassLike.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/ClassLike.php index 4627b8e..7634ca1 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/ClassLike.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/ClassLike.php @@ -3,23 +3,23 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; +use ncc\ThirdParty\nikic\PhpParser\Node\PropertyItem; -abstract class ClassLike extends Node\Stmt -{ +abstract class ClassLike extends Node\Stmt { /** @var Node\Identifier|null Name */ - public $name; + public ?Node\Identifier $name; /** @var Node\Stmt[] Statements */ - public $stmts; + public array $stmts; /** @var Node\AttributeGroup[] PHP attribute groups */ - public $attrGroups; + public array $attrGroups; /** @var Node\Name|null Namespaced name (if using NameResolver) */ - public $namespacedName; + public ?Node\Name $namespacedName; /** * @return TraitUse[] */ - public function getTraitUses() : array { + public function getTraitUses(): array { $traitUses = []; foreach ($this->stmts as $stmt) { if ($stmt instanceof TraitUse) { @@ -32,7 +32,7 @@ abstract class ClassLike extends Node\Stmt /** * @return ClassConst[] */ - public function getConstants() : array { + public function getConstants(): array { $constants = []; foreach ($this->stmts as $stmt) { if ($stmt instanceof ClassConst) { @@ -45,7 +45,7 @@ abstract class ClassLike extends Node\Stmt /** * @return Property[] */ - public function getProperties() : array { + public function getProperties(): array { $properties = []; foreach ($this->stmts as $stmt) { if ($stmt instanceof Property) { @@ -62,11 +62,11 @@ abstract class ClassLike extends Node\Stmt * * @return Property|null Property node or null if the property does not exist */ - public function getProperty(string $name) { + public function getProperty(string $name): ?Property { foreach ($this->stmts as $stmt) { if ($stmt instanceof Property) { foreach ($stmt->props as $prop) { - if ($prop instanceof PropertyProperty && $name === $prop->name->toString()) { + if ($prop instanceof PropertyItem && $name === $prop->name->toString()) { return $stmt; } } @@ -80,7 +80,7 @@ abstract class ClassLike extends Node\Stmt * * @return ClassMethod[] */ - public function getMethods() : array { + public function getMethods(): array { $methods = []; foreach ($this->stmts as $stmt) { if ($stmt instanceof ClassMethod) { @@ -97,7 +97,7 @@ abstract class ClassLike extends Node\Stmt * * @return ClassMethod|null Method node or null if the method does not exist */ - public function getMethod(string $name) { + public function getMethod(string $name): ?ClassMethod { $lowerName = strtolower($name); foreach ($this->stmts as $stmt) { if ($stmt instanceof ClassMethod && $lowerName === $stmt->name->toLowerString()) { diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/ClassMethod.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/ClassMethod.php index 631f289..933a41a 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/ClassMethod.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/ClassMethod.php @@ -2,27 +2,28 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; +use ncc\ThirdParty\nikic\PhpParser\Modifiers; use ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\Node\FunctionLike; -class ClassMethod extends Node\Stmt implements FunctionLike -{ +class ClassMethod extends Node\Stmt implements FunctionLike { /** @var int Flags */ - public $flags; + public int $flags; /** @var bool Whether to return by reference */ - public $byRef; + public bool $byRef; /** @var Node\Identifier Name */ - public $name; + public Node\Identifier $name; /** @var Node\Param[] Parameters */ - public $params; + public array $params; /** @var null|Node\Identifier|Node\Name|Node\ComplexType Return type */ - public $returnType; + public ?Node $returnType; /** @var Node\Stmt[]|null Statements */ - public $stmts; + public ?array $stmts; /** @var Node\AttributeGroup[] PHP attribute groups */ - public $attrGroups; + public array $attrGroups; - private static $magicNames = [ + /** @var array */ + private static array $magicNames = [ '__construct' => true, '__destruct' => true, '__call' => true, @@ -46,14 +47,21 @@ class ClassMethod extends Node\Stmt implements FunctionLike * Constructs a class method node. * * @param string|Node\Identifier $name Name - * @param array $subNodes Array of the following optional subnodes: - * 'flags => MODIFIER_PUBLIC: Flags - * 'byRef' => false : Whether to return by reference - * 'params' => array() : Parameters - * 'returnType' => null : Return type - * 'stmts' => array() : Statements - * 'attrGroups' => array() : PHP attribute groups - * @param array $attributes Additional attributes + * @param array{ + * flags?: int, + * byRef?: bool, + * params?: Node\Param[], + * returnType?: null|Node\Identifier|Node\Name|Node\ComplexType, + * stmts?: Node\Stmt[]|null, + * attrGroups?: Node\AttributeGroup[], + * } $subNodes Array of the following optional subnodes: + * 'flags => 0 : Flags + * 'byRef' => false : Whether to return by reference + * 'params' => array() : Parameters + * 'returnType' => null : Return type + * 'stmts' => array() : Statements + * 'attrGroups' => array() : PHP attribute groups + * @param array $attributes Additional attributes */ public function __construct($name, array $subNodes = [], array $attributes = []) { $this->attributes = $attributes; @@ -61,21 +69,20 @@ class ClassMethod extends Node\Stmt implements FunctionLike $this->byRef = $subNodes['byRef'] ?? false; $this->name = \is_string($name) ? new Node\Identifier($name) : $name; $this->params = $subNodes['params'] ?? []; - $returnType = $subNodes['returnType'] ?? null; - $this->returnType = \is_string($returnType) ? new Node\Identifier($returnType) : $returnType; + $this->returnType = $subNodes['returnType'] ?? null; $this->stmts = array_key_exists('stmts', $subNodes) ? $subNodes['stmts'] : []; $this->attrGroups = $subNodes['attrGroups'] ?? []; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['attrGroups', 'flags', 'byRef', 'name', 'params', 'returnType', 'stmts']; } - public function returnsByRef() : bool { + public function returnsByRef(): bool { return $this->byRef; } - public function getParams() : array { + public function getParams(): array { return $this->params; } @@ -83,79 +90,65 @@ class ClassMethod extends Node\Stmt implements FunctionLike return $this->returnType; } - public function getStmts() { + public function getStmts(): ?array { return $this->stmts; } - public function getAttrGroups() : array { + public function getAttrGroups(): array { return $this->attrGroups; } /** * Whether the method is explicitly or implicitly public. - * - * @return bool */ - public function isPublic() : bool { - return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0 - || ($this->flags & Class_::VISIBILITY_MODIFIER_MASK) === 0; + public function isPublic(): bool { + return ($this->flags & Modifiers::PUBLIC) !== 0 + || ($this->flags & Modifiers::VISIBILITY_MASK) === 0; } /** * Whether the method is protected. - * - * @return bool */ - public function isProtected() : bool { - return (bool) ($this->flags & Class_::MODIFIER_PROTECTED); + public function isProtected(): bool { + return (bool) ($this->flags & Modifiers::PROTECTED); } /** * Whether the method is private. - * - * @return bool */ - public function isPrivate() : bool { - return (bool) ($this->flags & Class_::MODIFIER_PRIVATE); + public function isPrivate(): bool { + return (bool) ($this->flags & Modifiers::PRIVATE); } /** * Whether the method is abstract. - * - * @return bool */ - public function isAbstract() : bool { - return (bool) ($this->flags & Class_::MODIFIER_ABSTRACT); + public function isAbstract(): bool { + return (bool) ($this->flags & Modifiers::ABSTRACT); } /** * Whether the method is final. - * - * @return bool */ - public function isFinal() : bool { - return (bool) ($this->flags & Class_::MODIFIER_FINAL); + public function isFinal(): bool { + return (bool) ($this->flags & Modifiers::FINAL); } /** * Whether the method is static. - * - * @return bool */ - public function isStatic() : bool { - return (bool) ($this->flags & Class_::MODIFIER_STATIC); + public function isStatic(): bool { + return (bool) ($this->flags & Modifiers::STATIC); } /** * Whether the method is magic. - * - * @return bool */ - public function isMagic() : bool { + public function isMagic(): bool { return isset(self::$magicNames[$this->name->toLowerString()]); } - public function getType() : string { + public function getType(): string { return 'Stmt_ClassMethod'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Class_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Class_.php index ff9adbd..d116ccb 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Class_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Class_.php @@ -2,39 +2,52 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; -use ncc\ThirdParty\nikic\PhpParser\Error; +use ncc\ThirdParty\nikic\PhpParser\Modifiers; use ncc\ThirdParty\nikic\PhpParser\Node; -class Class_ extends ClassLike -{ - const MODIFIER_PUBLIC = 1; - const MODIFIER_PROTECTED = 2; - const MODIFIER_PRIVATE = 4; - const MODIFIER_STATIC = 8; - const MODIFIER_ABSTRACT = 16; - const MODIFIER_FINAL = 32; - const MODIFIER_READONLY = 64; +class Class_ extends ClassLike { + /** @deprecated Use Modifiers::PUBLIC instead */ + public const MODIFIER_PUBLIC = 1; + /** @deprecated Use Modifiers::PROTECTED instead */ + public const MODIFIER_PROTECTED = 2; + /** @deprecated Use Modifiers::PRIVATE instead */ + public const MODIFIER_PRIVATE = 4; + /** @deprecated Use Modifiers::STATIC instead */ + public const MODIFIER_STATIC = 8; + /** @deprecated Use Modifiers::ABSTRACT instead */ + public const MODIFIER_ABSTRACT = 16; + /** @deprecated Use Modifiers::FINAL instead */ + public const MODIFIER_FINAL = 32; + /** @deprecated Use Modifiers::READONLY instead */ + public const MODIFIER_READONLY = 64; - const VISIBILITY_MODIFIER_MASK = 7; // 1 | 2 | 4 + /** @deprecated Use Modifiers::VISIBILITY_MASK instead */ + public const VISIBILITY_MODIFIER_MASK = 7; // 1 | 2 | 4 - /** @var int Type */ - public $flags; + /** @var int Modifiers */ + public int $flags; /** @var null|Node\Name Name of extended class */ - public $extends; + public ?Node\Name $extends; /** @var Node\Name[] Names of implemented interfaces */ - public $implements; + public array $implements; /** * Constructs a class node. * * @param string|Node\Identifier|null $name Name - * @param array $subNodes Array of the following optional subnodes: - * 'flags' => 0 : Flags - * 'extends' => null : Name of extended class - * 'implements' => array(): Names of implemented interfaces - * 'stmts' => array(): Statements - * 'attrGroups' => array(): PHP attribute groups - * @param array $attributes Additional attributes + * @param array{ + * flags?: int, + * extends?: Node\Name|null, + * implements?: Node\Name[], + * stmts?: Node\Stmt[], + * attrGroups?: Node\AttributeGroup[], + * } $subNodes Array of the following optional subnodes: + * 'flags' => 0 : Flags + * 'extends' => null : Name of extended class + * 'implements' => array(): Names of implemented interfaces + * 'stmts' => array(): Statements + * 'attrGroups' => array(): PHP attribute groups + * @param array $attributes Additional attributes */ public function __construct($name, array $subNodes = [], array $attributes = []) { $this->attributes = $attributes; @@ -46,92 +59,36 @@ class Class_ extends ClassLike $this->attrGroups = $subNodes['attrGroups'] ?? []; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['attrGroups', 'flags', 'name', 'extends', 'implements', 'stmts']; } /** * Whether the class is explicitly abstract. - * - * @return bool */ - public function isAbstract() : bool { - return (bool) ($this->flags & self::MODIFIER_ABSTRACT); + public function isAbstract(): bool { + return (bool) ($this->flags & Modifiers::ABSTRACT); } /** * Whether the class is final. - * - * @return bool */ - public function isFinal() : bool { - return (bool) ($this->flags & self::MODIFIER_FINAL); + public function isFinal(): bool { + return (bool) ($this->flags & Modifiers::FINAL); } - public function isReadonly() : bool { - return (bool) ($this->flags & self::MODIFIER_READONLY); + public function isReadonly(): bool { + return (bool) ($this->flags & Modifiers::READONLY); } /** * Whether the class is anonymous. - * - * @return bool */ - public function isAnonymous() : bool { + public function isAnonymous(): bool { return null === $this->name; } - /** - * @internal - */ - public static function verifyClassModifier($a, $b) { - if ($a & self::MODIFIER_ABSTRACT && $b & self::MODIFIER_ABSTRACT) { - throw new Error('Multiple abstract modifiers are not allowed'); - } - - if ($a & self::MODIFIER_FINAL && $b & self::MODIFIER_FINAL) { - throw new Error('Multiple final modifiers are not allowed'); - } - - if ($a & self::MODIFIER_READONLY && $b & self::MODIFIER_READONLY) { - throw new Error('Multiple readonly modifiers are not allowed'); - } - - if ($a & 48 && $b & 48) { - throw new Error('Cannot use the final modifier on an abstract class'); - } - } - - /** - * @internal - */ - public static function verifyModifier($a, $b) { - if ($a & self::VISIBILITY_MODIFIER_MASK && $b & self::VISIBILITY_MODIFIER_MASK) { - throw new Error('Multiple access type modifiers are not allowed'); - } - - if ($a & self::MODIFIER_ABSTRACT && $b & self::MODIFIER_ABSTRACT) { - throw new Error('Multiple abstract modifiers are not allowed'); - } - - if ($a & self::MODIFIER_STATIC && $b & self::MODIFIER_STATIC) { - throw new Error('Multiple static modifiers are not allowed'); - } - - if ($a & self::MODIFIER_FINAL && $b & self::MODIFIER_FINAL) { - throw new Error('Multiple final modifiers are not allowed'); - } - - if ($a & self::MODIFIER_READONLY && $b & self::MODIFIER_READONLY) { - throw new Error('Multiple readonly modifiers are not allowed'); - } - - if ($a & 48 && $b & 48) { - throw new Error('Cannot use the final modifier on an abstract class member'); - } - } - - public function getType() : string { + public function getType(): string { return 'Stmt_Class'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Const_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Const_.php index 0eb121e..e0dd90f 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Const_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Const_.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -class Const_ extends Node\Stmt -{ +class Const_ extends Node\Stmt { /** @var Node\Const_[] Constant declarations */ - public $consts; + public array $consts; /** * Constructs a const list node. * - * @param Node\Const_[] $consts Constant declarations - * @param array $attributes Additional attributes + * @param Node\Const_[] $consts Constant declarations + * @param array $attributes Additional attributes */ public function __construct(array $consts, array $attributes = []) { $this->attributes = $attributes; $this->consts = $consts; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['consts']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_Const'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Continue_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Continue_.php index 02785da..ad4b8fa 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Continue_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Continue_.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -class Continue_ extends Node\Stmt -{ +class Continue_ extends Node\Stmt { /** @var null|Node\Expr Number of loops to continue */ - public $num; + public ?Node\Expr $num; /** * Constructs a continue node. * - * @param null|Node\Expr $num Number of loops to continue - * @param array $attributes Additional attributes + * @param null|Node\Expr $num Number of loops to continue + * @param array $attributes Additional attributes */ - public function __construct(Node\Expr $num = null, array $attributes = []) { + public function __construct(?Node\Expr $num = null, array $attributes = []) { $this->attributes = $attributes; $this->num = $num; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['num']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_Continue'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/DeclareDeclare.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/DeclareDeclare.php index 6530e31..cb9e837 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/DeclareDeclare.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/DeclareDeclare.php @@ -1,34 +1,3 @@ value pair node. - * - * @param string|Node\Identifier $key Key - * @param Node\Expr $value Value - * @param array $attributes Additional attributes - */ - public function __construct($key, Node\Expr $value, array $attributes = []) { - $this->attributes = $attributes; - $this->key = \is_string($key) ? new Node\Identifier($key) : $key; - $this->value = $value; - } - - public function getSubNodeNames() : array { - return ['key', 'value']; - } - - public function getType() : string { - return 'Stmt_DeclareDeclare'; - } -} +require __DIR__ . '/../DeclareItem.php'; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Declare_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Declare_.php index 257ba5a..14c5e68 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Declare_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Declare_.php @@ -3,32 +3,32 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; +use ncc\ThirdParty\nikic\PhpParser\Node\DeclareItem; -class Declare_ extends Node\Stmt -{ - /** @var DeclareDeclare[] List of declares */ - public $declares; +class Declare_ extends Node\Stmt { + /** @var DeclareItem[] List of declares */ + public array $declares; /** @var Node\Stmt[]|null Statements */ - public $stmts; + public ?array $stmts; /** * Constructs a declare node. * - * @param DeclareDeclare[] $declares List of declares - * @param Node\Stmt[]|null $stmts Statements - * @param array $attributes Additional attributes + * @param DeclareItem[] $declares List of declares + * @param Node\Stmt[]|null $stmts Statements + * @param array $attributes Additional attributes */ - public function __construct(array $declares, array $stmts = null, array $attributes = []) { + public function __construct(array $declares, ?array $stmts = null, array $attributes = []) { $this->attributes = $attributes; $this->declares = $declares; $this->stmts = $stmts; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['declares', 'stmts']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_Declare'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Do_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Do_.php index 3b81d8c..2984f1f 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Do_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Do_.php @@ -4,19 +4,18 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -class Do_ extends Node\Stmt -{ +class Do_ extends Node\Stmt { /** @var Node\Stmt[] Statements */ - public $stmts; + public array $stmts; /** @var Node\Expr Condition */ - public $cond; + public Node\Expr $cond; /** * Constructs a do while node. * - * @param Node\Expr $cond Condition - * @param Node\Stmt[] $stmts Statements - * @param array $attributes Additional attributes + * @param Node\Expr $cond Condition + * @param Node\Stmt[] $stmts Statements + * @param array $attributes Additional attributes */ public function __construct(Node\Expr $cond, array $stmts = [], array $attributes = []) { $this->attributes = $attributes; @@ -24,11 +23,11 @@ class Do_ extends Node\Stmt $this->stmts = $stmts; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['stmts', 'cond']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_Do'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Echo_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Echo_.php index 334da75..fd73b26 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Echo_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Echo_.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -class Echo_ extends Node\Stmt -{ +class Echo_ extends Node\Stmt { /** @var Node\Expr[] Expressions */ - public $exprs; + public array $exprs; /** * Constructs an echo node. * - * @param Node\Expr[] $exprs Expressions - * @param array $attributes Additional attributes + * @param Node\Expr[] $exprs Expressions + * @param array $attributes Additional attributes */ public function __construct(array $exprs, array $attributes = []) { $this->attributes = $attributes; $this->exprs = $exprs; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['exprs']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_Echo'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/ElseIf_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/ElseIf_.php index da0e593..dfd3e0f 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/ElseIf_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/ElseIf_.php @@ -4,19 +4,18 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -class ElseIf_ extends Node\Stmt -{ +class ElseIf_ extends Node\Stmt { /** @var Node\Expr Condition */ - public $cond; + public Node\Expr $cond; /** @var Node\Stmt[] Statements */ - public $stmts; + public array $stmts; /** * Constructs an elseif node. * - * @param Node\Expr $cond Condition - * @param Node\Stmt[] $stmts Statements - * @param array $attributes Additional attributes + * @param Node\Expr $cond Condition + * @param Node\Stmt[] $stmts Statements + * @param array $attributes Additional attributes */ public function __construct(Node\Expr $cond, array $stmts = [], array $attributes = []) { $this->attributes = $attributes; @@ -24,11 +23,11 @@ class ElseIf_ extends Node\Stmt $this->stmts = $stmts; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['cond', 'stmts']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_ElseIf'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Else_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Else_.php index 2477959..002fbb0 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Else_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Else_.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -class Else_ extends Node\Stmt -{ +class Else_ extends Node\Stmt { /** @var Node\Stmt[] Statements */ - public $stmts; + public array $stmts; /** * Constructs an else node. * - * @param Node\Stmt[] $stmts Statements - * @param array $attributes Additional attributes + * @param Node\Stmt[] $stmts Statements + * @param array $attributes Additional attributes */ public function __construct(array $stmts = [], array $attributes = []) { $this->attributes = $attributes; $this->stmts = $stmts; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['stmts']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_Else'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/EnumCase.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/EnumCase.php index 7efccb0..e58fd07 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/EnumCase.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/EnumCase.php @@ -5,33 +5,32 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\Node\AttributeGroup; -class EnumCase extends Node\Stmt -{ +class EnumCase extends Node\Stmt { /** @var Node\Identifier Enum case name */ - public $name; + public Node\Identifier $name; /** @var Node\Expr|null Enum case expression */ - public $expr; + public ?Node\Expr $expr; /** @var Node\AttributeGroup[] PHP attribute groups */ - public $attrGroups; + public array $attrGroups; /** - * @param string|Node\Identifier $name Enum case name - * @param Node\Expr|null $expr Enum case expression - * @param AttributeGroup[] $attrGroups PHP attribute groups - * @param array $attributes Additional attributes + * @param string|Node\Identifier $name Enum case name + * @param Node\Expr|null $expr Enum case expression + * @param list $attrGroups PHP attribute groups + * @param array $attributes Additional attributes */ - public function __construct($name, Node\Expr $expr = null, array $attrGroups = [], array $attributes = []) { + public function __construct($name, ?Node\Expr $expr = null, array $attrGroups = [], array $attributes = []) { parent::__construct($attributes); $this->name = \is_string($name) ? new Node\Identifier($name) : $name; $this->expr = $expr; $this->attrGroups = $attrGroups; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['attrGroups', 'name', 'expr']; } - public function getType() : string { + public function getType(): string { return 'Stmt_EnumCase'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Enum_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Enum_.php index 3215b14..482c276 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Enum_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Enum_.php @@ -4,21 +4,25 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -class Enum_ extends ClassLike -{ +class Enum_ extends ClassLike { /** @var null|Node\Identifier Scalar Type */ - public $scalarType; + public ?Node $scalarType; /** @var Node\Name[] Names of implemented interfaces */ - public $implements; + public array $implements; /** - * @param string|Node\Identifier|null $name Name - * @param array $subNodes Array of the following optional subnodes: - * 'scalarType' => null : Scalar type - * 'implements' => array() : Names of implemented interfaces - * 'stmts' => array() : Statements - * 'attrGroups' => array() : PHP attribute groups - * @param array $attributes Additional attributes + * @param string|Node\Identifier|null $name Name + * @param array{ + * scalarType?: Node\Identifier|null, + * implements?: Node\Name[], + * stmts?: Node\Stmt[], + * attrGroups?: Node\AttributeGroup[], + * } $subNodes Array of the following optional subnodes: + * 'scalarType' => null : Scalar type + * 'implements' => array() : Names of implemented interfaces + * 'stmts' => array() : Statements + * 'attrGroups' => array() : PHP attribute groups + * @param array $attributes Additional attributes */ public function __construct($name, array $subNodes = [], array $attributes = []) { $this->name = \is_string($name) ? new Node\Identifier($name) : $name; @@ -30,11 +34,11 @@ class Enum_ extends ClassLike parent::__construct($attributes); } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['attrGroups', 'name', 'scalarType', 'implements', 'stmts']; } - public function getType() : string { + public function getType(): string { return 'Stmt_Enum'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Expression.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Expression.php index 48f17ac..c399995 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Expression.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Expression.php @@ -7,27 +7,26 @@ use ncc\ThirdParty\nikic\PhpParser\Node; /** * Represents statements of type "expr;" */ -class Expression extends Node\Stmt -{ +class Expression extends Node\Stmt { /** @var Node\Expr Expression */ - public $expr; + public Node\Expr $expr; /** * Constructs an expression statement. * - * @param Node\Expr $expr Expression - * @param array $attributes Additional attributes + * @param Node\Expr $expr Expression + * @param array $attributes Additional attributes */ public function __construct(Node\Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['expr']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_Expression'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Finally_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Finally_.php index 46f0a18..6759a44 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Finally_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Finally_.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -class Finally_ extends Node\Stmt -{ +class Finally_ extends Node\Stmt { /** @var Node\Stmt[] Statements */ - public $stmts; + public array $stmts; /** * Constructs a finally node. * - * @param Node\Stmt[] $stmts Statements - * @param array $attributes Additional attributes + * @param Node\Stmt[] $stmts Statements + * @param array $attributes Additional attributes */ public function __construct(array $stmts = [], array $attributes = []) { $this->attributes = $attributes; $this->stmts = $stmts; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['stmts']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_Finally'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/For_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/For_.php index a3161a5..d4930b6 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/For_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/For_.php @@ -4,26 +4,30 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -class For_ extends Node\Stmt -{ +class For_ extends Node\Stmt { /** @var Node\Expr[] Init expressions */ - public $init; + public array $init; /** @var Node\Expr[] Loop conditions */ - public $cond; + public array $cond; /** @var Node\Expr[] Loop expressions */ - public $loop; + public array $loop; /** @var Node\Stmt[] Statements */ - public $stmts; + public array $stmts; /** * Constructs a for loop node. * - * @param array $subNodes Array of the following optional subnodes: - * 'init' => array(): Init expressions - * 'cond' => array(): Loop conditions - * 'loop' => array(): Loop expressions - * 'stmts' => array(): Statements - * @param array $attributes Additional attributes + * @param array{ + * init?: Node\Expr[], + * cond?: Node\Expr[], + * loop?: Node\Expr[], + * stmts?: Node\Stmt[], + * } $subNodes Array of the following optional subnodes: + * 'init' => array(): Init expressions + * 'cond' => array(): Loop conditions + * 'loop' => array(): Loop expressions + * 'stmts' => array(): Statements + * @param array $attributes Additional attributes */ public function __construct(array $subNodes = [], array $attributes = []) { $this->attributes = $attributes; @@ -33,11 +37,11 @@ class For_ extends Node\Stmt $this->stmts = $subNodes['stmts'] ?? []; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['init', 'cond', 'loop', 'stmts']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_For'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Foreach_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Foreach_.php index b04a6d4..f4ae143 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Foreach_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Foreach_.php @@ -4,29 +4,32 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -class Foreach_ extends Node\Stmt -{ +class Foreach_ extends Node\Stmt { /** @var Node\Expr Expression to iterate */ - public $expr; + public Node\Expr $expr; /** @var null|Node\Expr Variable to assign key to */ - public $keyVar; + public ?Node\Expr $keyVar; /** @var bool Whether to assign value by reference */ - public $byRef; + public bool $byRef; /** @var Node\Expr Variable to assign value to */ - public $valueVar; + public Node\Expr $valueVar; /** @var Node\Stmt[] Statements */ - public $stmts; + public array $stmts; /** * Constructs a foreach node. * - * @param Node\Expr $expr Expression to iterate - * @param Node\Expr $valueVar Variable to assign value to - * @param array $subNodes Array of the following optional subnodes: - * 'keyVar' => null : Variable to assign key to - * 'byRef' => false : Whether to assign value by reference - * 'stmts' => array(): Statements - * @param array $attributes Additional attributes + * @param Node\Expr $expr Expression to iterate + * @param Node\Expr $valueVar Variable to assign value to + * @param array{ + * keyVar?: Node\Expr|null, + * byRef?: bool, + * stmts?: Node\Stmt[], + * } $subNodes Array of the following optional subnodes: + * 'keyVar' => null : Variable to assign key to + * 'byRef' => false : Whether to assign value by reference + * 'stmts' => array(): Statements + * @param array $attributes Additional attributes */ public function __construct(Node\Expr $expr, Node\Expr $valueVar, array $subNodes = [], array $attributes = []) { $this->attributes = $attributes; @@ -37,11 +40,11 @@ class Foreach_ extends Node\Stmt $this->stmts = $subNodes['stmts'] ?? []; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['expr', 'keyVar', 'byRef', 'valueVar', 'stmts']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_Foreach'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Function_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Function_.php index f7b968a..5b4eaf8 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Function_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Function_.php @@ -5,56 +5,60 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\Node\FunctionLike; -class Function_ extends Node\Stmt implements FunctionLike -{ +class Function_ extends Node\Stmt implements FunctionLike { /** @var bool Whether function returns by reference */ - public $byRef; + public bool $byRef; /** @var Node\Identifier Name */ - public $name; + public Node\Identifier $name; /** @var Node\Param[] Parameters */ - public $params; + public array $params; /** @var null|Node\Identifier|Node\Name|Node\ComplexType Return type */ - public $returnType; + public ?Node $returnType; /** @var Node\Stmt[] Statements */ - public $stmts; + public array $stmts; /** @var Node\AttributeGroup[] PHP attribute groups */ - public $attrGroups; + public array $attrGroups; /** @var Node\Name|null Namespaced name (if using NameResolver) */ - public $namespacedName; + public ?Node\Name $namespacedName; /** * Constructs a function node. * * @param string|Node\Identifier $name Name - * @param array $subNodes Array of the following optional subnodes: - * 'byRef' => false : Whether to return by reference - * 'params' => array(): Parameters - * 'returnType' => null : Return type - * 'stmts' => array(): Statements - * 'attrGroups' => array(): PHP attribute groups - * @param array $attributes Additional attributes + * @param array{ + * byRef?: bool, + * params?: Node\Param[], + * returnType?: null|Node\Identifier|Node\Name|Node\ComplexType, + * stmts?: Node\Stmt[], + * attrGroups?: Node\AttributeGroup[], + * } $subNodes Array of the following optional subnodes: + * 'byRef' => false : Whether to return by reference + * 'params' => array(): Parameters + * 'returnType' => null : Return type + * 'stmts' => array(): Statements + * 'attrGroups' => array(): PHP attribute groups + * @param array $attributes Additional attributes */ public function __construct($name, array $subNodes = [], array $attributes = []) { $this->attributes = $attributes; $this->byRef = $subNodes['byRef'] ?? false; $this->name = \is_string($name) ? new Node\Identifier($name) : $name; $this->params = $subNodes['params'] ?? []; - $returnType = $subNodes['returnType'] ?? null; - $this->returnType = \is_string($returnType) ? new Node\Identifier($returnType) : $returnType; + $this->returnType = $subNodes['returnType'] ?? null; $this->stmts = $subNodes['stmts'] ?? []; $this->attrGroups = $subNodes['attrGroups'] ?? []; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['attrGroups', 'byRef', 'name', 'params', 'returnType', 'stmts']; } - public function returnsByRef() : bool { + public function returnsByRef(): bool { return $this->byRef; } - public function getParams() : array { + public function getParams(): array { return $this->params; } @@ -62,16 +66,16 @@ class Function_ extends Node\Stmt implements FunctionLike return $this->returnType; } - public function getAttrGroups() : array { + public function getAttrGroups(): array { return $this->attrGroups; } /** @return Node\Stmt[] */ - public function getStmts() : array { + public function getStmts(): array { return $this->stmts; } - public function getType() : string { + public function getType(): string { return 'Stmt_Function'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Global_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Global_.php index e46108c..9536596 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Global_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Global_.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -class Global_ extends Node\Stmt -{ +class Global_ extends Node\Stmt { /** @var Node\Expr[] Variables */ - public $vars; + public array $vars; /** * Constructs a global variables list node. * - * @param Node\Expr[] $vars Variables to unset - * @param array $attributes Additional attributes + * @param Node\Expr[] $vars Variables to unset + * @param array $attributes Additional attributes */ public function __construct(array $vars, array $attributes = []) { $this->attributes = $attributes; $this->vars = $vars; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['vars']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_Global'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Goto_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Goto_.php index e442b8b..207675d 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Goto_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Goto_.php @@ -5,27 +5,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node\Identifier; use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; -class Goto_ extends Stmt -{ +class Goto_ extends Stmt { /** @var Identifier Name of label to jump to */ - public $name; + public Identifier $name; /** * Constructs a goto node. * - * @param string|Identifier $name Name of label to jump to - * @param array $attributes Additional attributes + * @param string|Identifier $name Name of label to jump to + * @param array $attributes Additional attributes */ public function __construct($name, array $attributes = []) { $this->attributes = $attributes; $this->name = \is_string($name) ? new Identifier($name) : $name; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['name']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_Goto'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/GroupUse.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/GroupUse.php index 79a6876..9224dbd 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/GroupUse.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/GroupUse.php @@ -4,23 +4,25 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node\Name; use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; +use ncc\ThirdParty\nikic\PhpParser\Node\UseItem; -class GroupUse extends Stmt -{ - /** @var int Type of group use */ - public $type; +class GroupUse extends Stmt { + /** + * @var Use_::TYPE_* Type of group use + */ + public int $type; /** @var Name Prefix for uses */ - public $prefix; - /** @var UseUse[] Uses */ - public $uses; + public Name $prefix; + /** @var UseItem[] Uses */ + public array $uses; /** * Constructs a group use node. * - * @param Name $prefix Prefix for uses - * @param UseUse[] $uses Uses - * @param int $type Type of group use - * @param array $attributes Additional attributes + * @param Name $prefix Prefix for uses + * @param UseItem[] $uses Uses + * @param Use_::TYPE_* $type Type of group use + * @param array $attributes Additional attributes */ public function __construct(Name $prefix, array $uses, int $type = Use_::TYPE_NORMAL, array $attributes = []) { $this->attributes = $attributes; @@ -29,11 +31,11 @@ class GroupUse extends Stmt $this->uses = $uses; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['type', 'prefix', 'uses']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_GroupUse'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/HaltCompiler.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/HaltCompiler.php index 04251cb..b9c1bf8 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/HaltCompiler.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/HaltCompiler.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; -class HaltCompiler extends Stmt -{ +class HaltCompiler extends Stmt { /** @var string Remaining text after halt compiler statement. */ - public $remaining; + public string $remaining; /** * Constructs a __halt_compiler node. * - * @param string $remaining Remaining text after halt compiler statement. - * @param array $attributes Additional attributes + * @param string $remaining Remaining text after halt compiler statement. + * @param array $attributes Additional attributes */ public function __construct(string $remaining, array $attributes = []) { $this->attributes = $attributes; $this->remaining = $remaining; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['remaining']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_HaltCompiler'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/If_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/If_.php index ff5f234..78e591e 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/If_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/If_.php @@ -4,26 +4,29 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -class If_ extends Node\Stmt -{ +class If_ extends Node\Stmt { /** @var Node\Expr Condition expression */ - public $cond; + public Node\Expr $cond; /** @var Node\Stmt[] Statements */ - public $stmts; + public array $stmts; /** @var ElseIf_[] Elseif clauses */ - public $elseifs; + public array $elseifs; /** @var null|Else_ Else clause */ - public $else; + public ?Else_ $else; /** * Constructs an if node. * - * @param Node\Expr $cond Condition - * @param array $subNodes Array of the following optional subnodes: - * 'stmts' => array(): Statements - * 'elseifs' => array(): Elseif clauses - * 'else' => null : Else clause - * @param array $attributes Additional attributes + * @param Node\Expr $cond Condition + * @param array{ + * stmts?: Node\Stmt[], + * elseifs?: ElseIf_[], + * else?: Else_|null, + * } $subNodes Array of the following optional subnodes: + * 'stmts' => array(): Statements + * 'elseifs' => array(): Elseif clauses + * 'else' => null : Else clause + * @param array $attributes Additional attributes */ public function __construct(Node\Expr $cond, array $subNodes = [], array $attributes = []) { $this->attributes = $attributes; @@ -33,11 +36,11 @@ class If_ extends Node\Stmt $this->else = $subNodes['else'] ?? null; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['cond', 'stmts', 'elseifs', 'else']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_If'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/InlineHTML.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/InlineHTML.php index 394c117..8475255 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/InlineHTML.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/InlineHTML.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; -class InlineHTML extends Stmt -{ +class InlineHTML extends Stmt { /** @var string String */ - public $value; + public string $value; /** * Constructs an inline HTML node. * - * @param string $value String - * @param array $attributes Additional attributes + * @param string $value String + * @param array $attributes Additional attributes */ public function __construct(string $value, array $attributes = []) { $this->attributes = $attributes; $this->value = $value; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['value']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_InlineHTML'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Interface_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Interface_.php index 43d4bb2..ff11be8 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Interface_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Interface_.php @@ -4,20 +4,23 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -class Interface_ extends ClassLike -{ +class Interface_ extends ClassLike { /** @var Node\Name[] Extended interfaces */ - public $extends; + public array $extends; /** * Constructs a class node. * * @param string|Node\Identifier $name Name - * @param array $subNodes Array of the following optional subnodes: - * 'extends' => array(): Name of extended interfaces - * 'stmts' => array(): Statements - * 'attrGroups' => array(): PHP attribute groups - * @param array $attributes Additional attributes + * @param array{ + * extends?: Node\Name[], + * stmts?: Node\Stmt[], + * attrGroups?: Node\AttributeGroup[], + * } $subNodes Array of the following optional subnodes: + * 'extends' => array(): Name of extended interfaces + * 'stmts' => array(): Statements + * 'attrGroups' => array(): PHP attribute groups + * @param array $attributes Additional attributes */ public function __construct($name, array $subNodes = [], array $attributes = []) { $this->attributes = $attributes; @@ -27,11 +30,11 @@ class Interface_ extends ClassLike $this->attrGroups = $subNodes['attrGroups'] ?? []; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['attrGroups', 'name', 'extends', 'stmts']; } - public function getType() : string { + public function getType(): string { return 'Stmt_Interface'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Label.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Label.php index b9bbcac..d2b59be 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Label.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Label.php @@ -5,27 +5,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node\Identifier; use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; -class Label extends Stmt -{ +class Label extends Stmt { /** @var Identifier Name */ - public $name; + public Identifier $name; /** * Constructs a label node. * - * @param string|Identifier $name Name - * @param array $attributes Additional attributes + * @param string|Identifier $name Name + * @param array $attributes Additional attributes */ public function __construct($name, array $attributes = []) { $this->attributes = $attributes; $this->name = \is_string($name) ? new Identifier($name) : $name; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['name']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_Label'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Namespace_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Namespace_.php index 704b6b9..ba9105e 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Namespace_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Namespace_.php @@ -4,35 +4,34 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -class Namespace_ extends Node\Stmt -{ +class Namespace_ extends Node\Stmt { /* For use in the "kind" attribute */ - const KIND_SEMICOLON = 1; - const KIND_BRACED = 2; + public const KIND_SEMICOLON = 1; + public const KIND_BRACED = 2; /** @var null|Node\Name Name */ - public $name; + public ?Node\Name $name; /** @var Node\Stmt[] Statements */ public $stmts; /** * Constructs a namespace node. * - * @param null|Node\Name $name Name - * @param null|Node\Stmt[] $stmts Statements - * @param array $attributes Additional attributes + * @param null|Node\Name $name Name + * @param null|Node\Stmt[] $stmts Statements + * @param array $attributes Additional attributes */ - public function __construct(Node\Name $name = null, $stmts = [], array $attributes = []) { + public function __construct(?Node\Name $name = null, ?array $stmts = [], array $attributes = []) { $this->attributes = $attributes; $this->name = $name; $this->stmts = $stmts; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['name', 'stmts']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_Namespace'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Nop.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Nop.php index fea860b..dc52602 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Nop.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Nop.php @@ -5,13 +5,12 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; /** Nop/empty statement (;). */ -class Nop extends Node\Stmt -{ - public function getSubNodeNames() : array { +class Nop extends Node\Stmt { + public function getSubNodeNames(): array { return []; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_Nop'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Property.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Property.php index 1cb7da0..3eb746b 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Property.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Property.php @@ -2,90 +2,106 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; +use ncc\ThirdParty\nikic\PhpParser\Modifiers; use ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\Node\ComplexType; use ncc\ThirdParty\nikic\PhpParser\Node\Identifier; use ncc\ThirdParty\nikic\PhpParser\Node\Name; +use ncc\ThirdParty\nikic\PhpParser\Node\PropertyItem; -class Property extends Node\Stmt -{ +class Property extends Node\Stmt { /** @var int Modifiers */ - public $flags; - /** @var PropertyProperty[] Properties */ - public $props; + public int $flags; + /** @var PropertyItem[] Properties */ + public array $props; /** @var null|Identifier|Name|ComplexType Type declaration */ - public $type; + public ?Node $type; /** @var Node\AttributeGroup[] PHP attribute groups */ - public $attrGroups; + public array $attrGroups; + /** @var Node\PropertyHook[] Property hooks */ + public array $hooks; /** * Constructs a class property list node. * - * @param int $flags Modifiers - * @param PropertyProperty[] $props Properties - * @param array $attributes Additional attributes - * @param null|string|Identifier|Name|ComplexType $type Type declaration - * @param Node\AttributeGroup[] $attrGroups PHP attribute groups + * @param int $flags Modifiers + * @param PropertyItem[] $props Properties + * @param array $attributes Additional attributes + * @param null|Identifier|Name|ComplexType $type Type declaration + * @param Node\AttributeGroup[] $attrGroups PHP attribute groups + * @param Node\PropertyHook[] $hooks Property hooks */ - public function __construct(int $flags, array $props, array $attributes = [], $type = null, array $attrGroups = []) { + public function __construct(int $flags, array $props, array $attributes = [], ?Node $type = null, array $attrGroups = [], array $hooks = []) { $this->attributes = $attributes; $this->flags = $flags; $this->props = $props; - $this->type = \is_string($type) ? new Identifier($type) : $type; + $this->type = $type; $this->attrGroups = $attrGroups; + $this->hooks = $hooks; } - public function getSubNodeNames() : array { - return ['attrGroups', 'flags', 'type', 'props']; + public function getSubNodeNames(): array { + return ['attrGroups', 'flags', 'type', 'props', 'hooks']; } /** * Whether the property is explicitly or implicitly public. - * - * @return bool */ - public function isPublic() : bool { - return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0 - || ($this->flags & Class_::VISIBILITY_MODIFIER_MASK) === 0; + public function isPublic(): bool { + return ($this->flags & Modifiers::PUBLIC) !== 0 + || ($this->flags & Modifiers::VISIBILITY_MASK) === 0; } /** * Whether the property is protected. - * - * @return bool */ - public function isProtected() : bool { - return (bool) ($this->flags & Class_::MODIFIER_PROTECTED); + public function isProtected(): bool { + return (bool) ($this->flags & Modifiers::PROTECTED); } /** * Whether the property is private. - * - * @return bool */ - public function isPrivate() : bool { - return (bool) ($this->flags & Class_::MODIFIER_PRIVATE); + public function isPrivate(): bool { + return (bool) ($this->flags & Modifiers::PRIVATE); } /** * Whether the property is static. - * - * @return bool */ - public function isStatic() : bool { - return (bool) ($this->flags & Class_::MODIFIER_STATIC); + public function isStatic(): bool { + return (bool) ($this->flags & Modifiers::STATIC); } /** * Whether the property is readonly. - * - * @return bool */ - public function isReadonly() : bool { - return (bool) ($this->flags & Class_::MODIFIER_READONLY); + public function isReadonly(): bool { + return (bool) ($this->flags & Modifiers::READONLY); } - public function getType() : string { + /** + * Whether the property has explicit public(set) visibility. + */ + public function isPublicSet(): bool { + return (bool) ($this->flags & Modifiers::PUBLIC_SET); + } + + /** + * Whether the property has explicit protected(set) visibility. + */ + public function isProtectedSet(): bool { + return (bool) ($this->flags & Modifiers::PROTECTED_SET); + } + + /** + * Whether the property has explicit private(set) visibility. + */ + public function isPrivateSet(): bool { + return (bool) ($this->flags & Modifiers::PRIVATE_SET); + } + + public function getType(): string { return 'Stmt_Property'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/PropertyProperty.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/PropertyProperty.php index aa31246..4a21a88 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/PropertyProperty.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/PropertyProperty.php @@ -1,34 +1,3 @@ attributes = $attributes; - $this->name = \is_string($name) ? new Node\VarLikeIdentifier($name) : $name; - $this->default = $default; - } - - public function getSubNodeNames() : array { - return ['name', 'default']; - } - - public function getType() : string { - return 'Stmt_PropertyProperty'; - } -} +require __DIR__ . '/../PropertyItem.php'; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Return_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Return_.php index 9a43fa6..6f7b329 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Return_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Return_.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -class Return_ extends Node\Stmt -{ +class Return_ extends Node\Stmt { /** @var null|Node\Expr Expression */ - public $expr; + public ?Node\Expr $expr; /** * Constructs a return node. * - * @param null|Node\Expr $expr Expression - * @param array $attributes Additional attributes + * @param null|Node\Expr $expr Expression + * @param array $attributes Additional attributes */ - public function __construct(Node\Expr $expr = null, array $attributes = []) { + public function __construct(?Node\Expr $expr = null, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['expr']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_Return'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/StaticVar.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/StaticVar.php index 387b9fb..88452e7 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/StaticVar.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/StaticVar.php @@ -1,37 +1,3 @@ attributes = $attributes; - $this->var = $var; - $this->default = $default; - } - - public function getSubNodeNames() : array { - return ['var', 'default']; - } - - public function getType() : string { - return 'Stmt_StaticVar'; - } -} +require __DIR__ . '/../StaticVar.php'; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Static_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Static_.php index b2250a4..641f1b5 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Static_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Static_.php @@ -2,29 +2,29 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; +use ncc\ThirdParty\nikic\PhpParser\Node\StaticVar; use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; -class Static_ extends Stmt -{ +class Static_ extends Stmt { /** @var StaticVar[] Variable definitions */ - public $vars; + public array $vars; /** * Constructs a static variables list node. * - * @param StaticVar[] $vars Variable definitions - * @param array $attributes Additional attributes + * @param StaticVar[] $vars Variable definitions + * @param array $attributes Additional attributes */ public function __construct(array $vars, array $attributes = []) { $this->attributes = $attributes; $this->vars = $vars; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['vars']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_Static'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Switch_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Switch_.php index 614fd33..c8cf4a0 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Switch_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Switch_.php @@ -4,19 +4,18 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -class Switch_ extends Node\Stmt -{ +class Switch_ extends Node\Stmt { /** @var Node\Expr Condition */ - public $cond; + public Node\Expr $cond; /** @var Case_[] Case list */ - public $cases; + public array $cases; /** * Constructs a case node. * - * @param Node\Expr $cond Condition - * @param Case_[] $cases Case list - * @param array $attributes Additional attributes + * @param Node\Expr $cond Condition + * @param Case_[] $cases Case list + * @param array $attributes Additional attributes */ public function __construct(Node\Expr $cond, array $cases, array $attributes = []) { $this->attributes = $attributes; @@ -24,11 +23,11 @@ class Switch_ extends Node\Stmt $this->cases = $cases; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['cond', 'cases']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_Switch'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Throw_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Throw_.php deleted file mode 100644 index 6844645..0000000 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Throw_.php +++ /dev/null @@ -1,30 +0,0 @@ -attributes = $attributes; - $this->expr = $expr; - } - - public function getSubNodeNames() : array { - return ['expr']; - } - - public function getType() : string { - return 'Stmt_Throw'; - } -} diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/TraitUse.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/TraitUse.php index c24e895..6b06114 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/TraitUse.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/TraitUse.php @@ -4,19 +4,18 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -class TraitUse extends Node\Stmt -{ +class TraitUse extends Node\Stmt { /** @var Node\Name[] Traits */ - public $traits; + public array $traits; /** @var TraitUseAdaptation[] Adaptations */ - public $adaptations; + public array $adaptations; /** * Constructs a trait use node. * - * @param Node\Name[] $traits Traits + * @param Node\Name[] $traits Traits * @param TraitUseAdaptation[] $adaptations Adaptations - * @param array $attributes Additional attributes + * @param array $attributes Additional attributes */ public function __construct(array $traits, array $adaptations = [], array $attributes = []) { $this->attributes = $attributes; @@ -24,11 +23,11 @@ class TraitUse extends Node\Stmt $this->adaptations = $adaptations; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['traits', 'adaptations']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_TraitUse'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/TraitUseAdaptation.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/TraitUseAdaptation.php index 3d1e8c6..4b52604 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/TraitUseAdaptation.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/TraitUseAdaptation.php @@ -4,10 +4,9 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -abstract class TraitUseAdaptation extends Node\Stmt -{ +abstract class TraitUseAdaptation extends Node\Stmt { /** @var Node\Name|null Trait name */ - public $trait; + public ?Node\Name $trait; /** @var Node\Identifier Method name */ - public $method; + public Node\Identifier $method; } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php index b332a9d..ecfd502 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php @@ -4,23 +4,22 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation; use ncc\ThirdParty\nikic\PhpParser\Node; -class Alias extends Node\Stmt\TraitUseAdaptation -{ +class Alias extends Node\Stmt\TraitUseAdaptation { /** @var null|int New modifier */ - public $newModifier; + public ?int $newModifier; /** @var null|Node\Identifier New name */ - public $newName; + public ?Node\Identifier $newName; /** * Constructs a trait use precedence adaptation node. * - * @param null|Node\Name $trait Trait name - * @param string|Node\Identifier $method Method name - * @param null|int $newModifier New modifier - * @param null|string|Node\Identifier $newName New name - * @param array $attributes Additional attributes + * @param null|Node\Name $trait Trait name + * @param string|Node\Identifier $method Method name + * @param null|int $newModifier New modifier + * @param null|string|Node\Identifier $newName New name + * @param array $attributes Additional attributes */ - public function __construct($trait, $method, $newModifier, $newName, array $attributes = []) { + public function __construct(?Node\Name $trait, $method, ?int $newModifier, $newName, array $attributes = []) { $this->attributes = $attributes; $this->trait = $trait; $this->method = \is_string($method) ? new Node\Identifier($method) : $method; @@ -28,11 +27,11 @@ class Alias extends Node\Stmt\TraitUseAdaptation $this->newName = \is_string($newName) ? new Node\Identifier($newName) : $newName; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['trait', 'method', 'newModifier', 'newName']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_TraitUseAdaptation_Alias'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php index f32a0d0..4b035b9 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php @@ -4,18 +4,17 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation; use ncc\ThirdParty\nikic\PhpParser\Node; -class Precedence extends Node\Stmt\TraitUseAdaptation -{ +class Precedence extends Node\Stmt\TraitUseAdaptation { /** @var Node\Name[] Overwritten traits */ - public $insteadof; + public array $insteadof; /** * Constructs a trait use precedence adaptation node. * - * @param Node\Name $trait Trait name - * @param string|Node\Identifier $method Method name - * @param Node\Name[] $insteadof Overwritten traits - * @param array $attributes Additional attributes + * @param Node\Name $trait Trait name + * @param string|Node\Identifier $method Method name + * @param Node\Name[] $insteadof Overwritten traits + * @param array $attributes Additional attributes */ public function __construct(Node\Name $trait, $method, array $insteadof, array $attributes = []) { $this->attributes = $attributes; @@ -24,11 +23,11 @@ class Precedence extends Node\Stmt\TraitUseAdaptation $this->insteadof = $insteadof; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['trait', 'method', 'insteadof']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_TraitUseAdaptation_Precedence'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Trait_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Trait_.php index a28ce4b..1a0ad74 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Trait_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Trait_.php @@ -4,16 +4,18 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -class Trait_ extends ClassLike -{ +class Trait_ extends ClassLike { /** * Constructs a trait node. * * @param string|Node\Identifier $name Name - * @param array $subNodes Array of the following optional subnodes: - * 'stmts' => array(): Statements - * 'attrGroups' => array(): PHP attribute groups - * @param array $attributes Additional attributes + * @param array{ + * stmts?: Node\Stmt[], + * attrGroups?: Node\AttributeGroup[], + * } $subNodes Array of the following optional subnodes: + * 'stmts' => array(): Statements + * 'attrGroups' => array(): PHP attribute groups + * @param array $attributes Additional attributes */ public function __construct($name, array $subNodes = [], array $attributes = []) { $this->attributes = $attributes; @@ -22,11 +24,11 @@ class Trait_ extends ClassLike $this->attrGroups = $subNodes['attrGroups'] ?? []; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['attrGroups', 'name', 'stmts']; } - public function getType() : string { + public function getType(): string { return 'Stmt_Trait'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/TryCatch.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/TryCatch.php index ba7a2fa..b5843ac 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/TryCatch.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/TryCatch.php @@ -4,35 +4,34 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -class TryCatch extends Node\Stmt -{ +class TryCatch extends Node\Stmt { /** @var Node\Stmt[] Statements */ - public $stmts; + public array $stmts; /** @var Catch_[] Catches */ - public $catches; + public array $catches; /** @var null|Finally_ Optional finally node */ - public $finally; + public ?Finally_ $finally; /** * Constructs a try catch node. * - * @param Node\Stmt[] $stmts Statements - * @param Catch_[] $catches Catches - * @param null|Finally_ $finally Optional finally node - * @param array $attributes Additional attributes + * @param Node\Stmt[] $stmts Statements + * @param Catch_[] $catches Catches + * @param null|Finally_ $finally Optional finally node + * @param array $attributes Additional attributes */ - public function __construct(array $stmts, array $catches, Finally_ $finally = null, array $attributes = []) { + public function __construct(array $stmts, array $catches, ?Finally_ $finally = null, array $attributes = []) { $this->attributes = $attributes; $this->stmts = $stmts; $this->catches = $catches; $this->finally = $finally; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['stmts', 'catches', 'finally']; } - public function getType() : string { + public function getType(): string { return 'Stmt_TryCatch'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Unset_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Unset_.php index c0ca230..e887172 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Unset_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Unset_.php @@ -4,27 +4,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -class Unset_ extends Node\Stmt -{ +class Unset_ extends Node\Stmt { /** @var Node\Expr[] Variables to unset */ - public $vars; + public array $vars; /** * Constructs an unset node. * - * @param Node\Expr[] $vars Variables to unset - * @param array $attributes Additional attributes + * @param Node\Expr[] $vars Variables to unset + * @param array $attributes Additional attributes */ public function __construct(array $vars, array $attributes = []) { $this->attributes = $attributes; $this->vars = $vars; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['vars']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_Unset'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/UseUse.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/UseUse.php index 25fac1a..85830ed 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/UseUse.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/UseUse.php @@ -1,52 +1,3 @@ attributes = $attributes; - $this->type = $type; - $this->name = $name; - $this->alias = \is_string($alias) ? new Identifier($alias) : $alias; - } - - public function getSubNodeNames() : array { - return ['type', 'name', 'alias']; - } - - /** - * Get alias. If not explicitly given this is the last component of the used name. - * - * @return Identifier - */ - public function getAlias() : Identifier { - if (null !== $this->alias) { - return $this->alias; - } - - return new Identifier($this->name->getLast()); - } - - public function getType() : string { - return 'Stmt_UseUse'; - } -} +require __DIR__ . '/../UseItem.php'; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Use_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Use_.php index 341a18d..43ade7c 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Use_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/Use_.php @@ -3,33 +3,33 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; +use ncc\ThirdParty\nikic\PhpParser\Node\UseItem; -class Use_ extends Stmt -{ +class Use_ extends Stmt { /** * Unknown type. Both Stmt\Use_ / Stmt\GroupUse and Stmt\UseUse have a $type property, one of them will always be * TYPE_UNKNOWN while the other has one of the three other possible types. For normal use statements the type on the * Stmt\UseUse is unknown. It's only the other way around for mixed group use declarations. */ - const TYPE_UNKNOWN = 0; + public const TYPE_UNKNOWN = 0; /** Class or namespace import */ - const TYPE_NORMAL = 1; + public const TYPE_NORMAL = 1; /** Function import */ - const TYPE_FUNCTION = 2; + public const TYPE_FUNCTION = 2; /** Constant import */ - const TYPE_CONSTANT = 3; + public const TYPE_CONSTANT = 3; - /** @var int Type of alias */ - public $type; - /** @var UseUse[] Aliases */ - public $uses; + /** @var self::TYPE_* Type of alias */ + public int $type; + /** @var UseItem[] Aliases */ + public array $uses; /** * Constructs an alias (use) list node. * - * @param UseUse[] $uses Aliases - * @param int $type Type of alias - * @param array $attributes Additional attributes + * @param UseItem[] $uses Aliases + * @param Stmt\Use_::TYPE_* $type Type of alias + * @param array $attributes Additional attributes */ public function __construct(array $uses, int $type = self::TYPE_NORMAL, array $attributes = []) { $this->attributes = $attributes; @@ -37,11 +37,11 @@ class Use_ extends Stmt $this->uses = $uses; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['type', 'uses']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_Use'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/While_.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/While_.php index 70aa196..f4a7a48 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/While_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/Stmt/While_.php @@ -4,19 +4,18 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\Node; -class While_ extends Node\Stmt -{ +class While_ extends Node\Stmt { /** @var Node\Expr Condition */ - public $cond; + public Node\Expr $cond; /** @var Node\Stmt[] Statements */ - public $stmts; + public array $stmts; /** * Constructs a while node. * - * @param Node\Expr $cond Condition - * @param Node\Stmt[] $stmts Statements - * @param array $attributes Additional attributes + * @param Node\Expr $cond Condition + * @param Node\Stmt[] $stmts Statements + * @param array $attributes Additional attributes */ public function __construct(Node\Expr $cond, array $stmts = [], array $attributes = []) { $this->attributes = $attributes; @@ -24,11 +23,11 @@ class While_ extends Node\Stmt $this->stmts = $stmts; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['cond', 'stmts']; } - - public function getType() : string { + + public function getType(): string { return 'Stmt_While'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/UnionType.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/UnionType.php index aacfc0a..525b404 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/UnionType.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/UnionType.php @@ -2,27 +2,26 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node; -class UnionType extends ComplexType -{ +class UnionType extends ComplexType { /** @var (Identifier|Name|IntersectionType)[] Types */ - public $types; + public array $types; /** * Constructs a union type. * - * @param (Identifier|Name|IntersectionType)[] $types Types - * @param array $attributes Additional attributes + * @param (Identifier|Name|IntersectionType)[] $types Types + * @param array $attributes Additional attributes */ public function __construct(array $types, array $attributes = []) { $this->attributes = $attributes; $this->types = $types; } - public function getSubNodeNames() : array { + public function getSubNodeNames(): array { return ['types']; } - - public function getType() : string { + + public function getType(): string { return 'UnionType'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/UseItem.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/UseItem.php new file mode 100644 index 0000000..e3c52cd --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/UseItem.php @@ -0,0 +1,55 @@ + $attributes Additional attributes + */ + public function __construct(Node\Name $name, $alias = null, int $type = Use_::TYPE_UNKNOWN, array $attributes = []) { + $this->attributes = $attributes; + $this->type = $type; + $this->name = $name; + $this->alias = \is_string($alias) ? new Identifier($alias) : $alias; + } + + public function getSubNodeNames(): array { + return ['type', 'name', 'alias']; + } + + /** + * Get alias. If not explicitly given this is the last component of the used name. + */ + public function getAlias(): Identifier { + if (null !== $this->alias) { + return $this->alias; + } + + return new Identifier($this->name->getLast()); + } + + public function getType(): string { + return 'UseItem'; + } +} + +// @deprecated compatibility alias +class_alias(UseItem::class, Stmt\UseUse::class); diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/VarLikeIdentifier.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/VarLikeIdentifier.php index f895fa4..99a605d 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/VarLikeIdentifier.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/VarLikeIdentifier.php @@ -9,9 +9,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Node; * Examples: Names in property declarations are formatted as variables. Names in static property * lookups are also formatted as variables. */ -class VarLikeIdentifier extends Identifier -{ - public function getType() : string { +class VarLikeIdentifier extends Identifier { + public function getType(): string { return 'VarLikeIdentifier'; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Node/VariadicPlaceholder.php b/src/ncc/ThirdParty/nikic/PhpParser/Node/VariadicPlaceholder.php index 3248112..4e5b1c4 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Node/VariadicPlaceholder.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Node/VariadicPlaceholder.php @@ -11,7 +11,7 @@ class VariadicPlaceholder extends NodeAbstract { /** * Create a variadic argument placeholder (first-class callable syntax). * - * @param array $attributes Additional attributes + * @param array $attributes Additional attributes */ public function __construct(array $attributes = []) { $this->attributes = $attributes; @@ -24,4 +24,4 @@ class VariadicPlaceholder extends NodeAbstract { public function getSubNodeNames(): array { return []; } -} \ No newline at end of file +} diff --git a/src/ncc/ThirdParty/nikic/PhpParser/NodeAbstract.php b/src/ncc/ThirdParty/nikic/PhpParser/NodeAbstract.php index e76c38b..fa2ea2c 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/NodeAbstract.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/NodeAbstract.php @@ -2,14 +2,14 @@ namespace ncc\ThirdParty\nikic\PhpParser; -abstract class NodeAbstract implements Node, \JsonSerializable -{ - protected $attributes; +abstract class NodeAbstract implements Node, \JsonSerializable { + /** @var array Attributes */ + protected array $attributes; /** * Creates a Node. * - * @param array $attributes Array of attributes + * @param array $attributes Array of attributes */ public function __construct(array $attributes = []) { $this->attributes = $attributes; @@ -19,8 +19,9 @@ abstract class NodeAbstract implements Node, \JsonSerializable * Gets line the node started in (alias of getStartLine). * * @return int Start line (or -1 if not available) + * @phpstan-return -1|positive-int */ - public function getLine() : int { + public function getLine(): int { return $this->attributes['startLine'] ?? -1; } @@ -30,8 +31,9 @@ abstract class NodeAbstract implements Node, \JsonSerializable * Requires the 'startLine' attribute to be enabled in the lexer (enabled by default). * * @return int Start line (or -1 if not available) + * @phpstan-return -1|positive-int */ - public function getStartLine() : int { + public function getStartLine(): int { return $this->attributes['startLine'] ?? -1; } @@ -41,8 +43,9 @@ abstract class NodeAbstract implements Node, \JsonSerializable * Requires the 'endLine' attribute to be enabled in the lexer (enabled by default). * * @return int End line (or -1 if not available) + * @phpstan-return -1|positive-int */ - public function getEndLine() : int { + public function getEndLine(): int { return $this->attributes['endLine'] ?? -1; } @@ -55,7 +58,7 @@ abstract class NodeAbstract implements Node, \JsonSerializable * * @return int Token start position (or -1 if not available) */ - public function getStartTokenPos() : int { + public function getStartTokenPos(): int { return $this->attributes['startTokenPos'] ?? -1; } @@ -68,7 +71,7 @@ abstract class NodeAbstract implements Node, \JsonSerializable * * @return int Token end position (or -1 if not available) */ - public function getEndTokenPos() : int { + public function getEndTokenPos(): int { return $this->attributes['endTokenPos'] ?? -1; } @@ -79,7 +82,7 @@ abstract class NodeAbstract implements Node, \JsonSerializable * * @return int File start position (or -1 if not available) */ - public function getStartFilePos() : int { + public function getStartFilePos(): int { return $this->attributes['startFilePos'] ?? -1; } @@ -90,7 +93,7 @@ abstract class NodeAbstract implements Node, \JsonSerializable * * @return int File end position (or -1 if not available) */ - public function getEndFilePos() : int { + public function getEndFilePos(): int { return $this->attributes['endFilePos'] ?? -1; } @@ -101,7 +104,7 @@ abstract class NodeAbstract implements Node, \JsonSerializable * * @return Comment[] */ - public function getComments() : array { + public function getComments(): array { return $this->attributes['comments'] ?? []; } @@ -110,7 +113,7 @@ abstract class NodeAbstract implements Node, \JsonSerializable * * @return null|Comment\Doc Doc comment object or null */ - public function getDocComment() { + public function getDocComment(): ?Comment\Doc { $comments = $this->getComments(); for ($i = count($comments) - 1; $i >= 0; $i--) { $comment = $comments[$i]; @@ -129,7 +132,7 @@ abstract class NodeAbstract implements Node, \JsonSerializable * * @param Comment\Doc $docComment Doc comment to set */ - public function setDocComment(Comment\Doc $docComment) { + public function setDocComment(Comment\Doc $docComment): void { $comments = $this->getComments(); for ($i = count($comments) - 1; $i >= 0; $i--) { if ($comments[$i] instanceof Comment\Doc) { @@ -145,11 +148,11 @@ abstract class NodeAbstract implements Node, \JsonSerializable $this->setAttribute('comments', $comments); } - public function setAttribute(string $key, $value) { + public function setAttribute(string $key, $value): void { $this->attributes[$key] = $value; } - public function hasAttribute(string $key) : bool { + public function hasAttribute(string $key): bool { return array_key_exists($key, $this->attributes); } @@ -161,18 +164,18 @@ abstract class NodeAbstract implements Node, \JsonSerializable return $default; } - public function getAttributes() : array { + public function getAttributes(): array { return $this->attributes; } - public function setAttributes(array $attributes) { + public function setAttributes(array $attributes): void { $this->attributes = $attributes; } /** - * @return array + * @return array */ - public function jsonSerialize() : array { + public function jsonSerialize(): array { return ['nodeType' => $this->getType()] + get_object_vars($this); } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/NodeDumper.php b/src/ncc/ThirdParty/nikic/PhpParser/NodeDumper.php index 813ccd2..6876aac 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/NodeDumper.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/NodeDumper.php @@ -2,17 +2,33 @@ namespace ncc\ThirdParty\nikic\PhpParser; +use ncc\ThirdParty\nikic\PhpParser\Node\Expr\Array_; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\Include_; -use ncc\ThirdParty\nikic\PhpParser\Node\Stmt\Class_; +use ncc\ThirdParty\nikic\PhpParser\Node\Expr\List_; +use ncc\ThirdParty\nikic\PhpParser\Node\Scalar\Int_; +use ncc\ThirdParty\nikic\PhpParser\Node\Scalar\InterpolatedString; +use ncc\ThirdParty\nikic\PhpParser\Node\Scalar\String_; use ncc\ThirdParty\nikic\PhpParser\Node\Stmt\GroupUse; use ncc\ThirdParty\nikic\PhpParser\Node\Stmt\Use_; -use ncc\ThirdParty\nikic\PhpParser\Node\Stmt\UseUse; +use ncc\ThirdParty\nikic\PhpParser\Node\UseItem; -class NodeDumper -{ - private $dumpComments; - private $dumpPositions; - private $code; +class NodeDumper { + private bool $dumpComments; + private bool $dumpPositions; + private bool $dumpOtherAttributes; + private ?string $code; + private string $res; + private string $nl; + + private const IGNORE_ATTRIBUTES = [ + 'comments' => true, + 'startLine' => true, + 'endLine' => true, + 'startFilePos' => true, + 'endFilePos' => true, + 'startTokenPos' => true, + 'endTokenPos' => true, + ]; /** * Constructs a NodeDumper. @@ -21,150 +37,227 @@ class NodeDumper * * bool dumpComments: Whether comments should be dumped. * * bool dumpPositions: Whether line/offset information should be dumped. To dump offset * information, the code needs to be passed to dump(). + * * bool dumpOtherAttributes: Whether non-comment, non-position attributes should be dumped. * * @param array $options Options (see description) */ public function __construct(array $options = []) { $this->dumpComments = !empty($options['dumpComments']); $this->dumpPositions = !empty($options['dumpPositions']); + $this->dumpOtherAttributes = !empty($options['dumpOtherAttributes']); } /** * Dumps a node or array. * - * @param array|Node $node Node or array to dump + * @param array|Node $node Node or array to dump * @param string|null $code Code corresponding to dumped AST. This only needs to be passed if * the dumpPositions option is enabled and the dumping of node offsets * is desired. * * @return string Dumped value */ - public function dump($node, string $code = null) : string { + public function dump($node, ?string $code = null): string { $this->code = $code; - return $this->dumpRecursive($node); + $this->res = ''; + $this->nl = "\n"; + $this->dumpRecursive($node, false); + return $this->res; } - protected function dumpRecursive($node) { + /** @param mixed $node */ + protected function dumpRecursive($node, bool $indent = true): void { + if ($indent) { + $this->nl .= " "; + } if ($node instanceof Node) { - $r = $node->getType(); + $this->res .= $node->getType(); if ($this->dumpPositions && null !== $p = $this->dumpPosition($node)) { - $r .= $p; + $this->res .= $p; } - $r .= '('; + $this->res .= '('; foreach ($node->getSubNodeNames() as $key) { - $r .= "\n " . $key . ': '; + $this->res .= "$this->nl " . $key . ': '; $value = $node->$key; - if (null === $value) { - $r .= 'null'; - } elseif (false === $value) { - $r .= 'false'; - } elseif (true === $value) { - $r .= 'true'; - } elseif (is_scalar($value)) { + if (\is_int($value)) { if ('flags' === $key || 'newModifier' === $key) { - $r .= $this->dumpFlags($value); - } elseif ('type' === $key && $node instanceof Include_) { - $r .= $this->dumpIncludeType($value); - } elseif ('type' === $key - && ($node instanceof Use_ || $node instanceof UseUse || $node instanceof GroupUse)) { - $r .= $this->dumpUseType($value); - } else { - $r .= $value; + $this->res .= $this->dumpFlags($value); + continue; + } + if ('type' === $key && $node instanceof Include_) { + $this->res .= $this->dumpIncludeType($value); + continue; + } + if ('type' === $key + && ($node instanceof Use_ || $node instanceof UseItem || $node instanceof GroupUse)) { + $this->res .= $this->dumpUseType($value); + continue; } - } else { - $r .= str_replace("\n", "\n ", $this->dumpRecursive($value)); } + $this->dumpRecursive($value); } if ($this->dumpComments && $comments = $node->getComments()) { - $r .= "\n comments: " . str_replace("\n", "\n ", $this->dumpRecursive($comments)); + $this->res .= "$this->nl comments: "; + $this->dumpRecursive($comments); } - } elseif (is_array($node)) { - $r = 'array('; - foreach ($node as $key => $value) { - $r .= "\n " . $key . ': '; + if ($this->dumpOtherAttributes) { + foreach ($node->getAttributes() as $key => $value) { + if (isset(self::IGNORE_ATTRIBUTES[$key])) { + continue; + } - if (null === $value) { - $r .= 'null'; - } elseif (false === $value) { - $r .= 'false'; - } elseif (true === $value) { - $r .= 'true'; - } elseif (is_scalar($value)) { - $r .= $value; - } else { - $r .= str_replace("\n", "\n ", $this->dumpRecursive($value)); + $this->res .= "$this->nl $key: "; + if (\is_int($value)) { + if ('kind' === $key) { + if ($node instanceof Int_) { + $this->res .= $this->dumpIntKind($value); + continue; + } + if ($node instanceof String_ || $node instanceof InterpolatedString) { + $this->res .= $this->dumpStringKind($value); + continue; + } + if ($node instanceof Array_) { + $this->res .= $this->dumpArrayKind($value); + continue; + } + if ($node instanceof List_) { + $this->res .= $this->dumpListKind($value); + continue; + } + } + } + $this->dumpRecursive($value); } } + $this->res .= "$this->nl)"; + } elseif (\is_array($node)) { + $this->res .= 'array('; + foreach ($node as $key => $value) { + $this->res .= "$this->nl " . $key . ': '; + $this->dumpRecursive($value); + } + $this->res .= "$this->nl)"; } elseif ($node instanceof Comment) { - return $node->getReformattedText(); + $this->res .= \str_replace("\n", $this->nl, $node->getReformattedText()); + } elseif (\is_string($node)) { + $this->res .= \str_replace("\n", $this->nl, (string)$node); + } elseif (\is_int($node) || \is_float($node)) { + $this->res .= $node; + } elseif (null === $node) { + $this->res .= 'null'; + } elseif (false === $node) { + $this->res .= 'false'; + } elseif (true === $node) { + $this->res .= 'true'; } else { throw new \InvalidArgumentException('Can only dump nodes and arrays.'); } - - return $r . "\n)"; + if ($indent) { + $this->nl = \substr($this->nl, 0, -4); + } } - protected function dumpFlags($flags) { + protected function dumpFlags(int $flags): string { $strs = []; - if ($flags & Class_::MODIFIER_PUBLIC) { - $strs[] = 'MODIFIER_PUBLIC'; + if ($flags & Modifiers::PUBLIC) { + $strs[] = 'PUBLIC'; } - if ($flags & Class_::MODIFIER_PROTECTED) { - $strs[] = 'MODIFIER_PROTECTED'; + if ($flags & Modifiers::PROTECTED) { + $strs[] = 'PROTECTED'; } - if ($flags & Class_::MODIFIER_PRIVATE) { - $strs[] = 'MODIFIER_PRIVATE'; + if ($flags & Modifiers::PRIVATE) { + $strs[] = 'PRIVATE'; } - if ($flags & Class_::MODIFIER_ABSTRACT) { - $strs[] = 'MODIFIER_ABSTRACT'; + if ($flags & Modifiers::ABSTRACT) { + $strs[] = 'ABSTRACT'; } - if ($flags & Class_::MODIFIER_STATIC) { - $strs[] = 'MODIFIER_STATIC'; + if ($flags & Modifiers::STATIC) { + $strs[] = 'STATIC'; } - if ($flags & Class_::MODIFIER_FINAL) { - $strs[] = 'MODIFIER_FINAL'; + if ($flags & Modifiers::FINAL) { + $strs[] = 'FINAL'; } - if ($flags & Class_::MODIFIER_READONLY) { - $strs[] = 'MODIFIER_READONLY'; + if ($flags & Modifiers::READONLY) { + $strs[] = 'READONLY'; + } + if ($flags & Modifiers::PUBLIC_SET) { + $strs[] = 'PUBLIC_SET'; + } + if ($flags & Modifiers::PROTECTED_SET) { + $strs[] = 'PROTECTED_SET'; + } + if ($flags & Modifiers::PRIVATE_SET) { + $strs[] = 'PRIVATE_SET'; } if ($strs) { return implode(' | ', $strs) . ' (' . $flags . ')'; } else { - return $flags; + return (string) $flags; } } - protected function dumpIncludeType($type) { - $map = [ + /** @param array $map */ + private function dumpEnum(int $value, array $map): string { + if (!isset($map[$value])) { + return (string) $value; + } + return $map[$value] . ' (' . $value . ')'; + } + + private function dumpIncludeType(int $type): string { + return $this->dumpEnum($type, [ Include_::TYPE_INCLUDE => 'TYPE_INCLUDE', Include_::TYPE_INCLUDE_ONCE => 'TYPE_INCLUDE_ONCE', Include_::TYPE_REQUIRE => 'TYPE_REQUIRE', Include_::TYPE_REQUIRE_ONCE => 'TYPE_REQUIRE_ONCE', - ]; - - if (!isset($map[$type])) { - return $type; - } - return $map[$type] . ' (' . $type . ')'; + ]); } - protected function dumpUseType($type) { - $map = [ + private function dumpUseType(int $type): string { + return $this->dumpEnum($type, [ Use_::TYPE_UNKNOWN => 'TYPE_UNKNOWN', Use_::TYPE_NORMAL => 'TYPE_NORMAL', Use_::TYPE_FUNCTION => 'TYPE_FUNCTION', Use_::TYPE_CONSTANT => 'TYPE_CONSTANT', - ]; + ]); + } - if (!isset($map[$type])) { - return $type; - } - return $map[$type] . ' (' . $type . ')'; + private function dumpIntKind(int $kind): string { + return $this->dumpEnum($kind, [ + Int_::KIND_BIN => 'KIND_BIN', + Int_::KIND_OCT => 'KIND_OCT', + Int_::KIND_DEC => 'KIND_DEC', + Int_::KIND_HEX => 'KIND_HEX', + ]); + } + + private function dumpStringKind(int $kind): string { + return $this->dumpEnum($kind, [ + String_::KIND_SINGLE_QUOTED => 'KIND_SINGLE_QUOTED', + String_::KIND_DOUBLE_QUOTED => 'KIND_DOUBLE_QUOTED', + String_::KIND_HEREDOC => 'KIND_HEREDOC', + String_::KIND_NOWDOC => 'KIND_NOWDOC', + ]); + } + + private function dumpArrayKind(int $kind): string { + return $this->dumpEnum($kind, [ + Array_::KIND_LONG => 'KIND_LONG', + Array_::KIND_SHORT => 'KIND_SHORT', + ]); + } + + private function dumpListKind(int $kind): string { + return $this->dumpEnum($kind, [ + List_::KIND_LIST => 'KIND_LIST', + List_::KIND_ARRAY => 'KIND_ARRAY', + ]); } /** @@ -174,7 +267,7 @@ class NodeDumper * * @return string|null Dump of position, or null if position information not available */ - protected function dumpPosition(Node $node) { + protected function dumpPosition(Node $node): ?string { if (!$node->hasAttribute('startLine') || !$node->hasAttribute('endLine')) { return null; } @@ -191,7 +284,7 @@ class NodeDumper } // Copied from Error class - private function toColumn($code, $pos) { + private function toColumn(string $code, int $pos): int { if ($pos > strlen($code)) { throw new \RuntimeException('Invalid position information'); } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/NodeFinder.php b/src/ncc/ThirdParty/nikic/PhpParser/NodeFinder.php index 935212c..b6f8434 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/NodeFinder.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/NodeFinder.php @@ -5,25 +5,27 @@ namespace ncc\ThirdParty\nikic\PhpParser; use ncc\ThirdParty\nikic\PhpParser\NodeVisitor\FindingVisitor; use ncc\ThirdParty\nikic\PhpParser\NodeVisitor\FirstFindingVisitor; -class NodeFinder -{ +class NodeFinder { /** * Find all nodes satisfying a filter callback. * - * @param Node|Node[] $nodes Single node or array of nodes to search in - * @param callable $filter Filter callback: function(Node $node) : bool + * @param Node|Node[] $nodes Single node or array of nodes to search in + * @param callable $filter Filter callback: function(Node $node) : bool * * @return Node[] Found nodes satisfying the filter callback */ - public function find($nodes, callable $filter) : array { + public function find($nodes, callable $filter): array { + if ($nodes === []) { + return []; + } + if (!is_array($nodes)) { $nodes = [$nodes]; } $visitor = new FindingVisitor($filter); - $traverser = new NodeTraverser; - $traverser->addVisitor($visitor); + $traverser = new NodeTraverser($visitor); $traverser->traverse($nodes); return $visitor->getFoundNodes(); @@ -31,13 +33,15 @@ class NodeFinder /** * Find all nodes that are instances of a certain class. + + * @template TNode as Node * * @param Node|Node[] $nodes Single node or array of nodes to search in - * @param string $class Class name + * @param class-string $class Class name * - * @return Node[] Found nodes (all instances of $class) + * @return TNode[] Found nodes (all instances of $class) */ - public function findInstanceOf($nodes, string $class) : array { + public function findInstanceOf($nodes, string $class): array { return $this->find($nodes, function ($node) use ($class) { return $node instanceof $class; }); @@ -46,20 +50,23 @@ class NodeFinder /** * Find first node satisfying a filter callback. * - * @param Node|Node[] $nodes Single node or array of nodes to search in - * @param callable $filter Filter callback: function(Node $node) : bool + * @param Node|Node[] $nodes Single node or array of nodes to search in + * @param callable $filter Filter callback: function(Node $node) : bool * * @return null|Node Found node (or null if none found) */ - public function findFirst($nodes, callable $filter) { + public function findFirst($nodes, callable $filter): ?Node { + if ($nodes === []) { + return null; + } + if (!is_array($nodes)) { $nodes = [$nodes]; } $visitor = new FirstFindingVisitor($filter); - $traverser = new NodeTraverser; - $traverser->addVisitor($visitor); + $traverser = new NodeTraverser($visitor); $traverser->traverse($nodes); return $visitor->getFoundNode(); @@ -68,12 +75,14 @@ class NodeFinder /** * Find first node that is an instance of a certain class. * - * @param Node|Node[] $nodes Single node or array of nodes to search in - * @param string $class Class name + * @template TNode as Node * - * @return null|Node Found node, which is an instance of $class (or null if none found) + * @param Node|Node[] $nodes Single node or array of nodes to search in + * @param class-string $class Class name + * + * @return null|TNode Found node, which is an instance of $class (or null if none found) */ - public function findFirstInstanceOf($nodes, string $class) { + public function findFirstInstanceOf($nodes, string $class): ?Node { return $this->findFirst($nodes, function ($node) use ($class) { return $node instanceof $class; }); diff --git a/src/ncc/ThirdParty/nikic/PhpParser/NodeTraverser.php b/src/ncc/ThirdParty/nikic/PhpParser/NodeTraverser.php index c7045e7..3fc2c19 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/NodeTraverser.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/NodeTraverser.php @@ -2,51 +2,40 @@ namespace ncc\ThirdParty\nikic\PhpParser; -class NodeTraverser implements NodeTraverserInterface -{ +class NodeTraverser implements NodeTraverserInterface { /** - * If NodeVisitor::enterNode() returns DONT_TRAVERSE_CHILDREN, child nodes - * of the current node will not be traversed for any visitors. - * - * For subsequent visitors enterNode() will still be called on the current - * node and leaveNode() will also be invoked for the current node. + * @deprecated Use NodeVisitor::DONT_TRAVERSE_CHILDREN instead. */ - const DONT_TRAVERSE_CHILDREN = 1; + public const DONT_TRAVERSE_CHILDREN = NodeVisitor::DONT_TRAVERSE_CHILDREN; /** - * If NodeVisitor::enterNode() or NodeVisitor::leaveNode() returns - * STOP_TRAVERSAL, traversal is aborted. - * - * The afterTraverse() method will still be invoked. + * @deprecated Use NodeVisitor::STOP_TRAVERSAL instead. */ - const STOP_TRAVERSAL = 2; + public const STOP_TRAVERSAL = NodeVisitor::STOP_TRAVERSAL; /** - * If NodeVisitor::leaveNode() returns REMOVE_NODE for a node that occurs - * in an array, it will be removed from the array. - * - * For subsequent visitors leaveNode() will still be invoked for the - * removed node. + * @deprecated Use NodeVisitor::REMOVE_NODE instead. */ - const REMOVE_NODE = 3; + public const REMOVE_NODE = NodeVisitor::REMOVE_NODE; /** - * If NodeVisitor::enterNode() returns DONT_TRAVERSE_CURRENT_AND_CHILDREN, child nodes - * of the current node will not be traversed for any visitors. - * - * For subsequent visitors enterNode() will not be called as well. - * leaveNode() will be invoked for visitors that has enterNode() method invoked. + * @deprecated Use NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN instead. */ - const DONT_TRAVERSE_CURRENT_AND_CHILDREN = 4; + public const DONT_TRAVERSE_CURRENT_AND_CHILDREN = NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN; - /** @var NodeVisitor[] Visitors */ - protected $visitors = []; + /** @var list Visitors */ + protected array $visitors = []; /** @var bool Whether traversal should be stopped */ - protected $stopTraversal; + protected bool $stopTraversal; - public function __construct() { - // for BC + /** + * Create a traverser with the given visitors. + * + * @param NodeVisitor ...$visitors Node visitors + */ + public function __construct(NodeVisitor ...$visitors) { + $this->visitors = $visitors; } /** @@ -54,21 +43,17 @@ class NodeTraverser implements NodeTraverserInterface * * @param NodeVisitor $visitor Visitor to add */ - public function addVisitor(NodeVisitor $visitor) { + public function addVisitor(NodeVisitor $visitor): void { $this->visitors[] = $visitor; } /** * Removes an added visitor. - * - * @param NodeVisitor $visitor */ - public function removeVisitor(NodeVisitor $visitor) { - foreach ($this->visitors as $index => $storedVisitor) { - if ($storedVisitor === $visitor) { - unset($this->visitors[$index]); - break; - } + public function removeVisitor(NodeVisitor $visitor): void { + $index = array_search($visitor, $this->visitors); + if ($index !== false) { + array_splice($this->visitors, $index, 1, []); } } @@ -79,7 +64,7 @@ class NodeTraverser implements NodeTraverserInterface * * @return Node[] Traversed array of nodes */ - public function traverse(array $nodes) : array { + public function traverse(array $nodes): array { $this->stopTraversal = false; foreach ($this->visitors as $visitor) { @@ -90,7 +75,8 @@ class NodeTraverser implements NodeTraverserInterface $nodes = $this->traverseArray($nodes); - foreach ($this->visitors as $visitor) { + for ($i = \count($this->visitors) - 1; $i >= 0; --$i) { + $visitor = $this->visitors[$i]; if (null !== $return = $visitor->afterTraverse($nodes)) { $nodes = $return; } @@ -103,37 +89,37 @@ class NodeTraverser implements NodeTraverserInterface * Recursively traverse a node. * * @param Node $node Node to traverse. - * - * @return Node Result of traversal (may be original node or new one) */ - protected function traverseNode(Node $node) : Node { + protected function traverseNode(Node $node): void { foreach ($node->getSubNodeNames() as $name) { - $subNode =& $node->$name; + $subNode = $node->$name; if (\is_array($subNode)) { - $subNode = $this->traverseArray($subNode); + $node->$name = $this->traverseArray($subNode); if ($this->stopTraversal) { break; } } elseif ($subNode instanceof Node) { $traverseChildren = true; - $breakVisitorIndex = null; + $visitorIndex = -1; foreach ($this->visitors as $visitorIndex => $visitor) { $return = $visitor->enterNode($subNode); if (null !== $return) { if ($return instanceof Node) { $this->ensureReplacementReasonable($subNode, $return); - $subNode = $return; - } elseif (self::DONT_TRAVERSE_CHILDREN === $return) { + $subNode = $node->$name = $return; + } elseif (NodeVisitor::DONT_TRAVERSE_CHILDREN === $return) { $traverseChildren = false; - } elseif (self::DONT_TRAVERSE_CURRENT_AND_CHILDREN === $return) { + } elseif (NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN === $return) { $traverseChildren = false; - $breakVisitorIndex = $visitorIndex; break; - } elseif (self::STOP_TRAVERSAL === $return) { + } elseif (NodeVisitor::STOP_TRAVERSAL === $return) { $this->stopTraversal = true; break 2; + } elseif (NodeVisitor::REPLACE_WITH_NULL === $return) { + $node->$name = null; + continue 2; } else { throw new \LogicException( 'enterNode() returned invalid value of type ' . gettype($return) @@ -143,22 +129,26 @@ class NodeTraverser implements NodeTraverserInterface } if ($traverseChildren) { - $subNode = $this->traverseNode($subNode); + $this->traverseNode($subNode); if ($this->stopTraversal) { break; } } - foreach ($this->visitors as $visitorIndex => $visitor) { + for (; $visitorIndex >= 0; --$visitorIndex) { + $visitor = $this->visitors[$visitorIndex]; $return = $visitor->leaveNode($subNode); if (null !== $return) { if ($return instanceof Node) { $this->ensureReplacementReasonable($subNode, $return); - $subNode = $return; - } elseif (self::STOP_TRAVERSAL === $return) { + $subNode = $node->$name = $return; + } elseif (NodeVisitor::STOP_TRAVERSAL === $return) { $this->stopTraversal = true; break 2; + } elseif (NodeVisitor::REPLACE_WITH_NULL === $return) { + $node->$name = null; + break; } elseif (\is_array($return)) { throw new \LogicException( 'leaveNode() may only return an array ' . @@ -170,15 +160,9 @@ class NodeTraverser implements NodeTraverserInterface ); } } - - if ($breakVisitorIndex === $visitorIndex) { - break; - } } } } - - return $node; } /** @@ -188,29 +172,37 @@ class NodeTraverser implements NodeTraverserInterface * * @return array Result of traversal (may be original array or changed one) */ - protected function traverseArray(array $nodes) : array { + protected function traverseArray(array $nodes): array { $doNodes = []; - foreach ($nodes as $i => &$node) { + foreach ($nodes as $i => $node) { if ($node instanceof Node) { $traverseChildren = true; - $breakVisitorIndex = null; + $visitorIndex = -1; foreach ($this->visitors as $visitorIndex => $visitor) { $return = $visitor->enterNode($node); if (null !== $return) { if ($return instanceof Node) { $this->ensureReplacementReasonable($node, $return); - $node = $return; - } elseif (self::DONT_TRAVERSE_CHILDREN === $return) { + $nodes[$i] = $node = $return; + } elseif (\is_array($return)) { + $doNodes[] = [$i, $return]; + continue 2; + } elseif (NodeVisitor::REMOVE_NODE === $return) { + $doNodes[] = [$i, []]; + continue 2; + } elseif (NodeVisitor::DONT_TRAVERSE_CHILDREN === $return) { $traverseChildren = false; - } elseif (self::DONT_TRAVERSE_CURRENT_AND_CHILDREN === $return) { + } elseif (NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN === $return) { $traverseChildren = false; - $breakVisitorIndex = $visitorIndex; break; - } elseif (self::STOP_TRAVERSAL === $return) { + } elseif (NodeVisitor::STOP_TRAVERSAL === $return) { $this->stopTraversal = true; break 2; + } elseif (NodeVisitor::REPLACE_WITH_NULL === $return) { + throw new \LogicException( + 'REPLACE_WITH_NULL can not be used if the parent structure is an array'); } else { throw new \LogicException( 'enterNode() returned invalid value of type ' . gettype($return) @@ -220,43 +212,38 @@ class NodeTraverser implements NodeTraverserInterface } if ($traverseChildren) { - $node = $this->traverseNode($node); + $this->traverseNode($node); if ($this->stopTraversal) { break; } } - foreach ($this->visitors as $visitorIndex => $visitor) { + for (; $visitorIndex >= 0; --$visitorIndex) { + $visitor = $this->visitors[$visitorIndex]; $return = $visitor->leaveNode($node); if (null !== $return) { if ($return instanceof Node) { $this->ensureReplacementReasonable($node, $return); - $node = $return; + $nodes[$i] = $node = $return; } elseif (\is_array($return)) { $doNodes[] = [$i, $return]; break; - } elseif (self::REMOVE_NODE === $return) { + } elseif (NodeVisitor::REMOVE_NODE === $return) { $doNodes[] = [$i, []]; break; - } elseif (self::STOP_TRAVERSAL === $return) { + } elseif (NodeVisitor::STOP_TRAVERSAL === $return) { $this->stopTraversal = true; break 2; - } elseif (false === $return) { + } elseif (NodeVisitor::REPLACE_WITH_NULL === $return) { throw new \LogicException( - 'bool(false) return from leaveNode() no longer supported. ' . - 'Return NodeTraverser::REMOVE_NODE instead' - ); + 'REPLACE_WITH_NULL can not be used if the parent structure is an array'); } else { throw new \LogicException( 'leaveNode() returned invalid value of type ' . gettype($return) ); } } - - if ($breakVisitorIndex === $visitorIndex) { - break; - } } } elseif (\is_array($node)) { throw new \LogicException('Invalid node structure: Contains nested arrays'); @@ -272,8 +259,8 @@ class NodeTraverser implements NodeTraverserInterface return $nodes; } - private function ensureReplacementReasonable($old, $new) { - if ($old instanceof Node\Stmt && $new instanceof Node\Expr) { + private function ensureReplacementReasonable(Node $old, Node $new): void { + if ($old instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt && $new instanceof ncc\ThirdParty\nikic\PhpParser\Node\Expr) { throw new \LogicException( "Trying to replace statement ({$old->getType()}) " . "with expression ({$new->getType()}). Are you missing a " . @@ -281,7 +268,7 @@ class NodeTraverser implements NodeTraverserInterface ); } - if ($old instanceof Node\Expr && $new instanceof Node\Stmt) { + if ($old instanceof ncc\ThirdParty\nikic\PhpParser\Node\Expr && $new instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt) { throw new \LogicException( "Trying to replace expression ({$old->getType()}) " . "with statement ({$new->getType()})" diff --git a/src/ncc/ThirdParty/nikic/PhpParser/NodeTraverserInterface.php b/src/ncc/ThirdParty/nikic/PhpParser/NodeTraverserInterface.php index 9cf5b7e..ef4634a 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/NodeTraverserInterface.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/NodeTraverserInterface.php @@ -2,21 +2,18 @@ namespace ncc\ThirdParty\nikic\PhpParser; -interface NodeTraverserInterface -{ +interface NodeTraverserInterface { /** * Adds a visitor. * * @param NodeVisitor $visitor Visitor to add */ - public function addVisitor(NodeVisitor $visitor); + public function addVisitor(NodeVisitor $visitor): void; /** * Removes an added visitor. - * - * @param NodeVisitor $visitor */ - public function removeVisitor(NodeVisitor $visitor); + public function removeVisitor(NodeVisitor $visitor): void; /** * Traverses an array of nodes using the registered visitors. @@ -25,5 +22,5 @@ interface NodeTraverserInterface * * @return Node[] Traversed array of nodes */ - public function traverse(array $nodes) : array; + public function traverse(array $nodes): array; } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor.php b/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor.php index ec5f450..338b495 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor.php @@ -2,8 +2,49 @@ namespace ncc\ThirdParty\nikic\PhpParser; -interface NodeVisitor -{ +interface NodeVisitor { + /** + * If NodeVisitor::enterNode() returns DONT_TRAVERSE_CHILDREN, child nodes + * of the current node will not be traversed for any visitors. + * + * For subsequent visitors enterNode() will still be called on the current + * node and leaveNode() will also be invoked for the current node. + */ + public const DONT_TRAVERSE_CHILDREN = 1; + + /** + * If NodeVisitor::enterNode() or NodeVisitor::leaveNode() returns + * STOP_TRAVERSAL, traversal is aborted. + * + * The afterTraverse() method will still be invoked. + */ + public const STOP_TRAVERSAL = 2; + + /** + * If NodeVisitor::leaveNode() returns REMOVE_NODE for a node that occurs + * in an array, it will be removed from the array. + * + * For subsequent visitors leaveNode() will still be invoked for the + * removed node. + */ + public const REMOVE_NODE = 3; + + /** + * If NodeVisitor::enterNode() returns DONT_TRAVERSE_CURRENT_AND_CHILDREN, child nodes + * of the current node will not be traversed for any visitors. + * + * For subsequent visitors enterNode() will not be called as well. + * leaveNode() will be invoked for visitors that has enterNode() method invoked. + */ + public const DONT_TRAVERSE_CURRENT_AND_CHILDREN = 4; + + /** + * If NodeVisitor::enterNode() or NodeVisitor::leaveNode() returns REPLACE_WITH_NULL, + * the node will be replaced with null. This is not a legal return value if the node is part + * of an array, rather than another node. + */ + public const REPLACE_WITH_NULL = 5; + /** * Called once before traversal. * @@ -23,16 +64,25 @@ interface NodeVisitor * Return value semantics: * * null * => $node stays as-is - * * NodeTraverser::DONT_TRAVERSE_CHILDREN + * * array (of Nodes) + * => The return value is merged into the parent array (at the position of the $node) + * * NodeVisitor::REMOVE_NODE + * => $node is removed from the parent array + * * NodeVisitor::REPLACE_WITH_NULL + * => $node is replaced with null + * * NodeVisitor::DONT_TRAVERSE_CHILDREN * => Children of $node are not traversed. $node stays as-is - * * NodeTraverser::STOP_TRAVERSAL + * * NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN + * => Further visitors for the current node are skipped, and its children are not + * traversed. $node stays as-is. + * * NodeVisitor::STOP_TRAVERSAL * => Traversal is aborted. $node stays as-is * * otherwise * => $node is set to the return value * * @param Node $node Node * - * @return null|int|Node Replacement node (or special return value) + * @return null|int|Node|Node[] Replacement node (or special return value) */ public function enterNode(Node $node); @@ -42,9 +92,11 @@ interface NodeVisitor * Return value semantics: * * null * => $node stays as-is - * * NodeTraverser::REMOVE_NODE + * * NodeVisitor::REMOVE_NODE * => $node is removed from the parent array - * * NodeTraverser::STOP_TRAVERSAL + * * NodeVisitor::REPLACE_WITH_NULL + * => $node is replaced with null + * * NodeVisitor::STOP_TRAVERSAL * => Traversal is aborted. $node stays as-is * * array (of Nodes) * => The return value is merged into the parent array (at the position of the $node) diff --git a/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/CloningVisitor.php b/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/CloningVisitor.php index 52d21fc..df7807f 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/CloningVisitor.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/CloningVisitor.php @@ -10,8 +10,7 @@ use ncc\ThirdParty\nikic\PhpParser\NodeVisitorAbstract; * * This visitor is required to perform format-preserving pretty prints. */ -class CloningVisitor extends NodeVisitorAbstract -{ +class CloningVisitor extends NodeVisitorAbstract { public function enterNode(Node $origNode) { $node = clone $origNode; $node->setAttribute('origNode', $origNode); diff --git a/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/CommentAnnotatingVisitor.php b/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/CommentAnnotatingVisitor.php new file mode 100644 index 0000000..888913a --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/CommentAnnotatingVisitor.php @@ -0,0 +1,82 @@ + Token positions of comments */ + private array $commentPositions = []; + + /** + * Create a comment annotation visitor. + * + * @param Token[] $tokens Token array + */ + public function __construct(array $tokens) { + $this->tokens = $tokens; + + // Collect positions of comments. We use this to avoid traversing parts of the AST where + // there are no comments. + foreach ($tokens as $i => $token) { + if ($token->id === \T_COMMENT || $token->id === \T_DOC_COMMENT) { + $this->commentPositions[] = $i; + } + } + } + + public function enterNode(Node $node) { + $nextCommentPos = current($this->commentPositions); + if ($nextCommentPos === false) { + // No more comments. + return self::STOP_TRAVERSAL; + } + + $oldPos = $this->pos; + $this->pos = $pos = $node->getStartTokenPos(); + if ($nextCommentPos > $oldPos && $nextCommentPos < $pos) { + $comments = []; + while (--$pos >= $oldPos) { + $token = $this->tokens[$pos]; + if ($token->id === \T_DOC_COMMENT) { + $comments[] = new Comment\Doc( + $token->text, $token->line, $token->pos, $pos, + $token->getEndLine(), $token->getEndPos() - 1, $pos); + continue; + } + if ($token->id === \T_COMMENT) { + $comments[] = new Comment( + $token->text, $token->line, $token->pos, $pos, + $token->getEndLine(), $token->getEndPos() - 1, $pos); + continue; + } + if ($token->id !== \T_WHITESPACE) { + break; + } + } + if (!empty($comments)) { + $node->setAttribute('comments', array_reverse($comments)); + } + + do { + $nextCommentPos = next($this->commentPositions); + } while ($nextCommentPos !== false && $nextCommentPos < $this->pos); + } + + $endPos = $node->getEndTokenPos(); + if ($nextCommentPos > $endPos) { + // Skip children if there are no comments located inside this node. + $this->pos = $endPos; + return self::DONT_TRAVERSE_CHILDREN; + } + + return null; + } +} diff --git a/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/FindingVisitor.php b/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/FindingVisitor.php index 2d2d1cd..d18a5a1 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/FindingVisitor.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/FindingVisitor.php @@ -9,12 +9,11 @@ use ncc\ThirdParty\nikic\PhpParser\NodeVisitorAbstract; * This visitor can be used to find and collect all nodes satisfying some criterion determined by * a filter callback. */ -class FindingVisitor extends NodeVisitorAbstract -{ +class FindingVisitor extends NodeVisitorAbstract { /** @var callable Filter callback */ protected $filterCallback; /** @var Node[] Found nodes */ - protected $foundNodes; + protected array $foundNodes; public function __construct(callable $filterCallback) { $this->filterCallback = $filterCallback; @@ -27,11 +26,11 @@ class FindingVisitor extends NodeVisitorAbstract * * @return Node[] Found nodes */ - public function getFoundNodes() : array { + public function getFoundNodes(): array { return $this->foundNodes; } - public function beforeTraverse(array $nodes) { + public function beforeTraverse(array $nodes): ?array { $this->foundNodes = []; return null; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/FirstFindingVisitor.php b/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/FirstFindingVisitor.php index 7fef36b..247a1f6 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/FirstFindingVisitor.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/FirstFindingVisitor.php @@ -3,19 +3,18 @@ namespace ncc\ThirdParty\nikic\PhpParser\NodeVisitor; use ncc\ThirdParty\nikic\PhpParser\Node; -use ncc\ThirdParty\nikic\PhpParser\NodeTraverser; +use ncc\ThirdParty\nikic\PhpParser\NodeVisitor; use ncc\ThirdParty\nikic\PhpParser\NodeVisitorAbstract; /** * This visitor can be used to find the first node satisfying some criterion determined by * a filter callback. */ -class FirstFindingVisitor extends NodeVisitorAbstract -{ +class FirstFindingVisitor extends NodeVisitorAbstract { /** @var callable Filter callback */ protected $filterCallback; /** @var null|Node Found node */ - protected $foundNode; + protected ?Node $foundNode; public function __construct(callable $filterCallback) { $this->filterCallback = $filterCallback; @@ -28,11 +27,11 @@ class FirstFindingVisitor extends NodeVisitorAbstract * * @return null|Node Found node (or null if not found) */ - public function getFoundNode() { + public function getFoundNode(): ?Node { return $this->foundNode; } - public function beforeTraverse(array $nodes) { + public function beforeTraverse(array $nodes): ?array { $this->foundNode = null; return null; @@ -42,7 +41,7 @@ class FirstFindingVisitor extends NodeVisitorAbstract $filterCallback = $this->filterCallback; if ($filterCallback($node)) { $this->foundNode = $node; - return NodeTraverser::STOP_TRAVERSAL; + return NodeVisitor::STOP_TRAVERSAL; } return null; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/NameResolver.php b/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/NameResolver.php index 20b9455..55f0837 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/NameResolver.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/NameResolver.php @@ -11,16 +11,15 @@ use ncc\ThirdParty\nikic\PhpParser\Node\Name\FullyQualified; use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; use ncc\ThirdParty\nikic\PhpParser\NodeVisitorAbstract; -class NameResolver extends NodeVisitorAbstract -{ +class NameResolver extends NodeVisitorAbstract { /** @var NameContext Naming context */ - protected $nameContext; + protected NameContext $nameContext; /** @var bool Whether to preserve original names */ - protected $preserveOriginalNames; + protected bool $preserveOriginalNames; /** @var bool Whether to replace resolved nodes in place, or to add resolvedNode attributes */ - protected $replaceNodes; + protected bool $replaceNodes; /** * Constructs a name resolution visitor. @@ -33,24 +32,22 @@ class NameResolver extends NodeVisitorAbstract * namespacedName attribute, as usual.) * * @param ErrorHandler|null $errorHandler Error handler - * @param array $options Options + * @param array{preserveOriginalNames?: bool, replaceNodes?: bool} $options Options */ - public function __construct(ErrorHandler $errorHandler = null, array $options = []) { - $this->nameContext = new NameContext($errorHandler ?? new ErrorHandler\Throwing); + public function __construct(?ErrorHandler $errorHandler = null, array $options = []) { + $this->nameContext = new NameContext($errorHandler ?? new ErrorHandler\Throwing()); $this->preserveOriginalNames = $options['preserveOriginalNames'] ?? false; $this->replaceNodes = $options['replaceNodes'] ?? true; } /** * Get name resolution context. - * - * @return NameContext */ - public function getNameContext() : NameContext { + public function getNameContext(): NameContext { return $this->nameContext; } - public function beforeTraverse(array $nodes) { + public function beforeTraverse(array $nodes): ?array { $this->nameContext->startNamespace(); return null; } @@ -78,6 +75,8 @@ class NameResolver extends NodeVisitorAbstract $this->resolveAttrGroups($node); if (null !== $node->name) { $this->addNamespacedName($node); + } else { + $node->namespacedName = null; } } elseif ($node instanceof Stmt\Interface_) { foreach ($node->extends as &$interface) { @@ -86,15 +85,13 @@ class NameResolver extends NodeVisitorAbstract $this->resolveAttrGroups($node); $this->addNamespacedName($node); - } elseif ($node instanceof Stmt\Enum_) { + } elseif ($node instanceof Stmt\Enum_) { foreach ($node->implements as &$interface) { $interface = $this->resolveClassName($interface); } $this->resolveAttrGroups($node); - if (null !== $node->name) { - $this->addNamespacedName($node); - } + $this->addNamespacedName($node); } elseif ($node instanceof Stmt\Trait_) { $this->resolveAttrGroups($node); $this->addNamespacedName($node); @@ -113,13 +110,22 @@ class NameResolver extends NodeVisitorAbstract $node->type = $this->resolveType($node->type); } $this->resolveAttrGroups($node); + } elseif ($node instanceof Node\PropertyHook) { + foreach ($node->params as $param) { + $param->type = $this->resolveType($param->type); + $this->resolveAttrGroups($param); + } + $this->resolveAttrGroups($node); } elseif ($node instanceof Stmt\Const_) { foreach ($node->consts as $const) { $this->addNamespacedName($const); } - } else if ($node instanceof Stmt\ClassConst) { + } elseif ($node instanceof Stmt\ClassConst) { + if (null !== $node->type) { + $node->type = $this->resolveType($node->type); + } $this->resolveAttrGroups($node); - } else if ($node instanceof Stmt\EnumCase) { + } elseif ($node instanceof Stmt\EnumCase) { $this->resolveAttrGroups($node); } elseif ($node instanceof Expr\StaticCall || $node instanceof Expr\StaticPropertyFetch @@ -150,7 +156,7 @@ class NameResolver extends NodeVisitorAbstract $adaptation->trait = $this->resolveClassName($adaptation->trait); } - if ($adaptation instanceof Stmt\TraitUseAdaptation\Precedence) { + if ($adaptation instanceof \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Precedence) { foreach ($adaptation->insteadof as &$insteadof) { $insteadof = $this->resolveClassName($insteadof); } @@ -161,7 +167,8 @@ class NameResolver extends NodeVisitorAbstract return null; } - private function addAlias(Stmt\UseUse $use, int $type, Name $prefix = null) { + /** @param Stmt\Use_::TYPE_* $type */ + private function addAlias(Node\UseItem $use, int $type, ?Name $prefix = null): void { // Add prefix for group uses $name = $prefix ? Name::concat($prefix, $use->name) : $use->name; // Type is determined either by individual element or whole use declaration @@ -172,8 +179,8 @@ class NameResolver extends NodeVisitorAbstract ); } - /** @param Stmt\Function_|Stmt\ClassMethod|Expr\Closure $node */ - private function resolveSignature($node) { + /** @param Stmt\Function_|Stmt\ClassMethod|Expr\Closure|Expr\ArrowFunction $node */ + private function resolveSignature($node): void { foreach ($node->params as $param) { $param->type = $this->resolveType($param->type); $this->resolveAttrGroups($param); @@ -181,7 +188,12 @@ class NameResolver extends NodeVisitorAbstract $node->returnType = $this->resolveType($node->returnType); } - private function resolveType($node) { + /** + * @template T of Node\Identifier|Name|Node\ComplexType|null + * @param T $node + * @return T + */ + private function resolveType(?Node $node): ?Node { if ($node instanceof Name) { return $this->resolveClassName($node); } @@ -202,11 +214,11 @@ class NameResolver extends NodeVisitorAbstract * Resolve name, according to name resolver options. * * @param Name $name Function or constant name to resolve - * @param int $type One of Stmt\Use_::TYPE_* + * @param Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_* * * @return Name Resolved name, or original name with attribute */ - protected function resolveName(Name $name, int $type) : Name { + protected function resolveName(Name $name, int $type): Name { if (!$this->replaceNodes) { $resolvedName = $this->nameContext->getResolvedName($name, $type); if (null !== $resolvedName) { @@ -237,17 +249,16 @@ class NameResolver extends NodeVisitorAbstract return $name; } - protected function resolveClassName(Name $name) { + protected function resolveClassName(Name $name): Name { return $this->resolveName($name, Stmt\Use_::TYPE_NORMAL); } - protected function addNamespacedName(Node $node) { + protected function addNamespacedName(Node $node): void { $node->namespacedName = Name::concat( $this->nameContext->getNamespace(), (string) $node->name); } - protected function resolveAttrGroups(Node $node) - { + protected function resolveAttrGroups(Node $node): void { foreach ($node->attrGroups as $attrGroup) { foreach ($attrGroup->attrs as $attr) { $attr->name = $this->resolveClassName($attr->name); diff --git a/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/NodeConnectingVisitor.php b/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/NodeConnectingVisitor.php index 463b48a..22c922b 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/NodeConnectingVisitor.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/NodeConnectingVisitor.php @@ -14,12 +14,11 @@ use ncc\ThirdParty\nikic\PhpParser\NodeVisitorAbstract; * node can be accessed through $node->getAttribute('previous'), * and the next node can be accessed through $node->getAttribute('next'). */ -final class NodeConnectingVisitor extends NodeVisitorAbstract -{ +final class NodeConnectingVisitor extends NodeVisitorAbstract { /** * @var Node[] */ - private $stack = []; + private array $stack = []; /** * @var ?Node diff --git a/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/ParentConnectingVisitor.php b/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/ParentConnectingVisitor.php index 253be1b..6ecedf9 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/ParentConnectingVisitor.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/ParentConnectingVisitor.php @@ -2,31 +2,29 @@ namespace ncc\ThirdParty\nikic\PhpParser\NodeVisitor; -use function array_pop; -use function count; use ncc\ThirdParty\nikic\PhpParser\Node; use ncc\ThirdParty\nikic\PhpParser\NodeVisitorAbstract; +use function array_pop; +use function count; + /** * Visitor that connects a child node to its parent node. * * On the child node, the parent node can be accessed through * $node->getAttribute('parent'). */ -final class ParentConnectingVisitor extends NodeVisitorAbstract -{ +final class ParentConnectingVisitor extends NodeVisitorAbstract { /** * @var Node[] */ - private $stack = []; + private array $stack = []; - public function beforeTraverse(array $nodes) - { + public function beforeTraverse(array $nodes) { $this->stack = []; } - public function enterNode(Node $node) - { + public function enterNode(Node $node) { if (!empty($this->stack)) { $node->setAttribute('parent', $this->stack[count($this->stack) - 1]); } @@ -34,8 +32,7 @@ final class ParentConnectingVisitor extends NodeVisitorAbstract $this->stack[] = $node; } - public function leaveNode(Node $node) - { + public function leaveNode(Node $node) { array_pop($this->stack); } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitorAbstract.php b/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitorAbstract.php index 59fbde3..6476242 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitorAbstract.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitorAbstract.php @@ -5,8 +5,7 @@ namespace ncc\ThirdParty\nikic\PhpParser; /** * @codeCoverageIgnore */ -class NodeVisitorAbstract implements NodeVisitor -{ +abstract class NodeVisitorAbstract implements NodeVisitor { public function beforeTraverse(array $nodes) { return null; } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Parser.php b/src/ncc/ThirdParty/nikic/PhpParser/Parser.php index 69d0196..7e77e49 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Parser.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Parser.php @@ -2,8 +2,7 @@ namespace ncc\ThirdParty\nikic\PhpParser; -interface Parser -{ +interface Parser { /** * Parses PHP code into a node tree. * @@ -11,8 +10,15 @@ interface Parser * @param ErrorHandler|null $errorHandler Error handler to use for lexer/parser errors, defaults * to ErrorHandler\Throwing. * - * @return Node\Stmt[]|null Array of statements (or null non-throwing error handler is used and + * @return ncc\ThirdParty\nikic\PhpParser\Node\Stmt[]|null Array of statements (or null non-throwing error handler is used and * the parser was unable to recover from an error). */ - public function parse(string $code, ErrorHandler $errorHandler = null); + public function parse(string $code, ?ErrorHandler $errorHandler = null): ?array; + + /** + * Return tokens for the last parse. + * + * @return Token[] + */ + public function getTokens(): array; } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Parser/Multiple.php b/src/ncc/ThirdParty/nikic/PhpParser/Parser/Multiple.php deleted file mode 100644 index 4f92e62..0000000 --- a/src/ncc/ThirdParty/nikic/PhpParser/Parser/Multiple.php +++ /dev/null @@ -1,55 +0,0 @@ -parsers = $parsers; - } - - public function parse(string $code, ErrorHandler $errorHandler = null) { - if (null === $errorHandler) { - $errorHandler = new ErrorHandler\Throwing; - } - - list($firstStmts, $firstError) = $this->tryParse($this->parsers[0], $errorHandler, $code); - if ($firstError === null) { - return $firstStmts; - } - - for ($i = 1, $c = count($this->parsers); $i < $c; ++$i) { - list($stmts, $error) = $this->tryParse($this->parsers[$i], $errorHandler, $code); - if ($error === null) { - return $stmts; - } - } - - throw $firstError; - } - - private function tryParse(Parser $parser, ErrorHandler $errorHandler, $code) { - $stmts = null; - $error = null; - try { - $stmts = $parser->parse($code, $errorHandler); - } catch (Error $error) {} - return [$stmts, $error]; - } -} diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Parser/Php5.php b/src/ncc/ThirdParty/nikic/PhpParser/Parser/Php5.php deleted file mode 100644 index 91f9950..0000000 --- a/src/ncc/ThirdParty/nikic/PhpParser/Parser/Php5.php +++ /dev/null @@ -1,2682 +0,0 @@ -'", - "T_IS_GREATER_OR_EQUAL", - "T_SL", - "T_SR", - "'+'", - "'-'", - "'.'", - "'*'", - "'/'", - "'%'", - "'!'", - "T_INSTANCEOF", - "'~'", - "T_INC", - "T_DEC", - "T_INT_CAST", - "T_DOUBLE_CAST", - "T_STRING_CAST", - "T_ARRAY_CAST", - "T_OBJECT_CAST", - "T_BOOL_CAST", - "T_UNSET_CAST", - "'@'", - "T_POW", - "'['", - "T_NEW", - "T_CLONE", - "T_EXIT", - "T_IF", - "T_ELSEIF", - "T_ELSE", - "T_ENDIF", - "T_LNUMBER", - "T_DNUMBER", - "T_STRING", - "T_STRING_VARNAME", - "T_VARIABLE", - "T_NUM_STRING", - "T_INLINE_HTML", - "T_ENCAPSED_AND_WHITESPACE", - "T_CONSTANT_ENCAPSED_STRING", - "T_ECHO", - "T_DO", - "T_WHILE", - "T_ENDWHILE", - "T_FOR", - "T_ENDFOR", - "T_FOREACH", - "T_ENDFOREACH", - "T_DECLARE", - "T_ENDDECLARE", - "T_AS", - "T_SWITCH", - "T_MATCH", - "T_ENDSWITCH", - "T_CASE", - "T_DEFAULT", - "T_BREAK", - "T_CONTINUE", - "T_GOTO", - "T_FUNCTION", - "T_FN", - "T_CONST", - "T_RETURN", - "T_TRY", - "T_CATCH", - "T_FINALLY", - "T_USE", - "T_INSTEADOF", - "T_GLOBAL", - "T_STATIC", - "T_ABSTRACT", - "T_FINAL", - "T_PRIVATE", - "T_PROTECTED", - "T_PUBLIC", - "T_READONLY", - "T_VAR", - "T_UNSET", - "T_ISSET", - "T_EMPTY", - "T_HALT_COMPILER", - "T_CLASS", - "T_TRAIT", - "T_INTERFACE", - "T_EXTENDS", - "T_IMPLEMENTS", - "T_OBJECT_OPERATOR", - "T_LIST", - "T_ARRAY", - "T_CALLABLE", - "T_CLASS_C", - "T_TRAIT_C", - "T_METHOD_C", - "T_FUNC_C", - "T_LINE", - "T_FILE", - "T_START_HEREDOC", - "T_END_HEREDOC", - "T_DOLLAR_OPEN_CURLY_BRACES", - "T_CURLY_OPEN", - "T_PAAMAYIM_NEKUDOTAYIM", - "T_NAMESPACE", - "T_NS_C", - "T_DIR", - "T_NS_SEPARATOR", - "T_ELLIPSIS", - "T_NAME_FULLY_QUALIFIED", - "T_NAME_QUALIFIED", - "T_NAME_RELATIVE", - "';'", - "'{'", - "'}'", - "'('", - "')'", - "'$'", - "'`'", - "']'", - "'\"'", - "T_ENUM", - "T_NULLSAFE_OBJECT_OPERATOR", - "T_ATTRIBUTE" - ); - - protected $tokenToSymbol = array( - 0, 168, 168, 168, 168, 168, 168, 168, 168, 168, - 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, - 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, - 168, 168, 168, 56, 164, 168, 161, 55, 168, 168, - 159, 160, 53, 50, 8, 51, 52, 54, 168, 168, - 168, 168, 168, 168, 168, 168, 168, 168, 31, 156, - 44, 16, 46, 30, 68, 168, 168, 168, 168, 168, - 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, - 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, - 168, 70, 168, 163, 36, 168, 162, 168, 168, 168, - 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, - 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, - 168, 168, 168, 157, 35, 158, 58, 168, 168, 168, - 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, - 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, - 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, - 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, - 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, - 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, - 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, - 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, - 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, - 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, - 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, - 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, - 168, 168, 168, 168, 168, 168, 1, 2, 3, 4, - 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 32, 33, 34, 37, 38, 39, 40, - 41, 42, 43, 45, 47, 48, 49, 57, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 69, 71, 72, - 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, - 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, - 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, - 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, - 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, - 123, 124, 125, 126, 127, 128, 129, 130, 165, 131, - 132, 133, 166, 134, 135, 136, 137, 138, 139, 140, - 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, - 151, 152, 153, 154, 155, 167 - ); - - protected $action = array( - 700, 670, 671, 672, 673, 674, 286, 675, 676, 677, - 713, 714, 223, 224, 225, 226, 227, 228, 229, 230, - 231, 232, 0, 233, 234, 235, 236, 237, 238, 239, - 240, 241, 242, 243, 244,-32766,-32766,-32766,-32766,-32766, - -32766,-32766,-32766,-32766,-32767,-32767,-32767,-32767, 245, 246, - 242, 243, 244,-32766,-32766, 678,-32766,-32766,-32766,-32766, - -32766,-32766,-32766,-32766,-32766, 1229, 245, 246, 1230, 679, - 680, 681, 682, 683, 684, 685, 899, 900, 747,-32766, - -32766,-32766,-32766,-32766,-32766, 686, 687, 688, 689, 690, - 691, 692, 693, 694, 695, 696, 716, 739, 717, 718, - 719, 720, 708, 709, 710, 738, 711, 712, 697, 698, - 699, 701, 702, 703, 741, 742, 743, 744, 745, 746, - 875, 704, 705, 706, 707, 737, 728, 726, 727, 723, - 724, 1046, 715, 721, 722, 729, 730, 732, 731, 733, - 734, 55, 56, 425, 57, 58, 725, 736, 735, 755, - 59, 60, -226, 61,-32766,-32766,-32766,-32766,-32766,-32766, - -32766,-32766,-32766,-32766, 337,-32767,-32767,-32767,-32767, 29, - 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, - 117, 118, 119, 620,-32766,-32766,-32766,-32766, 62, 63, - 1046,-32766,-32766,-32766, 64, 419, 65, 294, 295, 66, - 67, 68, 69, 70, 71, 72, 73, 823, 25, 302, - 74, 418, 984, 986, 669, 668, 1100, 1101, 1078, 755, - 755, 767, 1220, 768, 470,-32766,-32766,-32766, 341, 749, - 824, 54,-32767,-32767,-32767,-32767, 98, 99, 100, 101, - 102, 220, 221, 222, 362, 876,-32766, 27,-32766,-32766, - -32766,-32766,-32766, 1046, 493, 126, 1080, 1079, 1081, 370, - 1068, 930, 207, 478, 479, 952, 953, 954, 951, 950, - 949, 128, 480, 481, 803, 1106, 1107, 1108, 1109, 1103, - 1104, 319, 32, 297, 10, 211, -515, 1110, 1105, 669, - 668, 1080, 1079, 1081, 220, 221, 222, 41, 364, 341, - 334, 421, 336, 426, -128, -128, -128, 313, 1046, 469, - -4, 824, 54, 812, 770, 207, 40, 21, 427, -128, - 471, -128, 472, -128, 473, -128, 1046, 428, 220, 221, - 222,-32766, 33, 34, 429, 361, 327, 52, 35, 474, - -32766,-32766,-32766, 342, 357, 358, 475, 476, 48, 207, - 249, 669, 668, 477, 443, 300, 795, 846, 430, 431, - 28,-32766, 814,-32766,-32766,-32766,-32766,-32766,-32766,-32766, - -32767,-32767,-32767,-32767,-32767, 952, 953, 954, 951, 950, - 949, 422, 755, 424, 426, 826, 634, -128,-32766,-32766, - 469, 824, 54, 288, 812, 1151, 755, 40, 21, 427, - 317, 471, 345, 472, 129, 473, 9, 1186, 428, 769, - 360, 324, 905, 33, 34, 429, 361, 1046, 415, 35, - 474, 944, 1068, 315, 125, 357, 358, 475, 476,-32766, - -32766,-32766, 926, 302, 477, 121, 1068, 759, 846, 430, - 431, 669, 668, 423, 755, 1152, 809, 1046, 480, 766, - -32766, 805,-32766,-32766,-32766,-32766, -261, 127, 347, 436, - 841, 341, 1078, 1200, 426, 446, 826, 634, -4, 807, - 469, 824, 54, 436, 812, 341, 755, 40, 21, 427, - 444, 471, 130, 472, 1068, 473, 346, 767, 428, 768, - -211, -211, -211, 33, 34, 429, 361, 308, 1076, 35, - 474,-32766,-32766,-32766, 1046, 357, 358, 475, 476,-32766, - -32766,-32766, 906, 120, 477, 539, 1068, 795, 846, 430, - 431, 436,-32766, 341,-32766,-32766,-32766, 1046, 480, 810, - -32766, 925,-32766,-32766, 754, 1080, 1079, 1081, 49,-32766, - -32766,-32766, 749, 751, 426, 1201, 826, 634, -211, 30, - 469, 669, 668, 436, 812, 341, 75, 40, 21, 427, - -32766, 471, 1064, 472, 124, 473, 669, 668, 428, 212, - -210, -210, -210, 33, 34, 429, 361, 51, 1186, 35, - 474, 755,-32766,-32766,-32766, 357, 358, 475, 476, 213, - 824, 54, 221, 222, 477, 20, 581, 795, 846, 430, - 431, 220, 221, 222, 755, 222, 247, 78, 79, 80, - 81, 341, 207, 517, 103, 104, 105, 752, 307, 131, - 637, 1068, 207, 341, 207, 122, 826, 634, -210, 36, - 106, 82, 83, 84, 85, 86, 87, 88, 89, 90, - 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, - 101, 102, 103, 104, 105, 1112, 307, 346, 436, 214, - 341, 824, 54, 426, 123, 250, 129, 134, 106, 469, - -32766, 572, 1112, 812, 245, 246, 40, 21, 427, 251, - 471, 252, 472, 341, 473, 453, 22, 428, 207, 899, - 900, 638, 33, 34, 429, 824, 54, -86, 35, 474, - 220, 221, 222, 314, 357, 358, 100, 101, 102, 239, - 240, 241, 645, 477, -230, 458, 589, 135, 374, 596, - 597, 207, 760, 640, 648, 642, 941, 654, 929, 662, - 822, 133, 307, 837, 426,-32766, 106, 749, 43, 44, - 469, 45, 442, 46, 812, 826, 634, 40, 21, 427, - 47, 471, 50, 472, 53, 473, 132, 608, 428, 302, - 604, -280,-32766, 33, 34, 429, 824, 54, 426, 35, - 474, 755, 957, -84, 469, 357, 358, 521, 812, 628, - 363, 40, 21, 427, 477, 471, 575, 472, -515, 473, - 847, 616, 428, -423,-32766, 11, 646, 33, 34, 429, - 824, 54, 445, 35, 474, 462, 285, 578, 1111, 357, - 358, 593, 369, 848, 594, 290, 826, 634, 477, 0, - 0, 532, 0, 0, 325, 0, 0, 0, 0, 0, - 651, 0, 0, 0, 322, 326, 0, 0, 0, 426, - 0, 0, 0, 0, 323, 469, 316, 318, -516, 812, - 862, 634, 40, 21, 427, 0, 471, 0, 472, 0, - 473, 1158, 0, 428, 0, -414, 6, 7, 33, 34, - 429, 824, 54, 426, 35, 474, 12, 14, 373, 469, - 357, 358, -424, 812, 563, 754, 40, 21, 427, 477, - 471, 248, 472, 839, 473, 38, 39, 428, 657, 658, - 765, 813, 33, 34, 429, 821, 800, 815, 35, 474, - 215, 216, 878, 869, 357, 358, 217, 870, 218, 798, - 863, 826, 634, 477, 860, 858, 936, 937, 934, 820, - 209, 804, 806, 808, 811, 933, 763, 764, 1100, 1101, - 935, 659, 78, 335, 426, 359, 1102, 635, 639, 641, - 469, 643, 644, 647, 812, 826, 634, 40, 21, 427, - 649, 471, 650, 472, 652, 473, 653, 636, 428, 796, - 1226, 1228, 762, 33, 34, 429, 215, 216, 845, 35, - 474, 761, 217, 844, 218, 357, 358, 1227, 843, 1060, - 831, 1048, 842, 1049, 477, 559, 209, 1106, 1107, 1108, - 1109, 1103, 1104, 398, 1100, 1101, 829, 942, 867, 1110, - 1105, 868, 1102, 457, 1225, 1194, 1192, 1177, 1157, 219, - 1190, 1091, 917, 1198, 1188, 0, 826, 634, 24, -433, - 26, 31, 37, 42, 76, 77, 210, 287, 292, 293, - 308, 309, 310, 311, 339, 356, 416, 0, -227, -226, - 16, 17, 18, 393, 454, 461, 463, 467, 553, 625, - 1051, 559, 1054, 1106, 1107, 1108, 1109, 1103, 1104, 398, - 907, 1116, 1050, 1026, 564, 1110, 1105, 1025, 1093, 1055, - 0, 1044, 0, 1057, 1056, 219, 1059, 1058, 1075, 0, - 1191, 1176, 1172, 1189, 1090, 1223, 1117, 1171, 600 - ); - - protected $actionCheck = array( - 2, 3, 4, 5, 6, 7, 14, 9, 10, 11, - 12, 13, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 0, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 9, 10, 11, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 69, 70, - 53, 54, 55, 9, 10, 57, 30, 116, 32, 33, - 34, 35, 36, 37, 38, 80, 69, 70, 83, 71, - 72, 73, 74, 75, 76, 77, 135, 136, 80, 33, - 34, 35, 36, 37, 38, 87, 88, 89, 90, 91, - 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, - 31, 123, 124, 125, 126, 127, 128, 129, 130, 131, - 132, 13, 134, 135, 136, 137, 138, 139, 140, 141, - 142, 3, 4, 5, 6, 7, 148, 149, 150, 82, - 12, 13, 160, 15, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 8, 44, 45, 46, 47, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 80, 33, 34, 35, 36, 50, 51, - 13, 9, 10, 11, 56, 128, 58, 59, 60, 61, - 62, 63, 64, 65, 66, 67, 68, 1, 70, 71, - 72, 73, 59, 60, 37, 38, 78, 79, 80, 82, - 82, 106, 85, 108, 86, 9, 10, 11, 161, 80, - 1, 2, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 9, 10, 11, 106, 156, 30, 8, 32, 33, - 34, 35, 36, 13, 116, 8, 153, 154, 155, 8, - 122, 158, 30, 125, 126, 116, 117, 118, 119, 120, - 121, 31, 134, 135, 156, 137, 138, 139, 140, 141, - 142, 143, 145, 146, 8, 8, 133, 149, 150, 37, - 38, 153, 154, 155, 9, 10, 11, 159, 8, 161, - 162, 8, 164, 74, 75, 76, 77, 8, 13, 80, - 0, 1, 2, 84, 158, 30, 87, 88, 89, 90, - 91, 92, 93, 94, 95, 96, 13, 98, 9, 10, - 11, 9, 103, 104, 105, 106, 8, 70, 109, 110, - 9, 10, 11, 8, 115, 116, 117, 118, 70, 30, - 31, 37, 38, 124, 31, 8, 127, 128, 129, 130, - 8, 30, 156, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, 116, 117, 118, 119, 120, - 121, 8, 82, 8, 74, 156, 157, 158, 33, 34, - 80, 1, 2, 8, 84, 163, 82, 87, 88, 89, - 133, 91, 70, 93, 152, 95, 108, 82, 98, 158, - 8, 113, 160, 103, 104, 105, 106, 13, 108, 109, - 110, 123, 122, 113, 157, 115, 116, 117, 118, 9, - 10, 11, 156, 71, 124, 157, 122, 127, 128, 129, - 130, 37, 38, 8, 82, 160, 156, 13, 134, 156, - 30, 156, 32, 33, 34, 35, 158, 157, 148, 159, - 122, 161, 80, 1, 74, 133, 156, 157, 158, 156, - 80, 1, 2, 159, 84, 161, 82, 87, 88, 89, - 157, 91, 157, 93, 122, 95, 161, 106, 98, 108, - 100, 101, 102, 103, 104, 105, 106, 159, 116, 109, - 110, 9, 10, 11, 13, 115, 116, 117, 118, 9, - 10, 11, 160, 16, 124, 81, 122, 127, 128, 129, - 130, 159, 30, 161, 32, 33, 34, 13, 134, 156, - 30, 156, 32, 33, 153, 153, 154, 155, 70, 9, - 10, 11, 80, 80, 74, 160, 156, 157, 158, 14, - 80, 37, 38, 159, 84, 161, 152, 87, 88, 89, - 30, 91, 160, 93, 14, 95, 37, 38, 98, 16, - 100, 101, 102, 103, 104, 105, 106, 70, 82, 109, - 110, 82, 33, 34, 35, 115, 116, 117, 118, 16, - 1, 2, 10, 11, 124, 160, 85, 127, 128, 129, - 130, 9, 10, 11, 82, 11, 14, 157, 9, 10, - 11, 161, 30, 85, 53, 54, 55, 154, 57, 157, - 31, 122, 30, 161, 30, 157, 156, 157, 158, 30, - 69, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 144, 57, 161, 159, 16, - 161, 1, 2, 74, 157, 16, 152, 157, 69, 80, - 116, 161, 144, 84, 69, 70, 87, 88, 89, 16, - 91, 16, 93, 161, 95, 75, 76, 98, 30, 135, - 136, 31, 103, 104, 105, 1, 2, 31, 109, 110, - 9, 10, 11, 31, 115, 116, 50, 51, 52, 50, - 51, 52, 31, 124, 160, 75, 76, 101, 102, 111, - 112, 30, 156, 157, 31, 31, 156, 157, 156, 157, - 31, 31, 57, 38, 74, 33, 69, 80, 70, 70, - 80, 70, 89, 70, 84, 156, 157, 87, 88, 89, - 70, 91, 70, 93, 70, 95, 70, 96, 98, 71, - 77, 82, 85, 103, 104, 105, 1, 2, 74, 109, - 110, 82, 82, 97, 80, 115, 116, 85, 84, 92, - 106, 87, 88, 89, 124, 91, 90, 93, 133, 95, - 128, 94, 98, 147, 116, 97, 31, 103, 104, 105, - 1, 2, 97, 109, 110, 97, 97, 100, 144, 115, - 116, 100, 106, 128, 113, 161, 156, 157, 124, -1, - -1, 151, -1, -1, 114, -1, -1, -1, -1, -1, - 31, -1, -1, -1, 131, 131, -1, -1, -1, 74, - -1, -1, -1, -1, 132, 80, 133, 133, 133, 84, - 156, 157, 87, 88, 89, -1, 91, -1, 93, -1, - 95, 144, -1, 98, -1, 147, 147, 147, 103, 104, - 105, 1, 2, 74, 109, 110, 147, 147, 147, 80, - 115, 116, 147, 84, 151, 153, 87, 88, 89, 124, - 91, 31, 93, 152, 95, 156, 156, 98, 156, 156, - 156, 156, 103, 104, 105, 156, 156, 156, 109, 110, - 50, 51, 156, 156, 115, 116, 56, 156, 58, 156, - 156, 156, 157, 124, 156, 156, 156, 156, 156, 156, - 70, 156, 156, 156, 156, 156, 156, 156, 78, 79, - 156, 158, 157, 157, 74, 157, 86, 157, 157, 157, - 80, 157, 157, 157, 84, 156, 157, 87, 88, 89, - 157, 91, 157, 93, 157, 95, 157, 157, 98, 158, - 158, 158, 158, 103, 104, 105, 50, 51, 158, 109, - 110, 158, 56, 158, 58, 115, 116, 158, 158, 158, - 158, 158, 158, 158, 124, 135, 70, 137, 138, 139, - 140, 141, 142, 143, 78, 79, 158, 158, 158, 149, - 150, 158, 86, 158, 158, 158, 158, 158, 164, 159, - 158, 158, 158, 158, 158, -1, 156, 157, 159, 162, - 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, - 159, 159, 159, 159, 159, 159, 159, -1, 160, 160, - 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, - 160, 135, 160, 137, 138, 139, 140, 141, 142, 143, - 160, 160, 160, 160, 160, 149, 150, 160, 160, 163, - -1, 162, -1, 163, 163, 159, 163, 163, 163, -1, - 163, 163, 163, 163, 163, 163, 163, 163, 163 - ); - - protected $actionBase = array( - 0, 229, 310, 390, 470, 103, 325, 325, 784, -2, - -2, 149, -2, -2, -2, 660, 765, 799, 765, 589, - 694, 870, 870, 870, 252, 404, 404, 404, 514, 177, - 177, 918, 434, 118, 295, 313, 240, 491, 491, 491, - 491, 138, 138, 491, 491, 491, 491, 491, 491, 491, - 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, - 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, - 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, - 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, - 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, - 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, - 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, - 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, - 491, 491, 491, 491, 491, 491, 89, 206, 773, 550, - 535, 775, 776, 777, 912, 709, 913, 856, 857, 700, - 858, 859, 862, 863, 864, 855, 865, 935, 866, 599, - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - 599, 322, 592, 285, 319, 232, 44, 691, 691, 691, - 691, 691, 691, 691, 182, 182, 182, 182, 182, 182, - 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, - 182, 182, 582, 530, 530, 530, 594, 860, 658, 926, - 926, 926, 926, 926, 926, 926, 926, 926, 926, 926, - 926, 926, 926, 926, 926, 926, 926, 926, 926, 926, - 926, 926, 926, 926, 926, 926, 926, 926, 926, 926, - 926, 926, 926, 926, 926, 926, 926, 926, 926, 926, - 926, 926, 926, 500, -21, -21, 492, 702, 420, 355, - 216, 549, 151, 26, 26, 331, 331, 331, 331, 331, - 46, 46, 5, 5, 5, 5, 153, 188, 188, 188, - 188, 121, 121, 121, 121, 314, 314, 394, 394, 362, - 300, 298, 499, 499, 499, 499, 499, 499, 499, 499, - 499, 499, 67, 656, 656, 659, 659, 522, 554, 554, - 554, 554, 679, -59, -59, 381, 462, 462, 462, 528, - 717, 854, 382, 382, 382, 382, 382, 382, 561, 561, - 561, -3, -3, -3, 692, 115, 137, 115, 137, 678, - 732, 450, 732, 338, 677, -15, 510, 810, 468, 707, - 850, 711, 853, 572, 735, 267, 529, 654, 674, 463, - 529, 529, 529, 529, 654, 610, 640, 608, 463, 529, - 463, 718, 323, 496, 89, 570, 507, 675, 778, 293, - 670, 780, 290, 373, 332, 566, 278, 435, 733, 781, - 914, 917, 385, 715, 675, 675, 675, 352, 511, 278, - -8, 605, 605, 605, 605, 156, 605, 605, 605, 605, - 251, 276, 375, 402, 779, 657, 657, 690, 872, 869, - 869, 657, 689, 657, 690, 874, 874, 874, 874, 657, - 657, 657, 657, 869, 869, 869, 688, 869, 239, 703, - 704, 704, 874, 742, 743, 657, 657, 712, 869, 869, - 869, 712, 695, 874, 701, 741, 277, 869, 874, 672, - 689, 672, 657, 701, 672, 689, 689, 672, 22, 666, - 668, 873, 875, 887, 790, 662, 685, 879, 880, 876, - 878, 871, 699, 744, 745, 497, 669, 671, 673, 680, - 719, 682, 713, 674, 667, 667, 667, 655, 720, 655, - 667, 667, 667, 667, 667, 667, 667, 667, 916, 646, - 731, 714, 653, 749, 553, 573, 791, 664, 811, 900, - 893, 867, 919, 881, 898, 655, 920, 739, 247, 643, - 882, 783, 786, 655, 883, 655, 792, 655, 902, 812, - 686, 813, 814, 667, 910, 921, 923, 924, 925, 927, - 928, 929, 930, 684, 931, 750, 696, 894, 299, 877, - 718, 729, 705, 788, 751, 820, 328, 932, 823, 655, - 655, 794, 785, 655, 795, 756, 740, 890, 757, 895, - 933, 664, 708, 896, 655, 706, 825, 934, 328, 681, - 683, 888, 661, 761, 886, 911, 885, 796, 649, 663, - 829, 830, 831, 693, 763, 891, 892, 889, 764, 803, - 665, 805, 697, 832, 807, 884, 768, 833, 834, 899, - 676, 730, 710, 698, 687, 809, 835, 897, 769, 770, - 771, 848, 772, 849, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 138, 138, 138, 138, -2, -2, - -2, -2, 0, 0, -2, 0, 0, 0, 138, 138, - 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, - 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, - 138, 138, 138, 138, 0, 0, 138, 138, 138, 138, - 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, - 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, - 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, - 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, - 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, - 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, - 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, - 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, - 138, 138, 138, 138, 138, 138, 138, 138, 138, 599, - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - 599, 599, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 599, -21, -21, -21, -21, 599, - -21, -21, -21, -21, -21, -21, -21, 599, 599, 599, - 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, - 599, 599, 599, 599, 599, -21, 599, 599, 599, -21, - 382, -21, 382, 382, 382, 382, 382, 382, 382, 382, - 382, 382, 382, 382, 382, 382, 382, 382, 382, 382, - 382, 382, 382, 382, 382, 382, 382, 382, 382, 382, - 382, 382, 382, 382, 382, 382, 382, 382, 382, 382, - 382, 382, 382, 382, 382, 382, 599, 0, 0, 599, - -21, 599, -21, 599, -21, -21, 599, 599, 599, 599, - 599, 599, 599, -21, -21, -21, -21, -21, -21, 0, - 561, 561, 561, 561, -21, -21, -21, -21, 382, 382, - 382, 382, 382, 382, 259, 382, 382, 382, 382, 382, - 382, 382, 382, 382, 382, 382, 561, 561, -3, -3, - 382, 382, 382, 382, 382, 259, 382, 382, 463, 689, - 689, 689, 137, 137, 137, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 137, 463, 0, - 463, 0, 382, 463, 689, 463, 657, 137, 689, 689, - 463, 869, 616, 616, 616, 616, 328, 278, 0, 0, - 689, 689, 0, 0, 0, 0, 0, 689, 0, 0, - 0, 0, 0, 0, 869, 0, 0, 0, 0, 0, - 667, 247, 0, 705, 335, 0, 0, 0, 0, 0, - 0, 705, 335, 347, 347, 0, 684, 667, 667, 667, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 328 - ); - - protected $actionDefault = array( - 3,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767, 544, 544, 499,32767,32767, - 32767,32767,32767,32767,32767,32767,32767, 299, 299, 299, - 32767,32767,32767, 532, 532, 532, 532, 532, 532, 532, - 532, 532, 532, 532,32767,32767,32767,32767,32767,32767, - 383,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767,32767,32767,32767, 389, - 549,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767,32767,32767,32767, 364, - 365, 367, 368, 298, 552, 533, 247, 390, 548, 297, - 249, 327, 503,32767,32767,32767, 329, 122, 258, 203, - 502, 125, 296, 234, 382, 384, 328, 303, 308, 309, - 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, - 320, 302, 458, 361, 360, 359, 460,32767, 459, 496, - 496, 499,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767, 325, 487, 486, 326, 456, 330, 457, - 333, 461, 464, 331, 332, 349, 350, 347, 348, 351, - 462, 463, 480, 481, 478, 479, 301, 352, 353, 354, - 355, 482, 483, 484, 485,32767,32767, 543, 543,32767, - 32767, 282,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767, 340, 341, 471, 472,32767, 238, 238, - 238, 238, 283, 238,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767,32767,32767, 335, 336, - 334, 466, 467, 465, 432,32767,32767,32767, 434,32767, - 32767,32767,32767,32767,32767,32767,32767,32767, 504,32767, - 32767,32767,32767,32767, 517, 421, 171,32767, 413,32767, - 171, 171, 171, 171,32767, 222, 224, 167,32767, 171, - 32767, 490,32767,32767,32767,32767, 522, 345,32767,32767, - 116,32767,32767,32767, 559,32767, 517,32767, 116,32767, - 32767,32767,32767, 358, 337, 338, 339,32767,32767, 521, - 515, 474, 475, 476, 477,32767, 468, 469, 470, 473, - 32767,32767,32767,32767,32767,32767,32767,32767, 429, 435, - 435,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767, 520, 519,32767, 414, 498, 188, - 186, 186,32767, 208, 208,32767,32767, 190, 491, 510, - 32767, 190, 173,32767, 400, 175, 498,32767,32767, 240, - 32767, 240,32767, 400, 240,32767,32767, 240,32767, 415, - 439,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767, 379, 380, 493, 506, - 32767, 507,32767, 413, 343, 344, 346, 322,32767, 324, - 369, 370, 371, 372, 373, 374, 375, 377,32767, 419, - 32767, 422,32767,32767,32767, 257,32767, 557,32767,32767, - 306, 557,32767,32767,32767, 551,32767,32767, 300,32767, - 32767,32767,32767, 253,32767, 169,32767, 541,32767, 558, - 32767, 515,32767, 342,32767,32767,32767,32767,32767,32767, - 32767,32767,32767, 516,32767,32767,32767,32767, 229,32767, - 452,32767, 116,32767,32767,32767, 189,32767,32767, 304, - 248,32767,32767, 550,32767,32767,32767,32767,32767,32767, - 32767,32767, 114,32767, 170,32767,32767,32767, 191,32767, - 32767, 515,32767,32767,32767,32767,32767,32767,32767, 295, - 32767,32767,32767,32767,32767,32767,32767, 515,32767,32767, - 233,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 415,32767, 276,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767, 127, 127, 3, 127, 127, 260, - 3, 260, 127, 260, 260, 127, 127, 127, 127, 127, - 127, 127, 127, 127, 127, 216, 219, 208, 208, 164, - 127, 127, 268 - ); - - protected $goto = array( - 166, 140, 140, 140, 166, 187, 168, 144, 147, 141, - 142, 143, 149, 163, 163, 163, 163, 144, 144, 165, - 165, 165, 165, 165, 165, 165, 165, 165, 165, 165, - 138, 159, 160, 161, 162, 184, 139, 185, 494, 495, - 377, 496, 500, 501, 502, 503, 504, 505, 506, 507, - 970, 164, 145, 146, 148, 171, 176, 186, 203, 253, - 256, 258, 260, 263, 264, 265, 266, 267, 268, 269, - 277, 278, 279, 280, 303, 304, 328, 329, 330, 394, - 395, 396, 543, 188, 189, 190, 191, 192, 193, 194, - 195, 196, 197, 198, 199, 200, 201, 150, 151, 152, - 167, 153, 169, 154, 204, 170, 155, 156, 157, 205, - 158, 136, 621, 561, 757, 561, 561, 561, 561, 561, - 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, - 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, - 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, - 561, 561, 561, 561, 561, 561, 561, 561, 561, 1113, - 629, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, - 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, - 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, - 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, - 1113, 1113, 1113, 1113, 1113, 758, 520, 531, 509, 656, - 556, 1183, 750, 509, 592, 786, 1183, 888, 612, 613, - 884, 617, 618, 624, 626, 631, 633, 817, 855, 855, - 855, 855, 850, 856, 174, 891, 891, 1205, 1205, 177, - 178, 179, 401, 402, 403, 404, 173, 202, 206, 208, - 257, 259, 261, 262, 270, 271, 272, 273, 274, 275, - 281, 282, 283, 284, 305, 306, 331, 332, 333, 406, - 407, 408, 409, 175, 180, 254, 255, 181, 182, 183, - 498, 498, 498, 498, 498, 498, 861, 498, 498, 498, - 498, 498, 498, 498, 498, 498, 498, 510, 586, 538, - 601, 602, 510, 545, 546, 547, 548, 549, 550, 551, - 552, 554, 587, 1209, 560, 350, 560, 560, 560, 560, - 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, - 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, - 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, - 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, - 400, 607, 537, 537, 569, 533, 909, 535, 535, 497, - 499, 525, 541, 570, 573, 584, 591, 298, 296, 296, - 296, 298, 289, 299, 611, 378, 511, 614, 595, 947, - 375, 511, 437, 437, 437, 437, 437, 437, 1163, 437, - 437, 437, 437, 437, 437, 437, 437, 437, 437, 1077, - 948, 338, 1175, 321, 1077, 898, 898, 898, 898, 606, - 898, 898, 1217, 1217, 1202, 753, 576, 605, 756, 1077, - 1077, 1077, 1077, 1077, 1077, 1069, 384, 384, 384, 391, - 1217, 877, 859, 857, 859, 655, 466, 512, 886, 881, - 753, 384, 753, 384, 968, 384, 895, 385, 588, 353, - 414, 384, 1231, 1019, 542, 1197, 1197, 1197, 568, 1094, - 386, 386, 386, 904, 915, 515, 1029, 19, 15, 372, - 389, 915, 940, 448, 450, 632, 340, 1216, 1216, 1114, - 615, 938, 840, 555, 775, 386, 913, 1070, 1073, 1074, - 399, 1069, 1182, 660, 23, 1216, 773, 1182, 544, 603, - 1066, 1219, 1071, 1174, 1071, 519, 1199, 1199, 1199, 1089, - 1088, 1072, 343, 523, 534, 519, 519, 772, 351, 352, - 13, 579, 583, 627, 1061, 388, 782, 562, 771, 515, - 783, 1181, 3, 4, 918, 956, 865, 451, 574, 1160, - 464, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 514, 529, 0, 0, 0, 0, - 514, 0, 529, 0, 0, 0, 0, 610, 513, 516, - 439, 440, 1067, 619, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 780, 1224, 0, 0, 0, 0, - 0, 524, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 778, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 301, 301 - ); - - protected $gotoCheck = array( - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 57, 69, 15, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 69, 69, 69, 69, 69, 128, - 9, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 16, 102, 32, 69, 32, - 32, 120, 6, 69, 32, 29, 120, 32, 32, 32, - 32, 32, 32, 32, 32, 32, 32, 50, 69, 69, - 69, 69, 69, 69, 27, 77, 77, 77, 77, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 119, 119, 119, 119, 119, 119, 33, 119, 119, 119, - 119, 119, 119, 119, 119, 119, 119, 119, 67, 110, - 67, 67, 119, 111, 111, 111, 111, 111, 111, 111, - 111, 111, 111, 142, 57, 72, 57, 57, 57, 57, - 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 51, 51, 51, 51, 51, 51, 84, 51, 51, 51, - 51, 51, 51, 51, 51, 51, 51, 5, 5, 5, - 5, 5, 5, 5, 63, 46, 124, 63, 129, 98, - 63, 124, 57, 57, 57, 57, 57, 57, 133, 57, - 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 98, 127, 82, 127, 57, 57, 57, 57, 57, 49, - 57, 57, 144, 144, 140, 11, 40, 40, 14, 57, - 57, 57, 57, 57, 57, 82, 13, 13, 13, 48, - 144, 14, 14, 14, 14, 14, 57, 14, 14, 14, - 11, 13, 11, 13, 102, 13, 79, 11, 70, 70, - 70, 13, 13, 103, 2, 9, 9, 9, 2, 34, - 125, 125, 125, 81, 13, 13, 34, 34, 34, 34, - 17, 13, 8, 8, 8, 8, 18, 143, 143, 8, - 8, 8, 9, 34, 25, 125, 85, 82, 82, 82, - 125, 82, 121, 74, 34, 143, 24, 121, 47, 34, - 116, 143, 82, 82, 82, 47, 121, 121, 121, 126, - 126, 82, 58, 58, 58, 47, 47, 23, 72, 72, - 58, 62, 62, 62, 114, 12, 23, 12, 23, 13, - 26, 121, 30, 30, 86, 100, 71, 65, 66, 132, - 109, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 9, 9, -1, -1, -1, -1, - 9, -1, 9, -1, -1, -1, -1, 13, 9, 9, - 9, 9, 13, 13, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 9, 9, -1, -1, -1, -1, - -1, 102, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 9, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 5, 5 - ); - - protected $gotoBase = array( - 0, 0, -172, 0, 0, 353, 201, 0, 477, 149, - 0, 110, 195, 117, 426, 112, 203, 140, 171, 0, - 0, 0, 0, 168, 164, 157, 119, 27, 0, 205, - -118, 0, -428, 266, 51, 0, 0, 0, 0, 0, - 388, 0, 0, -24, 0, 0, 345, 484, 146, 133, - 209, 75, 0, 0, 0, 0, 0, 107, 161, 0, - 0, 0, 222, -77, 0, 106, 97, -343, 0, -94, - 135, 123, -129, 0, 129, 0, 0, -50, 0, 143, - 0, 159, 64, 0, 338, 132, 122, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 98, 0, - 121, 0, 165, 156, 0, 0, 0, 0, 0, 87, - 273, 259, 0, 0, 114, 0, 150, 0, 0, -5, - -91, 200, 0, 0, 84, 154, 202, 77, -48, 178, - 0, 0, 93, 187, 0, 0, 0, 0, 0, 0, - 136, 0, 286, 167, 102, 0, 0 - ); - - protected $gotoDefault = array( - -32768, 468, 664, 2, 665, 835, 740, 748, 598, 482, - 630, 582, 380, 1193, 792, 793, 794, 381, 368, 483, - 379, 410, 405, 781, 774, 776, 784, 172, 411, 787, - 1, 789, 518, 825, 1020, 365, 797, 366, 590, 799, - 527, 801, 802, 137, 382, 383, 528, 484, 390, 577, - 816, 276, 387, 818, 367, 819, 828, 371, 465, 455, - 460, 530, 557, 609, 432, 447, 571, 565, 536, 1086, - 566, 864, 349, 872, 661, 880, 883, 485, 558, 894, - 452, 902, 1099, 397, 908, 914, 919, 291, 922, 417, - 412, 585, 927, 928, 5, 932, 622, 623, 8, 312, - 955, 599, 969, 420, 1039, 1041, 486, 487, 522, 459, - 508, 526, 488, 1062, 441, 413, 1065, 433, 489, 490, - 434, 435, 1083, 355, 1168, 354, 449, 320, 1155, 580, - 1118, 456, 1208, 1164, 348, 491, 492, 376, 1187, 392, - 1203, 438, 1210, 1218, 344, 540, 567 - ); - - protected $ruleToNonTerminal = array( - 0, 1, 3, 3, 2, 5, 5, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, - 7, 7, 7, 7, 8, 8, 9, 10, 11, 11, - 12, 12, 13, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 18, 18, 19, 19, 21, 21, - 17, 17, 22, 22, 23, 23, 24, 24, 25, 25, - 20, 20, 26, 28, 28, 29, 30, 30, 32, 31, - 31, 31, 31, 33, 33, 33, 33, 33, 33, 33, - 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, - 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, - 33, 33, 14, 14, 54, 54, 56, 55, 55, 48, - 48, 58, 58, 59, 59, 60, 60, 61, 61, 15, - 16, 16, 16, 64, 64, 64, 65, 65, 68, 68, - 66, 66, 70, 70, 41, 41, 50, 50, 53, 53, - 53, 52, 52, 71, 42, 42, 42, 42, 72, 72, - 73, 73, 74, 74, 39, 39, 35, 35, 75, 37, - 37, 76, 36, 36, 38, 38, 49, 49, 49, 62, - 62, 78, 78, 79, 79, 81, 81, 81, 80, 80, - 63, 63, 82, 82, 82, 83, 83, 84, 84, 84, - 44, 44, 85, 85, 85, 45, 45, 86, 86, 87, - 87, 67, 88, 88, 88, 88, 93, 93, 94, 94, - 95, 95, 95, 95, 95, 96, 97, 97, 92, 92, - 89, 89, 91, 91, 99, 99, 98, 98, 98, 98, - 98, 98, 90, 90, 101, 100, 100, 46, 46, 40, - 40, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 34, 34, 47, - 47, 106, 106, 107, 107, 107, 107, 113, 102, 102, - 109, 109, 115, 115, 116, 117, 118, 118, 118, 118, - 118, 118, 118, 69, 69, 57, 57, 57, 57, 103, - 103, 122, 122, 119, 119, 123, 123, 123, 123, 104, - 104, 104, 108, 108, 108, 114, 114, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 27, 27, 27, 27, 27, 27, 130, 130, 130, 130, - 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, - 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, - 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, - 112, 112, 105, 105, 105, 105, 129, 129, 132, 132, - 131, 131, 133, 133, 51, 51, 51, 51, 135, 135, - 134, 134, 134, 134, 134, 136, 136, 121, 121, 124, - 124, 120, 120, 138, 137, 137, 137, 137, 125, 125, - 125, 125, 111, 111, 126, 126, 126, 126, 77, 139, - 139, 140, 140, 140, 110, 110, 141, 141, 142, 142, - 142, 142, 142, 127, 127, 127, 127, 144, 145, 143, - 143, 143, 143, 143, 143, 143, 146, 146, 146 - ); - - protected $ruleToLength = array( - 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 3, 5, 4, - 3, 4, 2, 3, 1, 1, 7, 6, 3, 1, - 3, 1, 3, 1, 1, 3, 1, 3, 1, 2, - 3, 1, 3, 3, 1, 3, 2, 0, 1, 1, - 1, 1, 1, 3, 5, 8, 3, 5, 9, 3, - 2, 3, 2, 3, 2, 3, 3, 3, 3, 1, - 2, 2, 5, 7, 9, 5, 6, 3, 3, 2, - 2, 1, 1, 1, 0, 2, 8, 0, 4, 1, - 3, 0, 1, 0, 1, 0, 1, 1, 1, 10, - 7, 6, 5, 1, 2, 2, 0, 2, 0, 2, - 0, 2, 1, 3, 1, 4, 1, 4, 1, 1, - 4, 1, 3, 3, 3, 4, 4, 5, 0, 2, - 4, 3, 1, 1, 1, 4, 0, 2, 3, 0, - 2, 4, 0, 2, 0, 3, 1, 2, 1, 1, - 0, 1, 3, 4, 6, 1, 1, 1, 0, 1, - 0, 2, 2, 3, 3, 1, 3, 1, 2, 2, - 3, 1, 1, 2, 4, 3, 1, 1, 3, 2, - 0, 1, 3, 3, 9, 3, 1, 3, 0, 2, - 4, 5, 4, 4, 4, 3, 1, 1, 1, 3, - 1, 1, 0, 1, 1, 2, 1, 1, 1, 1, - 1, 1, 1, 3, 1, 1, 3, 3, 1, 0, - 1, 1, 3, 3, 4, 4, 1, 2, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 2, 2, 2, 2, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 1, 3, 5, - 4, 3, 4, 4, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, - 1, 3, 2, 1, 2, 10, 11, 3, 3, 2, - 4, 4, 3, 4, 4, 4, 4, 7, 3, 2, - 0, 4, 1, 3, 2, 1, 2, 2, 4, 6, - 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 3, 3, 4, 4, 0, - 2, 1, 0, 1, 1, 0, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, - 1, 3, 1, 4, 3, 1, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 2, 2, 2, 2, 3, 3, - 3, 3, 3, 3, 3, 3, 5, 4, 4, 3, - 1, 3, 1, 1, 3, 3, 0, 2, 0, 1, - 3, 1, 3, 1, 1, 1, 1, 1, 6, 4, - 3, 4, 2, 4, 4, 1, 3, 1, 2, 1, - 1, 4, 1, 1, 3, 6, 4, 4, 4, 4, - 1, 4, 0, 1, 1, 3, 1, 1, 4, 3, - 1, 1, 1, 0, 0, 2, 3, 1, 3, 1, - 4, 2, 2, 2, 2, 1, 2, 1, 1, 1, - 4, 3, 3, 3, 6, 3, 1, 1, 1 - ); - - protected function initReduceCallbacks() { - $this->reduceCallbacks = [ - 0 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 1 => function ($stackPos) { - $this->semValue = $this->handleNamespaces($this->semStack[$stackPos-(1-1)]); - }, - 2 => function ($stackPos) { - if (is_array($this->semStack[$stackPos-(2-2)])) { $this->semValue = array_merge($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)]); } else { $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; }; - }, - 3 => function ($stackPos) { - $this->semValue = array(); - }, - 4 => function ($stackPos) { - $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); } else { $nop = null; }; - if ($nop !== null) { $this->semStack[$stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 5 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 6 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 7 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 8 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 9 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 10 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 11 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 12 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 13 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 14 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 15 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 16 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 17 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 18 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 19 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 20 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 21 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 22 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 23 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 24 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 25 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 26 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 27 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 28 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 29 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 30 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 31 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 32 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 33 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 34 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 35 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 36 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 37 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 38 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 39 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 40 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 41 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 42 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 43 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 44 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 45 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 46 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 47 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 48 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 49 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 50 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 51 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 52 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 53 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 54 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 55 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 56 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 57 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 58 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 59 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 60 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 61 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 62 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 63 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 64 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 65 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 66 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 67 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 68 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 69 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 70 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 71 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 72 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 73 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 74 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 75 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 76 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 77 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 78 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 79 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 80 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 81 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 82 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 83 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 84 => function ($stackPos) { - $this->semValue = new Node\Identifier($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 85 => function ($stackPos) { - $this->semValue = new Node\Identifier($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 86 => function ($stackPos) { - $this->semValue = new Node\Identifier($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 87 => function ($stackPos) { - $this->semValue = new Node\Identifier($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 88 => function ($stackPos) { - $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 89 => function ($stackPos) { - $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 90 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 91 => function ($stackPos) { - $this->semValue = new Name(substr($this->semStack[$stackPos-(1-1)], 1), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 92 => function ($stackPos) { - $this->semValue = new Expr\Variable(substr($this->semStack[$stackPos-(1-1)], 1), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 93 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 94 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 95 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 96 => function ($stackPos) { - $this->semValue = new Stmt\HaltCompiler($this->lexer->handleHaltCompiler(), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 97 => function ($stackPos) { - $this->semValue = new Stmt\Namespace_($this->semStack[$stackPos-(3-2)], null, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - $this->semValue->setAttribute('kind', Stmt\Namespace_::KIND_SEMICOLON); - $this->checkNamespace($this->semValue); - }, - 98 => function ($stackPos) { - $this->semValue = new Stmt\Namespace_($this->semStack[$stackPos-(5-2)], $this->semStack[$stackPos-(5-4)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); - $this->semValue->setAttribute('kind', Stmt\Namespace_::KIND_BRACED); - $this->checkNamespace($this->semValue); - }, - 99 => function ($stackPos) { - $this->semValue = new Stmt\Namespace_(null, $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - $this->semValue->setAttribute('kind', Stmt\Namespace_::KIND_BRACED); - $this->checkNamespace($this->semValue); - }, - 100 => function ($stackPos) { - $this->semValue = new Stmt\Use_($this->semStack[$stackPos-(3-2)], Stmt\Use_::TYPE_NORMAL, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 101 => function ($stackPos) { - $this->semValue = new Stmt\Use_($this->semStack[$stackPos-(4-3)], $this->semStack[$stackPos-(4-2)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 102 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-1)]; - }, - 103 => function ($stackPos) { - $this->semValue = new Stmt\Const_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 104 => function ($stackPos) { - $this->semValue = Stmt\Use_::TYPE_FUNCTION; - }, - 105 => function ($stackPos) { - $this->semValue = Stmt\Use_::TYPE_CONSTANT; - }, - 106 => function ($stackPos) { - $this->semValue = new Stmt\GroupUse($this->semStack[$stackPos-(7-3)], $this->semStack[$stackPos-(7-6)], $this->semStack[$stackPos-(7-2)], $this->startAttributeStack[$stackPos-(7-1)] + $this->endAttributes); - }, - 107 => function ($stackPos) { - $this->semValue = new Stmt\GroupUse($this->semStack[$stackPos-(6-2)], $this->semStack[$stackPos-(6-5)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); - }, - 108 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; - }, - 109 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 110 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; - }, - 111 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 112 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; - }, - 113 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 114 => function ($stackPos) { - $this->semValue = new Stmt\UseUse($this->semStack[$stackPos-(1-1)], null, Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos-(1-1)); - }, - 115 => function ($stackPos) { - $this->semValue = new Stmt\UseUse($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos-(3-3)); - }, - 116 => function ($stackPos) { - $this->semValue = new Stmt\UseUse($this->semStack[$stackPos-(1-1)], null, Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos-(1-1)); - }, - 117 => function ($stackPos) { - $this->semValue = new Stmt\UseUse($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos-(3-3)); - }, - 118 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; $this->semValue->type = Stmt\Use_::TYPE_NORMAL; - }, - 119 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-2)]; $this->semValue->type = $this->semStack[$stackPos-(2-1)]; - }, - 120 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; - }, - 121 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 122 => function ($stackPos) { - $this->semValue = new Node\Const_($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 123 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; - }, - 124 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 125 => function ($stackPos) { - $this->semValue = new Node\Const_($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 126 => function ($stackPos) { - if (is_array($this->semStack[$stackPos-(2-2)])) { $this->semValue = array_merge($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)]); } else { $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; }; - }, - 127 => function ($stackPos) { - $this->semValue = array(); - }, - 128 => function ($stackPos) { - $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); } else { $nop = null; }; - if ($nop !== null) { $this->semStack[$stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 129 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 130 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 131 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 132 => function ($stackPos) { - throw new Error('__HALT_COMPILER() can only be used from the outermost scope', $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 133 => function ($stackPos) { - - if ($this->semStack[$stackPos-(3-2)]) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; $attrs = $this->startAttributeStack[$stackPos-(3-1)]; $stmts = $this->semValue; if (!empty($attrs['comments'])) {$stmts[0]->setAttribute('comments', array_merge($attrs['comments'], $stmts[0]->getAttribute('comments', []))); }; - } else { - $startAttributes = $this->startAttributeStack[$stackPos-(3-1)]; if (isset($startAttributes['comments'])) { $this->semValue = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $this->semValue = null; }; - if (null === $this->semValue) { $this->semValue = array(); } - } - - }, - 134 => function ($stackPos) { - $this->semValue = new Stmt\If_($this->semStack[$stackPos-(5-2)], ['stmts' => is_array($this->semStack[$stackPos-(5-3)]) ? $this->semStack[$stackPos-(5-3)] : array($this->semStack[$stackPos-(5-3)]), 'elseifs' => $this->semStack[$stackPos-(5-4)], 'else' => $this->semStack[$stackPos-(5-5)]], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); - }, - 135 => function ($stackPos) { - $this->semValue = new Stmt\If_($this->semStack[$stackPos-(8-2)], ['stmts' => $this->semStack[$stackPos-(8-4)], 'elseifs' => $this->semStack[$stackPos-(8-5)], 'else' => $this->semStack[$stackPos-(8-6)]], $this->startAttributeStack[$stackPos-(8-1)] + $this->endAttributes); - }, - 136 => function ($stackPos) { - $this->semValue = new Stmt\While_($this->semStack[$stackPos-(3-2)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 137 => function ($stackPos) { - $this->semValue = new Stmt\Do_($this->semStack[$stackPos-(5-4)], is_array($this->semStack[$stackPos-(5-2)]) ? $this->semStack[$stackPos-(5-2)] : array($this->semStack[$stackPos-(5-2)]), $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); - }, - 138 => function ($stackPos) { - $this->semValue = new Stmt\For_(['init' => $this->semStack[$stackPos-(9-3)], 'cond' => $this->semStack[$stackPos-(9-5)], 'loop' => $this->semStack[$stackPos-(9-7)], 'stmts' => $this->semStack[$stackPos-(9-9)]], $this->startAttributeStack[$stackPos-(9-1)] + $this->endAttributes); - }, - 139 => function ($stackPos) { - $this->semValue = new Stmt\Switch_($this->semStack[$stackPos-(3-2)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 140 => function ($stackPos) { - $this->semValue = new Stmt\Break_(null, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 141 => function ($stackPos) { - $this->semValue = new Stmt\Break_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 142 => function ($stackPos) { - $this->semValue = new Stmt\Continue_(null, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 143 => function ($stackPos) { - $this->semValue = new Stmt\Continue_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 144 => function ($stackPos) { - $this->semValue = new Stmt\Return_(null, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 145 => function ($stackPos) { - $this->semValue = new Stmt\Return_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 146 => function ($stackPos) { - $this->semValue = new Stmt\Global_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 147 => function ($stackPos) { - $this->semValue = new Stmt\Static_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 148 => function ($stackPos) { - $this->semValue = new Stmt\Echo_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 149 => function ($stackPos) { - $this->semValue = new Stmt\InlineHTML($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 150 => function ($stackPos) { - $this->semValue = new Stmt\Expression($this->semStack[$stackPos-(2-1)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 151 => function ($stackPos) { - $this->semValue = new Stmt\Expression($this->semStack[$stackPos-(2-1)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 152 => function ($stackPos) { - $this->semValue = new Stmt\Unset_($this->semStack[$stackPos-(5-3)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); - }, - 153 => function ($stackPos) { - $this->semValue = new Stmt\Foreach_($this->semStack[$stackPos-(7-3)], $this->semStack[$stackPos-(7-5)][0], ['keyVar' => null, 'byRef' => $this->semStack[$stackPos-(7-5)][1], 'stmts' => $this->semStack[$stackPos-(7-7)]], $this->startAttributeStack[$stackPos-(7-1)] + $this->endAttributes); - }, - 154 => function ($stackPos) { - $this->semValue = new Stmt\Foreach_($this->semStack[$stackPos-(9-3)], $this->semStack[$stackPos-(9-7)][0], ['keyVar' => $this->semStack[$stackPos-(9-5)], 'byRef' => $this->semStack[$stackPos-(9-7)][1], 'stmts' => $this->semStack[$stackPos-(9-9)]], $this->startAttributeStack[$stackPos-(9-1)] + $this->endAttributes); - }, - 155 => function ($stackPos) { - $this->semValue = new Stmt\Declare_($this->semStack[$stackPos-(5-3)], $this->semStack[$stackPos-(5-5)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); - }, - 156 => function ($stackPos) { - $this->semValue = new Stmt\TryCatch($this->semStack[$stackPos-(6-3)], $this->semStack[$stackPos-(6-5)], $this->semStack[$stackPos-(6-6)], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); $this->checkTryCatch($this->semValue); - }, - 157 => function ($stackPos) { - $this->semValue = new Stmt\Throw_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 158 => function ($stackPos) { - $this->semValue = new Stmt\Goto_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 159 => function ($stackPos) { - $this->semValue = new Stmt\Label($this->semStack[$stackPos-(2-1)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 160 => function ($stackPos) { - $this->semValue = new Stmt\Expression($this->semStack[$stackPos-(2-1)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 161 => function ($stackPos) { - $this->semValue = array(); /* means: no statement */ - }, - 162 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 163 => function ($stackPos) { - $startAttributes = $this->startAttributeStack[$stackPos-(1-1)]; if (isset($startAttributes['comments'])) { $this->semValue = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $this->semValue = null; }; - if ($this->semValue === null) $this->semValue = array(); /* means: no statement */ - }, - 164 => function ($stackPos) { - $this->semValue = array(); - }, - 165 => function ($stackPos) { - $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; - }, - 166 => function ($stackPos) { - $this->semValue = new Stmt\Catch_(array($this->semStack[$stackPos-(8-3)]), $this->semStack[$stackPos-(8-4)], $this->semStack[$stackPos-(8-7)], $this->startAttributeStack[$stackPos-(8-1)] + $this->endAttributes); - }, - 167 => function ($stackPos) { - $this->semValue = null; - }, - 168 => function ($stackPos) { - $this->semValue = new Stmt\Finally_($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 169 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 170 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; - }, - 171 => function ($stackPos) { - $this->semValue = false; - }, - 172 => function ($stackPos) { - $this->semValue = true; - }, - 173 => function ($stackPos) { - $this->semValue = false; - }, - 174 => function ($stackPos) { - $this->semValue = true; - }, - 175 => function ($stackPos) { - $this->semValue = false; - }, - 176 => function ($stackPos) { - $this->semValue = true; - }, - 177 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 178 => function ($stackPos) { - $this->semValue = new Node\Identifier($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 179 => function ($stackPos) { - $this->semValue = new Stmt\Function_($this->semStack[$stackPos-(10-3)], ['byRef' => $this->semStack[$stackPos-(10-2)], 'params' => $this->semStack[$stackPos-(10-5)], 'returnType' => $this->semStack[$stackPos-(10-7)], 'stmts' => $this->semStack[$stackPos-(10-9)]], $this->startAttributeStack[$stackPos-(10-1)] + $this->endAttributes); - }, - 180 => function ($stackPos) { - $this->semValue = new Stmt\Class_($this->semStack[$stackPos-(7-2)], ['type' => $this->semStack[$stackPos-(7-1)], 'extends' => $this->semStack[$stackPos-(7-3)], 'implements' => $this->semStack[$stackPos-(7-4)], 'stmts' => $this->semStack[$stackPos-(7-6)]], $this->startAttributeStack[$stackPos-(7-1)] + $this->endAttributes); - $this->checkClass($this->semValue, $stackPos-(7-2)); - }, - 181 => function ($stackPos) { - $this->semValue = new Stmt\Interface_($this->semStack[$stackPos-(6-2)], ['extends' => $this->semStack[$stackPos-(6-3)], 'stmts' => $this->semStack[$stackPos-(6-5)]], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); - $this->checkInterface($this->semValue, $stackPos-(6-2)); - }, - 182 => function ($stackPos) { - $this->semValue = new Stmt\Trait_($this->semStack[$stackPos-(5-2)], ['stmts' => $this->semStack[$stackPos-(5-4)]], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); - }, - 183 => function ($stackPos) { - $this->semValue = 0; - }, - 184 => function ($stackPos) { - $this->semValue = Stmt\Class_::MODIFIER_ABSTRACT; - }, - 185 => function ($stackPos) { - $this->semValue = Stmt\Class_::MODIFIER_FINAL; - }, - 186 => function ($stackPos) { - $this->semValue = null; - }, - 187 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-2)]; - }, - 188 => function ($stackPos) { - $this->semValue = array(); - }, - 189 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-2)]; - }, - 190 => function ($stackPos) { - $this->semValue = array(); - }, - 191 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-2)]; - }, - 192 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 193 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; - }, - 194 => function ($stackPos) { - $this->semValue = is_array($this->semStack[$stackPos-(1-1)]) ? $this->semStack[$stackPos-(1-1)] : array($this->semStack[$stackPos-(1-1)]); - }, - 195 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(4-2)]; - }, - 196 => function ($stackPos) { - $this->semValue = is_array($this->semStack[$stackPos-(1-1)]) ? $this->semStack[$stackPos-(1-1)] : array($this->semStack[$stackPos-(1-1)]); - }, - 197 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(4-2)]; - }, - 198 => function ($stackPos) { - $this->semValue = is_array($this->semStack[$stackPos-(1-1)]) ? $this->semStack[$stackPos-(1-1)] : array($this->semStack[$stackPos-(1-1)]); - }, - 199 => function ($stackPos) { - $this->semValue = null; - }, - 200 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(4-2)]; - }, - 201 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 202 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; - }, - 203 => function ($stackPos) { - $this->semValue = new Stmt\DeclareDeclare($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 204 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; - }, - 205 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(4-3)]; - }, - 206 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(4-2)]; - }, - 207 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(5-3)]; - }, - 208 => function ($stackPos) { - $this->semValue = array(); - }, - 209 => function ($stackPos) { - $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; - }, - 210 => function ($stackPos) { - $this->semValue = new Stmt\Case_($this->semStack[$stackPos-(4-2)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 211 => function ($stackPos) { - $this->semValue = new Stmt\Case_(null, $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 212 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 213 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 214 => function ($stackPos) { - $this->semValue = is_array($this->semStack[$stackPos-(1-1)]) ? $this->semStack[$stackPos-(1-1)] : array($this->semStack[$stackPos-(1-1)]); - }, - 215 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(4-2)]; - }, - 216 => function ($stackPos) { - $this->semValue = array(); - }, - 217 => function ($stackPos) { - $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; - }, - 218 => function ($stackPos) { - $this->semValue = new Stmt\ElseIf_($this->semStack[$stackPos-(3-2)], is_array($this->semStack[$stackPos-(3-3)]) ? $this->semStack[$stackPos-(3-3)] : array($this->semStack[$stackPos-(3-3)]), $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 219 => function ($stackPos) { - $this->semValue = array(); - }, - 220 => function ($stackPos) { - $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; - }, - 221 => function ($stackPos) { - $this->semValue = new Stmt\ElseIf_($this->semStack[$stackPos-(4-2)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 222 => function ($stackPos) { - $this->semValue = null; - }, - 223 => function ($stackPos) { - $this->semValue = new Stmt\Else_(is_array($this->semStack[$stackPos-(2-2)]) ? $this->semStack[$stackPos-(2-2)] : array($this->semStack[$stackPos-(2-2)]), $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 224 => function ($stackPos) { - $this->semValue = null; - }, - 225 => function ($stackPos) { - $this->semValue = new Stmt\Else_($this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 226 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)], false); - }, - 227 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(2-2)], true); - }, - 228 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)], false); - }, - 229 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 230 => function ($stackPos) { - $this->semValue = array(); - }, - 231 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 232 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; - }, - 233 => function ($stackPos) { - $this->semValue = new Node\Param($this->semStack[$stackPos-(4-4)], null, $this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-2)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); $this->checkParam($this->semValue); - }, - 234 => function ($stackPos) { - $this->semValue = new Node\Param($this->semStack[$stackPos-(6-4)], $this->semStack[$stackPos-(6-6)], $this->semStack[$stackPos-(6-1)], $this->semStack[$stackPos-(6-2)], $this->semStack[$stackPos-(6-3)], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); $this->checkParam($this->semValue); - }, - 235 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 236 => function ($stackPos) { - $this->semValue = new Node\Identifier('array', $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 237 => function ($stackPos) { - $this->semValue = new Node\Identifier('callable', $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 238 => function ($stackPos) { - $this->semValue = null; - }, - 239 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 240 => function ($stackPos) { - $this->semValue = null; - }, - 241 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-2)]; - }, - 242 => function ($stackPos) { - $this->semValue = array(); - }, - 243 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; - }, - 244 => function ($stackPos) { - $this->semValue = array(new Node\Arg($this->semStack[$stackPos-(3-2)], false, false, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes)); - }, - 245 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 246 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; - }, - 247 => function ($stackPos) { - $this->semValue = new Node\Arg($this->semStack[$stackPos-(1-1)], false, false, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 248 => function ($stackPos) { - $this->semValue = new Node\Arg($this->semStack[$stackPos-(2-2)], true, false, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 249 => function ($stackPos) { - $this->semValue = new Node\Arg($this->semStack[$stackPos-(2-2)], false, true, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 250 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; - }, - 251 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 252 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 253 => function ($stackPos) { - $this->semValue = new Expr\Variable($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 254 => function ($stackPos) { - $this->semValue = new Expr\Variable($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 255 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; - }, - 256 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 257 => function ($stackPos) { - $this->semValue = new Stmt\StaticVar($this->semStack[$stackPos-(1-1)], null, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 258 => function ($stackPos) { - $this->semValue = new Stmt\StaticVar($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 259 => function ($stackPos) { - if ($this->semStack[$stackPos-(2-2)] !== null) { $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; } - }, - 260 => function ($stackPos) { - $this->semValue = array(); - }, - 261 => function ($stackPos) { - $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); } else { $nop = null; }; - if ($nop !== null) { $this->semStack[$stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 262 => function ($stackPos) { - $this->semValue = new Stmt\Property($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); $this->checkProperty($this->semValue, $stackPos-(3-1)); - }, - 263 => function ($stackPos) { - $this->semValue = new Stmt\ClassConst($this->semStack[$stackPos-(3-2)], 0, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 264 => function ($stackPos) { - $this->semValue = new Stmt\ClassMethod($this->semStack[$stackPos-(9-4)], ['type' => $this->semStack[$stackPos-(9-1)], 'byRef' => $this->semStack[$stackPos-(9-3)], 'params' => $this->semStack[$stackPos-(9-6)], 'returnType' => $this->semStack[$stackPos-(9-8)], 'stmts' => $this->semStack[$stackPos-(9-9)]], $this->startAttributeStack[$stackPos-(9-1)] + $this->endAttributes); - $this->checkClassMethod($this->semValue, $stackPos-(9-1)); - }, - 265 => function ($stackPos) { - $this->semValue = new Stmt\TraitUse($this->semStack[$stackPos-(3-2)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 266 => function ($stackPos) { - $this->semValue = array(); - }, - 267 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; - }, - 268 => function ($stackPos) { - $this->semValue = array(); - }, - 269 => function ($stackPos) { - $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; - }, - 270 => function ($stackPos) { - $this->semValue = new Stmt\TraitUseAdaptation\Precedence($this->semStack[$stackPos-(4-1)][0], $this->semStack[$stackPos-(4-1)][1], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 271 => function ($stackPos) { - $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos-(5-1)][0], $this->semStack[$stackPos-(5-1)][1], $this->semStack[$stackPos-(5-3)], $this->semStack[$stackPos-(5-4)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); - }, - 272 => function ($stackPos) { - $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos-(4-1)][0], $this->semStack[$stackPos-(4-1)][1], $this->semStack[$stackPos-(4-3)], null, $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 273 => function ($stackPos) { - $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos-(4-1)][0], $this->semStack[$stackPos-(4-1)][1], null, $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 274 => function ($stackPos) { - $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos-(4-1)][0], $this->semStack[$stackPos-(4-1)][1], null, $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 275 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)]); - }, - 276 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 277 => function ($stackPos) { - $this->semValue = array(null, $this->semStack[$stackPos-(1-1)]); - }, - 278 => function ($stackPos) { - $this->semValue = null; - }, - 279 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; - }, - 280 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 281 => function ($stackPos) { - $this->semValue = 0; - }, - 282 => function ($stackPos) { - $this->semValue = 0; - }, - 283 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 284 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 285 => function ($stackPos) { - $this->checkModifier($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)], $stackPos-(2-2)); $this->semValue = $this->semStack[$stackPos-(2-1)] | $this->semStack[$stackPos-(2-2)]; - }, - 286 => function ($stackPos) { - $this->semValue = Stmt\Class_::MODIFIER_PUBLIC; - }, - 287 => function ($stackPos) { - $this->semValue = Stmt\Class_::MODIFIER_PROTECTED; - }, - 288 => function ($stackPos) { - $this->semValue = Stmt\Class_::MODIFIER_PRIVATE; - }, - 289 => function ($stackPos) { - $this->semValue = Stmt\Class_::MODIFIER_STATIC; - }, - 290 => function ($stackPos) { - $this->semValue = Stmt\Class_::MODIFIER_ABSTRACT; - }, - 291 => function ($stackPos) { - $this->semValue = Stmt\Class_::MODIFIER_FINAL; - }, - 292 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 293 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; - }, - 294 => function ($stackPos) { - $this->semValue = new Node\VarLikeIdentifier(substr($this->semStack[$stackPos-(1-1)], 1), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 295 => function ($stackPos) { - $this->semValue = new Stmt\PropertyProperty($this->semStack[$stackPos-(1-1)], null, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 296 => function ($stackPos) { - $this->semValue = new Stmt\PropertyProperty($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 297 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; - }, - 298 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 299 => function ($stackPos) { - $this->semValue = array(); - }, - 300 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 301 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 302 => function ($stackPos) { - $this->semValue = new Expr\Assign($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 303 => function ($stackPos) { - $this->semValue = new Expr\Assign($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 304 => function ($stackPos) { - $this->semValue = new Expr\AssignRef($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 305 => function ($stackPos) { - $this->semValue = new Expr\AssignRef($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 306 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 307 => function ($stackPos) { - $this->semValue = new Expr\Clone_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 308 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\Plus($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 309 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\Minus($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 310 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\Mul($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 311 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\Div($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 312 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\Concat($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 313 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\Mod($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 314 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\BitwiseAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 315 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\BitwiseOr($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 316 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\BitwiseXor($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 317 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\ShiftLeft($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 318 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\ShiftRight($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 319 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\Pow($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 320 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\Coalesce($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 321 => function ($stackPos) { - $this->semValue = new Expr\PostInc($this->semStack[$stackPos-(2-1)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 322 => function ($stackPos) { - $this->semValue = new Expr\PreInc($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 323 => function ($stackPos) { - $this->semValue = new Expr\PostDec($this->semStack[$stackPos-(2-1)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 324 => function ($stackPos) { - $this->semValue = new Expr\PreDec($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 325 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\BooleanOr($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 326 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\BooleanAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 327 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\LogicalOr($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 328 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\LogicalAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 329 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\LogicalXor($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 330 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\BitwiseOr($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 331 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 332 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 333 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\BitwiseXor($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 334 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Concat($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 335 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Plus($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 336 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Minus($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 337 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Mul($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 338 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Div($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 339 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Mod($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 340 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\ShiftLeft($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 341 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\ShiftRight($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 342 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Pow($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 343 => function ($stackPos) { - $this->semValue = new Expr\UnaryPlus($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 344 => function ($stackPos) { - $this->semValue = new Expr\UnaryMinus($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 345 => function ($stackPos) { - $this->semValue = new Expr\BooleanNot($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 346 => function ($stackPos) { - $this->semValue = new Expr\BitwiseNot($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 347 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Identical($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 348 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\NotIdentical($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 349 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Equal($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 350 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\NotEqual($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 351 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Spaceship($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 352 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Smaller($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 353 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\SmallerOrEqual($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 354 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Greater($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 355 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\GreaterOrEqual($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 356 => function ($stackPos) { - $this->semValue = new Expr\Instanceof_($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 357 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 358 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; - }, - 359 => function ($stackPos) { - $this->semValue = new Expr\Ternary($this->semStack[$stackPos-(5-1)], $this->semStack[$stackPos-(5-3)], $this->semStack[$stackPos-(5-5)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); - }, - 360 => function ($stackPos) { - $this->semValue = new Expr\Ternary($this->semStack[$stackPos-(4-1)], null, $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 361 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Coalesce($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 362 => function ($stackPos) { - $this->semValue = new Expr\Isset_($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 363 => function ($stackPos) { - $this->semValue = new Expr\Empty_($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 364 => function ($stackPos) { - $this->semValue = new Expr\Include_($this->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_INCLUDE, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 365 => function ($stackPos) { - $this->semValue = new Expr\Include_($this->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_INCLUDE_ONCE, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 366 => function ($stackPos) { - $this->semValue = new Expr\Eval_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 367 => function ($stackPos) { - $this->semValue = new Expr\Include_($this->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_REQUIRE, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 368 => function ($stackPos) { - $this->semValue = new Expr\Include_($this->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_REQUIRE_ONCE, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 369 => function ($stackPos) { - $this->semValue = new Expr\Cast\Int_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 370 => function ($stackPos) { - $attrs = $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes; - $attrs['kind'] = $this->getFloatCastKind($this->semStack[$stackPos-(2-1)]); - $this->semValue = new Expr\Cast\Double($this->semStack[$stackPos-(2-2)], $attrs); - }, - 371 => function ($stackPos) { - $this->semValue = new Expr\Cast\String_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 372 => function ($stackPos) { - $this->semValue = new Expr\Cast\Array_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 373 => function ($stackPos) { - $this->semValue = new Expr\Cast\Object_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 374 => function ($stackPos) { - $this->semValue = new Expr\Cast\Bool_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 375 => function ($stackPos) { - $this->semValue = new Expr\Cast\Unset_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 376 => function ($stackPos) { - $attrs = $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes; - $attrs['kind'] = strtolower($this->semStack[$stackPos-(2-1)]) === 'exit' ? Expr\Exit_::KIND_EXIT : Expr\Exit_::KIND_DIE; - $this->semValue = new Expr\Exit_($this->semStack[$stackPos-(2-2)], $attrs); - }, - 377 => function ($stackPos) { - $this->semValue = new Expr\ErrorSuppress($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 378 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 379 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 380 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 381 => function ($stackPos) { - $this->semValue = new Expr\ShellExec($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 382 => function ($stackPos) { - $this->semValue = new Expr\Print_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 383 => function ($stackPos) { - $this->semValue = new Expr\Yield_(null, null, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 384 => function ($stackPos) { - $this->semValue = new Expr\YieldFrom($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 385 => function ($stackPos) { - $this->semValue = new Expr\Closure(['static' => false, 'byRef' => $this->semStack[$stackPos-(10-2)], 'params' => $this->semStack[$stackPos-(10-4)], 'uses' => $this->semStack[$stackPos-(10-6)], 'returnType' => $this->semStack[$stackPos-(10-7)], 'stmts' => $this->semStack[$stackPos-(10-9)]], $this->startAttributeStack[$stackPos-(10-1)] + $this->endAttributes); - }, - 386 => function ($stackPos) { - $this->semValue = new Expr\Closure(['static' => true, 'byRef' => $this->semStack[$stackPos-(11-3)], 'params' => $this->semStack[$stackPos-(11-5)], 'uses' => $this->semStack[$stackPos-(11-7)], 'returnType' => $this->semStack[$stackPos-(11-8)], 'stmts' => $this->semStack[$stackPos-(11-10)]], $this->startAttributeStack[$stackPos-(11-1)] + $this->endAttributes); - }, - 387 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; - }, - 388 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; - }, - 389 => function ($stackPos) { - $this->semValue = new Expr\Yield_($this->semStack[$stackPos-(2-2)], null, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 390 => function ($stackPos) { - $this->semValue = new Expr\Yield_($this->semStack[$stackPos-(4-4)], $this->semStack[$stackPos-(4-2)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 391 => function ($stackPos) { - $attrs = $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes; $attrs['kind'] = Expr\Array_::KIND_LONG; - $this->semValue = new Expr\Array_($this->semStack[$stackPos-(4-3)], $attrs); - }, - 392 => function ($stackPos) { - $attrs = $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes; $attrs['kind'] = Expr\Array_::KIND_SHORT; - $this->semValue = new Expr\Array_($this->semStack[$stackPos-(3-2)], $attrs); - }, - 393 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 394 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch(Scalar\String_::fromString($this->semStack[$stackPos-(4-1)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes), $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 395 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 396 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 397 => function ($stackPos) { - $this->semValue = array(new Stmt\Class_(null, ['type' => 0, 'extends' => $this->semStack[$stackPos-(7-3)], 'implements' => $this->semStack[$stackPos-(7-4)], 'stmts' => $this->semStack[$stackPos-(7-6)]], $this->startAttributeStack[$stackPos-(7-1)] + $this->endAttributes), $this->semStack[$stackPos-(7-2)]); - $this->checkClass($this->semValue[0], -1); - }, - 398 => function ($stackPos) { - $this->semValue = new Expr\New_($this->semStack[$stackPos-(3-2)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 399 => function ($stackPos) { - list($class, $ctorArgs) = $this->semStack[$stackPos-(2-2)]; $this->semValue = new Expr\New_($class, $ctorArgs, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 400 => function ($stackPos) { - $this->semValue = array(); - }, - 401 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(4-3)]; - }, - 402 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 403 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; - }, - 404 => function ($stackPos) { - $this->semValue = new Expr\ClosureUse($this->semStack[$stackPos-(2-2)], $this->semStack[$stackPos-(2-1)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 405 => function ($stackPos) { - $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 406 => function ($stackPos) { - $this->semValue = new Expr\FuncCall($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 407 => function ($stackPos) { - $this->semValue = new Expr\FuncCall($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 408 => function ($stackPos) { - $this->semValue = new Expr\StaticCall($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 409 => function ($stackPos) { - $this->semValue = new Expr\StaticCall($this->semStack[$stackPos-(6-1)], $this->semStack[$stackPos-(6-4)], $this->semStack[$stackPos-(6-6)], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); - }, - 410 => function ($stackPos) { - $this->semValue = $this->fixupPhp5StaticPropCall($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 411 => function ($stackPos) { - $this->semValue = new Expr\FuncCall($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 412 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 413 => function ($stackPos) { - $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 414 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 415 => function ($stackPos) { - $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 416 => function ($stackPos) { - $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 417 => function ($stackPos) { - $this->semValue = new Name\FullyQualified(substr($this->semStack[$stackPos-(1-1)], 1), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 418 => function ($stackPos) { - $this->semValue = new Name\Relative(substr($this->semStack[$stackPos-(1-1)], 10), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 419 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 420 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 421 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 422 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 423 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 424 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 425 => function ($stackPos) { - $this->semValue = new Expr\PropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 426 => function ($stackPos) { - $this->semValue = new Expr\PropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 427 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 428 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 429 => function ($stackPos) { - $this->semValue = null; - }, - 430 => function ($stackPos) { - $this->semValue = null; - }, - 431 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 432 => function ($stackPos) { - $this->semValue = array(); - }, - 433 => function ($stackPos) { - $this->semValue = array(new Scalar\EncapsedStringPart(Scalar\String_::parseEscapeSequences($this->semStack[$stackPos-(1-1)], '`', false), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes)); - }, - 434 => function ($stackPos) { - foreach ($this->semStack[$stackPos-(1-1)] as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) { $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, '`', false); } }; $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 435 => function ($stackPos) { - $this->semValue = array(); - }, - 436 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 437 => function ($stackPos) { - $this->semValue = $this->parseLNumber($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes, true); - }, - 438 => function ($stackPos) { - $this->semValue = Scalar\DNumber::fromString($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 439 => function ($stackPos) { - $this->semValue = Scalar\String_::fromString($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes, false); - }, - 440 => function ($stackPos) { - $this->semValue = new Scalar\MagicConst\Line($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 441 => function ($stackPos) { - $this->semValue = new Scalar\MagicConst\File($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 442 => function ($stackPos) { - $this->semValue = new Scalar\MagicConst\Dir($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 443 => function ($stackPos) { - $this->semValue = new Scalar\MagicConst\Class_($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 444 => function ($stackPos) { - $this->semValue = new Scalar\MagicConst\Trait_($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 445 => function ($stackPos) { - $this->semValue = new Scalar\MagicConst\Method($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 446 => function ($stackPos) { - $this->semValue = new Scalar\MagicConst\Function_($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 447 => function ($stackPos) { - $this->semValue = new Scalar\MagicConst\Namespace_($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 448 => function ($stackPos) { - $this->semValue = $this->parseDocString($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-2)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes, $this->startAttributeStack[$stackPos-(3-3)] + $this->endAttributeStack[$stackPos-(3-3)], false); - }, - 449 => function ($stackPos) { - $this->semValue = $this->parseDocString($this->semStack[$stackPos-(2-1)], '', $this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes, $this->startAttributeStack[$stackPos-(2-2)] + $this->endAttributeStack[$stackPos-(2-2)], false); - }, - 450 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 451 => function ($stackPos) { - $this->semValue = new Expr\ClassConstFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 452 => function ($stackPos) { - $this->semValue = new Expr\ConstFetch($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 453 => function ($stackPos) { - $this->semValue = new Expr\Array_($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 454 => function ($stackPos) { - $this->semValue = new Expr\Array_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 455 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 456 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\BooleanOr($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 457 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\BooleanAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 458 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\LogicalOr($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 459 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\LogicalAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 460 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\LogicalXor($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 461 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\BitwiseOr($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 462 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 463 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 464 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\BitwiseXor($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 465 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Concat($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 466 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Plus($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 467 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Minus($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 468 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Mul($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 469 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Div($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 470 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Mod($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 471 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\ShiftLeft($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 472 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\ShiftRight($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 473 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Pow($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 474 => function ($stackPos) { - $this->semValue = new Expr\UnaryPlus($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 475 => function ($stackPos) { - $this->semValue = new Expr\UnaryMinus($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 476 => function ($stackPos) { - $this->semValue = new Expr\BooleanNot($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 477 => function ($stackPos) { - $this->semValue = new Expr\BitwiseNot($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 478 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Identical($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 479 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\NotIdentical($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 480 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Equal($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 481 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\NotEqual($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 482 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Smaller($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 483 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\SmallerOrEqual($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 484 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Greater($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 485 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\GreaterOrEqual($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 486 => function ($stackPos) { - $this->semValue = new Expr\Ternary($this->semStack[$stackPos-(5-1)], $this->semStack[$stackPos-(5-3)], $this->semStack[$stackPos-(5-5)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); - }, - 487 => function ($stackPos) { - $this->semValue = new Expr\Ternary($this->semStack[$stackPos-(4-1)], null, $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 488 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 489 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; - }, - 490 => function ($stackPos) { - $this->semValue = new Expr\ConstFetch($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 491 => function ($stackPos) { - $this->semValue = new Expr\ClassConstFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 492 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 493 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 494 => function ($stackPos) { - $attrs = $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes; $attrs['kind'] = Scalar\String_::KIND_DOUBLE_QUOTED; - foreach ($this->semStack[$stackPos-(3-2)] as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) { $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, '"', true); } }; $this->semValue = new Scalar\Encapsed($this->semStack[$stackPos-(3-2)], $attrs); - }, - 495 => function ($stackPos) { - $this->semValue = $this->parseDocString($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-2)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes, $this->startAttributeStack[$stackPos-(3-3)] + $this->endAttributeStack[$stackPos-(3-3)], true); - }, - 496 => function ($stackPos) { - $this->semValue = array(); - }, - 497 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-1)]; - }, - 498 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 499 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 500 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; - }, - 501 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 502 => function ($stackPos) { - $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(3-3)], $this->semStack[$stackPos-(3-1)], false, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 503 => function ($stackPos) { - $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(1-1)], null, false, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 504 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 505 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 506 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 507 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 508 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(6-2)], $this->semStack[$stackPos-(6-5)], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); - }, - 509 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 510 => function ($stackPos) { - $this->semValue = new Expr\PropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 511 => function ($stackPos) { - $this->semValue = new Expr\MethodCall($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 512 => function ($stackPos) { - $this->semValue = new Expr\FuncCall($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 513 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 514 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 515 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 516 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; - }, - 517 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 518 => function ($stackPos) { - $this->semValue = new Expr\Variable($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 519 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 520 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 521 => function ($stackPos) { - $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 522 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 523 => function ($stackPos) { - $var = substr($this->semStack[$stackPos-(1-1)], 1); $this->semValue = \is_string($var) ? new Node\VarLikeIdentifier($var, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes) : $var; - }, - 524 => function ($stackPos) { - $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 525 => function ($stackPos) { - $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$stackPos-(6-1)], $this->semStack[$stackPos-(6-5)], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); - }, - 526 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 527 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 528 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 529 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 530 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 531 => function ($stackPos) { - $this->semValue = new Expr\Variable($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 532 => function ($stackPos) { - $this->semValue = null; - }, - 533 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 534 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 535 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; - }, - 536 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 537 => function ($stackPos) { - $this->semValue = new Expr\Error($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); $this->errorState = 2; - }, - 538 => function ($stackPos) { - $this->semValue = new Expr\List_($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 539 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; - }, - 540 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 541 => function ($stackPos) { - $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(1-1)], null, false, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 542 => function ($stackPos) { - $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(1-1)], null, false, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 543 => function ($stackPos) { - $this->semValue = null; - }, - 544 => function ($stackPos) { - $this->semValue = array(); - }, - 545 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-1)]; - }, - 546 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; - }, - 547 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 548 => function ($stackPos) { - $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(3-3)], $this->semStack[$stackPos-(3-1)], false, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 549 => function ($stackPos) { - $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(1-1)], null, false, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 550 => function ($stackPos) { - $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(4-4)], $this->semStack[$stackPos-(4-1)], true, $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 551 => function ($stackPos) { - $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(2-2)], null, true, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 552 => function ($stackPos) { - $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(2-2)], null, false, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes, true); - }, - 553 => function ($stackPos) { - $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; - }, - 554 => function ($stackPos) { - $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; - }, - 555 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 556 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)]); - }, - 557 => function ($stackPos) { - $this->semValue = new Scalar\EncapsedStringPart($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 558 => function ($stackPos) { - $this->semValue = new Expr\Variable($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 559 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 560 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 561 => function ($stackPos) { - $this->semValue = new Expr\PropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 562 => function ($stackPos) { - $this->semValue = new Expr\Variable($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 563 => function ($stackPos) { - $this->semValue = new Expr\Variable($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 564 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(6-2)], $this->semStack[$stackPos-(6-4)], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); - }, - 565 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; - }, - 566 => function ($stackPos) { - $this->semValue = new Scalar\String_($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 567 => function ($stackPos) { - $this->semValue = $this->parseNumString($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 568 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - ]; - } -} diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Parser/Php7.php b/src/ncc/ThirdParty/nikic/PhpParser/Parser/Php7.php index a5ab49d..aeae506 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Parser/Php7.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Parser/Php7.php @@ -1,8 +1,9 @@ -reduceCallbacks = [ - 0 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 1 => function ($stackPos) { - $this->semValue = $this->handleNamespaces($this->semStack[$stackPos-(1-1)]); - }, - 2 => function ($stackPos) { - if (is_array($this->semStack[$stackPos-(2-2)])) { $this->semValue = array_merge($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)]); } else { $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; }; - }, - 3 => function ($stackPos) { - $this->semValue = array(); - }, - 4 => function ($stackPos) { - $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); } else { $nop = null; }; - if ($nop !== null) { $this->semStack[$stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 5 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 6 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 7 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 8 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 9 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 10 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 11 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 12 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 13 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 14 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 15 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 16 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 17 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 18 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 19 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 20 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 21 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 22 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 23 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 24 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 25 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 26 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 27 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 28 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 29 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 30 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 31 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 32 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 33 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 34 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 35 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 36 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 37 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 38 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 39 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 40 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 41 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 42 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 43 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 44 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 45 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 46 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 47 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 48 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 49 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 50 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 51 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 52 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 53 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 54 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 55 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 56 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 57 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 58 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 59 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 60 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 61 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 62 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 63 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 64 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 65 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 66 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 67 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 68 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 69 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 70 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 71 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 72 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 73 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 74 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 75 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 76 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 77 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 78 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 79 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 80 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 81 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 82 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 83 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 84 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 85 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 86 => function ($stackPos) { - $this->semValue = new Node\Identifier($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 87 => function ($stackPos) { - $this->semValue = new Node\Identifier($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 88 => function ($stackPos) { - $this->semValue = new Node\Identifier($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 89 => function ($stackPos) { - $this->semValue = new Node\Identifier($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 90 => function ($stackPos) { - $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 91 => function ($stackPos) { - $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 92 => function ($stackPos) { - $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 93 => function ($stackPos) { - $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 94 => function ($stackPos) { - $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 95 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 96 => function ($stackPos) { - $this->semValue = new Name(substr($this->semStack[$stackPos-(1-1)], 1), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 97 => function ($stackPos) { - $this->semValue = new Expr\Variable(substr($this->semStack[$stackPos-(1-1)], 1), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 98 => function ($stackPos) { + 0 => null, + 1 => static function ($self, $stackPos) { + $self->semValue = $self->handleNamespaces($self->semStack[$stackPos-(1-1)]); + }, + 2 => static function ($self, $stackPos) { + if ($self->semStack[$stackPos-(2-2)] !== null) { $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; } $self->semValue = $self->semStack[$stackPos-(2-1)];; + }, + 3 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 4 => static function ($self, $stackPos) { + $nop = $self->maybeCreateZeroLengthNop($self->tokenPos);; + if ($nop !== null) { $self->semStack[$stackPos-(1-1)][] = $nop; } $self->semValue = $self->semStack[$stackPos-(1-1)]; + }, + 5 => null, + 6 => null, + 7 => null, + 8 => null, + 9 => null, + 10 => null, + 11 => null, + 12 => null, + 13 => null, + 14 => null, + 15 => null, + 16 => null, + 17 => null, + 18 => null, + 19 => null, + 20 => null, + 21 => null, + 22 => null, + 23 => null, + 24 => null, + 25 => null, + 26 => null, + 27 => null, + 28 => null, + 29 => null, + 30 => null, + 31 => null, + 32 => null, + 33 => null, + 34 => null, + 35 => null, + 36 => null, + 37 => null, + 38 => null, + 39 => null, + 40 => null, + 41 => null, + 42 => null, + 43 => null, + 44 => null, + 45 => null, + 46 => null, + 47 => null, + 48 => null, + 49 => null, + 50 => null, + 51 => null, + 52 => null, + 53 => null, + 54 => null, + 55 => null, + 56 => null, + 57 => null, + 58 => null, + 59 => null, + 60 => null, + 61 => null, + 62 => null, + 63 => null, + 64 => null, + 65 => null, + 66 => null, + 67 => null, + 68 => null, + 69 => null, + 70 => null, + 71 => null, + 72 => null, + 73 => null, + 74 => null, + 75 => null, + 76 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(1-1)]; if ($self->semValue === "emitError(new Error('Cannot use "getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos]))); + }, + 77 => null, + 78 => null, + 79 => null, + 80 => null, + 81 => null, + 82 => null, + 83 => null, + 84 => null, + 85 => static function ($self, $stackPos) { + $self->semValue = new Node\Identifier($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 86 => static function ($self, $stackPos) { + $self->semValue = new Node\Identifier($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 87 => static function ($self, $stackPos) { + $self->semValue = new Node\Identifier($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 88 => static function ($self, $stackPos) { + $self->semValue = new Node\Identifier($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 89 => static function ($self, $stackPos) { + $self->semValue = new Name($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 90 => static function ($self, $stackPos) { + $self->semValue = new Name($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 91 => static function ($self, $stackPos) { + $self->semValue = new Name($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 92 => static function ($self, $stackPos) { + $self->semValue = new Name($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 93 => static function ($self, $stackPos) { + $self->semValue = new Name($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 94 => null, + 95 => static function ($self, $stackPos) { + $self->semValue = new Name(substr($self->semStack[$stackPos-(1-1)], 1), $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 96 => static function ($self, $stackPos) { + $self->semValue = new Expr\Variable(substr($self->semStack[$stackPos-(1-1)], 1), $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 97 => static function ($self, $stackPos) { /* nothing */ }, - 99 => function ($stackPos) { + 98 => static function ($self, $stackPos) { /* nothing */ }, - 100 => function ($stackPos) { + 99 => static function ($self, $stackPos) { /* nothing */ }, - 101 => function ($stackPos) { - $this->emitError(new Error('A trailing comma is not allowed here', $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes)); + 100 => static function ($self, $stackPos) { + $self->emitError(new Error('A trailing comma is not allowed here', $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos]))); }, - 102 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; + 101 => null, + 102 => null, + 103 => static function ($self, $stackPos) { + $self->semValue = new Node\Attribute($self->semStack[$stackPos-(1-1)], [], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 103 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; + 104 => static function ($self, $stackPos) { + $self->semValue = new Node\Attribute($self->semStack[$stackPos-(2-1)], $self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 104 => function ($stackPos) { - $this->semValue = new Node\Attribute($this->semStack[$stackPos-(1-1)], [], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + 105 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); }, - 105 => function ($stackPos) { - $this->semValue = new Node\Attribute($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + 106 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; }, - 106 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); + 107 => static function ($self, $stackPos) { + $self->semValue = new Node\AttributeGroup($self->semStack[$stackPos-(4-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, - 107 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + 108 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); }, - 108 => function ($stackPos) { - $this->semValue = new Node\AttributeGroup($this->semStack[$stackPos-(4-2)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + 109 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; $self->semValue = $self->semStack[$stackPos-(2-1)]; }, - 109 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); + 110 => static function ($self, $stackPos) { + $self->semValue = []; }, - 110 => function ($stackPos) { - $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; + 111 => null, + 112 => null, + 113 => null, + 114 => null, + 115 => static function ($self, $stackPos) { + $self->semValue = new Stmt\HaltCompiler($self->handleHaltCompiler(), $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, - 111 => function ($stackPos) { - $this->semValue = []; + 116 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Namespace_($self->semStack[$stackPos-(3-2)], null, $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + $self->semValue->setAttribute('kind', Stmt\Namespace_::KIND_SEMICOLON); + $self->checkNamespace($self->semValue); }, - 112 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; + 117 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Namespace_($self->semStack[$stackPos-(5-2)], $self->semStack[$stackPos-(5-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); + $self->semValue->setAttribute('kind', Stmt\Namespace_::KIND_BRACED); + $self->checkNamespace($self->semValue); }, - 113 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; + 118 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Namespace_(null, $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + $self->semValue->setAttribute('kind', Stmt\Namespace_::KIND_BRACED); + $self->checkNamespace($self->semValue); }, - 114 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; + 119 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Use_($self->semStack[$stackPos-(3-2)], Stmt\Use_::TYPE_NORMAL, $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 115 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; + 120 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Use_($self->semStack[$stackPos-(4-3)], $self->semStack[$stackPos-(4-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, - 116 => function ($stackPos) { - $this->semValue = new Stmt\HaltCompiler($this->lexer->handleHaltCompiler(), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + 121 => null, + 122 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Const_($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 117 => function ($stackPos) { - $this->semValue = new Stmt\Namespace_($this->semStack[$stackPos-(3-2)], null, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - $this->semValue->setAttribute('kind', Stmt\Namespace_::KIND_SEMICOLON); - $this->checkNamespace($this->semValue); + 123 => static function ($self, $stackPos) { + $self->semValue = Stmt\Use_::TYPE_FUNCTION; }, - 118 => function ($stackPos) { - $this->semValue = new Stmt\Namespace_($this->semStack[$stackPos-(5-2)], $this->semStack[$stackPos-(5-4)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); - $this->semValue->setAttribute('kind', Stmt\Namespace_::KIND_BRACED); - $this->checkNamespace($this->semValue); + 124 => static function ($self, $stackPos) { + $self->semValue = Stmt\Use_::TYPE_CONSTANT; }, - 119 => function ($stackPos) { - $this->semValue = new Stmt\Namespace_(null, $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - $this->semValue->setAttribute('kind', Stmt\Namespace_::KIND_BRACED); - $this->checkNamespace($this->semValue); + 125 => static function ($self, $stackPos) { + $self->semValue = new Stmt\GroupUse($self->semStack[$stackPos-(7-3)], $self->semStack[$stackPos-(7-6)], $self->semStack[$stackPos-(7-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(7-1)], $self->tokenEndStack[$stackPos])); }, - 120 => function ($stackPos) { - $this->semValue = new Stmt\Use_($this->semStack[$stackPos-(3-2)], Stmt\Use_::TYPE_NORMAL, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + 126 => static function ($self, $stackPos) { + $self->semValue = new Stmt\GroupUse($self->semStack[$stackPos-(6-2)], $self->semStack[$stackPos-(6-5)], Stmt\Use_::TYPE_UNKNOWN, $self->getAttributes($self->tokenStartStack[$stackPos-(6-1)], $self->tokenEndStack[$stackPos])); }, - 121 => function ($stackPos) { - $this->semValue = new Stmt\Use_($this->semStack[$stackPos-(4-3)], $this->semStack[$stackPos-(4-2)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + 127 => null, + 128 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; }, - 122 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-1)]; + 129 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); }, - 123 => function ($stackPos) { - $this->semValue = new Stmt\Const_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + 130 => null, + 131 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; }, - 124 => function ($stackPos) { - $this->semValue = Stmt\Use_::TYPE_FUNCTION; + 132 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); }, - 125 => function ($stackPos) { - $this->semValue = Stmt\Use_::TYPE_CONSTANT; + 133 => null, + 134 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; }, - 126 => function ($stackPos) { - $this->semValue = new Stmt\GroupUse($this->semStack[$stackPos-(7-3)], $this->semStack[$stackPos-(7-6)], $this->semStack[$stackPos-(7-2)], $this->startAttributeStack[$stackPos-(7-1)] + $this->endAttributes); + 135 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); }, - 127 => function ($stackPos) { - $this->semValue = new Stmt\GroupUse($this->semStack[$stackPos-(6-2)], $this->semStack[$stackPos-(6-5)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); + 136 => static function ($self, $stackPos) { + $self->semValue = new Node\UseItem($self->semStack[$stackPos-(1-1)], null, Stmt\Use_::TYPE_UNKNOWN, $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); $self->checkUseUse($self->semValue, $stackPos-(1-1)); }, - 128 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-1)]; + 137 => static function ($self, $stackPos) { + $self->semValue = new Node\UseItem($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], Stmt\Use_::TYPE_UNKNOWN, $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); $self->checkUseUse($self->semValue, $stackPos-(3-3)); }, - 129 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + 138 => static function ($self, $stackPos) { + $self->semValue = new Node\UseItem($self->semStack[$stackPos-(1-1)], null, Stmt\Use_::TYPE_UNKNOWN, $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); $self->checkUseUse($self->semValue, $stackPos-(1-1)); }, - 130 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); + 139 => static function ($self, $stackPos) { + $self->semValue = new Node\UseItem($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], Stmt\Use_::TYPE_UNKNOWN, $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); $self->checkUseUse($self->semValue, $stackPos-(3-3)); }, - 131 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-1)]; + 140 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(1-1)]; $self->semValue->type = Stmt\Use_::TYPE_NORMAL; }, - 132 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + 141 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(2-2)]; $self->semValue->type = $self->semStack[$stackPos-(2-1)]; }, - 133 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); + 142 => null, + 143 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; }, - 134 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-1)]; + 144 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); }, - 135 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + 145 => static function ($self, $stackPos) { + $self->semValue = new Node\Const_($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 136 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); + 146 => null, + 147 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; }, - 137 => function ($stackPos) { - $this->semValue = new Stmt\UseUse($this->semStack[$stackPos-(1-1)], null, Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos-(1-1)); + 148 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); }, - 138 => function ($stackPos) { - $this->semValue = new Stmt\UseUse($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos-(3-3)); + 149 => static function ($self, $stackPos) { + $self->semValue = new Node\Const_(new Node\Identifier($self->semStack[$stackPos-(3-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos-(3-1)])), $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 139 => function ($stackPos) { - $this->semValue = new Stmt\UseUse($this->semStack[$stackPos-(1-1)], null, Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos-(1-1)); + 150 => static function ($self, $stackPos) { + $self->semValue = new Node\Const_(new Node\Identifier($self->semStack[$stackPos-(3-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos-(3-1)])), $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 140 => function ($stackPos) { - $this->semValue = new Stmt\UseUse($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); $this->checkUseUse($this->semValue, $stackPos-(3-3)); + 151 => static function ($self, $stackPos) { + if ($self->semStack[$stackPos-(2-2)] !== null) { $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; } $self->semValue = $self->semStack[$stackPos-(2-1)];; }, - 141 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; $this->semValue->type = Stmt\Use_::TYPE_NORMAL; + 152 => static function ($self, $stackPos) { + $self->semValue = array(); }, - 142 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-2)]; $this->semValue->type = $this->semStack[$stackPos-(2-1)]; + 153 => static function ($self, $stackPos) { + $nop = $self->maybeCreateZeroLengthNop($self->tokenPos);; + if ($nop !== null) { $self->semStack[$stackPos-(1-1)][] = $nop; } $self->semValue = $self->semStack[$stackPos-(1-1)]; }, - 143 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-1)]; + 154 => null, + 155 => null, + 156 => null, + 157 => static function ($self, $stackPos) { + throw new Error('__HALT_COMPILER() can only be used from the outermost scope', $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 144 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + 158 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Block($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 145 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); + 159 => static function ($self, $stackPos) { + $self->semValue = new Stmt\If_($self->semStack[$stackPos-(7-3)], ['stmts' => $self->semStack[$stackPos-(7-5)], 'elseifs' => $self->semStack[$stackPos-(7-6)], 'else' => $self->semStack[$stackPos-(7-7)]], $self->getAttributes($self->tokenStartStack[$stackPos-(7-1)], $self->tokenEndStack[$stackPos])); }, - 146 => function ($stackPos) { - $this->semValue = new Node\Const_($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + 160 => static function ($self, $stackPos) { + $self->semValue = new Stmt\If_($self->semStack[$stackPos-(10-3)], ['stmts' => $self->semStack[$stackPos-(10-6)], 'elseifs' => $self->semStack[$stackPos-(10-7)], 'else' => $self->semStack[$stackPos-(10-8)]], $self->getAttributes($self->tokenStartStack[$stackPos-(10-1)], $self->tokenEndStack[$stackPos])); }, - 147 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-1)]; + 161 => static function ($self, $stackPos) { + $self->semValue = new Stmt\While_($self->semStack[$stackPos-(5-3)], $self->semStack[$stackPos-(5-5)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); }, - 148 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + 162 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Do_($self->semStack[$stackPos-(7-5)], $self->semStack[$stackPos-(7-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(7-1)], $self->tokenEndStack[$stackPos])); }, - 149 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); + 163 => static function ($self, $stackPos) { + $self->semValue = new Stmt\For_(['init' => $self->semStack[$stackPos-(9-3)], 'cond' => $self->semStack[$stackPos-(9-5)], 'loop' => $self->semStack[$stackPos-(9-7)], 'stmts' => $self->semStack[$stackPos-(9-9)]], $self->getAttributes($self->tokenStartStack[$stackPos-(9-1)], $self->tokenEndStack[$stackPos])); }, - 150 => function ($stackPos) { - $this->semValue = new Node\Const_(new Node\Identifier($this->semStack[$stackPos-(3-1)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributeStack[$stackPos-(3-1)]), $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + 164 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Switch_($self->semStack[$stackPos-(5-3)], $self->semStack[$stackPos-(5-5)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); }, - 151 => function ($stackPos) { - $this->semValue = new Node\Const_(new Node\Identifier($this->semStack[$stackPos-(3-1)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributeStack[$stackPos-(3-1)]), $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + 165 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Break_($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 152 => function ($stackPos) { - if (is_array($this->semStack[$stackPos-(2-2)])) { $this->semValue = array_merge($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)]); } else { $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; }; + 166 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Continue_($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 153 => function ($stackPos) { - $this->semValue = array(); + 167 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Return_($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 154 => function ($stackPos) { - $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); } else { $nop = null; }; - if ($nop !== null) { $this->semStack[$stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$stackPos-(1-1)]; + 168 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Global_($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 155 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; + 169 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Static_($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 156 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; + 170 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Echo_($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 157 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 158 => function ($stackPos) { - throw new Error('__HALT_COMPILER() can only be used from the outermost scope', $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 159 => function ($stackPos) { + 171 => static function ($self, $stackPos) { - if ($this->semStack[$stackPos-(3-2)]) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; $attrs = $this->startAttributeStack[$stackPos-(3-1)]; $stmts = $this->semValue; if (!empty($attrs['comments'])) {$stmts[0]->setAttribute('comments', array_merge($attrs['comments'], $stmts[0]->getAttribute('comments', []))); }; - } else { - $startAttributes = $this->startAttributeStack[$stackPos-(3-1)]; if (isset($startAttributes['comments'])) { $this->semValue = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $this->semValue = null; }; - if (null === $this->semValue) { $this->semValue = array(); } - } + $self->semValue = new Stmt\InlineHTML($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + $self->semValue->setAttribute('hasLeadingNewline', $self->inlineHtmlHasLeadingNewline($stackPos-(1-1))); }, - 160 => function ($stackPos) { - $this->semValue = new Stmt\If_($this->semStack[$stackPos-(7-3)], ['stmts' => is_array($this->semStack[$stackPos-(7-5)]) ? $this->semStack[$stackPos-(7-5)] : array($this->semStack[$stackPos-(7-5)]), 'elseifs' => $this->semStack[$stackPos-(7-6)], 'else' => $this->semStack[$stackPos-(7-7)]], $this->startAttributeStack[$stackPos-(7-1)] + $this->endAttributes); + 172 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Expression($self->semStack[$stackPos-(2-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 161 => function ($stackPos) { - $this->semValue = new Stmt\If_($this->semStack[$stackPos-(10-3)], ['stmts' => $this->semStack[$stackPos-(10-6)], 'elseifs' => $this->semStack[$stackPos-(10-7)], 'else' => $this->semStack[$stackPos-(10-8)]], $this->startAttributeStack[$stackPos-(10-1)] + $this->endAttributes); + 173 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Unset_($self->semStack[$stackPos-(5-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); }, - 162 => function ($stackPos) { - $this->semValue = new Stmt\While_($this->semStack[$stackPos-(5-3)], $this->semStack[$stackPos-(5-5)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); + 174 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Foreach_($self->semStack[$stackPos-(7-3)], $self->semStack[$stackPos-(7-5)][0], ['keyVar' => null, 'byRef' => $self->semStack[$stackPos-(7-5)][1], 'stmts' => $self->semStack[$stackPos-(7-7)]], $self->getAttributes($self->tokenStartStack[$stackPos-(7-1)], $self->tokenEndStack[$stackPos])); }, - 163 => function ($stackPos) { - $this->semValue = new Stmt\Do_($this->semStack[$stackPos-(7-5)], is_array($this->semStack[$stackPos-(7-2)]) ? $this->semStack[$stackPos-(7-2)] : array($this->semStack[$stackPos-(7-2)]), $this->startAttributeStack[$stackPos-(7-1)] + $this->endAttributes); + 175 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Foreach_($self->semStack[$stackPos-(9-3)], $self->semStack[$stackPos-(9-7)][0], ['keyVar' => $self->semStack[$stackPos-(9-5)], 'byRef' => $self->semStack[$stackPos-(9-7)][1], 'stmts' => $self->semStack[$stackPos-(9-9)]], $self->getAttributes($self->tokenStartStack[$stackPos-(9-1)], $self->tokenEndStack[$stackPos])); }, - 164 => function ($stackPos) { - $this->semValue = new Stmt\For_(['init' => $this->semStack[$stackPos-(9-3)], 'cond' => $this->semStack[$stackPos-(9-5)], 'loop' => $this->semStack[$stackPos-(9-7)], 'stmts' => $this->semStack[$stackPos-(9-9)]], $this->startAttributeStack[$stackPos-(9-1)] + $this->endAttributes); + 176 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Foreach_($self->semStack[$stackPos-(6-3)], new Expr\Error($self->getAttributes($self->tokenStartStack[$stackPos-(6-4)], $self->tokenEndStack[$stackPos-(6-4)])), ['stmts' => $self->semStack[$stackPos-(6-6)]], $self->getAttributes($self->tokenStartStack[$stackPos-(6-1)], $self->tokenEndStack[$stackPos])); }, - 165 => function ($stackPos) { - $this->semValue = new Stmt\Switch_($this->semStack[$stackPos-(5-3)], $this->semStack[$stackPos-(5-5)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); + 177 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Declare_($self->semStack[$stackPos-(5-3)], $self->semStack[$stackPos-(5-5)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); }, - 166 => function ($stackPos) { - $this->semValue = new Stmt\Break_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + 178 => static function ($self, $stackPos) { + $self->semValue = new Stmt\TryCatch($self->semStack[$stackPos-(6-3)], $self->semStack[$stackPos-(6-5)], $self->semStack[$stackPos-(6-6)], $self->getAttributes($self->tokenStartStack[$stackPos-(6-1)], $self->tokenEndStack[$stackPos])); $self->checkTryCatch($self->semValue); }, - 167 => function ($stackPos) { - $this->semValue = new Stmt\Continue_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + 179 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Goto_($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 168 => function ($stackPos) { - $this->semValue = new Stmt\Return_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + 180 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Label($self->semStack[$stackPos-(2-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 169 => function ($stackPos) { - $this->semValue = new Stmt\Global_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + 181 => static function ($self, $stackPos) { + $self->semValue = null; /* means: no statement */ }, - 170 => function ($stackPos) { - $this->semValue = new Stmt\Static_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + 182 => null, + 183 => static function ($self, $stackPos) { + $self->semValue = $self->maybeCreateNop($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos]); }, - 171 => function ($stackPos) { - $this->semValue = new Stmt\Echo_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + 184 => static function ($self, $stackPos) { + if ($self->semStack[$stackPos-(1-1)] instanceof Stmt\Block) { $self->semValue = $self->semStack[$stackPos-(1-1)]->stmts; } else if ($self->semStack[$stackPos-(1-1)] === null) { $self->semValue = []; } else { $self->semValue = [$self->semStack[$stackPos-(1-1)]]; }; }, - 172 => function ($stackPos) { - $this->semValue = new Stmt\InlineHTML($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + 185 => static function ($self, $stackPos) { + $self->semValue = array(); }, - 173 => function ($stackPos) { - - $e = $this->semStack[$stackPos-(2-1)]; - if ($e instanceof Expr\Throw_) { - // For backwards-compatibility reasons, convert throw in statement position into - // Stmt\Throw_ rather than Stmt\Expression(Expr\Throw_). - $this->semValue = new Stmt\Throw_($e->expr, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - } else { - $this->semValue = new Stmt\Expression($e, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - } + 186 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; $self->semValue = $self->semStack[$stackPos-(2-1)]; + }, + 187 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 188 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 189 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Catch_($self->semStack[$stackPos-(8-3)], $self->semStack[$stackPos-(8-4)], $self->semStack[$stackPos-(8-7)], $self->getAttributes($self->tokenStartStack[$stackPos-(8-1)], $self->tokenEndStack[$stackPos])); + }, + 190 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 191 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Finally_($self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 192 => null, + 193 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 194 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 195 => static function ($self, $stackPos) { + $self->semValue = false; + }, + 196 => static function ($self, $stackPos) { + $self->semValue = true; + }, + 197 => static function ($self, $stackPos) { + $self->semValue = false; + }, + 198 => static function ($self, $stackPos) { + $self->semValue = true; + }, + 199 => static function ($self, $stackPos) { + $self->semValue = false; + }, + 200 => static function ($self, $stackPos) { + $self->semValue = true; + }, + 201 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; + }, + 202 => static function ($self, $stackPos) { + $self->semValue = []; + }, + 203 => null, + 204 => static function ($self, $stackPos) { + $self->semValue = new Node\Identifier($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 205 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Function_($self->semStack[$stackPos-(8-3)], ['byRef' => $self->semStack[$stackPos-(8-2)], 'params' => $self->semStack[$stackPos-(8-5)], 'returnType' => $self->semStack[$stackPos-(8-7)], 'stmts' => $self->semStack[$stackPos-(8-8)], 'attrGroups' => []], $self->getAttributes($self->tokenStartStack[$stackPos-(8-1)], $self->tokenEndStack[$stackPos])); + }, + 206 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Function_($self->semStack[$stackPos-(9-4)], ['byRef' => $self->semStack[$stackPos-(9-3)], 'params' => $self->semStack[$stackPos-(9-6)], 'returnType' => $self->semStack[$stackPos-(9-8)], 'stmts' => $self->semStack[$stackPos-(9-9)], 'attrGroups' => $self->semStack[$stackPos-(9-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(9-1)], $self->tokenEndStack[$stackPos])); + }, + 207 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Class_($self->semStack[$stackPos-(7-2)], ['type' => $self->semStack[$stackPos-(7-1)], 'extends' => $self->semStack[$stackPos-(7-3)], 'implements' => $self->semStack[$stackPos-(7-4)], 'stmts' => $self->semStack[$stackPos-(7-6)], 'attrGroups' => []], $self->getAttributes($self->tokenStartStack[$stackPos-(7-1)], $self->tokenEndStack[$stackPos])); + $self->checkClass($self->semValue, $stackPos-(7-2)); + }, + 208 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Class_($self->semStack[$stackPos-(8-3)], ['type' => $self->semStack[$stackPos-(8-2)], 'extends' => $self->semStack[$stackPos-(8-4)], 'implements' => $self->semStack[$stackPos-(8-5)], 'stmts' => $self->semStack[$stackPos-(8-7)], 'attrGroups' => $self->semStack[$stackPos-(8-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(8-1)], $self->tokenEndStack[$stackPos])); + $self->checkClass($self->semValue, $stackPos-(8-3)); + }, + 209 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Interface_($self->semStack[$stackPos-(7-3)], ['extends' => $self->semStack[$stackPos-(7-4)], 'stmts' => $self->semStack[$stackPos-(7-6)], 'attrGroups' => $self->semStack[$stackPos-(7-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(7-1)], $self->tokenEndStack[$stackPos])); + $self->checkInterface($self->semValue, $stackPos-(7-3)); + }, + 210 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Trait_($self->semStack[$stackPos-(6-3)], ['stmts' => $self->semStack[$stackPos-(6-5)], 'attrGroups' => $self->semStack[$stackPos-(6-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(6-1)], $self->tokenEndStack[$stackPos])); + }, + 211 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Enum_($self->semStack[$stackPos-(8-3)], ['scalarType' => $self->semStack[$stackPos-(8-4)], 'implements' => $self->semStack[$stackPos-(8-5)], 'stmts' => $self->semStack[$stackPos-(8-7)], 'attrGroups' => $self->semStack[$stackPos-(8-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(8-1)], $self->tokenEndStack[$stackPos])); + $self->checkEnum($self->semValue, $stackPos-(8-3)); + }, + 212 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 213 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(2-2)]; + }, + 214 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 215 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(2-2)]; + }, + 216 => static function ($self, $stackPos) { + $self->semValue = 0; + }, + 217 => null, + 218 => null, + 219 => static function ($self, $stackPos) { + $self->checkClassModifier($self->semStack[$stackPos-(2-1)], $self->semStack[$stackPos-(2-2)], $stackPos-(2-2)); $self->semValue = $self->semStack[$stackPos-(2-1)] | $self->semStack[$stackPos-(2-2)]; + }, + 220 => static function ($self, $stackPos) { + $self->semValue = Modifiers::ABSTRACT; + }, + 221 => static function ($self, $stackPos) { + $self->semValue = Modifiers::FINAL; + }, + 222 => static function ($self, $stackPos) { + $self->semValue = Modifiers::READONLY; + }, + 223 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 224 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(2-2)]; + }, + 225 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 226 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(2-2)]; + }, + 227 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 228 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(2-2)]; + }, + 229 => null, + 230 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 231 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 232 => null, + 233 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(4-2)]; + }, + 234 => null, + 235 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(4-2)]; + }, + 236 => static function ($self, $stackPos) { + if ($self->semStack[$stackPos-(1-1)] instanceof Stmt\Block) { $self->semValue = $self->semStack[$stackPos-(1-1)]->stmts; } else if ($self->semStack[$stackPos-(1-1)] === null) { $self->semValue = []; } else { $self->semValue = [$self->semStack[$stackPos-(1-1)]]; }; + }, + 237 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 238 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(4-2)]; + }, + 239 => null, + 240 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 241 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 242 => static function ($self, $stackPos) { + $self->semValue = new Node\DeclareItem($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 243 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; + }, + 244 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(4-3)]; + }, + 245 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(4-2)]; + }, + 246 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(5-3)]; + }, + 247 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 248 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; $self->semValue = $self->semStack[$stackPos-(2-1)]; + }, + 249 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Case_($self->semStack[$stackPos-(4-2)], $self->semStack[$stackPos-(4-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 250 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Case_(null, $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 251 => null, + 252 => null, + 253 => static function ($self, $stackPos) { + $self->semValue = new Expr\Match_($self->semStack[$stackPos-(7-3)], $self->semStack[$stackPos-(7-6)], $self->getAttributes($self->tokenStartStack[$stackPos-(7-1)], $self->tokenEndStack[$stackPos])); + }, + 254 => static function ($self, $stackPos) { + $self->semValue = []; + }, + 255 => null, + 256 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 257 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 258 => static function ($self, $stackPos) { + $self->semValue = new Node\MatchArm($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 259 => static function ($self, $stackPos) { + $self->semValue = new Node\MatchArm(null, $self->semStack[$stackPos-(4-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 260 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(1-1)]; + }, + 261 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(4-2)]; + }, + 262 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 263 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; $self->semValue = $self->semStack[$stackPos-(2-1)]; + }, + 264 => static function ($self, $stackPos) { + $self->semValue = new Stmt\ElseIf_($self->semStack[$stackPos-(5-3)], $self->semStack[$stackPos-(5-5)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); + }, + 265 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 266 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; $self->semValue = $self->semStack[$stackPos-(2-1)]; + }, + 267 => static function ($self, $stackPos) { + $self->semValue = new Stmt\ElseIf_($self->semStack[$stackPos-(6-3)], $self->semStack[$stackPos-(6-6)], $self->getAttributes($self->tokenStartStack[$stackPos-(6-1)], $self->tokenEndStack[$stackPos])); $self->fixupAlternativeElse($self->semValue); + }, + 268 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 269 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Else_($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 270 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 271 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Else_($self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); $self->fixupAlternativeElse($self->semValue); + }, + 272 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)], false); + }, + 273 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(2-2)], true); + }, + 274 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)], false); + }, + 275 => static function ($self, $stackPos) { + $self->semValue = array($self->fixupArrayDestructuring($self->semStack[$stackPos-(1-1)]), false); + }, + 276 => null, + 277 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 278 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 279 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 280 => static function ($self, $stackPos) { + $self->semValue = 0; + }, + 281 => static function ($self, $stackPos) { + $self->checkModifier($self->semStack[$stackPos-(2-1)], $self->semStack[$stackPos-(2-2)], $stackPos-(2-2)); $self->semValue = $self->semStack[$stackPos-(2-1)] | $self->semStack[$stackPos-(2-2)]; + }, + 282 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PUBLIC; + }, + 283 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PROTECTED; + }, + 284 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PRIVATE; + }, + 285 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PUBLIC_SET; + }, + 286 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PROTECTED_SET; + }, + 287 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PRIVATE_SET; + }, + 288 => static function ($self, $stackPos) { + $self->semValue = Modifiers::READONLY; + }, + 289 => static function ($self, $stackPos) { + $self->semValue = new Node\Param($self->semStack[$stackPos-(7-6)], null, $self->semStack[$stackPos-(7-3)], $self->semStack[$stackPos-(7-4)], $self->semStack[$stackPos-(7-5)], $self->getAttributes($self->tokenStartStack[$stackPos-(7-1)], $self->tokenEndStack[$stackPos]), $self->semStack[$stackPos-(7-2)], $self->semStack[$stackPos-(7-1)], $self->semStack[$stackPos-(7-7)]); + $self->checkParam($self->semValue); + }, + 290 => static function ($self, $stackPos) { + $self->semValue = new Node\Param($self->semStack[$stackPos-(9-6)], $self->semStack[$stackPos-(9-8)], $self->semStack[$stackPos-(9-3)], $self->semStack[$stackPos-(9-4)], $self->semStack[$stackPos-(9-5)], $self->getAttributes($self->tokenStartStack[$stackPos-(9-1)], $self->tokenEndStack[$stackPos]), $self->semStack[$stackPos-(9-2)], $self->semStack[$stackPos-(9-1)], $self->semStack[$stackPos-(9-9)]); + $self->checkParam($self->semValue); + }, + 291 => static function ($self, $stackPos) { + $self->semValue = new Node\Param(new Expr\Error($self->getAttributes($self->tokenStartStack[$stackPos-(6-1)], $self->tokenEndStack[$stackPos])), null, $self->semStack[$stackPos-(6-3)], $self->semStack[$stackPos-(6-4)], $self->semStack[$stackPos-(6-5)], $self->getAttributes($self->tokenStartStack[$stackPos-(6-1)], $self->tokenEndStack[$stackPos]), $self->semStack[$stackPos-(6-2)], $self->semStack[$stackPos-(6-1)]); + }, + 292 => null, + 293 => static function ($self, $stackPos) { + $self->semValue = new Node\NullableType($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 294 => static function ($self, $stackPos) { + $self->semValue = new Node\UnionType($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 295 => null, + 296 => null, + 297 => static function ($self, $stackPos) { + $self->semValue = new Node\Name('static', $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 298 => static function ($self, $stackPos) { + $self->semValue = $self->handleBuiltinTypes($self->semStack[$stackPos-(1-1)]); + }, + 299 => static function ($self, $stackPos) { + $self->semValue = new Node\Identifier('array', $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 300 => static function ($self, $stackPos) { + $self->semValue = new Node\Identifier('callable', $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 301 => null, + 302 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; + }, + 303 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)]); + }, + 304 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 305 => null, + 306 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; + }, + 307 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)]); + }, + 308 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 309 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)]); + }, + 310 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 311 => static function ($self, $stackPos) { + $self->semValue = new Node\IntersectionType($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 312 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)]); + }, + 313 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 314 => static function ($self, $stackPos) { + $self->semValue = new Node\IntersectionType($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 315 => null, + 316 => static function ($self, $stackPos) { + $self->semValue = new Node\NullableType($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 317 => static function ($self, $stackPos) { + $self->semValue = new Node\UnionType($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 318 => null, + 319 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 320 => null, + 321 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 322 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(2-2)]; + }, + 323 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 324 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 325 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(4-2)]; + }, + 326 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(3-2)]); + }, + 327 => static function ($self, $stackPos) { + $self->semValue = new Node\VariadicPlaceholder($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 328 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 329 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 330 => static function ($self, $stackPos) { + $self->semValue = new Node\Arg($self->semStack[$stackPos-(1-1)], false, false, $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 331 => static function ($self, $stackPos) { + $self->semValue = new Node\Arg($self->semStack[$stackPos-(2-2)], true, false, $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 332 => static function ($self, $stackPos) { + $self->semValue = new Node\Arg($self->semStack[$stackPos-(2-2)], false, true, $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 333 => static function ($self, $stackPos) { + $self->semValue = new Node\Arg($self->semStack[$stackPos-(3-3)], false, false, $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos]), $self->semStack[$stackPos-(3-1)]); + }, + 334 => null, + 335 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 336 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 337 => null, + 338 => null, + 339 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 340 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 341 => static function ($self, $stackPos) { + $self->semValue = new Node\StaticVar($self->semStack[$stackPos-(1-1)], null, $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 342 => static function ($self, $stackPos) { + $self->semValue = new Node\StaticVar($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 343 => static function ($self, $stackPos) { + if ($self->semStack[$stackPos-(2-2)] !== null) { $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; $self->semValue = $self->semStack[$stackPos-(2-1)]; } else { $self->semValue = $self->semStack[$stackPos-(2-1)]; } + }, + 344 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 345 => static function ($self, $stackPos) { + $nop = $self->maybeCreateZeroLengthNop($self->tokenPos);; + if ($nop !== null) { $self->semStack[$stackPos-(1-1)][] = $nop; } $self->semValue = $self->semStack[$stackPos-(1-1)]; + }, + 346 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Property($self->semStack[$stackPos-(5-2)], $self->semStack[$stackPos-(5-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos]), $self->semStack[$stackPos-(5-3)], $self->semStack[$stackPos-(5-1)]); + }, + 347 => static function ($self, $stackPos) { + $self->semValue = new Stmt\ClassConst($self->semStack[$stackPos-(5-4)], $self->semStack[$stackPos-(5-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos]), $self->semStack[$stackPos-(5-1)]); + $self->checkClassConst($self->semValue, $stackPos-(5-2)); + }, + 348 => static function ($self, $stackPos) { + $self->semValue = new Stmt\ClassConst($self->semStack[$stackPos-(6-5)], $self->semStack[$stackPos-(6-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(6-1)], $self->tokenEndStack[$stackPos]), $self->semStack[$stackPos-(6-1)], $self->semStack[$stackPos-(6-4)]); + $self->checkClassConst($self->semValue, $stackPos-(6-2)); + }, + 349 => static function ($self, $stackPos) { + $self->semValue = new Stmt\ClassMethod($self->semStack[$stackPos-(10-5)], ['type' => $self->semStack[$stackPos-(10-2)], 'byRef' => $self->semStack[$stackPos-(10-4)], 'params' => $self->semStack[$stackPos-(10-7)], 'returnType' => $self->semStack[$stackPos-(10-9)], 'stmts' => $self->semStack[$stackPos-(10-10)], 'attrGroups' => $self->semStack[$stackPos-(10-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(10-1)], $self->tokenEndStack[$stackPos])); + $self->checkClassMethod($self->semValue, $stackPos-(10-2)); + }, + 350 => static function ($self, $stackPos) { + $self->semValue = new Stmt\TraitUse($self->semStack[$stackPos-(3-2)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 351 => static function ($self, $stackPos) { + $self->semValue = new Stmt\EnumCase($self->semStack[$stackPos-(5-3)], $self->semStack[$stackPos-(5-4)], $self->semStack[$stackPos-(5-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); + }, + 352 => static function ($self, $stackPos) { + $self->semValue = null; /* will be skipped */ + }, + 353 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 354 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; + }, + 355 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 356 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; $self->semValue = $self->semStack[$stackPos-(2-1)]; + }, + 357 => static function ($self, $stackPos) { + $self->semValue = new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Precedence($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 358 => static function ($self, $stackPos) { + $self->semValue = new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(5-1)][0], $self->semStack[$stackPos-(5-1)][1], $self->semStack[$stackPos-(5-3)], $self->semStack[$stackPos-(5-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); + }, + 359 => static function ($self, $stackPos) { + $self->semValue = new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], $self->semStack[$stackPos-(4-3)], null, $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 360 => static function ($self, $stackPos) { + $self->semValue = new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], null, $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 361 => static function ($self, $stackPos) { + $self->semValue = new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], null, $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 362 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)]); + }, + 363 => null, + 364 => static function ($self, $stackPos) { + $self->semValue = array(null, $self->semStack[$stackPos-(1-1)]); + }, + 365 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 366 => null, + 367 => null, + 368 => static function ($self, $stackPos) { + $self->semValue = 0; + }, + 369 => static function ($self, $stackPos) { + $self->semValue = 0; + }, + 370 => null, + 371 => null, + 372 => static function ($self, $stackPos) { + $self->checkModifier($self->semStack[$stackPos-(2-1)], $self->semStack[$stackPos-(2-2)], $stackPos-(2-2)); $self->semValue = $self->semStack[$stackPos-(2-1)] | $self->semStack[$stackPos-(2-2)]; + }, + 373 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PUBLIC; + }, + 374 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PROTECTED; + }, + 375 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PRIVATE; + }, + 376 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PUBLIC_SET; + }, + 377 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PROTECTED_SET; + }, + 378 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PRIVATE_SET; + }, + 379 => static function ($self, $stackPos) { + $self->semValue = Modifiers::STATIC; + }, + 380 => static function ($self, $stackPos) { + $self->semValue = Modifiers::ABSTRACT; + }, + 381 => static function ($self, $stackPos) { + $self->semValue = Modifiers::FINAL; + }, + 382 => static function ($self, $stackPos) { + $self->semValue = Modifiers::READONLY; + }, + 383 => null, + 384 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 385 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 386 => static function ($self, $stackPos) { + $self->semValue = new Node\VarLikeIdentifier(substr($self->semStack[$stackPos-(1-1)], 1), $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 387 => static function ($self, $stackPos) { + $self->semValue = new Node\PropertyItem($self->semStack[$stackPos-(1-1)], null, $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 388 => static function ($self, $stackPos) { + $self->semValue = new Node\PropertyItem($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 389 => static function ($self, $stackPos) { + $self->semValue = []; + }, + 390 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; $self->semValue = $self->semStack[$stackPos-(2-1)]; + }, + 391 => static function ($self, $stackPos) { + $self->semValue = []; + }, + 392 => static function ($self, $stackPos) { + $self->semValue = new Node\PropertyHook($self->semStack[$stackPos-(5-4)], $self->semStack[$stackPos-(5-5)], ['flags' => $self->semStack[$stackPos-(5-2)], 'byRef' => $self->semStack[$stackPos-(5-3)], 'params' => [], 'attrGroups' => $self->semStack[$stackPos-(5-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); + $self->checkPropertyHook($self->semValue, null); + }, + 393 => static function ($self, $stackPos) { + $self->semValue = new Node\PropertyHook($self->semStack[$stackPos-(8-4)], $self->semStack[$stackPos-(8-8)], ['flags' => $self->semStack[$stackPos-(8-2)], 'byRef' => $self->semStack[$stackPos-(8-3)], 'params' => $self->semStack[$stackPos-(8-6)], 'attrGroups' => $self->semStack[$stackPos-(8-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(8-1)], $self->tokenEndStack[$stackPos])); + $self->checkPropertyHook($self->semValue, $stackPos-(8-5)); + }, + 394 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 395 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; + }, + 396 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; + }, + 397 => static function ($self, $stackPos) { + $self->semValue = 0; + }, + 398 => static function ($self, $stackPos) { + $self->checkPropertyHookModifiers($self->semStack[$stackPos-(2-1)], $self->semStack[$stackPos-(2-2)], $stackPos-(2-2)); $self->semValue = $self->semStack[$stackPos-(2-1)] | $self->semStack[$stackPos-(2-2)]; + }, + 399 => null, + 400 => null, + 401 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 402 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 403 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 404 => null, + 405 => null, + 406 => static function ($self, $stackPos) { + $self->semValue = new Expr\Assign($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 407 => static function ($self, $stackPos) { + $self->semValue = new Expr\Assign($self->fixupArrayDestructuring($self->semStack[$stackPos-(3-1)]), $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 408 => static function ($self, $stackPos) { + $self->semValue = new Expr\Assign($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 409 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignRef($self->semStack[$stackPos-(4-1)], $self->semStack[$stackPos-(4-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 410 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignRef($self->semStack[$stackPos-(4-1)], $self->semStack[$stackPos-(4-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + if (!$self->phpVersion->allowsAssignNewByReference()) { + $self->emitError(new Error('Cannot assign new by reference', $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos]))); + } }, - 174 => function ($stackPos) { - $this->semValue = new Stmt\Unset_($this->semStack[$stackPos-(5-3)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); + 411 => null, + 412 => null, + 413 => static function ($self, $stackPos) { + $self->semValue = new Expr\Clone_($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 175 => function ($stackPos) { - $this->semValue = new Stmt\Foreach_($this->semStack[$stackPos-(7-3)], $this->semStack[$stackPos-(7-5)][0], ['keyVar' => null, 'byRef' => $this->semStack[$stackPos-(7-5)][1], 'stmts' => $this->semStack[$stackPos-(7-7)]], $this->startAttributeStack[$stackPos-(7-1)] + $this->endAttributes); + 414 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\Plus($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 176 => function ($stackPos) { - $this->semValue = new Stmt\Foreach_($this->semStack[$stackPos-(9-3)], $this->semStack[$stackPos-(9-7)][0], ['keyVar' => $this->semStack[$stackPos-(9-5)], 'byRef' => $this->semStack[$stackPos-(9-7)][1], 'stmts' => $this->semStack[$stackPos-(9-9)]], $this->startAttributeStack[$stackPos-(9-1)] + $this->endAttributes); + 415 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\Minus($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 177 => function ($stackPos) { - $this->semValue = new Stmt\Foreach_($this->semStack[$stackPos-(6-3)], new Expr\Error($this->startAttributeStack[$stackPos-(6-4)] + $this->endAttributeStack[$stackPos-(6-4)]), ['stmts' => $this->semStack[$stackPos-(6-6)]], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); + 416 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\Mul($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 178 => function ($stackPos) { - $this->semValue = new Stmt\Declare_($this->semStack[$stackPos-(5-3)], $this->semStack[$stackPos-(5-5)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); + 417 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\Div($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 179 => function ($stackPos) { - $this->semValue = new Stmt\TryCatch($this->semStack[$stackPos-(6-3)], $this->semStack[$stackPos-(6-5)], $this->semStack[$stackPos-(6-6)], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); $this->checkTryCatch($this->semValue); + 418 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\Concat($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 180 => function ($stackPos) { - $this->semValue = new Stmt\Goto_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + 419 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\Mod($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 181 => function ($stackPos) { - $this->semValue = new Stmt\Label($this->semStack[$stackPos-(2-1)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + 420 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\BitwiseAnd($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 182 => function ($stackPos) { - $this->semValue = array(); /* means: no statement */ + 421 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\BitwiseOr($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 183 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; + 422 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\BitwiseXor($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 184 => function ($stackPos) { - $startAttributes = $this->startAttributeStack[$stackPos-(1-1)]; if (isset($startAttributes['comments'])) { $this->semValue = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $this->semValue = null; }; - if ($this->semValue === null) $this->semValue = array(); /* means: no statement */ + 423 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\ShiftLeft($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 185 => function ($stackPos) { - $this->semValue = array(); + 424 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\ShiftRight($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 186 => function ($stackPos) { - $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; + 425 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\Pow($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 187 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); + 426 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\Coalesce($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 188 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + 427 => static function ($self, $stackPos) { + $self->semValue = new Expr\PostInc($self->semStack[$stackPos-(2-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 189 => function ($stackPos) { - $this->semValue = new Stmt\Catch_($this->semStack[$stackPos-(8-3)], $this->semStack[$stackPos-(8-4)], $this->semStack[$stackPos-(8-7)], $this->startAttributeStack[$stackPos-(8-1)] + $this->endAttributes); + 428 => static function ($self, $stackPos) { + $self->semValue = new Expr\PreInc($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 190 => function ($stackPos) { - $this->semValue = null; + 429 => static function ($self, $stackPos) { + $self->semValue = new Expr\PostDec($self->semStack[$stackPos-(2-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 191 => function ($stackPos) { - $this->semValue = new Stmt\Finally_($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + 430 => static function ($self, $stackPos) { + $self->semValue = new Expr\PreDec($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 192 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-1)]; + 431 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\BooleanOr($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 193 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); + 432 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\BooleanAnd($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 194 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + 433 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\LogicalOr($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 195 => function ($stackPos) { - $this->semValue = false; + 434 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\LogicalAnd($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 196 => function ($stackPos) { - $this->semValue = true; + 435 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\LogicalXor($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 197 => function ($stackPos) { - $this->semValue = false; + 436 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\BitwiseOr($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 198 => function ($stackPos) { - $this->semValue = true; + 437 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\BitwiseAnd($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 199 => function ($stackPos) { - $this->semValue = false; + 438 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\BitwiseAnd($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 200 => function ($stackPos) { - $this->semValue = true; + 439 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\BitwiseXor($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 201 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; + 440 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Concat($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 202 => function ($stackPos) { - $this->semValue = []; + 441 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Plus($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 203 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; + 442 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Minus($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 204 => function ($stackPos) { - $this->semValue = new Node\Identifier($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + 443 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Mul($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 205 => function ($stackPos) { - $this->semValue = new Stmt\Function_($this->semStack[$stackPos-(8-3)], ['byRef' => $this->semStack[$stackPos-(8-2)], 'params' => $this->semStack[$stackPos-(8-5)], 'returnType' => $this->semStack[$stackPos-(8-7)], 'stmts' => $this->semStack[$stackPos-(8-8)], 'attrGroups' => []], $this->startAttributeStack[$stackPos-(8-1)] + $this->endAttributes); + 444 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Div($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 206 => function ($stackPos) { - $this->semValue = new Stmt\Function_($this->semStack[$stackPos-(9-4)], ['byRef' => $this->semStack[$stackPos-(9-3)], 'params' => $this->semStack[$stackPos-(9-6)], 'returnType' => $this->semStack[$stackPos-(9-8)], 'stmts' => $this->semStack[$stackPos-(9-9)], 'attrGroups' => $this->semStack[$stackPos-(9-1)]], $this->startAttributeStack[$stackPos-(9-1)] + $this->endAttributes); + 445 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Mod($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 207 => function ($stackPos) { - $this->semValue = new Stmt\Class_($this->semStack[$stackPos-(7-2)], ['type' => $this->semStack[$stackPos-(7-1)], 'extends' => $this->semStack[$stackPos-(7-3)], 'implements' => $this->semStack[$stackPos-(7-4)], 'stmts' => $this->semStack[$stackPos-(7-6)], 'attrGroups' => []], $this->startAttributeStack[$stackPos-(7-1)] + $this->endAttributes); - $this->checkClass($this->semValue, $stackPos-(7-2)); + 446 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\ShiftLeft($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 208 => function ($stackPos) { - $this->semValue = new Stmt\Class_($this->semStack[$stackPos-(8-3)], ['type' => $this->semStack[$stackPos-(8-2)], 'extends' => $this->semStack[$stackPos-(8-4)], 'implements' => $this->semStack[$stackPos-(8-5)], 'stmts' => $this->semStack[$stackPos-(8-7)], 'attrGroups' => $this->semStack[$stackPos-(8-1)]], $this->startAttributeStack[$stackPos-(8-1)] + $this->endAttributes); - $this->checkClass($this->semValue, $stackPos-(8-3)); + 447 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\ShiftRight($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 209 => function ($stackPos) { - $this->semValue = new Stmt\Interface_($this->semStack[$stackPos-(7-3)], ['extends' => $this->semStack[$stackPos-(7-4)], 'stmts' => $this->semStack[$stackPos-(7-6)], 'attrGroups' => $this->semStack[$stackPos-(7-1)]], $this->startAttributeStack[$stackPos-(7-1)] + $this->endAttributes); - $this->checkInterface($this->semValue, $stackPos-(7-3)); + 448 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Pow($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 210 => function ($stackPos) { - $this->semValue = new Stmt\Trait_($this->semStack[$stackPos-(6-3)], ['stmts' => $this->semStack[$stackPos-(6-5)], 'attrGroups' => $this->semStack[$stackPos-(6-1)]], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); + 449 => static function ($self, $stackPos) { + $self->semValue = new Expr\UnaryPlus($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 211 => function ($stackPos) { - $this->semValue = new Stmt\Enum_($this->semStack[$stackPos-(8-3)], ['scalarType' => $this->semStack[$stackPos-(8-4)], 'implements' => $this->semStack[$stackPos-(8-5)], 'stmts' => $this->semStack[$stackPos-(8-7)], 'attrGroups' => $this->semStack[$stackPos-(8-1)]], $this->startAttributeStack[$stackPos-(8-1)] + $this->endAttributes); - $this->checkEnum($this->semValue, $stackPos-(8-3)); + 450 => static function ($self, $stackPos) { + $self->semValue = new Expr\UnaryMinus($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 212 => function ($stackPos) { - $this->semValue = null; + 451 => static function ($self, $stackPos) { + $self->semValue = new Expr\BooleanNot($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 213 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-2)]; + 452 => static function ($self, $stackPos) { + $self->semValue = new Expr\BitwiseNot($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 214 => function ($stackPos) { - $this->semValue = null; + 453 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Identical($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 215 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-2)]; + 454 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\NotIdentical($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 216 => function ($stackPos) { - $this->semValue = 0; + 455 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Equal($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 217 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-1)]; + 456 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\NotEqual($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 218 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; + 457 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Spaceship($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 219 => function ($stackPos) { - $this->checkClassModifier($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)], $stackPos-(2-2)); $this->semValue = $this->semStack[$stackPos-(2-1)] | $this->semStack[$stackPos-(2-2)]; + 458 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Smaller($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 220 => function ($stackPos) { - $this->semValue = Stmt\Class_::MODIFIER_ABSTRACT; + 459 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\SmallerOrEqual($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 221 => function ($stackPos) { - $this->semValue = Stmt\Class_::MODIFIER_FINAL; + 460 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Greater($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 222 => function ($stackPos) { - $this->semValue = Stmt\Class_::MODIFIER_READONLY; + 461 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\GreaterOrEqual($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 223 => function ($stackPos) { - $this->semValue = null; + 462 => static function ($self, $stackPos) { + $self->semValue = new Expr\Instanceof_($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 224 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-2)]; + 463 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; }, - 225 => function ($stackPos) { - $this->semValue = array(); + 464 => static function ($self, $stackPos) { + $self->semValue = new Expr\Ternary($self->semStack[$stackPos-(5-1)], $self->semStack[$stackPos-(5-3)], $self->semStack[$stackPos-(5-5)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); }, - 226 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-2)]; + 465 => static function ($self, $stackPos) { + $self->semValue = new Expr\Ternary($self->semStack[$stackPos-(4-1)], null, $self->semStack[$stackPos-(4-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, - 227 => function ($stackPos) { - $this->semValue = array(); + 466 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Coalesce($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 228 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-2)]; + 467 => static function ($self, $stackPos) { + $self->semValue = new Expr\Isset_($self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, - 229 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-1)]; + 468 => static function ($self, $stackPos) { + $self->semValue = new Expr\Empty_($self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, - 230 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); + 469 => static function ($self, $stackPos) { + $self->semValue = new Expr\Include_($self->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_INCLUDE, $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 231 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + 470 => static function ($self, $stackPos) { + $self->semValue = new Expr\Include_($self->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_INCLUDE_ONCE, $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 232 => function ($stackPos) { - $this->semValue = is_array($this->semStack[$stackPos-(1-1)]) ? $this->semStack[$stackPos-(1-1)] : array($this->semStack[$stackPos-(1-1)]); + 471 => static function ($self, $stackPos) { + $self->semValue = new Expr\Eval_($self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, - 233 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(4-2)]; + 472 => static function ($self, $stackPos) { + $self->semValue = new Expr\Include_($self->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_REQUIRE, $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 234 => function ($stackPos) { - $this->semValue = is_array($this->semStack[$stackPos-(1-1)]) ? $this->semStack[$stackPos-(1-1)] : array($this->semStack[$stackPos-(1-1)]); + 473 => static function ($self, $stackPos) { + $self->semValue = new Expr\Include_($self->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_REQUIRE_ONCE, $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 235 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(4-2)]; + 474 => static function ($self, $stackPos) { + $self->semValue = new Expr\Cast\Int_($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 236 => function ($stackPos) { - $this->semValue = is_array($this->semStack[$stackPos-(1-1)]) ? $this->semStack[$stackPos-(1-1)] : array($this->semStack[$stackPos-(1-1)]); + 475 => static function ($self, $stackPos) { + $attrs = $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos]); + $attrs['kind'] = $self->getFloatCastKind($self->semStack[$stackPos-(2-1)]); + $self->semValue = new Expr\Cast\Double($self->semStack[$stackPos-(2-2)], $attrs); }, - 237 => function ($stackPos) { - $this->semValue = null; + 476 => static function ($self, $stackPos) { + $self->semValue = new Expr\Cast\String_($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 238 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(4-2)]; + 477 => static function ($self, $stackPos) { + $self->semValue = new Expr\Cast\Array_($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 239 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-1)]; + 478 => static function ($self, $stackPos) { + $self->semValue = new Expr\Cast\Object_($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 240 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); + 479 => static function ($self, $stackPos) { + $self->semValue = new Expr\Cast\Bool_($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 241 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + 480 => static function ($self, $stackPos) { + $self->semValue = new Expr\Cast\Unset_($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 242 => function ($stackPos) { - $this->semValue = new Stmt\DeclareDeclare($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + 481 => static function ($self, $stackPos) { + $self->semValue = $self->createExitExpr($self->semStack[$stackPos-(2-1)], $stackPos-(2-1), $self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 243 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; + 482 => static function ($self, $stackPos) { + $self->semValue = new Expr\ErrorSuppress($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 244 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(4-3)]; + 483 => null, + 484 => static function ($self, $stackPos) { + $self->semValue = new Expr\ShellExec($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 245 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(4-2)]; + 485 => static function ($self, $stackPos) { + $self->semValue = new Expr\Print_($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 246 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(5-3)]; + 486 => static function ($self, $stackPos) { + $self->semValue = new Expr\Yield_(null, null, $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 247 => function ($stackPos) { - $this->semValue = array(); + 487 => static function ($self, $stackPos) { + $self->semValue = new Expr\Yield_($self->semStack[$stackPos-(2-2)], null, $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 248 => function ($stackPos) { - $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; + 488 => static function ($self, $stackPos) { + $self->semValue = new Expr\Yield_($self->semStack[$stackPos-(4-4)], $self->semStack[$stackPos-(4-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, - 249 => function ($stackPos) { - $this->semValue = new Stmt\Case_($this->semStack[$stackPos-(4-2)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + 489 => static function ($self, $stackPos) { + $self->semValue = new Expr\YieldFrom($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 250 => function ($stackPos) { - $this->semValue = new Stmt\Case_(null, $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + 490 => static function ($self, $stackPos) { + $self->semValue = new Expr\Throw_($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 251 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; + 491 => static function ($self, $stackPos) { + $self->semValue = new Expr\ArrowFunction(['static' => false, 'byRef' => $self->semStack[$stackPos-(8-2)], 'params' => $self->semStack[$stackPos-(8-4)], 'returnType' => $self->semStack[$stackPos-(8-6)], 'expr' => $self->semStack[$stackPos-(8-8)], 'attrGroups' => []], $self->getAttributes($self->tokenStartStack[$stackPos-(8-1)], $self->tokenEndStack[$stackPos])); }, - 252 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; + 492 => static function ($self, $stackPos) { + $self->semValue = new Expr\ArrowFunction(['static' => true, 'byRef' => $self->semStack[$stackPos-(9-3)], 'params' => $self->semStack[$stackPos-(9-5)], 'returnType' => $self->semStack[$stackPos-(9-7)], 'expr' => $self->semStack[$stackPos-(9-9)], 'attrGroups' => []], $self->getAttributes($self->tokenStartStack[$stackPos-(9-1)], $self->tokenEndStack[$stackPos])); }, - 253 => function ($stackPos) { - $this->semValue = new Expr\Match_($this->semStack[$stackPos-(7-3)], $this->semStack[$stackPos-(7-6)], $this->startAttributeStack[$stackPos-(7-1)] + $this->endAttributes); + 493 => static function ($self, $stackPos) { + $self->semValue = new Expr\Closure(['static' => false, 'byRef' => $self->semStack[$stackPos-(8-2)], 'params' => $self->semStack[$stackPos-(8-4)], 'uses' => $self->semStack[$stackPos-(8-6)], 'returnType' => $self->semStack[$stackPos-(8-7)], 'stmts' => $self->semStack[$stackPos-(8-8)], 'attrGroups' => []], $self->getAttributes($self->tokenStartStack[$stackPos-(8-1)], $self->tokenEndStack[$stackPos])); }, - 254 => function ($stackPos) { - $this->semValue = []; + 494 => static function ($self, $stackPos) { + $self->semValue = new Expr\Closure(['static' => true, 'byRef' => $self->semStack[$stackPos-(9-3)], 'params' => $self->semStack[$stackPos-(9-5)], 'uses' => $self->semStack[$stackPos-(9-7)], 'returnType' => $self->semStack[$stackPos-(9-8)], 'stmts' => $self->semStack[$stackPos-(9-9)], 'attrGroups' => []], $self->getAttributes($self->tokenStartStack[$stackPos-(9-1)], $self->tokenEndStack[$stackPos])); }, - 255 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-1)]; + 495 => static function ($self, $stackPos) { + $self->semValue = new Expr\ArrowFunction(['static' => false, 'byRef' => $self->semStack[$stackPos-(9-3)], 'params' => $self->semStack[$stackPos-(9-5)], 'returnType' => $self->semStack[$stackPos-(9-7)], 'expr' => $self->semStack[$stackPos-(9-9)], 'attrGroups' => $self->semStack[$stackPos-(9-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(9-1)], $self->tokenEndStack[$stackPos])); }, - 256 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); + 496 => static function ($self, $stackPos) { + $self->semValue = new Expr\ArrowFunction(['static' => true, 'byRef' => $self->semStack[$stackPos-(10-4)], 'params' => $self->semStack[$stackPos-(10-6)], 'returnType' => $self->semStack[$stackPos-(10-8)], 'expr' => $self->semStack[$stackPos-(10-10)], 'attrGroups' => $self->semStack[$stackPos-(10-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(10-1)], $self->tokenEndStack[$stackPos])); }, - 257 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + 497 => static function ($self, $stackPos) { + $self->semValue = new Expr\Closure(['static' => false, 'byRef' => $self->semStack[$stackPos-(9-3)], 'params' => $self->semStack[$stackPos-(9-5)], 'uses' => $self->semStack[$stackPos-(9-7)], 'returnType' => $self->semStack[$stackPos-(9-8)], 'stmts' => $self->semStack[$stackPos-(9-9)], 'attrGroups' => $self->semStack[$stackPos-(9-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(9-1)], $self->tokenEndStack[$stackPos])); }, - 258 => function ($stackPos) { - $this->semValue = new Node\MatchArm($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + 498 => static function ($self, $stackPos) { + $self->semValue = new Expr\Closure(['static' => true, 'byRef' => $self->semStack[$stackPos-(10-4)], 'params' => $self->semStack[$stackPos-(10-6)], 'uses' => $self->semStack[$stackPos-(10-8)], 'returnType' => $self->semStack[$stackPos-(10-9)], 'stmts' => $self->semStack[$stackPos-(10-10)], 'attrGroups' => $self->semStack[$stackPos-(10-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(10-1)], $self->tokenEndStack[$stackPos])); }, - 259 => function ($stackPos) { - $this->semValue = new Node\MatchArm(null, $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + 499 => static function ($self, $stackPos) { + $self->semValue = array(new Stmt\Class_(null, ['type' => $self->semStack[$stackPos-(8-2)], 'extends' => $self->semStack[$stackPos-(8-4)], 'implements' => $self->semStack[$stackPos-(8-5)], 'stmts' => $self->semStack[$stackPos-(8-7)], 'attrGroups' => $self->semStack[$stackPos-(8-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(8-1)], $self->tokenEndStack[$stackPos])), $self->semStack[$stackPos-(8-3)]); + $self->checkClass($self->semValue[0], -1); }, - 260 => function ($stackPos) { - $this->semValue = is_array($this->semStack[$stackPos-(1-1)]) ? $this->semStack[$stackPos-(1-1)] : array($this->semStack[$stackPos-(1-1)]); + 500 => static function ($self, $stackPos) { + $self->semValue = new Expr\New_($self->semStack[$stackPos-(3-2)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 261 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(4-2)]; + 501 => static function ($self, $stackPos) { + list($class, $ctorArgs) = $self->semStack[$stackPos-(2-2)]; $self->semValue = new Expr\New_($class, $ctorArgs, $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 262 => function ($stackPos) { - $this->semValue = array(); + 502 => static function ($self, $stackPos) { + $self->semValue = new Expr\New_($self->semStack[$stackPos-(2-2)], [], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 263 => function ($stackPos) { - $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; + 503 => null, + 504 => null, + 505 => static function ($self, $stackPos) { + $self->semValue = array(); }, - 264 => function ($stackPos) { - $this->semValue = new Stmt\ElseIf_($this->semStack[$stackPos-(5-3)], is_array($this->semStack[$stackPos-(5-5)]) ? $this->semStack[$stackPos-(5-5)] : array($this->semStack[$stackPos-(5-5)]), $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); + 506 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(4-3)]; }, - 265 => function ($stackPos) { - $this->semValue = array(); + 507 => null, + 508 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); }, - 266 => function ($stackPos) { - $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; + 509 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; }, - 267 => function ($stackPos) { - $this->semValue = new Stmt\ElseIf_($this->semStack[$stackPos-(6-3)], $this->semStack[$stackPos-(6-6)], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); $this->fixupAlternativeElse($this->semValue); + 510 => static function ($self, $stackPos) { + $self->semValue = new Node\ClosureUse($self->semStack[$stackPos-(2-2)], $self->semStack[$stackPos-(2-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 268 => function ($stackPos) { - $this->semValue = null; + 511 => static function ($self, $stackPos) { + $self->semValue = new Name($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 269 => function ($stackPos) { - $this->semValue = new Stmt\Else_(is_array($this->semStack[$stackPos-(2-2)]) ? $this->semStack[$stackPos-(2-2)] : array($this->semStack[$stackPos-(2-2)]), $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + 512 => static function ($self, $stackPos) { + $self->semValue = new Expr\FuncCall($self->semStack[$stackPos-(2-1)], $self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 270 => function ($stackPos) { - $this->semValue = null; + 513 => static function ($self, $stackPos) { + $self->semValue = new Expr\FuncCall($self->semStack[$stackPos-(2-1)], $self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 271 => function ($stackPos) { - $this->semValue = new Stmt\Else_($this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); $this->fixupAlternativeElse($this->semValue); + 514 => static function ($self, $stackPos) { + $self->semValue = new Expr\FuncCall($self->semStack[$stackPos-(2-1)], $self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 272 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)], false); + 515 => static function ($self, $stackPos) { + $self->semValue = new Expr\StaticCall($self->semStack[$stackPos-(4-1)], $self->semStack[$stackPos-(4-3)], $self->semStack[$stackPos-(4-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, - 273 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(2-2)], true); + 516 => static function ($self, $stackPos) { + $self->semValue = new Name($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 274 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)], false); + 517 => null, + 518 => static function ($self, $stackPos) { + $self->semValue = new Name($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 275 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)], false); + 519 => static function ($self, $stackPos) { + $self->semValue = new Name($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 276 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-1)]; + 520 => static function ($self, $stackPos) { + $self->semValue = new Name\FullyQualified(substr($self->semStack[$stackPos-(1-1)], 1), $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 277 => function ($stackPos) { - $this->semValue = array(); + 521 => static function ($self, $stackPos) { + $self->semValue = new Name\Relative(substr($self->semStack[$stackPos-(1-1)], 10), $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 278 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); + 522 => null, + 523 => null, + 524 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; }, - 279 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + 525 => static function ($self, $stackPos) { + $self->semValue = new Expr\Error($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); $self->errorState = 2; }, - 280 => function ($stackPos) { - $this->semValue = 0; + 526 => null, + 527 => null, + 528 => static function ($self, $stackPos) { + $self->semValue = array(); }, - 281 => function ($stackPos) { - $this->checkModifier($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)], $stackPos-(2-2)); $this->semValue = $this->semStack[$stackPos-(2-1)] | $this->semStack[$stackPos-(2-2)]; + 529 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); foreach ($self->semValue as $s) { if ($s instanceof Node\InterpolatedStringPart) { $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, '`', $self->phpVersion->supportsUnicodeEscapes()); } }; }, - 282 => function ($stackPos) { - $this->semValue = Stmt\Class_::MODIFIER_PUBLIC; + 530 => static function ($self, $stackPos) { + foreach ($self->semStack[$stackPos-(1-1)] as $s) { if ($s instanceof Node\InterpolatedStringPart) { $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, '`', $self->phpVersion->supportsUnicodeEscapes()); } }; $self->semValue = $self->semStack[$stackPos-(1-1)]; }, - 283 => function ($stackPos) { - $this->semValue = Stmt\Class_::MODIFIER_PROTECTED; + 531 => static function ($self, $stackPos) { + $self->semValue = array(); }, - 284 => function ($stackPos) { - $this->semValue = Stmt\Class_::MODIFIER_PRIVATE; + 532 => null, + 533 => static function ($self, $stackPos) { + $self->semValue = new Expr\ConstFetch($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 285 => function ($stackPos) { - $this->semValue = Stmt\Class_::MODIFIER_READONLY; + 534 => static function ($self, $stackPos) { + $self->semValue = new Scalar\MagicConst\Line($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 286 => function ($stackPos) { - $this->semValue = new Node\Param($this->semStack[$stackPos-(6-6)], null, $this->semStack[$stackPos-(6-3)], $this->semStack[$stackPos-(6-4)], $this->semStack[$stackPos-(6-5)], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes, $this->semStack[$stackPos-(6-2)], $this->semStack[$stackPos-(6-1)]); - $this->checkParam($this->semValue); + 535 => static function ($self, $stackPos) { + $self->semValue = new Scalar\MagicConst\File($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 287 => function ($stackPos) { - $this->semValue = new Node\Param($this->semStack[$stackPos-(8-6)], $this->semStack[$stackPos-(8-8)], $this->semStack[$stackPos-(8-3)], $this->semStack[$stackPos-(8-4)], $this->semStack[$stackPos-(8-5)], $this->startAttributeStack[$stackPos-(8-1)] + $this->endAttributes, $this->semStack[$stackPos-(8-2)], $this->semStack[$stackPos-(8-1)]); - $this->checkParam($this->semValue); + 536 => static function ($self, $stackPos) { + $self->semValue = new Scalar\MagicConst\Dir($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 288 => function ($stackPos) { - $this->semValue = new Node\Param(new Expr\Error($this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes), null, $this->semStack[$stackPos-(6-3)], $this->semStack[$stackPos-(6-4)], $this->semStack[$stackPos-(6-5)], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes, $this->semStack[$stackPos-(6-2)], $this->semStack[$stackPos-(6-1)]); + 537 => static function ($self, $stackPos) { + $self->semValue = new Scalar\MagicConst\Class_($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 289 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; + 538 => static function ($self, $stackPos) { + $self->semValue = new Scalar\MagicConst\Trait_($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 290 => function ($stackPos) { - $this->semValue = new Node\NullableType($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + 539 => static function ($self, $stackPos) { + $self->semValue = new Scalar\MagicConst\Method($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 291 => function ($stackPos) { - $this->semValue = new Node\UnionType($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + 540 => static function ($self, $stackPos) { + $self->semValue = new Scalar\MagicConst\Function_($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 292 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; + 541 => static function ($self, $stackPos) { + $self->semValue = new Scalar\MagicConst\Namespace_($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 293 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; + 542 => static function ($self, $stackPos) { + $self->semValue = new Scalar\MagicConst\Property($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 294 => function ($stackPos) { - $this->semValue = new Node\Name('static', $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + 543 => static function ($self, $stackPos) { + $self->semValue = new Expr\ClassConstFetch($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 295 => function ($stackPos) { - $this->semValue = $this->handleBuiltinTypes($this->semStack[$stackPos-(1-1)]); + 544 => static function ($self, $stackPos) { + $self->semValue = new Expr\ClassConstFetch($self->semStack[$stackPos-(5-1)], $self->semStack[$stackPos-(5-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); }, - 296 => function ($stackPos) { - $this->semValue = new Node\Identifier('array', $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + 545 => static function ($self, $stackPos) { + $self->semValue = new Expr\ClassConstFetch($self->semStack[$stackPos-(3-1)], new Expr\Error($self->getAttributes($self->tokenStartStack[$stackPos-(3-3)], $self->tokenEndStack[$stackPos-(3-3)])), $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); $self->errorState = 2; }, - 297 => function ($stackPos) { - $this->semValue = new Node\Identifier('callable', $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + 546 => static function ($self, $stackPos) { + $attrs = $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos]); $attrs['kind'] = Expr\Array_::KIND_SHORT; + $self->semValue = new Expr\Array_($self->semStack[$stackPos-(3-2)], $attrs); }, - 298 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; + 547 => static function ($self, $stackPos) { + $attrs = $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos]); $attrs['kind'] = Expr\Array_::KIND_LONG; + $self->semValue = new Expr\Array_($self->semStack[$stackPos-(4-3)], $attrs); + $self->createdArrays->attach($self->semValue); }, - 299 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; + 548 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(1-1)]; $self->createdArrays->attach($self->semValue); }, - 300 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)]); + 549 => static function ($self, $stackPos) { + $self->semValue = Scalar\String_::fromString($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos]), $self->phpVersion->supportsUnicodeEscapes()); }, - 301 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + 550 => static function ($self, $stackPos) { + $attrs = $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos]); $attrs['kind'] = Scalar\String_::KIND_DOUBLE_QUOTED; + foreach ($self->semStack[$stackPos-(3-2)] as $s) { if ($s instanceof Node\InterpolatedStringPart) { $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, '"', $self->phpVersion->supportsUnicodeEscapes()); } }; $self->semValue = new Scalar\InterpolatedString($self->semStack[$stackPos-(3-2)], $attrs); }, - 302 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; + 551 => static function ($self, $stackPos) { + $self->semValue = $self->parseLNumber($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos]), $self->phpVersion->allowsInvalidOctals()); }, - 303 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; + 552 => static function ($self, $stackPos) { + $self->semValue = Scalar\Float_::fromString($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 304 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)]); + 553 => null, + 554 => null, + 555 => null, + 556 => static function ($self, $stackPos) { + $self->semValue = $self->parseDocString($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-2)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos]), $self->getAttributes($self->tokenStartStack[$stackPos-(3-3)], $self->tokenEndStack[$stackPos-(3-3)]), true); }, - 305 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + 557 => static function ($self, $stackPos) { + $self->semValue = $self->parseDocString($self->semStack[$stackPos-(2-1)], '', $self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos]), $self->getAttributes($self->tokenStartStack[$stackPos-(2-2)], $self->tokenEndStack[$stackPos-(2-2)]), true); }, - 306 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)]); + 558 => static function ($self, $stackPos) { + $self->semValue = $self->parseDocString($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-2)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos]), $self->getAttributes($self->tokenStartStack[$stackPos-(3-3)], $self->tokenEndStack[$stackPos-(3-3)]), true); }, - 307 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + 559 => static function ($self, $stackPos) { + $self->semValue = null; }, - 308 => function ($stackPos) { - $this->semValue = new Node\IntersectionType($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + 560 => null, + 561 => null, + 562 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; }, - 309 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)]); + 563 => null, + 564 => null, + 565 => null, + 566 => null, + 567 => null, + 568 => null, + 569 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; }, - 310 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + 570 => null, + 571 => null, + 572 => null, + 573 => static function ($self, $stackPos) { + $self->semValue = new Expr\ArrayDimFetch($self->semStack[$stackPos-(4-1)], $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, - 311 => function ($stackPos) { - $this->semValue = new Node\IntersectionType($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + 574 => static function ($self, $stackPos) { + $self->semValue = new Expr\ArrayDimFetch($self->semStack[$stackPos-(4-1)], $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, - 312 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; + 575 => null, + 576 => static function ($self, $stackPos) { + $self->semValue = new Expr\MethodCall($self->semStack[$stackPos-(4-1)], $self->semStack[$stackPos-(4-3)], $self->semStack[$stackPos-(4-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, - 313 => function ($stackPos) { - $this->semValue = new Node\NullableType($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + 577 => static function ($self, $stackPos) { + $self->semValue = new Expr\NullsafeMethodCall($self->semStack[$stackPos-(4-1)], $self->semStack[$stackPos-(4-3)], $self->semStack[$stackPos-(4-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, - 314 => function ($stackPos) { - $this->semValue = new Node\UnionType($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + 578 => static function ($self, $stackPos) { + $self->semValue = null; }, - 315 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; + 579 => null, + 580 => null, + 581 => null, + 582 => static function ($self, $stackPos) { + $self->semValue = new Expr\PropertyFetch($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 316 => function ($stackPos) { - $this->semValue = null; + 583 => static function ($self, $stackPos) { + $self->semValue = new Expr\NullsafePropertyFetch($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 317 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; + 584 => null, + 585 => static function ($self, $stackPos) { + $self->semValue = new Expr\Variable($self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, - 318 => function ($stackPos) { - $this->semValue = null; + 586 => static function ($self, $stackPos) { + $self->semValue = new Expr\Variable($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 319 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-2)]; + 587 => static function ($self, $stackPos) { + $self->semValue = new Expr\Variable(new Expr\Error($self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])), $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); $self->errorState = 2; }, - 320 => function ($stackPos) { - $this->semValue = null; + 588 => static function ($self, $stackPos) { + $var = $self->semStack[$stackPos-(1-1)]->name; $self->semValue = \is_string($var) ? new Node\VarLikeIdentifier($var, $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])) : $var; }, - 321 => function ($stackPos) { - $this->semValue = array(); + 589 => static function ($self, $stackPos) { + $self->semValue = new Expr\StaticPropertyFetch($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 322 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(4-2)]; + 590 => null, + 591 => static function ($self, $stackPos) { + $self->semValue = new Expr\ArrayDimFetch($self->semStack[$stackPos-(4-1)], $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, - 323 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(3-2)]); + 592 => static function ($self, $stackPos) { + $self->semValue = new Expr\ArrayDimFetch($self->semStack[$stackPos-(4-1)], $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, - 324 => function ($stackPos) { - $this->semValue = new Node\VariadicPlaceholder($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + 593 => static function ($self, $stackPos) { + $self->semValue = new Expr\PropertyFetch($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 325 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); + 594 => static function ($self, $stackPos) { + $self->semValue = new Expr\NullsafePropertyFetch($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 326 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + 595 => static function ($self, $stackPos) { + $self->semValue = new Expr\StaticPropertyFetch($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 327 => function ($stackPos) { - $this->semValue = new Node\Arg($this->semStack[$stackPos-(1-1)], false, false, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + 596 => static function ($self, $stackPos) { + $self->semValue = new Expr\StaticPropertyFetch($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 328 => function ($stackPos) { - $this->semValue = new Node\Arg($this->semStack[$stackPos-(2-2)], true, false, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + 597 => null, + 598 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; }, - 329 => function ($stackPos) { - $this->semValue = new Node\Arg($this->semStack[$stackPos-(2-2)], false, true, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); + 599 => null, + 600 => null, + 601 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; }, - 330 => function ($stackPos) { - $this->semValue = new Node\Arg($this->semStack[$stackPos-(3-3)], false, false, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes, $this->semStack[$stackPos-(3-1)]); + 602 => null, + 603 => static function ($self, $stackPos) { + $self->semValue = new Expr\Error($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); $self->errorState = 2; }, - 331 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-1)]; + 604 => static function ($self, $stackPos) { + $self->semValue = new Expr\List_($self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); $self->semValue->setAttribute('kind', Expr\List_::KIND_LIST); + $self->postprocessList($self->semValue); }, - 332 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + 605 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(1-1)]; $end = count($self->semValue)-1; if ($self->semValue[$end]->value instanceof Expr\Error) array_pop($self->semValue); }, - 333 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); + 606 => null, + 607 => static function ($self, $stackPos) { + /* do nothing -- prevent default action of $$=$self->semStack[$1]. See $551. */ }, - 334 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; + 608 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; }, - 335 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-1)]; + 609 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); }, - 336 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; + 610 => static function ($self, $stackPos) { + $self->semValue = new Node\ArrayItem($self->semStack[$stackPos-(1-1)], null, false, $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 337 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); + 611 => static function ($self, $stackPos) { + $self->semValue = new Node\ArrayItem($self->semStack[$stackPos-(2-2)], null, true, $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, - 338 => function ($stackPos) { - $this->semValue = new Stmt\StaticVar($this->semStack[$stackPos-(1-1)], null, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); + 612 => static function ($self, $stackPos) { + $self->semValue = new Node\ArrayItem($self->semStack[$stackPos-(1-1)], null, false, $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 339 => function ($stackPos) { - $this->semValue = new Stmt\StaticVar($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + 613 => static function ($self, $stackPos) { + $self->semValue = new Node\ArrayItem($self->semStack[$stackPos-(3-3)], $self->semStack[$stackPos-(3-1)], false, $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 340 => function ($stackPos) { - if ($this->semStack[$stackPos-(2-2)] !== null) { $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; } + 614 => static function ($self, $stackPos) { + $self->semValue = new Node\ArrayItem($self->semStack[$stackPos-(4-4)], $self->semStack[$stackPos-(4-1)], true, $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, - 341 => function ($stackPos) { - $this->semValue = array(); + 615 => static function ($self, $stackPos) { + $self->semValue = new Node\ArrayItem($self->semStack[$stackPos-(3-3)], $self->semStack[$stackPos-(3-1)], false, $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 342 => function ($stackPos) { - $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop($this->createCommentNopAttributes($startAttributes['comments'])); } else { $nop = null; }; - if ($nop !== null) { $this->semStack[$stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$stackPos-(1-1)]; + 616 => static function ($self, $stackPos) { + $self->semValue = new Node\ArrayItem($self->semStack[$stackPos-(2-2)], null, false, $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos]), true); }, - 343 => function ($stackPos) { - $this->semValue = new Stmt\Property($this->semStack[$stackPos-(5-2)], $this->semStack[$stackPos-(5-4)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes, $this->semStack[$stackPos-(5-3)], $this->semStack[$stackPos-(5-1)]); - $this->checkProperty($this->semValue, $stackPos-(5-2)); + 617 => static function ($self, $stackPos) { + /* Create an Error node now to remember the position. We'll later either report an error, + or convert this into a null element, depending on whether this is a creation or destructuring context. */ + $attrs = $self->createEmptyElemAttributes($self->tokenPos); + $self->semValue = new Node\ArrayItem(new Expr\Error($attrs), null, false, $attrs); }, - 344 => function ($stackPos) { - $this->semValue = new Stmt\ClassConst($this->semStack[$stackPos-(5-4)], $this->semStack[$stackPos-(5-2)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes, $this->semStack[$stackPos-(5-1)]); - $this->checkClassConst($this->semValue, $stackPos-(5-2)); + 618 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; $self->semValue = $self->semStack[$stackPos-(2-1)]; }, - 345 => function ($stackPos) { - $this->semValue = new Stmt\ClassConst($this->semStack[$stackPos-(6-5)], $this->semStack[$stackPos-(6-2)], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes, $this->semStack[$stackPos-(6-1)], $this->semStack[$stackPos-(6-4)]); - $this->checkClassConst($this->semValue, $stackPos-(6-2)); + 619 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; $self->semValue = $self->semStack[$stackPos-(2-1)]; }, - 346 => function ($stackPos) { - $this->semValue = new Stmt\ClassMethod($this->semStack[$stackPos-(10-5)], ['type' => $this->semStack[$stackPos-(10-2)], 'byRef' => $this->semStack[$stackPos-(10-4)], 'params' => $this->semStack[$stackPos-(10-7)], 'returnType' => $this->semStack[$stackPos-(10-9)], 'stmts' => $this->semStack[$stackPos-(10-10)], 'attrGroups' => $this->semStack[$stackPos-(10-1)]], $this->startAttributeStack[$stackPos-(10-1)] + $this->endAttributes); - $this->checkClassMethod($this->semValue, $stackPos-(10-2)); + 620 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); }, - 347 => function ($stackPos) { - $this->semValue = new Stmt\TraitUse($this->semStack[$stackPos-(3-2)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); + 621 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(2-1)], $self->semStack[$stackPos-(2-2)]); }, - 348 => function ($stackPos) { - $this->semValue = new Stmt\EnumCase($this->semStack[$stackPos-(5-3)], $this->semStack[$stackPos-(5-4)], $this->semStack[$stackPos-(5-1)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); + 622 => static function ($self, $stackPos) { + $attrs = $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos]); $attrs['rawValue'] = $self->semStack[$stackPos-(1-1)]; $self->semValue = new Node\InterpolatedStringPart($self->semStack[$stackPos-(1-1)], $attrs); }, - 349 => function ($stackPos) { - $this->semValue = null; /* will be skipped */ + 623 => static function ($self, $stackPos) { + $self->semValue = new Expr\Variable($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 350 => function ($stackPos) { - $this->semValue = array(); + 624 => null, + 625 => static function ($self, $stackPos) { + $self->semValue = new Expr\ArrayDimFetch($self->semStack[$stackPos-(4-1)], $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, - 351 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; + 626 => static function ($self, $stackPos) { + $self->semValue = new Expr\PropertyFetch($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 352 => function ($stackPos) { - $this->semValue = array(); + 627 => static function ($self, $stackPos) { + $self->semValue = new Expr\NullsafePropertyFetch($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 353 => function ($stackPos) { - $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; + 628 => static function ($self, $stackPos) { + $self->semValue = new Expr\Variable($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 354 => function ($stackPos) { - $this->semValue = new Stmt\TraitUseAdaptation\Precedence($this->semStack[$stackPos-(4-1)][0], $this->semStack[$stackPos-(4-1)][1], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + 629 => static function ($self, $stackPos) { + $self->semValue = new Expr\Variable($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); }, - 355 => function ($stackPos) { - $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos-(5-1)][0], $this->semStack[$stackPos-(5-1)][1], $this->semStack[$stackPos-(5-3)], $this->semStack[$stackPos-(5-4)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); + 630 => static function ($self, $stackPos) { + $self->semValue = new Expr\ArrayDimFetch($self->semStack[$stackPos-(6-2)], $self->semStack[$stackPos-(6-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(6-1)], $self->tokenEndStack[$stackPos])); }, - 356 => function ($stackPos) { - $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos-(4-1)][0], $this->semStack[$stackPos-(4-1)][1], $this->semStack[$stackPos-(4-3)], null, $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + 631 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; }, - 357 => function ($stackPos) { - $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos-(4-1)][0], $this->semStack[$stackPos-(4-1)][1], null, $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + 632 => static function ($self, $stackPos) { + $self->semValue = new Scalar\String_($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 358 => function ($stackPos) { - $this->semValue = new Stmt\TraitUseAdaptation\Alias($this->semStack[$stackPos-(4-1)][0], $this->semStack[$stackPos-(4-1)][1], null, $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); + 633 => static function ($self, $stackPos) { + $self->semValue = $self->parseNumString($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); }, - 359 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)]); - }, - 360 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 361 => function ($stackPos) { - $this->semValue = array(null, $this->semStack[$stackPos-(1-1)]); - }, - 362 => function ($stackPos) { - $this->semValue = null; - }, - 363 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 364 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 365 => function ($stackPos) { - $this->semValue = 0; - }, - 366 => function ($stackPos) { - $this->semValue = 0; - }, - 367 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 368 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 369 => function ($stackPos) { - $this->checkModifier($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)], $stackPos-(2-2)); $this->semValue = $this->semStack[$stackPos-(2-1)] | $this->semStack[$stackPos-(2-2)]; - }, - 370 => function ($stackPos) { - $this->semValue = Stmt\Class_::MODIFIER_PUBLIC; - }, - 371 => function ($stackPos) { - $this->semValue = Stmt\Class_::MODIFIER_PROTECTED; - }, - 372 => function ($stackPos) { - $this->semValue = Stmt\Class_::MODIFIER_PRIVATE; - }, - 373 => function ($stackPos) { - $this->semValue = Stmt\Class_::MODIFIER_STATIC; - }, - 374 => function ($stackPos) { - $this->semValue = Stmt\Class_::MODIFIER_ABSTRACT; - }, - 375 => function ($stackPos) { - $this->semValue = Stmt\Class_::MODIFIER_FINAL; - }, - 376 => function ($stackPos) { - $this->semValue = Stmt\Class_::MODIFIER_READONLY; - }, - 377 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-1)]; - }, - 378 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 379 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; - }, - 380 => function ($stackPos) { - $this->semValue = new Node\VarLikeIdentifier(substr($this->semStack[$stackPos-(1-1)], 1), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 381 => function ($stackPos) { - $this->semValue = new Stmt\PropertyProperty($this->semStack[$stackPos-(1-1)], null, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 382 => function ($stackPos) { - $this->semValue = new Stmt\PropertyProperty($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 383 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-1)]; - }, - 384 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-1)]; - }, - 385 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; - }, - 386 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 387 => function ($stackPos) { - $this->semValue = array(); - }, - 388 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 389 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 390 => function ($stackPos) { - $this->semValue = new Expr\Assign($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 391 => function ($stackPos) { - $this->semValue = new Expr\Assign($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 392 => function ($stackPos) { - $this->semValue = new Expr\Assign($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 393 => function ($stackPos) { - $this->semValue = new Expr\AssignRef($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 394 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 395 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 396 => function ($stackPos) { - $this->semValue = new Expr\Clone_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 397 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\Plus($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 398 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\Minus($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 399 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\Mul($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 400 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\Div($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 401 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\Concat($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 402 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\Mod($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 403 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\BitwiseAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 404 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\BitwiseOr($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 405 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\BitwiseXor($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 406 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\ShiftLeft($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 407 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\ShiftRight($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 408 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\Pow($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 409 => function ($stackPos) { - $this->semValue = new Expr\AssignOp\Coalesce($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 410 => function ($stackPos) { - $this->semValue = new Expr\PostInc($this->semStack[$stackPos-(2-1)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 411 => function ($stackPos) { - $this->semValue = new Expr\PreInc($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 412 => function ($stackPos) { - $this->semValue = new Expr\PostDec($this->semStack[$stackPos-(2-1)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 413 => function ($stackPos) { - $this->semValue = new Expr\PreDec($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 414 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\BooleanOr($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 415 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\BooleanAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 416 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\LogicalOr($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 417 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\LogicalAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 418 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\LogicalXor($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 419 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\BitwiseOr($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 420 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 421 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\BitwiseAnd($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 422 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\BitwiseXor($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 423 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Concat($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 424 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Plus($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 425 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Minus($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 426 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Mul($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 427 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Div($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 428 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Mod($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 429 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\ShiftLeft($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 430 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\ShiftRight($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 431 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Pow($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 432 => function ($stackPos) { - $this->semValue = new Expr\UnaryPlus($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 433 => function ($stackPos) { - $this->semValue = new Expr\UnaryMinus($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 434 => function ($stackPos) { - $this->semValue = new Expr\BooleanNot($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 435 => function ($stackPos) { - $this->semValue = new Expr\BitwiseNot($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 436 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Identical($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 437 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\NotIdentical($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 438 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Equal($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 439 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\NotEqual($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 440 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Spaceship($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 441 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Smaller($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 442 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\SmallerOrEqual($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 443 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Greater($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 444 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\GreaterOrEqual($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 445 => function ($stackPos) { - $this->semValue = new Expr\Instanceof_($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 446 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; - }, - 447 => function ($stackPos) { - $this->semValue = new Expr\Ternary($this->semStack[$stackPos-(5-1)], $this->semStack[$stackPos-(5-3)], $this->semStack[$stackPos-(5-5)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); - }, - 448 => function ($stackPos) { - $this->semValue = new Expr\Ternary($this->semStack[$stackPos-(4-1)], null, $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 449 => function ($stackPos) { - $this->semValue = new Expr\BinaryOp\Coalesce($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 450 => function ($stackPos) { - $this->semValue = new Expr\Isset_($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 451 => function ($stackPos) { - $this->semValue = new Expr\Empty_($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 452 => function ($stackPos) { - $this->semValue = new Expr\Include_($this->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_INCLUDE, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 453 => function ($stackPos) { - $this->semValue = new Expr\Include_($this->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_INCLUDE_ONCE, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 454 => function ($stackPos) { - $this->semValue = new Expr\Eval_($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 455 => function ($stackPos) { - $this->semValue = new Expr\Include_($this->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_REQUIRE, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 456 => function ($stackPos) { - $this->semValue = new Expr\Include_($this->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_REQUIRE_ONCE, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 457 => function ($stackPos) { - $this->semValue = new Expr\Cast\Int_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 458 => function ($stackPos) { - $attrs = $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes; - $attrs['kind'] = $this->getFloatCastKind($this->semStack[$stackPos-(2-1)]); - $this->semValue = new Expr\Cast\Double($this->semStack[$stackPos-(2-2)], $attrs); - }, - 459 => function ($stackPos) { - $this->semValue = new Expr\Cast\String_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 460 => function ($stackPos) { - $this->semValue = new Expr\Cast\Array_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 461 => function ($stackPos) { - $this->semValue = new Expr\Cast\Object_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 462 => function ($stackPos) { - $this->semValue = new Expr\Cast\Bool_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 463 => function ($stackPos) { - $this->semValue = new Expr\Cast\Unset_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 464 => function ($stackPos) { - $attrs = $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes; - $attrs['kind'] = strtolower($this->semStack[$stackPos-(2-1)]) === 'exit' ? Expr\Exit_::KIND_EXIT : Expr\Exit_::KIND_DIE; - $this->semValue = new Expr\Exit_($this->semStack[$stackPos-(2-2)], $attrs); - }, - 465 => function ($stackPos) { - $this->semValue = new Expr\ErrorSuppress($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 466 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 467 => function ($stackPos) { - $this->semValue = new Expr\ShellExec($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 468 => function ($stackPos) { - $this->semValue = new Expr\Print_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 469 => function ($stackPos) { - $this->semValue = new Expr\Yield_(null, null, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 470 => function ($stackPos) { - $this->semValue = new Expr\Yield_($this->semStack[$stackPos-(2-2)], null, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 471 => function ($stackPos) { - $this->semValue = new Expr\Yield_($this->semStack[$stackPos-(4-4)], $this->semStack[$stackPos-(4-2)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 472 => function ($stackPos) { - $this->semValue = new Expr\YieldFrom($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 473 => function ($stackPos) { - $this->semValue = new Expr\Throw_($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 474 => function ($stackPos) { - $this->semValue = new Expr\ArrowFunction(['static' => false, 'byRef' => $this->semStack[$stackPos-(8-2)], 'params' => $this->semStack[$stackPos-(8-4)], 'returnType' => $this->semStack[$stackPos-(8-6)], 'expr' => $this->semStack[$stackPos-(8-8)], 'attrGroups' => []], $this->startAttributeStack[$stackPos-(8-1)] + $this->endAttributes); - }, - 475 => function ($stackPos) { - $this->semValue = new Expr\ArrowFunction(['static' => true, 'byRef' => $this->semStack[$stackPos-(9-3)], 'params' => $this->semStack[$stackPos-(9-5)], 'returnType' => $this->semStack[$stackPos-(9-7)], 'expr' => $this->semStack[$stackPos-(9-9)], 'attrGroups' => []], $this->startAttributeStack[$stackPos-(9-1)] + $this->endAttributes); - }, - 476 => function ($stackPos) { - $this->semValue = new Expr\Closure(['static' => false, 'byRef' => $this->semStack[$stackPos-(8-2)], 'params' => $this->semStack[$stackPos-(8-4)], 'uses' => $this->semStack[$stackPos-(8-6)], 'returnType' => $this->semStack[$stackPos-(8-7)], 'stmts' => $this->semStack[$stackPos-(8-8)], 'attrGroups' => []], $this->startAttributeStack[$stackPos-(8-1)] + $this->endAttributes); - }, - 477 => function ($stackPos) { - $this->semValue = new Expr\Closure(['static' => true, 'byRef' => $this->semStack[$stackPos-(9-3)], 'params' => $this->semStack[$stackPos-(9-5)], 'uses' => $this->semStack[$stackPos-(9-7)], 'returnType' => $this->semStack[$stackPos-(9-8)], 'stmts' => $this->semStack[$stackPos-(9-9)], 'attrGroups' => []], $this->startAttributeStack[$stackPos-(9-1)] + $this->endAttributes); - }, - 478 => function ($stackPos) { - $this->semValue = new Expr\ArrowFunction(['static' => false, 'byRef' => $this->semStack[$stackPos-(9-3)], 'params' => $this->semStack[$stackPos-(9-5)], 'returnType' => $this->semStack[$stackPos-(9-7)], 'expr' => $this->semStack[$stackPos-(9-9)], 'attrGroups' => $this->semStack[$stackPos-(9-1)]], $this->startAttributeStack[$stackPos-(9-1)] + $this->endAttributes); - }, - 479 => function ($stackPos) { - $this->semValue = new Expr\ArrowFunction(['static' => true, 'byRef' => $this->semStack[$stackPos-(10-4)], 'params' => $this->semStack[$stackPos-(10-6)], 'returnType' => $this->semStack[$stackPos-(10-8)], 'expr' => $this->semStack[$stackPos-(10-10)], 'attrGroups' => $this->semStack[$stackPos-(10-1)]], $this->startAttributeStack[$stackPos-(10-1)] + $this->endAttributes); - }, - 480 => function ($stackPos) { - $this->semValue = new Expr\Closure(['static' => false, 'byRef' => $this->semStack[$stackPos-(9-3)], 'params' => $this->semStack[$stackPos-(9-5)], 'uses' => $this->semStack[$stackPos-(9-7)], 'returnType' => $this->semStack[$stackPos-(9-8)], 'stmts' => $this->semStack[$stackPos-(9-9)], 'attrGroups' => $this->semStack[$stackPos-(9-1)]], $this->startAttributeStack[$stackPos-(9-1)] + $this->endAttributes); - }, - 481 => function ($stackPos) { - $this->semValue = new Expr\Closure(['static' => true, 'byRef' => $this->semStack[$stackPos-(10-4)], 'params' => $this->semStack[$stackPos-(10-6)], 'uses' => $this->semStack[$stackPos-(10-8)], 'returnType' => $this->semStack[$stackPos-(10-9)], 'stmts' => $this->semStack[$stackPos-(10-10)], 'attrGroups' => $this->semStack[$stackPos-(10-1)]], $this->startAttributeStack[$stackPos-(10-1)] + $this->endAttributes); - }, - 482 => function ($stackPos) { - $this->semValue = array(new Stmt\Class_(null, ['type' => $this->semStack[$stackPos-(8-2)], 'extends' => $this->semStack[$stackPos-(8-4)], 'implements' => $this->semStack[$stackPos-(8-5)], 'stmts' => $this->semStack[$stackPos-(8-7)], 'attrGroups' => $this->semStack[$stackPos-(8-1)]], $this->startAttributeStack[$stackPos-(8-1)] + $this->endAttributes), $this->semStack[$stackPos-(8-3)]); - $this->checkClass($this->semValue[0], -1); - }, - 483 => function ($stackPos) { - $this->semValue = new Expr\New_($this->semStack[$stackPos-(3-2)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 484 => function ($stackPos) { - list($class, $ctorArgs) = $this->semStack[$stackPos-(2-2)]; $this->semValue = new Expr\New_($class, $ctorArgs, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 485 => function ($stackPos) { - $this->semValue = array(); - }, - 486 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(4-3)]; - }, - 487 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(2-1)]; - }, - 488 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 489 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; - }, - 490 => function ($stackPos) { - $this->semValue = new Expr\ClosureUse($this->semStack[$stackPos-(2-2)], $this->semStack[$stackPos-(2-1)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 491 => function ($stackPos) { - $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 492 => function ($stackPos) { - $this->semValue = new Expr\FuncCall($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 493 => function ($stackPos) { - $this->semValue = new Expr\FuncCall($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 494 => function ($stackPos) { - $this->semValue = new Expr\FuncCall($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 495 => function ($stackPos) { - $this->semValue = new Expr\StaticCall($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 496 => function ($stackPos) { - $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 497 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 498 => function ($stackPos) { - $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 499 => function ($stackPos) { - $this->semValue = new Name($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 500 => function ($stackPos) { - $this->semValue = new Name\FullyQualified(substr($this->semStack[$stackPos-(1-1)], 1), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 501 => function ($stackPos) { - $this->semValue = new Name\Relative(substr($this->semStack[$stackPos-(1-1)], 10), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 502 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 503 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 504 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; - }, - 505 => function ($stackPos) { - $this->semValue = new Expr\Error($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); $this->errorState = 2; - }, - 506 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 507 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 508 => function ($stackPos) { - $this->semValue = null; - }, - 509 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; - }, - 510 => function ($stackPos) { - $this->semValue = array(); - }, - 511 => function ($stackPos) { - $this->semValue = array(new Scalar\EncapsedStringPart(Scalar\String_::parseEscapeSequences($this->semStack[$stackPos-(1-1)], '`'), $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes)); - }, - 512 => function ($stackPos) { - foreach ($this->semStack[$stackPos-(1-1)] as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) { $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, '`', true); } }; $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 513 => function ($stackPos) { - $this->semValue = array(); - }, - 514 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 515 => function ($stackPos) { - $this->semValue = new Expr\ConstFetch($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 516 => function ($stackPos) { - $this->semValue = new Scalar\MagicConst\Line($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 517 => function ($stackPos) { - $this->semValue = new Scalar\MagicConst\File($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 518 => function ($stackPos) { - $this->semValue = new Scalar\MagicConst\Dir($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 519 => function ($stackPos) { - $this->semValue = new Scalar\MagicConst\Class_($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 520 => function ($stackPos) { - $this->semValue = new Scalar\MagicConst\Trait_($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 521 => function ($stackPos) { - $this->semValue = new Scalar\MagicConst\Method($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 522 => function ($stackPos) { - $this->semValue = new Scalar\MagicConst\Function_($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 523 => function ($stackPos) { - $this->semValue = new Scalar\MagicConst\Namespace_($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 524 => function ($stackPos) { - $this->semValue = new Expr\ClassConstFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 525 => function ($stackPos) { - $this->semValue = new Expr\ClassConstFetch($this->semStack[$stackPos-(5-1)], $this->semStack[$stackPos-(5-4)], $this->startAttributeStack[$stackPos-(5-1)] + $this->endAttributes); - }, - 526 => function ($stackPos) { - $this->semValue = new Expr\ClassConstFetch($this->semStack[$stackPos-(3-1)], new Expr\Error($this->startAttributeStack[$stackPos-(3-3)] + $this->endAttributeStack[$stackPos-(3-3)]), $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); $this->errorState = 2; - }, - 527 => function ($stackPos) { - $attrs = $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes; $attrs['kind'] = Expr\Array_::KIND_SHORT; - $this->semValue = new Expr\Array_($this->semStack[$stackPos-(3-2)], $attrs); - }, - 528 => function ($stackPos) { - $attrs = $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes; $attrs['kind'] = Expr\Array_::KIND_LONG; - $this->semValue = new Expr\Array_($this->semStack[$stackPos-(4-3)], $attrs); - }, - 529 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 530 => function ($stackPos) { - $this->semValue = Scalar\String_::fromString($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 531 => function ($stackPos) { - $attrs = $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes; $attrs['kind'] = Scalar\String_::KIND_DOUBLE_QUOTED; - foreach ($this->semStack[$stackPos-(3-2)] as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) { $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, '"', true); } }; $this->semValue = new Scalar\Encapsed($this->semStack[$stackPos-(3-2)], $attrs); - }, - 532 => function ($stackPos) { - $this->semValue = $this->parseLNumber($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 533 => function ($stackPos) { - $this->semValue = Scalar\DNumber::fromString($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 534 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 535 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 536 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 537 => function ($stackPos) { - $this->semValue = $this->parseDocString($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-2)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes, $this->startAttributeStack[$stackPos-(3-3)] + $this->endAttributeStack[$stackPos-(3-3)], true); - }, - 538 => function ($stackPos) { - $this->semValue = $this->parseDocString($this->semStack[$stackPos-(2-1)], '', $this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes, $this->startAttributeStack[$stackPos-(2-2)] + $this->endAttributeStack[$stackPos-(2-2)], true); - }, - 539 => function ($stackPos) { - $this->semValue = $this->parseDocString($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-2)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes, $this->startAttributeStack[$stackPos-(3-3)] + $this->endAttributeStack[$stackPos-(3-3)], true); - }, - 540 => function ($stackPos) { - $this->semValue = null; - }, - 541 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 542 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 543 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; - }, - 544 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 545 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 546 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 547 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 548 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 549 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; - }, - 550 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 551 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 552 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 553 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 554 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 555 => function ($stackPos) { - $this->semValue = new Expr\MethodCall($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 556 => function ($stackPos) { - $this->semValue = new Expr\NullsafeMethodCall($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->semStack[$stackPos-(4-4)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 557 => function ($stackPos) { - $this->semValue = null; - }, - 558 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 559 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 560 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 561 => function ($stackPos) { - $this->semValue = new Expr\PropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 562 => function ($stackPos) { - $this->semValue = new Expr\NullsafePropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 563 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 564 => function ($stackPos) { - $this->semValue = new Expr\Variable($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 565 => function ($stackPos) { - $this->semValue = new Expr\Variable($this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 566 => function ($stackPos) { - $this->semValue = new Expr\Variable(new Expr\Error($this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes), $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); $this->errorState = 2; - }, - 567 => function ($stackPos) { - $var = $this->semStack[$stackPos-(1-1)]->name; $this->semValue = \is_string($var) ? new Node\VarLikeIdentifier($var, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes) : $var; - }, - 568 => function ($stackPos) { - $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 569 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 570 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 571 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 572 => function ($stackPos) { - $this->semValue = new Expr\PropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 573 => function ($stackPos) { - $this->semValue = new Expr\NullsafePropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 574 => function ($stackPos) { - $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 575 => function ($stackPos) { - $this->semValue = new Expr\StaticPropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 576 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 577 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; - }, - 578 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 579 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 580 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; - }, - 581 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 582 => function ($stackPos) { - $this->semValue = new Expr\Error($this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); $this->errorState = 2; - }, - 583 => function ($stackPos) { - $this->semValue = new Expr\List_($this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 584 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; $end = count($this->semValue)-1; if ($this->semValue[$end] === null) array_pop($this->semValue); - }, - 585 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos]; - }, - 586 => function ($stackPos) { - /* do nothing -- prevent default action of $$=$this->semStack[$1]. See $551. */ - }, - 587 => function ($stackPos) { - $this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)]; - }, - 588 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 589 => function ($stackPos) { - $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(1-1)], null, false, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 590 => function ($stackPos) { - $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(2-2)], null, true, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 591 => function ($stackPos) { - $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(1-1)], null, false, $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 592 => function ($stackPos) { - $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(3-3)], $this->semStack[$stackPos-(3-1)], false, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 593 => function ($stackPos) { - $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(4-4)], $this->semStack[$stackPos-(4-1)], true, $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 594 => function ($stackPos) { - $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(3-3)], $this->semStack[$stackPos-(3-1)], false, $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 595 => function ($stackPos) { - $this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(2-2)], null, false, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes, true); - }, - 596 => function ($stackPos) { - $this->semValue = null; - }, - 597 => function ($stackPos) { - $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; - }, - 598 => function ($stackPos) { - $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; - }, - 599 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(1-1)]); - }, - 600 => function ($stackPos) { - $this->semValue = array($this->semStack[$stackPos-(2-1)], $this->semStack[$stackPos-(2-2)]); - }, - 601 => function ($stackPos) { - $this->semValue = new Scalar\EncapsedStringPart($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 602 => function ($stackPos) { - $this->semValue = new Expr\Variable($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 603 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; - }, - 604 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(4-1)], $this->semStack[$stackPos-(4-3)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes); - }, - 605 => function ($stackPos) { - $this->semValue = new Expr\PropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 606 => function ($stackPos) { - $this->semValue = new Expr\NullsafePropertyFetch($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 607 => function ($stackPos) { - $this->semValue = new Expr\Variable($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 608 => function ($stackPos) { - $this->semValue = new Expr\Variable($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes); - }, - 609 => function ($stackPos) { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$stackPos-(6-2)], $this->semStack[$stackPos-(6-4)], $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes); - }, - 610 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(3-2)]; - }, - 611 => function ($stackPos) { - $this->semValue = new Scalar\String_($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 612 => function ($stackPos) { - $this->semValue = $this->parseNumString($this->semStack[$stackPos-(1-1)], $this->startAttributeStack[$stackPos-(1-1)] + $this->endAttributes); - }, - 613 => function ($stackPos) { - $this->semValue = $this->parseNumString('-' . $this->semStack[$stackPos-(2-2)], $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes); - }, - 614 => function ($stackPos) { - $this->semValue = $this->semStack[$stackPos-(1-1)]; + 634 => static function ($self, $stackPos) { + $self->semValue = $self->parseNumString('-' . $self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); }, + 635 => null, ]; } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Parser/Php8.php b/src/ncc/ThirdParty/nikic/PhpParser/Parser/Php8.php new file mode 100644 index 0000000..cf23196 --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/Parser/Php8.php @@ -0,0 +1,2799 @@ +'", + "T_IS_GREATER_OR_EQUAL", + "'.'", + "T_SL", + "T_SR", + "'+'", + "'-'", + "'*'", + "'/'", + "'%'", + "'!'", + "T_INSTANCEOF", + "'~'", + "T_INC", + "T_DEC", + "T_INT_CAST", + "T_DOUBLE_CAST", + "T_STRING_CAST", + "T_ARRAY_CAST", + "T_OBJECT_CAST", + "T_BOOL_CAST", + "T_UNSET_CAST", + "'@'", + "T_POW", + "'['", + "T_NEW", + "T_CLONE", + "T_EXIT", + "T_IF", + "T_ELSEIF", + "T_ELSE", + "T_ENDIF", + "T_LNUMBER", + "T_DNUMBER", + "T_STRING", + "T_STRING_VARNAME", + "T_VARIABLE", + "T_NUM_STRING", + "T_INLINE_HTML", + "T_ENCAPSED_AND_WHITESPACE", + "T_CONSTANT_ENCAPSED_STRING", + "T_ECHO", + "T_DO", + "T_WHILE", + "T_ENDWHILE", + "T_FOR", + "T_ENDFOR", + "T_FOREACH", + "T_ENDFOREACH", + "T_DECLARE", + "T_ENDDECLARE", + "T_AS", + "T_SWITCH", + "T_MATCH", + "T_ENDSWITCH", + "T_CASE", + "T_DEFAULT", + "T_BREAK", + "T_CONTINUE", + "T_GOTO", + "T_FUNCTION", + "T_FN", + "T_CONST", + "T_RETURN", + "T_TRY", + "T_CATCH", + "T_FINALLY", + "T_USE", + "T_INSTEADOF", + "T_GLOBAL", + "T_STATIC", + "T_ABSTRACT", + "T_FINAL", + "T_PRIVATE", + "T_PROTECTED", + "T_PUBLIC", + "T_READONLY", + "T_PUBLIC_SET", + "T_PROTECTED_SET", + "T_PRIVATE_SET", + "T_VAR", + "T_UNSET", + "T_ISSET", + "T_EMPTY", + "T_HALT_COMPILER", + "T_CLASS", + "T_TRAIT", + "T_INTERFACE", + "T_ENUM", + "T_EXTENDS", + "T_IMPLEMENTS", + "T_OBJECT_OPERATOR", + "T_NULLSAFE_OBJECT_OPERATOR", + "T_LIST", + "T_ARRAY", + "T_CALLABLE", + "T_CLASS_C", + "T_TRAIT_C", + "T_METHOD_C", + "T_FUNC_C", + "T_PROPERTY_C", + "T_LINE", + "T_FILE", + "T_START_HEREDOC", + "T_END_HEREDOC", + "T_DOLLAR_OPEN_CURLY_BRACES", + "T_CURLY_OPEN", + "T_PAAMAYIM_NEKUDOTAYIM", + "T_NAMESPACE", + "T_NS_C", + "T_DIR", + "T_NS_SEPARATOR", + "T_ELLIPSIS", + "T_NAME_FULLY_QUALIFIED", + "T_NAME_QUALIFIED", + "T_NAME_RELATIVE", + "T_ATTRIBUTE", + "';'", + "']'", + "'('", + "')'", + "'{'", + "'}'", + "'`'", + "'\"'", + "'$'" + ); + + protected array $tokenToSymbol = array( + 0, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 56, 170, 172, 171, 55, 172, 172, + 165, 166, 53, 51, 8, 52, 48, 54, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 31, 163, + 44, 16, 46, 30, 68, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 70, 172, 164, 36, 172, 169, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 167, 35, 168, 58, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 1, 2, 3, 4, + 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 32, 33, 34, 37, 38, 39, 40, + 41, 42, 43, 45, 47, 49, 50, 57, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 69, 71, 72, + 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, + 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, + 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, + 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, + 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, + 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, + 153, 154, 155, 156, 157, 158, 159, 160, 161, 162 + ); + + protected array $action = array( + 126, 127, 128, 569, 129, 130, 954, 764, 765, 766, + 131, 38, 848, -85,-32766, 1374,-32766,-32766,-32766, 0, + 839, 1132, 1133, 1134, 1128, 1127, 1126, 1135, 1129, 1130, + 1131,-32766,-32766,-32766, 850, 758, 757,-32766,-32766,-32766, + -32766,-32766,-32766,-32766,-32766,-32766,-32767,-32767,-32767,-32767, + -32767, 1003,-32766, 1043, -569, 767, 1132, 1133, 1134, 1128, + 1127, 1126, 1135, 1129, 1130, 1131, 388, 387, 841, 263, + 132, 389, 771, 772, 773, 774, 429,-32766, 430, -85, + 956, 36, 246, 47, 291, 828, 775, 776, 777, 778, + 779, 780, 781, 782, 783, 784, 804, 570, 805, 806, + 807, 808, 796, 797, 343, 344, 799, 800, 785, 786, + 787, 789, 790, 791, 359, 831, 832, 833, 834, 835, + 571, -569, -569, 360, 792, 793, 572, 573, -331, 816, + 814, 815, 827, 811, 812, 2, -194, 574, 575, 810, + 576, 577, 578, 579, 322, 580, 581, 875, 843, 876, + 297, 298, 813, 582, 583, 721, 133, 236, 126, 127, + 128, 569, 129, 130, 1076, 764, 765, 766, 131, 38, + -32766, 26, 734, 1036, 1035, 1034, 1040, 1037, 1038, 1039, + -32766,-32766,-32766, 1004, 104, 105, 106, 107, 108, 35, + 275, 956,-32766, 758, 757, 1052, 849,-32766,-32766,-32766, + 847,-32766, 109,-32766,-32766,-32766,-32766,-32766,-32766,-32766, + 148, 475, 476, 767,-32766,-32766,-32766, 1052,-32766, 290, + -32766,-32766,-32766,-32766,-32766, 615, 134, 263, 132, 389, + 771, 772, 773, 774, 365,-32766, 430,-32766,-32766,-32766, + -32766, 290, 143, 828, 775, 776, 777, 778, 779, 780, + 781, 782, 783, 784, 804, 570, 805, 806, 807, 808, + 796, 797, 343, 344, 799, 800, 785, 786, 787, 789, + 790, 791, 359, 831, 832, 833, 834, 835, 571,-32766, + -32766,-32766, 792, 793, 572, 573, -331, 816, 814, 815, + 827, 811, 812, 1299, -194, 574, 575, 810, 576, 577, + 578, 579, 844, 580, 581, 149, 82, 83, 84, -272, + 813, 582, 583, 249, 146, 788, 759, 760, 761, 762, + 763, 235, 764, 765, 766, 801, 802, 37, 307, 85, + 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, + 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, + 106, 107, 108, 157, 275,-32766,-32766,-32766,-32767,-32767, + -32767,-32767, 101, 102, 103, 1106, 109, 309, 621, 747, + 767,-32766,-32766,-32766, 848, 318,-32766, 1105,-32766,-32766, + -32766, 338, 845, 1355, 768, 769, 770, 771, 772, 773, + 774, 339,-32766, 837,-32766,-32766, 1384, 374, 1279, 1385, + 828, 775, 776, 777, 778, 779, 780, 781, 782, 783, + 784, 804, 826, 805, 806, 807, 808, 796, 797, 798, + 825, 799, 800, 785, 786, 787, 789, 790, 791, 830, + 831, 832, 833, 834, 835, 836, 1075, 430, -566, 792, + 793, 794, 795, 1359, 816, 814, 815, 827, 811, 812, + 1358, -193, 803, 809, 810, 817, 818, 820, 819, 138, + 821, 822, 839, 321, 380, 285, 24, 813, 824, 823, + 49, 50, 51, 521, 52, 53, -371, -110, -371, 848, + 54, 55, -110, 56, -110,-32766,-32766,-32766, 1340, 303, + 125, 1121, -110, -110, -110, -110, -110, -110, -110, -110, + -110, -110, -110, 161, 749, -566, -566, 291, 972, 973, + 465, 466, 467, 974, 396, 285, 1274, 1273, 1275, 57, + 58, -566, 565, 447, 59, 1107, 60, 243, 244, 61, + 62, 63, 64, 65, 66, 67, 68,-32766, 28, 265, + 69, 445, 522, 489, -345, 448, 1305, 1306, 523, 139, + 848, 1049, 449, 321, 1303, 42, 20, 524, 933, 525, + 933, 526, 74, 527, -567, 697, 528, 529, 321, 386, + 387, 44, 45, 451, 383, 382, 1052, 46, 530, 429, + 972, 973, 450, 372, 337, 974, 1279, 1311, 724, 933, + 1265,-32766,-32766,-32766, 968, 532, 533, 534, 854, 933, + 281, 698, -78, -565, 1272, 758, 757, 536, 537, -193, + 1291, 1292, 1293, 1294, 1296, 1288, 1289, 295, 1052, 725, + 398, 151, 7, 1295, 1290, 699, 700, 1274, 1273, 1275, + 296, -567, -567, 70, -153, -153, -153, 316, 317, 321, + 1270, 923, 290, 923, 1274, 1273, 1275, -567, 1049, -153, + 281, -153, 1148, -153, 81, -153, 739, 152, 321, -573, + 153, 758, 757,-32766, 1051, 381, 875, 848, 876, 155, + -565, -565, 923, 1052, 1049, 33, 972, 973, -58, 490, + -57, 531, 923, 1274, 1273, 1275, -565, 123, 1052, 909, + 968, -110, -110, -110, 28, 266, 124, 281, -572, 1052, + 102, 103, -110, -110,-32766,-32766, 848, -110, 135, -563, + 1303, 136, -605, 142, -605, 156, -110, 664, 21, 158, + 935, 159, 935, 160, 719,-32766, 719, -153, -305, 48, + 32, 110, 111, 112, 113, 114, 115, 116, 117, 118, + 119, 120, 121, 122, 683, 684, 1265, 296, 758, 757, + 74, 935, -87, 933, -84, 719, 321, -4, 933, -78, + 933, 935, -73, 536, 537, 719, 1291, 1292, 1293, 1294, + 1296, 1288, 1289, 1181, 1183, 933, -563, -563, -564, 1295, + 1290, 758, 757, 726, -563,-32766, 147, 413, -301, 72, + 729, 1272, -563, -72, 317, 321, 299, 300,-32766,-32766, + -32766, -71,-32766, -70,-32766, 736,-32766, 384, 385,-32766, + 390, 391, 379, -69,-32766,-32766,-32766, -68,-32766, -67, + -32766,-32766, -66, -65, 1272, -46,-32766, 426, 28, 265, + -18,-32766,-32766,-32766, 140,-32766, 923,-32766,-32766,-32766, + 848, 923,-32766, 923, 1303, -564, -564,-32766,-32766,-32766, + 274, -563, -563,-32766,-32766, 282, 655, 656, 923,-32766, + 426, -564, 735, 381, 738, 442, 932, -563, 145, 73, + 294,-32766, 950, -571, 972, 973, 279, 280, 283, 531, + 1265, 28, 266, 284, 327, 275, 109, 535, 968, -110, + -110, -110, 286, 848, 287, 292, 293, 1303, 537, 144, + 1291, 1292, 1293, 1294, 1296, 1288, 1289, 693, 848, 1139, + -32766, 11, 839, 1295, 1290, 989, 708, 686, 670, 719, + 935, 1386, 935, 72, 719, -4, 719, 653, 317, 321, + -50, 710, 304, 1265, 586, 968, 665, 935, 969, 1310, + 671, 719, 302, 301, 10, 308, 1312, 472, 500,-32766, + -529, 537, 687, 1291, 1292, 1293, 1294, 1296, 1288, 1289, + 952, 40, 592, 137, 41, -519, 1295, 1290, 8, 27, + 619, 321, 0,-32766, 378, 0, 72, 0, 0, 1272, + 0, 317, 321, 744, 0, 0,-32766,-32766,-32766, 0, + -32766, 0,-32766, 0,-32766, 0, 0,-32766, 0, 0, + 0, 0,-32766,-32766,-32766, 933,-32766, 745,-32766,-32766, + 0, 0, 1272, 847,-32766, 426, 867, 0, 296,-32766, + -32766,-32766, 0,-32766, 914,-32766,-32766,-32766, 933, 1013, + -32766, 990, 997, 987, 998,-32766,-32766,-32766, 912,-32766, + 985,-32766,-32766, 1110, 1113, 1272, 1114,-32766, 426, 1111, + 1150, 1112,-32766,-32766,-32766, 1118,-32766, 1300,-32766,-32766, + -32766, 859, 1327,-32766, 1344, 1377, 658, 495,-32766,-32766, + -32766, -599,-32766, -598,-32766,-32766, -597, -573, 1272, 599, + -32766, 426, -572, -571, -570,-32766,-32766,-32766, 923,-32766, + -513,-32766,-32766,-32766, 1, 29,-32766, -275, 30, 39, + 43,-32766,-32766,-32766, -250, -250, -250,-32766,-32766, 71, + 381, 923, 75,-32766, 426, 76, 77, 78, 1279, 79, + 80, 972, 973, 141, 150,-32766, 531, -249, -249, -249, + -273, 154, 241, 381, 909, 968, -110, -110, -110, 323, + 360, 361, 362, 363, 972, 973, 364, 365, -16, 531, + 366, 367, 368, 369, 370, 373, 443, 909, 968, -110, + -110, -110,-32766, -272, 564, 371, 1304, 935, 1272, 13, + 741, 719, -250, 14, 15,-32766,-32766,-32766, 16,-32766, + 18,-32766, 354,-32766, 412, 491,-32766, 492, 499, 502, + 935,-32766,-32766,-32766, 719, -249, 503,-32766,-32766, 848, + 504, 505, 509,-32766, 426, 510, 511, 518, 597, 703, + 1078, 1221, 1301, 1077, 1058,-32766, 1260, 1054, -277, -102, + 12, 17, 22, 312, 411, 611, 616, 644, 709, 1225, + 1278, 1222, 1356, 0, -110, -110, 34, 315, 375, -110, + 720, 723, 727, 728, 730, 731, 732, 733, -110, 737, + 749, 722, 750, 0, 910, 1381, 0,-32766, 1383, 870, + 869, 878, 962, 1005, 877, 1382, 961, 959, 960, 963, + 1253, 943, 953, 941, 1149, 1145, 1099, 995, 996, 296, + 642, 1380, 74, 1338, 1353, 0, 0, 1238, 321 + ); + + protected array $actionCheck = array( + 2, 3, 4, 5, 6, 7, 1, 9, 10, 11, + 12, 13, 82, 31, 116, 85, 9, 10, 11, 0, + 80, 116, 117, 118, 119, 120, 121, 122, 123, 124, + 125, 9, 10, 11, 1, 37, 38, 30, 140, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 31, 30, 1, 70, 57, 116, 117, 118, 119, + 120, 121, 122, 123, 124, 125, 106, 107, 80, 71, + 72, 73, 74, 75, 76, 77, 116, 9, 80, 97, + 122, 151, 152, 70, 30, 87, 88, 89, 90, 91, + 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, + 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, + 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, + 122, 137, 138, 165, 126, 127, 128, 129, 8, 131, + 132, 133, 134, 135, 136, 8, 8, 139, 140, 141, + 142, 143, 144, 145, 70, 147, 148, 106, 160, 108, + 137, 138, 154, 155, 156, 167, 158, 14, 2, 3, + 4, 5, 6, 7, 166, 9, 10, 11, 12, 13, + 116, 8, 167, 119, 120, 121, 122, 123, 124, 125, + 9, 10, 11, 163, 51, 52, 53, 54, 55, 8, + 57, 122, 116, 37, 38, 141, 163, 9, 10, 11, + 159, 30, 69, 32, 33, 34, 35, 36, 37, 38, + 14, 137, 138, 57, 9, 10, 11, 141, 30, 165, + 32, 33, 34, 35, 36, 1, 8, 71, 72, 73, + 74, 75, 76, 77, 165, 30, 80, 32, 33, 34, + 35, 165, 8, 87, 88, 89, 90, 91, 92, 93, + 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, + 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, + 114, 115, 116, 117, 118, 119, 120, 121, 122, 9, + 10, 11, 126, 127, 128, 129, 166, 131, 132, 133, + 134, 135, 136, 1, 166, 139, 140, 141, 142, 143, + 144, 145, 80, 147, 148, 14, 9, 10, 11, 166, + 154, 155, 156, 8, 158, 2, 3, 4, 5, 6, + 7, 97, 9, 10, 11, 12, 13, 30, 8, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 16, 57, 9, 10, 11, 44, 45, + 46, 47, 48, 49, 50, 163, 69, 8, 52, 167, + 57, 9, 10, 11, 82, 8, 30, 1, 32, 33, + 34, 8, 160, 1, 71, 72, 73, 74, 75, 76, + 77, 8, 30, 80, 32, 33, 80, 8, 1, 83, + 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, + 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, + 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, + 117, 118, 119, 120, 121, 122, 1, 80, 70, 126, + 127, 128, 129, 1, 131, 132, 133, 134, 135, 136, + 8, 8, 139, 140, 141, 142, 143, 144, 145, 167, + 147, 148, 80, 171, 8, 30, 101, 154, 155, 156, + 2, 3, 4, 5, 6, 7, 106, 101, 108, 82, + 12, 13, 106, 15, 108, 9, 10, 11, 1, 113, + 14, 126, 116, 117, 118, 119, 120, 121, 122, 123, + 124, 125, 126, 14, 167, 137, 138, 30, 117, 118, + 132, 133, 134, 122, 8, 30, 159, 160, 161, 51, + 52, 153, 85, 8, 56, 168, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 140, 70, 71, + 72, 73, 74, 31, 168, 8, 78, 79, 80, 167, + 82, 116, 8, 171, 86, 87, 88, 89, 1, 91, + 1, 93, 165, 95, 70, 80, 98, 99, 171, 106, + 107, 103, 104, 105, 106, 107, 141, 109, 110, 116, + 117, 118, 8, 115, 116, 122, 1, 150, 31, 1, + 122, 9, 10, 116, 131, 127, 128, 129, 8, 1, + 165, 116, 16, 70, 80, 37, 38, 139, 140, 166, + 142, 143, 144, 145, 146, 147, 148, 149, 141, 31, + 106, 14, 108, 155, 156, 140, 141, 159, 160, 161, + 162, 137, 138, 165, 75, 76, 77, 169, 170, 171, + 116, 84, 165, 84, 159, 160, 161, 153, 116, 90, + 165, 92, 163, 94, 167, 96, 167, 14, 171, 165, + 14, 37, 38, 116, 140, 106, 106, 82, 108, 14, + 137, 138, 84, 141, 116, 14, 117, 118, 16, 167, + 16, 122, 84, 159, 160, 161, 153, 16, 141, 130, + 131, 132, 133, 134, 70, 71, 16, 165, 165, 141, + 49, 50, 117, 118, 51, 52, 82, 122, 16, 70, + 86, 16, 164, 16, 166, 16, 131, 75, 76, 16, + 163, 16, 163, 16, 167, 140, 167, 168, 35, 70, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 75, 76, 122, 162, 37, 38, + 165, 163, 31, 1, 31, 167, 171, 0, 1, 31, + 1, 163, 31, 139, 140, 167, 142, 143, 144, 145, + 146, 147, 148, 59, 60, 1, 137, 138, 70, 155, + 156, 37, 38, 31, 70, 74, 101, 102, 35, 165, + 31, 80, 153, 31, 170, 171, 137, 138, 87, 88, + 89, 31, 91, 31, 93, 31, 95, 106, 107, 98, + 106, 107, 153, 31, 103, 104, 105, 31, 74, 31, + 109, 110, 31, 31, 80, 31, 115, 116, 70, 71, + 31, 87, 88, 89, 31, 91, 84, 93, 127, 95, + 82, 84, 98, 84, 86, 137, 138, 103, 104, 105, + 31, 137, 138, 109, 110, 31, 111, 112, 84, 115, + 116, 153, 31, 106, 31, 108, 31, 153, 31, 158, + 113, 127, 38, 165, 117, 118, 35, 35, 35, 122, + 122, 70, 71, 35, 35, 57, 69, 130, 131, 132, + 133, 134, 37, 82, 37, 37, 37, 86, 140, 70, + 142, 143, 144, 145, 146, 147, 148, 77, 82, 82, + 85, 154, 80, 155, 156, 163, 80, 94, 96, 167, + 163, 83, 163, 165, 167, 168, 167, 113, 170, 171, + 31, 92, 114, 122, 89, 131, 90, 163, 131, 150, + 100, 167, 136, 135, 97, 135, 150, 97, 97, 140, + 153, 140, 100, 142, 143, 144, 145, 146, 147, 148, + 158, 163, 157, 31, 163, 153, 155, 156, 153, 153, + 157, 171, -1, 74, 153, -1, 165, -1, -1, 80, + -1, 170, 171, 163, -1, -1, 87, 88, 89, -1, + 91, -1, 93, -1, 95, -1, -1, 98, -1, -1, + -1, -1, 103, 104, 105, 1, 74, 163, 109, 110, + -1, -1, 80, 159, 115, 116, 163, -1, 162, 87, + 88, 89, -1, 91, 163, 93, 127, 95, 1, 163, + 98, 163, 163, 163, 163, 103, 104, 105, 163, 74, + 163, 109, 110, 163, 163, 80, 163, 115, 116, 163, + 163, 163, 87, 88, 89, 163, 91, 164, 93, 127, + 95, 164, 164, 98, 164, 164, 164, 102, 103, 104, + 105, 165, 74, 165, 109, 110, 165, 165, 80, 81, + 115, 116, 165, 165, 165, 87, 88, 89, 84, 91, + 165, 93, 127, 95, 165, 165, 98, 166, 165, 165, + 165, 103, 104, 105, 100, 101, 102, 109, 110, 165, + 106, 84, 165, 115, 116, 165, 165, 165, 1, 165, + 165, 117, 118, 165, 165, 127, 122, 100, 101, 102, + 166, 165, 165, 106, 130, 131, 132, 133, 134, 165, + 165, 165, 165, 165, 117, 118, 165, 165, 31, 122, + 165, 165, 165, 165, 165, 165, 165, 130, 131, 132, + 133, 134, 74, 166, 165, 165, 170, 163, 80, 166, + 168, 167, 168, 166, 166, 87, 88, 89, 166, 91, + 166, 93, 166, 95, 166, 166, 98, 166, 166, 166, + 163, 103, 104, 105, 167, 168, 166, 109, 110, 82, + 166, 166, 166, 115, 116, 166, 166, 166, 166, 166, + 166, 166, 166, 166, 166, 127, 166, 166, 166, 166, + 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, + 166, 166, 166, -1, 117, 118, 167, 167, 167, 122, + 167, 167, 167, 167, 167, 167, 167, 167, 131, 167, + 167, 167, 167, -1, 168, 168, -1, 140, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 168, 168, 168, 168, 162, + 168, 168, 165, 168, 168, -1, -1, 169, 171 + ); + + protected array $actionBase = array( + 0, -2, 156, 559, 757, 1004, 1027, 485, 292, 357, + -60, -12, 588, 759, 759, 774, 759, 557, 752, 888, + 598, 598, 598, 836, 313, 313, 836, 313, 711, 711, + 711, 711, 744, 744, 965, 965, 998, 932, 899, 1088, + 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, + 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, + 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, + 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, + 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, + 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, + 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, + 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, + 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, + 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, + 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, + 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, 1088, + 1088, 1088, 33, 20, 224, 1083, 661, 1057, 1063, 1059, + 1064, 1055, 1054, 1058, 1060, 1065, 1113, 1115, 837, 1112, + 1116, 1061, 902, 1056, 1062, 887, 297, 297, 297, 297, + 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, + 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, + 297, 297, 68, 476, 582, 270, 270, 270, 270, 270, + 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, + 270, 270, 270, 270, 270, 624, 624, 22, 22, 22, + 362, 811, 758, 811, 811, 811, 811, 811, 811, 811, + 811, 346, 205, 188, 714, 171, 171, 7, 7, 7, + 7, 7, 376, 1117, 54, 585, 585, 314, 314, 314, + 314, 365, 568, 370, 435, 397, 651, 477, 463, 532, + 532, 558, 558, 76, 76, 558, 558, 558, 133, 133, + 547, 547, 547, 547, 41, 437, 809, 382, 382, 382, + 382, 809, 809, 809, 809, 796, 996, 809, 809, 809, + 494, 533, 708, 653, 653, 560, -70, -70, 560, 804, + -70, 487, 316, -102, 807, -40, 548, -102, 1000, 368, + 639, 639, 659, 639, 639, 639, 854, 701, 854, 1053, + -42, 825, 825, 794, 731, 69, 892, 1084, 1066, 840, + 1109, 852, 1110, 1085, 489, 378, -16, 13, 74, 728, + 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, + 1052, 1052, 800, 568, 1053, 222, 1107, 1108, 800, 800, + 800, 568, 568, 568, 568, 568, 568, 568, 568, 799, + 568, 568, 745, 222, 642, 669, 222, 849, 568, 33, + 812, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 512, 33, 20, 5, 5, 202, 52, 5, 5, + 5, 337, 5, 33, 33, 33, 701, 828, 805, 704, + -18, 813, 443, 828, 828, 828, 120, 143, 128, 693, + 753, 514, 832, 832, 827, 929, 929, 832, 826, 832, + 827, 832, 832, 929, 929, 856, 929, 218, 515, 373, + 456, 537, 929, 320, 832, 832, 832, 832, 810, 929, + 127, 544, 832, 305, 234, 832, 832, 810, 808, 824, + 806, 929, 929, 929, 810, 389, 806, 806, 806, 820, + 844, 814, 819, 367, 359, 590, 181, 834, 819, 819, + 832, 506, 814, 819, 814, 819, 802, 819, 819, 819, + 814, 819, 826, 383, 819, 699, 574, 163, 819, 832, + 19, 944, 947, 721, 950, 934, 951, 991, 952, 954, + 1073, 925, 967, 935, 955, 999, 933, 930, 835, 671, + 680, 815, 797, 919, 817, 817, 817, 912, 917, 817, + 817, 817, 817, 817, 817, 817, 817, 671, 893, 821, + 845, 976, 692, 695, 1042, 789, 1086, 1118, 975, 944, + 954, 723, 935, 955, 933, 930, 792, 791, 786, 788, + 782, 772, 762, 770, 803, 1044, 958, 798, 697, 1014, + 977, 1002, 1070, 978, 981, 1018, 1045, 853, 1046, 1087, + 829, 1090, 1091, 897, 985, 1074, 817, 911, 906, 898, + 982, 918, 671, 900, 1047, 1003, 1069, 1019, 1021, 1071, + 850, 838, 901, 1092, 986, 987, 988, 1075, 1076, 801, + 1007, 931, 1022, 851, 1093, 1023, 1030, 1034, 1035, 1077, + 1094, 1078, 908, 1079, 861, 846, 964, 822, 1095, 196, + 843, 848, 859, 990, 291, 974, 1080, 1096, 1097, 1036, + 1039, 1040, 1098, 1099, 959, 866, 1008, 823, 1012, 997, + 868, 869, 607, 858, 1048, 841, 842, 857, 643, 646, + 1100, 1101, 1102, 966, 831, 830, 870, 871, 1050, 855, + 1051, 1103, 655, 875, 1104, 1043, 703, 705, 586, 664, + 662, 707, 839, 1082, 816, 818, 847, 989, 705, 833, + 877, 1105, 880, 881, 883, 1041, 886, 1016, 1106, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 468, 468, 468, 468, 468, 468, 313, + 313, 313, 313, 313, 468, 468, 468, 468, 468, 468, + 468, 313, 468, 468, 468, 313, 0, 0, 313, 0, + 468, 468, 468, 468, 468, 468, 468, 468, 468, 468, + 468, 468, 468, 468, 468, 468, 468, 468, 468, 468, + 468, 468, 468, 468, 468, 468, 468, 468, 468, 468, + 468, 468, 468, 468, 468, 468, 468, 468, 468, 468, + 468, 468, 468, 468, 468, 468, 468, 468, 468, 468, + 468, 468, 468, 468, 468, 468, 468, 468, 468, 468, + 468, 468, 468, 468, 468, 468, 468, 468, 468, 468, + 468, 468, 468, 468, 468, 468, 468, 468, 468, 468, + 468, 468, 468, 468, 468, 468, 468, 468, 468, 468, + 468, 468, 468, 468, 468, 468, 468, 468, 468, 468, + 468, 468, 468, 468, 468, 468, 468, 468, 468, 468, + 468, 468, 468, 468, 468, 468, 468, 468, 468, 468, + 468, 468, 468, 468, 468, 468, 468, 468, 468, 468, + 468, 468, 468, 468, 297, 297, 297, 297, 297, 297, + 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, + 297, 297, 297, 297, 297, 297, 297, 297, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 297, 297, 297, 297, 297, 297, + 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, + 297, 297, 297, 297, 297, 297, 297, 524, 524, 297, + 297, 297, 297, 524, 524, 524, 524, 524, 524, 524, + 524, 524, 524, 297, 297, 297, 0, 297, 297, 297, + 297, 297, 297, 297, 856, 524, 524, 524, 524, 133, + 133, 133, 133, -95, -95, -95, 524, 524, 133, 524, + 856, 524, 524, 524, 524, 524, 524, 524, 524, 524, + 0, 0, 524, 524, 524, 524, 222, -70, 524, 826, + 826, 826, 826, 524, 524, 524, 524, -70, -70, 524, + 524, 524, 0, 0, 0, 133, 133, 222, 0, 0, + 222, 391, 0, 826, 826, 524, 391, 856, 442, 524, + 489, 0, 0, 0, 0, 0, 0, 0, 222, 826, + 222, 568, 832, -70, -70, 568, 568, 832, 5, 33, + 442, 685, 685, 685, 685, 33, 0, 0, 0, 0, + 0, 701, 856, 856, 856, 856, 856, 856, 856, 856, + 856, 856, 856, 856, 826, 0, 856, 0, 856, 856, + 826, 826, 826, 0, 0, 0, 0, 0, 0, 0, + 0, 929, 0, 0, 0, 0, 0, 0, 0, 826, + 0, 0, 929, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 826, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 817, + 850, 0, 0, 850, 0, 817, 817, 817, 0, 0, + 0, 858, 855 + ); + + protected array $actionDefault = array( + 3,32767, 102,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767, 100,32767, 617, 617, + 617, 617,32767,32767, 254, 102,32767,32767, 488, 405, + 405, 405,32767,32767, 561, 561, 561, 561, 561,32767, + 32767,32767,32767,32767,32767, 488,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767, 36, 7, 8, 10, + 11, 49, 17, 327, 100,32767,32767,32767,32767,32767, + 32767,32767,32767, 102,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767, 392, 610,32767,32767,32767, + 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767, 492, 471, 472, 474, + 475, 404, 562, 616, 330, 613, 332, 403, 145, 342, + 333, 242, 258, 493, 259, 494, 497, 498, 215, 389, + 149, 150, 435, 489, 437, 487, 491, 436, 410, 416, + 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, + 427, 428, 408, 409, 490,32767,32767, 468, 467, 466, + 433,32767,32767,32767,32767,32767,32767,32767,32767, 102, + 32767, 434, 438, 441, 407, 439, 440, 457, 458, 455, + 456, 459,32767,32767, 319,32767,32767, 460, 461, 462, + 463, 370, 195, 368,32767,32767, 442, 319, 111,32767, + 32767,32767,32767,32767,32767,32767,32767,32767, 448, 449, + 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767,32767, 102,32767, 100, + 505, 555, 465, 443, 444,32767, 530,32767, 102,32767, + 532,32767,32767,32767,32767,32767,32767,32767,32767, 557, + 430, 432, 525, 611, 411, 614,32767, 518, 100, 195, + 32767,32767, 531, 195, 195,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767, 556,32767, 624, 518, + 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, + 110, 110,32767, 195, 110,32767, 110, 110,32767,32767, + 100, 195, 195, 195, 195, 195, 195, 195, 195, 533, + 195, 195, 190,32767, 268, 270, 102, 579, 195,32767, + 535,32767,32767,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, + 32767, 392,32767,32767,32767,32767, 518, 453, 138,32767, + 520, 138, 563, 445, 446, 447, 563, 563, 563, 315, + 292,32767,32767,32767,32767, 533, 533, 100, 100, 100, + 100,32767,32767,32767,32767, 111, 504, 99, 99, 99, + 99, 99, 103, 101,32767,32767,32767,32767, 223,32767, + 101, 99,32767, 101, 101,32767,32767, 223, 225, 212, + 227,32767, 583, 584, 223, 101, 227, 227, 227, 247, + 247, 507, 321, 101, 99, 101, 101, 197, 321, 321, + 32767, 101, 507, 321, 507, 321, 199, 321, 321, 321, + 507, 321,32767, 101, 321, 214, 99, 99, 321,32767, + 32767,32767,32767, 520,32767,32767,32767,32767,32767,32767, + 32767, 222,32767,32767,32767,32767,32767,32767,32767,32767, + 550,32767, 568, 581, 451, 452, 454, 567, 565, 476, + 477, 478, 479, 480, 481, 482, 484, 612,32767, 524, + 32767,32767,32767, 341,32767, 622,32767,32767,32767, 9, + 74, 513, 42, 43, 51, 57, 539, 540, 541, 542, + 536, 537, 543, 538,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767,32767,32767,32767, 623, + 32767, 563,32767,32767,32767,32767, 450, 545, 589,32767, + 32767, 564, 615,32767,32767,32767,32767,32767,32767,32767, + 138,32767,32767,32767,32767,32767,32767,32767,32767,32767, + 32767, 550,32767, 136,32767,32767,32767,32767,32767,32767, + 32767,32767, 546,32767,32767,32767, 563,32767,32767,32767, + 32767, 317, 314,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767,32767,32767,32767, 563, + 32767,32767,32767,32767,32767, 294,32767, 311,32767,32767, + 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767, 388, 520, 297, 299, + 300,32767,32767,32767,32767, 364,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767,32767,32767,32767, 152, + 152, 3, 3, 344, 152, 152, 152, 344, 344, 152, + 344, 344, 344, 152, 152, 152, 152, 152, 152, 152, + 280, 185, 262, 265, 247, 247, 152, 356, 152, 390, + 390, 399 + ); + + protected array $goto = array( + 194, 194, 1050, 486, 704, 278, 278, 278, 278, 1081, + 488, 547, 547, 906, 864, 906, 906, 547, 713, 547, + 547, 547, 547, 547, 547, 547, 547, 166, 166, 166, + 166, 218, 195, 191, 191, 176, 178, 213, 191, 191, + 191, 191, 191, 192, 192, 192, 192, 192, 186, 187, + 188, 189, 190, 215, 213, 216, 544, 545, 427, 546, + 549, 550, 551, 552, 553, 554, 555, 556, 1167, 167, + 168, 169, 193, 170, 171, 172, 164, 173, 174, 175, + 177, 212, 214, 217, 237, 240, 251, 252, 253, 255, + 256, 257, 258, 259, 260, 261, 267, 268, 269, 270, + 276, 288, 289, 313, 314, 433, 434, 435, 606, 219, + 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, + 230, 231, 232, 233, 234, 186, 187, 188, 189, 190, + 215, 1167, 196, 197, 198, 199, 238, 179, 180, 200, + 181, 201, 197, 182, 239, 196, 163, 202, 203, 183, + 204, 205, 206, 184, 207, 208, 165, 209, 210, 211, + 185, 868, 247, 247, 591, 474, 474, 1098, 743, 645, + 647, 865, 608, 667, 474, 866, 469, 691, 694, 1023, + 702, 711, 1019, 718, 464, 1216, 881, 358, 840, 245, + 245, 245, 245, 242, 248, 1370, 1370, 358, 358, 350, + 557, 557, 557, 557, 893, 612, 341, 880, 358, 358, + 1370, 988, 358, 873, 1387, 922, 917, 918, 931, 874, + 919, 871, 920, 921, 872, 446, 925, 342, 341, 563, + 425, 1373, 1373, 358, 358, 899, 861, 1104, 1100, 1101, + 437, 669, 403, 406, 609, 613, 432, 334, 330, 331, + 333, 601, 436, 335, 438, 646, 629, 666, 1271, 1050, + 1271, 1271, 1056, 1055, 455, 455, 598, 455, 455, 1050, + 1271, 348, 1050, 519, 1050, 1050, 1050, 1050, 1050, 1050, + 1050, 1050, 1050, 861, 1360, 1050, 1050, 1050, 1050, 1332, + 1009, 1271, 507, 926, 508, 927, 1271, 1271, 1271, 1271, + 514, 401, 1271, 1271, 1271, 1352, 1352, 1352, 1352, 421, + 355, 355, 355, 355, 1124, 1152, 1125, 596, 939, 631, + 631, 668, 940, 439, 1164, 1302, 1302, 1302, 1302, 1302, + 1302, 1302, 1302, 1302, 1302, 1074, 439, 483, 1345, 1346, + 563, 444, 1057, 1057, 568, 561, 1059, 1060, 955, 673, + 1068, 1064, 1065, 955, 662, 663, 846, 680, 681, 682, + 320, 306, 455, 455, 455, 455, 455, 455, 455, 455, + 455, 455, 455, 455, 690, 5, 455, 6, 455, 455, + 602, 623, 340, 561, 568, 593, 594, 345, 604, 610, + 674, 625, 626, 980, 416, 712, 250, 250, 846, 25, + 846, 1347, 1348, 559, 1264, 559, 559, 1026, 1026, 336, + 1321, 1321, 431, 861, 620, 559, 1321, 1321, 1321, 1321, + 1321, 1321, 1321, 1321, 1321, 1321, 858, 1343, 886, 1343, + 1343, 639, 641, 643, 410, 971, 462, 883, 1262, 1343, + 624, 982, 982, 982, 982, 1031, 1147, 462, 976, 983, + 562, 588, 701, 351, 352, 562, 842, 588, 1087, 404, + 468, 1354, 1354, 1354, 1354, 746, 1041, 895, 701, 1138, + 484, 701, 477, 605, 478, 479, 1091, 377, 993, 0, + 891, 1318, 1318, 1378, 1379, 1339, 0, 1318, 1318, 1318, + 1318, 1318, 1318, 1318, 1318, 1318, 1318, 0, 0, 0, + 0, 0, 0, 548, 548, 1266, 0, 0, 889, 548, + 548, 548, 548, 548, 548, 548, 548, 548, 548, 414, + 415, 0, 0, 0, 678, 0, 679, 328, 418, 419, + 420, 0, 692, 0, 0, 422, 1089, 0, 0, 346, + 0, 0, 1341, 1341, 1089, 618, 632, 635, 636, 637, + 638, 659, 660, 661, 715, 717, 0, 0, 1267, 1268, + 0, 1254, 894, 882, 1086, 1090, 0, 856, 0, 271, + 319, 0, 319, 319, 1254, 991, 614, 1247, 957, 944, + 1154, 1248, 1251, 958, 0, 1252, 1269, 1329, 1330, 0, + 0, 1028, 0, 0, 0, 0, 0, 0, 981, 885, + 0, 672, 1007, 1053, 1053, 689, 965, 879, 0, 1045, + 1061, 1062, 607, 1117, 0, 0, 0, 0, 0, 1261, + 1136, 898, 0, 716, 0, 0, 0, 1012, 515, 707, + 984, 1115, 742, 0, 0, 560, 1021, 1016, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 751, 751 + ); + + protected array $gotoCheck = array( + 42, 42, 73, 84, 73, 23, 23, 23, 23, 128, + 84, 162, 162, 25, 25, 25, 25, 162, 9, 162, + 162, 162, 162, 162, 162, 162, 162, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 15, 5, 5, 48, 154, 154, 15, 48, 48, + 48, 26, 131, 48, 154, 27, 156, 48, 48, 48, + 48, 48, 48, 48, 83, 156, 35, 14, 6, 5, + 5, 5, 5, 5, 5, 188, 188, 14, 14, 97, + 107, 107, 107, 107, 35, 107, 174, 35, 14, 14, + 188, 49, 14, 15, 14, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 83, 15, 174, 174, 14, + 43, 188, 188, 14, 14, 45, 22, 15, 15, 15, + 66, 66, 59, 59, 59, 59, 66, 66, 66, 66, + 66, 66, 66, 66, 66, 66, 56, 56, 73, 73, + 73, 73, 119, 119, 23, 23, 178, 23, 23, 73, + 73, 185, 73, 76, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 22, 187, 73, 73, 73, 73, 14, + 103, 73, 160, 65, 160, 65, 73, 73, 73, 73, + 160, 62, 73, 73, 73, 9, 9, 9, 9, 14, + 24, 24, 24, 24, 146, 146, 146, 104, 73, 108, + 108, 64, 73, 118, 155, 108, 108, 108, 108, 108, + 108, 108, 108, 108, 108, 115, 118, 182, 182, 182, + 14, 113, 118, 118, 76, 76, 120, 120, 9, 118, + 118, 118, 118, 9, 86, 86, 12, 86, 86, 86, + 175, 175, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 117, 46, 23, 46, 23, 23, + 2, 2, 76, 76, 76, 76, 76, 76, 76, 76, + 121, 76, 76, 93, 93, 93, 5, 5, 12, 76, + 12, 184, 184, 19, 14, 19, 19, 107, 107, 29, + 176, 176, 13, 22, 13, 19, 176, 176, 176, 176, + 176, 176, 176, 176, 176, 176, 18, 131, 39, 131, + 131, 85, 85, 85, 28, 92, 19, 37, 166, 131, + 80, 19, 19, 19, 19, 110, 153, 19, 19, 19, + 9, 9, 7, 97, 97, 9, 7, 9, 130, 9, + 9, 131, 131, 131, 131, 99, 114, 41, 7, 149, + 157, 7, 9, 9, 9, 9, 133, 138, 96, -1, + 9, 177, 177, 9, 9, 131, -1, 177, 177, 177, + 177, 177, 177, 177, 177, 177, 177, -1, -1, -1, + -1, -1, -1, 179, 179, 20, -1, -1, 9, 179, + 179, 179, 179, 179, 179, 179, 179, 179, 179, 82, + 82, -1, -1, -1, 82, -1, 82, 9, 82, 82, + 82, -1, 82, -1, -1, 82, 131, -1, -1, 82, + -1, -1, 131, 131, 131, 81, 81, 81, 81, 81, + 81, 81, 81, 81, 81, 81, -1, -1, 20, 20, + -1, 20, 16, 16, 16, 16, -1, 20, -1, 24, + 24, -1, 24, 24, 20, 16, 17, 79, 79, 17, + 17, 79, 79, 79, -1, 79, 20, 20, 20, -1, + -1, 17, -1, -1, -1, -1, -1, -1, 16, 17, + -1, 17, 17, 89, 89, 89, 89, 17, -1, 89, + 89, 89, 8, 8, -1, -1, -1, -1, -1, 17, + 16, 16, -1, 8, -1, -1, -1, 50, 8, 8, + 50, 8, 50, -1, -1, 50, 50, 50, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 24, 24 + ); + + protected array $gotoBase = array( + 0, 0, -341, 0, 0, 161, 178, 445, 604, 8, + 0, 0, 62, 76, -108, -186, 104, 106, 119, 140, + 105, 0, -42, 2, 307, 10, 167, 171, 98, 115, + 0, 0, 0, 0, 0, -189, 0, 99, 0, 110, + 0, 20, -1, 207, 0, 209, -371, 0, -556, 193, + 615, 0, 0, 0, 0, 0, 216, 0, 0, 197, + 0, 0, 259, 0, 85, 279, 5, 0, 0, 0, + 0, 0, 0, -5, 0, 0, 1, 0, 0, 163, + 95, 184, 21, -94, -474, -55, -373, 0, 0, 324, + 0, 0, 111, 91, 0, 0, 29, -291, 0, 52, + 0, 0, 0, 255, 274, 0, 0, 172, 84, 0, + 71, 0, 0, 64, 45, 61, 0, 93, 59, -17, + 63, 100, 0, 0, 0, 0, 0, 0, 7, 0, + 78, 164, 0, 28, 0, 0, 0, 0, -273, 0, + 0, 0, 0, 0, 0, 0, 43, 0, 0, 19, + 0, 0, 0, 92, 131, 82, -90, 24, 0, 0, + -210, 0, -224, 0, 0, 0, 65, 0, 0, 0, + 0, 0, 0, 0, -89, 44, 175, 246, 237, 268, + 0, 0, 39, 0, 23, 241, 0, 253, -110, 0, + 0 + ); + + protected array $gotoDefault = array( + -32768, 520, 753, 4, 754, 948, 829, 838, 584, 538, + 714, 347, 633, 428, 1337, 924, 1153, 603, 857, 1280, + 1286, 463, 860, 325, 740, 936, 907, 908, 407, 393, + 399, 405, 657, 634, 501, 892, 459, 884, 493, 887, + 458, 896, 162, 424, 517, 900, 3, 903, 566, 934, + 986, 394, 911, 395, 685, 913, 587, 915, 916, 402, + 408, 409, 1158, 595, 630, 928, 254, 589, 929, 392, + 930, 938, 397, 400, 695, 473, 512, 506, 417, 1119, + 590, 617, 654, 452, 480, 628, 640, 627, 487, 440, + 423, 324, 970, 978, 494, 471, 992, 349, 1000, 748, + 1166, 648, 496, 1008, 649, 1015, 1018, 539, 540, 485, + 1030, 264, 1033, 497, 1042, 23, 675, 1047, 1048, 676, + 650, 1070, 651, 677, 652, 1072, 470, 585, 1080, 460, + 1088, 1326, 461, 1092, 262, 1095, 277, 353, 376, 441, + 1102, 1103, 9, 1109, 705, 706, 19, 273, 516, 1137, + 696, 1143, 272, 1146, 457, 1165, 456, 1235, 1237, 567, + 498, 1255, 310, 1258, 688, 513, 1263, 453, 1328, 454, + 541, 481, 332, 542, 1371, 305, 356, 329, 558, 311, + 357, 543, 482, 1334, 1342, 326, 31, 1361, 1372, 600, + 622 + ); + + protected array $ruleToNonTerminal = array( + 0, 1, 3, 3, 2, 5, 5, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, + 7, 7, 7, 7, 7, 8, 8, 9, 10, 11, + 11, 11, 12, 12, 13, 13, 14, 15, 15, 16, + 16, 17, 17, 18, 18, 21, 21, 22, 23, 23, + 24, 24, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 29, 29, 30, 30, 32, 34, 34, + 28, 36, 36, 33, 38, 38, 35, 35, 37, 37, + 39, 39, 31, 40, 40, 41, 43, 44, 44, 45, + 45, 46, 46, 48, 47, 47, 47, 47, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 25, 25, 50, 69, 69, 72, 72, 71, + 70, 70, 63, 75, 75, 76, 76, 77, 77, 78, + 78, 79, 79, 80, 80, 26, 26, 27, 27, 27, + 27, 27, 88, 88, 90, 90, 83, 83, 91, 91, + 92, 92, 92, 84, 84, 87, 87, 85, 85, 93, + 94, 94, 57, 57, 65, 65, 68, 68, 68, 67, + 95, 95, 96, 58, 58, 58, 58, 97, 97, 98, + 98, 99, 99, 100, 101, 101, 102, 102, 103, 103, + 55, 55, 51, 51, 105, 53, 53, 106, 52, 52, + 54, 54, 64, 64, 64, 64, 81, 81, 109, 109, + 111, 111, 112, 112, 112, 112, 112, 112, 112, 110, + 110, 110, 115, 115, 115, 115, 89, 89, 118, 118, + 118, 119, 119, 116, 116, 120, 120, 122, 122, 123, + 123, 117, 124, 124, 121, 125, 125, 125, 125, 113, + 113, 82, 82, 82, 20, 20, 20, 127, 126, 126, + 128, 128, 128, 128, 60, 129, 129, 130, 61, 132, + 132, 133, 133, 134, 134, 86, 135, 135, 135, 135, + 135, 135, 135, 135, 141, 141, 142, 142, 143, 143, + 143, 143, 143, 144, 145, 145, 140, 140, 136, 136, + 139, 139, 147, 147, 146, 146, 146, 146, 146, 146, + 146, 146, 146, 146, 137, 148, 148, 150, 149, 149, + 138, 138, 114, 114, 151, 151, 153, 153, 153, 152, + 152, 62, 104, 154, 154, 56, 56, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 161, 162, 162, 163, 155, 155, 160, 160, 164, + 165, 165, 166, 167, 168, 168, 168, 168, 19, 19, + 73, 73, 73, 73, 156, 156, 156, 156, 170, 170, + 159, 159, 159, 157, 157, 176, 176, 176, 176, 176, + 176, 176, 176, 176, 176, 177, 177, 177, 108, 179, + 179, 179, 179, 158, 158, 158, 158, 158, 158, 158, + 158, 59, 59, 173, 173, 173, 173, 173, 180, 180, + 169, 169, 169, 169, 181, 181, 181, 181, 181, 74, + 74, 66, 66, 66, 66, 131, 131, 131, 131, 184, + 183, 172, 172, 172, 172, 172, 172, 171, 171, 171, + 182, 182, 182, 182, 107, 178, 186, 186, 185, 185, + 187, 187, 187, 187, 187, 187, 187, 187, 175, 175, + 175, 175, 174, 189, 188, 188, 188, 188, 188, 188, + 188, 188, 190, 190, 190, 190 + ); + + protected array $ruleToLength = array( + 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 1, 0, 1, 1, 2, 1, 3, 4, 1, 2, + 0, 1, 1, 1, 1, 4, 3, 5, 4, 3, + 4, 2, 3, 1, 1, 7, 6, 2, 3, 1, + 2, 3, 1, 2, 3, 1, 1, 3, 1, 3, + 1, 2, 2, 3, 1, 3, 2, 3, 1, 3, + 3, 2, 0, 1, 1, 1, 1, 1, 3, 7, + 10, 5, 7, 9, 5, 3, 3, 3, 3, 3, + 3, 1, 2, 5, 7, 9, 6, 5, 6, 3, + 2, 1, 1, 1, 1, 0, 2, 1, 3, 8, + 0, 4, 2, 1, 3, 0, 1, 0, 1, 0, + 1, 3, 1, 1, 1, 8, 9, 7, 8, 7, + 6, 8, 0, 2, 0, 2, 1, 2, 1, 2, + 1, 1, 1, 0, 2, 0, 2, 0, 2, 2, + 1, 3, 1, 4, 1, 4, 1, 1, 4, 2, + 1, 3, 3, 3, 4, 4, 5, 0, 2, 4, + 3, 1, 1, 7, 0, 2, 1, 3, 3, 4, + 1, 4, 0, 2, 5, 0, 2, 6, 0, 2, + 0, 3, 1, 2, 1, 1, 2, 0, 1, 3, + 0, 2, 1, 1, 1, 1, 1, 1, 1, 7, + 9, 6, 1, 2, 1, 1, 1, 1, 1, 1, + 1, 1, 3, 3, 3, 1, 3, 3, 3, 3, + 3, 1, 3, 3, 1, 1, 2, 1, 1, 0, + 1, 0, 2, 2, 2, 4, 3, 1, 1, 3, + 1, 2, 2, 3, 2, 3, 1, 1, 2, 3, + 1, 1, 3, 2, 0, 1, 5, 7, 5, 6, + 10, 3, 5, 1, 1, 3, 0, 2, 4, 5, + 4, 4, 4, 3, 1, 1, 1, 1, 1, 1, + 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 2, 1, 3, 1, 1, 3, + 0, 2, 0, 3, 5, 8, 1, 3, 3, 0, + 2, 2, 2, 3, 1, 0, 1, 1, 3, 3, + 3, 4, 4, 1, 1, 2, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, + 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 2, 2, 2, 2, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 5, 4, 3, 4, + 4, 2, 2, 4, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 1, 3, 2, 1, 2, + 4, 2, 2, 8, 9, 8, 9, 9, 10, 9, + 10, 8, 3, 2, 2, 1, 1, 0, 4, 2, + 1, 3, 2, 1, 2, 2, 2, 4, 1, 1, + 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, + 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 3, 5, 3, 3, 4, + 1, 1, 3, 1, 1, 1, 1, 1, 3, 2, + 3, 0, 1, 1, 3, 1, 1, 1, 1, 1, + 1, 3, 1, 1, 1, 4, 1, 4, 4, 0, + 1, 1, 1, 3, 3, 1, 4, 2, 2, 1, + 3, 1, 4, 3, 3, 3, 3, 1, 3, 1, + 1, 3, 1, 1, 4, 1, 1, 1, 3, 1, + 1, 2, 1, 3, 4, 3, 2, 0, 2, 2, + 1, 2, 1, 1, 1, 4, 3, 3, 3, 3, + 6, 3, 1, 1, 2, 1 + ); + + protected function initReduceCallbacks(): void { + $this->reduceCallbacks = [ + 0 => null, + 1 => static function ($self, $stackPos) { + $self->semValue = $self->handleNamespaces($self->semStack[$stackPos-(1-1)]); + }, + 2 => static function ($self, $stackPos) { + if ($self->semStack[$stackPos-(2-2)] !== null) { $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; } $self->semValue = $self->semStack[$stackPos-(2-1)];; + }, + 3 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 4 => static function ($self, $stackPos) { + $nop = $self->maybeCreateZeroLengthNop($self->tokenPos);; + if ($nop !== null) { $self->semStack[$stackPos-(1-1)][] = $nop; } $self->semValue = $self->semStack[$stackPos-(1-1)]; + }, + 5 => null, + 6 => null, + 7 => null, + 8 => null, + 9 => null, + 10 => null, + 11 => null, + 12 => null, + 13 => null, + 14 => null, + 15 => null, + 16 => null, + 17 => null, + 18 => null, + 19 => null, + 20 => null, + 21 => null, + 22 => null, + 23 => null, + 24 => null, + 25 => null, + 26 => null, + 27 => null, + 28 => null, + 29 => null, + 30 => null, + 31 => null, + 32 => null, + 33 => null, + 34 => null, + 35 => null, + 36 => null, + 37 => null, + 38 => null, + 39 => null, + 40 => null, + 41 => null, + 42 => null, + 43 => null, + 44 => null, + 45 => null, + 46 => null, + 47 => null, + 48 => null, + 49 => null, + 50 => null, + 51 => null, + 52 => null, + 53 => null, + 54 => null, + 55 => null, + 56 => null, + 57 => null, + 58 => null, + 59 => null, + 60 => null, + 61 => null, + 62 => null, + 63 => null, + 64 => null, + 65 => null, + 66 => null, + 67 => null, + 68 => null, + 69 => null, + 70 => null, + 71 => null, + 72 => null, + 73 => null, + 74 => null, + 75 => null, + 76 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(1-1)]; if ($self->semValue === "emitError(new Error('Cannot use "getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos]))); + }, + 77 => null, + 78 => null, + 79 => null, + 80 => null, + 81 => null, + 82 => null, + 83 => null, + 84 => null, + 85 => static function ($self, $stackPos) { + $self->semValue = new Node\Identifier($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 86 => static function ($self, $stackPos) { + $self->semValue = new Node\Identifier($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 87 => static function ($self, $stackPos) { + $self->semValue = new Node\Identifier($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 88 => static function ($self, $stackPos) { + $self->semValue = new Node\Identifier($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 89 => static function ($self, $stackPos) { + $self->semValue = new Name($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 90 => static function ($self, $stackPos) { + $self->semValue = new Name($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 91 => static function ($self, $stackPos) { + $self->semValue = new Name($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 92 => static function ($self, $stackPos) { + $self->semValue = new Name($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 93 => static function ($self, $stackPos) { + $self->semValue = new Name($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 94 => null, + 95 => static function ($self, $stackPos) { + $self->semValue = new Name(substr($self->semStack[$stackPos-(1-1)], 1), $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 96 => static function ($self, $stackPos) { + $self->semValue = new Expr\Variable(substr($self->semStack[$stackPos-(1-1)], 1), $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 97 => static function ($self, $stackPos) { + /* nothing */ + }, + 98 => static function ($self, $stackPos) { + /* nothing */ + }, + 99 => static function ($self, $stackPos) { + /* nothing */ + }, + 100 => static function ($self, $stackPos) { + $self->emitError(new Error('A trailing comma is not allowed here', $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos]))); + }, + 101 => null, + 102 => null, + 103 => static function ($self, $stackPos) { + $self->semValue = new Node\Attribute($self->semStack[$stackPos-(1-1)], [], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 104 => static function ($self, $stackPos) { + $self->semValue = new Node\Attribute($self->semStack[$stackPos-(2-1)], $self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 105 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 106 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 107 => static function ($self, $stackPos) { + $self->semValue = new Node\AttributeGroup($self->semStack[$stackPos-(4-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 108 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 109 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; $self->semValue = $self->semStack[$stackPos-(2-1)]; + }, + 110 => static function ($self, $stackPos) { + $self->semValue = []; + }, + 111 => null, + 112 => null, + 113 => null, + 114 => null, + 115 => static function ($self, $stackPos) { + $self->semValue = new Stmt\HaltCompiler($self->handleHaltCompiler(), $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 116 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Namespace_($self->semStack[$stackPos-(3-2)], null, $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + $self->semValue->setAttribute('kind', Stmt\Namespace_::KIND_SEMICOLON); + $self->checkNamespace($self->semValue); + }, + 117 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Namespace_($self->semStack[$stackPos-(5-2)], $self->semStack[$stackPos-(5-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); + $self->semValue->setAttribute('kind', Stmt\Namespace_::KIND_BRACED); + $self->checkNamespace($self->semValue); + }, + 118 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Namespace_(null, $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + $self->semValue->setAttribute('kind', Stmt\Namespace_::KIND_BRACED); + $self->checkNamespace($self->semValue); + }, + 119 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Use_($self->semStack[$stackPos-(3-2)], Stmt\Use_::TYPE_NORMAL, $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 120 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Use_($self->semStack[$stackPos-(4-3)], $self->semStack[$stackPos-(4-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 121 => null, + 122 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Const_($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 123 => static function ($self, $stackPos) { + $self->semValue = Stmt\Use_::TYPE_FUNCTION; + }, + 124 => static function ($self, $stackPos) { + $self->semValue = Stmt\Use_::TYPE_CONSTANT; + }, + 125 => static function ($self, $stackPos) { + $self->semValue = new Stmt\GroupUse($self->semStack[$stackPos-(7-3)], $self->semStack[$stackPos-(7-6)], $self->semStack[$stackPos-(7-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(7-1)], $self->tokenEndStack[$stackPos])); + }, + 126 => static function ($self, $stackPos) { + $self->semValue = new Stmt\GroupUse($self->semStack[$stackPos-(6-2)], $self->semStack[$stackPos-(6-5)], Stmt\Use_::TYPE_UNKNOWN, $self->getAttributes($self->tokenStartStack[$stackPos-(6-1)], $self->tokenEndStack[$stackPos])); + }, + 127 => null, + 128 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 129 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 130 => null, + 131 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 132 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 133 => null, + 134 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 135 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 136 => static function ($self, $stackPos) { + $self->semValue = new Node\UseItem($self->semStack[$stackPos-(1-1)], null, Stmt\Use_::TYPE_UNKNOWN, $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); $self->checkUseUse($self->semValue, $stackPos-(1-1)); + }, + 137 => static function ($self, $stackPos) { + $self->semValue = new Node\UseItem($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], Stmt\Use_::TYPE_UNKNOWN, $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); $self->checkUseUse($self->semValue, $stackPos-(3-3)); + }, + 138 => static function ($self, $stackPos) { + $self->semValue = new Node\UseItem($self->semStack[$stackPos-(1-1)], null, Stmt\Use_::TYPE_UNKNOWN, $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); $self->checkUseUse($self->semValue, $stackPos-(1-1)); + }, + 139 => static function ($self, $stackPos) { + $self->semValue = new Node\UseItem($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], Stmt\Use_::TYPE_UNKNOWN, $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); $self->checkUseUse($self->semValue, $stackPos-(3-3)); + }, + 140 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(1-1)]; $self->semValue->type = Stmt\Use_::TYPE_NORMAL; + }, + 141 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(2-2)]; $self->semValue->type = $self->semStack[$stackPos-(2-1)]; + }, + 142 => null, + 143 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 144 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 145 => static function ($self, $stackPos) { + $self->semValue = new Node\Const_($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 146 => null, + 147 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 148 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 149 => static function ($self, $stackPos) { + $self->semValue = new Node\Const_(new Node\Identifier($self->semStack[$stackPos-(3-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos-(3-1)])), $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 150 => static function ($self, $stackPos) { + $self->semValue = new Node\Const_(new Node\Identifier($self->semStack[$stackPos-(3-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos-(3-1)])), $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 151 => static function ($self, $stackPos) { + if ($self->semStack[$stackPos-(2-2)] !== null) { $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; } $self->semValue = $self->semStack[$stackPos-(2-1)];; + }, + 152 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 153 => static function ($self, $stackPos) { + $nop = $self->maybeCreateZeroLengthNop($self->tokenPos);; + if ($nop !== null) { $self->semStack[$stackPos-(1-1)][] = $nop; } $self->semValue = $self->semStack[$stackPos-(1-1)]; + }, + 154 => null, + 155 => null, + 156 => null, + 157 => static function ($self, $stackPos) { + throw new Error('__HALT_COMPILER() can only be used from the outermost scope', $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 158 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Block($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 159 => static function ($self, $stackPos) { + $self->semValue = new Stmt\If_($self->semStack[$stackPos-(7-3)], ['stmts' => $self->semStack[$stackPos-(7-5)], 'elseifs' => $self->semStack[$stackPos-(7-6)], 'else' => $self->semStack[$stackPos-(7-7)]], $self->getAttributes($self->tokenStartStack[$stackPos-(7-1)], $self->tokenEndStack[$stackPos])); + }, + 160 => static function ($self, $stackPos) { + $self->semValue = new Stmt\If_($self->semStack[$stackPos-(10-3)], ['stmts' => $self->semStack[$stackPos-(10-6)], 'elseifs' => $self->semStack[$stackPos-(10-7)], 'else' => $self->semStack[$stackPos-(10-8)]], $self->getAttributes($self->tokenStartStack[$stackPos-(10-1)], $self->tokenEndStack[$stackPos])); + }, + 161 => static function ($self, $stackPos) { + $self->semValue = new Stmt\While_($self->semStack[$stackPos-(5-3)], $self->semStack[$stackPos-(5-5)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); + }, + 162 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Do_($self->semStack[$stackPos-(7-5)], $self->semStack[$stackPos-(7-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(7-1)], $self->tokenEndStack[$stackPos])); + }, + 163 => static function ($self, $stackPos) { + $self->semValue = new Stmt\For_(['init' => $self->semStack[$stackPos-(9-3)], 'cond' => $self->semStack[$stackPos-(9-5)], 'loop' => $self->semStack[$stackPos-(9-7)], 'stmts' => $self->semStack[$stackPos-(9-9)]], $self->getAttributes($self->tokenStartStack[$stackPos-(9-1)], $self->tokenEndStack[$stackPos])); + }, + 164 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Switch_($self->semStack[$stackPos-(5-3)], $self->semStack[$stackPos-(5-5)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); + }, + 165 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Break_($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 166 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Continue_($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 167 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Return_($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 168 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Global_($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 169 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Static_($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 170 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Echo_($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 171 => static function ($self, $stackPos) { + + $self->semValue = new Stmt\InlineHTML($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + $self->semValue->setAttribute('hasLeadingNewline', $self->inlineHtmlHasLeadingNewline($stackPos-(1-1))); + + }, + 172 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Expression($self->semStack[$stackPos-(2-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 173 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Unset_($self->semStack[$stackPos-(5-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); + }, + 174 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Foreach_($self->semStack[$stackPos-(7-3)], $self->semStack[$stackPos-(7-5)][0], ['keyVar' => null, 'byRef' => $self->semStack[$stackPos-(7-5)][1], 'stmts' => $self->semStack[$stackPos-(7-7)]], $self->getAttributes($self->tokenStartStack[$stackPos-(7-1)], $self->tokenEndStack[$stackPos])); + }, + 175 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Foreach_($self->semStack[$stackPos-(9-3)], $self->semStack[$stackPos-(9-7)][0], ['keyVar' => $self->semStack[$stackPos-(9-5)], 'byRef' => $self->semStack[$stackPos-(9-7)][1], 'stmts' => $self->semStack[$stackPos-(9-9)]], $self->getAttributes($self->tokenStartStack[$stackPos-(9-1)], $self->tokenEndStack[$stackPos])); + }, + 176 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Foreach_($self->semStack[$stackPos-(6-3)], new Expr\Error($self->getAttributes($self->tokenStartStack[$stackPos-(6-4)], $self->tokenEndStack[$stackPos-(6-4)])), ['stmts' => $self->semStack[$stackPos-(6-6)]], $self->getAttributes($self->tokenStartStack[$stackPos-(6-1)], $self->tokenEndStack[$stackPos])); + }, + 177 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Declare_($self->semStack[$stackPos-(5-3)], $self->semStack[$stackPos-(5-5)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); + }, + 178 => static function ($self, $stackPos) { + $self->semValue = new Stmt\TryCatch($self->semStack[$stackPos-(6-3)], $self->semStack[$stackPos-(6-5)], $self->semStack[$stackPos-(6-6)], $self->getAttributes($self->tokenStartStack[$stackPos-(6-1)], $self->tokenEndStack[$stackPos])); $self->checkTryCatch($self->semValue); + }, + 179 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Goto_($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 180 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Label($self->semStack[$stackPos-(2-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 181 => static function ($self, $stackPos) { + $self->semValue = null; /* means: no statement */ + }, + 182 => null, + 183 => static function ($self, $stackPos) { + $self->semValue = $self->maybeCreateNop($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos]); + }, + 184 => static function ($self, $stackPos) { + if ($self->semStack[$stackPos-(1-1)] instanceof Stmt\Block) { $self->semValue = $self->semStack[$stackPos-(1-1)]->stmts; } else if ($self->semStack[$stackPos-(1-1)] === null) { $self->semValue = []; } else { $self->semValue = [$self->semStack[$stackPos-(1-1)]]; }; + }, + 185 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 186 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; $self->semValue = $self->semStack[$stackPos-(2-1)]; + }, + 187 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 188 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 189 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Catch_($self->semStack[$stackPos-(8-3)], $self->semStack[$stackPos-(8-4)], $self->semStack[$stackPos-(8-7)], $self->getAttributes($self->tokenStartStack[$stackPos-(8-1)], $self->tokenEndStack[$stackPos])); + }, + 190 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 191 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Finally_($self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 192 => null, + 193 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 194 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 195 => static function ($self, $stackPos) { + $self->semValue = false; + }, + 196 => static function ($self, $stackPos) { + $self->semValue = true; + }, + 197 => static function ($self, $stackPos) { + $self->semValue = false; + }, + 198 => static function ($self, $stackPos) { + $self->semValue = true; + }, + 199 => static function ($self, $stackPos) { + $self->semValue = false; + }, + 200 => static function ($self, $stackPos) { + $self->semValue = true; + }, + 201 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; + }, + 202 => static function ($self, $stackPos) { + $self->semValue = []; + }, + 203 => null, + 204 => static function ($self, $stackPos) { + $self->semValue = new Node\Identifier($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 205 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Function_($self->semStack[$stackPos-(8-3)], ['byRef' => $self->semStack[$stackPos-(8-2)], 'params' => $self->semStack[$stackPos-(8-5)], 'returnType' => $self->semStack[$stackPos-(8-7)], 'stmts' => $self->semStack[$stackPos-(8-8)], 'attrGroups' => []], $self->getAttributes($self->tokenStartStack[$stackPos-(8-1)], $self->tokenEndStack[$stackPos])); + }, + 206 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Function_($self->semStack[$stackPos-(9-4)], ['byRef' => $self->semStack[$stackPos-(9-3)], 'params' => $self->semStack[$stackPos-(9-6)], 'returnType' => $self->semStack[$stackPos-(9-8)], 'stmts' => $self->semStack[$stackPos-(9-9)], 'attrGroups' => $self->semStack[$stackPos-(9-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(9-1)], $self->tokenEndStack[$stackPos])); + }, + 207 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Class_($self->semStack[$stackPos-(7-2)], ['type' => $self->semStack[$stackPos-(7-1)], 'extends' => $self->semStack[$stackPos-(7-3)], 'implements' => $self->semStack[$stackPos-(7-4)], 'stmts' => $self->semStack[$stackPos-(7-6)], 'attrGroups' => []], $self->getAttributes($self->tokenStartStack[$stackPos-(7-1)], $self->tokenEndStack[$stackPos])); + $self->checkClass($self->semValue, $stackPos-(7-2)); + }, + 208 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Class_($self->semStack[$stackPos-(8-3)], ['type' => $self->semStack[$stackPos-(8-2)], 'extends' => $self->semStack[$stackPos-(8-4)], 'implements' => $self->semStack[$stackPos-(8-5)], 'stmts' => $self->semStack[$stackPos-(8-7)], 'attrGroups' => $self->semStack[$stackPos-(8-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(8-1)], $self->tokenEndStack[$stackPos])); + $self->checkClass($self->semValue, $stackPos-(8-3)); + }, + 209 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Interface_($self->semStack[$stackPos-(7-3)], ['extends' => $self->semStack[$stackPos-(7-4)], 'stmts' => $self->semStack[$stackPos-(7-6)], 'attrGroups' => $self->semStack[$stackPos-(7-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(7-1)], $self->tokenEndStack[$stackPos])); + $self->checkInterface($self->semValue, $stackPos-(7-3)); + }, + 210 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Trait_($self->semStack[$stackPos-(6-3)], ['stmts' => $self->semStack[$stackPos-(6-5)], 'attrGroups' => $self->semStack[$stackPos-(6-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(6-1)], $self->tokenEndStack[$stackPos])); + }, + 211 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Enum_($self->semStack[$stackPos-(8-3)], ['scalarType' => $self->semStack[$stackPos-(8-4)], 'implements' => $self->semStack[$stackPos-(8-5)], 'stmts' => $self->semStack[$stackPos-(8-7)], 'attrGroups' => $self->semStack[$stackPos-(8-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(8-1)], $self->tokenEndStack[$stackPos])); + $self->checkEnum($self->semValue, $stackPos-(8-3)); + }, + 212 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 213 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(2-2)]; + }, + 214 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 215 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(2-2)]; + }, + 216 => static function ($self, $stackPos) { + $self->semValue = 0; + }, + 217 => null, + 218 => null, + 219 => static function ($self, $stackPos) { + $self->checkClassModifier($self->semStack[$stackPos-(2-1)], $self->semStack[$stackPos-(2-2)], $stackPos-(2-2)); $self->semValue = $self->semStack[$stackPos-(2-1)] | $self->semStack[$stackPos-(2-2)]; + }, + 220 => static function ($self, $stackPos) { + $self->semValue = Modifiers::ABSTRACT; + }, + 221 => static function ($self, $stackPos) { + $self->semValue = Modifiers::FINAL; + }, + 222 => static function ($self, $stackPos) { + $self->semValue = Modifiers::READONLY; + }, + 223 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 224 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(2-2)]; + }, + 225 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 226 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(2-2)]; + }, + 227 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 228 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(2-2)]; + }, + 229 => null, + 230 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 231 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 232 => null, + 233 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(4-2)]; + }, + 234 => null, + 235 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(4-2)]; + }, + 236 => static function ($self, $stackPos) { + if ($self->semStack[$stackPos-(1-1)] instanceof Stmt\Block) { $self->semValue = $self->semStack[$stackPos-(1-1)]->stmts; } else if ($self->semStack[$stackPos-(1-1)] === null) { $self->semValue = []; } else { $self->semValue = [$self->semStack[$stackPos-(1-1)]]; }; + }, + 237 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 238 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(4-2)]; + }, + 239 => null, + 240 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 241 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 242 => static function ($self, $stackPos) { + $self->semValue = new Node\DeclareItem($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 243 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; + }, + 244 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(4-3)]; + }, + 245 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(4-2)]; + }, + 246 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(5-3)]; + }, + 247 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 248 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; $self->semValue = $self->semStack[$stackPos-(2-1)]; + }, + 249 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Case_($self->semStack[$stackPos-(4-2)], $self->semStack[$stackPos-(4-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 250 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Case_(null, $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 251 => null, + 252 => null, + 253 => static function ($self, $stackPos) { + $self->semValue = new Expr\Match_($self->semStack[$stackPos-(7-3)], $self->semStack[$stackPos-(7-6)], $self->getAttributes($self->tokenStartStack[$stackPos-(7-1)], $self->tokenEndStack[$stackPos])); + }, + 254 => static function ($self, $stackPos) { + $self->semValue = []; + }, + 255 => null, + 256 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 257 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 258 => static function ($self, $stackPos) { + $self->semValue = new Node\MatchArm($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 259 => static function ($self, $stackPos) { + $self->semValue = new Node\MatchArm(null, $self->semStack[$stackPos-(4-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 260 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(1-1)]; + }, + 261 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(4-2)]; + }, + 262 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 263 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; $self->semValue = $self->semStack[$stackPos-(2-1)]; + }, + 264 => static function ($self, $stackPos) { + $self->semValue = new Stmt\ElseIf_($self->semStack[$stackPos-(5-3)], $self->semStack[$stackPos-(5-5)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); + }, + 265 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 266 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; $self->semValue = $self->semStack[$stackPos-(2-1)]; + }, + 267 => static function ($self, $stackPos) { + $self->semValue = new Stmt\ElseIf_($self->semStack[$stackPos-(6-3)], $self->semStack[$stackPos-(6-6)], $self->getAttributes($self->tokenStartStack[$stackPos-(6-1)], $self->tokenEndStack[$stackPos])); $self->fixupAlternativeElse($self->semValue); + }, + 268 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 269 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Else_($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 270 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 271 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Else_($self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); $self->fixupAlternativeElse($self->semValue); + }, + 272 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)], false); + }, + 273 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(2-2)], true); + }, + 274 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)], false); + }, + 275 => static function ($self, $stackPos) { + $self->semValue = array($self->fixupArrayDestructuring($self->semStack[$stackPos-(1-1)]), false); + }, + 276 => null, + 277 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 278 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 279 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 280 => static function ($self, $stackPos) { + $self->semValue = 0; + }, + 281 => static function ($self, $stackPos) { + $self->checkModifier($self->semStack[$stackPos-(2-1)], $self->semStack[$stackPos-(2-2)], $stackPos-(2-2)); $self->semValue = $self->semStack[$stackPos-(2-1)] | $self->semStack[$stackPos-(2-2)]; + }, + 282 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PUBLIC; + }, + 283 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PROTECTED; + }, + 284 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PRIVATE; + }, + 285 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PUBLIC_SET; + }, + 286 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PROTECTED_SET; + }, + 287 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PRIVATE_SET; + }, + 288 => static function ($self, $stackPos) { + $self->semValue = Modifiers::READONLY; + }, + 289 => static function ($self, $stackPos) { + $self->semValue = new Node\Param($self->semStack[$stackPos-(7-6)], null, $self->semStack[$stackPos-(7-3)], $self->semStack[$stackPos-(7-4)], $self->semStack[$stackPos-(7-5)], $self->getAttributes($self->tokenStartStack[$stackPos-(7-1)], $self->tokenEndStack[$stackPos]), $self->semStack[$stackPos-(7-2)], $self->semStack[$stackPos-(7-1)], $self->semStack[$stackPos-(7-7)]); + $self->checkParam($self->semValue); + }, + 290 => static function ($self, $stackPos) { + $self->semValue = new Node\Param($self->semStack[$stackPos-(9-6)], $self->semStack[$stackPos-(9-8)], $self->semStack[$stackPos-(9-3)], $self->semStack[$stackPos-(9-4)], $self->semStack[$stackPos-(9-5)], $self->getAttributes($self->tokenStartStack[$stackPos-(9-1)], $self->tokenEndStack[$stackPos]), $self->semStack[$stackPos-(9-2)], $self->semStack[$stackPos-(9-1)], $self->semStack[$stackPos-(9-9)]); + $self->checkParam($self->semValue); + }, + 291 => static function ($self, $stackPos) { + $self->semValue = new Node\Param(new Expr\Error($self->getAttributes($self->tokenStartStack[$stackPos-(6-1)], $self->tokenEndStack[$stackPos])), null, $self->semStack[$stackPos-(6-3)], $self->semStack[$stackPos-(6-4)], $self->semStack[$stackPos-(6-5)], $self->getAttributes($self->tokenStartStack[$stackPos-(6-1)], $self->tokenEndStack[$stackPos]), $self->semStack[$stackPos-(6-2)], $self->semStack[$stackPos-(6-1)]); + }, + 292 => null, + 293 => static function ($self, $stackPos) { + $self->semValue = new Node\NullableType($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 294 => static function ($self, $stackPos) { + $self->semValue = new Node\UnionType($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 295 => null, + 296 => null, + 297 => static function ($self, $stackPos) { + $self->semValue = new Node\Name('static', $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 298 => static function ($self, $stackPos) { + $self->semValue = $self->handleBuiltinTypes($self->semStack[$stackPos-(1-1)]); + }, + 299 => static function ($self, $stackPos) { + $self->semValue = new Node\Identifier('array', $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 300 => static function ($self, $stackPos) { + $self->semValue = new Node\Identifier('callable', $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 301 => null, + 302 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; + }, + 303 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)]); + }, + 304 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 305 => null, + 306 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; + }, + 307 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)]); + }, + 308 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 309 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)]); + }, + 310 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 311 => static function ($self, $stackPos) { + $self->semValue = new Node\IntersectionType($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 312 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)]); + }, + 313 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 314 => static function ($self, $stackPos) { + $self->semValue = new Node\IntersectionType($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 315 => null, + 316 => static function ($self, $stackPos) { + $self->semValue = new Node\NullableType($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 317 => static function ($self, $stackPos) { + $self->semValue = new Node\UnionType($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 318 => null, + 319 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 320 => null, + 321 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 322 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(2-2)]; + }, + 323 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 324 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 325 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(4-2)]; + }, + 326 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(3-2)]); + }, + 327 => static function ($self, $stackPos) { + $self->semValue = new Node\VariadicPlaceholder($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 328 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 329 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 330 => static function ($self, $stackPos) { + $self->semValue = new Node\Arg($self->semStack[$stackPos-(1-1)], false, false, $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 331 => static function ($self, $stackPos) { + $self->semValue = new Node\Arg($self->semStack[$stackPos-(2-2)], true, false, $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 332 => static function ($self, $stackPos) { + $self->semValue = new Node\Arg($self->semStack[$stackPos-(2-2)], false, true, $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 333 => static function ($self, $stackPos) { + $self->semValue = new Node\Arg($self->semStack[$stackPos-(3-3)], false, false, $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos]), $self->semStack[$stackPos-(3-1)]); + }, + 334 => null, + 335 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 336 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 337 => null, + 338 => null, + 339 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 340 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 341 => static function ($self, $stackPos) { + $self->semValue = new Node\StaticVar($self->semStack[$stackPos-(1-1)], null, $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 342 => static function ($self, $stackPos) { + $self->semValue = new Node\StaticVar($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 343 => static function ($self, $stackPos) { + if ($self->semStack[$stackPos-(2-2)] !== null) { $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; $self->semValue = $self->semStack[$stackPos-(2-1)]; } else { $self->semValue = $self->semStack[$stackPos-(2-1)]; } + }, + 344 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 345 => static function ($self, $stackPos) { + $nop = $self->maybeCreateZeroLengthNop($self->tokenPos);; + if ($nop !== null) { $self->semStack[$stackPos-(1-1)][] = $nop; } $self->semValue = $self->semStack[$stackPos-(1-1)]; + }, + 346 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Property($self->semStack[$stackPos-(5-2)], $self->semStack[$stackPos-(5-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos]), $self->semStack[$stackPos-(5-3)], $self->semStack[$stackPos-(5-1)]); + }, + 347 => static function ($self, $stackPos) { + $self->semValue = new Stmt\Property($self->semStack[$stackPos-(7-2)], $self->semStack[$stackPos-(7-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(7-1)], $self->tokenEndStack[$stackPos]), $self->semStack[$stackPos-(7-3)], $self->semStack[$stackPos-(7-1)], $self->semStack[$stackPos-(7-6)]); + $self->checkPropertyHookList($self->semStack[$stackPos-(7-6)], $stackPos-(7-5)); + }, + 348 => static function ($self, $stackPos) { + $self->semValue = new Stmt\ClassConst($self->semStack[$stackPos-(5-4)], $self->semStack[$stackPos-(5-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos]), $self->semStack[$stackPos-(5-1)]); + $self->checkClassConst($self->semValue, $stackPos-(5-2)); + }, + 349 => static function ($self, $stackPos) { + $self->semValue = new Stmt\ClassConst($self->semStack[$stackPos-(6-5)], $self->semStack[$stackPos-(6-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(6-1)], $self->tokenEndStack[$stackPos]), $self->semStack[$stackPos-(6-1)], $self->semStack[$stackPos-(6-4)]); + $self->checkClassConst($self->semValue, $stackPos-(6-2)); + }, + 350 => static function ($self, $stackPos) { + $self->semValue = new Stmt\ClassMethod($self->semStack[$stackPos-(10-5)], ['type' => $self->semStack[$stackPos-(10-2)], 'byRef' => $self->semStack[$stackPos-(10-4)], 'params' => $self->semStack[$stackPos-(10-7)], 'returnType' => $self->semStack[$stackPos-(10-9)], 'stmts' => $self->semStack[$stackPos-(10-10)], 'attrGroups' => $self->semStack[$stackPos-(10-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(10-1)], $self->tokenEndStack[$stackPos])); + $self->checkClassMethod($self->semValue, $stackPos-(10-2)); + }, + 351 => static function ($self, $stackPos) { + $self->semValue = new Stmt\TraitUse($self->semStack[$stackPos-(3-2)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 352 => static function ($self, $stackPos) { + $self->semValue = new Stmt\EnumCase($self->semStack[$stackPos-(5-3)], $self->semStack[$stackPos-(5-4)], $self->semStack[$stackPos-(5-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); + }, + 353 => static function ($self, $stackPos) { + $self->semValue = null; /* will be skipped */ + }, + 354 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 355 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; + }, + 356 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 357 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; $self->semValue = $self->semStack[$stackPos-(2-1)]; + }, + 358 => static function ($self, $stackPos) { + $self->semValue = new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Precedence($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 359 => static function ($self, $stackPos) { + $self->semValue = new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(5-1)][0], $self->semStack[$stackPos-(5-1)][1], $self->semStack[$stackPos-(5-3)], $self->semStack[$stackPos-(5-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); + }, + 360 => static function ($self, $stackPos) { + $self->semValue = new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], $self->semStack[$stackPos-(4-3)], null, $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 361 => static function ($self, $stackPos) { + $self->semValue = new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], null, $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 362 => static function ($self, $stackPos) { + $self->semValue = new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], null, $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 363 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)]); + }, + 364 => null, + 365 => static function ($self, $stackPos) { + $self->semValue = array(null, $self->semStack[$stackPos-(1-1)]); + }, + 366 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 367 => null, + 368 => null, + 369 => static function ($self, $stackPos) { + $self->semValue = 0; + }, + 370 => static function ($self, $stackPos) { + $self->semValue = 0; + }, + 371 => null, + 372 => null, + 373 => static function ($self, $stackPos) { + $self->checkModifier($self->semStack[$stackPos-(2-1)], $self->semStack[$stackPos-(2-2)], $stackPos-(2-2)); $self->semValue = $self->semStack[$stackPos-(2-1)] | $self->semStack[$stackPos-(2-2)]; + }, + 374 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PUBLIC; + }, + 375 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PROTECTED; + }, + 376 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PRIVATE; + }, + 377 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PUBLIC_SET; + }, + 378 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PROTECTED_SET; + }, + 379 => static function ($self, $stackPos) { + $self->semValue = Modifiers::PRIVATE_SET; + }, + 380 => static function ($self, $stackPos) { + $self->semValue = Modifiers::STATIC; + }, + 381 => static function ($self, $stackPos) { + $self->semValue = Modifiers::ABSTRACT; + }, + 382 => static function ($self, $stackPos) { + $self->semValue = Modifiers::FINAL; + }, + 383 => static function ($self, $stackPos) { + $self->semValue = Modifiers::READONLY; + }, + 384 => null, + 385 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 386 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 387 => static function ($self, $stackPos) { + $self->semValue = new Node\VarLikeIdentifier(substr($self->semStack[$stackPos-(1-1)], 1), $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 388 => static function ($self, $stackPos) { + $self->semValue = new Node\PropertyItem($self->semStack[$stackPos-(1-1)], null, $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 389 => static function ($self, $stackPos) { + $self->semValue = new Node\PropertyItem($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 390 => static function ($self, $stackPos) { + $self->semValue = []; + }, + 391 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; $self->semValue = $self->semStack[$stackPos-(2-1)]; + }, + 392 => static function ($self, $stackPos) { + $self->semValue = []; + }, + 393 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; $self->checkPropertyHookList($self->semStack[$stackPos-(3-2)], $stackPos-(3-1)); + }, + 394 => static function ($self, $stackPos) { + $self->semValue = new Node\PropertyHook($self->semStack[$stackPos-(5-4)], $self->semStack[$stackPos-(5-5)], ['flags' => $self->semStack[$stackPos-(5-2)], 'byRef' => $self->semStack[$stackPos-(5-3)], 'params' => [], 'attrGroups' => $self->semStack[$stackPos-(5-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); + $self->checkPropertyHook($self->semValue, null); + }, + 395 => static function ($self, $stackPos) { + $self->semValue = new Node\PropertyHook($self->semStack[$stackPos-(8-4)], $self->semStack[$stackPos-(8-8)], ['flags' => $self->semStack[$stackPos-(8-2)], 'byRef' => $self->semStack[$stackPos-(8-3)], 'params' => $self->semStack[$stackPos-(8-6)], 'attrGroups' => $self->semStack[$stackPos-(8-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(8-1)], $self->tokenEndStack[$stackPos])); + $self->checkPropertyHook($self->semValue, $stackPos-(8-5)); + }, + 396 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 397 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; + }, + 398 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; + }, + 399 => static function ($self, $stackPos) { + $self->semValue = 0; + }, + 400 => static function ($self, $stackPos) { + $self->checkPropertyHookModifiers($self->semStack[$stackPos-(2-1)], $self->semStack[$stackPos-(2-2)], $stackPos-(2-2)); $self->semValue = $self->semStack[$stackPos-(2-1)] | $self->semStack[$stackPos-(2-2)]; + }, + 401 => null, + 402 => null, + 403 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 404 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 405 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 406 => null, + 407 => null, + 408 => static function ($self, $stackPos) { + $self->semValue = new Expr\Assign($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 409 => static function ($self, $stackPos) { + $self->semValue = new Expr\Assign($self->fixupArrayDestructuring($self->semStack[$stackPos-(3-1)]), $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 410 => static function ($self, $stackPos) { + $self->semValue = new Expr\Assign($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 411 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignRef($self->semStack[$stackPos-(4-1)], $self->semStack[$stackPos-(4-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 412 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignRef($self->semStack[$stackPos-(4-1)], $self->semStack[$stackPos-(4-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + if (!$self->phpVersion->allowsAssignNewByReference()) { + $self->emitError(new Error('Cannot assign new by reference', $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos]))); + } + + }, + 413 => null, + 414 => null, + 415 => static function ($self, $stackPos) { + $self->semValue = new Expr\Clone_($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 416 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\Plus($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 417 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\Minus($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 418 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\Mul($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 419 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\Div($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 420 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\Concat($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 421 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\Mod($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 422 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\BitwiseAnd($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 423 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\BitwiseOr($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 424 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\BitwiseXor($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 425 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\ShiftLeft($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 426 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\ShiftRight($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 427 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\Pow($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 428 => static function ($self, $stackPos) { + $self->semValue = new Expr\AssignOp\Coalesce($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 429 => static function ($self, $stackPos) { + $self->semValue = new Expr\PostInc($self->semStack[$stackPos-(2-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 430 => static function ($self, $stackPos) { + $self->semValue = new Expr\PreInc($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 431 => static function ($self, $stackPos) { + $self->semValue = new Expr\PostDec($self->semStack[$stackPos-(2-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 432 => static function ($self, $stackPos) { + $self->semValue = new Expr\PreDec($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 433 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\BooleanOr($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 434 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\BooleanAnd($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 435 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\LogicalOr($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 436 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\LogicalAnd($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 437 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\LogicalXor($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 438 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\BitwiseOr($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 439 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\BitwiseAnd($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 440 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\BitwiseAnd($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 441 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\BitwiseXor($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 442 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Concat($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 443 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Plus($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 444 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Minus($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 445 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Mul($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 446 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Div($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 447 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Mod($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 448 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\ShiftLeft($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 449 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\ShiftRight($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 450 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Pow($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 451 => static function ($self, $stackPos) { + $self->semValue = new Expr\UnaryPlus($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 452 => static function ($self, $stackPos) { + $self->semValue = new Expr\UnaryMinus($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 453 => static function ($self, $stackPos) { + $self->semValue = new Expr\BooleanNot($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 454 => static function ($self, $stackPos) { + $self->semValue = new Expr\BitwiseNot($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 455 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Identical($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 456 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\NotIdentical($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 457 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Equal($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 458 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\NotEqual($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 459 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Spaceship($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 460 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Smaller($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 461 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\SmallerOrEqual($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 462 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Greater($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 463 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\GreaterOrEqual($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 464 => static function ($self, $stackPos) { + $self->semValue = new Expr\Instanceof_($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 465 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; + }, + 466 => static function ($self, $stackPos) { + $self->semValue = new Expr\Ternary($self->semStack[$stackPos-(5-1)], $self->semStack[$stackPos-(5-3)], $self->semStack[$stackPos-(5-5)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); + }, + 467 => static function ($self, $stackPos) { + $self->semValue = new Expr\Ternary($self->semStack[$stackPos-(4-1)], null, $self->semStack[$stackPos-(4-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 468 => static function ($self, $stackPos) { + $self->semValue = new Expr\BinaryOp\Coalesce($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 469 => static function ($self, $stackPos) { + $self->semValue = new Expr\Isset_($self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 470 => static function ($self, $stackPos) { + $self->semValue = new Expr\Empty_($self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 471 => static function ($self, $stackPos) { + $self->semValue = new Expr\Include_($self->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_INCLUDE, $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 472 => static function ($self, $stackPos) { + $self->semValue = new Expr\Include_($self->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_INCLUDE_ONCE, $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 473 => static function ($self, $stackPos) { + $self->semValue = new Expr\Eval_($self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 474 => static function ($self, $stackPos) { + $self->semValue = new Expr\Include_($self->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_REQUIRE, $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 475 => static function ($self, $stackPos) { + $self->semValue = new Expr\Include_($self->semStack[$stackPos-(2-2)], Expr\Include_::TYPE_REQUIRE_ONCE, $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 476 => static function ($self, $stackPos) { + $self->semValue = new Expr\Cast\Int_($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 477 => static function ($self, $stackPos) { + $attrs = $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos]); + $attrs['kind'] = $self->getFloatCastKind($self->semStack[$stackPos-(2-1)]); + $self->semValue = new Expr\Cast\Double($self->semStack[$stackPos-(2-2)], $attrs); + }, + 478 => static function ($self, $stackPos) { + $self->semValue = new Expr\Cast\String_($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 479 => static function ($self, $stackPos) { + $self->semValue = new Expr\Cast\Array_($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 480 => static function ($self, $stackPos) { + $self->semValue = new Expr\Cast\Object_($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 481 => static function ($self, $stackPos) { + $self->semValue = new Expr\Cast\Bool_($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 482 => static function ($self, $stackPos) { + $self->semValue = new Expr\Cast\Unset_($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 483 => static function ($self, $stackPos) { + $self->semValue = $self->createExitExpr($self->semStack[$stackPos-(2-1)], $stackPos-(2-1), $self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 484 => static function ($self, $stackPos) { + $self->semValue = new Expr\ErrorSuppress($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 485 => null, + 486 => static function ($self, $stackPos) { + $self->semValue = new Expr\ShellExec($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 487 => static function ($self, $stackPos) { + $self->semValue = new Expr\Print_($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 488 => static function ($self, $stackPos) { + $self->semValue = new Expr\Yield_(null, null, $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 489 => static function ($self, $stackPos) { + $self->semValue = new Expr\Yield_($self->semStack[$stackPos-(2-2)], null, $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 490 => static function ($self, $stackPos) { + $self->semValue = new Expr\Yield_($self->semStack[$stackPos-(4-4)], $self->semStack[$stackPos-(4-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 491 => static function ($self, $stackPos) { + $self->semValue = new Expr\YieldFrom($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 492 => static function ($self, $stackPos) { + $self->semValue = new Expr\Throw_($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 493 => static function ($self, $stackPos) { + $self->semValue = new Expr\ArrowFunction(['static' => false, 'byRef' => $self->semStack[$stackPos-(8-2)], 'params' => $self->semStack[$stackPos-(8-4)], 'returnType' => $self->semStack[$stackPos-(8-6)], 'expr' => $self->semStack[$stackPos-(8-8)], 'attrGroups' => []], $self->getAttributes($self->tokenStartStack[$stackPos-(8-1)], $self->tokenEndStack[$stackPos])); + }, + 494 => static function ($self, $stackPos) { + $self->semValue = new Expr\ArrowFunction(['static' => true, 'byRef' => $self->semStack[$stackPos-(9-3)], 'params' => $self->semStack[$stackPos-(9-5)], 'returnType' => $self->semStack[$stackPos-(9-7)], 'expr' => $self->semStack[$stackPos-(9-9)], 'attrGroups' => []], $self->getAttributes($self->tokenStartStack[$stackPos-(9-1)], $self->tokenEndStack[$stackPos])); + }, + 495 => static function ($self, $stackPos) { + $self->semValue = new Expr\Closure(['static' => false, 'byRef' => $self->semStack[$stackPos-(8-2)], 'params' => $self->semStack[$stackPos-(8-4)], 'uses' => $self->semStack[$stackPos-(8-6)], 'returnType' => $self->semStack[$stackPos-(8-7)], 'stmts' => $self->semStack[$stackPos-(8-8)], 'attrGroups' => []], $self->getAttributes($self->tokenStartStack[$stackPos-(8-1)], $self->tokenEndStack[$stackPos])); + }, + 496 => static function ($self, $stackPos) { + $self->semValue = new Expr\Closure(['static' => true, 'byRef' => $self->semStack[$stackPos-(9-3)], 'params' => $self->semStack[$stackPos-(9-5)], 'uses' => $self->semStack[$stackPos-(9-7)], 'returnType' => $self->semStack[$stackPos-(9-8)], 'stmts' => $self->semStack[$stackPos-(9-9)], 'attrGroups' => []], $self->getAttributes($self->tokenStartStack[$stackPos-(9-1)], $self->tokenEndStack[$stackPos])); + }, + 497 => static function ($self, $stackPos) { + $self->semValue = new Expr\ArrowFunction(['static' => false, 'byRef' => $self->semStack[$stackPos-(9-3)], 'params' => $self->semStack[$stackPos-(9-5)], 'returnType' => $self->semStack[$stackPos-(9-7)], 'expr' => $self->semStack[$stackPos-(9-9)], 'attrGroups' => $self->semStack[$stackPos-(9-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(9-1)], $self->tokenEndStack[$stackPos])); + }, + 498 => static function ($self, $stackPos) { + $self->semValue = new Expr\ArrowFunction(['static' => true, 'byRef' => $self->semStack[$stackPos-(10-4)], 'params' => $self->semStack[$stackPos-(10-6)], 'returnType' => $self->semStack[$stackPos-(10-8)], 'expr' => $self->semStack[$stackPos-(10-10)], 'attrGroups' => $self->semStack[$stackPos-(10-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(10-1)], $self->tokenEndStack[$stackPos])); + }, + 499 => static function ($self, $stackPos) { + $self->semValue = new Expr\Closure(['static' => false, 'byRef' => $self->semStack[$stackPos-(9-3)], 'params' => $self->semStack[$stackPos-(9-5)], 'uses' => $self->semStack[$stackPos-(9-7)], 'returnType' => $self->semStack[$stackPos-(9-8)], 'stmts' => $self->semStack[$stackPos-(9-9)], 'attrGroups' => $self->semStack[$stackPos-(9-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(9-1)], $self->tokenEndStack[$stackPos])); + }, + 500 => static function ($self, $stackPos) { + $self->semValue = new Expr\Closure(['static' => true, 'byRef' => $self->semStack[$stackPos-(10-4)], 'params' => $self->semStack[$stackPos-(10-6)], 'uses' => $self->semStack[$stackPos-(10-8)], 'returnType' => $self->semStack[$stackPos-(10-9)], 'stmts' => $self->semStack[$stackPos-(10-10)], 'attrGroups' => $self->semStack[$stackPos-(10-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(10-1)], $self->tokenEndStack[$stackPos])); + }, + 501 => static function ($self, $stackPos) { + $self->semValue = array(new Stmt\Class_(null, ['type' => $self->semStack[$stackPos-(8-2)], 'extends' => $self->semStack[$stackPos-(8-4)], 'implements' => $self->semStack[$stackPos-(8-5)], 'stmts' => $self->semStack[$stackPos-(8-7)], 'attrGroups' => $self->semStack[$stackPos-(8-1)]], $self->getAttributes($self->tokenStartStack[$stackPos-(8-1)], $self->tokenEndStack[$stackPos])), $self->semStack[$stackPos-(8-3)]); + $self->checkClass($self->semValue[0], -1); + }, + 502 => static function ($self, $stackPos) { + $self->semValue = new Expr\New_($self->semStack[$stackPos-(3-2)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 503 => static function ($self, $stackPos) { + list($class, $ctorArgs) = $self->semStack[$stackPos-(2-2)]; $self->semValue = new Expr\New_($class, $ctorArgs, $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 504 => static function ($self, $stackPos) { + $self->semValue = new Expr\New_($self->semStack[$stackPos-(2-2)], [], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 505 => null, + 506 => null, + 507 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 508 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(4-3)]; + }, + 509 => null, + 510 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 511 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 512 => static function ($self, $stackPos) { + $self->semValue = new Node\ClosureUse($self->semStack[$stackPos-(2-2)], $self->semStack[$stackPos-(2-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 513 => static function ($self, $stackPos) { + $self->semValue = new Name($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 514 => static function ($self, $stackPos) { + $self->semValue = new Expr\FuncCall($self->semStack[$stackPos-(2-1)], $self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 515 => static function ($self, $stackPos) { + $self->semValue = new Expr\FuncCall($self->semStack[$stackPos-(2-1)], $self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 516 => static function ($self, $stackPos) { + $self->semValue = new Expr\FuncCall($self->semStack[$stackPos-(2-1)], $self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 517 => static function ($self, $stackPos) { + $self->semValue = new Expr\StaticCall($self->semStack[$stackPos-(4-1)], $self->semStack[$stackPos-(4-3)], $self->semStack[$stackPos-(4-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 518 => static function ($self, $stackPos) { + $self->semValue = new Name($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 519 => null, + 520 => static function ($self, $stackPos) { + $self->semValue = new Name($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 521 => static function ($self, $stackPos) { + $self->semValue = new Name($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 522 => static function ($self, $stackPos) { + $self->semValue = new Name\FullyQualified(substr($self->semStack[$stackPos-(1-1)], 1), $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 523 => static function ($self, $stackPos) { + $self->semValue = new Name\Relative(substr($self->semStack[$stackPos-(1-1)], 10), $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 524 => null, + 525 => null, + 526 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; + }, + 527 => static function ($self, $stackPos) { + $self->semValue = new Expr\Error($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); $self->errorState = 2; + }, + 528 => null, + 529 => null, + 530 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 531 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); foreach ($self->semValue as $s) { if ($s instanceof Node\InterpolatedStringPart) { $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, '`', $self->phpVersion->supportsUnicodeEscapes()); } }; + }, + 532 => static function ($self, $stackPos) { + foreach ($self->semStack[$stackPos-(1-1)] as $s) { if ($s instanceof Node\InterpolatedStringPart) { $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, '`', $self->phpVersion->supportsUnicodeEscapes()); } }; $self->semValue = $self->semStack[$stackPos-(1-1)]; + }, + 533 => static function ($self, $stackPos) { + $self->semValue = array(); + }, + 534 => null, + 535 => static function ($self, $stackPos) { + $self->semValue = new Expr\ConstFetch($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 536 => static function ($self, $stackPos) { + $self->semValue = new Scalar\MagicConst\Line($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 537 => static function ($self, $stackPos) { + $self->semValue = new Scalar\MagicConst\File($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 538 => static function ($self, $stackPos) { + $self->semValue = new Scalar\MagicConst\Dir($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 539 => static function ($self, $stackPos) { + $self->semValue = new Scalar\MagicConst\Class_($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 540 => static function ($self, $stackPos) { + $self->semValue = new Scalar\MagicConst\Trait_($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 541 => static function ($self, $stackPos) { + $self->semValue = new Scalar\MagicConst\Method($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 542 => static function ($self, $stackPos) { + $self->semValue = new Scalar\MagicConst\Function_($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 543 => static function ($self, $stackPos) { + $self->semValue = new Scalar\MagicConst\Namespace_($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 544 => static function ($self, $stackPos) { + $self->semValue = new Scalar\MagicConst\Property($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 545 => static function ($self, $stackPos) { + $self->semValue = new Expr\ClassConstFetch($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 546 => static function ($self, $stackPos) { + $self->semValue = new Expr\ClassConstFetch($self->semStack[$stackPos-(5-1)], $self->semStack[$stackPos-(5-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); + }, + 547 => static function ($self, $stackPos) { + $self->semValue = new Expr\ClassConstFetch($self->semStack[$stackPos-(3-1)], new Expr\Error($self->getAttributes($self->tokenStartStack[$stackPos-(3-3)], $self->tokenEndStack[$stackPos-(3-3)])), $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); $self->errorState = 2; + }, + 548 => static function ($self, $stackPos) { + $attrs = $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos]); $attrs['kind'] = Expr\Array_::KIND_SHORT; + $self->semValue = new Expr\Array_($self->semStack[$stackPos-(3-2)], $attrs); + }, + 549 => static function ($self, $stackPos) { + $attrs = $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos]); $attrs['kind'] = Expr\Array_::KIND_LONG; + $self->semValue = new Expr\Array_($self->semStack[$stackPos-(4-3)], $attrs); + $self->createdArrays->attach($self->semValue); + }, + 550 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(1-1)]; $self->createdArrays->attach($self->semValue); + }, + 551 => static function ($self, $stackPos) { + $self->semValue = Scalar\String_::fromString($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos]), $self->phpVersion->supportsUnicodeEscapes()); + }, + 552 => static function ($self, $stackPos) { + $attrs = $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos]); $attrs['kind'] = Scalar\String_::KIND_DOUBLE_QUOTED; + foreach ($self->semStack[$stackPos-(3-2)] as $s) { if ($s instanceof Node\InterpolatedStringPart) { $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, '"', $self->phpVersion->supportsUnicodeEscapes()); } }; $self->semValue = new Scalar\InterpolatedString($self->semStack[$stackPos-(3-2)], $attrs); + }, + 553 => static function ($self, $stackPos) { + $self->semValue = $self->parseLNumber($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos]), $self->phpVersion->allowsInvalidOctals()); + }, + 554 => static function ($self, $stackPos) { + $self->semValue = Scalar\Float_::fromString($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 555 => null, + 556 => null, + 557 => null, + 558 => static function ($self, $stackPos) { + $self->semValue = $self->parseDocString($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-2)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos]), $self->getAttributes($self->tokenStartStack[$stackPos-(3-3)], $self->tokenEndStack[$stackPos-(3-3)]), true); + }, + 559 => static function ($self, $stackPos) { + $self->semValue = $self->parseDocString($self->semStack[$stackPos-(2-1)], '', $self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos]), $self->getAttributes($self->tokenStartStack[$stackPos-(2-2)], $self->tokenEndStack[$stackPos-(2-2)]), true); + }, + 560 => static function ($self, $stackPos) { + $self->semValue = $self->parseDocString($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-2)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos]), $self->getAttributes($self->tokenStartStack[$stackPos-(3-3)], $self->tokenEndStack[$stackPos-(3-3)]), true); + }, + 561 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 562 => null, + 563 => null, + 564 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; + }, + 565 => null, + 566 => null, + 567 => null, + 568 => null, + 569 => null, + 570 => null, + 571 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; + }, + 572 => null, + 573 => null, + 574 => null, + 575 => static function ($self, $stackPos) { + $self->semValue = new Expr\ArrayDimFetch($self->semStack[$stackPos-(4-1)], $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 576 => null, + 577 => static function ($self, $stackPos) { + $self->semValue = new Expr\MethodCall($self->semStack[$stackPos-(4-1)], $self->semStack[$stackPos-(4-3)], $self->semStack[$stackPos-(4-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 578 => static function ($self, $stackPos) { + $self->semValue = new Expr\NullsafeMethodCall($self->semStack[$stackPos-(4-1)], $self->semStack[$stackPos-(4-3)], $self->semStack[$stackPos-(4-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 579 => static function ($self, $stackPos) { + $self->semValue = null; + }, + 580 => null, + 581 => null, + 582 => null, + 583 => static function ($self, $stackPos) { + $self->semValue = new Expr\PropertyFetch($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 584 => static function ($self, $stackPos) { + $self->semValue = new Expr\NullsafePropertyFetch($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 585 => null, + 586 => static function ($self, $stackPos) { + $self->semValue = new Expr\Variable($self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 587 => static function ($self, $stackPos) { + $self->semValue = new Expr\Variable($self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 588 => static function ($self, $stackPos) { + $self->semValue = new Expr\Variable(new Expr\Error($self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])), $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); $self->errorState = 2; + }, + 589 => static function ($self, $stackPos) { + $var = $self->semStack[$stackPos-(1-1)]->name; $self->semValue = \is_string($var) ? new Node\VarLikeIdentifier($var, $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])) : $var; + }, + 590 => static function ($self, $stackPos) { + $self->semValue = new Expr\StaticPropertyFetch($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 591 => null, + 592 => static function ($self, $stackPos) { + $self->semValue = new Expr\ArrayDimFetch($self->semStack[$stackPos-(4-1)], $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 593 => static function ($self, $stackPos) { + $self->semValue = new Expr\PropertyFetch($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 594 => static function ($self, $stackPos) { + $self->semValue = new Expr\NullsafePropertyFetch($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 595 => static function ($self, $stackPos) { + $self->semValue = new Expr\StaticPropertyFetch($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 596 => static function ($self, $stackPos) { + $self->semValue = new Expr\StaticPropertyFetch($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 597 => null, + 598 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; + }, + 599 => null, + 600 => null, + 601 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; + }, + 602 => null, + 603 => static function ($self, $stackPos) { + $self->semValue = new Expr\Error($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); $self->errorState = 2; + }, + 604 => static function ($self, $stackPos) { + $self->semValue = new Expr\List_($self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); $self->semValue->setAttribute('kind', Expr\List_::KIND_LIST); + $self->postprocessList($self->semValue); + }, + 605 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(1-1)]; $end = count($self->semValue)-1; if ($self->semValue[$end]->value instanceof Expr\Error) array_pop($self->semValue); + }, + 606 => null, + 607 => static function ($self, $stackPos) { + /* do nothing -- prevent default action of $$=$self->semStack[$1]. See $551. */ + }, + 608 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(3-1)][] = $self->semStack[$stackPos-(3-3)]; $self->semValue = $self->semStack[$stackPos-(3-1)]; + }, + 609 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 610 => static function ($self, $stackPos) { + $self->semValue = new Node\ArrayItem($self->semStack[$stackPos-(1-1)], null, false, $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 611 => static function ($self, $stackPos) { + $self->semValue = new Node\ArrayItem($self->semStack[$stackPos-(2-2)], null, true, $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 612 => static function ($self, $stackPos) { + $self->semValue = new Node\ArrayItem($self->semStack[$stackPos-(1-1)], null, false, $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 613 => static function ($self, $stackPos) { + $self->semValue = new Node\ArrayItem($self->semStack[$stackPos-(3-3)], $self->semStack[$stackPos-(3-1)], false, $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 614 => static function ($self, $stackPos) { + $self->semValue = new Node\ArrayItem($self->semStack[$stackPos-(4-4)], $self->semStack[$stackPos-(4-1)], true, $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 615 => static function ($self, $stackPos) { + $self->semValue = new Node\ArrayItem($self->semStack[$stackPos-(3-3)], $self->semStack[$stackPos-(3-1)], false, $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 616 => static function ($self, $stackPos) { + $self->semValue = new Node\ArrayItem($self->semStack[$stackPos-(2-2)], null, false, $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos]), true); + }, + 617 => static function ($self, $stackPos) { + /* Create an Error node now to remember the position. We'll later either report an error, + or convert this into a null element, depending on whether this is a creation or destructuring context. */ + $attrs = $self->createEmptyElemAttributes($self->tokenPos); + $self->semValue = new Node\ArrayItem(new Expr\Error($attrs), null, false, $attrs); + }, + 618 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; $self->semValue = $self->semStack[$stackPos-(2-1)]; + }, + 619 => static function ($self, $stackPos) { + $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; $self->semValue = $self->semStack[$stackPos-(2-1)]; + }, + 620 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(1-1)]); + }, + 621 => static function ($self, $stackPos) { + $self->semValue = array($self->semStack[$stackPos-(2-1)], $self->semStack[$stackPos-(2-2)]); + }, + 622 => static function ($self, $stackPos) { + $attrs = $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos]); $attrs['rawValue'] = $self->semStack[$stackPos-(1-1)]; $self->semValue = new Node\InterpolatedStringPart($self->semStack[$stackPos-(1-1)], $attrs); + }, + 623 => static function ($self, $stackPos) { + $self->semValue = new Expr\Variable($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 624 => null, + 625 => static function ($self, $stackPos) { + $self->semValue = new Expr\ArrayDimFetch($self->semStack[$stackPos-(4-1)], $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + }, + 626 => static function ($self, $stackPos) { + $self->semValue = new Expr\PropertyFetch($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 627 => static function ($self, $stackPos) { + $self->semValue = new Expr\NullsafePropertyFetch($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 628 => static function ($self, $stackPos) { + $self->semValue = new Expr\Variable($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 629 => static function ($self, $stackPos) { + $self->semValue = new Expr\Variable($self->semStack[$stackPos-(3-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(3-1)], $self->tokenEndStack[$stackPos])); + }, + 630 => static function ($self, $stackPos) { + $self->semValue = new Expr\ArrayDimFetch($self->semStack[$stackPos-(6-2)], $self->semStack[$stackPos-(6-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(6-1)], $self->tokenEndStack[$stackPos])); + }, + 631 => static function ($self, $stackPos) { + $self->semValue = $self->semStack[$stackPos-(3-2)]; + }, + 632 => static function ($self, $stackPos) { + $self->semValue = new Scalar\String_($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 633 => static function ($self, $stackPos) { + $self->semValue = $self->parseNumString($self->semStack[$stackPos-(1-1)], $self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); + }, + 634 => static function ($self, $stackPos) { + $self->semValue = $self->parseNumString('-' . $self->semStack[$stackPos-(2-2)], $self->getAttributes($self->tokenStartStack[$stackPos-(2-1)], $self->tokenEndStack[$stackPos])); + }, + 635 => null, + ]; + } +} diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Parser/Tokens.php b/src/ncc/ThirdParty/nikic/PhpParser/Parser/Tokens.php deleted file mode 100644 index 63f797e..0000000 --- a/src/ncc/ThirdParty/nikic/PhpParser/Parser/Tokens.php +++ /dev/null @@ -1,148 +0,0 @@ - Map of PHP token IDs to drop */ + protected array $dropTokens; + /** @var int[] Map of external symbols (static::T_*) to internal symbols */ + protected array $tokenToSymbol; /** @var string[] Map of symbols to their names */ - protected $symbolToName; - /** @var array Names of the production rules (only necessary for debugging) */ - protected $productions; + protected array $symbolToName; + /** @var array Names of the production rules (only necessary for debugging) */ + protected array $productions; /** @var int[] Map of states to a displacement into the $action table. The corresponding action for this * state/symbol pair is $action[$actionBase[$state] + $symbol]. If $actionBase[$state] is 0, the * action is defaulted, i.e. $actionDefault[$state] should be used instead. */ - protected $actionBase; + protected array $actionBase; /** @var int[] Table of actions. Indexed according to $actionBase comment. */ - protected $action; + protected array $action; /** @var int[] Table indexed analogously to $action. If $actionCheck[$actionBase[$state] + $symbol] != $symbol * then the action is defaulted, i.e. $actionDefault[$state] should be used instead. */ - protected $actionCheck; + protected array $actionCheck; /** @var int[] Map of states to their default action */ - protected $actionDefault; + protected array $actionDefault; /** @var callable[] Semantic action callbacks */ - protected $reduceCallbacks; + protected array $reduceCallbacks; /** @var int[] Map of non-terminals to a displacement into the $goto table. The corresponding goto state for this * non-terminal/state pair is $goto[$gotoBase[$nonTerminal] + $state] (unless defaulted) */ - protected $gotoBase; + protected array $gotoBase; /** @var int[] Table of states to goto after reduction. Indexed according to $gotoBase comment. */ - protected $goto; + protected array $goto; /** @var int[] Table indexed analogously to $goto. If $gotoCheck[$gotoBase[$nonTerminal] + $state] != $nonTerminal * then the goto state is defaulted, i.e. $gotoDefault[$nonTerminal] should be used. */ - protected $gotoCheck; + protected array $gotoCheck; /** @var int[] Map of non-terminals to the default state to goto after their reduction */ - protected $gotoDefault; + protected array $gotoDefault; /** @var int[] Map of rules to the non-terminal on their left-hand side, i.e. the non-terminal to use for * determining the state to goto after reduction. */ - protected $ruleToNonTerminal; + protected array $ruleToNonTerminal; /** @var int[] Map of rules to the length of their right-hand side, which is the number of elements that have to * be popped from the stack(s) on reduction. */ - protected $ruleToLength; + protected array $ruleToLength; /* * The following members are part of the parser state: */ - /** @var Lexer Lexer that is used when parsing */ - protected $lexer; /** @var mixed Temporary value containing the result of last semantic action (reduction) */ protected $semValue; - /** @var array Semantic value stack (contains values of tokens and semantic action results) */ - protected $semStack; - /** @var array[] Start attribute stack */ - protected $startAttributeStack; - /** @var array[] End attribute stack */ - protected $endAttributeStack; - /** @var array End attributes of last *shifted* token */ - protected $endAttributes; - /** @var array Start attributes of last *read* token */ - protected $lookaheadStartAttributes; + /** @var mixed[] Semantic value stack (contains values of tokens and semantic action results) */ + protected array $semStack; + /** @var int[] Token start position stack */ + protected array $tokenStartStack; + /** @var int[] Token end position stack */ + protected array $tokenEndStack; /** @var ErrorHandler Error handler */ - protected $errorHandler; + protected ErrorHandler $errorHandler; /** @var int Error state, used to avoid error floods */ - protected $errorState; + protected int $errorState; + + /** @var \SplObjectStorage|null Array nodes created during parsing, for postprocessing of empty elements. */ + protected ?\SplObjectStorage $createdArrays; + + /** @var Token[] Tokens for the current parse */ + protected array $tokens; + /** @var int Current position in token array */ + protected int $tokenPos; /** * Initialize $reduceCallbacks map. */ - abstract protected function initReduceCallbacks(); + abstract protected function initReduceCallbacks(): void; /** * Creates a parser instance. * - * Options: Currently none. + * Options: + * * phpVersion: ?PhpVersion, * * @param Lexer $lexer A lexer - * @param array $options Options array. + * @param PhpVersion $phpVersion PHP version to target, defaults to latest supported. This + * option is best-effort: Even if specified, parsing will generally assume the latest + * supported version and only adjust behavior in minor ways, for example by omitting + * errors in older versions and interpreting type hints as a name or identifier depending + * on version. */ - public function __construct(Lexer $lexer, array $options = []) { + public function __construct(Lexer $lexer, ?PhpVersion $phpVersion = null) { $this->lexer = $lexer; - - if (isset($options['throwOnError'])) { - throw new \LogicException( - '"throwOnError" is no longer supported, use "errorHandler" instead'); - } + $this->phpVersion = $phpVersion ?? PhpVersion::getNewestSupported(); $this->initReduceCallbacks(); + $this->phpTokenToSymbol = $this->createTokenMap(); + $this->dropTokens = array_fill_keys( + [\T_WHITESPACE, \T_OPEN_TAG, \T_COMMENT, \T_DOC_COMMENT, \T_BAD_CHARACTER], true + ); } /** @@ -152,39 +174,58 @@ abstract class ParserAbstract implements Parser * @param ErrorHandler|null $errorHandler Error handler to use for lexer/parser errors, defaults * to ErrorHandler\Throwing. * - * @return Node\Stmt[]|null Array of statements (or null non-throwing error handler is used and + * @return ncc\ThirdParty\nikic\PhpParser\Node\Stmt[]|null Array of statements (or null non-throwing error handler is used and * the parser was unable to recover from an error). */ - public function parse(string $code, ErrorHandler $errorHandler = null) { - $this->errorHandler = $errorHandler ?: new ErrorHandler\Throwing; + public function parse(string $code, ?ErrorHandler $errorHandler = null): ?array { + $this->errorHandler = $errorHandler ?: new ErrorHandler\Throwing(); + $this->createdArrays = new \SplObjectStorage(); - $this->lexer->startLexing($code, $this->errorHandler); + $this->tokens = $this->lexer->tokenize($code, $this->errorHandler); $result = $this->doParse(); + // Report errors for any empty elements used inside arrays. This is delayed until after the main parse, + // because we don't know a priori whether a given array expression will be used in a destructuring context + // or not. + foreach ($this->createdArrays as $node) { + foreach ($node->items as $item) { + if ($item->value instanceof Expr\Error) { + $this->errorHandler->handleError( + new Error('Cannot use empty array elements in arrays', $item->getAttributes())); + } + } + } + // Clear out some of the interior state, so we don't hold onto unnecessary // memory between uses of the parser - $this->startAttributeStack = []; - $this->endAttributeStack = []; + $this->tokenStartStack = []; + $this->tokenEndStack = []; $this->semStack = []; $this->semValue = null; + $this->createdArrays = null; + + if ($result !== null) { + $traverser = new NodeTraverser(new CommentAnnotatingVisitor($this->tokens)); + $traverser->traverse($result); + } return $result; } - protected function doParse() { + public function getTokens(): array { + return $this->tokens; + } + + /** @return Stmt[]|null */ + protected function doParse(): ?array { // We start off with no lookahead-token $symbol = self::SYMBOL_NONE; - - // The attributes for a node are taken from the first and last token of the node. - // From the first token only the startAttributes are taken and from the last only - // the endAttributes. Both are merged using the array union operator (+). - $startAttributes = []; - $endAttributes = []; - $this->endAttributes = $endAttributes; + $tokenValue = null; + $this->tokenPos = -1; // Keep stack of start and end attributes - $this->startAttributeStack = []; - $this->endAttributeStack = [$endAttributes]; + $this->tokenStartStack = []; + $this->tokenEndStack = [0]; // Start off in the initial state and keep a stack of previous states $state = 0; @@ -205,26 +246,20 @@ abstract class ParserAbstract implements Parser $rule = $this->actionDefault[$state]; } else { if ($symbol === self::SYMBOL_NONE) { - // Fetch the next token id from the lexer and fetch additional info by-ref. - // The end attributes are fetched into a temporary variable and only set once the token is really - // shifted (not during read). Otherwise you would sometimes get off-by-one errors, when a rule is - // reduced after a token was read but not yet shifted. - $tokenId = $this->lexer->getNextToken($tokenValue, $startAttributes, $endAttributes); + do { + $token = $this->tokens[++$this->tokenPos]; + $tokenId = $token->id; + } while (isset($this->dropTokens[$tokenId])); - // map the lexer token id to the internally used symbols - $symbol = $tokenId >= 0 && $tokenId < $this->tokenToSymbolMapSize - ? $this->tokenToSymbol[$tokenId] - : $this->invalidSymbol; - - if ($symbol === $this->invalidSymbol) { + // Map the lexer token id to the internally used symbols. + $tokenValue = $token->text; + if (!isset($this->phpTokenToSymbol[$tokenId])) { throw new \RangeException(sprintf( 'The lexer returned an invalid token (id=%d, value=%s)', $tokenId, $tokenValue )); } - - // Allow productions to access the start attributes of the lookahead token. - $this->lookaheadStartAttributes = $startAttributes; + $symbol = $this->phpTokenToSymbol[$tokenId]; //$this->traceRead($symbol); } @@ -249,9 +284,8 @@ abstract class ParserAbstract implements Parser ++$stackPos; $stateStack[$stackPos] = $state = $action; $this->semStack[$stackPos] = $tokenValue; - $this->startAttributeStack[$stackPos] = $startAttributes; - $this->endAttributeStack[$stackPos] = $endAttributes; - $this->endAttributes = $endAttributes; + $this->tokenStartStack[$stackPos] = $this->tokenPos; + $this->tokenEndStack[$stackPos] = $this->tokenPos; $symbol = self::SYMBOL_NONE; if ($this->errorState) { @@ -277,15 +311,22 @@ abstract class ParserAbstract implements Parser /* accept */ //$this->traceAccept(); return $this->semValue; - } elseif ($rule !== $this->unexpectedTokenRule) { + } + if ($rule !== $this->unexpectedTokenRule) { /* reduce */ //$this->traceReduce($rule); + $ruleLength = $this->ruleToLength[$rule]; try { - $this->reduceCallbacks[$rule]($stackPos); + $callback = $this->reduceCallbacks[$rule]; + if ($callback !== null) { + $callback($this, $stackPos); + } elseif ($ruleLength > 0) { + $this->semValue = $this->semStack[$stackPos - $ruleLength + 1]; + } } catch (Error $e) { - if (-1 === $e->getStartLine() && isset($startAttributes['startLine'])) { - $e->setStartLine($startAttributes['startLine']); + if (-1 === $e->getStartLine()) { + $e->setStartLine($this->tokens[$this->tokenPos]->line); } $this->emitError($e); @@ -294,8 +335,7 @@ abstract class ParserAbstract implements Parser } /* Goto - shift nonterminal */ - $lastEndAttributes = $this->endAttributeStack[$stackPos]; - $ruleLength = $this->ruleToLength[$rule]; + $lastTokenEnd = $this->tokenEndStack[$stackPos]; $stackPos -= $ruleLength; $nonTerminal = $this->ruleToNonTerminal[$rule]; $idx = $this->gotoBase[$nonTerminal] + $stateStack[$stackPos]; @@ -308,18 +348,19 @@ abstract class ParserAbstract implements Parser ++$stackPos; $stateStack[$stackPos] = $state; $this->semStack[$stackPos] = $this->semValue; - $this->endAttributeStack[$stackPos] = $lastEndAttributes; + $this->tokenEndStack[$stackPos] = $lastTokenEnd; if ($ruleLength === 0) { // Empty productions use the start attributes of the lookahead token. - $this->startAttributeStack[$stackPos] = $this->lookaheadStartAttributes; + $this->tokenStartStack[$stackPos] = $this->tokenPos; } } else { /* error */ switch ($this->errorState) { case 0: $msg = $this->getErrorMessage($symbol, $state); - $this->emitError(new Error($msg, $startAttributes + $endAttributes)); + $this->emitError(new Error($msg, $this->getAttributesForToken($this->tokenPos))); // Break missing intentionally + // no break case 1: case 2: $this->errorState = 3; @@ -346,9 +387,8 @@ abstract class ParserAbstract implements Parser // We treat the error symbol as being empty, so we reset the end attributes // to the end attributes of the last non-error symbol - $this->startAttributeStack[$stackPos] = $this->lookaheadStartAttributes; - $this->endAttributeStack[$stackPos] = $this->endAttributeStack[$stackPos - 1]; - $this->endAttributes = $this->endAttributeStack[$stackPos - 1]; + $this->tokenStartStack[$stackPos] = $this->tokenPos; + $this->tokenEndStack[$stackPos] = $this->tokenEndStack[$stackPos - 1]; break; case 3: @@ -375,7 +415,7 @@ abstract class ParserAbstract implements Parser throw new \RuntimeException('Reached end of parser loop'); } - protected function emitError(Error $error) { + protected function emitError(Error $error): void { $this->errorHandler->handleError($error); } @@ -383,11 +423,11 @@ abstract class ParserAbstract implements Parser * Format error message including expected tokens. * * @param int $symbol Unexpected symbol - * @param int $state State at time of error + * @param int $state State at time of error * * @return string Formatted error message */ - protected function getErrorMessage(int $symbol, int $state) : string { + protected function getErrorMessage(int $symbol, int $state): string { $expectedString = ''; if ($expected = $this->getExpectedTokens($state)) { $expectedString = ', expecting ' . implode(' or ', $expected); @@ -403,7 +443,7 @@ abstract class ParserAbstract implements Parser * * @return string[] Expected tokens. If too many, an empty array is returned. */ - protected function getExpectedTokens(int $state) : array { + protected function getExpectedTokens(int $state): array { $expected = []; $base = $this->actionBase[$state]; @@ -431,37 +471,79 @@ abstract class ParserAbstract implements Parser return $expected; } + /** + * Get attributes for a node with the given start and end token positions. + * + * @param int $tokenStartPos Token position the node starts at + * @param int $tokenEndPos Token position the node ends at + * @return array Attributes + */ + protected function getAttributes(int $tokenStartPos, int $tokenEndPos): array { + $startToken = $this->tokens[$tokenStartPos]; + $afterEndToken = $this->tokens[$tokenEndPos + 1]; + return [ + 'startLine' => $startToken->line, + 'startTokenPos' => $tokenStartPos, + 'startFilePos' => $startToken->pos, + 'endLine' => $afterEndToken->line, + 'endTokenPos' => $tokenEndPos, + 'endFilePos' => $afterEndToken->pos - 1, + ]; + } + + /** + * Get attributes for a single token at the given token position. + * + * @return array Attributes + */ + protected function getAttributesForToken(int $tokenPos): array { + if ($tokenPos < \count($this->tokens) - 1) { + return $this->getAttributes($tokenPos, $tokenPos); + } + + // Get attributes for the sentinel token. + $token = $this->tokens[$tokenPos]; + return [ + 'startLine' => $token->line, + 'startTokenPos' => $tokenPos, + 'startFilePos' => $token->pos, + 'endLine' => $token->line, + 'endTokenPos' => $tokenPos, + 'endFilePos' => $token->pos, + ]; + } + /* * Tracing functions used for debugging the parser. */ /* - protected function traceNewState($state, $symbol) { + protected function traceNewState($state, $symbol): void { echo '% State ' . $state . ', Lookahead ' . ($symbol == self::SYMBOL_NONE ? '--none--' : $this->symbolToName[$symbol]) . "\n"; } - protected function traceRead($symbol) { + protected function traceRead($symbol): void { echo '% Reading ' . $this->symbolToName[$symbol] . "\n"; } - protected function traceShift($symbol) { + protected function traceShift($symbol): void { echo '% Shift ' . $this->symbolToName[$symbol] . "\n"; } - protected function traceAccept() { + protected function traceAccept(): void { echo "% Accepted.\n"; } - protected function traceReduce($n) { + protected function traceReduce($n): void { echo '% Reduce by (' . $n . ') ' . $this->productions[$n] . "\n"; } - protected function tracePop($state) { + protected function tracePop($state): void { echo '% Recovering, uncovered state ' . $state . "\n"; } - protected function traceDiscard($symbol) { + protected function traceDiscard($symbol): void { echo '% Discard ' . $this->symbolToName[$symbol] . "\n"; } */ @@ -473,23 +555,24 @@ abstract class ParserAbstract implements Parser /** * Moves statements of semicolon-style namespaces into $ns->stmts and checks various error conditions. * - * @param Node\Stmt[] $stmts - * @return Node\Stmt[] + * @param ncc\ThirdParty\nikic\PhpParser\Node\Stmt[] $stmts + * @return ncc\ThirdParty\nikic\PhpParser\Node\Stmt[] */ - protected function handleNamespaces(array $stmts) : array { + protected function handleNamespaces(array $stmts): array { $hasErrored = false; $style = $this->getNamespacingStyle($stmts); if (null === $style) { // not namespaced, nothing to do return $stmts; - } elseif ('brace' === $style) { + } + if ('brace' === $style) { // For braced namespaces we only have to check that there are no invalid statements between the namespaces $afterFirstNamespace = false; foreach ($stmts as $stmt) { - if ($stmt instanceof Node\Stmt\Namespace_) { + if ($stmt instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt\Namespace_) { $afterFirstNamespace = true; - } elseif (!$stmt instanceof Node\Stmt\HaltCompiler - && !$stmt instanceof Node\Stmt\Nop + } elseif (!$stmt instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt\HaltCompiler + && !$stmt instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt\Nop && $afterFirstNamespace && !$hasErrored) { $this->emitError(new Error( 'No code may exist outside of namespace {}', $stmt->getAttributes())); @@ -500,24 +583,24 @@ abstract class ParserAbstract implements Parser } else { // For semicolon namespaces we have to move the statements after a namespace declaration into ->stmts $resultStmts = []; - $targetStmts =& $resultStmts; + $targetStmts = &$resultStmts; $lastNs = null; foreach ($stmts as $stmt) { - if ($stmt instanceof Node\Stmt\Namespace_) { + if ($stmt instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt\Namespace_) { if ($lastNs !== null) { $this->fixupNamespaceAttributes($lastNs); } if ($stmt->stmts === null) { $stmt->stmts = []; - $targetStmts =& $stmt->stmts; + $targetStmts = &$stmt->stmts; $resultStmts[] = $stmt; } else { // This handles the invalid case of mixed style namespaces $resultStmts[] = $stmt; - $targetStmts =& $resultStmts; + $targetStmts = &$resultStmts; } $lastNs = $stmt; - } elseif ($stmt instanceof Node\Stmt\HaltCompiler) { + } elseif ($stmt instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt\HaltCompiler) { // __halt_compiler() is not moved into the namespace $resultStmts[] = $stmt; } else { @@ -531,7 +614,7 @@ abstract class ParserAbstract implements Parser } } - private function fixupNamespaceAttributes(Node\Stmt\Namespace_ $stmt) { + private function fixupNamespaceAttributes(ncc\ThirdParty\nikic\PhpParser\Node\Stmt\Namespace_ $stmt): void { // We moved the statements into the namespace node, as such the end of the namespace node // needs to be extended to the end of the statements. if (empty($stmt->stmts)) { @@ -549,6 +632,22 @@ abstract class ParserAbstract implements Parser } } + /** @return array */ + private function getNamespaceErrorAttributes(Namespace_ $node): array { + $attrs = $node->getAttributes(); + // Adjust end attributes to only cover the "namespace" keyword, not the whole namespace. + if (isset($attrs['startLine'])) { + $attrs['endLine'] = $attrs['startLine']; + } + if (isset($attrs['startTokenPos'])) { + $attrs['endTokenPos'] = $attrs['startTokenPos']; + } + if (isset($attrs['startFilePos'])) { + $attrs['endFilePos'] = $attrs['startFilePos'] + \strlen('namespace') - 1; + } + return $attrs; + } + /** * Determine namespacing style (semicolon or brace) * @@ -556,24 +655,24 @@ abstract class ParserAbstract implements Parser * * @return null|string One of "semicolon", "brace" or null (no namespaces) */ - private function getNamespacingStyle(array $stmts) { + private function getNamespacingStyle(array $stmts): ?string { $style = null; $hasNotAllowedStmts = false; foreach ($stmts as $i => $stmt) { - if ($stmt instanceof Node\Stmt\Namespace_) { + if ($stmt instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt\Namespace_) { $currentStyle = null === $stmt->stmts ? 'semicolon' : 'brace'; if (null === $style) { $style = $currentStyle; if ($hasNotAllowedStmts) { $this->emitError(new Error( 'Namespace declaration statement has to be the very first statement in the script', - $stmt->getLine() // Avoid marking the entire namespace as an error + $this->getNamespaceErrorAttributes($stmt) )); } } elseif ($style !== $currentStyle) { $this->emitError(new Error( 'Cannot mix bracketed namespace declarations with unbracketed namespace declarations', - $stmt->getLine() // Avoid marking the entire namespace as an error + $this->getNamespaceErrorAttributes($stmt) )); // Treat like semicolon style for namespace normalization return 'semicolon'; @@ -582,14 +681,14 @@ abstract class ParserAbstract implements Parser } /* declare(), __halt_compiler() and nops can be used before a namespace declaration */ - if ($stmt instanceof Node\Stmt\Declare_ - || $stmt instanceof Node\Stmt\HaltCompiler - || $stmt instanceof Node\Stmt\Nop) { + if ($stmt instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt\Declare_ + || $stmt instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt\HaltCompiler + || $stmt instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt\Nop) { continue; } /* There may be a hashbang line at the very start of the file */ - if ($i === 0 && $stmt instanceof Node\Stmt\InlineHTML && preg_match('/\A#!.*\r?\n\z/', $stmt->value)) { + if ($i === 0 && $stmt instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt\InlineHTML && preg_match('/\A#!.*\r?\n\z/', $stmt->value)) { continue; } @@ -599,102 +698,32 @@ abstract class ParserAbstract implements Parser return $style; } - /** - * Fix up parsing of static property calls in PHP 5. - * - * In PHP 5 A::$b[c][d] and A::$b[c][d]() have very different interpretation. The former is - * interpreted as (A::$b)[c][d], while the latter is the same as A::{$b[c][d]}(). We parse the - * latter as the former initially and this method fixes the AST into the correct form when we - * encounter the "()". - * - * @param Node\Expr\StaticPropertyFetch|Node\Expr\ArrayDimFetch $prop - * @param Node\Arg[] $args - * @param array $attributes - * - * @return Expr\StaticCall - */ - protected function fixupPhp5StaticPropCall($prop, array $args, array $attributes) : Expr\StaticCall { - if ($prop instanceof Node\Expr\StaticPropertyFetch) { - $name = $prop->name instanceof VarLikeIdentifier - ? $prop->name->toString() : $prop->name; - $var = new Expr\Variable($name, $prop->name->getAttributes()); - return new Expr\StaticCall($prop->class, $var, $args, $attributes); - } elseif ($prop instanceof Node\Expr\ArrayDimFetch) { - $tmp = $prop; - while ($tmp->var instanceof Node\Expr\ArrayDimFetch) { - $tmp = $tmp->var; - } - - /** @var Expr\StaticPropertyFetch $staticProp */ - $staticProp = $tmp->var; - - // Set start attributes to attributes of innermost node - $tmp = $prop; - $this->fixupStartAttributes($tmp, $staticProp->name); - while ($tmp->var instanceof Node\Expr\ArrayDimFetch) { - $tmp = $tmp->var; - $this->fixupStartAttributes($tmp, $staticProp->name); - } - - $name = $staticProp->name instanceof VarLikeIdentifier - ? $staticProp->name->toString() : $staticProp->name; - $tmp->var = new Expr\Variable($name, $staticProp->name->getAttributes()); - return new Expr\StaticCall($staticProp->class, $prop, $args, $attributes); - } else { - throw new \Exception; - } - } - - protected function fixupStartAttributes(Node $to, Node $from) { - $startAttributes = ['startLine', 'startFilePos', 'startTokenPos']; - foreach ($startAttributes as $startAttribute) { - if ($from->hasAttribute($startAttribute)) { - $to->setAttribute($startAttribute, $from->getAttribute($startAttribute)); - } - } - } - + /** @return Name|Identifier */ protected function handleBuiltinTypes(Name $name) { - $builtinTypes = [ - 'bool' => true, - 'int' => true, - 'float' => true, - 'string' => true, - 'iterable' => true, - 'void' => true, - 'object' => true, - 'null' => true, - 'false' => true, - 'mixed' => true, - 'never' => true, - 'true' => true, - ]; - if (!$name->isUnqualified()) { return $name; } $lowerName = $name->toLowerString(); - if (!isset($builtinTypes[$lowerName])) { + if (!$this->phpVersion->supportsBuiltinType($lowerName)) { return $name; } - return new Node\Identifier($lowerName, $name->getAttributes()); + return new ncc\ThirdParty\nikic\PhpParser\Node\Identifier($lowerName, $name->getAttributes()); } /** * Get combined start and end attributes at a stack location * - * @param int $pos Stack location + * @param int $stackPos Stack location * - * @return array Combined start and end attributes + * @return array Combined start and end attributes */ - protected function getAttributesAt(int $pos) : array { - return $this->startAttributeStack[$pos] + $this->endAttributeStack[$pos]; + protected function getAttributesAt(int $stackPos): array { + return $this->getAttributes($this->tokenStartStack[$stackPos], $this->tokenEndStack[$stackPos]); } - protected function getFloatCastKind(string $cast): int - { + protected function getFloatCastKind(string $cast): int { $cast = strtolower($cast); if (strpos($cast, 'float') !== false) { return Double::KIND_FLOAT; @@ -707,23 +736,24 @@ abstract class ParserAbstract implements Parser return Double::KIND_DOUBLE; } - protected function parseLNumber($str, $attributes, $allowInvalidOctal = false) { + /** @param array $attributes */ + protected function parseLNumber(string $str, array $attributes, bool $allowInvalidOctal = false): Int_ { try { - return LNumber::fromString($str, $attributes, $allowInvalidOctal); + return Int_::fromString($str, $attributes, $allowInvalidOctal); } catch (Error $error) { $this->emitError($error); // Use dummy value - return new LNumber(0, $attributes); + return new Int_(0, $attributes); } } /** * Parse a T_NUM_STRING token into either an integer or string node. * - * @param string $str Number string - * @param array $attributes Attributes + * @param string $str Number string + * @param array $attributes Attributes * - * @return LNumber|String_ Integer or string node. + * @return Int_|String_ Integer or string node. */ protected function parseNumString(string $str, array $attributes) { if (!preg_match('/^(?:0|-?[1-9][0-9]*)$/', $str)) { @@ -735,13 +765,14 @@ abstract class ParserAbstract implements Parser return new String_($str, $attributes); } - return new LNumber($num, $attributes); + return new Int_($num, $attributes); } + /** @param array $attributes */ protected function stripIndentation( string $string, int $indentLen, string $indentChar, bool $newlineAtStart, bool $newlineAtEnd, array $attributes - ) { + ): string { if ($indentLen === 0) { return $string; } @@ -770,10 +801,15 @@ abstract class ParserAbstract implements Parser ); } + /** + * @param string|(Expr|InterpolatedStringPart)[] $contents + * @param array $attributes + * @param array $endTokenAttributes + */ protected function parseDocString( string $startToken, $contents, string $endToken, array $attributes, array $endTokenAttributes, bool $parseUnicodeEscape - ) { + ): Expr { $kind = strpos($startToken, "'") === false ? String_::KIND_HEREDOC : String_::KIND_NOWDOC; @@ -807,6 +843,7 @@ abstract class ParserAbstract implements Parser if (\is_string($contents)) { if ($contents === '') { + $attributes['rawValue'] = $contents; return new String_('', $attributes); } @@ -814,6 +851,7 @@ abstract class ParserAbstract implements Parser $contents, $indentLen, $indentChar, true, true, $attributes ); $contents = preg_replace('~(\r\n|\n|\r)\z~', '', $contents); + $attributes['rawValue'] = $contents; if ($kind === String_::KIND_HEREDOC) { $contents = String_::parseEscapeSequences($contents, null, $parseUnicodeEscape); @@ -822,7 +860,7 @@ abstract class ParserAbstract implements Parser return new String_($contents, $attributes); } else { assert(count($contents) > 0); - if (!$contents[0] instanceof Node\Scalar\EncapsedStringPart) { + if (!$contents[0] instanceof ncc\ThirdParty\nikic\PhpParser\Node\InterpolatedStringPart) { // If there is no leading encapsed string part, pretend there is an empty one $this->stripIndentation( '', $indentLen, $indentChar, true, false, $contents[0]->getAttributes() @@ -831,56 +869,139 @@ abstract class ParserAbstract implements Parser $newContents = []; foreach ($contents as $i => $part) { - if ($part instanceof Node\Scalar\EncapsedStringPart) { + if ($part instanceof ncc\ThirdParty\nikic\PhpParser\Node\InterpolatedStringPart) { $isLast = $i === \count($contents) - 1; $part->value = $this->stripIndentation( $part->value, $indentLen, $indentChar, $i === 0, $isLast, $part->getAttributes() ); - $part->value = String_::parseEscapeSequences($part->value, null, $parseUnicodeEscape); if ($isLast) { $part->value = preg_replace('~(\r\n|\n|\r)\z~', '', $part->value); } + $part->setAttribute('rawValue', $part->value); + $part->value = String_::parseEscapeSequences($part->value, null, $parseUnicodeEscape); if ('' === $part->value) { continue; } } $newContents[] = $part; } - return new Encapsed($newContents, $attributes); + return new InterpolatedString($newContents, $attributes); } } + protected function createCommentFromToken(Token $token, int $tokenPos): Comment { + assert($token->id === \T_COMMENT || $token->id == \T_DOC_COMMENT); + return \T_DOC_COMMENT === $token->id + ? new Comment\Doc($token->text, $token->line, $token->pos, $tokenPos, + $token->getEndLine(), $token->getEndPos() - 1, $tokenPos) + : new Comment($token->text, $token->line, $token->pos, $tokenPos, + $token->getEndLine(), $token->getEndPos() - 1, $tokenPos); + } + /** - * Create attributes for a zero-length common-capturing nop. - * - * @param Comment[] $comments - * @return array + * Get last comment before the given token position, if any */ - protected function createCommentNopAttributes(array $comments) { - $comment = $comments[count($comments) - 1]; + protected function getCommentBeforeToken(int $tokenPos): ?Comment { + while (--$tokenPos >= 0) { + $token = $this->tokens[$tokenPos]; + if (!isset($this->dropTokens[$token->id])) { + break; + } + + if ($token->id === \T_COMMENT || $token->id === \T_DOC_COMMENT) { + return $this->createCommentFromToken($token, $tokenPos); + } + } + return null; + } + + /** + * Create a zero-length nop to capture preceding comments, if any. + */ + protected function maybeCreateZeroLengthNop(int $tokenPos): ?Nop { + $comment = $this->getCommentBeforeToken($tokenPos); + if ($comment === null) { + return null; + } + $commentEndLine = $comment->getEndLine(); $commentEndFilePos = $comment->getEndFilePos(); $commentEndTokenPos = $comment->getEndTokenPos(); + $attributes = [ + 'startLine' => $commentEndLine, + 'endLine' => $commentEndLine, + 'startFilePos' => $commentEndFilePos + 1, + 'endFilePos' => $commentEndFilePos, + 'startTokenPos' => $commentEndTokenPos + 1, + 'endTokenPos' => $commentEndTokenPos, + ]; + return new Nop($attributes); + } - $attributes = ['comments' => $comments]; - if (-1 !== $commentEndLine) { - $attributes['startLine'] = $commentEndLine; - $attributes['endLine'] = $commentEndLine; + protected function maybeCreateNop(int $tokenStartPos, int $tokenEndPos): ?Nop { + if ($this->getCommentBeforeToken($tokenStartPos) === null) { + return null; } - if (-1 !== $commentEndFilePos) { - $attributes['startFilePos'] = $commentEndFilePos + 1; - $attributes['endFilePos'] = $commentEndFilePos; + return new Nop($this->getAttributes($tokenStartPos, $tokenEndPos)); + } + + protected function handleHaltCompiler(): string { + // Prevent the lexer from returning any further tokens. + $nextToken = $this->tokens[$this->tokenPos + 1]; + $this->tokenPos = \count($this->tokens) - 2; + + // Return text after __halt_compiler. + return $nextToken->id === \T_INLINE_HTML ? $nextToken->text : ''; + } + + protected function inlineHtmlHasLeadingNewline(int $stackPos): bool { + $tokenPos = $this->tokenStartStack[$stackPos]; + $token = $this->tokens[$tokenPos]; + assert($token->id == \T_INLINE_HTML); + if ($tokenPos > 0) { + $prevToken = $this->tokens[$tokenPos - 1]; + assert($prevToken->id == \T_CLOSE_TAG); + return false !== strpos($prevToken->text, "\n") + || false !== strpos($prevToken->text, "\r"); } - if (-1 !== $commentEndTokenPos) { - $attributes['startTokenPos'] = $commentEndTokenPos + 1; - $attributes['endTokenPos'] = $commentEndTokenPos; + return true; + } + + /** + * @return array + */ + protected function createEmptyElemAttributes(int $tokenPos): array { + return $this->getAttributesForToken($tokenPos); + } + + protected function fixupArrayDestructuring(Array_ $node): Expr\List_ { + $this->createdArrays->detach($node); + return new Expr\List_(array_map(function (ncc\ThirdParty\nikic\PhpParser\Node\ArrayItem $item) { + if ($item->value instanceof Expr\Error) { + // We used Error as a placeholder for empty elements, which are legal for destructuring. + return null; + } + if ($item->value instanceof Array_) { + return new ncc\ThirdParty\nikic\PhpParser\Node\ArrayItem( + $this->fixupArrayDestructuring($item->value), + $item->key, $item->byRef, $item->getAttributes()); + } + return $item; + }, $node->items), ['kind' => Expr\List_::KIND_ARRAY] + $node->getAttributes()); + } + + protected function postprocessList(Expr\List_ $node): void { + foreach ($node->items as $i => $item) { + if ($item->value instanceof Expr\Error) { + // We used Error as a placeholder for empty elements, which are legal for destructuring. + $node->items[$i] = null; + } } - return $attributes; } /** @param ElseIf_|Else_ $node */ - protected function fixupAlternativeElse($node) { + protected function fixupAlternativeElse($node): void { // Make sure a trailing nop statement carrying comments is part of the node. $numStmts = \count($node->stmts); if ($numStmts !== 0 && $node->stmts[$numStmts - 1] instanceof Nop) { @@ -897,26 +1018,26 @@ abstract class ParserAbstract implements Parser } } - protected function checkClassModifier($a, $b, $modifierPos) { + protected function checkClassModifier(int $a, int $b, int $modifierPos): void { try { - Class_::verifyClassModifier($a, $b); + Modifiers::verifyClassModifier($a, $b); } catch (Error $error) { $error->setAttributes($this->getAttributesAt($modifierPos)); $this->emitError($error); } } - protected function checkModifier($a, $b, $modifierPos) { + protected function checkModifier(int $a, int $b, int $modifierPos): void { // Jumping through some hoops here because verifyModifier() is also used elsewhere try { - Class_::verifyModifier($a, $b); + Modifiers::verifyModifier($a, $b); } catch (Error $error) { $error->setAttributes($this->getAttributesAt($modifierPos)); $this->emitError($error); } } - protected function checkParam(Param $node) { + protected function checkParam(Param $node): void { if ($node->variadic && null !== $node->default) { $this->emitError(new Error( 'Variadic parameter cannot have a default value', @@ -925,7 +1046,7 @@ abstract class ParserAbstract implements Parser } } - protected function checkTryCatch(TryCatch $node) { + protected function checkTryCatch(TryCatch $node): void { if (empty($node->catches) && null === $node->finally) { $this->emitError(new Error( 'Cannot use try without catch or finally', $node->getAttributes() @@ -933,7 +1054,7 @@ abstract class ParserAbstract implements Parser } } - protected function checkNamespace(Namespace_ $node) { + protected function checkNamespace(Namespace_ $node): void { if (null !== $node->stmts) { foreach ($node->stmts as $stmt) { if ($stmt instanceof Namespace_) { @@ -945,7 +1066,7 @@ abstract class ParserAbstract implements Parser } } - private function checkClassName($name, $namePos) { + private function checkClassName(?Identifier $name, int $namePos): void { if (null !== $name && $name->isSpecialClassName()) { $this->emitError(new Error( sprintf('Cannot use \'%s\' as class name as it is reserved', $name), @@ -954,7 +1075,8 @@ abstract class ParserAbstract implements Parser } } - private function checkImplementedInterfaces(array $interfaces) { + /** @param Name[] $interfaces */ + private function checkImplementedInterfaces(array $interfaces): void { foreach ($interfaces as $interface) { if ($interface->isSpecialClassName()) { $this->emitError(new Error( @@ -965,7 +1087,7 @@ abstract class ParserAbstract implements Parser } } - protected function checkClass(Class_ $node, $namePos) { + protected function checkClass(Class_ $node, int $namePos): void { $this->checkClassName($node->name, $namePos); if ($node->extends && $node->extends->isSpecialClassName()) { @@ -978,18 +1100,18 @@ abstract class ParserAbstract implements Parser $this->checkImplementedInterfaces($node->implements); } - protected function checkInterface(Interface_ $node, $namePos) { + protected function checkInterface(Interface_ $node, int $namePos): void { $this->checkClassName($node->name, $namePos); $this->checkImplementedInterfaces($node->extends); } - protected function checkEnum(Enum_ $node, $namePos) { + protected function checkEnum(Enum_ $node, int $namePos): void { $this->checkClassName($node->name, $namePos); $this->checkImplementedInterfaces($node->implements); } - protected function checkClassMethod(ClassMethod $node, $modifierPos) { - if ($node->flags & Class_::MODIFIER_STATIC) { + protected function checkClassMethod(ClassMethod $node, int $modifierPos): void { + if ($node->flags & Modifiers::STATIC) { switch ($node->name->toLowerString()) { case '__construct': $this->emitError(new Error( @@ -1009,44 +1131,24 @@ abstract class ParserAbstract implements Parser } } - if ($node->flags & Class_::MODIFIER_READONLY) { + if ($node->flags & Modifiers::READONLY) { $this->emitError(new Error( sprintf('Method %s() cannot be readonly', $node->name), $this->getAttributesAt($modifierPos))); } } - protected function checkClassConst(ClassConst $node, $modifierPos) { - if ($node->flags & Class_::MODIFIER_STATIC) { - $this->emitError(new Error( - "Cannot use 'static' as constant modifier", - $this->getAttributesAt($modifierPos))); - } - if ($node->flags & Class_::MODIFIER_ABSTRACT) { - $this->emitError(new Error( - "Cannot use 'abstract' as constant modifier", - $this->getAttributesAt($modifierPos))); - } - if ($node->flags & Class_::MODIFIER_READONLY) { - $this->emitError(new Error( - "Cannot use 'readonly' as constant modifier", - $this->getAttributesAt($modifierPos))); + protected function checkClassConst(ClassConst $node, int $modifierPos): void { + foreach ([Modifiers::STATIC, Modifiers::ABSTRACT, Modifiers::READONLY] as $modifier) { + if ($node->flags & $modifier) { + $this->emitError(new Error( + "Cannot use '" . Modifiers::toString($modifier) . "' as constant modifier", + $this->getAttributesAt($modifierPos))); + } } } - protected function checkProperty(Property $node, $modifierPos) { - if ($node->flags & Class_::MODIFIER_ABSTRACT) { - $this->emitError(new Error('Properties cannot be declared abstract', - $this->getAttributesAt($modifierPos))); - } - - if ($node->flags & Class_::MODIFIER_FINAL) { - $this->emitError(new Error('Properties cannot be declared final', - $this->getAttributesAt($modifierPos))); - } - } - - protected function checkUseUse(UseUse $node, $namePos) { + protected function checkUseUse(UseItem $node, int $namePos): void { if ($node->alias && $node->alias->isSpecialClassName()) { $this->emitError(new Error( sprintf( @@ -1057,4 +1159,108 @@ abstract class ParserAbstract implements Parser )); } } + + /** @param PropertyHook[] $hooks */ + protected function checkPropertyHookList(array $hooks, int $hookPos): void { + if (empty($hooks)) { + $this->emitError(new Error( + 'Property hook list cannot be empty', $this->getAttributesAt($hookPos))); + } + } + + protected function checkPropertyHook(PropertyHook $hook, ?int $paramListPos): void { + $name = $hook->name->toLowerString(); + if ($name !== 'get' && $name !== 'set') { + $this->emitError(new Error( + 'Unknown hook "' . $hook->name . '", expected "get" or "set"', + $hook->name->getAttributes())); + } + if ($name === 'get' && $paramListPos !== null) { + $this->emitError(new Error( + 'get hook must not have a parameter list', $this->getAttributesAt($paramListPos))); + } + } + + protected function checkPropertyHookModifiers(int $a, int $b, int $modifierPos): void { + try { + Modifiers::verifyModifier($a, $b); + } catch (Error $error) { + $error->setAttributes($this->getAttributesAt($modifierPos)); + $this->emitError($error); + } + + if ($b != Modifiers::FINAL) { + $this->emitError(new Error( + 'Cannot use the ' . Modifiers::toString($b) . ' modifier on a property hook', + $this->getAttributesAt($modifierPos))); + } + } + + /** @param array $args */ + private function isSimpleExit(array $args): bool { + if (\count($args) === 0) { + return true; + } + if (\count($args) === 1) { + $arg = $args[0]; + return $arg instanceof Arg && $arg->name === null && + $arg->byRef === false && $arg->unpack === false; + } + return false; + } + + /** + * @param array $args + * @param array $attrs + */ + protected function createExitExpr(string $name, int $namePos, array $args, array $attrs): Expr { + if ($this->isSimpleExit($args)) { + // Create Exit node for backwards compatibility. + $attrs['kind'] = strtolower($name) === 'exit' ? Expr\Exit_::KIND_EXIT : Expr\Exit_::KIND_DIE; + return new Expr\Exit_(\count($args) === 1 ? $args[0]->value : null, $attrs); + } + return new Expr\FuncCall(new Name($name, $this->getAttributesAt($namePos)), $args, $attrs); + } + + /** + * Creates the token map. + * + * The token map maps the PHP internal token identifiers + * to the identifiers used by the Parser. Additionally it + * maps T_OPEN_TAG_WITH_ECHO to T_ECHO and T_CLOSE_TAG to ';'. + * + * @return array The token map + */ + protected function createTokenMap(): array { + $tokenMap = []; + + // Single-char tokens use an identity mapping. + for ($i = 0; $i < 256; ++$i) { + $tokenMap[$i] = $i; + } + + foreach ($this->symbolToName as $name) { + if ($name[0] === 'T') { + $tokenMap[\constant($name)] = constant(static::class . '::' . $name); + } + } + + // T_OPEN_TAG_WITH_ECHO with dropped T_OPEN_TAG results in T_ECHO + $tokenMap[\T_OPEN_TAG_WITH_ECHO] = static::T_ECHO; + // T_CLOSE_TAG is equivalent to ';' + $tokenMap[\T_CLOSE_TAG] = ord(';'); + + // We have created a map from PHP token IDs to external symbol IDs. + // Now map them to the internal symbol ID. + $fullTokenMap = []; + foreach ($tokenMap as $phpToken => $extSymbol) { + $intSymbol = $this->tokenToSymbol[$extSymbol]; + if ($intSymbol === $this->invalidSymbol) { + continue; + } + $fullTokenMap[$phpToken] = $intSymbol; + } + + return $fullTokenMap; + } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/ParserFactory.php b/src/ncc/ThirdParty/nikic/PhpParser/ParserFactory.php index c71f19c..25943d5 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/ParserFactory.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/ParserFactory.php @@ -2,43 +2,41 @@ namespace ncc\ThirdParty\nikic\PhpParser; -class ParserFactory -{ - const PREFER_PHP7 = 1; - const PREFER_PHP5 = 2; - const ONLY_PHP7 = 3; - const ONLY_PHP5 = 4; +use ncc\ThirdParty\nikic\PhpParser\Parser\Php7; +use ncc\ThirdParty\nikic\PhpParser\Parser\Php8; + +class ParserFactory { + /** + * Create a parser targeting the given version on a best-effort basis. The parser will generally + * accept code for the newest supported version, but will try to accommodate code that becomes + * invalid in newer versions or changes in interpretation. + */ + public function createForVersion(PhpVersion $version): Parser { + if ($version->isHostVersion()) { + $lexer = new Lexer(); + } else { + $lexer = new Lexer\Emulative($version); + } + if ($version->id >= 80000) { + return new Php8($lexer, $version); + } + return new Php7($lexer, $version); + } /** - * Creates a Parser instance, according to the provided kind. - * - * @param int $kind One of ::PREFER_PHP7, ::PREFER_PHP5, ::ONLY_PHP7 or ::ONLY_PHP5 - * @param Lexer|null $lexer Lexer to use. Defaults to emulative lexer when not specified - * @param array $parserOptions Parser options. See ParserAbstract::__construct() argument - * - * @return Parser The parser instance + * Create a parser targeting the newest version supported by this library. Code for older + * versions will be accepted if there have been no relevant backwards-compatibility breaks in + * PHP. */ - public function create(int $kind, Lexer $lexer = null, array $parserOptions = []) : Parser { - if (null === $lexer) { - $lexer = new Lexer\Emulative(); - } - switch ($kind) { - case self::PREFER_PHP7: - return new Parser\Multiple([ - new Parser\Php7($lexer, $parserOptions), new Parser\Php5($lexer, $parserOptions) - ]); - case self::PREFER_PHP5: - return new Parser\Multiple([ - new Parser\Php5($lexer, $parserOptions), new Parser\Php7($lexer, $parserOptions) - ]); - case self::ONLY_PHP7: - return new Parser\Php7($lexer, $parserOptions); - case self::ONLY_PHP5: - return new Parser\Php5($lexer, $parserOptions); - default: - throw new \LogicException( - 'Kind must be one of ::PREFER_PHP7, ::PREFER_PHP5, ::ONLY_PHP7 or ::ONLY_PHP5' - ); - } + public function createForNewestSupportedVersion(): Parser { + return $this->createForVersion(PhpVersion::getNewestSupported()); + } + + /** + * Create a parser targeting the host PHP version, that is the PHP version we're currently + * running on. This parser will not use any token emulation. + */ + public function createForHostVersion(): Parser { + return $this->createForVersion(PhpVersion::getHostVersion()); } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/PhpVersion.php b/src/ncc/ThirdParty/nikic/PhpParser/PhpVersion.php new file mode 100644 index 0000000..ab57f6a --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/PhpVersion.php @@ -0,0 +1,164 @@ + 50100, + 'callable' => 50400, + 'bool' => 70000, + 'int' => 70000, + 'float' => 70000, + 'string' => 70000, + 'iterable' => 70100, + 'void' => 70100, + 'object' => 70200, + 'null' => 80000, + 'false' => 80000, + 'mixed' => 80000, + 'never' => 80100, + 'true' => 80200, + ]; + + private function __construct(int $id) { + $this->id = $id; + } + + /** + * Create a PhpVersion object from major and minor version components. + */ + public static function fromComponents(int $major, int $minor): self { + return new self($major * 10000 + $minor * 100); + } + + /** + * Get the newest PHP version supported by this library. Support for this version may be partial, + * if it is still under development. + */ + public static function getNewestSupported(): self { + return self::fromComponents(8, 4); + } + + /** + * Get the host PHP version, that is the PHP version we're currently running on. + */ + public static function getHostVersion(): self { + return self::fromComponents(\PHP_MAJOR_VERSION, \PHP_MINOR_VERSION); + } + + /** + * Parse the version from a string like "8.1". + */ + public static function fromString(string $version): self { + if (!preg_match('/^(\d+)\.(\d+)/', $version, $matches)) { + throw new \LogicException("Invalid PHP version \"$version\""); + } + return self::fromComponents((int) $matches[1], (int) $matches[2]); + } + + /** + * Check whether two versions are the same. + */ + public function equals(PhpVersion $other): bool { + return $this->id === $other->id; + } + + /** + * Check whether this version is greater than or equal to the argument. + */ + public function newerOrEqual(PhpVersion $other): bool { + return $this->id >= $other->id; + } + + /** + * Check whether this version is older than the argument. + */ + public function older(PhpVersion $other): bool { + return $this->id < $other->id; + } + + /** + * Check whether this is the host PHP version. + */ + public function isHostVersion(): bool { + return $this->equals(self::getHostVersion()); + } + + /** + * Check whether this PHP version supports the given builtin type. Type name must be lowercase. + */ + public function supportsBuiltinType(string $type): bool { + $minVersion = self::BUILTIN_TYPE_VERSIONS[$type] ?? null; + return $minVersion !== null && $this->id >= $minVersion; + } + + /** + * Whether this version supports [] array literals. + */ + public function supportsShortArraySyntax(): bool { + return $this->id >= 50400; + } + + /** + * Whether this version supports [] for destructuring. + */ + public function supportsShortArrayDestructuring(): bool { + return $this->id >= 70100; + } + + /** + * Whether this version supports flexible heredoc/nowdoc. + */ + public function supportsFlexibleHeredoc(): bool { + return $this->id >= 70300; + } + + /** + * Whether this version supports trailing commas in parameter lists. + */ + public function supportsTrailingCommaInParamList(): bool { + return $this->id >= 80000; + } + + /** + * Whether this version allows "$var =& new Obj". + */ + public function allowsAssignNewByReference(): bool { + return $this->id < 70000; + } + + /** + * Whether this version allows invalid octals like "08". + */ + public function allowsInvalidOctals(): bool { + return $this->id < 70000; + } + + /** + * Whether this version allows DEL (\x7f) to occur in identifiers. + */ + public function allowsDelInIdentifiers(): bool { + return $this->id < 70100; + } + + /** + * Whether this version supports yield in expression context without parentheses. + */ + public function supportsYieldWithoutParentheses(): bool { + return $this->id >= 70000; + } + + /** + * Whether this version supports unicode escape sequences in strings. + */ + public function supportsUnicodeEscapes(): bool { + return $this->id >= 70000; + } +} diff --git a/src/ncc/ThirdParty/nikic/PhpParser/PrettyPrinter.php b/src/ncc/ThirdParty/nikic/PhpParser/PrettyPrinter.php new file mode 100644 index 0000000..f9852d1 --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/PrettyPrinter.php @@ -0,0 +1,51 @@ +pAttrGroups($node->attrGroups, true) . $this->pModifiers($node->flags) . ($node->type ? $this->p($node->type) . ' ' : '') . ($node->byRef ? '&' : '') . ($node->variadic ? '...' : '') . $this->p($node->var) - . ($node->default ? ' = ' . $this->p($node->default) : ''); + . ($node->default ? ' = ' . $this->p($node->default) : '') + . ($node->hooks ? ' {' . $this->pStmts($node->hooks) . $this->nl . '}' : ''); } - protected function pArg(Node\Arg $node) { + protected function pArg(Node\Arg $node): string { return ($node->name ? $node->name->toString() . ': ' : '') . ($node->byRef ? '&' : '') . ($node->unpack ? '...' : '') . $this->p($node->value); } - protected function pVariadicPlaceholder(Node\VariadicPlaceholder $node) { + protected function pVariadicPlaceholder(Node\VariadicPlaceholder $node): string { return '...'; } - protected function pConst(Node\Const_ $node) { + protected function pConst(Node\Const_ $node): string { return $node->name . ' = ' . $this->p($node->value); } - protected function pNullableType(Node\NullableType $node) { + protected function pNullableType(Node\NullableType $node): string { return '?' . $this->p($node->type); } - protected function pUnionType(Node\UnionType $node) { + protected function pUnionType(Node\UnionType $node): string { $types = []; foreach ($node->types as $typeNode) { if ($typeNode instanceof Node\IntersectionType) { @@ -57,138 +57,154 @@ class Standard extends PrettyPrinterAbstract return implode('|', $types); } - protected function pIntersectionType(Node\IntersectionType $node) { + protected function pIntersectionType(Node\IntersectionType $node): string { return $this->pImplode($node->types, '&'); } - protected function pIdentifier(Node\Identifier $node) { + protected function pIdentifier(Node\Identifier $node): string { return $node->name; } - protected function pVarLikeIdentifier(Node\VarLikeIdentifier $node) { + protected function pVarLikeIdentifier(Node\VarLikeIdentifier $node): string { return '$' . $node->name; } - protected function pAttribute(Node\Attribute $node) { + protected function pAttribute(Node\Attribute $node): string { return $this->p($node->name) . ($node->args ? '(' . $this->pCommaSeparated($node->args) . ')' : ''); } - protected function pAttributeGroup(Node\AttributeGroup $node) { + protected function pAttributeGroup(Node\AttributeGroup $node): string { return '#[' . $this->pCommaSeparated($node->attrs) . ']'; } // Names - protected function pName(Name $node) { - return implode('\\', $node->parts); + protected function pName(Name $node): string { + return $node->name; } - protected function pName_FullyQualified(Name\FullyQualified $node) { - return '\\' . implode('\\', $node->parts); + protected function pName_FullyQualified(Name\FullyQualified $node): string { + return '\\' . $node->name; } - protected function pName_Relative(Name\Relative $node) { - return 'namespace\\' . implode('\\', $node->parts); + protected function pName_Relative(Name\Relative $node): string { + return 'namespace\\' . $node->name; } // Magic Constants - protected function pScalar_MagicConst_Class(MagicConst\Class_ $node) { + protected function pScalar_MagicConst_Class(MagicConst\Class_ $node): string { return '__CLASS__'; } - protected function pScalar_MagicConst_Dir(MagicConst\Dir $node) { + protected function pScalar_MagicConst_Dir(MagicConst\Dir $node): string { return '__DIR__'; } - protected function pScalar_MagicConst_File(MagicConst\File $node) { + protected function pScalar_MagicConst_File(MagicConst\File $node): string { return '__FILE__'; } - protected function pScalar_MagicConst_Function(MagicConst\Function_ $node) { + protected function pScalar_MagicConst_Function(MagicConst\Function_ $node): string { return '__FUNCTION__'; } - protected function pScalar_MagicConst_Line(MagicConst\Line $node) { + protected function pScalar_MagicConst_Line(MagicConst\Line $node): string { return '__LINE__'; } - protected function pScalar_MagicConst_Method(MagicConst\Method $node) { + protected function pScalar_MagicConst_Method(MagicConst\Method $node): string { return '__METHOD__'; } - protected function pScalar_MagicConst_Namespace(MagicConst\Namespace_ $node) { + protected function pScalar_MagicConst_Namespace(MagicConst\Namespace_ $node): string { return '__NAMESPACE__'; } - protected function pScalar_MagicConst_Trait(MagicConst\Trait_ $node) { + protected function pScalar_MagicConst_Trait(MagicConst\Trait_ $node): string { return '__TRAIT__'; } + protected function pScalar_MagicConst_Property(MagicConst\Property $node): string { + return '__PROPERTY__'; + } + // Scalars - protected function pScalar_String(Scalar\String_ $node) { + private function indentString(string $str): string { + return str_replace("\n", $this->nl, $str); + } + + protected function pScalar_String(Scalar\String_ $node): string { $kind = $node->getAttribute('kind', Scalar\String_::KIND_SINGLE_QUOTED); switch ($kind) { case Scalar\String_::KIND_NOWDOC: $label = $node->getAttribute('docLabel'); if ($label && !$this->containsEndLabel($node->value, $label)) { + $shouldIdent = $this->phpVersion->supportsFlexibleHeredoc(); + $nl = $shouldIdent ? $this->nl : $this->newline; if ($node->value === '') { - return "<<<'$label'\n$label" . $this->docStringEndToken; + return "<<<'$label'$nl$label{$this->docStringEndToken}"; } - return "<<<'$label'\n$node->value\n$label" - . $this->docStringEndToken; + // Make sure trailing \r is not combined with following \n into CRLF. + if ($node->value[strlen($node->value) - 1] !== "\r") { + $value = $shouldIdent ? $this->indentString($node->value) : $node->value; + return "<<<'$label'$nl$value$nl$label{$this->docStringEndToken}"; + } } /* break missing intentionally */ + // no break case Scalar\String_::KIND_SINGLE_QUOTED: return $this->pSingleQuotedString($node->value); case Scalar\String_::KIND_HEREDOC: $label = $node->getAttribute('docLabel'); - if ($label && !$this->containsEndLabel($node->value, $label)) { - if ($node->value === '') { - return "<<<$label\n$label" . $this->docStringEndToken; + $escaped = $this->escapeString($node->value, null); + if ($label && !$this->containsEndLabel($escaped, $label)) { + $nl = $this->phpVersion->supportsFlexibleHeredoc() ? $this->nl : $this->newline; + if ($escaped === '') { + return "<<<$label$nl$label{$this->docStringEndToken}"; } - $escaped = $this->escapeString($node->value, null); - return "<<<$label\n" . $escaped . "\n$label" - . $this->docStringEndToken; + return "<<<$label$nl$escaped$nl$label{$this->docStringEndToken}"; } - /* break missing intentionally */ + /* break missing intentionally */ + // no break case Scalar\String_::KIND_DOUBLE_QUOTED: return '"' . $this->escapeString($node->value, '"') . '"'; } throw new \Exception('Invalid string kind'); } - protected function pScalar_Encapsed(Scalar\Encapsed $node) { + protected function pScalar_InterpolatedString(Scalar\InterpolatedString $node): string { if ($node->getAttribute('kind') === Scalar\String_::KIND_HEREDOC) { $label = $node->getAttribute('docLabel'); if ($label && !$this->encapsedContainsEndLabel($node->parts, $label)) { + $nl = $this->phpVersion->supportsFlexibleHeredoc() ? $this->nl : $this->newline; if (count($node->parts) === 1 - && $node->parts[0] instanceof Scalar\EncapsedStringPart + && $node->parts[0] instanceof Node\InterpolatedStringPart && $node->parts[0]->value === '' ) { - return "<<<$label\n$label" . $this->docStringEndToken; + return "<<<$label$nl$label{$this->docStringEndToken}"; } - return "<<<$label\n" . $this->pEncapsList($node->parts, null) . "\n$label" - . $this->docStringEndToken; + return "<<<$label$nl" . $this->pEncapsList($node->parts, null) + . "$nl$label{$this->docStringEndToken}"; } } return '"' . $this->pEncapsList($node->parts, '"') . '"'; } - protected function pScalar_LNumber(Scalar\LNumber $node) { - if ($node->value === -\PHP_INT_MAX-1) { + protected function pScalar_Int(Scalar\Int_ $node): string { + if ($node->value === -\PHP_INT_MAX - 1) { // PHP_INT_MIN cannot be represented as a literal, // because the sign is not part of the literal return '(-' . \PHP_INT_MAX . '-1)'; } - $kind = $node->getAttribute('kind', Scalar\LNumber::KIND_DEC); - if (Scalar\LNumber::KIND_DEC === $kind) { + $kind = $node->getAttribute('kind', Scalar\Int_::KIND_DEC); + if (Scalar\Int_::KIND_DEC === $kind) { return (string) $node->value; } @@ -200,22 +216,23 @@ class Standard extends PrettyPrinterAbstract $str = (string) $node->value; } switch ($kind) { - case Scalar\LNumber::KIND_BIN: + case Scalar\Int_::KIND_BIN: return $sign . '0b' . base_convert($str, 10, 2); - case Scalar\LNumber::KIND_OCT: + case Scalar\Int_::KIND_OCT: return $sign . '0' . base_convert($str, 10, 8); - case Scalar\LNumber::KIND_HEX: + case Scalar\Int_::KIND_HEX: return $sign . '0x' . base_convert($str, 10, 16); } throw new \Exception('Invalid number kind'); } - protected function pScalar_DNumber(Scalar\DNumber $node) { + protected function pScalar_Float(Scalar\Float_ $node): string { if (!is_finite($node->value)) { if ($node->value === \INF) { - return '\INF'; - } elseif ($node->value === -\INF) { - return '-\INF'; + return '1.0E+1000'; + } + if ($node->value === -\INF) { + return '-1.0E+1000'; } else { return '\NAN'; } @@ -223,7 +240,7 @@ class Standard extends PrettyPrinterAbstract // Try to find a short full-precision representation $stringValue = sprintf('%.16G', $node->value); - if ($node->value !== (double) $stringValue) { + if ($node->value !== (float) $stringValue) { $stringValue = sprintf('%.17G', $node->value); } @@ -236,299 +253,288 @@ class Standard extends PrettyPrinterAbstract return preg_match('/^-?[0-9]+$/', $stringValue) ? $stringValue . '.0' : $stringValue; } - protected function pScalar_EncapsedStringPart(Scalar\EncapsedStringPart $node) { - throw new \LogicException('Cannot directly print EncapsedStringPart'); - } - // Assignments - protected function pExpr_Assign(Expr\Assign $node) { - return $this->pInfixOp(Expr\Assign::class, $node->var, ' = ', $node->expr); + protected function pExpr_Assign(Expr\Assign $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(Expr\Assign::class, $this->p($node->var) . ' = ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_AssignRef(Expr\AssignRef $node) { - return $this->pInfixOp(Expr\AssignRef::class, $node->var, ' =& ', $node->expr); + protected function pExpr_AssignRef(Expr\AssignRef $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(Expr\AssignRef::class, $this->p($node->var) . ' =& ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_AssignOp_Plus(AssignOp\Plus $node) { - return $this->pInfixOp(AssignOp\Plus::class, $node->var, ' += ', $node->expr); + protected function pExpr_AssignOp_Plus(AssignOp\Plus $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(AssignOp\Plus::class, $this->p($node->var) . ' += ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_AssignOp_Minus(AssignOp\Minus $node) { - return $this->pInfixOp(AssignOp\Minus::class, $node->var, ' -= ', $node->expr); + protected function pExpr_AssignOp_Minus(AssignOp\Minus $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(AssignOp\Minus::class, $this->p($node->var) . ' -= ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_AssignOp_Mul(AssignOp\Mul $node) { - return $this->pInfixOp(AssignOp\Mul::class, $node->var, ' *= ', $node->expr); + protected function pExpr_AssignOp_Mul(AssignOp\Mul $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(AssignOp\Mul::class, $this->p($node->var) . ' *= ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_AssignOp_Div(AssignOp\Div $node) { - return $this->pInfixOp(AssignOp\Div::class, $node->var, ' /= ', $node->expr); + protected function pExpr_AssignOp_Div(AssignOp\Div $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(AssignOp\Div::class, $this->p($node->var) . ' /= ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_AssignOp_Concat(AssignOp\Concat $node) { - return $this->pInfixOp(AssignOp\Concat::class, $node->var, ' .= ', $node->expr); + protected function pExpr_AssignOp_Concat(AssignOp\Concat $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(AssignOp\Concat::class, $this->p($node->var) . ' .= ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_AssignOp_Mod(AssignOp\Mod $node) { - return $this->pInfixOp(AssignOp\Mod::class, $node->var, ' %= ', $node->expr); + protected function pExpr_AssignOp_Mod(AssignOp\Mod $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(AssignOp\Mod::class, $this->p($node->var) . ' %= ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_AssignOp_BitwiseAnd(AssignOp\BitwiseAnd $node) { - return $this->pInfixOp(AssignOp\BitwiseAnd::class, $node->var, ' &= ', $node->expr); + protected function pExpr_AssignOp_BitwiseAnd(AssignOp\BitwiseAnd $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(AssignOp\BitwiseAnd::class, $this->p($node->var) . ' &= ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_AssignOp_BitwiseOr(AssignOp\BitwiseOr $node) { - return $this->pInfixOp(AssignOp\BitwiseOr::class, $node->var, ' |= ', $node->expr); + protected function pExpr_AssignOp_BitwiseOr(AssignOp\BitwiseOr $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(AssignOp\BitwiseOr::class, $this->p($node->var) . ' |= ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_AssignOp_BitwiseXor(AssignOp\BitwiseXor $node) { - return $this->pInfixOp(AssignOp\BitwiseXor::class, $node->var, ' ^= ', $node->expr); + protected function pExpr_AssignOp_BitwiseXor(AssignOp\BitwiseXor $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(AssignOp\BitwiseXor::class, $this->p($node->var) . ' ^= ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_AssignOp_ShiftLeft(AssignOp\ShiftLeft $node) { - return $this->pInfixOp(AssignOp\ShiftLeft::class, $node->var, ' <<= ', $node->expr); + protected function pExpr_AssignOp_ShiftLeft(AssignOp\ShiftLeft $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(AssignOp\ShiftLeft::class, $this->p($node->var) . ' <<= ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_AssignOp_ShiftRight(AssignOp\ShiftRight $node) { - return $this->pInfixOp(AssignOp\ShiftRight::class, $node->var, ' >>= ', $node->expr); + protected function pExpr_AssignOp_ShiftRight(AssignOp\ShiftRight $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(AssignOp\ShiftRight::class, $this->p($node->var) . ' >>= ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_AssignOp_Pow(AssignOp\Pow $node) { - return $this->pInfixOp(AssignOp\Pow::class, $node->var, ' **= ', $node->expr); + protected function pExpr_AssignOp_Pow(AssignOp\Pow $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(AssignOp\Pow::class, $this->p($node->var) . ' **= ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_AssignOp_Coalesce(AssignOp\Coalesce $node) { - return $this->pInfixOp(AssignOp\Coalesce::class, $node->var, ' ??= ', $node->expr); + protected function pExpr_AssignOp_Coalesce(AssignOp\Coalesce $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(AssignOp\Coalesce::class, $this->p($node->var) . ' ??= ', $node->expr, $precedence, $lhsPrecedence); } // Binary expressions - protected function pExpr_BinaryOp_Plus(BinaryOp\Plus $node) { - return $this->pInfixOp(BinaryOp\Plus::class, $node->left, ' + ', $node->right); + protected function pExpr_BinaryOp_Plus(BinaryOp\Plus $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\Plus::class, $node->left, ' + ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_Minus(BinaryOp\Minus $node) { - return $this->pInfixOp(BinaryOp\Minus::class, $node->left, ' - ', $node->right); + protected function pExpr_BinaryOp_Minus(BinaryOp\Minus $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\Minus::class, $node->left, ' - ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_Mul(BinaryOp\Mul $node) { - return $this->pInfixOp(BinaryOp\Mul::class, $node->left, ' * ', $node->right); + protected function pExpr_BinaryOp_Mul(BinaryOp\Mul $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\Mul::class, $node->left, ' * ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_Div(BinaryOp\Div $node) { - return $this->pInfixOp(BinaryOp\Div::class, $node->left, ' / ', $node->right); + protected function pExpr_BinaryOp_Div(BinaryOp\Div $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\Div::class, $node->left, ' / ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_Concat(BinaryOp\Concat $node) { - return $this->pInfixOp(BinaryOp\Concat::class, $node->left, ' . ', $node->right); + protected function pExpr_BinaryOp_Concat(BinaryOp\Concat $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\Concat::class, $node->left, ' . ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_Mod(BinaryOp\Mod $node) { - return $this->pInfixOp(BinaryOp\Mod::class, $node->left, ' % ', $node->right); + protected function pExpr_BinaryOp_Mod(BinaryOp\Mod $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\Mod::class, $node->left, ' % ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_BooleanAnd(BinaryOp\BooleanAnd $node) { - return $this->pInfixOp(BinaryOp\BooleanAnd::class, $node->left, ' && ', $node->right); + protected function pExpr_BinaryOp_BooleanAnd(BinaryOp\BooleanAnd $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\BooleanAnd::class, $node->left, ' && ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_BooleanOr(BinaryOp\BooleanOr $node) { - return $this->pInfixOp(BinaryOp\BooleanOr::class, $node->left, ' || ', $node->right); + protected function pExpr_BinaryOp_BooleanOr(BinaryOp\BooleanOr $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\BooleanOr::class, $node->left, ' || ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_BitwiseAnd(BinaryOp\BitwiseAnd $node) { - return $this->pInfixOp(BinaryOp\BitwiseAnd::class, $node->left, ' & ', $node->right); + protected function pExpr_BinaryOp_BitwiseAnd(BinaryOp\BitwiseAnd $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\BitwiseAnd::class, $node->left, ' & ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_BitwiseOr(BinaryOp\BitwiseOr $node) { - return $this->pInfixOp(BinaryOp\BitwiseOr::class, $node->left, ' | ', $node->right); + protected function pExpr_BinaryOp_BitwiseOr(BinaryOp\BitwiseOr $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\BitwiseOr::class, $node->left, ' | ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_BitwiseXor(BinaryOp\BitwiseXor $node) { - return $this->pInfixOp(BinaryOp\BitwiseXor::class, $node->left, ' ^ ', $node->right); + protected function pExpr_BinaryOp_BitwiseXor(BinaryOp\BitwiseXor $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\BitwiseXor::class, $node->left, ' ^ ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_ShiftLeft(BinaryOp\ShiftLeft $node) { - return $this->pInfixOp(BinaryOp\ShiftLeft::class, $node->left, ' << ', $node->right); + protected function pExpr_BinaryOp_ShiftLeft(BinaryOp\ShiftLeft $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\ShiftLeft::class, $node->left, ' << ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_ShiftRight(BinaryOp\ShiftRight $node) { - return $this->pInfixOp(BinaryOp\ShiftRight::class, $node->left, ' >> ', $node->right); + protected function pExpr_BinaryOp_ShiftRight(BinaryOp\ShiftRight $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\ShiftRight::class, $node->left, ' >> ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_Pow(BinaryOp\Pow $node) { - return $this->pInfixOp(BinaryOp\Pow::class, $node->left, ' ** ', $node->right); + protected function pExpr_BinaryOp_Pow(BinaryOp\Pow $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\Pow::class, $node->left, ' ** ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_LogicalAnd(BinaryOp\LogicalAnd $node) { - return $this->pInfixOp(BinaryOp\LogicalAnd::class, $node->left, ' and ', $node->right); + protected function pExpr_BinaryOp_LogicalAnd(BinaryOp\LogicalAnd $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\LogicalAnd::class, $node->left, ' and ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_LogicalOr(BinaryOp\LogicalOr $node) { - return $this->pInfixOp(BinaryOp\LogicalOr::class, $node->left, ' or ', $node->right); + protected function pExpr_BinaryOp_LogicalOr(BinaryOp\LogicalOr $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\LogicalOr::class, $node->left, ' or ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_LogicalXor(BinaryOp\LogicalXor $node) { - return $this->pInfixOp(BinaryOp\LogicalXor::class, $node->left, ' xor ', $node->right); + protected function pExpr_BinaryOp_LogicalXor(BinaryOp\LogicalXor $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\LogicalXor::class, $node->left, ' xor ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_Equal(BinaryOp\Equal $node) { - return $this->pInfixOp(BinaryOp\Equal::class, $node->left, ' == ', $node->right); + protected function pExpr_BinaryOp_Equal(BinaryOp\Equal $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\Equal::class, $node->left, ' == ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_NotEqual(BinaryOp\NotEqual $node) { - return $this->pInfixOp(BinaryOp\NotEqual::class, $node->left, ' != ', $node->right); + protected function pExpr_BinaryOp_NotEqual(BinaryOp\NotEqual $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\NotEqual::class, $node->left, ' != ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_Identical(BinaryOp\Identical $node) { - return $this->pInfixOp(BinaryOp\Identical::class, $node->left, ' === ', $node->right); + protected function pExpr_BinaryOp_Identical(BinaryOp\Identical $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\Identical::class, $node->left, ' === ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_NotIdentical(BinaryOp\NotIdentical $node) { - return $this->pInfixOp(BinaryOp\NotIdentical::class, $node->left, ' !== ', $node->right); + protected function pExpr_BinaryOp_NotIdentical(BinaryOp\NotIdentical $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\NotIdentical::class, $node->left, ' !== ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_Spaceship(BinaryOp\Spaceship $node) { - return $this->pInfixOp(BinaryOp\Spaceship::class, $node->left, ' <=> ', $node->right); + protected function pExpr_BinaryOp_Spaceship(BinaryOp\Spaceship $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\Spaceship::class, $node->left, ' <=> ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_Greater(BinaryOp\Greater $node) { - return $this->pInfixOp(BinaryOp\Greater::class, $node->left, ' > ', $node->right); + protected function pExpr_BinaryOp_Greater(BinaryOp\Greater $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\Greater::class, $node->left, ' > ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_GreaterOrEqual(BinaryOp\GreaterOrEqual $node) { - return $this->pInfixOp(BinaryOp\GreaterOrEqual::class, $node->left, ' >= ', $node->right); + protected function pExpr_BinaryOp_GreaterOrEqual(BinaryOp\GreaterOrEqual $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\GreaterOrEqual::class, $node->left, ' >= ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_Smaller(BinaryOp\Smaller $node) { - return $this->pInfixOp(BinaryOp\Smaller::class, $node->left, ' < ', $node->right); + protected function pExpr_BinaryOp_Smaller(BinaryOp\Smaller $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\Smaller::class, $node->left, ' < ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_SmallerOrEqual(BinaryOp\SmallerOrEqual $node) { - return $this->pInfixOp(BinaryOp\SmallerOrEqual::class, $node->left, ' <= ', $node->right); + protected function pExpr_BinaryOp_SmallerOrEqual(BinaryOp\SmallerOrEqual $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\SmallerOrEqual::class, $node->left, ' <= ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_BinaryOp_Coalesce(BinaryOp\Coalesce $node) { - return $this->pInfixOp(BinaryOp\Coalesce::class, $node->left, ' ?? ', $node->right); + protected function pExpr_BinaryOp_Coalesce(BinaryOp\Coalesce $node, int $precedence, int $lhsPrecedence): string { + return $this->pInfixOp(BinaryOp\Coalesce::class, $node->left, ' ?? ', $node->right, $precedence, $lhsPrecedence); } - protected function pExpr_Instanceof(Expr\Instanceof_ $node) { - list($precedence, $associativity) = $this->precedenceMap[Expr\Instanceof_::class]; - return $this->pPrec($node->expr, $precedence, $associativity, -1) - . ' instanceof ' - . $this->pNewVariable($node->class); + protected function pExpr_Instanceof(Expr\Instanceof_ $node, int $precedence, int $lhsPrecedence): string { + return $this->pPostfixOp( + Expr\Instanceof_::class, $node->expr, + ' instanceof ' . $this->pNewOperand($node->class), + $precedence, $lhsPrecedence); } // Unary expressions - protected function pExpr_BooleanNot(Expr\BooleanNot $node) { - return $this->pPrefixOp(Expr\BooleanNot::class, '!', $node->expr); + protected function pExpr_BooleanNot(Expr\BooleanNot $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(Expr\BooleanNot::class, '!', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_BitwiseNot(Expr\BitwiseNot $node) { - return $this->pPrefixOp(Expr\BitwiseNot::class, '~', $node->expr); + protected function pExpr_BitwiseNot(Expr\BitwiseNot $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(Expr\BitwiseNot::class, '~', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_UnaryMinus(Expr\UnaryMinus $node) { - if ($node->expr instanceof Expr\UnaryMinus || $node->expr instanceof Expr\PreDec) { - // Enforce -(-$expr) instead of --$expr - return '-(' . $this->p($node->expr) . ')'; - } - return $this->pPrefixOp(Expr\UnaryMinus::class, '-', $node->expr); + protected function pExpr_UnaryMinus(Expr\UnaryMinus $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(Expr\UnaryMinus::class, '-', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_UnaryPlus(Expr\UnaryPlus $node) { - if ($node->expr instanceof Expr\UnaryPlus || $node->expr instanceof Expr\PreInc) { - // Enforce +(+$expr) instead of ++$expr - return '+(' . $this->p($node->expr) . ')'; - } - return $this->pPrefixOp(Expr\UnaryPlus::class, '+', $node->expr); + protected function pExpr_UnaryPlus(Expr\UnaryPlus $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(Expr\UnaryPlus::class, '+', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_PreInc(Expr\PreInc $node) { - return $this->pPrefixOp(Expr\PreInc::class, '++', $node->var); + protected function pExpr_PreInc(Expr\PreInc $node): string { + return '++' . $this->p($node->var); } - protected function pExpr_PreDec(Expr\PreDec $node) { - return $this->pPrefixOp(Expr\PreDec::class, '--', $node->var); + protected function pExpr_PreDec(Expr\PreDec $node): string { + return '--' . $this->p($node->var); } - protected function pExpr_PostInc(Expr\PostInc $node) { - return $this->pPostfixOp(Expr\PostInc::class, $node->var, '++'); + protected function pExpr_PostInc(Expr\PostInc $node): string { + return $this->p($node->var) . '++'; } - protected function pExpr_PostDec(Expr\PostDec $node) { - return $this->pPostfixOp(Expr\PostDec::class, $node->var, '--'); + protected function pExpr_PostDec(Expr\PostDec $node): string { + return $this->p($node->var) . '--'; } - protected function pExpr_ErrorSuppress(Expr\ErrorSuppress $node) { - return $this->pPrefixOp(Expr\ErrorSuppress::class, '@', $node->expr); + protected function pExpr_ErrorSuppress(Expr\ErrorSuppress $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(Expr\ErrorSuppress::class, '@', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_YieldFrom(Expr\YieldFrom $node) { - return $this->pPrefixOp(Expr\YieldFrom::class, 'yield from ', $node->expr); + protected function pExpr_YieldFrom(Expr\YieldFrom $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(Expr\YieldFrom::class, 'yield from ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_Print(Expr\Print_ $node) { - return $this->pPrefixOp(Expr\Print_::class, 'print ', $node->expr); + protected function pExpr_Print(Expr\Print_ $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(Expr\Print_::class, 'print ', $node->expr, $precedence, $lhsPrecedence); } // Casts - protected function pExpr_Cast_Int(Cast\Int_ $node) { - return $this->pPrefixOp(Cast\Int_::class, '(int) ', $node->expr); + protected function pExpr_Cast_Int(Cast\Int_ $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(Cast\Int_::class, '(int) ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_Cast_Double(Cast\Double $node) { + protected function pExpr_Cast_Double(Cast\Double $node, int $precedence, int $lhsPrecedence): string { $kind = $node->getAttribute('kind', Cast\Double::KIND_DOUBLE); if ($kind === Cast\Double::KIND_DOUBLE) { $cast = '(double)'; } elseif ($kind === Cast\Double::KIND_FLOAT) { $cast = '(float)'; - } elseif ($kind === Cast\Double::KIND_REAL) { + } else { + assert($kind === Cast\Double::KIND_REAL); $cast = '(real)'; } - return $this->pPrefixOp(Cast\Double::class, $cast . ' ', $node->expr); + return $this->pPrefixOp(Cast\Double::class, $cast . ' ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_Cast_String(Cast\String_ $node) { - return $this->pPrefixOp(Cast\String_::class, '(string) ', $node->expr); + protected function pExpr_Cast_String(Cast\String_ $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(Cast\String_::class, '(string) ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_Cast_Array(Cast\Array_ $node) { - return $this->pPrefixOp(Cast\Array_::class, '(array) ', $node->expr); + protected function pExpr_Cast_Array(Cast\Array_ $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(Cast\Array_::class, '(array) ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_Cast_Object(Cast\Object_ $node) { - return $this->pPrefixOp(Cast\Object_::class, '(object) ', $node->expr); + protected function pExpr_Cast_Object(Cast\Object_ $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(Cast\Object_::class, '(object) ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_Cast_Bool(Cast\Bool_ $node) { - return $this->pPrefixOp(Cast\Bool_::class, '(bool) ', $node->expr); + protected function pExpr_Cast_Bool(Cast\Bool_ $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(Cast\Bool_::class, '(bool) ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_Cast_Unset(Cast\Unset_ $node) { - return $this->pPrefixOp(Cast\Unset_::class, '(unset) ', $node->expr); + protected function pExpr_Cast_Unset(Cast\Unset_ $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(Cast\Unset_::class, '(unset) ', $node->expr, $precedence, $lhsPrecedence); } // Function calls and similar constructs - protected function pExpr_FuncCall(Expr\FuncCall $node) { + protected function pExpr_FuncCall(Expr\FuncCall $node): string { return $this->pCallLhs($node->name) . '(' . $this->pMaybeMultiline($node->args) . ')'; } - protected function pExpr_MethodCall(Expr\MethodCall $node) { + protected function pExpr_MethodCall(Expr\MethodCall $node): string { return $this->pDereferenceLhs($node->var) . '->' . $this->pObjectProperty($node->name) . '(' . $this->pMaybeMultiline($node->args) . ')'; } - protected function pExpr_NullsafeMethodCall(Expr\NullsafeMethodCall $node) { + protected function pExpr_NullsafeMethodCall(Expr\NullsafeMethodCall $node): string { return $this->pDereferenceLhs($node->var) . '?->' . $this->pObjectProperty($node->name) . '(' . $this->pMaybeMultiline($node->args) . ')'; } - protected function pExpr_StaticCall(Expr\StaticCall $node) { + protected function pExpr_StaticCall(Expr\StaticCall $node): string { return $this->pStaticDereferenceLhs($node->class) . '::' . ($node->name instanceof Expr ? ($node->name instanceof Expr\Variable @@ -538,19 +544,19 @@ class Standard extends PrettyPrinterAbstract . '(' . $this->pMaybeMultiline($node->args) . ')'; } - protected function pExpr_Empty(Expr\Empty_ $node) { + protected function pExpr_Empty(Expr\Empty_ $node): string { return 'empty(' . $this->p($node->expr) . ')'; } - protected function pExpr_Isset(Expr\Isset_ $node) { + protected function pExpr_Isset(Expr\Isset_ $node): string { return 'isset(' . $this->pCommaSeparated($node->vars) . ')'; } - protected function pExpr_Eval(Expr\Eval_ $node) { + protected function pExpr_Eval(Expr\Eval_ $node): string { return 'eval(' . $this->p($node->expr) . ')'; } - protected function pExpr_Include(Expr\Include_ $node) { + protected function pExpr_Include(Expr\Include_ $node, int $precedence, int $lhsPrecedence): string { static $map = [ Expr\Include_::TYPE_INCLUDE => 'include', Expr\Include_::TYPE_INCLUDE_ONCE => 'include_once', @@ -558,20 +564,26 @@ class Standard extends PrettyPrinterAbstract Expr\Include_::TYPE_REQUIRE_ONCE => 'require_once', ]; - return $map[$node->type] . ' ' . $this->p($node->expr); + return $this->pPrefixOp(Expr\Include_::class, $map[$node->type] . ' ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_List(Expr\List_ $node) { - return 'list(' . $this->pCommaSeparated($node->items) . ')'; + protected function pExpr_List(Expr\List_ $node): string { + $syntax = $node->getAttribute('kind', + $this->phpVersion->supportsShortArrayDestructuring() ? Expr\List_::KIND_ARRAY : Expr\List_::KIND_LIST); + if ($syntax === Expr\List_::KIND_ARRAY) { + return '[' . $this->pMaybeMultiline($node->items, true) . ']'; + } else { + return 'list(' . $this->pMaybeMultiline($node->items, true) . ')'; + } } // Other - protected function pExpr_Error(Expr\Error $node) { + protected function pExpr_Error(Expr\Error $node): string { throw new \LogicException('Cannot pretty-print AST with Error nodes'); } - protected function pExpr_Variable(Expr\Variable $node) { + protected function pExpr_Variable(Expr\Variable $node): string { if ($node->name instanceof Expr) { return '${' . $this->p($node->name) . '}'; } else { @@ -579,9 +591,9 @@ class Standard extends PrettyPrinterAbstract } } - protected function pExpr_Array(Expr\Array_ $node) { + protected function pExpr_Array(Expr\Array_ $node): string { $syntax = $node->getAttribute('kind', - $this->options['shortArraySyntax'] ? Expr\Array_::KIND_SHORT : Expr\Array_::KIND_LONG); + $this->shortArraySyntax ? Expr\Array_::KIND_SHORT : Expr\Array_::KIND_LONG); if ($syntax === Expr\Array_::KIND_SHORT) { return '[' . $this->pMaybeMultiline($node->items, true) . ']'; } else { @@ -589,124 +601,152 @@ class Standard extends PrettyPrinterAbstract } } - protected function pExpr_ArrayItem(Expr\ArrayItem $node) { - return (null !== $node->key ? $this->p($node->key) . ' => ' : '') + protected function pKey(?Node $node): string { + if ($node === null) { + return ''; + } + + // => is not really an operator and does not typically participate in precedence resolution. + // However, there is an exception if yield expressions with keys are involved: + // [yield $a => $b] is interpreted as [(yield $a => $b)], so we need to ensure that + // [(yield $a) => $b] is printed with parentheses. We approximate this by lowering the LHS + // precedence to that of yield (which will also print unnecessary parentheses for rare low + // precedence unary operators like include). + $yieldPrecedence = $this->precedenceMap[Expr\Yield_::class][0]; + return $this->p($node, self::MAX_PRECEDENCE, $yieldPrecedence) . ' => '; + } + + protected function pArrayItem(Node\ArrayItem $node): string { + return $this->pKey($node->key) . ($node->byRef ? '&' : '') . ($node->unpack ? '...' : '') . $this->p($node->value); } - protected function pExpr_ArrayDimFetch(Expr\ArrayDimFetch $node) { + protected function pExpr_ArrayDimFetch(Expr\ArrayDimFetch $node): string { return $this->pDereferenceLhs($node->var) . '[' . (null !== $node->dim ? $this->p($node->dim) : '') . ']'; } - protected function pExpr_ConstFetch(Expr\ConstFetch $node) { + protected function pExpr_ConstFetch(Expr\ConstFetch $node): string { return $this->p($node->name); } - protected function pExpr_ClassConstFetch(Expr\ClassConstFetch $node) { + protected function pExpr_ClassConstFetch(Expr\ClassConstFetch $node): string { return $this->pStaticDereferenceLhs($node->class) . '::' . $this->pObjectProperty($node->name); } - protected function pExpr_PropertyFetch(Expr\PropertyFetch $node) { + protected function pExpr_PropertyFetch(Expr\PropertyFetch $node): string { return $this->pDereferenceLhs($node->var) . '->' . $this->pObjectProperty($node->name); } - protected function pExpr_NullsafePropertyFetch(Expr\NullsafePropertyFetch $node) { + protected function pExpr_NullsafePropertyFetch(Expr\NullsafePropertyFetch $node): string { return $this->pDereferenceLhs($node->var) . '?->' . $this->pObjectProperty($node->name); } - protected function pExpr_StaticPropertyFetch(Expr\StaticPropertyFetch $node) { + protected function pExpr_StaticPropertyFetch(Expr\StaticPropertyFetch $node): string { return $this->pStaticDereferenceLhs($node->class) . '::$' . $this->pObjectProperty($node->name); } - protected function pExpr_ShellExec(Expr\ShellExec $node) { + protected function pExpr_ShellExec(Expr\ShellExec $node): string { return '`' . $this->pEncapsList($node->parts, '`') . '`'; } - protected function pExpr_Closure(Expr\Closure $node) { + protected function pExpr_Closure(Expr\Closure $node): string { return $this->pAttrGroups($node->attrGroups, true) - . ($node->static ? 'static ' : '') + . $this->pStatic($node->static) . 'function ' . ($node->byRef ? '&' : '') - . '(' . $this->pCommaSeparated($node->params) . ')' - . (!empty($node->uses) ? ' use(' . $this->pCommaSeparated($node->uses) . ')' : '') - . (null !== $node->returnType ? ' : ' . $this->p($node->returnType) : '') + . '(' . $this->pMaybeMultiline($node->params, $this->phpVersion->supportsTrailingCommaInParamList()) . ')' + . (!empty($node->uses) ? ' use (' . $this->pCommaSeparated($node->uses) . ')' : '') + . (null !== $node->returnType ? ': ' . $this->p($node->returnType) : '') . ' {' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pExpr_Match(Expr\Match_ $node) { + protected function pExpr_Match(Expr\Match_ $node): string { return 'match (' . $this->p($node->cond) . ') {' . $this->pCommaSeparatedMultiline($node->arms, true) . $this->nl . '}'; } - protected function pMatchArm(Node\MatchArm $node) { - return ($node->conds ? $this->pCommaSeparated($node->conds) : 'default') - . ' => ' . $this->p($node->body); + protected function pMatchArm(Node\MatchArm $node): string { + $result = ''; + if ($node->conds) { + for ($i = 0, $c = \count($node->conds); $i + 1 < $c; $i++) { + $result .= $this->p($node->conds[$i]) . ', '; + } + $result .= $this->pKey($node->conds[$i]); + } else { + $result = 'default => '; + } + return $result . $this->p($node->body); } - protected function pExpr_ArrowFunction(Expr\ArrowFunction $node) { - return $this->pAttrGroups($node->attrGroups, true) - . ($node->static ? 'static ' : '') + protected function pExpr_ArrowFunction(Expr\ArrowFunction $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp( + Expr\ArrowFunction::class, + $this->pAttrGroups($node->attrGroups, true) + . $this->pStatic($node->static) . 'fn' . ($node->byRef ? '&' : '') - . '(' . $this->pCommaSeparated($node->params) . ')' + . '(' . $this->pMaybeMultiline($node->params, $this->phpVersion->supportsTrailingCommaInParamList()) . ')' . (null !== $node->returnType ? ': ' . $this->p($node->returnType) : '') - . ' => ' - . $this->p($node->expr); + . ' => ', + $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_ClosureUse(Expr\ClosureUse $node) { + protected function pClosureUse(Node\ClosureUse $node): string { return ($node->byRef ? '&' : '') . $this->p($node->var); } - protected function pExpr_New(Expr\New_ $node) { + protected function pExpr_New(Expr\New_ $node): string { if ($node->class instanceof Stmt\Class_) { $args = $node->args ? '(' . $this->pMaybeMultiline($node->args) . ')' : ''; return 'new ' . $this->pClassCommon($node->class, $args); } - return 'new ' . $this->pNewVariable($node->class) + return 'new ' . $this->pNewOperand($node->class) . '(' . $this->pMaybeMultiline($node->args) . ')'; } - protected function pExpr_Clone(Expr\Clone_ $node) { - return 'clone ' . $this->p($node->expr); + protected function pExpr_Clone(Expr\Clone_ $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(Expr\Clone_::class, 'clone ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_Ternary(Expr\Ternary $node) { + protected function pExpr_Ternary(Expr\Ternary $node, int $precedence, int $lhsPrecedence): string { // a bit of cheating: we treat the ternary as a binary op where the ?...: part is the operator. // this is okay because the part between ? and : never needs parentheses. return $this->pInfixOp(Expr\Ternary::class, - $node->cond, ' ?' . (null !== $node->if ? ' ' . $this->p($node->if) . ' ' : '') . ': ', $node->else + $node->cond, ' ?' . (null !== $node->if ? ' ' . $this->p($node->if) . ' ' : '') . ': ', $node->else, + $precedence, $lhsPrecedence ); } - protected function pExpr_Exit(Expr\Exit_ $node) { + protected function pExpr_Exit(Expr\Exit_ $node): string { $kind = $node->getAttribute('kind', Expr\Exit_::KIND_DIE); return ($kind === Expr\Exit_::KIND_EXIT ? 'exit' : 'die') . (null !== $node->expr ? '(' . $this->p($node->expr) . ')' : ''); } - protected function pExpr_Throw(Expr\Throw_ $node) { - return 'throw ' . $this->p($node->expr); + protected function pExpr_Throw(Expr\Throw_ $node, int $precedence, int $lhsPrecedence): string { + return $this->pPrefixOp(Expr\Throw_::class, 'throw ', $node->expr, $precedence, $lhsPrecedence); } - protected function pExpr_Yield(Expr\Yield_ $node) { + protected function pExpr_Yield(Expr\Yield_ $node, int $precedence, int $lhsPrecedence): string { if ($node->value === null) { - return 'yield'; + $opPrecedence = $this->precedenceMap[Expr\Yield_::class][0]; + return $opPrecedence >= $lhsPrecedence ? '(yield)' : 'yield'; } else { - // this is a bit ugly, but currently there is no way to detect whether the parentheses are necessary - return '(yield ' - . ($node->key !== null ? $this->p($node->key) . ' => ' : '') - . $this->p($node->value) - . ')'; + if (!$this->phpVersion->supportsYieldWithoutParentheses()) { + return '(yield ' . $this->pKey($node->key) . $this->p($node->value) . ')'; + } + return $this->pPrefixOp( + Expr\Yield_::class, 'yield ' . $this->pKey($node->key), + $node->value, $precedence, $lhsPrecedence); } } // Declarations - protected function pStmt_Namespace(Stmt\Namespace_ $node) { + protected function pStmt_Namespace(Stmt\Namespace_ $node): string { if ($this->canUseSemicolonNamespaces) { return 'namespace ' . $this->p($node->name) . ';' . $this->nl . $this->pStmts($node->stmts, false); @@ -716,102 +756,112 @@ class Standard extends PrettyPrinterAbstract } } - protected function pStmt_Use(Stmt\Use_ $node) { + protected function pStmt_Use(Stmt\Use_ $node): string { return 'use ' . $this->pUseType($node->type) . $this->pCommaSeparated($node->uses) . ';'; } - protected function pStmt_GroupUse(Stmt\GroupUse $node) { + protected function pStmt_GroupUse(Stmt\GroupUse $node): string { return 'use ' . $this->pUseType($node->type) . $this->pName($node->prefix) . '\{' . $this->pCommaSeparated($node->uses) . '};'; } - protected function pStmt_UseUse(Stmt\UseUse $node) { + protected function pUseItem(Node\UseItem $node): string { return $this->pUseType($node->type) . $this->p($node->name) . (null !== $node->alias ? ' as ' . $node->alias : ''); } - protected function pUseType($type) { + protected function pUseType(int $type): string { return $type === Stmt\Use_::TYPE_FUNCTION ? 'function ' : ($type === Stmt\Use_::TYPE_CONSTANT ? 'const ' : ''); } - protected function pStmt_Interface(Stmt\Interface_ $node) { + protected function pStmt_Interface(Stmt\Interface_ $node): string { return $this->pAttrGroups($node->attrGroups) . 'interface ' . $node->name . (!empty($node->extends) ? ' extends ' . $this->pCommaSeparated($node->extends) : '') . $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pStmt_Enum(Stmt\Enum_ $node) { + protected function pStmt_Enum(Stmt\Enum_ $node): string { return $this->pAttrGroups($node->attrGroups) . 'enum ' . $node->name - . ($node->scalarType ? " : $node->scalarType" : '') + . ($node->scalarType ? ' : ' . $this->p($node->scalarType) : '') . (!empty($node->implements) ? ' implements ' . $this->pCommaSeparated($node->implements) : '') . $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pStmt_Class(Stmt\Class_ $node) { + protected function pStmt_Class(Stmt\Class_ $node): string { return $this->pClassCommon($node, ' ' . $node->name); } - protected function pStmt_Trait(Stmt\Trait_ $node) { + protected function pStmt_Trait(Stmt\Trait_ $node): string { return $this->pAttrGroups($node->attrGroups) . 'trait ' . $node->name . $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pStmt_EnumCase(Stmt\EnumCase $node) { + protected function pStmt_EnumCase(Stmt\EnumCase $node): string { return $this->pAttrGroups($node->attrGroups) . 'case ' . $node->name . ($node->expr ? ' = ' . $this->p($node->expr) : '') . ';'; } - protected function pStmt_TraitUse(Stmt\TraitUse $node) { + protected function pStmt_TraitUse(Stmt\TraitUse $node): string { return 'use ' . $this->pCommaSeparated($node->traits) . (empty($node->adaptations) ? ';' : ' {' . $this->pStmts($node->adaptations) . $this->nl . '}'); } - protected function pStmt_TraitUseAdaptation_Precedence(Stmt\TraitUseAdaptation\Precedence $node) { + protected function pStmt_TraitUseAdaptation_Precedence(\ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Precedence $node): string { return $this->p($node->trait) . '::' . $node->method . ' insteadof ' . $this->pCommaSeparated($node->insteadof) . ';'; } - protected function pStmt_TraitUseAdaptation_Alias(Stmt\TraitUseAdaptation\Alias $node) { + protected function pStmt_TraitUseAdaptation_Alias(\ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Alias $node): string { return (null !== $node->trait ? $this->p($node->trait) . '::' : '') . $node->method . ' as' . (null !== $node->newModifier ? ' ' . rtrim($this->pModifiers($node->newModifier), ' ') : '') - . (null !== $node->newName ? ' ' . $node->newName : '') + . (null !== $node->newName ? ' ' . $node->newName : '') . ';'; } - protected function pStmt_Property(Stmt\Property $node) { + protected function pStmt_Property(Stmt\Property $node): string { return $this->pAttrGroups($node->attrGroups) . (0 === $node->flags ? 'var ' : $this->pModifiers($node->flags)) . ($node->type ? $this->p($node->type) . ' ' : '') - . $this->pCommaSeparated($node->props) . ';'; + . $this->pCommaSeparated($node->props) + . ($node->hooks ? ' {' . $this->pStmts($node->hooks) . $this->nl . '}' : ';'); } - protected function pStmt_PropertyProperty(Stmt\PropertyProperty $node) { + protected function pPropertyItem(Node\PropertyItem $node): string { return '$' . $node->name . (null !== $node->default ? ' = ' . $this->p($node->default) : ''); } - protected function pStmt_ClassMethod(Stmt\ClassMethod $node) { + protected function pPropertyHook(Node\PropertyHook $node): string { + return $this->pAttrGroups($node->attrGroups) + . $this->pModifiers($node->flags) + . ($node->byRef ? '&' : '') . $node->name + . ($node->params ? '(' . $this->pMaybeMultiline($node->params, $this->phpVersion->supportsTrailingCommaInParamList()) . ')' : '') + . (\is_array($node->body) ? ' {' . $this->pStmts($node->body) . $this->nl . '}' + : ($node->body !== null ? ' => ' . $this->p($node->body) : '') . ';'); + } + + protected function pStmt_ClassMethod(Stmt\ClassMethod $node): string { return $this->pAttrGroups($node->attrGroups) . $this->pModifiers($node->flags) . 'function ' . ($node->byRef ? '&' : '') . $node->name - . '(' . $this->pMaybeMultiline($node->params) . ')' - . (null !== $node->returnType ? ' : ' . $this->p($node->returnType) : '') + . '(' . $this->pMaybeMultiline($node->params, $this->phpVersion->supportsTrailingCommaInParamList()) . ')' + . (null !== $node->returnType ? ': ' . $this->p($node->returnType) : '') . (null !== $node->stmts ? $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}' : ';'); } - protected function pStmt_ClassConst(Stmt\ClassConst $node) { + protected function pStmt_ClassConst(Stmt\ClassConst $node): string { return $this->pAttrGroups($node->attrGroups) . $this->pModifiers($node->flags) . 'const ' @@ -819,46 +869,50 @@ class Standard extends PrettyPrinterAbstract . $this->pCommaSeparated($node->consts) . ';'; } - protected function pStmt_Function(Stmt\Function_ $node) { + protected function pStmt_Function(Stmt\Function_ $node): string { return $this->pAttrGroups($node->attrGroups) . 'function ' . ($node->byRef ? '&' : '') . $node->name - . '(' . $this->pCommaSeparated($node->params) . ')' - . (null !== $node->returnType ? ' : ' . $this->p($node->returnType) : '') + . '(' . $this->pMaybeMultiline($node->params, $this->phpVersion->supportsTrailingCommaInParamList()) . ')' + . (null !== $node->returnType ? ': ' . $this->p($node->returnType) : '') . $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pStmt_Const(Stmt\Const_ $node) { + protected function pStmt_Const(Stmt\Const_ $node): string { return 'const ' . $this->pCommaSeparated($node->consts) . ';'; } - protected function pStmt_Declare(Stmt\Declare_ $node) { + protected function pStmt_Declare(Stmt\Declare_ $node): string { return 'declare (' . $this->pCommaSeparated($node->declares) . ')' . (null !== $node->stmts ? ' {' . $this->pStmts($node->stmts) . $this->nl . '}' : ';'); } - protected function pStmt_DeclareDeclare(Stmt\DeclareDeclare $node) { + protected function pDeclareItem(Node\DeclareItem $node): string { return $node->key . '=' . $this->p($node->value); } // Control flow - protected function pStmt_If(Stmt\If_ $node) { + protected function pStmt_If(Stmt\If_ $node): string { return 'if (' . $this->p($node->cond) . ') {' . $this->pStmts($node->stmts) . $this->nl . '}' . ($node->elseifs ? ' ' . $this->pImplode($node->elseifs, ' ') : '') . (null !== $node->else ? ' ' . $this->p($node->else) : ''); } - protected function pStmt_ElseIf(Stmt\ElseIf_ $node) { + protected function pStmt_ElseIf(Stmt\ElseIf_ $node): string { return 'elseif (' . $this->p($node->cond) . ') {' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pStmt_Else(Stmt\Else_ $node) { + protected function pStmt_Else(Stmt\Else_ $node): string { + if (\count($node->stmts) === 1 && $node->stmts[0] instanceof Stmt\If_) { + // Print as "else if" rather than "else { if }" + return 'else ' . $this->p($node->stmts[0]); + } return 'else {' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pStmt_For(Stmt\For_ $node) { + protected function pStmt_For(Stmt\For_ $node): string { return 'for (' . $this->pCommaSeparated($node->init) . ';' . (!empty($node->cond) ? ' ' : '') . $this->pCommaSeparated($node->cond) . ';' . (!empty($node->loop) ? ' ' : '') @@ -866,116 +920,116 @@ class Standard extends PrettyPrinterAbstract . ') {' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pStmt_Foreach(Stmt\Foreach_ $node) { + protected function pStmt_Foreach(Stmt\Foreach_ $node): string { return 'foreach (' . $this->p($node->expr) . ' as ' . (null !== $node->keyVar ? $this->p($node->keyVar) . ' => ' : '') . ($node->byRef ? '&' : '') . $this->p($node->valueVar) . ') {' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pStmt_While(Stmt\While_ $node) { + protected function pStmt_While(Stmt\While_ $node): string { return 'while (' . $this->p($node->cond) . ') {' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pStmt_Do(Stmt\Do_ $node) { + protected function pStmt_Do(Stmt\Do_ $node): string { return 'do {' . $this->pStmts($node->stmts) . $this->nl . '} while (' . $this->p($node->cond) . ');'; } - protected function pStmt_Switch(Stmt\Switch_ $node) { + protected function pStmt_Switch(Stmt\Switch_ $node): string { return 'switch (' . $this->p($node->cond) . ') {' . $this->pStmts($node->cases) . $this->nl . '}'; } - protected function pStmt_Case(Stmt\Case_ $node) { + protected function pStmt_Case(Stmt\Case_ $node): string { return (null !== $node->cond ? 'case ' . $this->p($node->cond) : 'default') . ':' . $this->pStmts($node->stmts); } - protected function pStmt_TryCatch(Stmt\TryCatch $node) { + protected function pStmt_TryCatch(Stmt\TryCatch $node): string { return 'try {' . $this->pStmts($node->stmts) . $this->nl . '}' . ($node->catches ? ' ' . $this->pImplode($node->catches, ' ') : '') . ($node->finally !== null ? ' ' . $this->p($node->finally) : ''); } - protected function pStmt_Catch(Stmt\Catch_ $node) { + protected function pStmt_Catch(Stmt\Catch_ $node): string { return 'catch (' . $this->pImplode($node->types, '|') . ($node->var !== null ? ' ' . $this->p($node->var) : '') . ') {' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pStmt_Finally(Stmt\Finally_ $node) { + protected function pStmt_Finally(Stmt\Finally_ $node): string { return 'finally {' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pStmt_Break(Stmt\Break_ $node) { + protected function pStmt_Break(Stmt\Break_ $node): string { return 'break' . ($node->num !== null ? ' ' . $this->p($node->num) : '') . ';'; } - protected function pStmt_Continue(Stmt\Continue_ $node) { + protected function pStmt_Continue(Stmt\Continue_ $node): string { return 'continue' . ($node->num !== null ? ' ' . $this->p($node->num) : '') . ';'; } - protected function pStmt_Return(Stmt\Return_ $node) { + protected function pStmt_Return(Stmt\Return_ $node): string { return 'return' . (null !== $node->expr ? ' ' . $this->p($node->expr) : '') . ';'; } - protected function pStmt_Throw(Stmt\Throw_ $node) { - return 'throw ' . $this->p($node->expr) . ';'; - } - - protected function pStmt_Label(Stmt\Label $node) { + protected function pStmt_Label(Stmt\Label $node): string { return $node->name . ':'; } - protected function pStmt_Goto(Stmt\Goto_ $node) { + protected function pStmt_Goto(Stmt\Goto_ $node): string { return 'goto ' . $node->name . ';'; } // Other - protected function pStmt_Expression(Stmt\Expression $node) { + protected function pStmt_Expression(Stmt\Expression $node): string { return $this->p($node->expr) . ';'; } - protected function pStmt_Echo(Stmt\Echo_ $node) { + protected function pStmt_Echo(Stmt\Echo_ $node): string { return 'echo ' . $this->pCommaSeparated($node->exprs) . ';'; } - protected function pStmt_Static(Stmt\Static_ $node) { + protected function pStmt_Static(Stmt\Static_ $node): string { return 'static ' . $this->pCommaSeparated($node->vars) . ';'; } - protected function pStmt_Global(Stmt\Global_ $node) { + protected function pStmt_Global(Stmt\Global_ $node): string { return 'global ' . $this->pCommaSeparated($node->vars) . ';'; } - protected function pStmt_StaticVar(Stmt\StaticVar $node) { + protected function pStaticVar(Node\StaticVar $node): string { return $this->p($node->var) . (null !== $node->default ? ' = ' . $this->p($node->default) : ''); } - protected function pStmt_Unset(Stmt\Unset_ $node) { + protected function pStmt_Unset(Stmt\Unset_ $node): string { return 'unset(' . $this->pCommaSeparated($node->vars) . ');'; } - protected function pStmt_InlineHTML(Stmt\InlineHTML $node) { - $newline = $node->getAttribute('hasLeadingNewline', true) ? "\n" : ''; + protected function pStmt_InlineHTML(Stmt\InlineHTML $node): string { + $newline = $node->getAttribute('hasLeadingNewline', true) ? $this->newline : ''; return '?>' . $newline . $node->value . 'remaining; } - protected function pStmt_Nop(Stmt\Nop $node) { + protected function pStmt_Nop(Stmt\Nop $node): string { return ''; } + protected function pStmt_Block(Stmt\Block $node): string { + return '{' . $this->pStmts($node->stmts) . $this->nl . '}'; + } + // Helpers - protected function pClassCommon(Stmt\Class_ $node, $afterClassToken) { + protected function pClassCommon(Stmt\Class_ $node, string $afterClassToken): string { return $this->pAttrGroups($node->attrGroups, $node->name === null) . $this->pModifiers($node->flags) . 'class' . $afterClassToken @@ -984,18 +1038,20 @@ class Standard extends PrettyPrinterAbstract . $this->nl . '{' . $this->pStmts($node->stmts) . $this->nl . '}'; } - protected function pObjectProperty($node) { + protected function pObjectProperty(Node $node): string { if ($node instanceof Expr) { return '{' . $this->p($node) . '}'; } else { - return $node; + assert($node instanceof Node\Identifier); + return $node->name; } } - protected function pEncapsList(array $encapsList, $quote) { + /** @param (Expr|Node\InterpolatedStringPart)[] $encapsList */ + protected function pEncapsList(array $encapsList, ?string $quote): string { $return = ''; foreach ($encapsList as $element) { - if ($element instanceof Scalar\EncapsedStringPart) { + if ($element instanceof Node\InterpolatedStringPart) { $return .= $this->escapeString($element->value, $quote); } else { $return .= '{' . $this->p($element) . '}'; @@ -1005,14 +1061,25 @@ class Standard extends PrettyPrinterAbstract return $return; } - protected function pSingleQuotedString(string $string) { - return '\'' . addcslashes($string, '\'\\') . '\''; + protected function pSingleQuotedString(string $string): string { + // It is idiomatic to only escape backslashes when necessary, i.e. when followed by ', \ or + // the end of the string ('Foo\Bar' instead of 'Foo\\Bar'). However, we also don't want to + // produce an odd number of backslashes, so '\\\\a' should not get rendered as '\\\a', even + // though that would be legal. + $regex = '/\'|\\\\(?=[\'\\\\]|$)|(?<=\\\\)\\\\/'; + return '\'' . preg_replace($regex, '\\\\$0', $string) . '\''; } - protected function escapeString($string, $quote) { + protected function escapeString(string $string, ?string $quote): string { if (null === $quote) { // For doc strings, don't escape newlines $escaped = addcslashes($string, "\t\f\v$\\"); + // But do escape isolated \r. Combined with the terminating newline, it might get + // interpreted as \r\n and dropped from the string contents. + $escaped = preg_replace('/\r(?!\n)/', '\\r', $escaped); + if ($this->phpVersion->supportsFlexibleHeredoc()) { + $escaped = $this->indentString($escaped); + } } else { $escaped = addcslashes($string, "\n\r\t\f\v$" . $quote . "\\"); } @@ -1034,26 +1101,24 @@ class Standard extends PrettyPrinterAbstract | (?<=[\xF0-\xF4])[\x80-\xBF](?![\x80-\xBF]{2}) # Short 4 byte sequence | (?<=[\xF0-\xF4][\x80-\xBF])[\x80-\xBF](?![\x80-\xBF]) # Short 4 byte sequence (2) )/x'; - return preg_replace_callback($regex, function ($matches) { + return preg_replace_callback($regex, function ($matches): string { assert(strlen($matches[0]) === 1); - $hex = dechex(ord($matches[0]));; + $hex = dechex(ord($matches[0])); return '\\x' . str_pad($hex, 2, '0', \STR_PAD_LEFT); }, $escaped); } - protected function containsEndLabel($string, $label, $atStart = true, $atEnd = true) { - $start = $atStart ? '(?:^|[\r\n])' : '[\r\n]'; - $end = $atEnd ? '(?:$|[;\r\n])' : '[;\r\n]'; + protected function containsEndLabel(string $string, string $label, bool $atStart = true): bool { + $start = $atStart ? '(?:^|[\r\n])[ \t]*' : '[\r\n][ \t]*'; return false !== strpos($string, $label) - && preg_match('/' . $start . $label . $end . '/', $string); + && preg_match('/' . $start . $label . '(?:$|[^_A-Za-z0-9\x80-\xff])/', $string); } - protected function encapsedContainsEndLabel(array $parts, $label) { + /** @param (Expr|Node\InterpolatedStringPart)[] $parts */ + protected function encapsedContainsEndLabel(array $parts, string $label): bool { foreach ($parts as $i => $part) { - $atStart = $i === 0; - $atEnd = $i === count($parts) - 1; - if ($part instanceof Scalar\EncapsedStringPart - && $this->containsEndLabel($part->value, $label, $atStart, $atEnd) + if ($part instanceof Node\InterpolatedStringPart + && $this->containsEndLabel($this->escapeString($part->value, null), $label, $i === 0) ) { return true; } @@ -1061,15 +1126,15 @@ class Standard extends PrettyPrinterAbstract return false; } - protected function pDereferenceLhs(Node $node) { + protected function pDereferenceLhs(Node $node): string { if (!$this->dereferenceLhsRequiresParens($node)) { return $this->p($node); - } else { + } else { return '(' . $this->p($node) . ')'; } } - protected function pStaticDereferenceLhs(Node $node) { + protected function pStaticDereferenceLhs(Node $node): string { if (!$this->staticDereferenceLhsRequiresParens($node)) { return $this->p($node); } else { @@ -1077,15 +1142,15 @@ class Standard extends PrettyPrinterAbstract } } - protected function pCallLhs(Node $node) { + protected function pCallLhs(Node $node): string { if (!$this->callLhsRequiresParens($node)) { return $this->p($node); - } else { + } else { return '(' . $this->p($node) . ')'; } } - protected function pNewVariable(Node $node): string { + protected function pNewOperand(Node $node): string { if (!$this->newOperandRequiresParens($node)) { return $this->p($node); } else { @@ -1095,9 +1160,8 @@ class Standard extends PrettyPrinterAbstract /** * @param Node[] $nodes - * @return bool */ - protected function hasNodeWithComments(array $nodes) { + protected function hasNodeWithComments(array $nodes): bool { foreach ($nodes as $node) { if ($node && $node->getComments()) { return true; @@ -1106,7 +1170,8 @@ class Standard extends PrettyPrinterAbstract return false; } - protected function pMaybeMultiline(array $nodes, bool $trailingComma = false) { + /** @param Node[] $nodes */ + protected function pMaybeMultiline(array $nodes, bool $trailingComma = false): string { if (!$this->hasNodeWithComments($nodes)) { return $this->pCommaSeparated($nodes); } else { @@ -1114,6 +1179,7 @@ class Standard extends PrettyPrinterAbstract } } + /** @param Node\AttributeGroup[] $nodes */ protected function pAttrGroups(array $nodes, bool $inline = false): string { $result = ''; $sep = $inline ? ' ' : $this->nl; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/PrettyPrinterAbstract.php b/src/ncc/ThirdParty/nikic/PhpParser/PrettyPrinterAbstract.php index d738fd4..43fe1a9 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/PrettyPrinterAbstract.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/PrettyPrinterAbstract.php @@ -3,162 +3,201 @@ namespace ncc\ThirdParty\nikic\PhpParser; use ncc\ThirdParty\nikic\PhpParser\Internal\DiffElem; +use ncc\ThirdParty\nikic\PhpParser\Internal\Differ; use ncc\ThirdParty\nikic\PhpParser\Internal\PrintableNewAnonClassNode; use ncc\ThirdParty\nikic\PhpParser\Internal\TokenStream; +use ncc\ThirdParty\nikic\PhpParser\Node\AttributeGroup; use ncc\ThirdParty\nikic\PhpParser\Node\Expr; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\AssignOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\BinaryOp; use ncc\ThirdParty\nikic\PhpParser\Node\Expr\Cast; +use ncc\ThirdParty\nikic\PhpParser\Node\IntersectionType; +use ncc\ThirdParty\nikic\PhpParser\Node\MatchArm; +use ncc\ThirdParty\nikic\PhpParser\Node\Param; +use ncc\ThirdParty\nikic\PhpParser\Node\PropertyHook; use ncc\ThirdParty\nikic\PhpParser\Node\Scalar; use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; +use ncc\ThirdParty\nikic\PhpParser\Node\UnionType; -abstract class PrettyPrinterAbstract -{ - const FIXUP_PREC_LEFT = 0; // LHS operand affected by precedence - const FIXUP_PREC_RIGHT = 1; // RHS operand affected by precedence - const FIXUP_CALL_LHS = 2; // LHS of call - const FIXUP_DEREF_LHS = 3; // LHS of dereferencing operation - const FIXUP_BRACED_NAME = 4; // Name operand that may require bracing - const FIXUP_VAR_BRACED_NAME = 5; // Name operand that may require ${} bracing - const FIXUP_ENCAPSED = 6; // Encapsed string part - const FIXUP_NEW = 7; // New/instanceof operand - const FIXUP_STATIC_DEREF_LHS = 8; // LHS of static dereferencing operation +abstract class PrettyPrinterAbstract implements PrettyPrinter { + protected const FIXUP_PREC_LEFT = 0; // LHS operand affected by precedence + protected const FIXUP_PREC_RIGHT = 1; // RHS operand affected by precedence + protected const FIXUP_PREC_UNARY = 2; // Only operand affected by precedence + protected const FIXUP_CALL_LHS = 3; // LHS of call + protected const FIXUP_DEREF_LHS = 4; // LHS of dereferencing operation + protected const FIXUP_STATIC_DEREF_LHS = 5; // LHS of static dereferencing operation + protected const FIXUP_BRACED_NAME = 6; // Name operand that may require bracing + protected const FIXUP_VAR_BRACED_NAME = 7; // Name operand that may require ${} bracing + protected const FIXUP_ENCAPSED = 8; // Encapsed string part + protected const FIXUP_NEW = 9; // New/instanceof operand - protected $precedenceMap = [ - // [precedence, associativity] - // where for precedence -1 is %left, 0 is %nonassoc and 1 is %right - BinaryOp\Pow::class => [ 0, 1], - Expr\BitwiseNot::class => [ 10, 1], - Expr\PreInc::class => [ 10, 1], - Expr\PreDec::class => [ 10, 1], - Expr\PostInc::class => [ 10, -1], - Expr\PostDec::class => [ 10, -1], - Expr\UnaryPlus::class => [ 10, 1], - Expr\UnaryMinus::class => [ 10, 1], - Cast\Int_::class => [ 10, 1], - Cast\Double::class => [ 10, 1], - Cast\String_::class => [ 10, 1], - Cast\Array_::class => [ 10, 1], - Cast\Object_::class => [ 10, 1], - Cast\Bool_::class => [ 10, 1], - Cast\Unset_::class => [ 10, 1], - Expr\ErrorSuppress::class => [ 10, 1], - Expr\Instanceof_::class => [ 20, 0], - Expr\BooleanNot::class => [ 30, 1], - BinaryOp\Mul::class => [ 40, -1], - BinaryOp\Div::class => [ 40, -1], - BinaryOp\Mod::class => [ 40, -1], - BinaryOp\Plus::class => [ 50, -1], - BinaryOp\Minus::class => [ 50, -1], - BinaryOp\Concat::class => [ 50, -1], - BinaryOp\ShiftLeft::class => [ 60, -1], - BinaryOp\ShiftRight::class => [ 60, -1], - BinaryOp\Smaller::class => [ 70, 0], - BinaryOp\SmallerOrEqual::class => [ 70, 0], - BinaryOp\Greater::class => [ 70, 0], - BinaryOp\GreaterOrEqual::class => [ 70, 0], - BinaryOp\Equal::class => [ 80, 0], - BinaryOp\NotEqual::class => [ 80, 0], - BinaryOp\Identical::class => [ 80, 0], - BinaryOp\NotIdentical::class => [ 80, 0], - BinaryOp\Spaceship::class => [ 80, 0], - BinaryOp\BitwiseAnd::class => [ 90, -1], - BinaryOp\BitwiseXor::class => [100, -1], - BinaryOp\BitwiseOr::class => [110, -1], - BinaryOp\BooleanAnd::class => [120, -1], - BinaryOp\BooleanOr::class => [130, -1], - BinaryOp\Coalesce::class => [140, 1], - Expr\Ternary::class => [150, 0], - // parser uses %left for assignments, but they really behave as %right - Expr\Assign::class => [160, 1], - Expr\AssignRef::class => [160, 1], - AssignOp\Plus::class => [160, 1], - AssignOp\Minus::class => [160, 1], - AssignOp\Mul::class => [160, 1], - AssignOp\Div::class => [160, 1], - AssignOp\Concat::class => [160, 1], - AssignOp\Mod::class => [160, 1], - AssignOp\BitwiseAnd::class => [160, 1], - AssignOp\BitwiseOr::class => [160, 1], - AssignOp\BitwiseXor::class => [160, 1], - AssignOp\ShiftLeft::class => [160, 1], - AssignOp\ShiftRight::class => [160, 1], - AssignOp\Pow::class => [160, 1], - AssignOp\Coalesce::class => [160, 1], - Expr\YieldFrom::class => [165, 1], - Expr\Print_::class => [168, 1], - BinaryOp\LogicalAnd::class => [170, -1], - BinaryOp\LogicalXor::class => [180, -1], - BinaryOp\LogicalOr::class => [190, -1], - Expr\Include_::class => [200, -1], + protected const MAX_PRECEDENCE = 1000; + + /** @var array */ + protected array $precedenceMap = [ + // [precedence, precedenceLHS, precedenceRHS] + // Where the latter two are the precedences to use for the LHS and RHS of a binary operator, + // where 1 is added to one of the sides depending on associativity. This information is not + // used for unary operators and set to -1. + Expr\Clone_::class => [-10, 0, 1], + BinaryOp\Pow::class => [ 0, 0, 1], + Expr\BitwiseNot::class => [ 10, -1, -1], + Expr\UnaryPlus::class => [ 10, -1, -1], + Expr\UnaryMinus::class => [ 10, -1, -1], + Cast\Int_::class => [ 10, -1, -1], + Cast\Double::class => [ 10, -1, -1], + Cast\String_::class => [ 10, -1, -1], + Cast\Array_::class => [ 10, -1, -1], + Cast\Object_::class => [ 10, -1, -1], + Cast\Bool_::class => [ 10, -1, -1], + Cast\Unset_::class => [ 10, -1, -1], + Expr\ErrorSuppress::class => [ 10, -1, -1], + Expr\Instanceof_::class => [ 20, -1, -1], + Expr\BooleanNot::class => [ 30, -1, -1], + BinaryOp\Mul::class => [ 40, 41, 40], + BinaryOp\Div::class => [ 40, 41, 40], + BinaryOp\Mod::class => [ 40, 41, 40], + BinaryOp\Plus::class => [ 50, 51, 50], + BinaryOp\Minus::class => [ 50, 51, 50], + BinaryOp\Concat::class => [ 50, 51, 50], + BinaryOp\ShiftLeft::class => [ 60, 61, 60], + BinaryOp\ShiftRight::class => [ 60, 61, 60], + BinaryOp\Smaller::class => [ 70, 70, 70], + BinaryOp\SmallerOrEqual::class => [ 70, 70, 70], + BinaryOp\Greater::class => [ 70, 70, 70], + BinaryOp\GreaterOrEqual::class => [ 70, 70, 70], + BinaryOp\Equal::class => [ 80, 80, 80], + BinaryOp\NotEqual::class => [ 80, 80, 80], + BinaryOp\Identical::class => [ 80, 80, 80], + BinaryOp\NotIdentical::class => [ 80, 80, 80], + BinaryOp\Spaceship::class => [ 80, 80, 80], + BinaryOp\BitwiseAnd::class => [ 90, 91, 90], + BinaryOp\BitwiseXor::class => [100, 101, 100], + BinaryOp\BitwiseOr::class => [110, 111, 110], + BinaryOp\BooleanAnd::class => [120, 121, 120], + BinaryOp\BooleanOr::class => [130, 131, 130], + BinaryOp\Coalesce::class => [140, 140, 141], + Expr\Ternary::class => [150, 150, 150], + Expr\Assign::class => [160, -1, -1], + Expr\AssignRef::class => [160, -1, -1], + AssignOp\Plus::class => [160, -1, -1], + AssignOp\Minus::class => [160, -1, -1], + AssignOp\Mul::class => [160, -1, -1], + AssignOp\Div::class => [160, -1, -1], + AssignOp\Concat::class => [160, -1, -1], + AssignOp\Mod::class => [160, -1, -1], + AssignOp\BitwiseAnd::class => [160, -1, -1], + AssignOp\BitwiseOr::class => [160, -1, -1], + AssignOp\BitwiseXor::class => [160, -1, -1], + AssignOp\ShiftLeft::class => [160, -1, -1], + AssignOp\ShiftRight::class => [160, -1, -1], + AssignOp\Pow::class => [160, -1, -1], + AssignOp\Coalesce::class => [160, -1, -1], + Expr\YieldFrom::class => [170, -1, -1], + Expr\Yield_::class => [175, -1, -1], + Expr\Print_::class => [180, -1, -1], + BinaryOp\LogicalAnd::class => [190, 191, 190], + BinaryOp\LogicalXor::class => [200, 201, 200], + BinaryOp\LogicalOr::class => [210, 211, 210], + Expr\Include_::class => [220, -1, -1], + Expr\ArrowFunction::class => [230, -1, -1], + Expr\Throw_::class => [240, -1, -1], ]; /** @var int Current indentation level. */ - protected $indentLevel; + protected int $indentLevel; + /** @var string Newline style. Does not include current indentation. */ + protected string $newline; /** @var string Newline including current indentation. */ - protected $nl; - /** @var string Token placed at end of doc string to ensure it is followed by a newline. */ - protected $docStringEndToken; + protected string $nl; + /** @var string|null Token placed at end of doc string to ensure it is followed by a newline. + * Null if flexible doc strings are used. */ + protected ?string $docStringEndToken; /** @var bool Whether semicolon namespaces can be used (i.e. no global namespace is used) */ - protected $canUseSemicolonNamespaces; - /** @var array Pretty printer options */ - protected $options; + protected bool $canUseSemicolonNamespaces; + /** @var bool Whether to use short array syntax if the node specifies no preference */ + protected bool $shortArraySyntax; + /** @var PhpVersion PHP version to target */ + protected PhpVersion $phpVersion; - /** @var TokenStream Original tokens for use in format-preserving pretty print */ - protected $origTokens; - /** @var Internal\Differ Differ for node lists */ - protected $nodeListDiffer; - /** @var bool[] Map determining whether a certain character is a label character */ - protected $labelCharMap; + /** @var TokenStream|null Original tokens for use in format-preserving pretty print */ + protected ?TokenStream $origTokens; + /** @var ncc\ThirdParty\nikic\PhpParser\Internal\Differ Differ for node lists */ + protected Differ $nodeListDiffer; + /** @var array Map determining whether a certain character is a label character */ + protected array $labelCharMap; /** - * @var int[][] Map from token classes and subnode names to FIXUP_* constants. This is used - * during format-preserving prints to place additional parens/braces if necessary. + * @var array> Map from token classes and subnode names to FIXUP_* constants. + * This is used during format-preserving prints to place additional parens/braces if necessary. */ - protected $fixupMap; + protected array $fixupMap; /** - * @var int[][] Map from "{$node->getType()}->{$subNode}" to ['left' => $l, 'right' => $r], - * where $l and $r specify the token type that needs to be stripped when removing - * this node. + * @var array Map from "{$node->getType()}->{$subNode}" + * to ['left' => $l, 'right' => $r], where $l and $r specify the token type that needs to be stripped + * when removing this node. */ - protected $removalMap; + protected array $removalMap; /** - * @var mixed[] Map from "{$node->getType()}->{$subNode}" to [$find, $beforeToken, $extraLeft, $extraRight]. - * $find is an optional token after which the insertion occurs. $extraLeft/Right - * are optionally added before/after the main insertions. + * @var array Map from + * "{$node->getType()}->{$subNode}" to [$find, $beforeToken, $extraLeft, $extraRight]. + * $find is an optional token after which the insertion occurs. $extraLeft/Right + * are optionally added before/after the main insertions. */ - protected $insertionMap; + protected array $insertionMap; /** - * @var string[] Map From "{$node->getType()}->{$subNode}" to string that should be inserted - * between elements of this list subnode. + * @var array Map From "{$class}->{$subNode}" to string that should be inserted + * between elements of this list subnode. */ - protected $listInsertionMap; - protected $emptyListInsertionMap; - /** @var int[] Map from "{$node->getType()}->{$subNode}" to token before which the modifiers - * should be reprinted. */ - protected $modifierChangeMap; + protected array $listInsertionMap; + + /** + * @var array + */ + protected array $emptyListInsertionMap; + /** @var array Map from "{$class}->{$subNode}" to [$printFn, $token] + * where $printFn is the function to print the modifiers and $token is the token before which + * the modifiers should be reprinted. */ + protected array $modifierChangeMap; /** * Creates a pretty printer instance using the given options. * * Supported options: - * * bool $shortArraySyntax = false: Whether to use [] instead of array() as the default array - * syntax, if the node does not specify a format. + * * PhpVersion $phpVersion: The PHP version to target (default to PHP 7.4). This option + * controls compatibility of the generated code with older PHP + * versions in cases where a simple stylistic choice exists (e.g. + * array() vs []). It is safe to pretty-print an AST for a newer + * PHP version while specifying an older target (but the result will + * of course not be compatible with the older version in that case). + * * string $newline: The newline style to use. Should be "\n" (default) or "\r\n". + * * bool $shortArraySyntax: Whether to use [] instead of array() as the default array + * syntax, if the node does not specify a format. Defaults to whether + * the phpVersion support short array syntax. * - * @param array $options Dictionary of formatting options + * @param array{ + * phpVersion?: PhpVersion, newline?: string, shortArraySyntax?: bool + * } $options Dictionary of formatting options */ public function __construct(array $options = []) { - $this->docStringEndToken = '_DOC_STRING_END_' . mt_rand(); + $this->phpVersion = $options['phpVersion'] ?? PhpVersion::fromComponents(7, 4); - $defaultOptions = ['shortArraySyntax' => false]; - $this->options = $options + $defaultOptions; + $this->newline = $options['newline'] ?? "\n"; + if ($this->newline !== "\n" && $this->newline != "\r\n") { + throw new \LogicException('Option "newline" must be one of "\n" or "\r\n"'); + } + + $this->shortArraySyntax = + $options['shortArraySyntax'] ?? $this->phpVersion->supportsShortArraySyntax(); + $this->docStringEndToken = + $this->phpVersion->supportsFlexibleHeredoc() ? null : '_DOC_STRING_END_' . mt_rand(); } /** * Reset pretty printing state. */ - protected function resetState() { + protected function resetState(): void { $this->indentLevel = 0; - $this->nl = "\n"; + $this->nl = $this->newline; $this->origTokens = null; } @@ -167,15 +206,15 @@ abstract class PrettyPrinterAbstract * * @param int $level Level in number of spaces */ - protected function setIndentLevel(int $level) { + protected function setIndentLevel(int $level): void { $this->indentLevel = $level; - $this->nl = "\n" . \str_repeat(' ', $level); + $this->nl = $this->newline . \str_repeat(' ', $level); } /** * Increase indentation level. */ - protected function indent() { + protected function indent(): void { $this->indentLevel += 4; $this->nl .= ' '; } @@ -183,10 +222,10 @@ abstract class PrettyPrinterAbstract /** * Decrease indentation level. */ - protected function outdent() { + protected function outdent(): void { assert($this->indentLevel >= 4); $this->indentLevel -= 4; - $this->nl = "\n" . str_repeat(' ', $this->indentLevel); + $this->nl = $this->newline . str_repeat(' ', $this->indentLevel); } /** @@ -196,7 +235,7 @@ abstract class PrettyPrinterAbstract * * @return string Pretty printed statements */ - public function prettyPrint(array $stmts) : string { + public function prettyPrint(array $stmts): string { $this->resetState(); $this->preprocessNodes($stmts); @@ -210,7 +249,7 @@ abstract class PrettyPrinterAbstract * * @return string Pretty printed node */ - public function prettyPrintExpr(Expr $node) : string { + public function prettyPrintExpr(Expr $node): string { $this->resetState(); return $this->handleMagicTokens($this->p($node)); } @@ -222,15 +261,15 @@ abstract class PrettyPrinterAbstract * * @return string Pretty printed statements */ - public function prettyPrintFile(array $stmts) : string { + public function prettyPrintFile(array $stmts): string { if (!$stmts) { - return "newline . $this->newline; } - $p = "prettyPrint($stmts); + $p = "newline . $this->newline . $this->prettyPrint($stmts); if ($stmts[0] instanceof Stmt\InlineHTML) { - $p = preg_replace('/^<\?php\s+\?>\n?/', '', $p); + $p = preg_replace('/^<\?php\s+\?>\r?\n?/', '', $p); } if ($stmts[count($stmts) - 1] instanceof Stmt\InlineHTML) { $p = preg_replace('/<\?php$/', '', rtrim($p)); @@ -244,7 +283,7 @@ abstract class PrettyPrinterAbstract * * @param Node[] $nodes Array of nodes */ - protected function preprocessNodes(array $nodes) { + protected function preprocessNodes(array $nodes): void { /* We can use semicolon-namespaces unless there is a global namespace declaration */ $this->canUseSemicolonNamespaces = true; foreach ($nodes as $node) { @@ -256,15 +295,17 @@ abstract class PrettyPrinterAbstract } /** - * Handles (and removes) no-indent and doc-string-end tokens. - * - * @param string $str - * @return string + * Handles (and removes) doc-string-end tokens. */ - protected function handleMagicTokens(string $str) : string { - // Replace doc-string-end tokens with nothing or a newline - $str = str_replace($this->docStringEndToken . ";\n", ";\n", $str); - $str = str_replace($this->docStringEndToken, "\n", $str); + protected function handleMagicTokens(string $str): string { + if ($this->docStringEndToken !== null) { + // Replace doc-string-end tokens with nothing or a newline + $str = str_replace( + $this->docStringEndToken . ';' . $this->newline, + ';' . $this->newline, + $str); + $str = str_replace($this->docStringEndToken, $this->newline, $str); + } return $str; } @@ -272,12 +313,12 @@ abstract class PrettyPrinterAbstract /** * Pretty prints an array of nodes (statements) and indents them optionally. * - * @param Node[] $nodes Array of nodes - * @param bool $indent Whether to indent the printed nodes + * @param Node[] $nodes Array of nodes + * @param bool $indent Whether to indent the printed nodes * * @return string Pretty printed statements */ - protected function pStmts(array $nodes, bool $indent = true) : string { + protected function pStmts(array $nodes, bool $indent = true): string { if ($indent) { $this->indent(); } @@ -305,84 +346,96 @@ abstract class PrettyPrinterAbstract /** * Pretty-print an infix operation while taking precedence into account. * - * @param string $class Node class of operator - * @param Node $leftNode Left-hand side node + * @param string $class Node class of operator + * @param Node $leftNode Left-hand side node * @param string $operatorString String representation of the operator - * @param Node $rightNode Right-hand side node + * @param Node $rightNode Right-hand side node + * @param int $precedence Precedence of parent operator + * @param int $lhsPrecedence Precedence for unary operator on LHS of binary operator * * @return string Pretty printed infix operation */ - protected function pInfixOp(string $class, Node $leftNode, string $operatorString, Node $rightNode) : string { - list($precedence, $associativity) = $this->precedenceMap[$class]; - - return $this->pPrec($leftNode, $precedence, $associativity, -1) - . $operatorString - . $this->pPrec($rightNode, $precedence, $associativity, 1); + protected function pInfixOp( + string $class, Node $leftNode, string $operatorString, Node $rightNode, + int $precedence, int $lhsPrecedence + ): string { + list($opPrecedence, $newPrecedenceLHS, $newPrecedenceRHS) = $this->precedenceMap[$class]; + $prefix = ''; + $suffix = ''; + if ($opPrecedence >= $precedence) { + $prefix = '('; + $suffix = ')'; + $lhsPrecedence = self::MAX_PRECEDENCE; + } + return $prefix . $this->p($leftNode, $newPrecedenceLHS, $newPrecedenceLHS) + . $operatorString . $this->p($rightNode, $newPrecedenceRHS, $lhsPrecedence) . $suffix; } /** * Pretty-print a prefix operation while taking precedence into account. * - * @param string $class Node class of operator + * @param string $class Node class of operator * @param string $operatorString String representation of the operator - * @param Node $node Node + * @param Node $node Node + * @param int $precedence Precedence of parent operator + * @param int $lhsPrecedence Precedence for unary operator on LHS of binary operator * * @return string Pretty printed prefix operation */ - protected function pPrefixOp(string $class, string $operatorString, Node $node) : string { - list($precedence, $associativity) = $this->precedenceMap[$class]; - return $operatorString . $this->pPrec($node, $precedence, $associativity, 1); + protected function pPrefixOp(string $class, string $operatorString, Node $node, int $precedence, int $lhsPrecedence): string { + $opPrecedence = $this->precedenceMap[$class][0]; + $prefix = ''; + $suffix = ''; + if ($opPrecedence >= $lhsPrecedence) { + $prefix = '('; + $suffix = ')'; + $lhsPrecedence = self::MAX_PRECEDENCE; + } + $printedArg = $this->p($node, $opPrecedence, $lhsPrecedence); + if (($operatorString === '+' && $printedArg[0] === '+') || + ($operatorString === '-' && $printedArg[0] === '-') + ) { + // Avoid printing +(+$a) as ++$a and similar. + $printedArg = '(' . $printedArg . ')'; + } + return $prefix . $operatorString . $printedArg . $suffix; } /** * Pretty-print a postfix operation while taking precedence into account. * - * @param string $class Node class of operator + * @param string $class Node class of operator * @param string $operatorString String representation of the operator - * @param Node $node Node + * @param Node $node Node + * @param int $precedence Precedence of parent operator + * @param int $lhsPrecedence Precedence for unary operator on LHS of binary operator * * @return string Pretty printed postfix operation */ - protected function pPostfixOp(string $class, Node $node, string $operatorString) : string { - list($precedence, $associativity) = $this->precedenceMap[$class]; - return $this->pPrec($node, $precedence, $associativity, -1) . $operatorString; - } - - /** - * Prints an expression node with the least amount of parentheses necessary to preserve the meaning. - * - * @param Node $node Node to pretty print - * @param int $parentPrecedence Precedence of the parent operator - * @param int $parentAssociativity Associativity of parent operator - * (-1 is left, 0 is nonassoc, 1 is right) - * @param int $childPosition Position of the node relative to the operator - * (-1 is left, 1 is right) - * - * @return string The pretty printed node - */ - protected function pPrec(Node $node, int $parentPrecedence, int $parentAssociativity, int $childPosition) : string { - $class = \get_class($node); - if (isset($this->precedenceMap[$class])) { - $childPrecedence = $this->precedenceMap[$class][0]; - if ($childPrecedence > $parentPrecedence - || ($parentPrecedence === $childPrecedence && $parentAssociativity !== $childPosition) - ) { - return '(' . $this->p($node) . ')'; - } + protected function pPostfixOp(string $class, Node $node, string $operatorString, int $precedence, int $lhsPrecedence): string { + $opPrecedence = $this->precedenceMap[$class][0]; + $prefix = ''; + $suffix = ''; + if ($opPrecedence >= $precedence) { + $prefix = '('; + $suffix = ')'; + $lhsPrecedence = self::MAX_PRECEDENCE; } - - return $this->p($node); + if ($opPrecedence < $lhsPrecedence) { + $lhsPrecedence = $opPrecedence; + } + return $prefix . $this->p($node, $opPrecedence, $lhsPrecedence) . $operatorString . $suffix; } /** * Pretty prints an array of nodes and implodes the printed values. * * @param Node[] $nodes Array of Nodes to be printed - * @param string $glue Character to implode with + * @param string $glue Character to implode with * - * @return string Imploded pretty printed nodes + * @return string Imploded pretty printed nodes> $pre */ - protected function pImplode(array $nodes, string $glue = '') : string { + protected function pImplode(array $nodes, string $glue = ''): string { $pNodes = []; foreach ($nodes as $node) { if (null === $node) { @@ -402,7 +455,7 @@ abstract class PrettyPrinterAbstract * * @return string Comma separated pretty printed nodes */ - protected function pCommaSeparated(array $nodes) : string { + protected function pCommaSeparated(array $nodes): string { return $this->pImplode($nodes, ', '); } @@ -411,12 +464,12 @@ abstract class PrettyPrinterAbstract * * The result includes a leading newline and one level of indentation (same as pStmts). * - * @param Node[] $nodes Array of Nodes to be printed - * @param bool $trailingComma Whether to use a trailing comma + * @param Node[] $nodes Array of Nodes to be printed + * @param bool $trailingComma Whether to use a trailing comma * * @return string Comma separated pretty printed nodes in multiline style */ - protected function pCommaSeparatedMultiline(array $nodes, bool $trailingComma) : string { + protected function pCommaSeparatedMultiline(array $nodes, bool $trailingComma): string { $this->indent(); $result = ''; @@ -448,7 +501,7 @@ abstract class PrettyPrinterAbstract * * @return string Reformatted text of comments */ - protected function pComments(array $comments) : string { + protected function pComments(array $comments): string { $formattedComments = []; foreach ($comments as $comment) { @@ -469,13 +522,11 @@ abstract class PrettyPrinterAbstract * * The CloningVisitor must be run on the AST prior to modification. * * The original tokens must be provided, using the getTokens() method on the lexer. * - * @param Node[] $stmts Modified AST with links to original AST - * @param Node[] $origStmts Original AST with token offset information - * @param array $origTokens Tokens of the original code - * - * @return string + * @param Node[] $stmts Modified AST with links to original AST + * @param Node[] $origStmts Original AST with token offset information + * @param Token[] $origTokens Tokens of the original code */ - public function printFormatPreserving(array $stmts, array $origStmts, array $origTokens) : string { + public function printFormatPreserving(array $stmts, array $origStmts, array $origTokens): string { $this->initializeNodeListDiffer(); $this->initializeLabelCharMap(); $this->initializeFixupMap(); @@ -493,18 +544,18 @@ abstract class PrettyPrinterAbstract $pos = 0; $result = $this->pArray($stmts, $origStmts, $pos, 0, 'File', 'stmts', null); if (null !== $result) { - $result .= $this->origTokens->getTokenCode($pos, count($origTokens), 0); + $result .= $this->origTokens->getTokenCode($pos, count($origTokens) - 1, 0); } else { // Fallback // TODO Add pStmts($stmts, false); + $result = "newline . $this->pStmts($stmts, false); } - return ltrim($this->handleMagicTokens($result)); + return $this->handleMagicTokens($result); } - protected function pFallback(Node $node) { - return $this->{'p' . $node->getType()}($node); + protected function pFallback(Node $node, int $precedence, int $lhsPrecedence): string { + return $this->{'p' . $node->getType()}($node, $precedence, $lhsPrecedence); } /** @@ -513,20 +564,25 @@ abstract class PrettyPrinterAbstract * This method also handles formatting preservation for nodes. * * @param Node $node Node to be pretty printed + * @param int $precedence Precedence of parent operator + * @param int $lhsPrecedence Precedence for unary operator on LHS of binary operator * @param bool $parentFormatPreserved Whether parent node has preserved formatting * * @return string Pretty printed node */ - protected function p(Node $node, $parentFormatPreserved = false) : string { + protected function p( + Node $node, int $precedence = self::MAX_PRECEDENCE, int $lhsPrecedence = self::MAX_PRECEDENCE, + bool $parentFormatPreserved = false + ): string { // No orig tokens means this is a normal pretty print without preservation of formatting if (!$this->origTokens) { - return $this->{'p' . $node->getType()}($node); + return $this->{'p' . $node->getType()}($node, $precedence, $lhsPrecedence); } - /** @var Node $origNode */ + /** @var Node|null $origNode */ $origNode = $node->getAttribute('origNode'); if (null === $origNode) { - return $this->pFallback($node); + return $this->pFallback($node, $precedence, $lhsPrecedence); } $class = \get_class($node); @@ -539,15 +595,17 @@ abstract class PrettyPrinterAbstract $fallbackNode = $node; if ($node instanceof Expr\New_ && $node->class instanceof Stmt\Class_) { // Normalize node structure of anonymous classes + assert($origNode instanceof Expr\New_); $node = PrintableNewAnonClassNode::fromNewNode($node); $origNode = PrintableNewAnonClassNode::fromNewNode($origNode); + $class = PrintableNewAnonClassNode::class; } // InlineHTML node does not contain closing and opening PHP tags. If the parent formatting // is not preserved, then we need to use the fallback code to make sure the tags are // printed. if ($node instanceof Stmt\InlineHTML && !$parentFormatPreserved) { - return $this->pFallback($fallbackNode); + return $this->pFallback($fallbackNode, $precedence, $lhsPrecedence); } $indentAdjustment = $this->indentLevel - $this->origTokens->getIndentationBefore($startPos); @@ -572,34 +630,27 @@ abstract class PrettyPrinterAbstract if (is_array($subNode) && is_array($origSubNode)) { // Array subnode changed, we might be able to reconstruct it $listResult = $this->pArray( - $subNode, $origSubNode, $pos, $indentAdjustment, $type, $subNodeName, + $subNode, $origSubNode, $pos, $indentAdjustment, $class, $subNodeName, $fixupInfo[$subNodeName] ?? null ); if (null === $listResult) { - return $this->pFallback($fallbackNode); + return $this->pFallback($fallbackNode, $precedence, $lhsPrecedence); } $result .= $listResult; continue; } - if (is_int($subNode) && is_int($origSubNode)) { - // Check if this is a modifier change - $key = $type . '->' . $subNodeName; - if (!isset($this->modifierChangeMap[$key])) { - return $this->pFallback($fallbackNode); - } - - $findToken = $this->modifierChangeMap[$key]; - $result .= $this->pModifiers($subNode); - $pos = $this->origTokens->findRight($pos, $findToken); - continue; + // Check if this is a modifier change + $key = $class . '->' . $subNodeName; + if (!isset($this->modifierChangeMap[$key])) { + return $this->pFallback($fallbackNode, $precedence, $lhsPrecedence); } - // If a non-node, non-array subnode changed, we don't be able to do a partial - // reconstructions, as we don't have enough offset information. Pretty print the - // whole node instead. - return $this->pFallback($fallbackNode); + [$printFn, $findToken] = $this->modifierChangeMap[$key]; + $result .= $this->$printFn($subNode); + $pos = $this->origTokens->findRight($pos, $findToken); + continue; } $extraLeft = ''; @@ -617,7 +668,7 @@ abstract class PrettyPrinterAbstract // A node has been inserted, check if we have insertion information for it $key = $type . '->' . $subNodeName; if (!isset($this->insertionMap[$key])) { - return $this->pFallback($fallbackNode); + return $this->pFallback($fallbackNode, $precedence, $lhsPrecedence); } list($findToken, $beforeToken, $extraLeft, $extraRight) = $this->insertionMap[$key]; @@ -639,7 +690,7 @@ abstract class PrettyPrinterAbstract // A node has been removed, check if we have removal information for it $key = $type . '->' . $subNodeName; if (!isset($this->removalMap[$key])) { - return $this->pFallback($fallbackNode); + return $this->pFallback($fallbackNode, $precedence, $lhsPrecedence); } // Adjust positions to account for additional tokens that must be skipped @@ -669,7 +720,7 @@ abstract class PrettyPrinterAbstract $fixup = $fixupInfo[$subNodeName]; $res = $this->pFixup($fixup, $subNode, $class, $subStartPos, $subEndPos); } else { - $res = $this->p($subNode, true); + $res = $this->p($subNode, self::MAX_PRECEDENCE, self::MAX_PRECEDENCE, true); } $this->safeAppend($result, $res); @@ -688,23 +739,23 @@ abstract class PrettyPrinterAbstract /** * Perform a format-preserving pretty print of an array. * - * @param array $nodes New nodes - * @param array $origNodes Original nodes - * @param int $pos Current token position (updated by reference) - * @param int $indentAdjustment Adjustment for indentation - * @param string $parentNodeType Type of the containing node. - * @param string $subNodeName Name of array subnode. - * @param null|int $fixup Fixup information for array item nodes + * @param Node[] $nodes New nodes + * @param Node[] $origNodes Original nodes + * @param int $pos Current token position (updated by reference) + * @param int $indentAdjustment Adjustment for indentation + * @param string $parentNodeClass Class of the containing node. + * @param string $subNodeName Name of array subnode. + * @param null|int $fixup Fixup information for array item nodes * * @return null|string Result of pretty print or null if cannot preserve formatting */ protected function pArray( - array $nodes, array $origNodes, int &$pos, int $indentAdjustment, - string $parentNodeType, string $subNodeName, $fixup - ) { + array $nodes, array $origNodes, int &$pos, int $indentAdjustment, + string $parentNodeClass, string $subNodeName, ?int $fixup + ): ?string { $diff = $this->nodeListDiffer->diffWithReplacements($origNodes, $nodes); - $mapKey = $parentNodeType . '->' . $subNodeName; + $mapKey = $parentNodeClass . '->' . $subNodeName; $insertStr = $this->listInsertionMap[$mapKey] ?? null; $isStmtList = $subNodeName === 'stmts'; @@ -735,9 +786,9 @@ abstract class PrettyPrinterAbstract $result = ''; foreach ($diff as $i => $diffElem) { $diffType = $diffElem->type; - /** @var Node|null $arrItem */ + /** @var Node|string|null $arrItem */ $arrItem = $diffElem->new; - /** @var Node|null $origArrItem */ + /** @var Node|string|null $origArrItem */ $origArrItem = $diffElem->old; if ($diffType === DiffElem::TYPE_KEEP || $diffType === DiffElem::TYPE_REPLACE) { @@ -776,9 +827,8 @@ abstract class PrettyPrinterAbstract } if ($skipRemovedNode) { - if ($isStmtList && ($this->origTokens->haveBracesInRange($pos, $itemStartPos) || - $this->origTokens->haveTagInRange($pos, $itemStartPos))) { - // We'd remove the brace of a code block. + if ($isStmtList && $this->origTokens->haveTagInRange($pos, $itemStartPos)) { + // We'd remove an opening/closing PHP tag. // TODO: Preserve formatting. $this->setIndentLevel($origIndentLevel); return null; @@ -798,7 +848,7 @@ abstract class PrettyPrinterAbstract } } - $this->safeAppend($result, $this->p($delayedAddNode, true)); + $this->safeAppend($result, $this->p($delayedAddNode, self::MAX_PRECEDENCE, self::MAX_PRECEDENCE, true)); if ($insertNewline) { $result .= $insertStr . $this->nl; @@ -827,10 +877,17 @@ abstract class PrettyPrinterAbstract return null; } + if (!$arrItem instanceof Node) { + // We only support list insertion of nodes. + return null; + } + // We go multiline if the original code was multiline, // or if it's an array item with a comment above it. + // Match always uses multiline formatting. if ($insertStr === ', ' && - ($this->isMultiline($origNodes) || $arrItem->getComments()) + ($this->isMultiline($origNodes) || $arrItem->getComments() || + $parentNodeClass === Expr\Match_::class) ) { $insertStr = ','; $insertNewline = true; @@ -880,9 +937,8 @@ abstract class PrettyPrinterAbstract $pos, $itemStartPos, $indentAdjustment); $skipRemovedNode = true; } else { - if ($isStmtList && ($this->origTokens->haveBracesInRange($pos, $itemStartPos) || - $this->origTokens->haveTagInRange($pos, $itemStartPos))) { - // We'd remove the brace of a code block. + if ($isStmtList && $this->origTokens->haveTagInRange($pos, $itemStartPos)) { + // We'd remove an opening/closing PHP tag. // TODO: Preserve formatting. return null; } @@ -897,7 +953,7 @@ abstract class PrettyPrinterAbstract if (null !== $fixup && $arrItem->getAttribute('origNode') !== $origArrItem) { $res = $this->pFixup($fixup, $arrItem, null, $itemStartPos, $itemEndPos); } else { - $res = $this->p($arrItem, true); + $res = $this->p($arrItem, self::MAX_PRECEDENCE, self::MAX_PRECEDENCE, true); } $this->safeAppend($result, $res); @@ -931,7 +987,7 @@ abstract class PrettyPrinterAbstract $result .= $this->nl; } } - $result .= $this->p($delayedAddNode, true); + $result .= $this->p($delayedAddNode, self::MAX_PRECEDENCE, self::MAX_PRECEDENCE, true); $first = false; } $result .= $extraRight === "\n" ? $this->nl : $extraRight; @@ -947,22 +1003,33 @@ abstract class PrettyPrinterAbstract * are required to preserve program semantics in a certain context (e.g. to maintain precedence * or because only certain expressions are allowed in certain places). * - * @param int $fixup Fixup type - * @param Node $subNode Subnode to print + * @param int $fixup Fixup type + * @param Node $subNode Subnode to print * @param string|null $parentClass Class of parent node - * @param int $subStartPos Original start pos of subnode - * @param int $subEndPos Original end pos of subnode + * @param int $subStartPos Original start pos of subnode + * @param int $subEndPos Original end pos of subnode * * @return string Result of fixed-up print of subnode */ - protected function pFixup(int $fixup, Node $subNode, $parentClass, int $subStartPos, int $subEndPos) : string { + protected function pFixup(int $fixup, Node $subNode, ?string $parentClass, int $subStartPos, int $subEndPos): string { switch ($fixup) { case self::FIXUP_PREC_LEFT: + // We use a conservative approximation where lhsPrecedence == precedence. + if (!$this->origTokens->haveParens($subStartPos, $subEndPos)) { + $precedence = $this->precedenceMap[$parentClass][1]; + return $this->p($subNode, $precedence, $precedence); + } + break; case self::FIXUP_PREC_RIGHT: if (!$this->origTokens->haveParens($subStartPos, $subEndPos)) { - list($precedence, $associativity) = $this->precedenceMap[$parentClass]; - return $this->pPrec($subNode, $precedence, $associativity, - $fixup === self::FIXUP_PREC_LEFT ? -1 : 1); + $precedence = $this->precedenceMap[$parentClass][2]; + return $this->p($subNode, $precedence, $precedence); + } + break; + case self::FIXUP_PREC_UNARY: + if (!$this->origTokens->haveParens($subStartPos, $subEndPos)) { + $precedence = $this->precedenceMap[$parentClass][0]; + return $this->p($subNode, $precedence, $precedence); } break; case self::FIXUP_CALL_LHS: @@ -1002,7 +1069,7 @@ abstract class PrettyPrinterAbstract } break; case self::FIXUP_ENCAPSED: - if (!$subNode instanceof Scalar\EncapsedStringPart + if (!$subNode instanceof ncc\ThirdParty\nikic\PhpParser\Node\InterpolatedStringPart && !$this->origTokens->haveBraces($subStartPos, $subEndPos) ) { return '{' . $this->p($subNode) . '}'; @@ -1021,11 +1088,8 @@ abstract class PrettyPrinterAbstract * * Example: "echo" and "$x" result in "echo$x", but "echo" and "x" result in "echo x". * Without safeAppend the result would be "echox", which does not preserve semantics. - * - * @param string $str - * @param string $append */ - protected function safeAppend(string &$str, string $append) { + protected function safeAppend(string &$str, string $append): void { if ($str === "") { $str = $append; return; @@ -1050,8 +1114,8 @@ abstract class PrettyPrinterAbstract * * @return bool Whether parentheses are required */ - protected function callLhsRequiresParens(Node $node) : bool { - return !($node instanceof Node\Name + protected function callLhsRequiresParens(Node $node): bool { + return !($node instanceof ncc\ThirdParty\nikic\PhpParser\Node\Name || $node instanceof Expr\Variable || $node instanceof Expr\ArrayDimFetch || $node instanceof Expr\FuncCall @@ -1068,7 +1132,7 @@ abstract class PrettyPrinterAbstract * * @return bool Whether parentheses are required */ - protected function dereferenceLhsRequiresParens(Node $node) : bool { + protected function dereferenceLhsRequiresParens(Node $node): bool { // A constant can occur on the LHS of an array/object deref, but not a static deref. return $this->staticDereferenceLhsRequiresParens($node) && !$node instanceof Expr\ConstFetch; @@ -1083,7 +1147,7 @@ abstract class PrettyPrinterAbstract */ protected function staticDereferenceLhsRequiresParens(Node $node): bool { return !($node instanceof Expr\Variable - || $node instanceof Node\Name + || $node instanceof ncc\ThirdParty\nikic\PhpParser\Node\Name || $node instanceof Expr\ArrayDimFetch || $node instanceof Expr\PropertyFetch || $node instanceof Expr\NullsafePropertyFetch @@ -1105,7 +1169,7 @@ abstract class PrettyPrinterAbstract * @return bool Whether parentheses are required */ protected function newOperandRequiresParens(Node $node): bool { - if ($node instanceof Node\Name || $node instanceof Expr\Variable) { + if ($node instanceof ncc\ThirdParty\nikic\PhpParser\Node\Name || $node instanceof Expr\Variable) { return false; } if ($node instanceof Expr\ArrayDimFetch || $node instanceof Expr\PropertyFetch || @@ -1126,14 +1190,21 @@ abstract class PrettyPrinterAbstract * * @return string Printed modifiers */ - protected function pModifiers(int $modifiers) { - return ($modifiers & Stmt\Class_::MODIFIER_PUBLIC ? 'public ' : '') - . ($modifiers & Stmt\Class_::MODIFIER_PROTECTED ? 'protected ' : '') - . ($modifiers & Stmt\Class_::MODIFIER_PRIVATE ? 'private ' : '') - . ($modifiers & Stmt\Class_::MODIFIER_STATIC ? 'static ' : '') - . ($modifiers & Stmt\Class_::MODIFIER_ABSTRACT ? 'abstract ' : '') - . ($modifiers & Stmt\Class_::MODIFIER_FINAL ? 'final ' : '') - . ($modifiers & Stmt\Class_::MODIFIER_READONLY ? 'readonly ' : ''); + protected function pModifiers(int $modifiers): string { + return ($modifiers & Modifiers::FINAL ? 'final ' : '') + . ($modifiers & Modifiers::ABSTRACT ? 'abstract ' : '') + . ($modifiers & Modifiers::PUBLIC ? 'public ' : '') + . ($modifiers & Modifiers::PROTECTED ? 'protected ' : '') + . ($modifiers & Modifiers::PRIVATE ? 'private ' : '') + . ($modifiers & Modifiers::PUBLIC_SET ? 'public(set) ' : '') + . ($modifiers & Modifiers::PROTECTED_SET ? 'protected(set) ' : '') + . ($modifiers & Modifiers::PRIVATE_SET ? 'private(set) ' : '') + . ($modifiers & Modifiers::STATIC ? 'static ' : '') + . ($modifiers & Modifiers::READONLY ? 'readonly ' : ''); + } + + protected function pStatic(bool $static): string { + return $static ? 'static ' : ''; } /** @@ -1143,7 +1214,7 @@ abstract class PrettyPrinterAbstract * * @return bool Whether multiline formatting is used */ - protected function isMultiline(array $nodes) : bool { + protected function isMultiline(array $nodes): bool { if (\count($nodes) < 2) { return false; } @@ -1175,15 +1246,19 @@ abstract class PrettyPrinterAbstract * * The label char map determines whether a certain character may occur in a label. */ - protected function initializeLabelCharMap() { - if ($this->labelCharMap) return; + protected function initializeLabelCharMap(): void { + if (isset($this->labelCharMap)) { + return; + } $this->labelCharMap = []; for ($i = 0; $i < 256; $i++) { - // Since PHP 7.1 The lower range is 0x80. However, we also want to support code for - // older versions. $chr = chr($i); - $this->labelCharMap[$chr] = $i >= 0x7f || ctype_alnum($chr); + $this->labelCharMap[$chr] = $i >= 0x80 || ctype_alnum($chr); + } + + if ($this->phpVersion->allowsDelInIdentifiers()) { + $this->labelCharMap["\x7f"] = true; } } @@ -1192,10 +1267,12 @@ abstract class PrettyPrinterAbstract * * The node list differ is used to determine differences between two array subnodes. */ - protected function initializeNodeListDiffer() { - if ($this->nodeListDiffer) return; + protected function initializeNodeListDiffer(): void { + if (isset($this->nodeListDiffer)) { + return; + } - $this->nodeListDiffer = new Internal\Differ(function ($a, $b) { + $this->nodeListDiffer = new ncc\ThirdParty\nikic\PhpParser\Internal\Differ(function ($a, $b) { if ($a instanceof Node && $b instanceof Node) { return $a === $b->getAttribute('origNode'); } @@ -1210,22 +1287,21 @@ abstract class PrettyPrinterAbstract * The fixup map is used to determine whether a certain subnode of a certain node may require * some kind of "fixup" operation, e.g. the addition of parenthesis or braces. */ - protected function initializeFixupMap() { - if ($this->fixupMap) return; + protected function initializeFixupMap(): void { + if (isset($this->fixupMap)) { + return; + } $this->fixupMap = [ - Expr\PreInc::class => ['var' => self::FIXUP_PREC_RIGHT], - Expr\PreDec::class => ['var' => self::FIXUP_PREC_RIGHT], - Expr\PostInc::class => ['var' => self::FIXUP_PREC_LEFT], - Expr\PostDec::class => ['var' => self::FIXUP_PREC_LEFT], Expr\Instanceof_::class => [ - 'expr' => self::FIXUP_PREC_LEFT, + 'expr' => self::FIXUP_PREC_UNARY, 'class' => self::FIXUP_NEW, ], Expr\Ternary::class => [ 'cond' => self::FIXUP_PREC_LEFT, 'else' => self::FIXUP_PREC_RIGHT, ], + Expr\Yield_::class => ['value' => self::FIXUP_PREC_UNARY], Expr\FuncCall::class => ['name' => self::FIXUP_CALL_LHS], Expr\StaticCall::class => ['class' => self::FIXUP_STATIC_DEREF_LHS], @@ -1255,7 +1331,7 @@ abstract class PrettyPrinterAbstract 'var' => self::FIXUP_DEREF_LHS, 'name' => self::FIXUP_BRACED_NAME, ], - Scalar\Encapsed::class => [ + Scalar\InterpolatedString::class => [ 'parts' => self::FIXUP_ENCAPSED, ], ]; @@ -1278,27 +1354,19 @@ abstract class PrettyPrinterAbstract ]; } - $assignOps = [ - Expr\Assign::class, Expr\AssignRef::class, AssignOp\Plus::class, AssignOp\Minus::class, - AssignOp\Mul::class, AssignOp\Div::class, AssignOp\Concat::class, AssignOp\Mod::class, - AssignOp\BitwiseAnd::class, AssignOp\BitwiseOr::class, AssignOp\BitwiseXor::class, - AssignOp\ShiftLeft::class, AssignOp\ShiftRight::class, AssignOp\Pow::class, AssignOp\Coalesce::class - ]; - foreach ($assignOps as $assignOp) { - $this->fixupMap[$assignOp] = [ - 'var' => self::FIXUP_PREC_LEFT, - 'expr' => self::FIXUP_PREC_RIGHT, - ]; - } - $prefixOps = [ - Expr\BitwiseNot::class, Expr\BooleanNot::class, Expr\UnaryPlus::class, Expr\UnaryMinus::class, + Expr\Clone_::class, Expr\BitwiseNot::class, Expr\BooleanNot::class, Expr\UnaryPlus::class, Expr\UnaryMinus::class, Cast\Int_::class, Cast\Double::class, Cast\String_::class, Cast\Array_::class, Cast\Object_::class, Cast\Bool_::class, Cast\Unset_::class, Expr\ErrorSuppress::class, Expr\YieldFrom::class, Expr\Print_::class, Expr\Include_::class, + Expr\Assign::class, Expr\AssignRef::class, AssignOp\Plus::class, AssignOp\Minus::class, + AssignOp\Mul::class, AssignOp\Div::class, AssignOp\Concat::class, AssignOp\Mod::class, + AssignOp\BitwiseAnd::class, AssignOp\BitwiseOr::class, AssignOp\BitwiseXor::class, + AssignOp\ShiftLeft::class, AssignOp\ShiftRight::class, AssignOp\Pow::class, AssignOp\Coalesce::class, + Expr\ArrowFunction::class, Expr\Throw_::class, ]; foreach ($prefixOps as $prefixOp) { - $this->fixupMap[$prefixOp] = ['expr' => self::FIXUP_PREC_RIGHT]; + $this->fixupMap[$prefixOp] = ['expr' => self::FIXUP_PREC_UNARY]; } } @@ -1308,8 +1376,10 @@ abstract class PrettyPrinterAbstract * The removal map is used to determine which additional tokens should be removed when a * certain node is replaced by null. */ - protected function initializeRemovalMap() { - if ($this->removalMap) return; + protected function initializeRemovalMap(): void { + if (isset($this->removalMap)) { + return; + } $stripBoth = ['left' => \T_WHITESPACE, 'right' => \T_WHITESPACE]; $stripLeft = ['left' => \T_WHITESPACE]; @@ -1319,7 +1389,7 @@ abstract class PrettyPrinterAbstract $stripEquals = ['left' => '=']; $this->removalMap = [ 'Expr_ArrayDimFetch->dim' => $stripBoth, - 'Expr_ArrayItem->key' => $stripDoubleArrow, + 'ArrayItem->key' => $stripDoubleArrow, 'Expr_ArrowFunction->returnType' => $stripColon, 'Expr_Closure->returnType' => $stripColon, 'Expr_Exit->expr' => $stripBoth, @@ -1342,7 +1412,7 @@ abstract class PrettyPrinterAbstract 'Stmt_If->else' => $stripLeft, 'Stmt_Namespace->name' => $stripLeft, 'Stmt_Property->type' => $stripRight, - 'Stmt_PropertyProperty->default' => $stripEquals, + 'PropertyItem->default' => $stripEquals, 'Stmt_Return->expr' => $stripBoth, 'Stmt_StaticVar->default' => $stripEquals, 'Stmt_TraitUseAdaptation_Alias->newName' => $stripLeft, @@ -1354,16 +1424,18 @@ abstract class PrettyPrinterAbstract ]; } - protected function initializeInsertionMap() { - if ($this->insertionMap) return; + protected function initializeInsertionMap(): void { + if (isset($this->insertionMap)) { + return; + } // TODO: "yield" where both key and value are inserted doesn't work // [$find, $beforeToken, $extraLeft, $extraRight] $this->insertionMap = [ 'Expr_ArrayDimFetch->dim' => ['[', false, null, null], - 'Expr_ArrayItem->key' => [null, false, null, ' => '], - 'Expr_ArrowFunction->returnType' => [')', false, ' : ', null], - 'Expr_Closure->returnType' => [')', false, ' : ', null], + 'ArrayItem->key' => [null, false, null, ' => '], + 'Expr_ArrowFunction->returnType' => [')', false, ': ', null], + 'Expr_Closure->returnType' => [')', false, ': ', null], 'Expr_Ternary->if' => ['?', false, ' ', ' '], 'Expr_Yield->key' => [\T_YIELD, false, null, ' => '], 'Expr_Yield->value' => [\T_YIELD, false, ' ', null], @@ -1371,19 +1443,19 @@ abstract class PrettyPrinterAbstract 'Param->default' => [null, false, ' = ', null], 'Stmt_Break->num' => [\T_BREAK, false, ' ', null], 'Stmt_Catch->var' => [null, false, ' ', null], - 'Stmt_ClassMethod->returnType' => [')', false, ' : ', null], + 'Stmt_ClassMethod->returnType' => [')', false, ': ', null], 'Stmt_ClassConst->type' => [\T_CONST, false, ' ', null], 'Stmt_Class->extends' => [null, false, ' extends ', null], 'Stmt_Enum->scalarType' => [null, false, ' : ', null], 'Stmt_EnumCase->expr' => [null, false, ' = ', null], - 'Expr_PrintableNewAnonClass->extends' => [null, ' extends ', null], + 'Expr_PrintableNewAnonClass->extends' => [null, false, ' extends ', null], 'Stmt_Continue->num' => [\T_CONTINUE, false, ' ', null], 'Stmt_Foreach->keyVar' => [\T_AS, false, null, ' => '], - 'Stmt_Function->returnType' => [')', false, ' : ', null], + 'Stmt_Function->returnType' => [')', false, ': ', null], 'Stmt_If->else' => [null, false, ' ', null], 'Stmt_Namespace->name' => [\T_NAMESPACE, false, ' ', null], 'Stmt_Property->type' => [\T_VARIABLE, true, null, ' '], - 'Stmt_PropertyProperty->default' => [null, false, ' = ', null], + 'PropertyItem->default' => [null, false, ' = ', null], 'Stmt_Return->expr' => [\T_RETURN, false, ' ', null], 'Stmt_StaticVar->default' => [null, false, ' = ', null], //'Stmt_TraitUseAdaptation_Alias->newName' => [T_AS, false, ' ', null], // TODO @@ -1397,132 +1469,145 @@ abstract class PrettyPrinterAbstract ]; } - protected function initializeListInsertionMap() { - if ($this->listInsertionMap) return; + protected function initializeListInsertionMap(): void { + if (isset($this->listInsertionMap)) { + return; + } $this->listInsertionMap = [ // special //'Expr_ShellExec->parts' => '', // TODO These need to be treated more carefully - //'Scalar_Encapsed->parts' => '', - 'Stmt_Catch->types' => '|', - 'UnionType->types' => '|', - 'IntersectionType->types' => '&', - 'Stmt_If->elseifs' => ' ', - 'Stmt_TryCatch->catches' => ' ', + //'Scalar_InterpolatedString->parts' => '', + Stmt\Catch_::class . '->types' => '|', + UnionType::class . '->types' => '|', + IntersectionType::class . '->types' => '&', + Stmt\If_::class . '->elseifs' => ' ', + Stmt\TryCatch::class . '->catches' => ' ', // comma-separated lists - 'Expr_Array->items' => ', ', - 'Expr_ArrowFunction->params' => ', ', - 'Expr_Closure->params' => ', ', - 'Expr_Closure->uses' => ', ', - 'Expr_FuncCall->args' => ', ', - 'Expr_Isset->vars' => ', ', - 'Expr_List->items' => ', ', - 'Expr_MethodCall->args' => ', ', - 'Expr_NullsafeMethodCall->args' => ', ', - 'Expr_New->args' => ', ', - 'Expr_PrintableNewAnonClass->args' => ', ', - 'Expr_StaticCall->args' => ', ', - 'Stmt_ClassConst->consts' => ', ', - 'Stmt_ClassMethod->params' => ', ', - 'Stmt_Class->implements' => ', ', - 'Stmt_Enum->implements' => ', ', - 'Expr_PrintableNewAnonClass->implements' => ', ', - 'Stmt_Const->consts' => ', ', - 'Stmt_Declare->declares' => ', ', - 'Stmt_Echo->exprs' => ', ', - 'Stmt_For->init' => ', ', - 'Stmt_For->cond' => ', ', - 'Stmt_For->loop' => ', ', - 'Stmt_Function->params' => ', ', - 'Stmt_Global->vars' => ', ', - 'Stmt_GroupUse->uses' => ', ', - 'Stmt_Interface->extends' => ', ', - 'Stmt_Match->arms' => ', ', - 'Stmt_Property->props' => ', ', - 'Stmt_StaticVar->vars' => ', ', - 'Stmt_TraitUse->traits' => ', ', - 'Stmt_TraitUseAdaptation_Precedence->insteadof' => ', ', - 'Stmt_Unset->vars' => ', ', - 'Stmt_Use->uses' => ', ', - 'MatchArm->conds' => ', ', - 'AttributeGroup->attrs' => ', ', + Expr\Array_::class . '->items' => ', ', + Expr\ArrowFunction::class . '->params' => ', ', + Expr\Closure::class . '->params' => ', ', + Expr\Closure::class . '->uses' => ', ', + Expr\FuncCall::class . '->args' => ', ', + Expr\Isset_::class . '->vars' => ', ', + Expr\List_::class . '->items' => ', ', + Expr\MethodCall::class . '->args' => ', ', + Expr\NullsafeMethodCall::class . '->args' => ', ', + Expr\New_::class . '->args' => ', ', + PrintableNewAnonClassNode::class . '->args' => ', ', + Expr\StaticCall::class . '->args' => ', ', + Stmt\ClassConst::class . '->consts' => ', ', + Stmt\ClassMethod::class . '->params' => ', ', + Stmt\Class_::class . '->implements' => ', ', + Stmt\Enum_::class . '->implements' => ', ', + PrintableNewAnonClassNode::class . '->implements' => ', ', + Stmt\Const_::class . '->consts' => ', ', + Stmt\Declare_::class . '->declares' => ', ', + Stmt\Echo_::class . '->exprs' => ', ', + Stmt\For_::class . '->init' => ', ', + Stmt\For_::class . '->cond' => ', ', + Stmt\For_::class . '->loop' => ', ', + Stmt\Function_::class . '->params' => ', ', + Stmt\Global_::class . '->vars' => ', ', + Stmt\GroupUse::class . '->uses' => ', ', + Stmt\Interface_::class . '->extends' => ', ', + Expr\Match_::class . '->arms' => ', ', + Stmt\Property::class . '->props' => ', ', + Stmt\StaticVar::class . '->vars' => ', ', + Stmt\TraitUse::class . '->traits' => ', ', + \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Precedence::class . '->insteadof' => ', ', + Stmt\Unset_::class . '->vars' => ', ', + Stmt\UseUse::class . '->uses' => ', ', + MatchArm::class . '->conds' => ', ', + AttributeGroup::class . '->attrs' => ', ', + PropertyHook::class . '->params' => ', ', // statement lists - 'Expr_Closure->stmts' => "\n", - 'Stmt_Case->stmts' => "\n", - 'Stmt_Catch->stmts' => "\n", - 'Stmt_Class->stmts' => "\n", - 'Stmt_Enum->stmts' => "\n", - 'Expr_PrintableNewAnonClass->stmts' => "\n", - 'Stmt_Interface->stmts' => "\n", - 'Stmt_Trait->stmts' => "\n", - 'Stmt_ClassMethod->stmts' => "\n", - 'Stmt_Declare->stmts' => "\n", - 'Stmt_Do->stmts' => "\n", - 'Stmt_ElseIf->stmts' => "\n", - 'Stmt_Else->stmts' => "\n", - 'Stmt_Finally->stmts' => "\n", - 'Stmt_Foreach->stmts' => "\n", - 'Stmt_For->stmts' => "\n", - 'Stmt_Function->stmts' => "\n", - 'Stmt_If->stmts' => "\n", - 'Stmt_Namespace->stmts' => "\n", - 'Stmt_Class->attrGroups' => "\n", - 'Stmt_Enum->attrGroups' => "\n", - 'Stmt_EnumCase->attrGroups' => "\n", - 'Stmt_Interface->attrGroups' => "\n", - 'Stmt_Trait->attrGroups' => "\n", - 'Stmt_Function->attrGroups' => "\n", - 'Stmt_ClassMethod->attrGroups' => "\n", - 'Stmt_ClassConst->attrGroups' => "\n", - 'Stmt_Property->attrGroups' => "\n", - 'Expr_PrintableNewAnonClass->attrGroups' => ' ', - 'Expr_Closure->attrGroups' => ' ', - 'Expr_ArrowFunction->attrGroups' => ' ', - 'Param->attrGroups' => ' ', - 'Stmt_Switch->cases' => "\n", - 'Stmt_TraitUse->adaptations' => "\n", - 'Stmt_TryCatch->stmts' => "\n", - 'Stmt_While->stmts' => "\n", + Expr\Closure::class . '->stmts' => "\n", + Stmt\Case_::class . '->stmts' => "\n", + Stmt\Catch_::class . '->stmts' => "\n", + Stmt\Class_::class . '->stmts' => "\n", + Stmt\Enum_::class . '->stmts' => "\n", + PrintableNewAnonClassNode::class . '->stmts' => "\n", + Stmt\Interface_::class . '->stmts' => "\n", + Stmt\Trait_::class . '->stmts' => "\n", + Stmt\ClassMethod::class . '->stmts' => "\n", + Stmt\Declare_::class . '->stmts' => "\n", + Stmt\Do_::class . '->stmts' => "\n", + Stmt\ElseIf_::class . '->stmts' => "\n", + Stmt\Else_::class . '->stmts' => "\n", + Stmt\Finally_::class . '->stmts' => "\n", + Stmt\Foreach_::class . '->stmts' => "\n", + Stmt\For_::class . '->stmts' => "\n", + Stmt\Function_::class . '->stmts' => "\n", + Stmt\If_::class . '->stmts' => "\n", + Stmt\Namespace_::class . '->stmts' => "\n", + Stmt\Block::class . '->stmts' => "\n", + + // Attribute groups + Stmt\Class_::class . '->attrGroups' => "\n", + Stmt\Enum_::class . '->attrGroups' => "\n", + Stmt\EnumCase::class . '->attrGroups' => "\n", + Stmt\Interface_::class . '->attrGroups' => "\n", + Stmt\Trait_::class . '->attrGroups' => "\n", + Stmt\Function_::class . '->attrGroups' => "\n", + Stmt\ClassMethod::class . '->attrGroups' => "\n", + Stmt\ClassConst::class . '->attrGroups' => "\n", + Stmt\Property::class . '->attrGroups' => "\n", + PrintableNewAnonClassNode::class . '->attrGroups' => ' ', + Expr\Closure::class . '->attrGroups' => ' ', + Expr\ArrowFunction::class . '->attrGroups' => ' ', + Param::class . '->attrGroups' => ' ', + PropertyHook::class . '->attrGroups' => ' ', + + Stmt\Switch_::class . '->cases' => "\n", + Stmt\TraitUse::class . '->adaptations' => "\n", + Stmt\TryCatch::class . '->stmts' => "\n", + Stmt\While_::class . '->stmts' => "\n", + PropertyHook::class . '->body' => "\n", + Stmt\Property::class . '->hooks' => "\n", + Param::class . '->hooks' => "\n", // dummy for top-level context 'File->stmts' => "\n", ]; } - protected function initializeEmptyListInsertionMap() { - if ($this->emptyListInsertionMap) return; + protected function initializeEmptyListInsertionMap(): void { + if (isset($this->emptyListInsertionMap)) { + return; + } // TODO Insertion into empty statement lists. // [$find, $extraLeft, $extraRight] $this->emptyListInsertionMap = [ - 'Expr_ArrowFunction->params' => ['(', '', ''], - 'Expr_Closure->uses' => [')', ' use(', ')'], - 'Expr_Closure->params' => ['(', '', ''], - 'Expr_FuncCall->args' => ['(', '', ''], - 'Expr_MethodCall->args' => ['(', '', ''], - 'Expr_NullsafeMethodCall->args' => ['(', '', ''], - 'Expr_New->args' => ['(', '', ''], - 'Expr_PrintableNewAnonClass->args' => ['(', '', ''], - 'Expr_PrintableNewAnonClass->implements' => [null, ' implements ', ''], - 'Expr_StaticCall->args' => ['(', '', ''], - 'Stmt_Class->implements' => [null, ' implements ', ''], - 'Stmt_Enum->implements' => [null, ' implements ', ''], - 'Stmt_ClassMethod->params' => ['(', '', ''], - 'Stmt_Interface->extends' => [null, ' extends ', ''], - 'Stmt_Function->params' => ['(', '', ''], - 'Stmt_Interface->attrGroups' => [null, '', "\n"], - 'Stmt_Class->attrGroups' => [null, '', "\n"], - 'Stmt_ClassConst->attrGroups' => [null, '', "\n"], - 'Stmt_ClassMethod->attrGroups' => [null, '', "\n"], - 'Stmt_Function->attrGroups' => [null, '', "\n"], - 'Stmt_Property->attrGroups' => [null, '', "\n"], - 'Stmt_Trait->attrGroups' => [null, '', "\n"], - 'Expr_ArrowFunction->attrGroups' => [null, '', ' '], - 'Expr_Closure->attrGroups' => [null, '', ' '], - 'Expr_PrintableNewAnonClass->attrGroups' => [\T_NEW, ' ', ''], + Expr\ArrowFunction::class . '->params' => ['(', '', ''], + Expr\Closure::class . '->uses' => [')', ' use (', ')'], + Expr\Closure::class . '->params' => ['(', '', ''], + Expr\FuncCall::class . '->args' => ['(', '', ''], + Expr\MethodCall::class . '->args' => ['(', '', ''], + Expr\NullsafeMethodCall::class . '->args' => ['(', '', ''], + Expr\New_::class . '->args' => ['(', '', ''], + PrintableNewAnonClassNode::class . '->args' => ['(', '', ''], + PrintableNewAnonClassNode::class . '->implements' => [null, ' implements ', ''], + Expr\StaticCall::class . '->args' => ['(', '', ''], + Stmt\Class_::class . '->implements' => [null, ' implements ', ''], + Stmt\Enum_::class . '->implements' => [null, ' implements ', ''], + Stmt\ClassMethod::class . '->params' => ['(', '', ''], + Stmt\Interface_::class . '->extends' => [null, ' extends ', ''], + Stmt\Function_::class . '->params' => ['(', '', ''], + Stmt\Interface_::class . '->attrGroups' => [null, '', "\n"], + Stmt\Class_::class . '->attrGroups' => [null, '', "\n"], + Stmt\ClassConst::class . '->attrGroups' => [null, '', "\n"], + Stmt\ClassMethod::class . '->attrGroups' => [null, '', "\n"], + Stmt\Function_::class . '->attrGroups' => [null, '', "\n"], + Stmt\Property::class . '->attrGroups' => [null, '', "\n"], + Stmt\Trait_::class . '->attrGroups' => [null, '', "\n"], + Expr\ArrowFunction::class . '->attrGroups' => [null, '', ' '], + Expr\Closure::class . '->attrGroups' => [null, '', ' '], + PrintableNewAnonClassNode::class . '->attrGroups' => [\T_NEW, ' ', ''], /* These cannot be empty to start with: * Expr_Isset->vars @@ -1554,23 +1639,28 @@ abstract class PrettyPrinterAbstract ]; } - protected function initializeModifierChangeMap() { - if ($this->modifierChangeMap) return; + protected function initializeModifierChangeMap(): void { + if (isset($this->modifierChangeMap)) { + return; + } $this->modifierChangeMap = [ - 'Stmt_ClassConst->flags' => \T_CONST, - 'Stmt_ClassMethod->flags' => \T_FUNCTION, - 'Stmt_Class->flags' => \T_CLASS, - 'Stmt_Property->flags' => \T_VARIABLE, - 'Expr_PrintableNewAnonClass->flags' => \T_CLASS, - 'Param->flags' => \T_VARIABLE, - //'Stmt_TraitUseAdaptation_Alias->newModifier' => 0, // TODO + Stmt\ClassConst::class . '->flags' => ['pModifiers', \T_CONST], + Stmt\ClassMethod::class . '->flags' => ['pModifiers', \T_FUNCTION], + Stmt\Class_::class . '->flags' => ['pModifiers', \T_CLASS], + Stmt\Property::class . '->flags' => ['pModifiers', \T_VARIABLE], + PrintableNewAnonClassNode::class . '->flags' => ['pModifiers', \T_CLASS], + Param::class . '->flags' => ['pModifiers', \T_VARIABLE], + PropertyHook::class . '->flags' => ['pModifiers', \T_STRING], + Expr\Closure::class . '->static' => ['pStatic', \T_FUNCTION], + Expr\ArrowFunction::class . '->static' => ['pStatic', \T_FN], + //Stmt\TraitUseAdaptation\Alias::class . '->newModifier' => 0, // TODO ]; // List of integer subnodes that are not modifiers: // Expr_Include->type // Stmt_GroupUse->type // Stmt_Use->type - // Stmt_UseUse->type + // UseItem->type } } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/README.md b/src/ncc/ThirdParty/nikic/PhpParser/README.md index ac3c15e..fc10db7 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/README.md +++ b/src/ncc/ThirdParty/nikic/PhpParser/README.md @@ -3,24 +3,24 @@ PHP Parser [![Coverage Status](https://coveralls.io/repos/github/nikic/PHP-Parser/badge.svg?branch=master)](https://coveralls.io/github/nikic/PHP-Parser?branch=master) -This is a PHP 5.2 to PHP 8.2 parser written in PHP. Its purpose is to simplify static code analysis and +This is a PHP parser written in PHP. Its purpose is to simplify static code analysis and manipulation. -[**Documentation for version 4.x**][doc_4_x] (stable; for running on PHP >= 7.0; for parsing PHP 5.2 to PHP 8.2). +[**Documentation for version 5.x**][doc_master] (current; for running on PHP >= 7.4; for parsing PHP 7.0 to PHP 8.4, with limited support for parsing PHP 5.x). -[Documentation for version 3.x][doc_3_x] (unsupported; for running on PHP >= 5.5; for parsing PHP 5.2 to PHP 7.2). +[Documentation for version 4.x][doc_4_x] (supported; for running on PHP >= 7.0; for parsing PHP 5.2 to PHP 8.3). Features -------- The main features provided by this library are: - * Parsing PHP 5, PHP 7, and PHP 8 code into an abstract syntax tree (AST). + * Parsing PHP 7, and PHP 8 code into an abstract syntax tree (AST). * Invalid code can be parsed into a partial AST. * The AST contains accurate location information. * Dumping the AST in human-readable form. * Converting an AST back to PHP code. - * Experimental: Formatting can be preserved for partially changed ASTs. + * Formatting can be preserved for partially changed ASTs. * Infrastructure to traverse and modify ASTs. * Resolution of namespaced names. * Evaluation of constant expressions. @@ -51,7 +51,7 @@ function test($foo) } CODE; -$parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7); +$parser = (new ParserFactory())->createForNewestSupportedVersion(); try { $ast = $parser->parse($code); } catch (Error $error) { @@ -68,12 +68,17 @@ This dumps an AST looking something like this: ``` array( 0: Stmt_Function( + attrGroups: array( + ) byRef: false name: Identifier( name: test ) params: array( 0: Param( + attrGroups: array( + ) + flags: 0 type: null byRef: false variadic: false @@ -88,12 +93,11 @@ array( 0: Stmt_Expression( expr: Expr_FuncCall( name: Name( - parts: array( - 0: var_dump - ) + name: var_dump ) args: array( 0: Arg( + name: null value: Expr_Variable( name: foo ) @@ -135,12 +139,16 @@ This gives us an AST where the `Function_::$stmts` are empty: ``` array( 0: Stmt_Function( + attrGroups: array( + ) byRef: false name: Identifier( name: test ) params: array( 0: Param( + attrGroups: array( + ) type: null byRef: false variadic: false @@ -203,9 +211,8 @@ Component documentation: * [AST builders](doc/component/AST_builders.markdown) * Fluent builders for AST nodes * [Lexer](doc/component/Lexer.markdown) - * Lexer options - * Token and file positions for nodes - * Custom attributes + * Emulation + * Tokens, positions and attributes * [Error handling](doc/component/Error_handling.markdown) * Column information for errors * Error recovery (parsing of syntactically incorrect code) @@ -223,3 +230,4 @@ Component documentation: [doc_3_x]: https://github.com/nikic/PHP-Parser/tree/3.x/doc [doc_4_x]: https://github.com/nikic/PHP-Parser/tree/4.x/doc + [doc_master]: https://github.com/nikic/PHP-Parser/tree/master/doc diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Token.php b/src/ncc/ThirdParty/nikic/PhpParser/Token.php new file mode 100644 index 0000000..bab630d --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/Token.php @@ -0,0 +1,18 @@ +pos + \strlen($this->text); + } + + /** Get 1-based end line number of the token. */ + public function getEndLine(): int { + return $this->line + \substr_count($this->text, "\n"); + } +} diff --git a/src/ncc/ThirdParty/nikic/PhpParser/VERSION b/src/ncc/ThirdParty/nikic/PhpParser/VERSION index 331b258..7cbea07 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/VERSION +++ b/src/ncc/ThirdParty/nikic/PhpParser/VERSION @@ -1 +1 @@ -4.17.1 \ No newline at end of file +5.2.0 \ No newline at end of file diff --git a/src/ncc/ThirdParty/nikic/PhpParser/compatibility_tokens.php b/src/ncc/ThirdParty/nikic/PhpParser/compatibility_tokens.php new file mode 100644 index 0000000..13576c4 --- /dev/null +++ b/src/ncc/ThirdParty/nikic/PhpParser/compatibility_tokens.php @@ -0,0 +1,68 @@ + Date: Fri, 20 Sep 2024 16:00:53 -0400 Subject: [PATCH 108/134] Bug fixes with Php-Parser --- src/ncc/Classes/PhpExtension/AstWalker.php | 178 ------------------ src/ncc/Classes/PhpExtension/NccCompiler.php | 10 +- src/ncc/Classes/PhpExtension/Serializer.php | 151 +++++++++++++++ src/ncc/Classes/Runtime.php | 2 +- src/ncc/Objects/Package/Component.php | 15 +- .../nikic/PhpParser/Builder/ClassConst.php | 8 +- .../nikic/PhpParser/Builder/Class_.php | 6 +- .../nikic/PhpParser/Builder/Declaration.php | 4 +- .../nikic/PhpParser/Builder/EnumCase.php | 6 +- .../nikic/PhpParser/Builder/Enum_.php | 8 +- .../nikic/PhpParser/Builder/Function_.php | 4 +- .../nikic/PhpParser/Builder/Interface_.php | 6 +- .../nikic/PhpParser/Builder/Method.php | 4 +- .../nikic/PhpParser/Builder/Namespace_.php | 4 +- .../nikic/PhpParser/Builder/Param.php | 2 +- .../nikic/PhpParser/Builder/Property.php | 10 +- .../PhpParser/Builder/TraitUseAdaptation.php | 4 +- .../nikic/PhpParser/Builder/Trait_.php | 4 +- .../nikic/PhpParser/BuilderFactory.php | 116 ++++++------ .../nikic/PhpParser/BuilderHelpers.php | 20 +- .../PhpParser/Internal/TokenPolyfill.php | 3 +- .../nikic/PhpParser/NodeTraverser.php | 4 +- .../PhpParser/NodeVisitor/NameResolver.php | 2 +- src/ncc/ThirdParty/nikic/PhpParser/Parser.php | 2 +- .../nikic/PhpParser/Parser/Php7.php | 10 +- .../nikic/PhpParser/Parser/Php8.php | 10 +- .../nikic/PhpParser/ParserAbstract.php | 42 ++--- .../PhpParser/PrettyPrinter/Standard.php | 4 +- .../nikic/PhpParser/PrettyPrinterAbstract.php | 14 +- src/ncc/ThirdParty/nikic/PhpParser/Token.php | 2 +- 30 files changed, 316 insertions(+), 339 deletions(-) create mode 100644 src/ncc/Classes/PhpExtension/Serializer.php diff --git a/src/ncc/Classes/PhpExtension/AstWalker.php b/src/ncc/Classes/PhpExtension/AstWalker.php index 8e2f890..282c3d1 100644 --- a/src/ncc/Classes/PhpExtension/AstWalker.php +++ b/src/ncc/Classes/PhpExtension/AstWalker.php @@ -31,27 +31,6 @@ class AstWalker { - /** - * Returns an array representation of the node recursively - * - * @param array|Node $node - * @return array - */ - public static function serialize(array|Node $node): array - { - if(is_array($node)) - { - $serialized = []; - foreach($node as $sub_node) - { - $serialized[] = $sub_node->jsonSerialize(); - } - return $serialized; - } - - return $node->jsonSerialize(); - } - /** * Returns an array of classes associated with the node recursively * @@ -112,161 +91,4 @@ return $classes; } - - /** - * Reconstructs nodes from an array representation recursively - * - * @param $value - * @return array|Comment|Node - * @noinspection PhpMissingReturnTypeInspection - * @throws ReflectionException - */ - public static function decodeRecursive($value) - { - if (is_array($value)) - { - if (isset($value['nodeType'])) - { - if ($value['nodeType'] === 'Comment' || $value['nodeType'] === 'Comment_Doc') - { - return self::decodeComment($value); - } - - return self::decodeNode($value); - } - - return self::decodeArray($value); - } - - return $value; - } - - /** - * Decodes an array by recursively decoding each value - * - * @param array $array - * @return array - * @throws ReflectionException - */ - private static function decodeArray(array $array) : array - { - $decoded_array = []; - - foreach ($array as $key => $value) - { - $decoded_array[$key] = self::decodeRecursive($value); - } - - return $decoded_array; - } - - /** - * Returns the node from the node type - * - * @param array $value - * @return Node - * @throws ReflectionException - */ - private static function decodeNode(array $value) : Node - { - $node_type = $value['nodeType']; - if (!is_string($node_type)) - { - throw new RuntimeException('Node type must be a string'); - } - - /** @var Node $node */ - $node = self::reflectionClassFromNodeType($node_type)->newInstanceWithoutConstructor(); - - if (isset($value['attributes'])) { - if (!is_array($value['attributes'])) - { - throw new RuntimeException('Attributes must be an array'); - } - - $node->setAttributes(self::decodeArray($value['attributes'])); - } - - foreach ($value as $name => $sub_node) { - if ($name === 'nodeType' || $name === 'attributes') - { - continue; - } - - $node->$name = self::decodeRecursive($sub_node); - } - - return $node; - } - - /** - * Returns the comment from the node type - * - * @param array $value - * @return Comment - */ - private static function decodeComment(array $value): Comment - { - $class_name = $value['nodeType'] === 'Comment' ? Comment::class : Comment\Doc::class; - if (!isset($value['text'])) - { - throw new RuntimeException('Comment must have text'); - } - - return new $class_name( - $value['text'], - $value['line'] ?? -1, $value['filePos'] ?? -1, $value['tokenPos'] ?? -1, - $value['endLine'] ?? -1, $value['endFilePos'] ?? -1, $value['endTokenPos'] ?? -1 - ); - } - - /** - * Returns the reflection class from the node type - * - * @param string $node_type - * @return ReflectionClass - * @throws ReflectionException - */ - private static function reflectionClassFromNodeType(string $node_type): ReflectionClass - { - return new ReflectionClass(self::classNameFromNodeType($node_type)); - } - - /** - * Returns the class name from the node type - * - * @param string $nodeType - * @return string - */ - private static function classNameFromNodeType(string $nodeType): string - { - $class_name = 'ncc\\ThirdParty\\nikic\\PhpParser\\Node\\' . str_replace('_', '\\', $nodeType); - if (class_exists($class_name)) - { - return $class_name; - } - - $class_name .= '_'; - if (class_exists($class_name)) - { - return $class_name; - } - - throw new RuntimeException("Unknown node type \"$nodeType\""); - } - - /** - * Transforms include, include_once, require and require_once statements into function calls. - * - * @param Node|array $stmts The AST node or array of nodes to transform. - * @param string|null $package Optionally. The package name to pass to the transformed function calls. - * @return Node|array The transformed AST node or array of nodes. - */ - public static function transformRequireCalls(Node|array $stmts, ?string $package=null): Node|array - { - $traverser = new NodeTraverser(); - $traverser->addVisitor(new ExpressionTraverser($package)); - - return $traverser->traverse($stmts); - } } \ No newline at end of file diff --git a/src/ncc/Classes/PhpExtension/NccCompiler.php b/src/ncc/Classes/PhpExtension/NccCompiler.php index 0101dd9..603cbed 100644 --- a/src/ncc/Classes/PhpExtension/NccCompiler.php +++ b/src/ncc/Classes/PhpExtension/NccCompiler.php @@ -30,7 +30,9 @@ use ncc\Exceptions\PathNotFoundException; use ncc\Extensions\ZiProto\ZiProto; use ncc\Objects\Package\Component; + use ncc\ThirdParty\nikic\PhpParser\NodeDumper; use ncc\ThirdParty\nikic\PhpParser\ParserFactory; + use ncc\ThirdParty\nikic\PhpParser\PhpVersion; use ncc\Utilities\Base64; use ncc\Utilities\Console; use ncc\Utilities\Functions; @@ -52,12 +54,8 @@ try { - $stmts = (new ParserFactory())->create(ParserFactory::PREFER_PHP7)->parse(IO::fread($file_path)); - $stmts = AstWalker::transformRequireCalls( - $stmts, $this->getProjectManager()->getProjectConfiguration()->getAssembly()->getPackage() - ); - - $component = new Component($component_name, ZiProto::encode($stmts), ComponentDataType::AST); + $stmts = ((new ParserFactory())->createForNewestSupportedVersion())->parse(IO::fread($file_path)); + $component = new Component($component_name, ZiProto::encode(Serializer::nodesToArray($stmts)), ComponentDataType::AST); $component->addFlag(ComponentFlags::PHP_AST->value); $pointer = $package_writer->addComponent($component); diff --git a/src/ncc/Classes/PhpExtension/Serializer.php b/src/ncc/Classes/PhpExtension/Serializer.php new file mode 100644 index 0000000..d4f92a1 --- /dev/null +++ b/src/ncc/Classes/PhpExtension/Serializer.php @@ -0,0 +1,151 @@ +[] Node type to reflection class map */ + private static array $reflectionClassCache; + + /** + * @param NodeAbstract[] $nodeAbstracts + * @return array + */ + public static function nodesToArray(array $nodeAbstracts): array + { + $serialized = []; + + foreach ($nodeAbstracts as $nodeAbstract) + { + $serialized[] = $nodeAbstract->jsonSerialize(); + } + + return $serialized; + } + + /** + * @param array $nodeAbstracts + * @return NodeAbstract[] + */ + public static function arrayToNodes(array $nodeAbstracts): array + { + return self::decodeRecursive($nodeAbstracts); + } + + /** + * @param mixed $value + * @return mixed + */ + private static function decodeRecursive($value) { + if (is_array($value)) { + if (isset($value['nodeType'])) { + if ($value['nodeType'] === 'Comment' || $value['nodeType'] === 'Comment_Doc') { + return self::decodeComment($value); + } + return self::decodeNode($value); + } + return self::decodeArray($value); + } + return $value; + } + + private static function decodeArray(array $array): array { + $decodedArray = []; + foreach ($array as $key => $value) { + $decodedArray[$key] = self::decodeRecursive($value); + } + return $decodedArray; + } + + private static function decodeNode(array $value): Node { + $nodeType = $value['nodeType']; + if (!is_string($nodeType)) { + throw new RuntimeException('Node type must be a string'); + } + + $reflectionClass = self::reflectionClassFromNodeType($nodeType); + $node = $reflectionClass->newInstanceWithoutConstructor(); + + if (isset($value['attributes'])) { + if (!is_array($value['attributes'])) { + throw new RuntimeException('Attributes must be an array'); + } + + $node->setAttributes(self::decodeArray($value['attributes'])); + } + + foreach ($value as $name => $subNode) { + if ($name === 'nodeType' || $name === 'attributes') { + continue; + } + + $node->$name = self::decodeRecursive($subNode); + } + + return $node; + } + + private static function decodeComment(array $value): Comment { + $className = $value['nodeType'] === 'Comment' ? Comment::class : Comment\Doc::class; + if (!isset($value['text'])) { + throw new RuntimeException('Comment must have text'); + } + + return new $className( + $value['text'], + $value['line'] ?? -1, $value['filePos'] ?? -1, $value['tokenPos'] ?? -1, + $value['endLine'] ?? -1, $value['endFilePos'] ?? -1, $value['endTokenPos'] ?? -1 + ); + } + + private static function reflectionClassFromNodeType(string $nodeType): ReflectionClass { + if (!isset(self::$reflectionClassCache[$nodeType])) { + $className = self::classNameFromNodeType($nodeType); + self::$reflectionClassCache[$nodeType] = new ReflectionClass($className); + } + return self::$reflectionClassCache[$nodeType]; + } + + /** @return class-string */ + private static function classNameFromNodeType(string $nodeType): string { + $className = '\\ncc\\ThirdParty\\nikic\\PhpParser\\Node\\' . strtr($nodeType, '_', '\\'); + if (class_exists($className)) { + return $className; + } + + $className .= '_'; + if (class_exists($className)) { + return $className; + } + + throw new RuntimeException("Unknown node type \"$nodeType\""); + } +} \ No newline at end of file diff --git a/src/ncc/Classes/Runtime.php b/src/ncc/Classes/Runtime.php index a324a2d..f5bf8c1 100644 --- a/src/ncc/Classes/Runtime.php +++ b/src/ncc/Classes/Runtime.php @@ -162,7 +162,7 @@ } } - throw new RuntimeException('Importing from a package name is not supported yet'); + throw new RuntimeException(sprintf('Failed to import package "%s" because it does not exist', $package)); } /** diff --git a/src/ncc/Objects/Package/Component.php b/src/ncc/Objects/Package/Component.php index d44dcc7..8411f73 100644 --- a/src/ncc/Objects/Package/Component.php +++ b/src/ncc/Objects/Package/Component.php @@ -27,6 +27,7 @@ use Exception; use InvalidArgumentException; use ncc\Classes\PhpExtension\AstWalker; + use ncc\Classes\PhpExtension\Serializer; use ncc\Enums\Flags\ComponentFlags; use ncc\Enums\LogLevel; use ncc\Enums\Options\ComponentDecodeOptions; @@ -177,12 +178,15 @@ { try { + $decodedData = base64_decode($this->data); + $ast = Serializer::arrayToNodes((array)$decodedData); + if(in_array(ComponentDecodeOptions::AS_FILE->value, $options, true)) { - return (new Standard())->prettyPrintFile(AstWalker::decodeRecursive(base64_decode($this->data))); + return (new Standard())->prettyPrintFile($ast); } - return (new Standard())->prettyPrint(AstWalker::decodeRecursive(base64_decode($this->data))); + return (new Standard())->prettyPrint($ast); } catch(Exception $e) { @@ -197,12 +201,15 @@ { try { + $decodedData = ZiProto::decode($this->data); + $ast = Serializer::arrayToNodes($decodedData); + if(in_array(ComponentDecodeOptions::AS_FILE->value, $options, true)) { - return (new Standard())->prettyPrintFile(AstWalker::decodeRecursive(ZiProto::decode($this->data))); + return (new Standard())->prettyPrintFile($ast); } - return (new Standard())->prettyPrint(AstWalker::decodeRecursive(ZiProto::decode($this->data))); + return (new Standard())->prettyPrint($ast); } catch(Exception $e) { diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/ClassConst.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/ClassConst.php index 3beab31..37d0c81 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/ClassConst.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/ClassConst.php @@ -7,10 +7,10 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Modifiers; -use ncc\ThirdParty\nikic\PhpParser\Node; -use ncc\ThirdParty\nikic\PhpParser\Node\Const_; -use ncc\ThirdParty\nikic\PhpParser\Node\Identifier; -use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; +use PhpParser\Node; +use PhpParser\Node\Const_; +use PhpParser\Node\Identifier; +use PhpParser\Node\Stmt; class ClassConst implements PhpParser\Builder { protected int $flags = 0; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Class_.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Class_.php index 40f598f..d5b7c67 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Class_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Class_.php @@ -5,9 +5,9 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Modifiers; -use ncc\ThirdParty\nikic\PhpParser\Node; -use ncc\ThirdParty\nikic\PhpParser\Node\Name; -use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; +use PhpParser\Node; +use PhpParser\Node\Name; +use PhpParser\Node\Stmt; class Class_ extends Declaration { protected string $name; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Declaration.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Declaration.php index f4bd12e..1377017 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Declaration.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Declaration.php @@ -12,7 +12,7 @@ abstract class Declaration implements PhpParser\Builder { /** * Adds a statement. * - * @param \ncc\ThirdParty\nikic\PhpParser\Node\Stmt|PhpParser\Builder $stmt The statement to add + * @param PhpParser\Node\Stmt|PhpParser\Builder $stmt The statement to add * * @return $this The builder instance (for fluid interface) */ @@ -21,7 +21,7 @@ abstract class Declaration implements PhpParser\Builder { /** * Adds multiple statements. * - * @param (\ncc\ThirdParty\nikic\PhpParser\Node\Stmt|PhpParser\Builder)[] $stmts The statements to add + * @param (PhpParser\Node\Stmt|PhpParser\Builder)[] $stmts The statements to add * * @return $this The builder instance (for fluid interface) */ diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/EnumCase.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/EnumCase.php index 991f586..39005cb 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/EnumCase.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/EnumCase.php @@ -6,9 +6,9 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser; use PhpParser\BuilderHelpers; -use ncc\ThirdParty\nikic\PhpParser\Node; -use ncc\ThirdParty\nikic\PhpParser\Node\Identifier; -use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; +use PhpParser\Node; +use PhpParser\Node\Identifier; +use PhpParser\Node\Stmt; class EnumCase implements PhpParser\Builder { /** @var Identifier|string */ diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Enum_.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Enum_.php index 3db67e5..eeb7154 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Enum_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Enum_.php @@ -4,10 +4,10 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser; use PhpParser\BuilderHelpers; -use ncc\ThirdParty\nikic\PhpParser\Node; -use ncc\ThirdParty\nikic\PhpParser\Node\Identifier; -use ncc\ThirdParty\nikic\PhpParser\Node\Name; -use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; +use PhpParser\Node; +use PhpParser\Node\Identifier; +use PhpParser\Node\Name; +use PhpParser\Node\Stmt; class Enum_ extends Declaration { protected string $name; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Function_.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Function_.php index eb63e34..9a4d051 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Function_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Function_.php @@ -4,8 +4,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser; use PhpParser\BuilderHelpers; -use ncc\ThirdParty\nikic\PhpParser\Node; -use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; +use PhpParser\Node; +use PhpParser\Node\Stmt; class Function_ extends FunctionLike { protected string $name; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Interface_.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Interface_.php index 1696950..44d12b1 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Interface_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Interface_.php @@ -4,9 +4,9 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser; use PhpParser\BuilderHelpers; -use ncc\ThirdParty\nikic\PhpParser\Node; -use ncc\ThirdParty\nikic\PhpParser\Node\Name; -use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; +use PhpParser\Node; +use PhpParser\Node\Name; +use PhpParser\Node\Stmt; class Interface_ extends Declaration { protected string $name; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Method.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Method.php index fe74e72..3679777 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Method.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Method.php @@ -5,8 +5,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Modifiers; -use ncc\ThirdParty\nikic\PhpParser\Node; -use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; +use PhpParser\Node; +use PhpParser\Node\Stmt; class Method extends FunctionLike { protected string $name; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Namespace_.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Namespace_.php index 674f860..cc5a7c9 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Namespace_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Namespace_.php @@ -4,8 +4,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser; use PhpParser\BuilderHelpers; -use ncc\ThirdParty\nikic\PhpParser\Node; -use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; +use PhpParser\Node; +use PhpParser\Node\Stmt; class Namespace_ extends Declaration { private ?Node\Name $name; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Param.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Param.php index 9a81866..67069e8 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Param.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Param.php @@ -5,7 +5,7 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Modifiers; -use ncc\ThirdParty\nikic\PhpParser\Node; +use PhpParser\Node; class Param implements PhpParser\Builder { protected string $name; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Property.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Property.php index 66d819a..1ccfbd1 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Property.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Property.php @@ -5,11 +5,11 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Modifiers; -use ncc\ThirdParty\nikic\PhpParser\Node; -use ncc\ThirdParty\nikic\PhpParser\Node\Identifier; -use ncc\ThirdParty\nikic\PhpParser\Node\Name; -use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; -use ncc\ThirdParty\nikic\PhpParser\Node\ComplexType; +use PhpParser\Node; +use PhpParser\Node\Identifier; +use PhpParser\Node\Name; +use PhpParser\Node\Stmt; +use PhpParser\Node\ComplexType; class Property implements PhpParser\Builder { protected string $name; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/TraitUseAdaptation.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/TraitUseAdaptation.php index 4e181a9..6edc4e4 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/TraitUseAdaptation.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/TraitUseAdaptation.php @@ -135,9 +135,9 @@ class TraitUseAdaptation implements Builder { public function getNode(): Node { switch ($this->type) { case self::TYPE_ALIAS: - return new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Alias($this->trait, $this->method, $this->modifier, $this->alias); + return new Stmt\TraitUseAdaptation\Alias($this->trait, $this->method, $this->modifier, $this->alias); case self::TYPE_PRECEDENCE: - return new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Precedence($this->trait, $this->method, $this->insteadof); + return new Stmt\TraitUseAdaptation\Precedence($this->trait, $this->method, $this->insteadof); default: throw new \LogicException('Type of adaptation is not defined'); } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Trait_.php b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Trait_.php index 03491c4..d0bb060 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Builder/Trait_.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Builder/Trait_.php @@ -4,8 +4,8 @@ namespace ncc\ThirdParty\nikic\PhpParser\Builder; use ncc\ThirdParty\nikic\PhpParser; use PhpParser\BuilderHelpers; -use ncc\ThirdParty\nikic\PhpParser\Node; -use ncc\ThirdParty\nikic\PhpParser\Node\Stmt; +use PhpParser\Node; +use PhpParser\Node\Stmt; class Trait_ extends Declaration { protected string $name; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/BuilderFactory.php b/src/ncc/ThirdParty/nikic/PhpParser/BuilderFactory.php index e4f9f07..c74a9a0 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/BuilderFactory.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/BuilderFactory.php @@ -17,8 +17,8 @@ class BuilderFactory { * @param string|Name $name Name of the attribute * @param array $args Attribute named arguments */ - public function attribute($name, array $args = []): ncc\ThirdParty\nikic\PhpParser\Node\Attribute { - return new ncc\ThirdParty\nikic\PhpParser\Node\Attribute( + public function attribute($name, array $args = []): Node\Attribute { + return new Node\Attribute( BuilderHelpers::normalizeName($name), $this->args($args) ); @@ -27,12 +27,12 @@ class BuilderFactory { /** * Creates a namespace builder. * - * @param null|string|ncc\ThirdParty\nikic\PhpParser\Node\Name $name Name of the namespace + * @param null|string|Node\Name $name Name of the namespace * - * @return ncc\ThirdParty\nikic\PhpParser\Builder\Namespace_ The created namespace builder + * @return Builder\Namespace_ The created namespace builder */ - public function namespace($name): ncc\ThirdParty\nikic\PhpParser\Builder\Namespace_ { - return new ncc\ThirdParty\nikic\PhpParser\Builder\Namespace_($name); + public function namespace($name): Builder\Namespace_ { + return new Builder\Namespace_($name); } /** @@ -40,10 +40,10 @@ class BuilderFactory { * * @param string $name Name of the class * - * @return ncc\ThirdParty\nikic\PhpParser\Builder\Class_ The created class builder + * @return Builder\Class_ The created class builder */ - public function class(string $name): ncc\ThirdParty\nikic\PhpParser\Builder\Class_ { - return new ncc\ThirdParty\nikic\PhpParser\Builder\Class_($name); + public function class(string $name): Builder\Class_ { + return new Builder\Class_($name); } /** @@ -51,10 +51,10 @@ class BuilderFactory { * * @param string $name Name of the interface * - * @return ncc\ThirdParty\nikic\PhpParser\Builder\Interface_ The created interface builder + * @return Builder\Interface_ The created interface builder */ - public function interface(string $name): ncc\ThirdParty\nikic\PhpParser\Builder\Interface_ { - return new ncc\ThirdParty\nikic\PhpParser\Builder\Interface_($name); + public function interface(string $name): Builder\Interface_ { + return new Builder\Interface_($name); } /** @@ -62,10 +62,10 @@ class BuilderFactory { * * @param string $name Name of the trait * - * @return ncc\ThirdParty\nikic\PhpParser\Builder\Trait_ The created trait builder + * @return Builder\Trait_ The created trait builder */ - public function trait(string $name): ncc\ThirdParty\nikic\PhpParser\Builder\Trait_ { - return new ncc\ThirdParty\nikic\PhpParser\Builder\Trait_($name); + public function trait(string $name): Builder\Trait_ { + return new Builder\Trait_($name); } /** @@ -73,38 +73,38 @@ class BuilderFactory { * * @param string $name Name of the enum * - * @return ncc\ThirdParty\nikic\PhpParser\Builder\Enum_ The created enum builder + * @return Builder\Enum_ The created enum builder */ - public function enum(string $name): ncc\ThirdParty\nikic\PhpParser\Builder\Enum_ { - return new ncc\ThirdParty\nikic\PhpParser\Builder\Enum_($name); + public function enum(string $name): Builder\Enum_ { + return new Builder\Enum_($name); } /** * Creates a trait use builder. * - * @param ncc\ThirdParty\nikic\PhpParser\Node\Name|string ...$traits Trait names + * @param Node\Name|string ...$traits Trait names * - * @return ncc\ThirdParty\nikic\PhpParser\Builder\TraitUse The created trait use builder + * @return Builder\TraitUse The created trait use builder */ - public function useTrait(...$traits): ncc\ThirdParty\nikic\PhpParser\Builder\TraitUse { - return new ncc\ThirdParty\nikic\PhpParser\Builder\TraitUse(...$traits); + public function useTrait(...$traits): Builder\TraitUse { + return new Builder\TraitUse(...$traits); } /** * Creates a trait use adaptation builder. * - * @param ncc\ThirdParty\nikic\PhpParser\Node\Name|string|null $trait Trait name - * @param ncc\ThirdParty\nikic\PhpParser\Node\Identifier|string $method Method name + * @param Node\Name|string|null $trait Trait name + * @param Node\Identifier|string $method Method name * - * @return ncc\ThirdParty\nikic\PhpParser\Builder\TraitUseAdaptation The created trait use adaptation builder + * @return Builder\TraitUseAdaptation The created trait use adaptation builder */ - public function traitUseAdaptation($trait, $method = null): ncc\ThirdParty\nikic\PhpParser\Builder\TraitUseAdaptation { + public function traitUseAdaptation($trait, $method = null): Builder\TraitUseAdaptation { if ($method === null) { $method = $trait; $trait = null; } - return new ncc\ThirdParty\nikic\PhpParser\Builder\TraitUseAdaptation($trait, $method); + return new Builder\TraitUseAdaptation($trait, $method); } /** @@ -112,10 +112,10 @@ class BuilderFactory { * * @param string $name Name of the method * - * @return ncc\ThirdParty\nikic\PhpParser\Builder\Method The created method builder + * @return Builder\Method The created method builder */ - public function method(string $name): ncc\ThirdParty\nikic\PhpParser\Builder\Method { - return new ncc\ThirdParty\nikic\PhpParser\Builder\Method($name); + public function method(string $name): Builder\Method { + return new Builder\Method($name); } /** @@ -123,10 +123,10 @@ class BuilderFactory { * * @param string $name Name of the parameter * - * @return ncc\ThirdParty\nikic\PhpParser\Builder\Param The created parameter builder + * @return Builder\Param The created parameter builder */ - public function param(string $name): ncc\ThirdParty\nikic\PhpParser\Builder\Param { - return new ncc\ThirdParty\nikic\PhpParser\Builder\Param($name); + public function param(string $name): Builder\Param { + return new Builder\Param($name); } /** @@ -134,10 +134,10 @@ class BuilderFactory { * * @param string $name Name of the property * - * @return ncc\ThirdParty\nikic\PhpParser\Builder\Property The created property builder + * @return Builder\Property The created property builder */ - public function property(string $name): ncc\ThirdParty\nikic\PhpParser\Builder\Property { - return new ncc\ThirdParty\nikic\PhpParser\Builder\Property($name); + public function property(string $name): Builder\Property { + return new Builder\Property($name); } /** @@ -145,55 +145,55 @@ class BuilderFactory { * * @param string $name Name of the function * - * @return ncc\ThirdParty\nikic\PhpParser\Builder\Function_ The created function builder + * @return Builder\Function_ The created function builder */ - public function function(string $name): ncc\ThirdParty\nikic\PhpParser\Builder\Function_ { - return new ncc\ThirdParty\nikic\PhpParser\Builder\Function_($name); + public function function(string $name): Builder\Function_ { + return new Builder\Function_($name); } /** * Creates a namespace/class use builder. * - * @param ncc\ThirdParty\nikic\PhpParser\Node\Name|string $name Name of the entity (namespace or class) to alias + * @param Node\Name|string $name Name of the entity (namespace or class) to alias * - * @return ncc\ThirdParty\nikic\PhpParser\Builder\Use_ The created use builder + * @return Builder\Use_ The created use builder */ - public function use($name): ncc\ThirdParty\nikic\PhpParser\Builder\Use_ { - return new ncc\ThirdParty\nikic\PhpParser\Builder\Use_($name, Use_::TYPE_NORMAL); + public function use($name): Builder\Use_ { + return new Builder\Use_($name, Use_::TYPE_NORMAL); } /** * Creates a function use builder. * - * @param ncc\ThirdParty\nikic\PhpParser\Node\Name|string $name Name of the function to alias + * @param Node\Name|string $name Name of the function to alias * - * @return ncc\ThirdParty\nikic\PhpParser\Builder\Use_ The created use function builder + * @return Builder\Use_ The created use function builder */ - public function useFunction($name): ncc\ThirdParty\nikic\PhpParser\Builder\Use_ { - return new ncc\ThirdParty\nikic\PhpParser\Builder\Use_($name, Use_::TYPE_FUNCTION); + public function useFunction($name): Builder\Use_ { + return new Builder\Use_($name, Use_::TYPE_FUNCTION); } /** * Creates a constant use builder. * - * @param ncc\ThirdParty\nikic\PhpParser\Node\Name|string $name Name of the const to alias + * @param Node\Name|string $name Name of the const to alias * - * @return ncc\ThirdParty\nikic\PhpParser\Builder\Use_ The created use const builder + * @return Builder\Use_ The created use const builder */ - public function useConst($name): ncc\ThirdParty\nikic\PhpParser\Builder\Use_ { - return new ncc\ThirdParty\nikic\PhpParser\Builder\Use_($name, Use_::TYPE_CONSTANT); + public function useConst($name): Builder\Use_ { + return new Builder\Use_($name, Use_::TYPE_CONSTANT); } /** * Creates a class constant builder. * * @param string|Identifier $name Name - * @param ncc\ThirdParty\nikic\PhpParser\Node\Expr|bool|null|int|float|string|array $value Value + * @param Node\Expr|bool|null|int|float|string|array $value Value * - * @return ncc\ThirdParty\nikic\PhpParser\Builder\ClassConst The created use const builder + * @return Builder\ClassConst The created use const builder */ - public function classConst($name, $value): ncc\ThirdParty\nikic\PhpParser\Builder\ClassConst { - return new ncc\ThirdParty\nikic\PhpParser\Builder\ClassConst($name, $value); + public function classConst($name, $value): Builder\ClassConst { + return new Builder\ClassConst($name, $value); } /** @@ -201,10 +201,10 @@ class BuilderFactory { * * @param string|Identifier $name Name * - * @return ncc\ThirdParty\nikic\PhpParser\Builder\EnumCase The created use const builder + * @return Builder\EnumCase The created use const builder */ - public function enumCase($name): ncc\ThirdParty\nikic\PhpParser\Builder\EnumCase { - return new ncc\ThirdParty\nikic\PhpParser\Builder\EnumCase($name); + public function enumCase($name): Builder\EnumCase { + return new Builder\EnumCase($name); } /** diff --git a/src/ncc/ThirdParty/nikic/PhpParser/BuilderHelpers.php b/src/ncc/ThirdParty/nikic/PhpParser/BuilderHelpers.php index cd56a69..cb6c18c 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/BuilderHelpers.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/BuilderHelpers.php @@ -215,12 +215,12 @@ final class BuilderHelpers { * Normalizes a value: Converts nulls, booleans, integers, * floats, strings and arrays into their respective nodes * - * @param ncc\ThirdParty\nikic\PhpParser\Node\Expr|bool|null|int|float|string|array|\UnitEnum $value The value to normalize + * @param Node\Expr|bool|null|int|float|string|array|\UnitEnum $value The value to normalize * * @return Expr The normalized value */ public static function normalizeValue($value): Expr { - if ($value instanceof ncc\ThirdParty\nikic\PhpParser\Node\Expr) { + if ($value instanceof Node\Expr) { return $value; } @@ -254,12 +254,12 @@ final class BuilderHelpers { foreach ($value as $itemKey => $itemValue) { // for consecutive, numeric keys don't generate keys if (null !== $lastKey && ++$lastKey === $itemKey) { - $items[] = new ncc\ThirdParty\nikic\PhpParser\Node\ArrayItem( + $items[] = new Node\ArrayItem( self::normalizeValue($itemValue) ); } else { $lastKey = null; - $items[] = new ncc\ThirdParty\nikic\PhpParser\Node\ArrayItem( + $items[] = new Node\ArrayItem( self::normalizeValue($itemValue), self::normalizeValue($itemKey) ); @@ -298,20 +298,20 @@ final class BuilderHelpers { /** * Normalizes a attribute: Converts attribute to the Attribute Group if needed. * - * @param ncc\ThirdParty\nikic\PhpParser\Node\Attribute|ncc\ThirdParty\nikic\PhpParser\Node\AttributeGroup $attribute + * @param Node\Attribute|Node\AttributeGroup $attribute * - * @return ncc\ThirdParty\nikic\PhpParser\Node\AttributeGroup The Attribute Group + * @return Node\AttributeGroup The Attribute Group */ - public static function normalizeAttribute($attribute): ncc\ThirdParty\nikic\PhpParser\Node\AttributeGroup { - if ($attribute instanceof ncc\ThirdParty\nikic\PhpParser\Node\AttributeGroup) { + public static function normalizeAttribute($attribute): Node\AttributeGroup { + if ($attribute instanceof Node\AttributeGroup) { return $attribute; } - if (!($attribute instanceof ncc\ThirdParty\nikic\PhpParser\Node\Attribute)) { + if (!($attribute instanceof Node\Attribute)) { throw new \LogicException('Attribute must be an instance of PhpParser\Node\Attribute or PhpParser\Node\AttributeGroup'); } - return new ncc\ThirdParty\nikic\PhpParser\Node\AttributeGroup([$attribute]); + return new Node\AttributeGroup([$attribute]); } /** diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Internal/TokenPolyfill.php b/src/ncc/ThirdParty/nikic/PhpParser/Internal/TokenPolyfill.php index 256cd8e..1d8e1cf 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Internal/TokenPolyfill.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Internal/TokenPolyfill.php @@ -3,8 +3,7 @@ namespace ncc\ThirdParty\nikic\PhpParser\Internal; if (\PHP_VERSION_ID >= 80000) { - class TokenPolyfill extends \PhpToken { - } + class_alias(\PhpToken::class, TokenPolyfill::class); return; } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/NodeTraverser.php b/src/ncc/ThirdParty/nikic/PhpParser/NodeTraverser.php index 3fc2c19..be5a1f5 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/NodeTraverser.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/NodeTraverser.php @@ -260,7 +260,7 @@ class NodeTraverser implements NodeTraverserInterface { } private function ensureReplacementReasonable(Node $old, Node $new): void { - if ($old instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt && $new instanceof ncc\ThirdParty\nikic\PhpParser\Node\Expr) { + if ($old instanceof Node\Stmt && $new instanceof Node\Expr) { throw new \LogicException( "Trying to replace statement ({$old->getType()}) " . "with expression ({$new->getType()}). Are you missing a " . @@ -268,7 +268,7 @@ class NodeTraverser implements NodeTraverserInterface { ); } - if ($old instanceof ncc\ThirdParty\nikic\PhpParser\Node\Expr && $new instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt) { + if ($old instanceof Node\Expr && $new instanceof Node\Stmt) { throw new \LogicException( "Trying to replace expression ({$old->getType()}) " . "with statement ({$new->getType()})" diff --git a/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/NameResolver.php b/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/NameResolver.php index 55f0837..7d85aaf 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/NameResolver.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/NodeVisitor/NameResolver.php @@ -156,7 +156,7 @@ class NameResolver extends NodeVisitorAbstract { $adaptation->trait = $this->resolveClassName($adaptation->trait); } - if ($adaptation instanceof \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Precedence) { + if ($adaptation instanceof Stmt\TraitUseAdaptation\Precedence) { foreach ($adaptation->insteadof as &$insteadof) { $insteadof = $this->resolveClassName($insteadof); } diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Parser.php b/src/ncc/ThirdParty/nikic/PhpParser/Parser.php index 7e77e49..48593b2 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Parser.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Parser.php @@ -10,7 +10,7 @@ interface Parser { * @param ErrorHandler|null $errorHandler Error handler to use for lexer/parser errors, defaults * to ErrorHandler\Throwing. * - * @return ncc\ThirdParty\nikic\PhpParser\Node\Stmt[]|null Array of statements (or null non-throwing error handler is used and + * @return Node\Stmt[]|null Array of statements (or null non-throwing error handler is used and * the parser was unable to recover from an error). */ public function parse(string $code, ?ErrorHandler $errorHandler = null): ?array; diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Parser/Php7.php b/src/ncc/ThirdParty/nikic/PhpParser/Parser/Php7.php index aeae506..2dd32fa 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Parser/Php7.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Parser/Php7.php @@ -2027,19 +2027,19 @@ class Php7 extends \ncc\ThirdParty\nikic\PhpParser\ParserAbstract $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; $self->semValue = $self->semStack[$stackPos-(2-1)]; }, 357 => static function ($self, $stackPos) { - $self->semValue = new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Precedence($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + $self->semValue = new Stmt\TraitUseAdaptation\Precedence($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, 358 => static function ($self, $stackPos) { - $self->semValue = new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(5-1)][0], $self->semStack[$stackPos-(5-1)][1], $self->semStack[$stackPos-(5-3)], $self->semStack[$stackPos-(5-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); + $self->semValue = new Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(5-1)][0], $self->semStack[$stackPos-(5-1)][1], $self->semStack[$stackPos-(5-3)], $self->semStack[$stackPos-(5-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); }, 359 => static function ($self, $stackPos) { - $self->semValue = new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], $self->semStack[$stackPos-(4-3)], null, $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + $self->semValue = new Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], $self->semStack[$stackPos-(4-3)], null, $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, 360 => static function ($self, $stackPos) { - $self->semValue = new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], null, $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + $self->semValue = new Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], null, $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, 361 => static function ($self, $stackPos) { - $self->semValue = new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], null, $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + $self->semValue = new Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], null, $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, 362 => static function ($self, $stackPos) { $self->semValue = array($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)]); diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Parser/Php8.php b/src/ncc/ThirdParty/nikic/PhpParser/Parser/Php8.php index cf23196..89694a1 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Parser/Php8.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Parser/Php8.php @@ -2042,19 +2042,19 @@ class Php8 extends \ncc\ThirdParty\nikic\PhpParser\ParserAbstract $self->semStack[$stackPos-(2-1)][] = $self->semStack[$stackPos-(2-2)]; $self->semValue = $self->semStack[$stackPos-(2-1)]; }, 358 => static function ($self, $stackPos) { - $self->semValue = new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Precedence($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + $self->semValue = new Stmt\TraitUseAdaptation\Precedence($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, 359 => static function ($self, $stackPos) { - $self->semValue = new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(5-1)][0], $self->semStack[$stackPos-(5-1)][1], $self->semStack[$stackPos-(5-3)], $self->semStack[$stackPos-(5-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); + $self->semValue = new Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(5-1)][0], $self->semStack[$stackPos-(5-1)][1], $self->semStack[$stackPos-(5-3)], $self->semStack[$stackPos-(5-4)], $self->getAttributes($self->tokenStartStack[$stackPos-(5-1)], $self->tokenEndStack[$stackPos])); }, 360 => static function ($self, $stackPos) { - $self->semValue = new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], $self->semStack[$stackPos-(4-3)], null, $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + $self->semValue = new Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], $self->semStack[$stackPos-(4-3)], null, $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, 361 => static function ($self, $stackPos) { - $self->semValue = new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], null, $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + $self->semValue = new Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], null, $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, 362 => static function ($self, $stackPos) { - $self->semValue = new \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], null, $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); + $self->semValue = new Stmt\TraitUseAdaptation\Alias($self->semStack[$stackPos-(4-1)][0], $self->semStack[$stackPos-(4-1)][1], null, $self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); }, 363 => static function ($self, $stackPos) { $self->semValue = array($self->semStack[$stackPos-(3-1)], $self->semStack[$stackPos-(3-3)]); diff --git a/src/ncc/ThirdParty/nikic/PhpParser/ParserAbstract.php b/src/ncc/ThirdParty/nikic/PhpParser/ParserAbstract.php index c83c715..4ef6768 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/ParserAbstract.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/ParserAbstract.php @@ -174,7 +174,7 @@ abstract class ParserAbstract implements Parser { * @param ErrorHandler|null $errorHandler Error handler to use for lexer/parser errors, defaults * to ErrorHandler\Throwing. * - * @return ncc\ThirdParty\nikic\PhpParser\Node\Stmt[]|null Array of statements (or null non-throwing error handler is used and + * @return Node\Stmt[]|null Array of statements (or null non-throwing error handler is used and * the parser was unable to recover from an error). */ public function parse(string $code, ?ErrorHandler $errorHandler = null): ?array { @@ -555,8 +555,8 @@ abstract class ParserAbstract implements Parser { /** * Moves statements of semicolon-style namespaces into $ns->stmts and checks various error conditions. * - * @param ncc\ThirdParty\nikic\PhpParser\Node\Stmt[] $stmts - * @return ncc\ThirdParty\nikic\PhpParser\Node\Stmt[] + * @param Node\Stmt[] $stmts + * @return Node\Stmt[] */ protected function handleNamespaces(array $stmts): array { $hasErrored = false; @@ -569,10 +569,10 @@ abstract class ParserAbstract implements Parser { // For braced namespaces we only have to check that there are no invalid statements between the namespaces $afterFirstNamespace = false; foreach ($stmts as $stmt) { - if ($stmt instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt\Namespace_) { + if ($stmt instanceof Node\Stmt\Namespace_) { $afterFirstNamespace = true; - } elseif (!$stmt instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt\HaltCompiler - && !$stmt instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt\Nop + } elseif (!$stmt instanceof Node\Stmt\HaltCompiler + && !$stmt instanceof Node\Stmt\Nop && $afterFirstNamespace && !$hasErrored) { $this->emitError(new Error( 'No code may exist outside of namespace {}', $stmt->getAttributes())); @@ -586,7 +586,7 @@ abstract class ParserAbstract implements Parser { $targetStmts = &$resultStmts; $lastNs = null; foreach ($stmts as $stmt) { - if ($stmt instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt\Namespace_) { + if ($stmt instanceof Node\Stmt\Namespace_) { if ($lastNs !== null) { $this->fixupNamespaceAttributes($lastNs); } @@ -600,7 +600,7 @@ abstract class ParserAbstract implements Parser { $targetStmts = &$resultStmts; } $lastNs = $stmt; - } elseif ($stmt instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt\HaltCompiler) { + } elseif ($stmt instanceof Node\Stmt\HaltCompiler) { // __halt_compiler() is not moved into the namespace $resultStmts[] = $stmt; } else { @@ -614,7 +614,7 @@ abstract class ParserAbstract implements Parser { } } - private function fixupNamespaceAttributes(ncc\ThirdParty\nikic\PhpParser\Node\Stmt\Namespace_ $stmt): void { + private function fixupNamespaceAttributes(Node\Stmt\Namespace_ $stmt): void { // We moved the statements into the namespace node, as such the end of the namespace node // needs to be extended to the end of the statements. if (empty($stmt->stmts)) { @@ -659,7 +659,7 @@ abstract class ParserAbstract implements Parser { $style = null; $hasNotAllowedStmts = false; foreach ($stmts as $i => $stmt) { - if ($stmt instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt\Namespace_) { + if ($stmt instanceof Node\Stmt\Namespace_) { $currentStyle = null === $stmt->stmts ? 'semicolon' : 'brace'; if (null === $style) { $style = $currentStyle; @@ -681,14 +681,14 @@ abstract class ParserAbstract implements Parser { } /* declare(), __halt_compiler() and nops can be used before a namespace declaration */ - if ($stmt instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt\Declare_ - || $stmt instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt\HaltCompiler - || $stmt instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt\Nop) { + if ($stmt instanceof Node\Stmt\Declare_ + || $stmt instanceof Node\Stmt\HaltCompiler + || $stmt instanceof Node\Stmt\Nop) { continue; } /* There may be a hashbang line at the very start of the file */ - if ($i === 0 && $stmt instanceof ncc\ThirdParty\nikic\PhpParser\Node\Stmt\InlineHTML && preg_match('/\A#!.*\r?\n\z/', $stmt->value)) { + if ($i === 0 && $stmt instanceof Node\Stmt\InlineHTML && preg_match('/\A#!.*\r?\n\z/', $stmt->value)) { continue; } @@ -709,7 +709,7 @@ abstract class ParserAbstract implements Parser { return $name; } - return new ncc\ThirdParty\nikic\PhpParser\Node\Identifier($lowerName, $name->getAttributes()); + return new Node\Identifier($lowerName, $name->getAttributes()); } /** @@ -860,7 +860,7 @@ abstract class ParserAbstract implements Parser { return new String_($contents, $attributes); } else { assert(count($contents) > 0); - if (!$contents[0] instanceof ncc\ThirdParty\nikic\PhpParser\Node\InterpolatedStringPart) { + if (!$contents[0] instanceof Node\InterpolatedStringPart) { // If there is no leading encapsed string part, pretend there is an empty one $this->stripIndentation( '', $indentLen, $indentChar, true, false, $contents[0]->getAttributes() @@ -869,7 +869,7 @@ abstract class ParserAbstract implements Parser { $newContents = []; foreach ($contents as $i => $part) { - if ($part instanceof ncc\ThirdParty\nikic\PhpParser\Node\InterpolatedStringPart) { + if ($part instanceof Node\InterpolatedStringPart) { $isLast = $i === \count($contents) - 1; $part->value = $this->stripIndentation( $part->value, $indentLen, $indentChar, @@ -977,13 +977,13 @@ abstract class ParserAbstract implements Parser { protected function fixupArrayDestructuring(Array_ $node): Expr\List_ { $this->createdArrays->detach($node); - return new Expr\List_(array_map(function (ncc\ThirdParty\nikic\PhpParser\Node\ArrayItem $item) { + return new Expr\List_(array_map(function (Node\ArrayItem $item) { if ($item->value instanceof Expr\Error) { // We used Error as a placeholder for empty elements, which are legal for destructuring. return null; } if ($item->value instanceof Array_) { - return new ncc\ThirdParty\nikic\PhpParser\Node\ArrayItem( + return new Node\ArrayItem( $this->fixupArrayDestructuring($item->value), $item->key, $item->byRef, $item->getAttributes()); } @@ -1196,7 +1196,7 @@ abstract class ParserAbstract implements Parser { } } - /** @param array $args */ + /** @param array $args */ private function isSimpleExit(array $args): bool { if (\count($args) === 0) { return true; @@ -1210,7 +1210,7 @@ abstract class ParserAbstract implements Parser { } /** - * @param array $args + * @param array $args * @param array $attrs */ protected function createExitExpr(string $name, int $namePos, array $args, array $attrs): Expr { diff --git a/src/ncc/ThirdParty/nikic/PhpParser/PrettyPrinter/Standard.php b/src/ncc/ThirdParty/nikic/PhpParser/PrettyPrinter/Standard.php index be11404..7fe32b6 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/PrettyPrinter/Standard.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/PrettyPrinter/Standard.php @@ -815,12 +815,12 @@ class Standard extends PrettyPrinterAbstract { : ' {' . $this->pStmts($node->adaptations) . $this->nl . '}'); } - protected function pStmt_TraitUseAdaptation_Precedence(\ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Precedence $node): string { + protected function pStmt_TraitUseAdaptation_Precedence(Stmt\TraitUseAdaptation\Precedence $node): string { return $this->p($node->trait) . '::' . $node->method . ' insteadof ' . $this->pCommaSeparated($node->insteadof) . ';'; } - protected function pStmt_TraitUseAdaptation_Alias(\ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Alias $node): string { + protected function pStmt_TraitUseAdaptation_Alias(Stmt\TraitUseAdaptation\Alias $node): string { return (null !== $node->trait ? $this->p($node->trait) . '::' : '') . $node->method . ' as' . (null !== $node->newModifier ? ' ' . rtrim($this->pModifiers($node->newModifier), ' ') : '') diff --git a/src/ncc/ThirdParty/nikic/PhpParser/PrettyPrinterAbstract.php b/src/ncc/ThirdParty/nikic/PhpParser/PrettyPrinterAbstract.php index 43fe1a9..b5c433a 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/PrettyPrinterAbstract.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/PrettyPrinterAbstract.php @@ -122,7 +122,7 @@ abstract class PrettyPrinterAbstract implements PrettyPrinter { /** @var TokenStream|null Original tokens for use in format-preserving pretty print */ protected ?TokenStream $origTokens; - /** @var ncc\ThirdParty\nikic\PhpParser\Internal\Differ Differ for node lists */ + /** @var Internal\Differ Differ for node lists */ protected Differ $nodeListDiffer; /** @var array Map determining whether a certain character is a label character */ protected array $labelCharMap; @@ -1069,7 +1069,7 @@ abstract class PrettyPrinterAbstract implements PrettyPrinter { } break; case self::FIXUP_ENCAPSED: - if (!$subNode instanceof ncc\ThirdParty\nikic\PhpParser\Node\InterpolatedStringPart + if (!$subNode instanceof Node\InterpolatedStringPart && !$this->origTokens->haveBraces($subStartPos, $subEndPos) ) { return '{' . $this->p($subNode) . '}'; @@ -1115,7 +1115,7 @@ abstract class PrettyPrinterAbstract implements PrettyPrinter { * @return bool Whether parentheses are required */ protected function callLhsRequiresParens(Node $node): bool { - return !($node instanceof ncc\ThirdParty\nikic\PhpParser\Node\Name + return !($node instanceof Node\Name || $node instanceof Expr\Variable || $node instanceof Expr\ArrayDimFetch || $node instanceof Expr\FuncCall @@ -1147,7 +1147,7 @@ abstract class PrettyPrinterAbstract implements PrettyPrinter { */ protected function staticDereferenceLhsRequiresParens(Node $node): bool { return !($node instanceof Expr\Variable - || $node instanceof ncc\ThirdParty\nikic\PhpParser\Node\Name + || $node instanceof Node\Name || $node instanceof Expr\ArrayDimFetch || $node instanceof Expr\PropertyFetch || $node instanceof Expr\NullsafePropertyFetch @@ -1169,7 +1169,7 @@ abstract class PrettyPrinterAbstract implements PrettyPrinter { * @return bool Whether parentheses are required */ protected function newOperandRequiresParens(Node $node): bool { - if ($node instanceof ncc\ThirdParty\nikic\PhpParser\Node\Name || $node instanceof Expr\Variable) { + if ($node instanceof Node\Name || $node instanceof Expr\Variable) { return false; } if ($node instanceof Expr\ArrayDimFetch || $node instanceof Expr\PropertyFetch || @@ -1272,7 +1272,7 @@ abstract class PrettyPrinterAbstract implements PrettyPrinter { return; } - $this->nodeListDiffer = new ncc\ThirdParty\nikic\PhpParser\Internal\Differ(function ($a, $b) { + $this->nodeListDiffer = new Internal\Differ(function ($a, $b) { if ($a instanceof Node && $b instanceof Node) { return $a === $b->getAttribute('origNode'); } @@ -1516,7 +1516,7 @@ abstract class PrettyPrinterAbstract implements PrettyPrinter { Stmt\Property::class . '->props' => ', ', Stmt\StaticVar::class . '->vars' => ', ', Stmt\TraitUse::class . '->traits' => ', ', - \ncc\ThirdParty\nikic\PhpParser\Node\Stmt\TraitUseAdaptation\Precedence::class . '->insteadof' => ', ', + Stmt\TraitUseAdaptation\Precedence::class . '->insteadof' => ', ', Stmt\Unset_::class . '->vars' => ', ', Stmt\UseUse::class . '->uses' => ', ', MatchArm::class . '->conds' => ', ', diff --git a/src/ncc/ThirdParty/nikic/PhpParser/Token.php b/src/ncc/ThirdParty/nikic/PhpParser/Token.php index bab630d..221e415 100644 --- a/src/ncc/ThirdParty/nikic/PhpParser/Token.php +++ b/src/ncc/ThirdParty/nikic/PhpParser/Token.php @@ -5,7 +5,7 @@ namespace ncc\ThirdParty\nikic\PhpParser; /** * A PHP token. On PHP 8.0 this extends from PhpToken. */ -class Token extends ncc\ThirdParty\nikic\PhpParser\Internal\TokenPolyfill { +class Token extends Internal\TokenPolyfill { /** Get (exclusive) zero-based end position of the token. */ public function getEndPos(): int { return $this->pos + \strlen($this->text); From dda710119ce63cf262260cc4858206775602a56d Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 17:04:30 -0400 Subject: [PATCH 109/134] Add option to force package build from source --- src/ncc/CLI/Management/PackageManagerMenu.php | 6 ++ .../Enums/Options/InstallPackageOptions.php | 10 +++- src/ncc/Managers/PackageManager.php | 58 +++++++++++-------- src/ncc/Managers/ProjectManager.php | 6 ++ 4 files changed, 54 insertions(+), 26 deletions(-) diff --git a/src/ncc/CLI/Management/PackageManagerMenu.php b/src/ncc/CLI/Management/PackageManagerMenu.php index 58dc746..2d98853 100644 --- a/src/ncc/CLI/Management/PackageManagerMenu.php +++ b/src/ncc/CLI/Management/PackageManagerMenu.php @@ -168,6 +168,11 @@ $options[InstallPackageOptions::SKIP_DEPENDENCIES->value] = true; } + if(isset($args['build-source'])) + { + $options[InstallPackageOptions::BUILD_SOURCE->value] = true; + } + if($authentication !== null) { $entry = (new CredentialManager())->getVault()?->getEntry($authentication); @@ -560,6 +565,7 @@ new CliHelpSection(['install', '-p', '--skip-dependencies'], 'Installs a specified ncc package but skips the installation of dependencies'), new CliHelpSection(['install', '-p', '--reinstall'], 'Installs a specified ncc package, reinstall if already installed'), new CliHelpSection(['install', '--prefer-static', '--static'], 'Installs a static version of the package from the remote repository if available'), + new CliHelpSection(['install', '--build-source'], 'Forces ncc to build the packages from source rather than trying to use a pre-built binary'), new CliHelpSection(['uninstall', '--package', '-p'], 'Uninstalls a specified ncc package'), new CliHelpSection(['uninstall', '--package', '-p', '--version', '-v'], 'Uninstalls a specified ncc package version'), new CliHelpSection(['uninstall-all'], 'Uninstalls all packages'), diff --git a/src/ncc/Enums/Options/InstallPackageOptions.php b/src/ncc/Enums/Options/InstallPackageOptions.php index e074245..f217380 100644 --- a/src/ncc/Enums/Options/InstallPackageOptions.php +++ b/src/ncc/Enums/Options/InstallPackageOptions.php @@ -30,7 +30,7 @@ * @warning This will cause the package to fail to import of * the dependencies are not met */ - case SKIP_DEPENDENCIES = 'skip_dependencies'; + case SKIP_DEPENDENCIES = 'skip-dependencies'; /** * Reinstall all packages if they are already installed, @@ -42,5 +42,11 @@ * Installs a static version of the package if it's available * otherwise it will install non-static version */ - case PREFER_STATIC = 'prefer_static'; + case PREFER_STATIC = 'prefer-static'; + + /** + * Forces ncc to build packages from source rather than trying to obtain + * a pre-built version of the package + */ + case BUILD_SOURCE = 'build-source'; } \ No newline at end of file diff --git a/src/ncc/Managers/PackageManager.php b/src/ncc/Managers/PackageManager.php index a2837d5..d5f2678 100644 --- a/src/ncc/Managers/PackageManager.php +++ b/src/ncc/Managers/PackageManager.php @@ -521,7 +521,7 @@ )); /** @noinspection SlowArrayOperationsInLoopInspection */ - $installed_packages = array_merge($installed_packages, $this->install($dependency->getSource(), $authentication)); + $installed_packages = array_merge($installed_packages, $this->install($dependency->getSource(), $authentication, $options)); } } @@ -550,35 +550,45 @@ Console::out(sprintf('Fetching package %s/%s=%s from %s', $input->getVendor(), $input->getPackage(), $input->getVersion(), $input->getRepository())); - try + if(isset($options[InstallPackageOptions::BUILD_SOURCE->value])) { Console::outVerbose(sprintf( - 'Attempting to fetch a pre-built ncc package for %s=%s from %s', - $input->getPackage(), $input->getVersion(), $input->getRepository() + 'Forcing ncc to build package %s/%s=%s from source', + $input->getVendor(), $input->getPackage(), $input->getVersion() )); - - // First try to fetch a pre-built package from the repository - $results = $this->repository_manager->getRepository($input->getRepository())->fetchPackage( - $input->getVendor(), $input->getPackage(), $input->getVersion(), $authentication, $options - ); - - $package_path = $this->downloadFile($results->getUrl(), PathFinder::getCachePath()); } - catch(Exception $e) + else { - Console::outVerbose(sprintf( - 'Failed to fetch a pre-built ncc package for %s=%s from %s: %s', - $input->getPackage(), $input->getVersion(), $input->getRepository(), $e->getMessage() - )); - - // Clean up the package file if it exists - if(isset($package_path) && is_file($package_path)) + try { - ShutdownHandler::declareTemporaryPath($package_path); - } + Console::outVerbose(sprintf( + 'Attempting to fetch a pre-built ncc package for %s=%s from %s', + $input->getPackage(), $input->getVersion(), $input->getRepository() + )); - // This is a warning because we can still attempt to build from source - unset($results, $package_path); + // First try to fetch a pre-built package from the repository + $results = $this->repository_manager->getRepository($input->getRepository())->fetchPackage( + $input->getVendor(), $input->getPackage(), $input->getVersion(), $authentication, $options + ); + + $package_path = $this->downloadFile($results->getUrl(), PathFinder::getCachePath()); + } + catch(Exception $e) + { + Console::outVerbose(sprintf( + 'Failed to fetch a pre-built ncc package for %s=%s from %s: %s', + $input->getPackage(), $input->getVersion(), $input->getRepository(), $e->getMessage() + )); + + // Clean up the package file if it exists + if(isset($package_path) && is_file($package_path)) + { + ShutdownHandler::declareTemporaryPath($package_path); + } + + // This is a warning because we can still attempt to build from source + unset($results, $package_path); + } } if(!isset($package_path)) @@ -848,7 +858,7 @@ } default: - throw new NotSupportedException(sprintf('Cannot build from source %s, the project type %s is not supported', $archive, $project_detection->getProjectType())); + throw new NotSupportedException(sprintf('Cannot build from source %s, the project type %s is not supported', $archive, $project_detection->getProjectType()->value)); } } diff --git a/src/ncc/Managers/ProjectManager.php b/src/ncc/Managers/ProjectManager.php index 5f09005..6d6951f 100644 --- a/src/ncc/Managers/ProjectManager.php +++ b/src/ncc/Managers/ProjectManager.php @@ -96,6 +96,12 @@ $path = substr($path, 0, -1); } + if(is_file($path)) + { + // We can assume the user is trying to load a project file + $path = dirname($path); + } + // Detect if the folder exists or not if(!is_dir($path)) { From 170cb4bf6d83f7dd53a26ddbaba7aed948cfa8b6 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 17:13:44 -0400 Subject: [PATCH 110/134] Ensure required files exist before evaluation --- src/ncc/Classes/Runtime.php | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/ncc/Classes/Runtime.php b/src/ncc/Classes/Runtime.php index f5bf8c1..36daf32 100644 --- a/src/ncc/Classes/Runtime.php +++ b/src/ncc/Classes/Runtime.php @@ -195,18 +195,34 @@ { foreach($entry->getMetadata($version)->getOption(BuildConfigurationOptions::REQUIRE_FILES->value) as $item) { + $required_file = $entry->getPath($version) . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . $item; + try { - // Get the file contents and prepare it - $required_file = IO::fread($entry->getPath($version) . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . $item); - $required_file = preg_replace('/^<\?php|<\?PHP/', '', $required_file, 1); + if(!file_exists($required_file)) + { + throw new PathNotFoundException($required_file); + } - eval($required_file); - unset($required_file); + // Get the file contents and prepare it + $evaluated_code = IO::fread($required_file(preg_replace('/^<\?php|<\?PHP/', '', $required_file, 1))); + set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($item, $package) + { + throw new ImportException(sprintf('Failed to import "%s" from %s: %s', $item, $package, $errstr)); + }); + + // Evaluate the code + eval($evaluated_code); + restore_error_handler(); + unset($evaluated_code); } - catch(ConfigurationException $e) + catch (ConfigurationException $e) { - throw new ImportException(sprintf('Failed to import "%s" from %s: %s', $item, $package, $e->getMessage()), $e); + throw new ImportException(sprintf('%s: Failed to import "%s" from %s: %s', $required_file, $item, $package, $e->getMessage()), $e); + } + catch (Throwable $e) + { + throw new ImportException(sprintf('%s: Failed to import "%s" from %s: %s', $required_file, $item, $package, $e->getMessage()), $e); } } } From 7494ead7b34933a40b48d1b2f95824d65d1dc20b Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 17:47:30 -0400 Subject: [PATCH 111/134] Refactor ProjectManager and Runtime handling --- src/ncc/Classes/Runtime.php | 16 +++++++++++++--- src/ncc/Managers/ProjectManager.php | 9 +-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/ncc/Classes/Runtime.php b/src/ncc/Classes/Runtime.php index 36daf32..fd00c99 100644 --- a/src/ncc/Classes/Runtime.php +++ b/src/ncc/Classes/Runtime.php @@ -205,10 +205,16 @@ } // Get the file contents and prepare it - $evaluated_code = IO::fread($required_file(preg_replace('/^<\?php|<\?PHP/', '', $required_file, 1))); - set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($item, $package) + $evaluated_code = IO::fread($required_file); + + // Remove the PHP tags + $evaluated_code = preg_replace('/^<\?php|<\?PHP/', '', $evaluated_code, 1); + // Replace __DIR__ with the actual directory that the file is in + $evaluated_code = str_replace('__DIR__', sprintf('"%s"', dirname($required_file)), $evaluated_code); + + set_error_handler(function ($error_number, $message, $file, $line) use ($item, $package) { - throw new ImportException(sprintf('Failed to import "%s" from %s: %s', $item, $package, $errstr)); + throw new ImportException(sprintf('Fatal Evaluation Error: Failed to import "%s" from %s on %s:%s: %s', $item, $package, $file, $line, $message)); }); // Evaluate the code @@ -220,6 +226,10 @@ { throw new ImportException(sprintf('%s: Failed to import "%s" from %s: %s', $required_file, $item, $package, $e->getMessage()), $e); } + catch(ImportException $e) + { + throw $e; + } catch (Throwable $e) { throw new ImportException(sprintf('%s: Failed to import "%s" from %s: %s', $required_file, $item, $package, $e->getMessage()), $e); diff --git a/src/ncc/Managers/ProjectManager.php b/src/ncc/Managers/ProjectManager.php index 6d6951f..7f446e2 100644 --- a/src/ncc/Managers/ProjectManager.php +++ b/src/ncc/Managers/ProjectManager.php @@ -676,14 +676,7 @@ $path = substr($path, 0, -1); } - if($path === '') - { - $destination_path .= DIRECTORY_SEPARATOR . hash('crc32', $project_path); - } - else - { - $destination_path .= DIRECTORY_SEPARATOR . hash('crc32', $path); - } + $destination_path .= DIRECTORY_SEPARATOR . hash('crc32', $project_path); if(is_file($source_path)) { From 9418125722266470ed13b64a3dc1a2b534aa626b Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 18:39:46 -0400 Subject: [PATCH 112/134] Add CLI support for passing and splitting execution arguments --- src/ncc/CLI/Commands/ExecCommand.php | 10 +++++++++- src/ncc/CLI/Main.php | 16 ++++++++++++++++ src/ncc/Classes/Runtime.php | 5 +++-- src/ncc/Utilities/Resolver.php | 19 +++++++++++++++++++ 4 files changed, 47 insertions(+), 3 deletions(-) diff --git a/src/ncc/CLI/Commands/ExecCommand.php b/src/ncc/CLI/Commands/ExecCommand.php index 4c4dfcd..4dd9647 100644 --- a/src/ncc/CLI/Commands/ExecCommand.php +++ b/src/ncc/CLI/Commands/ExecCommand.php @@ -24,9 +24,11 @@ use Exception; use ncc\Classes\Runtime; + use ncc\CLI\Main; use ncc\Objects\CliHelpSection; use ncc\Utilities\Console; use ncc\Utilities\Functions; + use ncc\Utilities\Resolver; class ExecCommand { @@ -40,6 +42,12 @@ { $package = $args['package'] ?? null; $version = $args['exec-version'] ?? 'latest'; + $program_arguments = []; + + if(isset($args['exec-args'])) + { + $program_arguments = Resolver::splitArguments(Main::getRawArgs(), '--exec-args'); + } if($package === null) { @@ -58,7 +66,7 @@ try { - return Runtime::execute($package_name); + return Runtime::execute($package_name, $program_arguments); } catch(Exception $e) { diff --git a/src/ncc/CLI/Main.php b/src/ncc/CLI/Main.php index 08c9c25..6c584ae 100644 --- a/src/ncc/CLI/Main.php +++ b/src/ncc/CLI/Main.php @@ -49,6 +49,11 @@ */ private static $args; + /** + * @var array + */ + private static $raw_args; + /** * @var LogLevel|null */ @@ -63,6 +68,7 @@ public static function start(array $argv): int { self::$args = Resolver::parseArguments(implode(' ', $argv)); + self::$raw_args = $argv; if(!isset(self::$args['ncc-cli'])) { @@ -213,6 +219,16 @@ return self::$args; } + /** + * Returns the raw arguments passed to ncc + * + * @return array + */ + public static function getRawArgs(): array + { + return self::$raw_args; + } + /** * @return LogLevel */ diff --git a/src/ncc/Classes/Runtime.php b/src/ncc/Classes/Runtime.php index fd00c99..e1ff27e 100644 --- a/src/ncc/Classes/Runtime.php +++ b/src/ncc/Classes/Runtime.php @@ -84,7 +84,7 @@ * @throws PathNotFoundException * @throws OperationException */ - public static function execute(string $package): int + public static function execute(string $package, array $arguments=[]): int { if(!self::isImported($package)) { @@ -110,7 +110,8 @@ return ExecutionUnitRunner::executeFromSystem( self::$imported_packages[$package], - Metadata::fromArray(ZiProto::decode(IO::fread($metadata_path)))->getMainExecutionPolicy() + Metadata::fromArray(ZiProto::decode(IO::fread($metadata_path)))->getMainExecutionPolicy(), + $arguments ); } diff --git a/src/ncc/Utilities/Resolver.php b/src/ncc/Utilities/Resolver.php index 02c5c56..e3b8af1 100644 --- a/src/ncc/Utilities/Resolver.php +++ b/src/ncc/Utilities/Resolver.php @@ -130,6 +130,25 @@ return $configs; } + /** + * Split arguments + * + * @param array $args List of arguments + * @param string $arg The argument to split from + * @return array Split arguments starting from specified argument + */ + public static function splitArguments(array $args, string $arg): array + { + $index = array_search($arg, $args); + + if($index === false) + { + return []; + } + + return array_slice($args, $index + 1); + } + /** * Resolves the constant's full name * From b93e07bc3d425e291224b755743e811cafc4e0c5 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 18:43:59 -0400 Subject: [PATCH 113/134] Fix argument passing in ExecCommand runner --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e2b896..60de5a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,6 +77,7 @@ This update introduces a refactored code-base, code quality improvements, and be ### Fixed - Fixed Division by zero in PackageManager + - Fixed runner argument passing for ExecCommand ### Removed - Removed EncoderType enum file, unused. From 4db07af9bb36e6002a43e92278e995ab9907657c Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 18:58:40 -0400 Subject: [PATCH 114/134] Updated ci.yml --- .github/workflows/ci.yml | 92 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e69de29..ba8faff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -0,0 +1,92 @@ +name: CI Pipeline + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + extensions: mbstring, ctype, common, zip + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y git libpq-dev libzip-dev zip make wget gnupg + + - name: Install Phive + run: | + wget -O phive.phar https://phar.io/releases/phive.phar + wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc + gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79 + gpg --verify phive.phar.asc phive.phar + chmod +x phive.phar + sudo mv phive.phar /usr/local/bin/phive + + - name: Install PHPAB + run: phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C + + - name: Build project + run: make redist + + - name: Find NCC build directory + id: find-ncc-dir + run: echo "NCC_DIR=$(find build/ -type d -name 'ncc_*' | head -n 1)" >> $GITHUB_ENV + + - name: Upload NCC build directory + uses: actions/upload-artifact@v3 + with: + name: ncc-build + path: ${{ env.NCC_DIR }} + + - name: Build Debian package + run: make deb + + - name: Find Debian package + id: find-deb + run: echo "DEB_FILE=$(find build/ -type f -name '*.deb' | head -n 1)" >> $GITHUB_ENV + + - name: Upload Debian package + uses: actions/upload-artifact@v3 + with: + name: ncc-deb + path: ${{ env.DEB_FILE }} + + test: + runs-on: ubuntu-latest + needs: build + + steps: + - name: Download NCC build directory + uses: actions/download-artifact@v3 + with: + name: ncc-build + path: build + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + extensions: mbstring, ctype, common, zip + + - name: Test NCC installation + run: | + NCC_DIR=$(find build/ -type d -name 'ncc_*' | head -n 1) + if [ -z "$NCC_DIR" ]; then + echo "NCC build directory not found" + exit 1 + fi + php $NCC_DIR/INSTALL --auto \ No newline at end of file From 1bb6189e575ba696ed4e365d02ffbe4c031bd321 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 18:59:02 -0400 Subject: [PATCH 115/134] Updated ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba8faff..d249b84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,10 +3,10 @@ name: CI Pipeline on: push: branches: - - main + - master pull_request: branches: - - main + - master jobs: build: From 6d2d827de2063383abb49d7718a8608ea8f42d6c Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 19:00:38 -0400 Subject: [PATCH 116/134] Updated ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d249b84..523f4fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,10 +3,10 @@ name: CI Pipeline on: push: branches: - - master + - '**' pull_request: branches: - - master + - '**' jobs: build: From 634f50e31740af7088d82e7b72fcbe628463d64f Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 19:02:49 -0400 Subject: [PATCH 117/134] Updated ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 523f4fc..bdceb10 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,4 +89,4 @@ jobs: echo "NCC build directory not found" exit 1 fi - php $NCC_DIR/INSTALL --auto \ No newline at end of file + php $NCC_DIR/INSTALL --auto From c9e4a6741ab3b932fbaaa094f2bda4c1db4f30d3 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 19:05:39 -0400 Subject: [PATCH 118/134] Updated ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bdceb10..595b6e5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,7 @@ jobs: sudo mv phive.phar /usr/local/bin/phive - name: Install PHPAB - run: phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C + run: sudo phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C - name: Build project run: make redist @@ -89,4 +89,4 @@ jobs: echo "NCC build directory not found" exit 1 fi - php $NCC_DIR/INSTALL --auto + php $NCC_DIR/INSTALL --auto \ No newline at end of file From e041ca2c20fef44dac51267550d2faf65c0ce413 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 19:11:23 -0400 Subject: [PATCH 119/134] Updated ci.yml --- .github/workflows/ci.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 595b6e5..c838648 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,9 +84,4 @@ jobs: - name: Test NCC installation run: | - NCC_DIR=$(find build/ -type d -name 'ncc_*' | head -n 1) - if [ -z "$NCC_DIR" ]; then - echo "NCC build directory not found" - exit 1 - fi - php $NCC_DIR/INSTALL --auto \ No newline at end of file + php ncc-build/INSTALL --auto \ No newline at end of file From 2c5733c5c08d464fbd171c47f668f939b9483d40 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 19:13:44 -0400 Subject: [PATCH 120/134] Updated ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c838648..8e980eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,4 +84,4 @@ jobs: - name: Test NCC installation run: | - php ncc-build/INSTALL --auto \ No newline at end of file + php /home/runner/work/ncc/ncc/build/INSTALL --auto \ No newline at end of file From 5eeb0d270d45675ef51a9d3b2734c2053655e638 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 19:13:55 -0400 Subject: [PATCH 121/134] Updated ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e980eb..1bb3e6d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,4 +84,4 @@ jobs: - name: Test NCC installation run: | - php /home/runner/work/ncc/ncc/build/INSTALL --auto \ No newline at end of file + php /ncc/build/INSTALL --auto \ No newline at end of file From b29c83f276e665acde1aab02f683800973815c63 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 19:14:04 -0400 Subject: [PATCH 122/134] Updated ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1bb3e6d..7353a19 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,4 +84,4 @@ jobs: - name: Test NCC installation run: | - php /ncc/build/INSTALL --auto \ No newline at end of file + php ncc/build/INSTALL --auto \ No newline at end of file From 23bd2c6636262e67b1b487a6fffd941bbbc7d2aa Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 19:16:45 -0400 Subject: [PATCH 123/134] Updated ci.yml --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7353a19..802a08e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,4 +84,6 @@ jobs: - name: Test NCC installation run: | + ls -l + ls -l ncc php ncc/build/INSTALL --auto \ No newline at end of file From 64fdc3b5bda28967fc92f3a65fe40d99c0b0cbe1 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 19:19:33 -0400 Subject: [PATCH 124/134] Updated ci.yml --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 802a08e..797d32a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,6 +84,5 @@ jobs: - name: Test NCC installation run: | - ls -l - ls -l ncc - php ncc/build/INSTALL --auto \ No newline at end of file + ls -l build + php build/INSTALL --auto \ No newline at end of file From 140b0f2aff49f2f61c13b832445233145184181b Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 19:21:55 -0400 Subject: [PATCH 125/134] Updated ci.yml --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 797d32a..f034d41 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,5 +84,4 @@ jobs: - name: Test NCC installation run: | - ls -l build - php build/INSTALL --auto \ No newline at end of file + sudo php build/INSTALL --auto \ No newline at end of file From 798fe9e79759969b4971599bea102cdaaae69ee4 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 19:26:18 -0400 Subject: [PATCH 126/134] Updated ci.yml --- .github/workflows/ci.yml | 44 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f034d41..c003a05 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,9 @@ on: pull_request: branches: - '**' + release: + types: + - created jobs: build: @@ -46,11 +49,14 @@ jobs: id: find-ncc-dir run: echo "NCC_DIR=$(find build/ -type d -name 'ncc_*' | head -n 1)" >> $GITHUB_ENV + - name: Create redist.zip + run: zip -r redist.zip ${{ env.NCC_DIR }} + - name: Upload NCC build directory uses: actions/upload-artifact@v3 with: name: ncc-build - path: ${{ env.NCC_DIR }} + path: redist.zip - name: Build Debian package run: make deb @@ -84,4 +90,38 @@ jobs: - name: Test NCC installation run: | - sudo php build/INSTALL --auto \ No newline at end of file + sudo php build/INSTALL --auto + + upload: + runs-on: ubuntu-latest + needs: build + if: github.event_name == 'release' && github.event.action == 'created' + + steps: + - name: Download NCC build directory + uses: actions/download-artifact@v3 + with: + name: ncc-build + path: build + + - name: Download Debian package + uses: actions/download-artifact@v3 + with: + name: ncc-deb + path: build + + - name: Upload redist.zip to release + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: build/redist.zip + asset_name: redist.zip + asset_content_type: application/zip + + - name: Upload ncc.deb to release + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: build/${{ env.DEB_FILE }} + asset_name: ncc.deb + asset_content_type: application/vnd.debian.binary-package \ No newline at end of file From 3640befdccdf72a0595738f19bb59cb774a41f5b Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 19:29:48 -0400 Subject: [PATCH 127/134] Updated ci.yml --- .github/workflows/ci.yml | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c003a05..71ea475 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,7 +71,7 @@ jobs: name: ncc-deb path: ${{ env.DEB_FILE }} - test: + test-install: runs-on: ubuntu-latest needs: build @@ -92,7 +92,7 @@ jobs: run: | sudo php build/INSTALL --auto - upload: + upload-release: runs-on: ubuntu-latest needs: build if: github.event_name == 'release' && github.event.action == 'created' @@ -111,17 +111,15 @@ jobs: path: build - name: Upload redist.zip to release - uses: actions/upload-release-asset@v1 + uses: softprops/action-gh-release@v1 with: - upload_url: ${{ github.event.release.upload_url }} - asset_path: build/redist.zip - asset_name: redist.zip - asset_content_type: application/zip + files: build/redist.zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Upload ncc.deb to release - uses: actions/upload-release-asset@v1 + uses: softprops/action-gh-release@v1 with: - upload_url: ${{ github.event.release.upload_url }} - asset_path: build/${{ env.DEB_FILE }} - asset_name: ncc.deb - asset_content_type: application/vnd.debian.binary-package \ No newline at end of file + files: build/${{ env.DEB_FILE }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 3b0f1a805c05279590b5394ac36c8be63106d541 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 19:35:47 -0400 Subject: [PATCH 128/134] Updated ci.yml --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 71ea475..7427fb3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,6 +90,7 @@ jobs: - name: Test NCC installation run: | + ls -l sudo php build/INSTALL --auto upload-release: From 45c58c0568bb9f282d495cd5df031b938cabcc19 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 19:37:53 -0400 Subject: [PATCH 129/134] Updated ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7427fb3..0a3cd81 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,7 +90,7 @@ jobs: - name: Test NCC installation run: | - ls -l + ls -l build sudo php build/INSTALL --auto upload-release: From 7e79bba7626e5b047d7d4ffd38019c723ddb45a5 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 19:47:30 -0400 Subject: [PATCH 130/134] Updated ci.yml --- .github/workflows/ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0a3cd81..fd8b166 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,10 +52,10 @@ jobs: - name: Create redist.zip run: zip -r redist.zip ${{ env.NCC_DIR }} - - name: Upload NCC build directory + - name: Upload redist.zip uses: actions/upload-artifact@v3 with: - name: ncc-build + name: redist-zip path: redist.zip - name: Build Debian package @@ -99,28 +99,28 @@ jobs: if: github.event_name == 'release' && github.event.action == 'created' steps: - - name: Download NCC build directory + - name: Download redist.zip uses: actions/download-artifact@v3 with: - name: ncc-build - path: build + name: redist-zip + path: . - name: Download Debian package uses: actions/download-artifact@v3 with: name: ncc-deb - path: build + path: . - name: Upload redist.zip to release uses: softprops/action-gh-release@v1 with: - files: build/redist.zip + files: redist.zip env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Upload ncc.deb to release uses: softprops/action-gh-release@v1 with: - files: build/${{ env.DEB_FILE }} + files: ${{ env.DEB_FILE }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From b2ef33d48fd664196dd135decfa2d9ba8ceee35e Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 19:49:39 -0400 Subject: [PATCH 131/134] Updated ci.yml --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd8b166..6015c16 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,6 +49,12 @@ jobs: id: find-ncc-dir run: echo "NCC_DIR=$(find build/ -type d -name 'ncc_*' | head -n 1)" >> $GITHUB_ENV + - name: Upload NCC build directory + uses: actions/upload-artifact@v3 + with: + name: ncc-build + path: ${{ env.NCC_DIR }} + - name: Create redist.zip run: zip -r redist.zip ${{ env.NCC_DIR }} From d2baa2d580f8fa920d1c63077bc49cf05dc7b943 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 19:57:18 -0400 Subject: [PATCH 132/134] Updated ci.yml --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6015c16..ae0f371 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -103,6 +103,7 @@ jobs: runs-on: ubuntu-latest needs: build if: github.event_name == 'release' && github.event.action == 'created' + permissions: write-all steps: - name: Download redist.zip From 273df6ebb45ab70995cad2efa0f59da527214154 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 20:01:55 -0400 Subject: [PATCH 133/134] Updated ci.yml --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ae0f371..234899d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -118,6 +118,9 @@ jobs: name: ncc-deb path: . + - name: Set DEB_FILE environment variable + run: echo "DEB_FILE=$(find . -type f -name '*.deb' | head -n 1)" >> $GITHUB_ENV + - name: Upload redist.zip to release uses: softprops/action-gh-release@v1 with: From adbd1d1751b1333c7cbc39954af4acd07b470bc5 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 20 Sep 2024 20:07:18 -0400 Subject: [PATCH 134/134] Updated CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60de5a7..74c826a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [2.1.0] - Ongoing +## [2.1.0] - 2024-09-20 This update introduces a refactored code-base, code quality improvements, and better exception handling.