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

(Refactor) Naming Style #1547

Merged
merged 84 commits into from
Dec 31, 2020
Merged

(Refactor) Naming Style #1547

merged 84 commits into from
Dec 31, 2020

Conversation

HDVinnie
Copy link
Collaborator

Naming Refactors Performed In This PR

Make Bool Property Respect Is Has Was Method Naming

Renames property to respect is/has/was method naming

 class SomeClass
 {
-    private $full = false;
+    private $isFull = false;

     public function isFull()
     {
-        return $this->full;
+        return $this->isFull;
     }
+
 }

Make Getter Class Method Name Start With Get

Change getter method names to start with get/provide

 class SomeClass
 {
     /**
      * @var string
      */
     private $name;

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

Make Isser Class Method Name Start With Is

Change is method names to start with is/has/was

 class SomeClass
 {
     /**
      * @var bool
      */
     private $isActive = false;

-    public function getIsActive()
+    public function isActive()
     {
         return $this->isActive;
     }
 }

Rename Foreach Value Variable To Match Method Call Return Type

Renames value variable name in foreach loop to match method type

 class SomeClass
 {
     public function run()
     {
         $array = [];
-        foreach ($object->getMethods() as $property) {
-            $array[] = $property;
+        foreach ($object->getMethods() as $method) {
+            $array[] = $method;
         }
     }
 }

Rename Param To Match Type

Rename variable to match new ClassType

 final class SomeClass
 {
-    public function run(Apple $pie)
+    public function run(Apple $apple)
     {
-        $food = $pie;
+        $food = $apple;
     }
 }

Rename Property To Match Type

Rename property and method param to match its type

 class SomeClass
 {
     /**
      * @var EntityManager
      */
-    private $eventManager;
+    private $entityManager;

-    public function __construct(EntityManager $eventManager)
+    public function __construct(EntityManager $entityManager)
     {
-        $this->eventManager = $eventManager;
+        $this->entityManager = $entityManager;
     }
 }

Rename Variable To Match Method Cal lReturn Type

Rename variable to match method return type

 class SomeClass
 {
     public function run()
     {
-        $a = $this->getRunner();
+        $runner = $this->getRunner();
     }

     public function getRunner(): Runner
     {
         return new Runner();
     }
 }

Rename Variable To Match New Type

Rename variable to match new ClassType

 final class SomeClass
 {
     public function run()
     {
-        $search = new DreamSearch();
-        $search->advance();
+        $dreamSearch = new DreamSearch();
+        $dreamSearch->advance();
     }
 }

Underscore To CamelCase Local Variable Name

Change under_score local variable names to camelCase

 final class SomeClass
 {
     public function run($a_b)
     {
-        $some_value = $a_b;
+        $someValue = $a_b;
     }
 }

Underscore To CamelCase Property Name

Change under_score names to camelCase

 final class SomeClass
 {
-    public $property_name;
+    public $propertyName;

     public function run($a)
     {
-        $this->property_name = 5;
+        $this->propertyName = 5;
     }
 }

Underscore To CamelCase Variable Name

Change under_score names to camelCase

 final class SomeClass
 {
-    public function run($a_b)
+    public function run($aB)
     {
-        $some_value = $a_b;
+        $someValue = $aB;
     }
 }

@HDVinnie HDVinnie added the WIP label Dec 30, 2020
@HDVinnie HDVinnie removed the WIP label Dec 30, 2020
@HDVinnie HDVinnie removed the Review label Dec 31, 2020
@HDVinnie HDVinnie merged commit 1881470 into master Dec 31, 2020
@HDVinnie HDVinnie deleted the Naming-Style branch December 31, 2020 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant