@param array $plan

@return array
166002
private function validateAndNormalize(array $plan): array
    {
        if (empty($plan['steps'])) {
            throw new Exception\RuntimeException('Key "steps" must be set in plan "' . $this->name . '".');
        }

        $stepTypes = ['preflight_steps', 'clean_steps', 'steps', 'rollback_preflight_steps', 'rollback_steps'];
        $normalizedPlan = $plan;
        foreach ($stepTypes as $stepType) {
            $normalizedPlan[$stepType] = [];
            if (!empty($plan[$stepType])) {
                foreach ($plan[$stepType] as $name => $step) {
                    [$name, $step] = $this->validateAndNormalizeStep($name, $step);
                    if (!is_null($name)) {
                        $normalizedPlan[$stepType][$name] = $step;
                    } else {
                        $normalizedPlan[$stepType][] = $step;
                    }
                }
            }
        }

        return $normalizedPlan;
    }
183175
private function getOrgAndRepo(array $composer)
    {
        $target = $composer['target'];

        $matches = [];
        preg_match(self::TARGET_REGEX, $target, $matches);

        $org = $matches[1];
        $repo = $matches[2];

        return [$org, $repo];
    }
41206
function get_trial_plans( $plans ) {
			$trial_plans = array();

			if ( is_array( $plans ) && 0 < count( $plans ) ) {
				/**
				 * @var FS_Plugin_Plan[] $plans
				 */
				for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
					if ( $plans[ $i ]->has_trial() ) {
						$trial_plans[] = $plans[ $i ];
					}
				}
			}

			return $trial_plans;
		}
1141019
protected function processSection(array $section)
        {
            $config = array();

            foreach ($section as $key => $value) {
                $this->processKey($key, $value, $config);
            }

            return $config;
        }
805327
private function fetch_plan_by_id( $plan_id ) {
            $this->_logger->entrance();
            $api = $this->get_current_or_network_user_api_scope();

            $result = $api->get( "/plugins/{$this->_module_id}/plans/{$plan_id}.json", true );

            return $this->is_api_result_entity( $result ) ?
                new FS_Plugin_Plan( $result ) :
                $result;
        }
109351
public function getPlan()
    {
        if (isset($this->data['plan'])) {
            return $this->data['plan'];
        } elseif (array_key_exists('object', $this->data) && $this->data['object'] == 'plan') {
            return $this->data;
        }

        return null;
    }
725540
public function getAsArray($key)
    {
        if (! $this->has($key)) {
            return [];
        }
        $res = $this->attributes[$key];
        if (is_null($res)) {
            return [null];
        }

        return (array) $res;
    }
311775
public static String getPlanAsJSON(Plan plan) {
		PlanJSONDumpGenerator gen = new PlanJSONDumpGenerator();
		List<DataSinkNode> sinks = PactCompiler.createPreOptimizedPlan(plan);
		return gen.getPactPlanAsJSON(sinks);
	}
1228044
public function geocode($details)
    {
        $geo = $this->createGeocoder();

        try {
            $coords = $geo->geocode($details)->first()->getCoordinates();

            return [
                'lat' => $coords->getLatitude(),
                'lng' => $coords->getLongitude()
            ];
        } catch (Exception $e) {
            $this->logger->error('Error geocoding details', [
                'exception_message' => $e->getMessage(),
                'submitted_details' => $details
            ]);

            return [
                'lat' => null,
                'lng' => null
            ];
        }
    }
1151201
protected function parseInfo(array $info) {
        $return = array_shift($info);
        $params = [];
        foreach ($info as $name => $param) {
            $params[] = ["name" => $name, "type" => $param];
        }
        return [
            'return' => $return,
            'params' => $params,
        ];
    }
297569
public function getArray(array $options = array()): array
    {
        $content = $this->getContent();

        if (is_null($content)) {
            return (array)$content;
        }

        return json_decode($this->content, true);
    }
403191
protected function getPdoOptions(array $options)
    {
        $result = $this->pdoDefaultOptions;

        foreach ($options as $k => $v)
        {
            $result[$k] = $v;
        }

        return $result;
    }
549934
private function parseLine($line)
    {
        if (!$line) {
            return array();
        }

        $line = trim($line);

        if (!$line) {
            return array();
        }

        $array = array();
        $group = $this->nodeContainsGroup($line);

        if ($group) {
            $this->addGroup($line, $group);
            $line = $this->stripGroup ($line, $group);
        }
        if ($this->startsMappedSequence($line)) {
            return $this->returnMappedSequence($line);
        }
        if ($this->startsMappedValue($line)) {
            return $this->returnMappedValue($line);
        }
        if ($this->isArrayElement($line)) {
            return $this->returnArrayElement($line);
        }
        if ($this->isPlainArray($line)) {
            return $this->returnPlainArray($line);
        }

        return $this->returnKeyValuePair($line);
    }
875996
public function getPlans($page = '')
    {
        $planObjects = [];
        $plans = $this->getPlanResource()->getAll($page);

        if ($plans instanceof \Exception) {
            throw $plans;
        }

        foreach ($plans as $plan) {
            $planObject = new Plan($this->getPlanResource());
            $planObjects[] = $planObject->_setAttributes($plan);
        }

        return $planObjects;
    }
133268
public function merge(array $policies) {
        $result = parent::merge($policies);
        if($this->hasOption(static::PRIORITY_DETAILS)) {
            foreach($policies as $p) {
                $this->addResult($p);
            }
            $this->results[] = '';
        }
        return $result;
    }
293325
public function optimize(array $policiesAndSets): array
    {
        assert(empty($policiesAndSets) === false);

        $index              = 0;
        $rawTargets         = [];
        $serializedPolicies = [];
        foreach ($policiesAndSets as $policyOrSet) {
            /** @var PolicyInterface|PolicySetInterface $policyOrSet */
            $rawTargets[$index]         = $policyOrSet->getTarget();
            $serializedPolicies[$index] = $policyOrSet instanceof PolicyInterface ?
                Encoder::encodePolicy($policyOrSet) : Encoder::encodePolicySet($policyOrSet);
            $index++;
        }

        $callable         = static::METHOD;
        $optimizedTargets = $this->optimizeTargets($rawTargets);

        /** @var callable|array $callable */
        assert($callable !== null && is_array($callable) === true &&
            is_callable($callable) === true && count($callable) === 2 &&
            is_string($callable[0]) === true && is_string($callable[1]) === true);

        return [
            static::INDEX_TARGETS           => $optimizedTargets,
            static::INDEX_POLICIES_AND_SETS => $serializedPolicies,
            static::INDEX_CALLABLE          => $callable,
        ];
    }
1225297
public function newSubscription($subscription, $plan)
    {
        $container = Container::getInstance();

        if (method_exists($container, 'makeWith')) {
            return $container->makeWith(SubscriptionBuilderInterface::class, [
                'user' => $this, 'name' => $subscription, 'plan' => $plan
            ]);
        }

        return $container->make(SubscriptionBuilderInterface::class, [$this, $subscription, $plan]);
    }