CoreFiles by mySites.guru
Manifest.php149 lines, 3,355 bytes, from Joomla_5.4.2-Stable-Full_Package.zip
Raw History Compare with 5.4.1
md5
e241e371bc26ecba7c5a01ae9b7d06bd
sha1
2c1a1de1be138bf7d0afdbef5dff4e586ff2801d
sha256
571b31b23625e62a6afd24f24201c7a2a5395df3447f9e9e934b37f8a8d0a0c1
<?php
declare(strict_types=1);
namespace TYPO3\PharStreamWrapper\Phar;

/*
 * This file is part of the TYPO3 project.
 *
 * It is free software; you can redistribute it and/or modify it under the terms
 * of the MIT License (MIT). For the full copyright and license information,
 * please read the LICENSE file that was distributed with this source code.
 *
 * The TYPO3 project - inspiring people to share!
 */

class Manifest
{
    /**
     * @see http://php.net/manual/en/phar.fileformat.phar.php
     */
    public static function fromContent(string $content): self
    {
        $target = new static();
        $target->manifestLength = Reader::resolveFourByteLittleEndian($content, 0);
        $target->amountOfFiles = Reader::resolveFourByteLittleEndian($content, 4);
        $target->flags = Reader::resolveFourByteLittleEndian($content, 10);
        $target->aliasLength = Reader::resolveFourByteLittleEndian($content, 14);
        $target->alias = substr($content, 18, $target->aliasLength);
        $target->metaDataLength = Reader::resolveFourByteLittleEndian($content, 18 + $target->aliasLength);
        $target->metaData = substr($content, 22 + $target->aliasLength, $target->metaDataLength);

        $apiVersionNibbles = Reader::resolveTwoByteBigEndian($content, 8);
        $target->apiVersion = implode('.', [
            ($apiVersionNibbles & 0xf000) >> 12,
            ($apiVersionNibbles & 0x0f00) >> 8,
            ($apiVersionNibbles & 0x00f0) >> 4,
        ]);

        return $target;
    }

    /**
     * @var int
     */
    private $manifestLength;

    /**
     * @var int
     */
    private $amountOfFiles;

    /**
     * @var string
     */
    private $apiVersion;

    /**
     * @var int
     */
    private $flags;

    /**
     * @var int
     */
    private $aliasLength;

    /**
     * @var string
     */
    private $alias;

    /**
     * @var int
     */
    private $metaDataLength;

    /**
     * @var string
     */
    private $metaData;

    /**
     * Avoid direct instantiation.
     */
    private function __construct()
    {
    }

    public function getManifestLength(): int
    {
        return $this->manifestLength;
    }

    public function getAmountOfFiles(): int
    {
        return $this->amountOfFiles;
    }

    public function getApiVersion(): string
    {
        return $this->apiVersion;
    }

    public function getFlags(): int
    {
        return $this->flags;
    }

    public function getAliasLength(): int
    {
        return $this->aliasLength;
    }

    public function getAlias(): string
    {
        return $this->alias;
    }

    public function getMetaDataLength(): int
    {
        return $this->metaDataLength;
    }

    public function getMetaData(): string
    {
        return $this->metaData;
    }

    /**
     * @return mixed|null
     */
    public function deserializeMetaData()
    {
        if (empty($this->metaData)) {
            return null;
        }

        $result = unserialize($this->metaData, ['allowed_classes' => false]);

        $serialized = json_encode($result);
        if (strpos($serialized, '__PHP_Incomplete_Class_Name') !== false) {
            throw new DeserializationException(
                'Meta-data contains serialized object',
                1539623382
            );
        }

        return $result;
    }
}

The same content is in 45 releases, Joomla 5.3.0-beta1 to 5.4.11. See them all, or every version of this file.