@since 2.4.3
@since 2.10.0 Improved: multiple version

@param string $content

@return array
963018
private function parse_update_notice( $content ) {
		$notices         = [];
		$version_notices = [];
		if ( preg_match( '#==\s*Upgrade Notice\s*==([\s\S]+?)==#', $content, $matches ) ) {
			$version = false;
			foreach ( (array) preg_split( '~[\r\n]+~', trim( $matches[1] ) ) as $line ) {
				$line = preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line );
				$line = preg_replace( '#\A\s*\*+\s*#', '', $line );
				if ( preg_match( '#\A\s*=\s*([^\s]+)\s*=\s*\z#', $line, $m1 ) && preg_match( '#\s*(v\.?)?(\d+[\d.]*)*\s*#', $m1[1], $m2 ) ) {
					$version = $m2[2];
					continue;
				}
				if ( $version && version_compare( $version, $this->app->get_plugin_version(), '<=' ) ) {
					continue;
				}
				$line = preg_replace( '#\A\s*=\s*([^\s]+)\s*=\s*\z#', '[ $1 ]', $line );
				$line = trim( $line );
				if ( '' !== $line ) {
					if ( $version ) {
						$version_notices[ $version ][] = $line;
					} else {
						$notices[] = $line;
					}
				}
			}
			if ( ! empty( $version_notices ) ) {
				ksort( $version_notices );
				foreach ( $version_notices as $version => $items ) {
					$notices[ $version ] = $items;
				}
			}
		}

		return $notices;
	}
549426
protected function parseContent($content) {
		$lines  = explode(PHP_EOL, $content);
		$result = [];
		
		foreach ($lines as $lineNm => $lineRaw) {
			if (empty($lineRaw)) {
				continue;
			}
			
			$line = str_getcsv($lineRaw, $this->csvDelimiter, $this->csvEnclosure);
			
			// Lack of data detection
			if (count($line) < 2) {
				$template = 'Error has occurred while parsing CSV file for the file: "%s" on line %s';
				throw new ParseError(sprintf($template, $this->lastFilePath, $lineNm));
			}
			
			$id = trim($line[0]);
			
			// Override detection
			if (isset($result[$id])) {
				$template = 'Translation with ID "%s" is already defined in the file "%s"';
				throw new ParseError(sprintf($template, $id, $this->lastFilePath));
			}
			
			$result[$id] = trim($line[1]);
		}
		
		return $result;
	}
1016051
public function getShortcodesFromContent($content)
    {
        $content = $this->getContentWithoutIgnoreBlocks($content);

        if (false === strpos($content, '[')) {
            return [];
        }

        $result = [];

        $regex = "\[([A-Za-z_]+[^\ \]]+)";
        preg_match_all('/' . $regex . '/', $content, $matches);

        if (!empty($matches[1])) {
            foreach ($matches[1] as $match) {
                $result[$match] = $match;
            }
        }

        if ($result) {
            return array_keys($result);
        }

        return $result;
    }
993341
public static function extractImports($content)
    {
        $imports = array();
        static::filterImports($content, function($matches) use(& $imports) {
            $imports[] = $matches['url'];
        });

        return array_unique($imports);
    }
1172894
protected function _parseLoopEntities($content) {
		preg_match_all('/\bforeach \(\$([a-z]+) as \$([a-z]+)\)/i', $content, $matches);
		if (empty($matches[2])) {
			return [];
		}

		$result = [];

		foreach ($matches[2] as $key => $entity) {
			if (Inflector::pluralize($entity) !== $matches[1][$key]) {
				continue;
			}

			$entityName = Inflector::camelize(Inflector::underscore($entity));

			$className = App::className(($this->getConfig(static::CONFIG_PLUGIN) ? $this->getConfig(static::CONFIG_PLUGIN) . '.' : '') . $entityName, 'Model/Entity');
			if (!$className) {
				continue;
			}

			$result[$matches[1][$key]] = AnnotationFactory::createOrFail(VariableAnnotation::TAG, '\\' . $className . '[]|\Cake\Collection\CollectionInterface', '$' . $matches[1][$key]);
			// We do not need the singular then
			$result[$entity] = null;
		}

		return $result;
	}
848228
private static function getPlaceholders(string $content): array
    {
        $result = [];
        $matchCount = preg_match_all(static::getPlaceholderPattern(), $content, $result);

        if (false !== $matchCount && 0 < $matchCount) {
            foreach ($result as $index => $placeholders) {
                $result[$index] = array_unique($placeholders);
            }
        }

        return $result;
    }
686730
protected function _parseFormEntities($content) {
		preg_match_all('/\$this-\>Form->create\(\$(\w+)\W/i', $content, $matches);
		if (empty($matches[1])) {
			return [];
		}

		$result = [];

		$entities = array_unique($matches[1]);
		foreach ($entities as $entity) {
			$entityName = Inflector::camelize(Inflector::underscore($entity));

			$className = App::className(($this->getConfig(static::CONFIG_PLUGIN) ? $this->getConfig(static::CONFIG_PLUGIN) . '.' : '') . $entityName, 'Model/Entity');
			if (!$className) {
				continue;
			}

			$annotation = AnnotationFactory::createOrFail(VariableAnnotation::TAG, '\\' . $className, '$' . $entity);

			$result[$entity] = $annotation;
		}

		return $result;
	}
197510
protected function unpack($content)
    {
        if ( !is_array($content) ) return null;

        if ( $content['ttl'] > 0 && time() >= $content['time'] + $content['ttl'] ) {
            $this->remove($content['key']);

            return null;
        }

        return $content['value'];
    }
1347549
protected function _parseHelpersInContent($content) {
		preg_match_all('/\$this-\>([A-Z][A-Za-z]+)-\>/', $content, $matches);
		if (empty($matches[1])) {
			return [];
		}

		$helpers = array_unique($matches[1]);

		return $helpers;
	}
1191419
protected function _getIndexDefinitions( $content )
	{
		$defs = array( );
		$matches = array( );

		if ( preg_match_all('/CREATE [a-zA-Z]* ?INDEX \"?([a-zA-Z0-9_]+)\"? ON \"?([a-zA-Z0-9_]+)\"? .+(\n\n|$)/sU', $content, $matches, PREG_SET_ORDER) === false ) {
			throw new MW_Setup_Exception('Unable to get index definitions');
		}

		foreach ( $matches as $match ) {
			$name = $match[2] . '.' . $match[1];
			$defs[$name] = $match[0];
		}

		return $defs;
	}
115553
public function getFunctions(string $content): array
    {

        $functions = array();

        $tokenised_content = $this->getTokenisedContent($content);

        // Check for $tokenised_content["methods"];
        if (isset($tokenised_content["methods"])) {
            $functions = $tokenised_content["methods"];
        } elseif (isset($tokenised_content["functions"])) {
            $functions = $tokenised_content["functions"];
        }

        return $functions;

    }
205098
protected function _getUsedModels($content) {
		preg_match_all('/\$this-\>loadModel\(\'([a-z.\/]+)\'/i', $content, $matches);
		if (empty($matches[1])) {
			return [];
		}

		$models = $matches[1];

		return array_unique($models);
	}
563154
public function getMD($content)
    {
        $funcArr = ["yamlfrontmatter", "shortcode", "markdown", "titlefromheader"];
        $textFilter = new textFilter();
        return $textFilter->parse($content, $funcArr)->text;
    }
800425
public function parse($content)
    {
        if (!$content || strpos($content, '@') === false) {
            return [];
        }
        $ret = [];

        if (preg_match(self::VIEW_RENDER, $content, $match)) {
            $ret[0] = array_pop($match);
        } else {
            $ret[0] = null;
        }

        if (preg_match(self::VIEW_TEMPLATE_FILE, $content, $match)) {
            $ret[1] = array_pop($match);
        } else {
            $ret[1] = null;
        }

        if (preg_match_all(self::VIEW_PARAMETERS, $content, $match)) {

            foreach($match as $subMatch) {
                $ret[] = [$subMatch[0] => $subMatch[1]];
            }
        }

        return $ret;
    }
79613
protected function extractVariables($content)
    {
        preg_match_all('/\[\[(.*?)\]\]/', $content, $matches);

        if (!isset($matches[0], $matches[1])) {
            return [];
        }
        $return        = [];
        $notifications = \Antares\Foundation\Notification::getInstance()->all();

        foreach ($matches[1] as $index => $match) {
            if (!str_contains($match, '::')) {
                continue;
            }
            list($component, $var) = explode('::', trim($match));
            $name = $this->findExtensionName($component);
            if (!$name) {
                continue;
            }
            $variables                   = $notifications[$name]['variables'];
            $return[$matches[0][$index]] = $this->resolveValue($var, $variables);
        }
        return $return;
    }
717254
protected function encode($content)
    {
        $jsonEncodeOptions = [];

        // Here is a place, where any available JSON encoding options, that
        // deal with users' requirements to JSON response formatting and
        // structure, can be conveniently applied to tweak the output.

        if ($this->isJsonPrettyPrintEnabled()) {
            $jsonEncodeOptions[] = JSON_PRETTY_PRINT;
        }

        $encodedString = $this->performJsonEncoding($content, $jsonEncodeOptions);

        if ($this->isCustomIndentStyleRequired()) {
            $encodedString = $this->indentPrettyPrintedJson(
                $encodedString,
                $this->options['indent_style']
            );
        }

        return $encodedString;
    }
917575
public function getNodes($content)
    {
        $items = array();
        $document = $this->createDocumentFromXML($content);
        $nodes = $document->getElementsByTagName('item');
        if ($nodes->length) {
            foreach ($nodes as $node) {
                try {
                    $item = $this->create($node);
                    $items[] = $item;
                } catch (\Exception $e) {
                    throw new RuntimeException($e->getMessage());
                }
            }
        }

        return $items;
    }