What potential pitfalls should developers be aware of when transitioning from global functions to classes in PHP?

One potential pitfall developers should be aware of when transitioning from global functions to classes in PHP is namespace collisions. To avoid this issue, developers should properly namespace their classes to prevent conflicts with other classes or functions. Additionally, developers should refactor their code to ensure that all function calls are updated to use the new class methods.

<?php

namespace MyNamespace;

class MyClass {
    public function myFunction() {
        // code here
    }
}

// Before transition
myFunction();

// After transition
$myClass = new MyClass();
$myClass->myFunction();