Skip to content

Commit

Permalink
chore(app): streamlining setters and getters
Browse files Browse the repository at this point in the history
  • Loading branch information
razshare committed Jul 3, 2024
1 parent ec68534 commit 8ab62b7
Show file tree
Hide file tree
Showing 58 changed files with 267 additions and 267 deletions.
28 changes: 14 additions & 14 deletions src/lib/Core/AttributeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AttributeResolver {
* @param string $attributeName
* @return false|array<ReflectionAttribute<object>>
*/
public static function getClassAttributeArguments(ReflectionClass $reflectionClass, string $attributeName): false|array {
public static function classAttributeArguments(ReflectionClass $reflectionClass, string $attributeName): false|array {
$attributes = $reflectionClass->getAttributes();
foreach ($attributes as $attribute) {
$className = $attribute->getName();
Expand All @@ -32,7 +32,7 @@ public static function getClassAttributeArguments(ReflectionClass $reflectionCla
* @param string $attributeName
* @return false|string
*/
public static function issetClassAttribute(ReflectionClass $reflectionClass, string $attributeName): false|string {
public static function classAttribute(ReflectionClass $reflectionClass, string $attributeName): false|string {
$attributes = $reflectionClass->getAttributes();
foreach ($attributes as $attribute) {
$className = $attribute->getName();
Expand All @@ -49,7 +49,7 @@ public static function issetClassAttribute(ReflectionClass $reflectionClass, str
* @param string $attributeName
* @return false|array<mixed>
*/
public static function getFunctionAllAttributesArguments(ReflectionFunction $reflection_function, string $attributeName): false|array {
public static function functionAllAttributesArguments(ReflectionFunction $reflection_function, string $attributeName): false|array {
$arguments = [];
$attributes = $reflection_function->getAttributes();
foreach ($attributes as $attribute) {
Expand All @@ -67,7 +67,7 @@ public static function getFunctionAllAttributesArguments(ReflectionFunction $ref
* @param string $attributeName
* @return false|array<mixed>
*/
public static function getFunctionAttributeArguments(ReflectionFunction $reflection_function, string $attributeName): false|array {
public static function functionAttributeArguments(ReflectionFunction $reflection_function, string $attributeName): false|array {
$attributes = $reflection_function->getAttributes();
foreach ($attributes as $attribute) {
$className = $attribute->getName();
Expand All @@ -84,7 +84,7 @@ public static function getFunctionAttributeArguments(ReflectionFunction $reflect
* @param string $attributeName
* @return false|array<string>
*/
public static function issetFunctionAttributes(ReflectionFunction $reflectionFunction, string $attributeName): false|array {
public static function functionAttributes(ReflectionFunction $reflectionFunction, string $attributeName): false|array {
$attributes = $reflectionFunction->getAttributes();
$result = [];
foreach ($attributes as $attribute) {
Expand All @@ -107,7 +107,7 @@ public static function issetFunctionAttributes(ReflectionFunction $reflectionFun
* @param string $attributeName
* @return false|string
*/
public static function issetFunctionAttribute(ReflectionFunction $reflectionFunction, string $attributeName): false|string {
public static function functionAttribute(ReflectionFunction $reflectionFunction, string $attributeName): false|string {
$attributes = $reflectionFunction->getAttributes();
foreach ($attributes as $attribute) {
$className = $attribute->getName();
Expand All @@ -124,7 +124,7 @@ public static function issetFunctionAttribute(ReflectionFunction $reflectionFunc
* @param string $attributeName
* @return false|array<mixed>
*/
public static function getMethodAttributeArguments(ReflectionMethod $reflectionMethod, string $attributeName): false|array {
public static function methodAttributeArguments(ReflectionMethod $reflectionMethod, string $attributeName): false|array {
$attributes = $reflectionMethod->getAttributes();
foreach ($attributes as $attribute) {
$className = $attribute->getName();
Expand All @@ -141,7 +141,7 @@ public static function getMethodAttributeArguments(ReflectionMethod $reflectionM
* @param string $attributeName
* @return false|string
*/
public static function issetMethodAttribute(ReflectionMethod $reflectionMethod, string $attributeName): false|string {
public static function methodAttribute(ReflectionMethod $reflectionMethod, string $attributeName): false|string {
$attributes = $reflectionMethod->getAttributes();
foreach ($attributes as $attribute) {
$className = $attribute->getName();
Expand All @@ -158,7 +158,7 @@ public static function issetMethodAttribute(ReflectionMethod $reflectionMethod,
* @param string $attributeName
* @return false|array<mixed>
*/
public static function getPropertyAttributeArguments(ReflectionProperty $reflectionProperty, string $attributeName): false|array {
public static function propertyAttributeArguments(ReflectionProperty $reflectionProperty, string $attributeName): false|array {
$attributes = $reflectionProperty->getAttributes();
foreach ($attributes as $attribute) {
$className = $attribute->getName();
Expand All @@ -175,7 +175,7 @@ public static function getPropertyAttributeArguments(ReflectionProperty $reflect
* @param string $attributeName
* @return false|string
*/
public static function issetPropertyAttribute(ReflectionProperty $reflectionProperty, string $attributeName): false|string {
public static function propertyAttribute(ReflectionProperty $reflectionProperty, string $attributeName): false|string {
$attributes = $reflectionProperty->getAttributes();
foreach ($attributes as $attribute) {
$className = $attribute->getName();
Expand All @@ -192,7 +192,7 @@ public static function issetPropertyAttribute(ReflectionProperty $reflectionProp
* @param string $attributeName
* @return false|array<mixed>
*/
public static function getParameterAttributeArguments(ReflectionParameter $reflectionParameter, string $attributeName): false|array {
public static function parameterAttributeArguments(ReflectionParameter $reflectionParameter, string $attributeName): false|array {
$attributes = $reflectionParameter->getAttributes();
foreach ($attributes as $attribute) {
$className = $attribute->getName();
Expand All @@ -209,7 +209,7 @@ public static function getParameterAttributeArguments(ReflectionParameter $refle
* @param string $attributeName
* @return false|array<mixed>
*/
public static function getParameterAllAttributeArguments(ReflectionParameter $reflectionParameter, string $attributeName): false|array {
public static function parameterAllAttributeArguments(ReflectionParameter $reflectionParameter, string $attributeName): false|array {
$arguments = [];
$attributes = $reflectionParameter->getAttributes();
foreach ($attributes as $attribute) {
Expand All @@ -227,7 +227,7 @@ public static function getParameterAllAttributeArguments(ReflectionParameter $re
* @param string $attributeName
* @return false|array<string>
*/
public static function issetParameterAttributes(ReflectionParameter $reflectionParameter, string $attributeName): false|array {
public static function parameterAttributes(ReflectionParameter $reflectionParameter, string $attributeName): false|array {
$attributes = $reflectionParameter->getAttributes();
$result = [];
foreach ($attributes as $attribute) {
Expand All @@ -250,7 +250,7 @@ public static function issetParameterAttributes(ReflectionParameter $reflectionP
* @param string $attributeName
* @return false|string
*/
public static function issetParameterAttribute(ReflectionParameter $reflectionParameter, string $attributeName): false|string {
public static function parameterAttribute(ReflectionParameter $reflectionParameter, string $attributeName): false|string {
$attributes = $reflectionParameter->getAttributes();
foreach ($attributes as $attribute) {
$className = $attribute->getName();
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Core/Attributes/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public static function findNameByInterface(string $interfaceName):Unsafe {
/** @var array<string,array<string>> */
private static array $aliases = [];

public static function setAlias(string $name, string $alias):void {
public static function withAlias(string $name, string $alias):void {
if (!isset(self::$aliases[$name])) {
self::$aliases[$name] = [];
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Core/CommandStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
* @param int $code
* @return string
*/
public static function getReason(int $code): string {
public static function reason(int $code): string {
static $reasons = [
0 => 'Success',
1 => 'Operation not permitted',
Expand Down
8 changes: 4 additions & 4 deletions src/lib/Core/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ private static function findFunctionDependencies(

$isOptional = $wrappedType->allowsDefaultValue() || $wrappedType->allowsNullValue();
$defaultValue = match ($wrappedType->allowsDefaultValue()) {
true => $wrappedType->getDefaultValue(),
true => $wrappedType->defaultValue(),
default => match ($wrappedType->allowsBoolean() || $wrappedType->allowsFalse()) {
true => false,
default => null,
Expand Down Expand Up @@ -309,7 +309,7 @@ public static function dependencies(
}

if ($parameters[$key] instanceof StorageInterface) {
$parameters[$key] = &$parameters[$key]->getStorage();
$parameters[$key] = &$parameters[$key]->storage();
}
}
} catch(Throwable $e) {
Expand Down Expand Up @@ -470,7 +470,7 @@ public static function get(string $name, ...$args):Unsafe {
return error("Interface `$name` doesn't seem to be provided.\nMake sure you're providing it by invoking `Container::provide()` or by adding the `#[Provider]` attribute to any class that implements it.");
}

Provider::setAlias($providerClassName, $name);
Provider::withAlias($providerClassName, $name);

// @phpstan-ignore-next-line
return self::get($providerClassName, ...$args);
Expand All @@ -485,7 +485,7 @@ public static function get(string $name, ...$args):Unsafe {

$reflection = new ReflectionClass($name);

if (AttributeResolver::issetClassAttribute($reflection, Attribute::class)) {
if (AttributeResolver::classAttribute($reflection, Attribute::class)) {
return error("Cannot instantiate $name because it's meant to be an attribute.");
}

Expand Down
6 changes: 3 additions & 3 deletions src/lib/Core/ExecuteResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ public function __construct(
/**
* @return int
*/
function getCode() : int {
function code() : int {
return $this->code;
}

/**
* @return string
*/
function getOutput() : string {
function output() : string {
return $this->output;
}

/**
* @return string
*/
function getError() : string {
function error() : string {
return $this->error;
}

Expand Down
10 changes: 5 additions & 5 deletions src/lib/Core/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @param string $fileName
* @return Unsafe<int>
*/
public static function getSize(string $fileName):Unsafe {
public static function size(string $fileName):Unsafe {
$size = filesize($fileName);
if (false === $size) {
return error("Could not retrieve size of file $fileName.");
Expand Down Expand Up @@ -102,7 +102,7 @@ public static function copy(string $from, string $to):Unsafe {
return error($error);
}

$stream = $source->getAmpFile();
$stream = $source->ampFile();

return $destination->writeStream($stream);
}
Expand All @@ -112,7 +112,7 @@ public static function copy(string $from, string $to):Unsafe {
* @param string $fileName
* @return Unsafe<array<mixed>>
*/
public static function getStatus(string $fileName):Unsafe {
public static function status(string $fileName):Unsafe {
$status = getStatus($fileName);
if (null === $status) {
return error("Could not get status of file $fileName because it doesn't exist.");
Expand All @@ -124,7 +124,7 @@ public static function getStatus(string $fileName):Unsafe {
* @param string $fileName
* @return Unsafe<int>
*/
public static function getModificationTime(string $fileName):Unsafe {
public static function modificationTime(string $fileName):Unsafe {
try {
$mtime = getModificationTime($fileName);
return ok($mtime);
Expand Down Expand Up @@ -510,7 +510,7 @@ public function readAll(int $chunkSize = 8192):Unsafe {
/**
* @return AmpFile
*/
public function getAmpFile():AmpFile {
public function ampFile():AmpFile {
return $this->ampFile;
}

Expand Down
8 changes: 4 additions & 4 deletions src/lib/Core/FileName.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private static function asFileName(array $path):string {
return join($parts)?:'';
}

private static function getAbsolutePath(string $path):string {
private static function absolutePath(string $path):string {
$root = match (true) {
str_starts_with($path, './') => './',
str_starts_with($path, '../') => '../',
Expand Down Expand Up @@ -84,13 +84,13 @@ public function __toString(): string {
if ($this->usingPhar) {
$pharFileName = "$phar/$localizedFileName";
if (!file_exists($pharFileName)) {
return self::getAbsolutePath($localizedFileName);
return self::absolutePath($localizedFileName);
}
return $pharFileName;
}
return self::getAbsolutePath($localizedFileName);
return self::absolutePath($localizedFileName);
} else {
return self::getAbsolutePath(self::asFileName($this->path));
return self::absolutePath(self::asFileName($this->path));
}
}
}
Loading

0 comments on commit 8ab62b7

Please sign in to comment.