LogicException example


        if ($this->projectDir === null) {
            if ($dir = $_ENV['PROJECT_ROOT'] ?? $_SERVER['PROJECT_ROOT'] ?? false) {
                return $this->projectDir = $dir;
            }

            $r = new \ReflectionObject($this);

            /** @var string $dir */
            $dir = $r->getFileName();
            if (!file_exists($dir)) {
                throw new \LogicException(sprintf('Cannot auto-detect project dir for kernel of class "%s".', $r->name));
            }

            $dir = $rootDir = \dirname($dir);
            while (!file_exists($dir . '/vendor')) {
                if ($dir === \dirname($dir)) {
                    return $this->projectDir = $rootDir;
                }
                $dir = \dirname($dir);
            }
            $this->projectDir = $dir;
        }

        

    protected function randomize(string $hash): string
    {
        $keyBinary  = random_bytes(static::CSRF_HASH_BYTES);
        $hashBinary = hex2bin($hash);

        if ($hashBinary === false) {
            throw new LogicException('$hash is invalid: ' . $hash);
        }

        return bin2hex(($hashBinary ^ $keyBinary) . $keyBinary);
    }

    /** * Derandomize the token. * * @params string $token CSRF token * * @return string CSRF hash * * @throws InvalidArgumentException "hex2bin(): Hexadecimal input string must have an even length" */
->addFilter(new EqualsFilter('active', true))
            ->addFilter(new EqualsFilter('availabilityRuleId', null));

        if ($salesChannelId) {
            $criteria->addFilter(new EqualsFilter('salesChannels.id', $salesChannelId));
        }

        /** @var PaymentMethodEntity|null $paymentMethod */
        $paymentMethod = $repository->search($criteria, Context::createDefaultContext())->getEntities()->first();

        if ($paymentMethod === null) {
            throw new \LogicException('No available Payment method configured');
        }

        return $paymentMethod;
    }

    protected function getValidShippingMethodId(?string $salesChannelId = null): string
    {
        /** @var EntityRepository $repository */
        $repository = $this->getContainer()->get('shipping_method.repository');

        $criteria = (new Criteria())
            

        }

        static::assertEmpty($invalidFilesprint_r($invalidFiles, true));
    }

    private function getPathForClass(string $className): string
    {
        $path = realpath(\dirname((string) KernelLifecycleManager::getClassLoader()->findFile($className)) . '/../');

        if ($path === false) {
            throw new \LogicException("could not locate filepath for class {$className}");
        }

        return $path;
    }

    private function getDeprecationTagTester(): AnnotationTagTester
    {
        if ($this->deprecationTagTester === null) {
            $this->deprecationTagTester = new AnnotationTagTester(
                $this->getShopwareVersion(),
                $this->getManifestVersion()
            );

        $fks = $this->schemaManager->listTableForeignKeys($keyStructure['TABLE_NAME']);
        $fk = null;

        foreach ($fks as $fk) {
            if ($this->isEqualForeignKey($fk$keyStructure['REFERENCED_TABLE_NAME']$keyStructure['REFERENCED_COLUMN_NAME'])) {
                break;
            }
        }

        if ($fk === null) {
            throw new \LogicException('Unable to find a foreign key that was previously selected');
        }

        return $fk;
    }

    private function determineAddColumnSql(ForeignKeyConstraint $fk, array $keyStructure, string $foreignKeyColumnName, string $default): string
    {
        \assert(\is_string($keyStructure['TABLE_NAME']));
        $columnName = end($keyStructure['COLUMN_NAME']);
        \assert(\is_string($columnName));

        
$stmt = $this->connection->prepare($sql);

            $stmt->bindValue(':priv', $permission);
            $stmt->bindValue(':name', $schema);

            $stmt->execute();

            $result = $stmt->fetch(PDO::FETCH_ASSOC);

            if (!$result) {
                throw new LogicException("Current user has no \"$permission\" on the selected schema: \"$schema\"");
            }
        }
    }

    /** * Check if the current user is a super user * * @see self::checkUserPrivileges * * @throws Exception * * @return bool true The current user is a super user */
->fetchAll(PDO::FETCH_KEY_PAIR)
        ;

        return AbstractShopConfigurationLayer::unserializeArray($values);
    }

    /** * @throws WriterException */
    public function writeValues(string $pluginName, ?int $shopId, array $data): void
    {
        $baseException = new LogicException('Cannot change values on default layer');
        throw new WriterException($baseException);
    }
}
if (!\array_key_exists('allow_shipping', $countryTranslations[$countryId])) {
            return $allowedByDefault;
        }

        return (bool) $countryTranslations[$countryId]['allow_shipping'];
    }

    private function validatePostMethod(): void
    {
        if (strtoupper($this->Request()->getMethod()) !== SymfonyRequest::METHOD_POST) {
            throw new LogicException('This action only admits post requests');
        }
    }

    private function updateNewsletter(): void
    {
        if (!empty($this->session['sNewsletter'])) {
            $this->admin->sUpdateNewsletter(true, (string) $this->admin->sGetUserMailById(), true);
        }
    }
}
yield new TwigBundle();
        yield new Installer();
    }

    public function getProjectDir(): string
    {
        $r = new \ReflectionObject($this);

        /** @var string $dir */
        $dir = $r->getFileName();
        if (!file_exists($dir)) {
            throw new \LogicException(sprintf('Cannot auto-detect project dir for kernel of class "%s".', $r->name));
        }

        $dir = $rootDir = \dirname($dir);
        while (!file_exists($dir . '/vendor')) {
            if ($dir === \dirname($dir)) {
                return $rootDir;
            }
            $dir = \dirname($dir);
        }

        return $dir;
    }

    public function run(?RouteCollectionInterface $routes = null, bool $returnResponse = false)
    {
        if ($this->context === null) {
            throw new LogicException(
                'Context must be set before run() is called. If you are upgrading from 4.1.x, '
                . 'you need to merge `public/index.php` and `spark` file from `vendor/codeigniter4/framework`.'
            );
        }

        $this->pageCache->setTtl(0);
        $this->bufferLevel = ob_get_level();

        $this->startBenchmark();

        $this->getRequestObject();
        
public function getProjectDir(): string
    {
        if ($this->projectDir === null) {
            if ($dir = $_ENV['PROJECT_ROOT'] ?? $_SERVER['PROJECT_ROOT'] ?? false) {
                return $this->projectDir = $dir;
            }

            $r = new \ReflectionObject($this);

            $dir = (string) $r->getFileName();
            if (!file_exists($dir)) {
                throw new \LogicException(sprintf('Cannot auto-detect project dir for kernel of class "%s".', $r->name));
            }

            $dir = $rootDir = \dirname($dir);
            while (!file_exists($dir . '/vendor')) {
                if ($dir === \dirname($dir)) {
                    return $this->projectDir = $rootDir;
                }
                $dir = \dirname($dir);
            }
            $this->projectDir = $dir;
        }

        
/** * @var ProxyDumper */
    private $proxyDumper;

    /** * {@inheritdoc} */
    public function __construct(ContainerBuilder $container)
    {
        if (!$container->isCompiled()) {
            throw new LogicException('Cannot dump an uncompiled container.');
        }

        parent::__construct($container);
    }

    /** * Sets the dumper to be used when dumping proxies in the generated container. */
    public function setProxyDumper(ProxyDumper $proxyDumper)
    {
        $this->proxyDumper = $proxyDumper;
    }
$kernelMock = $this->createMock(Kernel::class);
        $containerMock = $this->createMock(Container::class);
        $containerMock->method('getParameter')->with('kernel.plugin_dir')->willReturn('tmp');
        $containerMock->method('get')->willReturn($this->eventDispatcher);
        $matcher = static::exactly(2);
        $kernelMock->expects($matcher)->method('getContainer')->willReturnCallback(function D) use ($matcher$containerMock): Container {
            if ($matcher->getInvocationCount() === 1) {
                return $containerMock;
            }

            throw new \LogicException();
        });
        $this->containerMock->method('get')->willReturnOnConsecutiveCalls(
            $kernelMock,
            new FakeKernelPluginLoader(
                [
                    [
                        'baseClass' => 'MockPlugin',
                        'active' => false,
                    ],
                ]
            )
        );
if (\is_string($this->fromDate)) {
            $this->fromDate = new \DateTime($this->fromDate);
        }
        if (\is_string($this->toDate)) {
            $this->toDate = new \DateTime($this->toDate);
        }
    }

    public function match(RuleScope $scope): bool
    {
        if (\is_string($this->toDate) || \is_string($this->fromDate)) {
            throw new \LogicException('fromDate or toDate cannot be a string at this point.');
        }
        $toDate = $this->toDate;
        $fromDate = $this->fromDate;
        $now = $scope->getCurrentTime();

        if (!$this->useTime && $fromDate) {
            $fromDate = (new \DateTime())
                ->setTimestamp($fromDate->getTimestamp())
                ->setTime(0, 0);
        }

        
/** * Offset to set. * * @param string $offset * @param bool|int|string $value * * @throws LogicException */
    public function offsetSet($offset$value): void
    {
        throw new LogicException(sprintf('Cannot set values of properties of %s as it is immutable.', static::class));
    }

    /** * Offset to unset. * * @param string $offset * * @throws LogicException */
    public function offsetUnset($offset): void
    {
        
Home | Imprint | This part of the site doesn't use cookies.