Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Don't use keywords self #11313

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions src/Core/CustomMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ protected function getExtraMethodConfig($method)
}
// Lazy define methods
$lowerClass = strtolower(static::class);
if (!isset(self::$extra_methods[$lowerClass])) {
if (!isset(self::class::$extra_methods[$lowerClass])) {
$this->defineMethods();
}

return self::$extra_methods[$lowerClass][strtolower($method)] ?? null;
return self::class::$extra_methods[$lowerClass][strtolower($method)] ?? null;
}

/**
Expand All @@ -190,8 +190,8 @@ public function allMethodNames($custom = false)

// Query extra methods
$lowerClass = strtolower(static::class);
if ($custom && isset(self::$extra_methods[$lowerClass])) {
$methods = array_merge(self::$extra_methods[$lowerClass], $methods);
if ($custom && isset(self::class::$extra_methods[$lowerClass])) {
$methods = array_merge(self::class::$extra_methods[$lowerClass], $methods);
}

return $methods;
Expand All @@ -207,19 +207,19 @@ protected static function findBuiltInMethods($class = null)
{
$class = is_object($class) ? get_class($class) : ($class ?: static::class);
$lowerClass = strtolower($class);
if (isset(self::$built_in_methods[$lowerClass])) {
return self::$built_in_methods[$lowerClass];
if (isset(self::class::$built_in_methods[$lowerClass])) {
return self::class::$built_in_methods[$lowerClass];
}

// Build new list
$reflection = new ReflectionClass($class);
$methods = $reflection->getMethods(ReflectionMethod::IS_PUBLIC);
self::$built_in_methods[$lowerClass] = [];
self::class::$built_in_methods[$lowerClass] = [];
foreach ($methods as $method) {
$name = $method->getName();
self::$built_in_methods[$lowerClass][strtolower($name)] = $name;
self::class::$built_in_methods[$lowerClass][strtolower($name)] = $name;
}
return self::$built_in_methods[$lowerClass];
return self::class::$built_in_methods[$lowerClass];
}

/**
Expand Down Expand Up @@ -280,10 +280,10 @@ protected function addMethodsFrom($property, $index = null)

// Merge with extra_methods
$lowerClass = strtolower($class);
if (isset(self::$extra_methods[$lowerClass])) {
self::$extra_methods[$lowerClass] = array_merge(self::$extra_methods[$lowerClass], $newMethods);
if (isset(self::class::$extra_methods[$lowerClass])) {
self::class::$extra_methods[$lowerClass] = array_merge(self::class::$extra_methods[$lowerClass], $newMethods);
} else {
self::$extra_methods[$lowerClass] = $newMethods;
self::class::$extra_methods[$lowerClass] = $newMethods;
}
}

Expand All @@ -305,17 +305,17 @@ protected function removeMethodsFrom($property, $index = null)
}

$lowerClass = strtolower($class);
if (!isset(self::$extra_methods[$lowerClass])) {
if (!isset(self::class::$extra_methods[$lowerClass])) {
return;
}
$methods = $this->findMethodsFrom($extension);

// Unset by key
self::$extra_methods[$lowerClass] = array_diff_key(self::$extra_methods[$lowerClass], $methods);
self::class::$extra_methods[$lowerClass] = array_diff_key(self::class::$extra_methods[$lowerClass], $methods);

// Clear empty list
if (empty(self::$extra_methods[$lowerClass])) {
unset(self::$extra_methods[$lowerClass]);
if (empty(self::class::$extra_methods[$lowerClass])) {
unset(self::class::$extra_methods[$lowerClass]);
}
}

Expand All @@ -328,7 +328,7 @@ protected function removeMethodsFrom($property, $index = null)
*/
protected function addWrapperMethod($method, $wrap)
{
self::$extra_methods[strtolower(static::class)][strtolower($method)] = [
self::class::$extra_methods[strtolower(static::class)][strtolower($method)] = [
'wrap' => $wrap,
'method' => $method
];
Expand All @@ -343,7 +343,7 @@ protected function addWrapperMethod($method, $wrap)
*/
protected function addCallbackMethod($method, $callback)
{
self::$extra_methods[strtolower(static::class)][strtolower($method)] = [
self::class::$extra_methods[strtolower(static::class)][strtolower($method)] = [
'callback' => $callback,
];
}
Expand Down
8 changes: 4 additions & 4 deletions src/Core/Extensible.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public static function add_extension($classOrExtension, $extension = null)
$subclasses = ClassInfo::subclassesFor($class);
$subclasses[] = $class;
foreach ($subclasses as $subclass) {
unset(self::$extra_methods[strtolower($subclass)]);
unset(self::class::$extra_methods[strtolower($subclass)]);
}

Config::modify()
Expand Down Expand Up @@ -248,7 +248,7 @@ public static function remove_extension($extension)
$subclasses = ClassInfo::subclassesFor($class);
$subclasses[] = $class;
foreach ($subclasses as $subclass) {
unset(self::$extra_methods[strtolower($subclass)]);
unset(self::class::$extra_methods[strtolower($subclass)]);
}
}

Expand Down Expand Up @@ -300,7 +300,7 @@ public static function get_extra_config_sources($class = null)
}

// If this class is unextendable, NOP
if (in_array($class, self::$unextendable_classes)) {
if (in_array($class, self::class::$unextendable_classes)) {
return null;
}

Expand Down Expand Up @@ -364,7 +364,7 @@ public static function has_extension($classOrExtension, $requiredExtension = nul
}

$requiredExtension = Extension::get_classname_without_arguments($requiredExtension);
$extensions = self::get_extensions($class);
$extensions = self::class::get_extensions($class);
foreach ($extensions as $extension) {
if (strcasecmp($extension ?? '', $requiredExtension ?? '') === 0) {
return true;
Expand Down
Loading