final class PhpFile

Instance of PHP file.

Generates:

  • opening tag (<?php)
  • doc comments
  • one or more namespaces

Methods

static PhpFile
fromCode(string $code)

No description

addClass(string $name)

No description

addInterface(string $name)

No description

addTrait(string $name)

No description

addEnum(string $name)

No description

addNamespace(PhpNamespace $namespace)

No description

addFunction(string $name)

No description

array
getNamespaces()

No description

array
getClasses()

No description

array
getFunctions()

No description

addUse(string $name, string|null $alias = null, string $of = PhpNamespace::NameNormal)

No description

setStrictTypes(bool $on = true)

Adds declare(strict_types=1) to output.

bool
hasStrictTypes()

No description

bool
getStrictTypes() deprecated

No description

string
__toString()

No description

Details

at line 33
static PhpFile fromCode(string $code)

No description

Parameters

string $code

Return Value

PhpFile

at line 39
ClassType addClass(string $name)

No description

Parameters

string $name

Return Value

ClassType

at line 47
InterfaceType addInterface(string $name)

No description

Parameters

string $name

Return Value

InterfaceType

at line 55
TraitType addTrait(string $name)

No description

Parameters

string $name

Return Value

TraitType

at line 63
EnumType addEnum(string $name)

No description

Parameters

string $name

Return Value

EnumType

at line 71
PhpNamespace addNamespace(PhpNamespace $namespace)

No description

Parameters

PhpNamespace $namespace

Return Value

PhpNamespace

at line 85
GlobalFunction addFunction(string $name)

No description

Parameters

string $name

Return Value

GlobalFunction

at line 94
array getNamespaces()

No description

Return Value

array

at line 101
array getClasses()

No description

Return Value

array

at line 116
array getFunctions()

No description

Return Value

array

at line 130
PhpFile addUse(string $name, string|null $alias = null, string $of = PhpNamespace::NameNormal)

No description

Parameters

string $name
string|null $alias
string $of

Return Value

PhpFile

at line 140
PhpFile setStrictTypes(bool $on = true)

Adds declare(strict_types=1) to output.

Parameters

bool $on

Return Value

PhpFile

at line 147
bool hasStrictTypes()

No description

Return Value

bool

at line 154
bool getStrictTypes() deprecated

deprecated use hasStrictTypes()

No description

Return Value

bool

at line 161
string __toString()

No description

Return Value

string

Traits

SmartObject