Unserialize attempt useranswer and add missing responseformat if needed
for compatibility with old records.

@param string $useranswer serialized object
@return object
336132
static public function extract_useranswer($useranswer) {
        $essayinfo = unserialize($useranswer);
        if (!isset($essayinfo->responseformat)) {
            $essayinfo->response = text_to_html($essayinfo->response, false, false);
            $essayinfo->responseformat = FORMAT_HTML;
        }
        return $essayinfo;
    }
1356720
private function updateUserByOAuthUserResponse(UserInterface $user, UserResponseInterface $response): SyliusUserInterface
    {
        /** @var SyliusUserInterface $user */
        Assert::isInstanceOf($user, SyliusUserInterface::class);

        /** @var UserOAuthInterface $oauth */
        $oauth = $this->oauthFactory->createNew();
        $oauth->setIdentifier($response->getUsername());
        $oauth->setProvider($response->getResourceOwner()->getName());
        $oauth->setAccessToken($response->getAccessToken());
        $oauth->setRefreshToken($response->getRefreshToken());

        $user->addOAuthAccount($oauth);

        $this->userManager->persist($user);
        $this->userManager->flush();

        return $user;
    }
655491
public function quarterback($createUserCommand) {

        // Get inputs into array
        $data = (array) $createUserCommand;


        // Sanitize
        $data = $this->sanitize($data, "create");

        // Wash the phone number
        if (isset($data['phone_number'])) {
            $data['phone_number'] = $this->repository->washPhoneNumber($data['phone_number']);
        }


        // Validate
        if ($this->validate($data, "create") != "passed") {
            // Prepare the response array, and then return to the edit form with error messages
            return $this->prepareResponseArray('validation_failed', 500, $data, $this->validate($data, "create"));
        }

        // Extra user validation
        $extraUserValidation = $this->extraUserValidation->extraValidation($data, false);

        if ($extraUserValidation['status_text'] != "extra_validation_successful") {
            // Prepare the response array, and then return to the edit form with error messages
            return $this->prepareResponseArray('validation_failed', 500, $data, $extraUserValidation['errorMessages']);
        }

        // Create
        if ( !$this->repository->createUser($data) ) {
            // Prepare the response array, and then return to the edit form with error messages
            // Laravel's https://github.com/laravel/framework/blob/5.0/src/Illuminate/Database/Eloquent/Model.php
            //  does not prepare a MessageBag object, so we'll whip up an error message in the
            //  originating controller
            return $this->prepareResponseArray('persist_failed', 500, $data);
        }

        // Prepare the response array, and then return to the command
        return $this->prepareResponseArray('create_successful', 200, $data);
    }
539290
public function isAnswerAllowed(UserInterface $user, $answer)
    {
        $answerEntity = $this->getEntityManagerAnswer()->getAnswer4UserId($user->getId());

        if (!$answerEntity) {
            return true;
        }

        // @TODO better workflow, with ZendFilter
        $realAnswer = strtolower(trim($answerEntity->getAnswer()));
        $plainAnswer = strtolower(trim($answer));

        return $realAnswer === $plainAnswer;
    }
1120645
protected function persist(ImportMapperInterface $userMapper)
    {
        if (!$userMapper instanceof UserMapperInterface) {
            throw new \Exception('Mapper should be a UserMapper');
        }

        $plainPassword = $userMapper->getPlainPassword();
        $properties    = $userMapper->getProperties();

        $class = $this->getUserClass($properties);

        $results = $class->searchInstances(
            [
                UserRdf::PROPERTY_LOGIN => $properties[UserRdf::PROPERTY_LOGIN]
            ],
            [
                'like' => false,
                'recursive' => true
            ]
        );

        if(count($results) > 0){
            $resource = $this->mergeUserProperties(current($results), $properties);
        } else {
            $resource = $class->createInstanceWithProperties($properties);
        }

        $this->triggerUserUpdated($resource, $properties, $plainPassword);

        return $resource;
    }
751310
public function unserialize($subscription): self
    {
        $data = json_decode($subscription, true);

        $this->operationName = $data['operation_name'];
        $this->channel = $data['channel'];
        $this->args = $data['args'];
        $this->context = $this->contextSerializer()->unserialize(
            $data['context']
        );
        $this->query = AST::fromArray(
            unserialize($data['query'])
        );

        return $this;
    }
780971
public function unserialize($serialized)
    {
        $data = unserialize($serialized);

        // add a few extra elements in the array to ensure that we have enough keys when unserializing
        // older data which does not include all properties.
        $data = array_merge($data, array_fill(0, 4, null));

        list(
            $this->providerID,
            $this->authenticationServiceName,
            $this->sessionIndex,
            $this->nameID,
            $this->nameIDFormat,
            $this->createdOn
            ) = $data;
    }
363477
public function getUserId(UserServiceInterface $userService)
    {
        $user = $this->getAndLogUserByCookie($userService);
        return $user ? $user->getId() : null;
    }
234774
public function unserialize($serialized)
    {
        list(
            $this->id,
            $this->username,
            $this->password,
            $this->salt,
            $this->roles
            ) = unserialize($serialized, []);
    }
539428
public function requestRememberPasswordAction(Request $request, $userClass)
    {
        $form = $this->get('form.factory')->createNamedBuilder('', RequestRememberPasswordType::class, null, [
            'csrf_protection' => false,
        ])->getForm();

        $form->handleRequest($request);
        if ($form->isValid()) {
            try {
                $this->get('bengor_user.' . $userClass . '.api_command_bus')->handle(
                    $form->getData()
                );

                return new JsonResponse();
            } catch (UserDoesNotExistException $exception) {
                return new JsonResponse(
                    sprintf(
                        'The "%s" user email does not exist ',
                        $form->getData()->email()
                    ),
                    400
                );
            }
        }

        return new JsonResponse(FormErrorSerializer::errors($form), 400);
    }
1303211
public function unserialize($input)
    {
        // Unserialize the executable, args, options, data, and inputs.
        list($this->calledScript, $this->args, $this->filter, $this->data, $this->inputs) = unserialize($input);

        $this->filter = $this->filter ?: new NullFilter();
    }
235889
public function unserialize($serialized) // [\SplDoublyLinkedList]
	{
		try
		{
			if(null === $this->last)
			{
				$this->first = unserialize($serialized);
			}
			else
			{
				$this->last->next = unserialize($serialized);
			}
		}
		catch(\Exception $e)
		{
			$error = $e->getMessage();
			
			throw new UnserializeException(substr($error, strpos($error, ': ') + 2));
		}
		
		$n    = 0;
		$iter = $this->first;
		$last = null;
		
		while(null !== $iter)
		{
			$last = $iter;
			$iter = $iter->next;
			++$n;
		}
		
		$this->last = $last;
		$this->size = $n;
	}
1009658
public function normalize($userAgent)
    {
        $userAgent = str_ireplace('blackberry', 'BlackBerry', $userAgent);
        $pos       = strpos($userAgent, 'BlackBerry');

        if ($pos !== false && $pos > 0) {
            $userAgent = substr($userAgent, $pos);
        }

        return $userAgent;
    }
317368
public function deleteUser($userId)
    {
        // Forget remembered users.
        $this->userEntities = [];

        $query = $this->deleteUserQuery($userId);

        return $query->execute();
    }
651703
public function getToken(UserSession $user): Token
    {
        // @todo Test that the expiresAfter() call works. We don't want to be caught
        // by cron etc.
        $item = $this->cacheItemPool->getItem($this->cacheKey($user));

        if (!$item->isHit()) {
            throw new TokenNotFoundException($user);
        }

        return $item->get();
    }
606379
public function invalidateUnusedTokens(AuthenticationRecordInterface $authenticationRecord)
    {
        $query = $this->getRepository()->createQueryBuilder('r')
            ->update()
            ->set('r.status', UserResetTokenInterface::STATUS_INVALID)
            ->where('r.authentication = :authentication')
            ->andWhere('r.status = :status_unused')
            ->setParameters([
                'authentication' => $authenticationRecord,
                'status_unused' => UserResetTokenInterface::STATUS_UNUSED,
            ])
            ->getQuery();

        $query->execute();
    }
25961
public function next(): Answer
    {
        if ($this->calledCount > $this->lastIndex) {
            $index = $this->lastIndex;
        } else {
            $index = $this->calledCount;
        }

        ++$this->calledCount;

        if (
            !isset($this->answers[$index]) ||
            !$this->answers[$index]->primaryRequest()
        ) {
            throw new UndefinedAnswerException();
        }

        return $this->answers[$index];
    }