@param User|string|null $user

@return callable
15108
private function prSorter($user = null)
    {
        $username = null;

        if ($user instanceof User) {
            $username = $this->getUsernameForGitHubMatching($user);
            $username = strtolower($username);
        }

        return function ($a, $b) use ($username) {
            $prA = (int) $a['number'];
            $prB = (int) $b['number'];
            $loginA = isset($a['head']['user']['login']) ? strtolower($a['head']['user']['login']) : 'unknown';
            $loginB = isset($b['head']['user']['login']) ? strtolower($b['head']['user']['login']) : 'unknown';

            if ($loginA === $loginB && $loginA === $username) {
                // Everyone is owner
                return ($prA > $prB) ? -1 : 1;

            } elseif ($loginA === $username || $loginB === $username) {
                // One is owner
                if ($loginA === $username) {
                    return -1;
                }

                if ($loginB === $username) {
                    return 1;
                }
            }

            // No one is owner
            return ($prA > $prB) ? -1 : 1;
        };
    }
914801
public function user($user = null)
    {
        if ($user !== null) {
            $this->user = $user;
        }

        return $this->user;
    }
292076
public function isOwner( $user = NULL )
	{
		$user	= $user ? $user : get_current_user();
		if( !function_exists( 'posix_getpwuid' ) )
			return TRUE;
		$uid	= fileowner( $this->fileName );
		if( !$uid )
			return TRUE;
		$owner	= posix_getpwuid( $uid );
		if( !$owner )
			return TRUE;
		print_m( $owner );
		return $user == $owner['name'];
	}
565280
public function setLastRunUser($user = null)
    {
        if (is_null($user)) {
            $user = Mage::helper('aoe_scheduler')->getRunningUser();
        }

        // Log the current user running the schedule if it's executed
        Mage::getModel('core/variable')
            ->loadByCode(Aoe_Scheduler_Helper_Data::VAR_LAST_RUN_USER_CODE)
            ->setCode(Aoe_Scheduler_Helper_Data::VAR_LAST_RUN_USER_CODE)
            ->setName('Scheduler - User Last Run As')
            ->setPlainValue((string) $user)
            ->save();

        return $this;
    }
573801
public function withUserInfo($user, $password = null)
    {
        $userInfo = implode(':', [$user, $password]);

        return $this->_clone('userInfo', rtrim($userInfo, ':'));
    }
1354546
public function me(): User
    {
        // Result is different - denormalize by hand
        $data = $this->getClient()->call(null, null, self::ENDPOINT, null, false, 'GET');

        return $this->getClient()->denormalizeObject(User::class, [$data], false);
    }
188797
public function setUser(\Claroline\CoreBundle\Entity\User $user)
    {
        $this->user = $user;

        return $this;
    }
554322
public function getUserEntity($user)
    {
        $result = null;
        if ($user instanceof UserEntity) {
            $result = $user;
        } else {
            $u = $this->getUser($user);
            if ($u !== null) {
                $result = $this->app->make(EntityManager::class)->find(UserEntity::class, $u->getUserID());
            }
        }

        return $result;
    }
1261380
public function user($user = null)
    {
        if ($user !== null) {
            $this->_user = $user;

            return;
        }

        if ($this->_user === false) {
            if (($session = $this->getSession()) && $session->id) {
                $this->_user = auth()->who($session);
            } else {
                $this->_user = null;
            }
        }

        return $this->_user;
    }
1008408
protected function tryChangeUser($user)
    {
        $changed_user = false;
        // Check user can be changed?
        if ($user && posix_getuid() > 0) {
            // Not root
            throw new \RuntimeException('Only root can change user to spawn the process');
        }

        // Check user if exists?
        if ($user && !($changed_user = posix_getpwnam($user))) {
            throw new \RuntimeException('Can not look up user: ' . $user);
        }

        return $changed_user;
    }
153360
private function getCommand($user = null)
    {
        $command = $this->executable;

        if ($user) {
            $command .= ' -u' . $user;
        }

        return $command;
    }
154105
public function setUser($user)
    {
        $this->removeTarget();

        if ($user) {
            $this->user = (string) $user;
        }

        return $this;
    }
102876
public function userCreate($user)
    {
        $this->dispatchHooks('BeforeUserCreateScope', $user);
        $this->parseEntityFields('user', $user);
        $this->getDriver()->userCreate($user);
        $this->dispatchHooks('AfterUserCreateScope', $user);
        $this->userManager->addUser($user);
        return $user;
    }
334002
protected function CanEdit(User $user)
    {
        return self::Guard()->Allow(BackendAction::Edit(), $user)&&
            self::Guard()->Allow(BackendAction::UseIt(), new UserForm());
    }
294119
public function createUserRole(User $user)
    {
        $username = $user->getUsername();
        $roleName = 'ROLE_USER_'.strtoupper($username);
        $role = $this->getRoleByName($roleName);

        $this->om->startFlushSuite();

        if (is_null($role)) {
            $role = new Role();
            $role->setName($roleName);
            $role->setTranslationKey($username);
            $role->setReadOnly(true);
            $role->setType(Role::USER_ROLE);
            $this->om->persist($role);
        }

        $user->addRole($role);
        $this->om->endFlushSuite();

        return $role;
    }
27351
protected function FormUrl(User $user = null)
    {
        $args = array();
        if ($user)
        {
            $args['user'] = $user->GetID();
        }
        return BackendRouter::ModuleUrl(new UserForm(), $args); 
    }
202372
protected function _getCurrentUser($user = null)
    {
        $this->_setCurrentUser($user);

        if (!$this->_currentUserInstance &&
            isset($this->_currentUserViewVar) &&
            !empty($this->viewVars[$this->_currentUserViewVar])
        ) {
            $this->_currentUserInstance = $this->viewVars[$this->_currentUserViewVar];
        }

        return $this->_currentUserInstance;
    }