valdates the structure of a division

@param array  $divisionData Data to validate
@param string $filename
@param array  $allDivisions
@param bool   $isCore

@throws \Assert\AssertionFailedException
@throws \LogicException
355906
public function validate(
        array $divisionData,
        string $filename,
        array &$allDivisions = [],
        bool $isCore = false
    ) : void {
        Assertion::keyExists($divisionData, 'division', 'required attibute "division" is missing in File ' . $filename);
        Assertion::string($divisionData['division'], 'required attibute "division" has to be a string in File ' . $filename);

        Assertion::keyExists($divisionData, 'sortIndex', 'required attibute "sortIndex" is missing in File ' . $filename);
        Assertion::integer($divisionData['sortIndex'], 'required attibute "sortIndex" has to be a integer in File ' . $filename);

        if (!$isCore) {
            Assertion::greaterThan($divisionData['sortIndex'], 0, 'required attibute "sortIndex" has to be a positive integer in File ' . $filename);
        }

        Assertion::keyExists($divisionData, 'lite', 'required attibute "lite" is missing in File ' . $filename);
        Assertion::boolean($divisionData['lite'], 'required attibute "lite" has to be an boolean in File ' . $filename);

        Assertion::keyExists($divisionData, 'standard', 'required attibute "standard" is missing in File ' . $filename);
        Assertion::boolean($divisionData['standard'], 'required attibute "standard" has to be an boolean in File ' . $filename);

        Assertion::keyExists($divisionData, 'userAgents', 'required attibute "userAgents" is missing in File ' . $filename);
        Assertion::isArray($divisionData['userAgents'], 'required attibute "userAgents" should be an array in File ' . $filename);
        Assertion::notEmpty($divisionData['userAgents'], 'required attibute "userAgents" should be an non-empty array in File ' . $filename);

        if (isset($divisionData['versions']) && is_array($divisionData['versions'])) {
            $versions = $divisionData['versions'];
        } else {
            $versions = ['0.0'];
        }

        foreach ($divisionData['userAgents'] as $index => $useragentData) {
            $this->validateUserAgentSection($useragentData, $versions, $allDivisions, $isCore, $filename, $index);

            $allDivisions[] = $useragentData['userAgent'];
        }
    }
97766
private static function loadModule(string $division, string $moduleName)
    {
        $mPath = $moduleName . '/' . ($division === '' ? 'primary/' : $division . '/');
        $mName = ucfirst($moduleName) . ucfirst($division);

        $fileName = MODULES . $mPath . $mName . 'ViewsController.php';

        if ( ! file_exists($fileName)) {
            throw new NotFoundException("Can't load module: file '$fileName' does not exists.");
        }

        /** @noinspection PhpIncludeInspection */
        require_once $fileName;
    }
663430
protected function dereferenceArray(array &$arrayData)
    {
        try {
            foreach ($arrayData as $idx => $data) {
                // go deeper if is array
                if (is_array($data)) {
                    $this->dereferenceArray($arrayData[$idx]);

                // dereference if it is a reference #changed
                } elseif (false !== ($ref = $this->isReference($data))) {
                    $arrayData[$idx] = $this->getReferenceValue($ref);
                }
            }
        } catch (\Exception $e) {
            throw new LogicException($e->getMessage(), $e->getCode(), $e);
        }
    }
417042
public function findInvoices($paymentData)
    {
        $invoices  = [];
        $vInvoices = [];
        $sInvoices = [];
        $uInvoices = [];
        $bInvoices = [];

        if (!empty($paymentData['varSym'])) {
            $vInvoices = $this->findInvoice(['varSym' => $paymentData['varSym']]);
        }

        if (empty($vInvoices)) {

            if (!empty($paymentData['specSym'])) {

                // Faktury vydane "firma":"code:02100",
                // Adresar: ext:lms.cstmr:2365
                $uInvoices = $this->findInvoice(['firma' => sprintf("code:%05s",
                        $paymentData['specSym'])]);
            }

            if (!empty($paymentData['specSym'])) {
                $sInvoices = $this->findInvoice(['specSym' => $paymentData['specSym']]);
            }

            if ($paymentData['buc']) {
                $bInvoices = $this->findInvoice(['buc' => $paymentData['buc']]);
            }
        }

        self::unifyInvoices($vInvoices, $invoices);
        self::unifyInvoices($uInvoices, $invoices);
        self::unifyInvoices($sInvoices, $invoices);
        self::unifyInvoices($bInvoices, $invoices);

        $invoices = self::reorderInvoicesByAge($invoices);

        if (empty($paymentData['varSym']) && empty($paymentData['specSym'])) {
            $this->banker->dataReset();
            $this->banker->setDataValue('id', $paymentData['id']);
            $this->banker->setDataValue('stitky', 'NEIDENTIFIKOVANO');
            $this->addStatusMessage(_('Neidentifikovaná platba').': '.$this->banker->getApiURL(),
                'warning');
            $this->banker->insertToFlexiBee();
        } elseif (count($invoices) == 0) {
            $this->banker->dataReset();
            $this->banker->setDataValue('id', $paymentData['id']);
            $this->banker->setDataValue('stitky', 'CHYBIFAKTURA');
            $this->addStatusMessage(_('Platba bez faktury').': '.$this->banker->getApiURL(),
                'warning');
            $this->banker->insertToFlexiBee();
        }

        return $invoices;
    }
619165
public static function parse(string $filePath): FilePathInterface
    {
        if (!self::myFilePathParse(
            DIRECTORY_SEPARATOR,
            $filePath,
            function ($p, $d, &$e) {
                return self::myPartValidator($p, $d, $e);
            },
            null,
            $isAbsolute,
            $aboveBaseLevel,
            $drive,
            $directoryParts,
            $filename,
            $error)
        ) {
            throw new FilePathInvalidArgumentException('File path "' . $filePath . '" is invalid: ' . $error);
        }

        return new self($isAbsolute, $aboveBaseLevel, $drive, $directoryParts, $filename);
    }
791749
public static function write($filename, $data, $permission = 0777, $flags = LOCK_EX, $relative = true) {
		// if we have relative path we convert it to full path
		if ($relative && $filename[0] == '.') {
			$path = \Application::get('application.path_full');
			$info = pathinfo($filename);
			$filename = realpath($path . $info['dirname']) . DIRECTORY_SEPARATOR . $info['basename'];
		}
		// write file
		if (file_put_contents($filename, $data, $flags) !== false) {
			@chmod($filename, $permission);
			return true;
		}
		return false;
	}
1304551
private function createRoles(array $aclData): void
    {
        if (array_key_exists('rolesActions', $aclData)) {
            foreach ($aclData['rolesActions'] as $role => $actions) {
                $roleRecord = $this->roleRepository->makeQuery()->firstOrCreate([
                    'slug' => $role,
                    'name' => ucfirst(str_replace(['-', '_'], ' ', $role)),
                ]);

                $this->rolesList[$roleRecord->id] = $roleRecord;
            }
        }
    }
104879
public function protectedDivideDigit($dividend, $divisor)
    {
        $carry = 0;
        $result = array();

        for ($i = count($dividend) - 1; $i >= 0; -- $i) {
            $temp = MATH_BIGINTEGER_BASE_FULL * $carry + $dividend[$i];
            $result[$i] = (int) ($temp / $divisor);
            $carry = (int) ($temp - $divisor * $result[$i]);
        }

        return array(
            $result,
            $carry
        );
    }
921819
private function createBlocks(Zone $zone, array $blocksData): void
    {
        foreach ($blocksData as $blockData) {
            $this->createBlockInZone($zone, $blockData);
        }
    }
744750
protected final void verifyWriteCData()
        throws XMLStreamException
    {
        // Not legal outside main element tree:
        if (mCheckStructure) {
            if (inPrologOrEpilog()) {
                reportNwfStructure(ErrorConsts.WERR_PROLOG_CDATA);
            }
        }
        // 08-Dec-2005, TSa: validator-based validation?
        if (mVldContent <= XMLValidator.CONTENT_ALLOW_WS) {
            // there's no ignorable white space CDATA...
            reportInvalidContent(CDATA);
        }
    }
764810
function(isques, rdata){
		var bd = this.board;
		for(var id=0;id<bd.border.length;id++){
			var border = bd.border[id], cell1 = border.sidecell[0], cell2 = border.sidecell[1];
			var isdiff = (!cell1.isnull && !cell2.isnull && rdata[cell1.id]!==rdata[cell2.id]);
			border[(isques?'ques':'qans')] = (isdiff?1:0);
		}
	}
404215
public function dataFormatoDestino($data, $formatoDestino)
    {
        $dataFormatada = false;

        if (!$dataFormatada && $this->validarDataPorFormato($data, $this->FORMATO_DATA_SQL)) {
            $dataFormatada = $this->dataFormatoOrigemDestino($data, $this->FORMATO_DATA_SQL, $formatoDestino);
        }

        if (!$dataFormatada && $this->validarDataPorFormato($data, $this->FORMATO_DATA_HORA_SQL)) {
            $dataFormatada = $this->dataFormatoOrigemDestino($data, $this->FORMATO_DATA_HORA_SQL, $formatoDestino);
        }

        if (!$dataFormatada && $this->validarDataPorFormato($data, $this->FORMATO_DATA_BR)) {
            $dataFormatada = $this->dataFormatoOrigemDestino($data, $this->FORMATO_DATA_BR, $formatoDestino);
        }

        if (!$dataFormatada && $this->validarDataPorFormato($data, $this->FORMATO_DATA_HORA_BR)) {
            $dataFormatada = $this->dataFormatoOrigemDestino($data, $this->FORMATO_DATA_HORA_BR, $formatoDestino);
        }

        return $dataFormatada;
    }
425959
public static void splitFile(String filePath, long[] splitPoints, String storageFolder) throws IOException {
        splitFile(new File(filePath), splitPoints, storageFolder);
    }
969533
protected static function parseOid(&$binaryData, &$offsetIndex, $octetsToRead)
    {
        $oid = '';

        while ($octetsToRead > 0) {
            $octets = '';

            do {
                if (0 === $octetsToRead) {
                    throw new ParserException('Malformed ASN.1 Object Identifier', $offsetIndex - 1);
                }

                $octetsToRead--;
                $octet = $binaryData[$offsetIndex++];
                $octets .= $octet;
            } while (ord($octet) & 0x80);

            $oid .= sprintf('%d.', Base128::decode($octets));
        }

        // Remove trailing '.'
        return substr($oid, 0, -1) ?: '';
    }
357237
public function fileExists($filename)
    {
        if ($this->mediaDirectory->isFile($filename)) {
            return true;
        } else {
            return $this->coreFileStorageDatabase->saveFileToFilesystem(
                $this->mediaDirectory->getAbsolutePath($filename)
            );
        }
    }
112636
public function setData(array $data = array(), $isDirty = true)
    {
        $this->extract(
            $data, array_merge(
                array('id'), $this->_readonlyAttr
            ), $isDirty
        );
    }
912673
private function validateUserAgentSection(
        array $useragentData,
        array $versions,
        array $allDivisions,
        bool $isCore,
        string $filename,
        int $index
    ) : void {
        Assertion::keyExists($useragentData, 'userAgent', 'required attibute "userAgent" is missing in userAgents section ' . $index . ' in File ' . $filename);
        Assertion::string($useragentData['userAgent'], 'required attibute "userAgent" has to be a string in userAgents section ' . $index . ' in File ' . $filename);

        if (preg_match('/[\[\]]/', $useragentData['userAgent'])) {
            throw new \LogicException('required attibute "userAgent" includes invalid characters in userAgents section ' . $index . ' in File ' . $filename);
        }

        if (false === mb_strpos($useragentData['userAgent'], '#')
            && in_array($useragentData['userAgent'], $allDivisions)
        ) {
            throw new \LogicException('Division "' . $useragentData['userAgent'] . '" is defined twice in file "' . $filename . '"');
        }

        if ((false !== mb_strpos($useragentData['userAgent'], '#MAJORVER#')
                || false !== mb_strpos($useragentData['userAgent'], '#MINORVER#'))
            && ['0.0'] === $versions
        ) {
            throw new \LogicException(
                'Division "' . $useragentData['userAgent']
                . '" is defined with version placeholders, but no versions are set in file "' . $filename . '"'
            );
        }

        if (false === mb_strpos($useragentData['userAgent'], '#MAJORVER#')
            && false === mb_strpos($useragentData['userAgent'], '#MINORVER#')
            && ['0.0'] !== $versions
            && 1 < count($versions)
        ) {
            throw new \LogicException(
                'Division "' . $useragentData['userAgent']
                . '" is defined without version placeholders, but there are versions set in file "' . $filename . '"'
            );
        }

        Assertion::keyExists($useragentData, 'properties', 'required attibute "properties" is missing in userAgents section ' . $index . ' in File ' . $filename);
        Assertion::isArray($useragentData['properties'], 'required attibute "properties" should be an array in userAgents section ' . $index . ' in File ' . $filename);
        Assertion::notEmpty($useragentData['properties'], 'required attibute "properties" should be an non-empty array in userAgents section ' . $index . ' in File ' . $filename);

        if (!$isCore) {
            Assertion::keyExists($useragentData['properties'], 'Parent', 'the "Parent" property is missing for key "' . $useragentData['userAgent'] . '" in file "' . $filename . '"');
            Assertion::same($useragentData['properties']['Parent'], 'DefaultProperties', 'the "Parent" property is not linked to the "DefaultProperties" for key "' . $useragentData['userAgent'] . '" in file "' . $filename . '"');
        }

        Assertion::keyExists($useragentData['properties'], 'Comment', 'the "Comment" property is missing for key "' . $useragentData['userAgent'] . '" in file "' . $filename . '"');
        Assertion::string($useragentData['properties']['Comment'], 'the "Comment" property has to be a string for key "' . $useragentData['userAgent'] . '" in file "' . $filename . '"');

        if (!array_key_exists('Version', $useragentData['properties']) && ['0.0'] !== $versions) {
            throw new \LogicException(
                'the "Version" property is missing for key "' . $useragentData['userAgent'] . '" in file "' . $filename
                . '", but there are defined versions'
            );
        }

        if ($isCore) {
            return;
        }

        if (array_key_exists('Version', $useragentData['properties'])) {
            Assertion::string($useragentData['properties']['Version'], 'the "Version" property has to be a string for key "' . $useragentData['userAgent'] . '" in file "' . $filename . '"');

            if ((false !== mb_strpos($useragentData['properties']['Version'], '#MAJORVER#')
                    || false !== mb_strpos($useragentData['properties']['Version'], '#MINORVER#'))
                && ['0.0'] === $versions) {
                throw new \LogicException(
                    'the "Version" property has version placeholders for key "' . $useragentData['userAgent'] . '" in file "' . $filename
                    . '", but no versions are defined'
                );
            }

            if (false === mb_strpos($useragentData['properties']['Version'], '#MAJORVER#')
                && false === mb_strpos($useragentData['properties']['Version'], '#MINORVER#')
                && ['0.0'] !== $versions
                && 1 < count($versions)
            ) {
                throw new \LogicException(
                    'the "Version" property has no version placeholders for key "' . $useragentData['userAgent'] . '" in file "' . $filename
                    . '", but versions are defined'
                );
            }
        }

        $this->checkPlatformProperties(
            $useragentData['properties'],
            'the properties array contains platform data for key "' . $useragentData['userAgent']
            . '", please use the "platform" keyword'
        );

        $this->checkEngineProperties(
            $useragentData['properties'],
            'the properties array contains engine data for key "' . $useragentData['userAgent']
            . '", please use the "engine" keyword'
        );

        $this->checkDeviceProperties(
            $useragentData['properties'],
            'the properties array contains device data for key "' . $useragentData['userAgent']
            . '", please use the "device" keyword'
        );

        $this->checkBrowserProperties(
            $useragentData['properties'],
            'the properties array contains browser data for key "' . $useragentData['userAgent']
            . '", please use the "browser" keyword'
        );

        $this->checkDeprecatedProperties(
            $useragentData['properties'],
            'the properties array contains deprecated properties for key "' . $useragentData['userAgent'] . '"'
        );

        Assertion::keyExists($useragentData, 'children', 'required attibute "children" is missing in userAgents section ' . $index . ' in File ' . $filename);
        Assertion::isArray($useragentData['children'], 'required attibute "children" should be an array in userAgents section ' . $index . ' in File ' . $filename);
        Assertion::notEmpty($useragentData['children'], 'required attibute "children" should be an non-empty array in userAgents section ' . $index . ' in File ' . $filename);

        Assertion::keyNotExists($useragentData['children'], 'match', 'the children property shall not have the "match" entry for key "' . $useragentData['userAgent'] . '" in file "' . $filename . '"');

        foreach ($useragentData['children'] as $child) {
            Assertion::isArray($child, 'each entry of the children property has to be an array for key "' . $useragentData['userAgent'] . '"');

            $this->validateChildSection($child, $useragentData, $versions);
        }
    }