diff --git a/applications/asset_server/Dockerfile b/applications/asset_server/Dockerfile index 56d0e6612..6029c0c13 100644 --- a/applications/asset_server/Dockerfile +++ b/applications/asset_server/Dockerfile @@ -1,103 +1,144 @@ -FROM alpine +FROM alpine:3.9 -#RUN echo "ipv6" >> /etc/modules +# TODO: Look into using https://github.com/docker-library/php/tree/a9f19e9df5f7a5b74d72a97439ca5b77b87faa35/7.3/alpine3.9/cli -# update -RUN apk update && apk upgrade \ - # bash - && apk add --no-cache bash && apk add --no-cache bash-completion \ - # npm - && apk add --no-cache nodejs && apk add --no-cache nodejs-npm \ - # curl - && apk add --no-cache curl \ - # "metapackage that pulls in the most essential packages used to build new packages" - && apk add --update alpine-sdk \ - # add GZIP just in case - && apk add --no-cache gzip \ - # install Postgres for compatibility - && apk add --no-cache postgresql-dev \ - && apk add --update wget +# ---------------------------------------------------------------------------------------------------------------- +# Base OS libs. +# ---------------------------------------------------------------------------------------------------------------- +RUN apk update && apk upgrade && apk --no-cache add bash bash-completion nodejs nodejs-npm curl gzip postgresql-dev \ + && apk add --update alpine-sdk wget # ---------------------------------------------------------------------------------------------------------------- # __ __ # |__) |__| |__) # | | | | # ---------------------------------------------------------------------------------------------------------------- - -# trust this project public key to trust the packages. -ADD https://php.codecasts.rocks/php-alpine.rsa.pub /etc/apk/keys/php-alpine.rsa.pub - -# https://github.com/codecasts/php-alpine - -RUN apk add --update ca-certificates \ - && update-ca-certificates \ - && echo "@php https://php.codecasts.rocks/v3.9/php-7.3" >> /etc/apk/repositories \ - && apk add --update php@php \ - && apk add --update php-common@php \ - && apk add --update php-fpm@php \ - && apk add --update php-cgi@php \ - && apk add --update php-doc@php \ - && apk add --update php-dev@php \ - && apk add --update php-gd@php \ - && apk add --update php-curl@php \ - && apk add --update php-openssl@php \ - && apk add --update php-dom@php --repository http://nl.alpinelinux.org/alpine/edge/testing/ \ - && apk add --update php-fpm@php \ - && apk add --update php-phar@php \ - && apk add --update php-json@php \ - && apk add --update php-iconv@php \ - && apk add --update php-openssl@php \ - && apk add --update php-zlib@php \ - && apk add --update php-iconv@php \ - && apk add --update php-mbstring@php \ - && apk add --update php-xml@php \ - && apk add --update php-zip@php \ - && apk add --update php-ctype@php \ - && apk add --update php-session@php \ - # Database libraries. - && apk add --update php-pdo@php \ - && apk add --update php-pgsql@php \ - && apk add --update php-pdo_pgsql@php \ - # Set alias for 'php' --> 'php7' - && ln -s /usr/bin/php7 /usr/bin/php - -#RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer - -# Deployer -#RUN curl -L0 https://deployer.org/deployer.phar --output dep && chmod +x ./dep +RUN apk --no-cache add php7 php7-fpm php7-mysqli php7-json php7-openssl php7-curl php7-zlib php7-xml \ + php7-phar php7-intl php7-dom php7-xmlreader php7-ctype php7-mbstring php7-gd php7-common php7-doc \ + php7-cgi php7-dev php7-iconv php7-zip php7-session php7-pdo php7-pgsql php7-pdo_pgsql php7-tokenizer \ + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer # ---------------------------------------------------------------------------------------------------------------- # __ # / ` __|__ __|__ # \__, | | # ---------------------------------------------------------------------------------------------------------------- -RUN apk add --no-cache libc-dev \ - && apk add --no-cache libressl-dev \ - && apk add --no-cache gcc \ - && apk add --no-cache zlib-dev \ - && apk add --no-cache jpeg-dev \ - && apk add --no-cache boost-dev \ - && apk add --no-cache musl-dev \ - && apk add --no-cache cmake \ - && apk add libev-dev \ - && apk add linux-headers \ - && apk add libtool \ - && apk add libsodium-dev \ - && apk add automake - - - # && apk add --no-cache build-base \ - #&& apk add openssl-dev +#RUN apk add --no-cache libc-dev \ +# && apk add --no-cache libressl-dev \ +# && apk add --no-cache gcc \ +# && apk add --no-cache zlib-dev \ +# && apk add --no-cache jpeg-dev \ +# && apk add --no-cache boost-dev \ +# && apk add --no-cache musl-dev \ +# && apk add --no-cache cmake \ +# && apk add --no-cache libev-dev \ +# && apk add --no-cache linux-headers \ +# && apk add --no-cache libtool \ +# && apk add --no-cache libsodium-dev \ +# && apk add --no-cache utomake RUN rm /var/cache/apk/* -#COPY ./generated_output/third_party_libraries/AMQP_CPP_3_1_0 /quasar_source/generated_output/third_party_libraries/AMQP_CPP_3_1_0 -#RUN cd /quasar_source/generated_output/third_party_libraries/AMQP_CPP_3_1_0 \ -# && make \ -# && make install - -#COPY ./libraries/pre_compiled/libamqpcpp.so.3.1 /usr/lib/libamqpcpp.so.3.1 +RUN echo $'[PHP] \n\ +engine=On \n\ +short_open_tag=Off \n\ +precision=14 \n\ +output_buffering=4096 \n\ +zlib.output_compression=Off \n\ +implicit_flush=Off \n\ +serialize_precision=-1 \n\ +realpath_cache_size=4096k \n\ +realpath_cache_ttl=600 \n\ +zend.enable_gc=On \n\ +expose_php=Off \n\ +max_execution_time=30 \n\ +max_input_time=60 \n\ +memory_limit=256M \n\ +error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT \n\ +display_errors=On \n\ +display_startup_errors=On \n\ +log_errors=On \n\ +log_errors_max_len=1024 \n\ +ignore_repeated_errors=Off \n\ +ignore_repeated_source=Off \n\ +report_memleaks=On \n\ +html_errors=Off \n\ +variables_order="S" \n\ +request_order="GP" \n\ +register_argc_argv=On \n\ +auto_globals_jit=On \n\ +enable_post_data_reading=Off \n\ +post_max_size=8M \n\ +include_path = ".:/usr/share/php7" \n\ +enable_dl = Off \n\ +file_uploads=On \n\ +upload_max_filesize=2M \n\ +max_file_uploads=20 \n\ +allow_url_fopen=On \n\ +allow_url_include=Off \n\ +default_socket_timeout=60 \n\ +[CLI Server] \n\ +cli_server.color=On \n\ +[Date] \n\ +date.timezone=America/Chicago \n\ +[ODBC] \n\ +odbc.allow_persistent=On \n\ +odbc.check_persistent=On \n\ +odbc.max_persistent=-1 \n\ +odbc.max_links=-1 \n\ +odbc.defaultlrl=4096 \n\ +odbc.defaultbinmode=1 \n\ +[Interbase] \n\ +ibase.allow_persistent=-1 \n\ +[mysqlnd] \n\ +mysqlnd.collect_statistics=Off \n\ +mysqlnd.collect_memory_statistics=Off \n\ +[PostgreSQL] \n\ +pgsql.allow_persistent=On \n\ +pgsql.auto_reset_persistent=On \n\ +pgsql.max_persistent=-1 \n\ +pgsql.max_links=-1 \n\ +pgsql.ignore_notice=1 \n\ +pgsql.log_notice=1 \n\ +[bcmath] \n\ +bcmath.scale=0 \n\ +[Session] \n\ +session.save_handler=files \n\ +session.use_strict_mode=0 \n\ +session.use_cookies=0 \n\ +session.use_only_cookies=0\n\ +session.name=PHPSESSID \n\ +session.auto_start=-1\n\ +session.serialize_handler = php \n\ +session.gc_probability=1 \n\ +session.gc_divisor=1000 \n\ +session.gc_maxlifetime=1440 \n\ +session.cache_limiter=nocache \n\ +session.cache_expire=180 \n\ +session.use_trans_sid=0 \n\ +[Assertion] \n\ +zend.assertions=-1 \n\ +[Tidy] \n\ +tidy.clean_output=Off \n\ +[soap] \n\ +soap.wsdl_cache_enabled=1 \n\ +soap.wsdl_cache_dir="/tmp" \n\ +soap.wsdl_cache_ttl=86400 \n\ +soap.wsdl_cache_limit=5 \n\ +[ldap] \n\ +ldap.max_links=-1 \n\ +[opcache] \n\ +opcache.enable=1 \n\ +opcache.enable_cli=1 \n\ +opcache.file_cache_only=1 \n\ +opcache.file_cache=/tmp/php-opcache \n\ +opcache.validate_timestamps=1 \n\ +opcache.revalidate_freq=0 \n\ +op.cache.revalidate_path=1 \n\ +opcache.max_accelerated_files=20000 \n\ +opcache.memory_consumption=192 \n\ +opcache.max_wasted_percentage=10 \n\ +opcache.interned_strings_buffer=16 \n\ +opcache.fast_shutdown=1\n' > /etc/php7/php.ini CMD ["bash", "/quasar_source/applications/asset_server/src/asset_server.sh"] - - diff --git a/applications/asset_server/code_manager/.env.dist b/applications/asset_server/code_manager/.env.dist index 414430e7f..494111bb6 100644 --- a/applications/asset_server/code_manager/.env.dist +++ b/applications/asset_server/code_manager/.env.dist @@ -1,4 +1,3 @@ -# define your env variables for the test env here -KERNEL_CLASS='App\Kernel' +KERNEL_CLASS='CodeManager\Kernel' APP_SECRET='s$cretf0rt3st' SYMFONY_DEPRECATIONS_HELPER=999999 diff --git a/applications/asset_server/code_manager/.env.test b/applications/asset_server/code_manager/.env.test index 414430e7f..494111bb6 100644 --- a/applications/asset_server/code_manager/.env.test +++ b/applications/asset_server/code_manager/.env.test @@ -1,4 +1,3 @@ -# define your env variables for the test env here -KERNEL_CLASS='App\Kernel' +KERNEL_CLASS='CodeManager\Kernel' APP_SECRET='s$cretf0rt3st' SYMFONY_DEPRECATIONS_HELPER=999999 diff --git a/applications/asset_server/code_manager/.gitignore b/applications/asset_server/code_manager/.gitignore index 50e13f759..683670f64 100644 --- a/applications/asset_server/code_manager/.gitignore +++ b/applications/asset_server/code_manager/.gitignore @@ -1,4 +1,3 @@ - ###> symfony/framework-bundle ### /.env.local /.env.local.php diff --git a/applications/asset_server/code_manager/bin/console b/applications/asset_server/code_manager/bin/console index 41a2aaf64..9f0f5331f 100755 --- a/applications/asset_server/code_manager/bin/console +++ b/applications/asset_server/code_manager/bin/console @@ -1,13 +1,13 @@ #!/usr/bin/env php -run($input); diff --git a/applications/asset_server/code_manager/composer.json b/applications/asset_server/code_manager/composer.json index 6355224ec..011d24855 100644 --- a/applications/asset_server/code_manager/composer.json +++ b/applications/asset_server/code_manager/composer.json @@ -1,27 +1,33 @@ { - "type": "project", - "license": "MIT", - "require": { - "php": "7.3.*", - "ext-ctype": "*", - "ext-iconv": "*", + "type" : "project", + "license" : "MIT", + "name" : "code_manager/code_manager", + "description": "Automated processes to manage and build Quasar Source.", + "require" : { + "php" : "7.2.*", + "ext-ctype" : "*", + "ext-iconv" : "*", "doctrine/doctrine-bundle": "^1.10", - "symfony/console": "4.2.*", - "symfony/dotenv": "4.2.*", - "symfony/event-dispatcher": "4.2.*", - "symfony/flex": "^1.1", + "doctrine/persistence" : "1.*", + "doctrine/reflection" : "1.*", + "symfony/config" : "4.2.*", + "symfony/console" : "4.*", + "symfony/doctrine-bridge" : "4.*", + "symfony/dotenv" : "4.*", + "symfony/event-dispatcher": "4.*", + "symfony/flex" : "^1.1", "symfony/framework-bundle": "4.2.*", - "symfony/monolog-bundle": "^3.3", - "symfony/orm-pack": "^1.0", - "symfony/phpunit-bridge": "4.2.*", - "symfony/process": "4.2.*", - "symfony/yaml": "4.2.*" + "symfony/monolog-bundle" : "^3.3", + "symfony/orm-pack" : "^1.0", + "symfony/phpunit-bridge" : "4.*", + "symfony/process" : "4.*", + "symfony/yaml" : "4.*" }, "config": { "preferred-install": { "*": "dist" }, - "sort-packages": true + "sort-packages": false }, "autoload": { "psr-4": { diff --git a/applications/asset_server/code_manager/config/bootstrap.php b/applications/asset_server/code_manager/config/bootstrap.php index 570bb924e..6ee0dca99 100644 --- a/applications/asset_server/code_manager/config/bootstrap.php +++ b/applications/asset_server/code_manager/config/bootstrap.php @@ -1,4 +1,4 @@ -=1.2) if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) { $_ENV += $env; -} elseif (!class_exists(Dotenv::class)) { +} else if (!class_exists(Dotenv::class)) { throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.'); } else { // load all the .env files diff --git a/applications/asset_server/code_manager/config/bundles.php b/applications/asset_server/code_manager/config/bundles.php index d30aebb63..8754ce8dd 100644 --- a/applications/asset_server/code_manager/config/bundles.php +++ b/applications/asset_server/code_manager/config/bundles.php @@ -1,9 +1,8 @@ - ['all' => true], Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true], Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], - Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], ]; diff --git a/applications/asset_server/code_manager/config/packages/cache.yaml b/applications/asset_server/code_manager/config/packages/cache.yaml index 93e620efa..1a63c7bd8 100644 --- a/applications/asset_server/code_manager/config/packages/cache.yaml +++ b/applications/asset_server/code_manager/config/packages/cache.yaml @@ -1,19 +1,2 @@ framework: cache: - # Put the unique name of your app here: the prefix seed - # is used to compute stable namespaces for cache keys. - #prefix_seed: your_vendor_name/app_name - - # The app cache caches to the filesystem by default. - # Other options include: - - # Redis - #app: cache.adapter.redis - #default_redis_provider: redis://localhost - - # APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues) - #app: cache.adapter.apcu - - # Namespaced pools use the above "app" backend by default - #pools: - #my.dedicated.cache: ~ diff --git a/applications/asset_server/code_manager/config/packages/dev/monolog.yaml b/applications/asset_server/code_manager/config/packages/dev/monolog.yaml index b1998da1a..71554587c 100644 --- a/applications/asset_server/code_manager/config/packages/dev/monolog.yaml +++ b/applications/asset_server/code_manager/config/packages/dev/monolog.yaml @@ -5,14 +5,6 @@ monolog: path: "%kernel.logs_dir%/%kernel.environment%.log" level: debug channels: ["!event"] - # uncomment to get logging in your browser - # you may have to allow bigger header sizes in your Web server configuration - #firephp: - # type: firephp - # level: info - #chromephp: - # type: chromephp - # level: info console: type: console process_psr_3_messages: false diff --git a/applications/asset_server/code_manager/config/packages/doctrine.yaml b/applications/asset_server/code_manager/config/packages/doctrine.yaml index dd7f8bbff..f7892d6fb 100644 --- a/applications/asset_server/code_manager/config/packages/doctrine.yaml +++ b/applications/asset_server/code_manager/config/packages/doctrine.yaml @@ -1,13 +1,8 @@ parameters: - # Adds a fallback DATABASE_URL if the env var is not set. - # This allows you to run cache:warmup even if your - # environment variables are not available yet. - # You should not need to change this value. env(DATABASE_URL): 'pgsql://postgres:password@postgres_server:5432/postgres' doctrine: dbal: - # configure these for your database server driver: 'pdo_pgsql' charset: utf8 url: '%env(DATABASE_URL)%' @@ -22,9 +17,3 @@ doctrine: dir: '%kernel.project_dir%/src/Entity' prefix: 'CodeManager\Entity' alias: CodeManager -# App: -# is_bundle: false -# type: annotation -# dir: '%kernel.project_dir%/src/Entity' -# prefix: 'CodeManager\Entity' -# alias: App diff --git a/applications/asset_server/code_manager/config/packages/doctrine_migrations.yaml b/applications/asset_server/code_manager/config/packages/doctrine_migrations.yaml deleted file mode 100644 index 3bf0fbcae..000000000 --- a/applications/asset_server/code_manager/config/packages/doctrine_migrations.yaml +++ /dev/null @@ -1,5 +0,0 @@ -doctrine_migrations: - dir_name: '%kernel.project_dir%/src/Migrations' - # namespace is arbitrary but should be different from App\Migrations - # as migrations classes should NOT be autoloaded - namespace: DoctrineMigrations diff --git a/applications/asset_server/code_manager/config/packages/framework.yaml b/applications/asset_server/code_manager/config/packages/framework.yaml index d3f884c4b..8ce131a8d 100644 --- a/applications/asset_server/code_manager/config/packages/framework.yaml +++ b/applications/asset_server/code_manager/config/packages/framework.yaml @@ -1,17 +1,4 @@ framework: secret: '%env(APP_SECRET)%' - #default_locale: en - #csrf_protection: true - #http_method_override: true - - # Enables session support. Note that the session will ONLY be started if you read or write from it. - # Remove or comment this section to explicitly disable session support. - session: - handler_id: ~ - cookie_secure: auto - cookie_samesite: lax - - #esi: true - #fragments: true php_errors: log: true diff --git a/applications/asset_server/code_manager/config/routes.yaml b/applications/asset_server/code_manager/config/routes.yaml index 4a02b42ef..0f2d8fec7 100644 --- a/applications/asset_server/code_manager/config/routes.yaml +++ b/applications/asset_server/code_manager/config/routes.yaml @@ -1,7 +1,3 @@ -#index: -# path: / -# controller: App\Controller\DefaultController::index - qa_test: path: /qa_test controller: CodeManager\Controller\QAController::test_response diff --git a/applications/asset_server/code_manager/config/services.yaml b/applications/asset_server/code_manager/config/services.yaml index c7930983b..5f566c766 100644 --- a/applications/asset_server/code_manager/config/services.yaml +++ b/applications/asset_server/code_manager/config/services.yaml @@ -1,35 +1,12 @@ -# This file is the entry point to configure your own services. -# Files in the packages/ subdirectory configure your dependencies. - -# Put parameters here that don't need to change on each machine where the app is deployed -# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration -parameters: - services: - # default configuration for services in *this* file _defaults: - autowire: true # Automatically injects dependencies in your services. - autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. + autowire: true + autoconfigure: true - # makes classes in src/ available to be used as services - # this creates a service per class whose id is the fully-qualified class name CodeManager\: resource: '../src/*' exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}' - # controllers are imported separately to make sure services can be injected - # as action arguments even if you don't extend any base controller class CodeManager\Controller\: resource: '../src/Controller' tags: ['controller.service_arguments'] - - # add more service definitions when explicit configuration is needed - # please note that last definitions always *replace* previous ones - - - #CodeManager\EventListener\TestHighPriorityListener: - # tags: - # - {name: doctrine.event_listener, event: postPersist, prority: 10} - #CodeManager\EventListener\TestLowPriorityListener: - # tags: - # - {name: doctrine.event_listener, event: postPersist, prority: 2} diff --git a/applications/asset_server/code_manager/phpunit.xml.dist b/applications/asset_server/code_manager/phpunit.xml.dist index 3034a39d6..76cf3a812 100644 --- a/applications/asset_server/code_manager/phpunit.xml.dist +++ b/applications/asset_server/code_manager/phpunit.xml.dist @@ -12,6 +12,8 @@ + + diff --git a/applications/asset_server/code_manager/src/Command/Abstractions/AbstractCommand.php b/applications/asset_server/code_manager/src/Command/Abstractions/AbstractCommand.php deleted file mode 100644 index 0f8a7bab2..000000000 --- a/applications/asset_server/code_manager/src/Command/Abstractions/AbstractCommand.php +++ /dev/null @@ -1,37 +0,0 @@ -setName(self::COMMAND_NAME) - ->setDescription(self::DESCRIPTION) - ->setHelp(self::HELP); - $this->add_required_arguments(); - } - - protected function execute(InputInterface $input, OutputInterface $output): ?int { - $this->input = $input; - $this->output = $output; - return $this->run_command(); - } - - abstract protected function add_required_arguments(): void; - - abstract protected function run_command(): int; -} diff --git a/applications/asset_server/code_manager/src/Command/CodeHealthCheckCommand.php b/applications/asset_server/code_manager/src/Command/CodeHealthCheckCommand.php index eaefe1c6e..4e4e054ab 100644 --- a/applications/asset_server/code_manager/src/Command/CodeHealthCheckCommand.php +++ b/applications/asset_server/code_manager/src/Command/CodeHealthCheckCommand.php @@ -1,44 +1,69 @@ -code_builder = $code_builder; + $this->db_health = $db_health; } protected function configure(): void { - $this + $this->setName(self::COMMAND_NAME) ->setDescription('Runs a code health check.') ->setHelp('Runs a health check across all files and settings for the all local code files in this project.'); } - protected function execute(InputInterface $input, OutputInterface $output) { - $this->code_builder->prepare_code_health_check($this->getApplication()); - $this->code_builder->run_code_health_check(); + /** + * Executes the current command. + * + * This method is not abstract because you can use this class + * as a concrete class. In this case, instead of defining the + * execute() method, you set the code to execute by passing + * a Closure to the setCode() method. + * + * @param InputInterface $input + * @param OutputInterface $output + * @return int|null null or 0 if everything went fine, or an error code + * + * @see setCode() + */ + protected function execute(InputInterface $input, OutputInterface $output): ?int { + $this->db_health->prepare_for_build_step($this->getApplication(), $this->code_builder); + $this->code_builder->run_code_health_check($this->db_health); #var_dump('TODO: run_composer_self_update'); - #$c = RUN::run_composer_self_update(PATH::get(PATH::COMPOSER)); + #$c = RUN::run_composer_self_update(); #var_dump($c); return 0; diff --git a/applications/asset_server/code_manager/src/Command/Prepared/DBSchemaUpdate.php b/applications/asset_server/code_manager/src/Command/Prepared/DBSchemaUpdate.php index 96a54fd66..a1cb0674b 100644 --- a/applications/asset_server/code_manager/src/Command/Prepared/DBSchemaUpdate.php +++ b/applications/asset_server/code_manager/src/Command/Prepared/DBSchemaUpdate.php @@ -1,18 +1,23 @@ - null, '--no-interaction' => null, '--force' => null diff --git a/applications/asset_server/code_manager/src/Command/Prepared/DBSchemaValidate.php b/applications/asset_server/code_manager/src/Command/Prepared/DBSchemaValidate.php index 3733fd5bf..98454285a 100644 --- a/applications/asset_server/code_manager/src/Command/Prepared/DBSchemaValidate.php +++ b/applications/asset_server/code_manager/src/Command/Prepared/DBSchemaValidate.php @@ -1,12 +1,14 @@ -exit_code !== 0) { # DBG::throw_exception('DB Health CMD had non 0 exit code{' . $this->exit_code . '} with output {' . $this->results . '}'); @@ -26,11 +34,11 @@ protected function on_command_completed(): void { $output = STR::split_into_non_empty_lines($this->results); if (count($output) !== 6) { - DBG::throw_exception('DB Check has invalid output<<' . json_encode($output) . '>>'); + throw LogicException::invalid_function_call('on_command_completed', 'DB Check has invalid output<<' . json_encode($output) . '>>'); } - $this->is_healthy_mapping = STR::contains($output[2], '[OK]'); - $this->is_healthy_schema = STR::contains($output[5], '[OK]'); + $this->is_healthy_mapping = STR::has($output[2], '[OK]'); + $this->is_healthy_schema = STR::has($output[5], '[OK]'); } public function is_healthy_schema(): bool { diff --git a/applications/asset_server/code_manager/src/Command/Abstractions/PreparedCommand.php b/applications/asset_server/code_manager/src/Command/Prepared/PreparedCommand.php similarity index 69% rename from applications/asset_server/code_manager/src/Command/Abstractions/PreparedCommand.php rename to applications/asset_server/code_manager/src/Command/Prepared/PreparedCommand.php index d0c0db7fd..18724b867 100644 --- a/applications/asset_server/code_manager/src/Command/Abstractions/PreparedCommand.php +++ b/applications/asset_server/code_manager/src/Command/Prepared/PreparedCommand.php @@ -1,18 +1,17 @@ -set_name($name); + /** + * @param Command $command + * @param array $input + */ + public function __construct(Command $command, array $input=[]) { $this->cmd = $command; $this->output = new BufferedOutput(); $this->input = new ArrayInput($input); } + /** + * @throws Exception + */ public function run_command(): void { $this->exit_code = $this->cmd->run($this->input, $this->output); $this->results = $this->output->fetch(); diff --git a/applications/asset_server/code_manager/src/Controller/QAController.php b/applications/asset_server/code_manager/src/Controller/QAController.php index 05e29fff0..e5c09f757 100644 --- a/applications/asset_server/code_manager/src/Controller/QAController.php +++ b/applications/asset_server/code_manager/src/Controller/QAController.php @@ -1,9 +1,9 @@ -files = new ArrayCollection(); + # $this->directories = new ArrayCollection(); + #} + + public function cache_needs_update(bool $trigger_update): bool { + return false; + } + + public function cache_update(bool $update_state=true): void {} + + public function on_event_born($data): void {} + + public function cache_calculate(string $cache_key) {} +} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Files/EntityFile.php b/applications/asset_server/code_manager/src/Entity/Abstractions/File/EntityFile.php similarity index 65% rename from applications/asset_server/code_manager/src/Entity/Abstractions/Files/EntityFile.php rename to applications/asset_server/code_manager/src/Entity/Abstractions/File/EntityFile.php index 9f494b1a1..6fabbfda0 100644 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Files/EntityFile.php +++ b/applications/asset_server/code_manager/src/Entity/Abstractions/File/EntityFile.php @@ -1,4 +1,4 @@ - self::TYPE_CSS, - UFO::EXTENSION_XML => self::TYPE_XML, - UFO::EXTENSION_HTML => self::TYPE_HTML, - UFO::EXTENSION_JSON => self::TYPE_JSON, - UFO::EXTENSION_SHADER_VERTEX => self::TYPE_SHADER_VERTEX, - UFO::EXTENSION_SHADER_FRAGMENT => self::TYPE_SHADER_FRAGMENT, - UFO::EXTENSION_WEB_MANIFEST => self::TYPE_WEB_MANIFEST, - UFO::EXTENSION_YAML => self::TYPE_YAML + EXTENSION::CSS => self::TYPE_CSS, + EXTENSION::XML => self::TYPE_XML, + EXTENSION::HTML => self::TYPE_HTML, + EXTENSION::JSON => self::TYPE_JSON, + EXTENSION::SHADER_VERTEX => self::TYPE_SHADER_VERTEX, + EXTENSION::SHADER_FRAGMENT => self::TYPE_SHADER_FRAGMENT, + EXTENSION::WEB_MANIFEST => self::TYPE_WEB_MANIFEST, + EXTENSION::YAML => self::TYPE_YAML ]; public const FLAG_MINIFY = 'minify'; @@ -141,29 +126,20 @@ public function before_remove(): void { private $content; /** - * @var bool - * @Column(name="is_gzipped", type="boolean", nullable=false, unique=false) - */ - private $is_gzipped; - - /** - * @var bool - * @Column(name="is_minified", type="boolean", nullable=false, unique=false) + * @inheritDoc */ - private $is_minified; - - /** - * @var bool - * @Column(name="is_pre_processed", type="boolean", nullable=false, unique=false) - */ - private $is_pre_processed; - - public function cache_set(string $key): void { + public function cache_calculate(string $key) { if ($key === self::CACHE_KEY_SHA512_SUM) { - $this->cached_values[$key] = UFO::get_sha512sum($this->getFullPath()); + return UFO::get_sha512sum($this->getFullPath()); } + return null; } + /** + * @param string $path + * @return int + * @throws LogicException + */ public static function get_file_type_from_path(string $path) : int { $all_extensions = PATH::get_all_extensions($path); foreach (self::EXTENSION_TO_TYPE as $extension => $type) { @@ -171,8 +147,7 @@ public static function get_file_type_from_path(string $path) : int { return $type; } } - DBG::throw_exception('No file type match for {' . $path . '}'); - return self::TYPE_NO_MATCH; + throw LogicException::invalid_function_call('get_file_type_from_path', 'No file type match for {' . $path . '}'); } public function get_flags(): array { @@ -209,15 +184,14 @@ public function set_flag(string $key, bool $value): void { * @throws Exception */ public function on_event_born($full_path): void { - $current_date_time = TIME::now(); - $this->setFirstCached($current_date_time); + $this->setUnixTimestamp0(-1); $this->setFullPath($full_path); $this->setTypeID(self::get_file_type_from_path($full_path)); $this->setRank(0); $this->setIsGzipped(false); $this->setIsMinified(false); $this->setIsPreProcessed(false); - $this->setName(UPO::get_file_name($full_path)); + $this->setText0(UPO::get_file_name($full_path)); $this->setExtension(UPO::get_ending_extension($full_path)); $this->cache_update(false); } @@ -234,12 +208,15 @@ public function cache_needs_update(bool $trigger_update): bool { } /** - * When DB values are out of date compared to the file's current values, this function is called to re-update those values. - * @param bool $update_state + * Called when DB values are out of date compared to the file's current values (to then update them if needed). + * + * @param bool $update_state [If the Entity state should be updated.] + * + * @return void * @throws Exception */ - public function cache_update(bool $update_state=true): void { - $this->setLastCached(TIME::now()); + public function cache_update(bool $update_state = true): void { + $this->setUnixTimestampEnd(-1); $this->setSizeInBytes(UFO::get_size($this->full_path)); $this->setSha512sum($this->cache_get(self::CACHE_KEY_SHA512_SUM)); if ($update_state) { @@ -250,7 +227,7 @@ public function cache_update(bool $update_state=true): void { /** * @return EntityDirectory */ - public function getDirectory() : EntityDirectory { + public function getDirectory(): EntityDirectory { return $this->directory; } @@ -258,19 +235,19 @@ public function getDirectory() : EntityDirectory { * @param $directory * @return self */ - public function setDirectory(EntityDirectory $directory) : self { + public function setDirectory(EntityDirectory $directory): self { $this->directory = $directory; return $this; } - public function getFullName() : string { + public function getFullName(): string { return $this->name . $this->extension; } /** * @return mixed */ - public function getExtension() : string { + public function getExtension(): string { return $this->extension; } @@ -278,7 +255,7 @@ public function getExtension() : string { * @param mixed $extension * @return self */ - public function setExtension($extension) : self { + public function setExtension($extension): self { $this->extension = $extension; return $this; } @@ -384,7 +361,7 @@ public function to_full_string(?EntityFile $relative_to=null) : string { if ($relative_to !== null) { $base = $this->getSizeInBytes(); $new = $relative_to->getSizeInBytes(); - $dif = MATH::get_percentage_decreased($base, $new, true); + $dif = MATH::percentage_decreased($base, $new, true); $info .= "\tsize{" . $base . '} to {' . $new . '}, reduction of(' . $dif . ')' . PHP_EOL; } else { $info .= "\tsize{" . $this->getSizeInBytes() . '}' . PHP_EOL; @@ -403,58 +380,10 @@ public function __toString() { return 'EntityFile{' . $this->getFullPath() . '}'; } - /** - * @return bool - */ - public function getIsGzipped() : bool { - return $this->is_gzipped; - } - - /** - * @param bool $is_gzipped - * @return self - */ - public function setIsGzipped(bool $is_gzipped): self { - $this->is_gzipped = $is_gzipped; - return $this; - } - - /** - * @return bool - */ - public function getIsMinified(): bool { - return $this->is_minified; - } - - /** - * @param bool $is_minified - * @return self - */ - public function setIsMinified(bool $is_minified): self { - $this->is_minified = $is_minified; - return $this; - } - - /** - * @return bool - */ - public function getIsPreProcessed(): bool { - return $this->is_pre_processed; - } - - /** - * @param bool $is_pre_processed - * @return self - */ - public function setIsPreProcessed(bool $is_pre_processed): self { - $this->is_pre_processed = $is_pre_processed; - return $this; - } - // ------ U T I L I T Y ------ public function get_full_name_minified() : string { - return $this->name . UFO::EXTENSION_MINIFIED . $this->extension; + return $this->name . EXTENSION::MINIFIED . $this->extension; } public function get_full_name_processed() : string { @@ -462,6 +391,6 @@ public function get_full_name_processed() : string { } public function get_full_name_gzipped() : string { - return $this->getFullName() . UFO::EXTENSION_GZIPPED; + return $this->getFullName() . EXTENSION::GZIPPED; } } diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/File/EntityFileType.php b/applications/asset_server/code_manager/src/Entity/Abstractions/File/EntityFileType.php new file mode 100644 index 000000000..bcbb0e047 --- /dev/null +++ b/applications/asset_server/code_manager/src/Entity/Abstractions/File/EntityFileType.php @@ -0,0 +1,30 @@ +files = new ArrayCollection(); - $this->directories = new ArrayCollection(); - } - - /** - * @return mixed - */ - public function getPath() { - return $this->path; - } - - /** - * @param mixed $path - * @return self - */ - public function setPath($path) : self { - $this->path = $path; - return $this; - } - - /** - * @return mixed - */ - public function getParentDirectory() { - return $this->parent_directory; - } - - /** - * @param mixed $parent_directory - * @return self - */ - public function setParentDirectory($parent_directory) : self { - $this->parent_directory = $parent_directory; - return $this; - } - - /** - * @return mixed - */ - public function getFiles() : Collection { - return $this->files; - } - - /** - * @param mixed $files - * @return self - */ - public function setFiles($files) : self { - $this->files = $files; - return $this; - } - - /** - * @return mixed - */ - public function getDirectories() { - return $this->directories; - } - - /** - * @param mixed $directories - * @return self - */ - public function setDirectories($directories) : self { - $this->directories = $directories; - return $this; - } - - public function cache_needs_update(bool $trigger_update): bool { - return false; - } - - public function cache_update(bool $update_state=true): void {} - - public function on_event_born($data): void {} - - public function cache_set(string $cache_key): void {} -} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Boolean/FieldBoolean.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Boolean/FieldBoolean.php new file mode 100644 index 000000000..07120b68d --- /dev/null +++ b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Boolean/FieldBoolean.php @@ -0,0 +1,34 @@ +bool0; + } + + /** + * @param bool $bool0 + * @return self + */ + public function setBooleanValue0(bool $bool0): self { + $this->bool0 = $bool0; + return $this; + } +} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Boolean/FieldBooleanThree.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Boolean/FieldBooleanThree.php new file mode 100644 index 000000000..9999d8a56 --- /dev/null +++ b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Boolean/FieldBooleanThree.php @@ -0,0 +1,31 @@ +bool2; + } + + /** + * @param bool $bool2 + * @return self + */ + public function setBooleanValue2(bool $bool2): self { + $this->bool2 = $bool2; + return $this; + } +} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Boolean/FieldBooleanTwo.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Boolean/FieldBooleanTwo.php new file mode 100644 index 000000000..651dcff6f --- /dev/null +++ b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Boolean/FieldBooleanTwo.php @@ -0,0 +1,31 @@ +bool1; + } + + /** + * @param bool $bool1 + * @return self + */ + public function setBooleanValue1(bool $bool1): self { + $this->bool1 = $bool1; + return $this; + } +} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Boolean/FieldLibVersionUpdated.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Boolean/FieldLibVersionUpdated.php deleted file mode 100644 index 138ec6446..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Boolean/FieldLibVersionUpdated.php +++ /dev/null @@ -1,30 +0,0 @@ -lib_version_updated; - } - - /** - * @param bool $lib_version_updated - * @return self - */ - public function setLibVersionUpdated(bool $lib_version_updated): self { - $this->lib_version_updated = $lib_version_updated; - return $this; - } -} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Boolean/FieldOptional.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Boolean/FieldOptional.php deleted file mode 100644 index 477d96b17..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Boolean/FieldOptional.php +++ /dev/null @@ -1,30 +0,0 @@ -optional; - } - - /** - * @param bool $optional - * @return self - */ - public function setOptional(bool $optional): self { - $this->optional = $optional; - return $this; - } -} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Enum/EntityFields.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Enum/EntityFields.php new file mode 100644 index 000000000..9a20c8c88 --- /dev/null +++ b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Enum/EntityFields.php @@ -0,0 +1,12 @@ +duration; - } - - /** - * @param float $duration - * @return self - */ - public function setDuration(float $duration): self { - $this->duration = $duration; - return $this; - } -} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Decimal/FieldFloat.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Decimal/FieldFloat.php new file mode 100644 index 000000000..895f5db9d --- /dev/null +++ b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Decimal/FieldFloat.php @@ -0,0 +1,30 @@ +float0; + } + + /** + * @param float $float0 + * @return self + */ + public function setFloat0(float $float0): self { + $this->float0 = $float0; + return $this; + } +} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldCashAmount.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldCashAmount.php deleted file mode 100644 index e1664f9d7..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldCashAmount.php +++ /dev/null @@ -1,32 +0,0 @@ -amount; - } - - /** - * @param int $amount - * @return self - */ - public function setAmount(int $amount): self { - $this->amount = $amount; - return $this; - } - -} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldInt.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldInt.php new file mode 100644 index 000000000..bc8ca51e5 --- /dev/null +++ b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldInt.php @@ -0,0 +1,41 @@ +int0; + } + + /** + * @param int $int0 + * @return self + */ + public function setInt0(int $int0): self { + $this->int0 = $int0; + return $this; + } + + /** + * @param int $n + * @return bool + */ + public function isInt0EqualTo(int $n): bool { + return $this->int0 === $n; + } + +} + diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldIntFour.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldIntFour.php new file mode 100644 index 000000000..50c1dfa18 --- /dev/null +++ b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldIntFour.php @@ -0,0 +1,34 @@ +int3; + } + + /** + * @param int $int3 + * @return self + */ + public function setInt3(int $int3): self { + $this->int3 = $int3; + return $this; + } + +} + diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldIntThree.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldIntThree.php new file mode 100644 index 000000000..84e0b50a6 --- /dev/null +++ b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldIntThree.php @@ -0,0 +1,34 @@ +int2; + } + + /** + * @param int $int2 + * @return self + */ + public function setInt2(int $int2): self { + $this->int2 = $int2; + return $this; + } + +} + diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldIntTwo.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldIntTwo.php new file mode 100644 index 000000000..cde341a80 --- /dev/null +++ b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldIntTwo.php @@ -0,0 +1,34 @@ +int1; + } + + /** + * @param int $int1 + * @return self + */ + public function setInt1(int $int1): self { + $this->int1 = $int1; + return $this; + } + +} + diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldNumElements.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldNumElements.php deleted file mode 100644 index 84366c8ab..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldNumElements.php +++ /dev/null @@ -1,30 +0,0 @@ -number_of_elements; - } - - /** - * @param int $number_of_elements - * @return self - */ - public function setNumElements(int $number_of_elements): self { - $this->number_of_elements = $number_of_elements; - return $this; - } -} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldNumErrors.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldNumErrors.php deleted file mode 100644 index 770060a7a..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldNumErrors.php +++ /dev/null @@ -1,31 +0,0 @@ -num_errors; - } - - /** - * @param int $num_errors - * @return self - */ - public function setNumErrors(int $num_errors): self { - $this->num_errors = $num_errors; - return $this; - } - -} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldNumFailed.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldNumFailed.php deleted file mode 100644 index 23c94b6be..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldNumFailed.php +++ /dev/null @@ -1,31 +0,0 @@ -num_failed; - } - - /** - * @param int $num_failed - * @return self - */ - public function setNumFailed(int $num_failed): self { - $this->num_failed = $num_failed; - return $this; - } - -} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldNumSkipped.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldNumSkipped.php deleted file mode 100644 index 7235d2f84..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldNumSkipped.php +++ /dev/null @@ -1,30 +0,0 @@ -num_skipped; - } - - /** - * @param int $num_skipped - * @return self - */ - public function setNumSkipped(int $num_skipped): self { - $this->num_skipped = $num_skipped; - return $this; - } -} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldRank.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldRank.php deleted file mode 100644 index 68094d59a..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldRank.php +++ /dev/null @@ -1,33 +0,0 @@ -rank; - } - - /** - * @param int $rank - * @return self - */ - public function setRank(int $rank): self { - $this->rank = $rank; - return $this; - } - -} - diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldSizeInBytes.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldSizeInBytes.php deleted file mode 100644 index e25a8fa0b..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldSizeInBytes.php +++ /dev/null @@ -1,29 +0,0 @@ -size_in_bytes; - } - - /** - * @param int $sizeInBytes - * @return self - */ - public function setSizeInBytes(int $sizeInBytes) : self { - $this->size_in_bytes = $sizeInBytes; - return $this; - } -} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldTypeID.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldTypeID.php deleted file mode 100644 index 22a500267..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Number/Whole/FieldTypeID.php +++ /dev/null @@ -1,35 +0,0 @@ -type_id; - } - - /** - * @param int $type_id - * @return self - */ - public function setTypeID(int $type_id) : self { - $this->type_id = $type_id; - return $this; - } - -} - - - diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldEntityPointer.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldEntityPointer.php new file mode 100644 index 000000000..3e835e5c8 --- /dev/null +++ b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldEntityPointer.php @@ -0,0 +1,31 @@ +entity_pointer0; + } + + /** + * @param int $entity_0_id + * @return self + */ + public function setEntityPointer0(int $entity_0_id): self { + $this->entity_pointer0 = $entity_0_id; + return $this; + } + +} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldEntityPointerTwo.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldEntityPointerTwo.php new file mode 100644 index 000000000..469cb63e4 --- /dev/null +++ b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldEntityPointerTwo.php @@ -0,0 +1,31 @@ +entity_pointer1; + } + + /** + * @param int $entity_1_id + * @return self + */ + public function setEntityPointer1(int $entity_1_id): self { + $this->entity_pointer1 = $entity_1_id; + return $this; + } + +} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldFromUser.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldFromUser.php deleted file mode 100644 index 2c510f312..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldFromUser.php +++ /dev/null @@ -1,32 +0,0 @@ -fromUser; - } - - /** - * @param EntityUser $fromUser - * @return self - */ - public function setFromUser(EntityUser $fromUser): self { - $this->fromUser = $fromUser; - return $this; - } - -} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldFromVendor.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldFromVendor.php deleted file mode 100644 index 452a2975d..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldFromVendor.php +++ /dev/null @@ -1,32 +0,0 @@ -fromVendor; - } - - /** - * @param EntityVendor $fromVendor - * @return self - */ - public function setFromVendor(EntityVendor $fromVendor): self { - $this->fromVendor = $fromVendor; - return $this; - } - -} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldHasPointerToBankTransactionType.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldHasPointerToBankTransactionType.php deleted file mode 100644 index 328d42943..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldHasPointerToBankTransactionType.php +++ /dev/null @@ -1,30 +0,0 @@ -type; - } - - /** - * @param EntityBankTransactionType $type - * @return self - */ - public function setType(EntityBankTransactionType $type): self { - $this->type = $type; - return $this; - } -} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldHasPointerToDBSnapshot.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldHasPointerToDBSnapshot.php deleted file mode 100644 index 0e997ce8e..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldHasPointerToDBSnapshot.php +++ /dev/null @@ -1,31 +0,0 @@ -db_snapshot; - } - - /** - * @param EntityDBSnapshot $db_snapshot - * @return self - */ - public function setDbSnapshot(EntityDBSnapshot $db_snapshot): self { - $this->db_snapshot = $db_snapshot; - return $this; - } -} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldHasPointerToEntityFile.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldHasPointerToEntityFile.php deleted file mode 100644 index 86baa33c7..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldHasPointerToEntityFile.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @return EntityFile - */ - public function getEntityFile(bool $raise_exception_if_null=false): EntityFile { - if ($raise_exception_if_null && $this->entity_file === null) { - DBG::throw_exception('EntityQAReport does not have {entity_file} set.'); - } - return $this->entity_file; - } - - /** - * @param EntityFile $entity_file - * @return self - */ - public function setEntityFile(EntityFile $entity_file): self { - $this->entity_file = $entity_file; - return $this; - } -} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldHasPointerToQAReport.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldHasPointerToQAReport.php deleted file mode 100644 index 12b3ec2a0..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldHasPointerToQAReport.php +++ /dev/null @@ -1,31 +0,0 @@ -qa_results; - } - - /** - * @param EntityQAReport $qa_results - * @return self - */ - public function setQaResults(EntityQAReport $qa_results): self { - $this->qa_results = $qa_results; - return $this; - } -} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldHasPointerToUserRole.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldHasPointerToUserRole.php deleted file mode 100644 index d9d8deb37..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldHasPointerToUserRole.php +++ /dev/null @@ -1,31 +0,0 @@ -role; - } - - /** - * @param EntityUserRole $role - * @return self - */ - public function setRole(EntityUserRole $role): self { - $this->role = $role; - return $this; - } -} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldHasPointerToVendorCategory.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldHasPointerToVendorCategory.php deleted file mode 100644 index 03716befa..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldHasPointerToVendorCategory.php +++ /dev/null @@ -1,31 +0,0 @@ -category; - } - - /** - * @param EntityVendorCategory $category - * @return self - */ - public function setCategory(EntityVendorCategory $category): self { - $this->category = $category; - return $this; - } -} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldToUser.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldToUser.php deleted file mode 100644 index b6b7c6de8..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldToUser.php +++ /dev/null @@ -1,32 +0,0 @@ -toUser; - } - - /** - * @param EntityUser $toUser - * @return self - */ - public function setToUser(EntityUser $toUser): self { - $this->toUser = $toUser; - return $this; - } - -} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldToVendor.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldToVendor.php deleted file mode 100644 index bd1aaacc3..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Relations/FieldToVendor.php +++ /dev/null @@ -1,32 +0,0 @@ -toVendor; - } - - /** - * @param EntityVendor $toVendor - * @return self - */ - public function setToVendor(EntityVendor $toVendor): self { - $this->toVendor = $toVendor; - return $this; - } - -} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldDescription.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldDescription.php deleted file mode 100644 index ab6599d87..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldDescription.php +++ /dev/null @@ -1,33 +0,0 @@ -description; - } - - /** - * @param string $description - * @return self - */ - public function setDescription(string $description): self { - $this->description = $description; - return $this; - } - -} - diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldDetails.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldDetails.php deleted file mode 100644 index f35ea0bbb..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldDetails.php +++ /dev/null @@ -1,35 +0,0 @@ -details; - } - - /** - * @param string $details - * @return self - */ - public function setDetails(string $details): self { - $this->details = $details; - return $this; - } - -} - - - diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldEmail.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldEmail.php deleted file mode 100644 index 9239dae83..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldEmail.php +++ /dev/null @@ -1,35 +0,0 @@ -email; - } - - /** - * @param string $email - * @return self - */ - public function setEmail(string $email): self { - $this->email = $email; - return $this; - } - -} - - - diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldJSONMetaData.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldJSONMetaData.php deleted file mode 100644 index bfa1e3d92..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldJSONMetaData.php +++ /dev/null @@ -1,35 +0,0 @@ -json_meta_data; - } - - /** - * @param string $json_meta_data - * @return self - */ - public function setJSONMetaData(string $json_meta_data): self { - $this->json_meta_data = $json_meta_data; - return $this; - } - -} - - - diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldName.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldName.php deleted file mode 100644 index 2f5a899fd..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldName.php +++ /dev/null @@ -1,35 +0,0 @@ -name; - } - - /** - * @param string $name - * @return self - */ - public function setName(string $name): self { - $this->name = $name; - return $this; - } - -} - - - diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldPassword.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldPassword.php deleted file mode 100644 index d42b1453f..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldPassword.php +++ /dev/null @@ -1,33 +0,0 @@ -password; - } - - /** - * @param string $password - * @return self - */ - public function setPassword(string $password): self { - $this->password = $password; - return $this; - } - -} - diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldSHA512Sum.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldSHA512Sum.php deleted file mode 100644 index dd7d92d89..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldSHA512Sum.php +++ /dev/null @@ -1,32 +0,0 @@ -sha512sum; - } - - /** - * @param string $sha512sum - * @return self - */ - public function setSha512sum(string $sha512sum) : self { - $this->sha512sum = $sha512sum; - return $this; - } - -} - diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldText.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldText.php new file mode 100644 index 000000000..67cdbd850 --- /dev/null +++ b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldText.php @@ -0,0 +1,35 @@ +text0; + } + + /** + * @param string $text0 + * @return self + */ + public function setText0(string $text0): self { + $this->text0 = $text0; + return $this; + } + +} + + + diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldTextThree.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldTextThree.php new file mode 100644 index 000000000..7eb364a67 --- /dev/null +++ b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldTextThree.php @@ -0,0 +1,34 @@ +text2; + } + + /** + * @param string $text2 + * @return self + */ + public function setText2(string $text2): self { + $this->text2 = $text2; + return $this; + } +} + + + diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldTextTwo.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldTextTwo.php new file mode 100644 index 000000000..000945e2d --- /dev/null +++ b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldTextTwo.php @@ -0,0 +1,36 @@ +text1; + } + + /** + * @param string $text1 + * @return self + */ + public function setText1(string $text1): self { + $this->text1 = $text1; + return $this; + } + +} + + + diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldVersionLatest.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldVersionLatest.php deleted file mode 100644 index 52c8b6acc..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldVersionLatest.php +++ /dev/null @@ -1,34 +0,0 @@ -version_latest; - } - - /** - * @param string $version_latest - * @return self - */ - public function setVersionLatest(string $version_latest): self { - $this->version_latest = $version_latest; - return $this; - } -} - - - diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldVersionLocal.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldVersionLocal.php deleted file mode 100644 index c487b47b7..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Text/FieldVersionLocal.php +++ /dev/null @@ -1,34 +0,0 @@ -version_local; - } - - /** - * @param string $version_local - * @return self - */ - public function setVersionLocal(string $version_local): self { - $this->version_local = $version_local; - return $this; - } -} - - - diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldCreatedAt.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldCreatedAt.php deleted file mode 100644 index 8628fa301..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldCreatedAt.php +++ /dev/null @@ -1,36 +0,0 @@ -created_at; - } - - /** - * @param DateTime $created_at - * @return self - */ - public function setCreatedAt(DateTime $created_at): self { - $this->created_at = $created_at; - return $this; - } - -} - - - diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldFirstCached.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldFirstCached.php deleted file mode 100644 index de7f1fba4..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldFirstCached.php +++ /dev/null @@ -1,36 +0,0 @@ -first_cached; - } - - /** - * @param DateTime $first_cached - * @return self - */ - public function setFirstCached(DateTime $first_cached): self { - $this->first_cached = $first_cached; - return $this; - } - -} - - - diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldLastCached.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldLastCached.php deleted file mode 100644 index eddd78010..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldLastCached.php +++ /dev/null @@ -1,36 +0,0 @@ -last_cached; - } - - /** - * @param DateTime $last_cached - * @return self - */ - public function setLastCached(DateTime $last_cached): self { - $this->last_cached = $last_cached; - return $this; - } - -} - - - diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldLastChecked.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldLastChecked.php deleted file mode 100644 index 823297306..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldLastChecked.php +++ /dev/null @@ -1,33 +0,0 @@ -last_checked; - } - - /** - * @param DateTime $last_checked - * @return self - */ - public function setLastChecked(DateTime $last_checked): self { - $this->last_checked = $last_checked; - return $this; - } - -} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldLastLogin.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldLastLogin.php deleted file mode 100644 index dd14ad9f1..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldLastLogin.php +++ /dev/null @@ -1,33 +0,0 @@ -last_login; - } - - /** - * @param DateTime $last_login - * @return self - */ - public function setLastLogin(DateTime $last_login): self { - $this->last_login = $last_login; - return $this; - } - -} diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldRanAt.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldRanAt.php deleted file mode 100644 index 2f6630442..000000000 --- a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldRanAt.php +++ /dev/null @@ -1,39 +0,0 @@ -ran_at; - } - - /** - * @param DateTime $ran_at - * @return self - */ - public function setRanAt(DateTime $ran_at): self { - $this->ran_at = $ran_at; - return $this; - } - - public function setRanAtNow(): self { - return $this->setRanAt(TIME::now()); - } - -} - diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldUnixTime.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldUnixTime.php new file mode 100644 index 000000000..e611ecc92 --- /dev/null +++ b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldUnixTime.php @@ -0,0 +1,38 @@ +unix_timestamp0; + } + + /** + * @param int $unix_timestamp0 + * @return self + */ + public function setUnixTimestamp0(int $unix_timestamp0=-1): self { + if ($unix_timestamp0 === -1) { + $this->unix_timestamp0 = UNIX::now(); + } else { + $this->unix_timestamp0 = $unix_timestamp0; + } + return $this; + } + +} + diff --git a/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldUnixTimeTwo.php b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldUnixTimeTwo.php new file mode 100644 index 000000000..8cd5ab3cf --- /dev/null +++ b/applications/asset_server/code_manager/src/Entity/Abstractions/Traits/Time/FieldUnixTimeTwo.php @@ -0,0 +1,39 @@ +unix_timestamp1; + } + + /** + * @param int $unix_timestamp1 + * @return self + */ + public function setUnixTimestamp1(int $unix_timestamp1=-1): self { + if ($unix_timestamp1 === -1) { + $this->unix_timestamp1 = UNIX::now(); + } else { + $this->unix_timestamp1 = $unix_timestamp1; + } + return $this; + } + +} + diff --git a/applications/asset_server/code_manager/src/Entity/CodeManager/EntityCodeBuild.php b/applications/asset_server/code_manager/src/Entity/CodeManager/EntityCodeBuild.php index 0c7a18323..6feb1cfa6 100644 --- a/applications/asset_server/code_manager/src/Entity/CodeManager/EntityCodeBuild.php +++ b/applications/asset_server/code_manager/src/Entity/CodeManager/EntityCodeBuild.php @@ -1,15 +1,14 @@ -setUnixTimestamp0(-1); + $this->setInt0($build_type); + } + + public function is_mode_rushed(): bool { + return $this->isInt0EqualTo(self::BUILD_TYPE_RUSH); + } + + #public function get_current_db_snapshot(): EntityDBSnapshot { + # return + #} } diff --git a/applications/asset_server/code_manager/src/Entity/CodeManager/EntityDBSnapshot.php b/applications/asset_server/code_manager/src/Entity/CodeManager/EntityDBSnapshot.php index 30f99d7dd..72d305598 100644 --- a/applications/asset_server/code_manager/src/Entity/CodeManager/EntityDBSnapshot.php +++ b/applications/asset_server/code_manager/src/Entity/CodeManager/EntityDBSnapshot.php @@ -1,15 +1,13 @@ -cached_values[$key] = RUN::get_npm_lib_latest_version($this->getName()); + return RUN::get_npm_lib_latest_version($this->getName()); } + return null; } public function cache_needs_inspection() : bool { - $last_checked = $this->getLastChecked(); - if (DATE::is_different_day($last_checked, DATE::now())) { - $this->setLastChecked(TIME::now()); - return true; - } + $last_checked = $this->getUnixTimestamp(); + var_dump('Last checked is {' . $last_checked . '}'); + + + #if (DATE::is_different_day($last_checked, DATE::now())) { + # $this->setLastChecked(TIME::now()); + # return true; + #} return false; } @@ -88,7 +76,7 @@ public function cache_update(bool $update_state=true): void { public function on_event_born($data): void { $latest_version = RUN::get_npm_lib_latest_version($data); - PATH::cwd_push(PATH::get(PATH::NODE_DIR)); + PATH::cwd_push(\CodeManager\Enum\ProjectParameterKeys\Path::DIRECTORY_NODE); $current_version = RUN::get_npm_lib_version_local($data); PATH::cwd_pop(); $this->setName($data); diff --git a/applications/asset_server/code_manager/src/Entity/CodeManager/EntityQAReport.php b/applications/asset_server/code_manager/src/Entity/CodeManager/EntityQAReport.php index 098ea5962..a88538684 100644 --- a/applications/asset_server/code_manager/src/Entity/CodeManager/EntityQAReport.php +++ b/applications/asset_server/code_manager/src/Entity/CodeManager/EntityQAReport.php @@ -1,4 +1,4 @@ -cached_values[$key] = new ProjectTestSuiteResult($this->entity_file->getFullPath()); + return new ProjectTestSuiteResult($this->entity_file->getFullPath()); } + return null; } public function cache_update(bool $update_state=true) : void { @@ -94,7 +77,7 @@ public function cache_update(bool $update_state=true) : void { ->setDuration($qa_results->get_time_taken()) ->setNumElements($qa_results->get_num_tests()) ->setNumSkipped($qa_results->get_num_skipped()) - ->setRanAtNow() + ->setUnixTimestamp(-1) ->setJSONMetaData($qa_results->get_qa_report()); } diff --git a/applications/asset_server/code_manager/src/Entity/Finance/Bank/EntityBankTransaction.php b/applications/asset_server/code_manager/src/Entity/Finance/Bank/EntityBankTransaction.php new file mode 100644 index 000000000..9dac74f52 --- /dev/null +++ b/applications/asset_server/code_manager/src/Entity/Finance/Bank/EntityBankTransaction.php @@ -0,0 +1,32 @@ + +asset_server | int(82867589) +asset_server | ["clientOrderId"]=> +asset_server | string(22) "Sl9EcSrqAguN3fFRjpuVVh" +asset_server | ["price"]=> +asset_server | string(10) "0.00004155" +asset_server | ["origQty"]=> +asset_server | string(13) "2000.00000000" +asset_server | ["executedQty"]=> +asset_server | string(13) "2000.00000000" +asset_server | ["cummulativeQuoteQty"]=> +asset_server | string(10) "0.08310000" +asset_server | ["status"]=> +asset_server | string(6) "FILLED" +asset_server | ["timeInForce"]=> +asset_server | string(3) "GTC" +asset_server | ["type"]=> +asset_server | string(5) "LIMIT" +asset_server | ["side"]=> +asset_server | string(3) "BUY" +asset_server | ["stopPrice"]=> +asset_server | string(10) "0.00000000" +asset_server | ["icebergQty"]=> +asset_server | string(10) "0.00000000" +asset_server | ["time"]=> +asset_server | int(1559463867238) +asset_server | ["updateTime"]=> +asset_server | int(1559463873069) +asset_server | ["isWorking"]=> +asset_server | bool(true) +asset_server | } + */ \ No newline at end of file diff --git a/applications/asset_server/code_manager/src/Entity/Finance/Binance/EntityBinanceTrade.php b/applications/asset_server/code_manager/src/Entity/Finance/Binance/EntityBinanceTrade.php new file mode 100644 index 000000000..74a80e59d --- /dev/null +++ b/applications/asset_server/code_manager/src/Entity/Finance/Binance/EntityBinanceTrade.php @@ -0,0 +1,25 @@ + VendorToVendor, 1 --> VendorToUser, 2 --> UserToUser, 3 --> UserToVendor + use FieldInt; + // A pointer from Entity and pointer to Entity. + use FieldEntityPointerTwo; } diff --git a/applications/asset_server/code_manager/src/Entity/Users/EntityUser.php b/applications/asset_server/code_manager/src/Entity/Users/EntityUser.php index c7bfac3df..edcb2e1eb 100644 --- a/applications/asset_server/code_manager/src/Entity/Users/EntityUser.php +++ b/applications/asset_server/code_manager/src/Entity/Users/EntityUser.php @@ -1,4 +1,4 @@ -getProjectDir().'/config/bundles.php'; - foreach ($contents as $class => $envs) { - if ($envs[$this->environment] ?? $envs['all'] ?? false) { - yield new $class(); - } - } + yield new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(); + yield new \Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(); + yield new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(); + yield new \Symfony\Bundle\MonologBundle\MonologBundle(); } + /** + * @return string + */ public function getProjectDir(): string { - return dirname(__DIR__); + if ($this->project_directory === null) { + $this->project_directory = dirname(__DIR__); + } + return $this->project_directory; } + /** + * @param ContainerBuilder $container + * @param LoaderInterface $loader + * @throws Exception + */ protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void { - $container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php')); - $container->setParameter('container.dumper.inline_class_loader', true); - $confDir = $this->getProjectDir().'/config'; + var_dump('CONFIGURE CONTAINER!'); + foreach ([PATHS::DIRECTORY_PROJECT, PATHS::DIRECTORY_CODE_MANAGER, PATHS::PROJECT_CONFIG, PATHS::PROJECT_BUNDLES, PATHS::NODE_MINIFY_CSS, PATHS::NODE_MINIFY_HTML, PATHS::NODE_MINIFY_JS] as $key) { + $container->setParameter($key, getenv($key)); + } + + $container->setParameter(SCHEMAS::YAML_CODE_MANAGER, [ + 'global_information' => null, + 'assets' => [ + '.css' => null, + '.html' => null, + '.json' => null, + '.vert' => null, + '.frag' => null + ], + 'npm' => null, + 'qa_report' => null, + 'docker' => null, + 'projects' => null + ]); + $container->setParameter(SCHEMAS::YAML_ASSETS, [ + [PATHS::DIRECTORY_OUTPUT => null, PATHS::DIRECTORY_DATA => null, 'files' => null] + ]); - $loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob'); - $loader->load($confDir.'/{packages}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob'); + $container->addResource(new FileResource($container->getParameter(PATHS::PROJECT_BUNDLES))); + $container->setParameter('container.dumper.inline_class_loader', true); + $confDir = $this->getProjectDir() . '/config'; + $loader->load($confDir.'/{packages}/*.yaml', 'glob'); + $loader->load($confDir.'/{packages}/'.$this->environment.'/**/*.yaml', 'glob'); $loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob'); $loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob'); } + /** + * @param RouteCollectionBuilder $routes + * @throws LoaderLoadException + */ protected function configureRoutes(RouteCollectionBuilder $routes): void { - $confDir = $this->getProjectDir().'/config'; - - $routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob'); - $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob'); - $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob'); + $conf_dir = dirname(__DIR__).'/config/{routes}'; + $routes->import($conf_dir.'/'.$this->environment.'/**/*.yaml', '/', 'glob'); + $routes->import($conf_dir.'/*'.self::CONFIG_EXTS, '/', 'glob'); + $routes->import($conf_dir.self::CONFIG_EXTS, '/', 'glob'); } } diff --git a/applications/asset_server/code_manager/src/Repository/Abstractions/AbstractRepository.php b/applications/asset_server/code_manager/src/Repository/Abstractions/AbstractRepository.php index 8f3a93d8e..e5e6a56b3 100644 --- a/applications/asset_server/code_manager/src/Repository/Abstractions/AbstractRepository.php +++ b/applications/asset_server/code_manager/src/Repository/Abstractions/AbstractRepository.php @@ -1,26 +1,31 @@ -event_before_remove_entity($entity); try { $this->_em->remove($entity); } catch (ORMException $e) { - DBG::throw_exception($e->getMessage()); + throw ExceptionDB::doctrine_error($e->getMessage()); } if ($save_db_state) { $this->flush(); } } + /** + * @param $entity + * @param bool $save_db_state + * @throws ExceptionDB + */ public function save_entity($entity, bool $save_db_state=false): void { try { $this->_em->persist($entity); } catch (ORMException $e) { - DBG::throw_exception($e->getMessage()); + throw ExceptionDB::doctrine_error($e->getMessage()); } if ($save_db_state) { $this->flush(); } } + /** + * @throws ExceptionDB + */ private function flush(): void { try { $this->_em->flush(); } catch (OptimisticLockException $e) { - DBG::throw_exception($e->getMessage()); + throw ExceptionDB::doctrine_error($e->getMessage()); } catch (ORMException $e) { - DBG::throw_exception($e->getMessage()); + throw ExceptionDB::doctrine_error($e->getMessage()); } } diff --git a/applications/asset_server/code_manager/src/Repository/Abstractions/QueryableRepository.php b/applications/asset_server/code_manager/src/Repository/Abstractions/QueryableRepository.php deleted file mode 100644 index cf2bcace6..000000000 --- a/applications/asset_server/code_manager/src/Repository/Abstractions/QueryableRepository.php +++ /dev/null @@ -1,72 +0,0 @@ -connection = $this->_em->getConnection(); - } - - public function set_table_name(string $table_name): void { - $this->table_name = $table_name; - } - - public function set_sort_field_time(string $field_name): void { - $this->sort_field_time = $field_name; - } - - protected function execute_query(string $sql, bool $single_result=false): ?array { - $statement = $this->connection->prepare($sql); - $statement->execute(); - $results = $statement->fetchAll(); - if ($single_result) { - if (count($results) !== 0) { - return $results[0]; - } - return null; - } - return $results; - } - - protected function get_table_size(): ?int { - $result = $this->execute_query(TABLE::get_size($this->table_name), true); - if ($result !== null) { - return $result['pg_total_relation_size']; - } - return null; - } - - protected function get_newest_entity() { - return $this->execute_query(TABLE::get_latest($this->table_name, $this->sort_field_time), true); - } - - protected function get_oldest_entity() { - return $this->execute_query(TABLE::get_oldest($this->table_name, $this->sort_field_time), true); - } - -} diff --git a/applications/asset_server/code_manager/src/Repository/CodeManager/EntityCodeBuildRepository.php b/applications/asset_server/code_manager/src/Repository/CodeManager/EntityCodeBuildRepository.php index d3ea6511d..f9e1e62a0 100644 --- a/applications/asset_server/code_manager/src/Repository/CodeManager/EntityCodeBuildRepository.php +++ b/applications/asset_server/code_manager/src/Repository/CodeManager/EntityCodeBuildRepository.php @@ -1,25 +1,46 @@ -set_table_name(EntityCodeBuild::TABLE_NAME); - $this->set_sort_field_time(EntityCodeBuild::SORT_FIELD_TIME); + $this->query_manager->set_table_name(TABLE::CODE_BUILDS); + $this->query_manager->set_sort_field(FIELD::TIME_START); + } + + public function fetch_or_generate_last_build(): EntityCodeBuild { + var_dump($this->get_table_size()); + + exit(3); + + #var_dump($this->get_table_num_rows()); + + var_dump($this->analyze_table()); + + $table_rows = $this->get_table_num_rows(); + if ($table_rows === 0) { + return new EntityCodeBuild(); + } + var_dump('ELSE, HANDLE THIS!'); + exit(2); } public function get_datetime_of_last_successful_build(): ?DateTime { @@ -28,14 +49,16 @@ public function get_datetime_of_last_successful_build(): ?DateTime { #var_dump($results); #var_dump($this->get_table_size()); + #var_dump($this->get_table_num_rows()); + return null; #var_dump($this->get_newest_entity()); #var_dump($this->get_oldest_entity()); - $entity = $this->get_newest_entity(); + #$entity = $this->get_newest_entity(); #var_dump('The newest entity is:'); - #ar_dump($entity); + #var_dump($entity); - return $entity; + #return $entity; } protected function event_before_remove_entity(EntityInterface $entity): void { diff --git a/applications/asset_server/code_manager/src/Repository/CodeManager/EntityDBSnapshotRepository.php b/applications/asset_server/code_manager/src/Repository/CodeManager/EntityDBSnapshotRepository.php index f2ab96d7b..088bf3931 100644 --- a/applications/asset_server/code_manager/src/Repository/CodeManager/EntityDBSnapshotRepository.php +++ b/applications/asset_server/code_manager/src/Repository/CodeManager/EntityDBSnapshotRepository.php @@ -1,4 +1,4 @@ -set_table_name(EntityFile::TABLE_NAME); - $this->set_sort_field_time(EntityFile::SORT_FIELD_TIME); + /** + * @param EntityManagerInterface $em + * @param ClassMetadata $class + * @param DBService $service_db + */ + public function __construct(EntityManagerInterface $em, ClassMetadata $class, DBService $service_db) { + parent::__construct($em, $class, $service_db); + #$this->query_manager->set_table_name(TABLE::CODE_BUILDS); + #$this->query_manager->set_sort_field(FIELD::TIME_END); } public function does_child_file_exist_as_needed(EntityFile $file, string $path_to_child) : bool { @@ -54,14 +67,21 @@ protected function set_entity_file_child(EntityFile $parent, EntityFile $child): $this->save_entity($child, true); } - private function create_new_child_entity(EntityFile $file, string $path_to_child, array $options) : EntityInterface { + private function create_new_child_entity(EntityFile $file, string $path_to_child, array $options): EntityInterface { $child = $this->create_new_entity($path_to_child, false); $child->set_flags($options); $this->set_entity_file_child($file, $child); return $child; } - public function ensure_file_has_child(EntityFile $file, string $path_to_child, string $flag) : EntityInterface { + /** + * @param EntityFile $file + * @param string $path_to_child + * @param string $flag + * @return EntityInterface + * @throws ParameterException + */ + public function ensure_file_has_child(EntityFile $file, string $path_to_child, string $flag): EntityInterface { if (!$this->does_child_file_exist_as_needed($file, $path_to_child)) { $options = $file->get_flags(); $options[$flag] = true; @@ -72,13 +92,15 @@ public function ensure_file_has_child(EntityFile $file, string $path_to_child, s case EntityFile::FLAG_MINIFY: switch ($file->getType()) { case EntityFile::TYPE_HTML: - UFO::minify_html($file->getFullPath(), $path_to_child); + #UFO::minify_html($file->getFullPath(), $path_to_child); + HTMLUtilities::minify($file->getFullPath(), $path_to_child); break; case EntityFile::TYPE_CSS: - UFO::minify_css($file->getFullPath(), $path_to_child); + #UFO::minify_css($file->getFullPath(), $path_to_child); + CSSUtilities::minify($file->getFullPath(), $path_to_child); break; default: - DBG::throw_exception('TODO: Handle minification for type{' . $path_to_child . '}'); + throw ParameterException::invalid_function_parameter('ensure_file_has_child', 'file type not supported {' . $path_to_child . '}'); break; } return $this->create_new_child_entity($file, $path_to_child, $options); diff --git a/applications/asset_server/code_manager/src/Repository/CodeManager/EntityFileTypeRepository.php b/applications/asset_server/code_manager/src/Repository/CodeManager/EntityFileTypeRepository.php new file mode 100644 index 000000000..ac75fef10 --- /dev/null +++ b/applications/asset_server/code_manager/src/Repository/CodeManager/EntityFileTypeRepository.php @@ -0,0 +1,40 @@ +logger = $logger; - } - - public function log($content): void { - $this->logger->debug($content); - } - - public function warn($content): void { - $this->logger->warning($content); - } - -} diff --git a/applications/asset_server/code_manager/src/Service/Abstractions/OwnsCommands.php b/applications/asset_server/code_manager/src/Service/Abstractions/OwnsCommands.php deleted file mode 100644 index a713ce47e..000000000 --- a/applications/asset_server/code_manager/src/Service/Abstractions/OwnsCommands.php +++ /dev/null @@ -1,9 +0,0 @@ - */ - public function __construct(LoggerInterface $logger, ManagerService $manager_service) { - parent::__construct($logger); - self::$SINGLETON = $this; - $this->manager_service = $manager_service; - $this->config_initialize( - [ - 'global_information' => null, - 'assets' => [ - UFO::EXTENSION_CSS => null, - UFO::EXTENSION_HTML => null, - UFO::EXTENSION_JSON => null, - UFO::EXTENSION_SHADER_VERTEX => null, - UFO::EXTENSION_SHADER_FRAGMENT => null - ], - 'npm' => null, - 'qa_report' => null, - 'docker' => null, - 'projects' => null - ], - UFO::get_yaml(PATH::get(PATH::PROJECT_CONFIG)) - ); - } + private const BUILD_STEPS = [ + #CSSBuildSection::class, + #HTMLBuildSection::class, + #JSONBuildSection::class, + #NPMLibBuildSection::class, + #QAReportBuildSection::class + ]; - public function get_test_hi(): string { - return 'wow, it freaking works :o'; + /** + * @param ContainerInterface $container + * @param ParameterBagInterface $bag + * @param LoggerService $logger_service + * @param DBService $service_db + * @throws \Exception + */ + public function __construct(ContainerInterface $container, ParameterBagInterface $bag, LoggerService $logger_service, DBService $service_db) { + parent::__construct($logger_service); + $this->configs_universal = $bag; + $this->service_db = $service_db; + + $apple = '/hello/world/how/are/you?/'; + var_dump(PathUtilities::remove_layer($apple)); + + var_dump('Early exit!'); + exit(); + + #$this->config_yaml_load($this->configs_universal->get(SCHEMAS_ENUM::YAML_CODE_MANAGER), getenv(PATHS_ENUM::PROJECT_CONFIG)); + + #$this->container = $container; + #var_dump($this->container); + #exit(); + + $this->all_build_sections[] = $this->service_db_health; + foreach (self::BUILD_STEPS as $build_section_class) { + $this->all_build_sections[] = new $build_section_class($this); + } + + $this->repo_code_builds = $this->service_db->get_repo(EntityCodeBuildRepository::class); + + $this->repo_code_builds->fetch_or_generate_last_build(); + + #var_dump($this->repo_code_builds); + exit(); } - public function prepare_code_health_check(Application $application): void { - $this->manager_service->set_application($application); - $this->manager_commands = $this->get_manager(CommandManagerService::class); - $this->manager_repo = $this->get_manager(RepositoryManagerService::class); - $this->manager_build_step = $this->get_manager(BuildStepManagerService::class); - $this->repo_code_builds = $this->get_repo(EntityCodeBuildRepository::class); + /** + * @param string $key + * @return mixed + */ + public function config_universal_get(string $key) { + return $this->configs_universal->get($key); } - public function run_code_health_check(): void { - $last_datetime = $this->repo_code_builds->get_datetime_of_last_successful_build(); + public function get_test_hi(): string { + return 'wow, it freaking works :o'; + } - if ($last_datetime === null) { - var_dump('TODO: Create new EntityCodeBuild object!'); - } + public function run_code_health_check(DBService $db_health_service): void { + $this->service_db_health = $db_health_service; - $binance = new BinanceAccountAPI(PATH::get(PATH::API)); - var_dump('Binance created!'); - $this->current_code_build = new EntityCodeBuild(); + #$last_datetime = $this->repo_code_builds->get_datetime_of_last_successful_build(); + #if ($last_datetime === null) { + # var_dump('TODO: Create new EntityCodeBuild object!'); + #} + # TODO: Utilize this! + #$this->current_code_build = new EntityCodeBuild(); #$path = '/quasar_source/var/data/orders.json'; - #$content = FileUtilities::get_json_contents($path); + #$content = JSONUtilities::get($path); #var_dump($content); #$output = RUN::run_webpack_build(); @@ -119,8 +153,18 @@ public function run_code_health_check(): void { #exit(); #var_dump('Code Health Check disabled'); - $this->manager_build_step->run_all_builds(); - $this->print_final_results(); + $this->run_all_builds(); + #$this->print_final_results(); + } + + private function run_all_builds(): void { + $previous_step_failed = false; + # TODO: Add try-catch. + /** @var BuildSection $build_section */ + foreach ($this->all_build_sections as $build_section) { + # TODO: Check if the previous step failed or not. + $build_section->run_unit_of_work(); + } } public function get_current_code_build(): EntityCodeBuild { @@ -142,25 +186,17 @@ private function print_final_results(): void { } } - $qa_results = new ProjectTestSuiteResult(PATH::get(PATH::QA_REPORT)); + $qa_results = new ProjectTestSuiteResult(SYS::get_env(PATHS_ENUM::QA_REPORT)); var_dump($qa_results->get_qa_report()); } - // ------------------------- I N T E R F A C E {OwnsCommands} ------------------------- - - public function get_command(string $command_name): PreparedCommand { - return $this->manager_commands->get_command($command_name); - } - - // ------------------------- I N T E R F A C E {OwnsManagers} ------------------------- - - public function get_manager(string $manager_class): BaseAbstractService { - return $this->manager_service->get_manager($manager_class); - } - - // --------------------------- I N T E R F A C E {OwnsRepos} --------------------------- + // ----------------------------------------- I N T E R F A C E {OwnsRepos} ----------------------------------------- + /** + * @param string $repo_key + * @return ObjectRepository + */ public function get_repo(string $repo_key): ObjectRepository { - return $this->manager_repo->get_repo($repo_key); + return $this->service_db->get_repo($repo_key); } } diff --git a/applications/asset_server/code_manager/src/Service/DBService.php b/applications/asset_server/code_manager/src/Service/DBService.php new file mode 100644 index 000000000..13ab257d5 --- /dev/null +++ b/applications/asset_server/code_manager/src/Service/DBService.php @@ -0,0 +1,198 @@ + EntityFile::class, + EntityDirectoryRepository::class => EntityDirectory::class, + EntityQAReportRepository::class => EntityQAReport::class, + EntityNPMLibRepository::class => EntityNPMLib::class, + EntityUserRepository::class => EntityUser::class, + EntityUserRoleRepository::class => EntityUserRole::class, + EntityCodeBuildRepository::class => EntityCodeBuild::class, + EntityDBSnapshotRepository::class => EntityDBSnapshot::class + ]; + + /** @var array */ + private $commands = []; + + /** @var DBSchemaUpdate */ + private $cmd_db_schema_update; + + /** @var DBSchemaValidate */ + private $cmd_db_schema_validate; + + /** @var Application */ + private $application; + + /** @var CodeBuilderService */ + private $code_builder; + + /** @var EntityManagerInterface */ + private $entity_manager; + + /** @var array */ + private $entity_repos = []; + + /** @var SQLQueryGroup $queries_schema */ + private $queries_schema; + + /** + * @param LoggerService $logger + * @param EntityManagerInterface $entity_manager + */ + public function __construct(LoggerService $logger, EntityManagerInterface $entity_manager) { + parent::__construct($logger); + $this->entity_manager = $entity_manager; + + $this->queries_schema = new DBSchema($this->entity_manager->getConnection()); + + #$this->query_manager = new QueryManager($this->entity_manager->getConnection()); + #parent::__construct('DB Health Check', $logger); + } + + /** + * @param string $command_name + * @param string $command_class + * @return PreparedCommand + */ + private function get_command(string $command_name, string $command_class): PreparedCommand { + if (!array_key_exists($command_name, $this->commands)) { + $this->commands[$command_name] = new $command_class($this->application->find($command_name)); + } + return $this->commands[$command_name]; + } + + // ----------------------------------------- I N T E R F A C E {OwnsRepo} ------------------------------------------ + + /** + * @param string $repo_key + * @return ObjectRepository + */ + public function get_repo(string $repo_key): ObjectRepository { + if (!array_key_exists($repo_key, $this->entity_repos)) { + $this->set_repo($repo_key, self::REPO_TO_ENTITY[$repo_key]); + } + return $this->entity_repos[$repo_key]; + } + + /** + * @param string $repo_key + * @param string $entity_class + */ + private function set_repo(string $repo_key, string $entity_class): void { + $this->entity_repos[$repo_key] = $this->entity_manager->getRepository($entity_class); + } + + // ---------------------------------------------- B U I L D S T E P ----------------------------------------------- + + /** + * @param Application $application + * @param CodeBuilderService $code_builder + */ + public function prepare_for_build_step(Application $application, CodeBuilderService $code_builder): void { + $this->application = $application; + $this->code_builder = $code_builder; + } + + protected function pre_work(): void { + $this->cmd_db_schema_update = $this->get_command( + 'doctrine:schema:update', + DBSchemaUpdate::class + ); + $this->cmd_db_schema_validate = $this->get_command( + 'doctrine:schema:validate', + DBSchemaValidate::class + ); + } + + protected function perform_work(): void { + $code_build = $this->code_builder->get_current_code_build(); + + if ($code_build->is_mode_rushed()) { + $this->log('Build mode is rushed, skipping DB checks.'); + } else { + $this->run_cmd_wrapped([$this, 'run_schema_validate']); + if (!$this->cmd_db_schema_validate->is_healthy_mapping()) { + $this->log('Entity mapping is not healthy!'); + $this->mark_as_failed(); + } + if (!$this->cmd_db_schema_validate->is_healthy_schema()) { + $this->log('Updating the DB Schema!'); + $this->run_cmd_wrapped([$this, 'run_schema_update']); + + if ($this->cmd_db_schema_update->did_db_schema_update()) { + // setOptional --> setDbSchemaUpdated + + #$this->code_builder->get_current_code_build()->setOptional(true); + $this->code_builder->get_current_code_build()->setBooleanValue0(true); + } + } + } + + // TODO: Check for any enum tables that need to be populated! + // TODO: ^ The above check depends on the code build mode set! + } + + private function run_schema_validate(): void { + $this->cmd_db_schema_validate->run_command(); + } + + private function run_schema_update(): void { + $this->cmd_db_schema_update->run_command(); + } + + /** + * @param callable $cmd + */ + private function run_cmd_wrapped(callable $cmd): void { + try { + $cmd(); + } catch (Exception $e) { + $this->mark_as_failed(); + $this->warn('Exception', $e->getMessage()); + } + } + + protected function post_work(): void { + $this->log('DBHealthService post_work'); + } + + +} diff --git a/applications/asset_server/code_manager/src/Service/Feature/AbstractService.php b/applications/asset_server/code_manager/src/Service/Feature/AbstractService.php new file mode 100644 index 000000000..d3a60b28c --- /dev/null +++ b/applications/asset_server/code_manager/src/Service/Feature/AbstractService.php @@ -0,0 +1,23 @@ +service_set_logger($logger_service); + } + +} \ No newline at end of file diff --git a/applications/asset_server/code_manager/src/Service/Feature/Config/FeatureConfigUniversalInterface.php b/applications/asset_server/code_manager/src/Service/Feature/Config/FeatureConfigUniversalInterface.php new file mode 100644 index 000000000..ab504a86e --- /dev/null +++ b/applications/asset_server/code_manager/src/Service/Feature/Config/FeatureConfigUniversalInterface.php @@ -0,0 +1,18 @@ +config_yaml_set_data($keys, YAML::get($path)); + } + + /** + * @param array $keys + * @param array $config + * @return FeatureConfigYAMLTrait + */ + protected function config_yaml_set_data(array $keys, array $config): self { + foreach ($keys as $k => $v) { + if (array_key_exists($k, $config)) { + $this->config_yaml[$k] = $config[$k]; + } else { + throw ParameterException::missing_config_parameter($k); + } + + if (is_array($v)) { + $this->config_verify_sub_layer($v, $config[$k]); + } + } + return $this; + } + + /** + * @param array $keys + * @param array $layer + * @throws ParameterException + */ + private function config_verify_sub_layer(array $keys, array $layer): void { + foreach ($keys as $k => $v) { + if (!array_key_exists($k, $layer)) { + throw ParameterException::missing_config_parameter($k); + } + if (is_array($v)) { + $this->config_verify_sub_layer($v, $layer[$k]); + } + } + } + + /** + * @return array + */ + public function config_yaml_get_all(): array { + return $this->config_yaml; + } + + /** + * @param string|array $keys + * @return mixed + */ + public function config_yaml_get($keys) { + if (is_string($keys)) { + return $this->config_yaml[$keys]; + } + #$current = $this->config_yaml; + #foreach ($keys as $k) { + # $current = $current[$k]; + #} + #return $this->config_yaml[$key]; + return array_values($this->config_yaml); + } + +} diff --git a/applications/asset_server/code_manager/src/Service/Feature/Logging/FeatureLoggingInterface.php b/applications/asset_server/code_manager/src/Service/Feature/Logging/FeatureLoggingInterface.php new file mode 100644 index 000000000..f9fb728ae --- /dev/null +++ b/applications/asset_server/code_manager/src/Service/Feature/Logging/FeatureLoggingInterface.php @@ -0,0 +1,27 @@ +service_logger; + } + + /** + * @param LoggerService $logger_service + * @return FeatureLoggingTrait + */ + protected function service_set_logger(LoggerService $logger_service): self { + $this->service_logger = $logger_service; + return $this; + } + + /** + * @param string $message [Any kind of section title/header/divider, etc. ] + * @param mixed $value [Optional parameter to be displayed in brackets.] + */ + public function header(string $message, $value = null): void { + $this->service_logger->header($value !== null ? STR::brackets($message, $value) : $message); + } + + /** + * @param string $message [A regular log message.] + * @param mixed $value [Optional parameter to be displayed in brackets.] + */ + public function log(string $message, $value = null): void { + $this->service_logger->log($value !== null ? STR::brackets($message, $value) : $message); + } + + /** + * @param string $message [A warning message.] + * @param mixed $value [Optional parameter to be displayed in brackets.] + */ + public function warn(string $message, $value = null): void { + $this->service_logger->warn($value !== null ? STR::brackets($message, $value) : $message); + } +} diff --git a/applications/asset_server/code_manager/src/Service/Feature/Repository/OwnsReposInterface.php b/applications/asset_server/code_manager/src/Service/Feature/Repository/OwnsReposInterface.php new file mode 100644 index 000000000..9a8aabd59 --- /dev/null +++ b/applications/asset_server/code_manager/src/Service/Feature/Repository/OwnsReposInterface.php @@ -0,0 +1,18 @@ +logger = $logger; + } + + /** + * @param string $message [Any kind of section title/header/divider, etc.] + */ + public function header(string $message): void { + $this->logger->debug('--- ' . $message . ' ---'); + } + + /** + * @param string $message [A regular log message.] + */ + public function log(string $message): void { + $this->logger->debug($message); + } + + /** + * @param string $message [A warning message.] + */ + public function warn(string $message): void { + $this->logger->warning($message); + } + + /** + * @return LoggerService + */ + public function service_get_logger(): LoggerService { + return $this; + } +} diff --git a/applications/asset_server/code_manager/src/Service/Manager/BuildStepManagerService.php b/applications/asset_server/code_manager/src/Service/Manager/BuildStepManagerService.php deleted file mode 100644 index 2403fd258..000000000 --- a/applications/asset_server/code_manager/src/Service/Manager/BuildStepManagerService.php +++ /dev/null @@ -1,48 +0,0 @@ - - */ - private const BUILD_STEPS = [ - DBBuildSection::class, - CSSBuildSection::class, - HTMLBuildSection::class, - JSONBuildSection::class, - NPMLibBuildSection::class, - QAReportBuildSection::class - ]; - - /** @var CodeBuilderService */ - private $code_builder; - /** @var array */ - private $all_build_sections = []; - - public function set_code_builder(CodeBuilderService $code_builder): void { - $this->code_builder = $code_builder; - foreach (self::BUILD_STEPS as $build_section_class) { - $this->all_build_sections[] = new $build_section_class($this->code_builder); - } - } - - public function run_all_builds(): void { - foreach ($this->all_build_sections as $build_section) { - $build_section->run_unit_of_work(); - } - } - -} diff --git a/applications/asset_server/code_manager/src/Service/Manager/CommandManagerService.php b/applications/asset_server/code_manager/src/Service/Manager/CommandManagerService.php deleted file mode 100644 index 998f2a9d2..000000000 --- a/applications/asset_server/code_manager/src/Service/Manager/CommandManagerService.php +++ /dev/null @@ -1,38 +0,0 @@ - DBSchemaUpdate::class, - PreparedCommand::CMD_DB_SCHEMA_VALIDATE => DBSchemaValidate::class - ]; - - /** @var array */ - private $commands = []; - /** @var Application */ - private $kernel; - - public function set_application(Application $application): void { - $this->kernel = $application; - } - - public function get_command(string $command_name): PreparedCommand { - if (!array_key_exists($command_name, $this->commands)) { - $cmd_class = self::CMD_NAMES_TO_CLASSES[$command_name]; - $this->commands[$command_name] = new $cmd_class($this->kernel->find($command_name)); - } - return $this->commands[$command_name]; - } - -} diff --git a/applications/asset_server/code_manager/src/Service/Manager/ManagerService.php b/applications/asset_server/code_manager/src/Service/Manager/ManagerService.php deleted file mode 100644 index 09a965403..000000000 --- a/applications/asset_server/code_manager/src/Service/Manager/ManagerService.php +++ /dev/null @@ -1,53 +0,0 @@ -managers[self::KEY_REPO] = [true , $manager_repo]; - $this->managers[self::KEY_BUILD_STEP] = [false, $manager_build_step]; - $this->managers[self::KEY_COMMANDS] = [false, $manager_commands]; - } - - public function set_application(Application $application): void { - $this->application = $application; - } - - public function get_manager(string $manager_class): BaseAbstractService { - if ($manager_class === self::KEY_BUILD_STEP && $this->managers[self::KEY_BUILD_STEP][0] === false) { - /** @var BuildStepManagerService $manager_build_step */ - $manager_build_step = $this->managers[self::KEY_BUILD_STEP][1]; - $this->managers[self::KEY_BUILD_STEP][0] = true; - $manager_build_step->set_code_builder(CodeBuilderService::$SINGLETON); - } else if ($manager_class === self::KEY_COMMANDS && $this->managers[self::KEY_COMMANDS][0] === false) { - /** @var CommandManagerService $manager_commands */ - $manager_commands = $this->managers[self::KEY_COMMANDS][1]; - $this->managers[self::KEY_COMMANDS][0] = true; - $manager_commands->set_application($this->application); - } - return $this->managers[$manager_class][1]; - } - -} \ No newline at end of file diff --git a/applications/asset_server/code_manager/src/Service/Manager/RepositoryManagerService.php b/applications/asset_server/code_manager/src/Service/Manager/RepositoryManagerService.php deleted file mode 100644 index fb53dc1dc..000000000 --- a/applications/asset_server/code_manager/src/Service/Manager/RepositoryManagerService.php +++ /dev/null @@ -1,62 +0,0 @@ - EntityFile::class, - EntityDirectoryRepository::class => EntityDirectory::class, - EntityQAReportRepository::class => EntityQAReport::class, - EntityNPMLibRepository::class => EntityNPMLib::class, - EntityUserRepository::class => EntityUser::class, - EntityUserRoleRepository::class => EntityUserRole::class, - EntityCodeBuildRepository::class => EntityCodeBuild::class, - EntityDBSnapshotRepository::class => EntityDBSnapshot::class - ]; - - /** @var EntityManagerInterface */ - private $entity_manager; - /** @var array */ - private $entity_repos = []; - - public function __construct(LoggerInterface $logger, EntityManagerInterface $entity_manager) { - parent::__construct($logger); - $this->entity_manager = $entity_manager; - } - - public function get_repo(string $repo_key): ObjectRepository { - if (!array_key_exists($repo_key, $this->entity_repos)) { - $this->set_repo($repo_key, self::REPO_TO_ENTITY[$repo_key]); - } - return $this->entity_repos[$repo_key]; - } - - private function set_repo(string $repo_key, string $entity_class): void { - $this->entity_repos[$repo_key] = $this->entity_manager->getRepository($entity_class); - } - -} diff --git a/applications/asset_server/code_manager/tests/traits/TraitPatternNameTest.php b/applications/asset_server/code_manager/tests/traits/TraitPatternNameTest.php index 5ae78f760..f93f890f3 100644 --- a/applications/asset_server/code_manager/tests/traits/TraitPatternNameTest.php +++ b/applications/asset_server/code_manager/tests/traits/TraitPatternNameTest.php @@ -9,11 +9,11 @@ namespace CodeManager\Traits; use PHPUnit\Framework\TestCase; -use QuasarSource\Traits\TraitPatternName; +use QuasarSource\Traits\TraitName; class TraitPatternNameTest extends TestCase { - use TraitPatternName; + use TraitName; public function test_trait_pattern_name(): void { $name = 'hello world'; diff --git a/applications/asset_server/code_manager/tests/universal_utilities/MathUtilitiesTest.php b/applications/asset_server/code_manager/tests/universal_utilities/MathUtilitiesTest.php index aab06dae7..44b9e2db5 100644 --- a/applications/asset_server/code_manager/tests/universal_utilities/MathUtilitiesTest.php +++ b/applications/asset_server/code_manager/tests/universal_utilities/MathUtilitiesTest.php @@ -13,8 +13,8 @@ class MathUtilitiesTest extends FileTestSuite { - public function test_get_percentage_decreased(): void { - $this->assertLessThan(.41, MATH::get_percentage_decreased(2.5, 1.5, false)); + public function test_percentage_decreased(): void { + $this->assertLessThan(.41, MATH::percentage_decreased(2.5, 1.5, false)); } } diff --git a/applications/asset_server/code_manager/tests/universal_utilities/SimpleTimerTest.php b/applications/asset_server/code_manager/tests/universal_utilities/SimpleTimerTest.php index 1d3a70231..0187107b2 100644 --- a/applications/asset_server/code_manager/tests/universal_utilities/SimpleTimerTest.php +++ b/applications/asset_server/code_manager/tests/universal_utilities/SimpleTimerTest.php @@ -8,7 +8,7 @@ namespace CodeManager\Tests; use QuasarSource\QualityAssurance\FileTestSuite; -use QuasarSource\Utilities\SimpleTimer; +use QuasarSource\Utilities\Time\SimpleTimer; class SimpleTimerTest extends FileTestSuite { diff --git a/applications/asset_server/code_manager/tests/universal_utilities/StringUtilitiesTest.php b/applications/asset_server/code_manager/tests/universal_utilities/StringUtilitiesTest.php index b1b57a716..b34dc96c6 100644 --- a/applications/asset_server/code_manager/tests/universal_utilities/StringUtilitiesTest.php +++ b/applications/asset_server/code_manager/tests/universal_utilities/StringUtilitiesTest.php @@ -15,9 +15,9 @@ class StringUtilitiesTest extends FileTestSuite { protected $class_to_test = STR::class; - public function test_get_matches_removed(): void { + public function test_remove(): void { $this->assert_equals_scenarios( - 'get_matches_removed', + 'remove', [ # Expected Result, To search, To Remove. ['hello ', 'hello world', 'world'], @@ -77,12 +77,12 @@ public function test_contains(): void { ); } - public function test_ensure_starts_with(): void { - $simple_case = 'png'; - STR::ensure_starts_with($simple_case, '.'); - $this->assertTrue(STR::starts_with($simple_case, '.')); - STR::ensure_starts_with($simple_case, 'a'); - $this->assertFalse(STR::starts_with($simple_case, '.')); + public function test_ensure_start(): void { + #$simple_case = 'png'; + #STR::ensure_start($simple_case, '.'); + #$this->assertTrue(STR::starts_with($simple_case, '.')); + #STR::ensure_start($simple_case, 'a'); + #$this->assertFalse(STR::starts_with($simple_case, '.')); } public function test_starts_with(): void { diff --git a/applications/asset_server/code_manager/tests/universal_utilities/files/DirectoryUtilitiesTest.php b/applications/asset_server/code_manager/tests/universal_utilities/files/DirectoryUtilitiesTest.php index c051f8814..845b8b114 100644 --- a/applications/asset_server/code_manager/tests/universal_utilities/files/DirectoryUtilitiesTest.php +++ b/applications/asset_server/code_manager/tests/universal_utilities/files/DirectoryUtilitiesTest.php @@ -9,9 +9,8 @@ namespace CodeManager\Tests; use QuasarSource\QualityAssurance\FileTestSuite; use QuasarSource\Utilities\ArrayUtilities; -use QuasarSource\Utilities\Files\DirectoryUtilities as DIR; -use QuasarSource\Utilities\Files\FileUtilities as UFO; -use QuasarSource\Utilities\Files\PathUtilities as PATH; +use QuasarSource\Utilities\File\DirectoryUtilities as DIR; +use QuasarSource\Utilities\File\PathUtilities as PATH; class DirectoryUtilitiesTest extends FileTestSuite { diff --git a/applications/asset_server/code_manager/tests/universal_utilities/files/FileUtilitiesTest.php b/applications/asset_server/code_manager/tests/universal_utilities/files/FileUtilitiesTest.php index cb2f57afc..5505d9050 100644 --- a/applications/asset_server/code_manager/tests/universal_utilities/files/FileUtilitiesTest.php +++ b/applications/asset_server/code_manager/tests/universal_utilities/files/FileUtilitiesTest.php @@ -8,7 +8,9 @@ namespace CodeManager\Tests; use QuasarSource\QualityAssurance\FileTestSuite; -use QuasarSource\Utilities\Files\FileUtilities as UFO; +use QuasarSource\Utilities\File\Discrete\CSSUtilities; +use QuasarSource\Utilities\File\Discrete\HTMLUtilities; +use QuasarSource\Utilities\File\FileUtilities as UFO; class FileUtilitiesTest extends FileTestSuite { @@ -40,12 +42,14 @@ private function assert_compression(string $base_path, string $output_path, floa } public function test_minify_html(): void { - UFO::minify_html(self::PATH_HTML_PRE, self::PATH_HTML_POST); + #UFO::minify_html(self::PATH_HTML_PRE, self::PATH_HTML_POST); + HTMLUtilities::minify(self::PATH_HTML_PRE, self::PATH_HTML_POST); $this->assert_compression(self::PATH_HTML_PRE, self::PATH_HTML_POST, 0.30); } public function test_minify_css(): void { - UFO::minify_css(self::PATH_CSS_PRE, self::PATH_CSS_POST); + #UFO::minify_css(self::PATH_CSS_PRE, self::PATH_CSS_POST); + CSSUtilities::minify(self::PATH_CSS_PRE, self::PATH_CSS_POST); $this->assert_compression(self::PATH_CSS_PRE, self::PATH_CSS_POST, 0.60); } @@ -69,6 +73,7 @@ public function test_get_size(): void { ); } + /* public function test_get_yaml(): void { $test_file_contents = [ 'section_a' => ['a', 'b', 'c'], @@ -82,6 +87,6 @@ public function test_get_yaml(): void { $test_file_contents, UFO::get_yaml(self::PATH_YAML) ); - } + }*/ } diff --git a/applications/asset_server/code_manager/tests/universal_utilities/files/PathUtilitiesTest.php b/applications/asset_server/code_manager/tests/universal_utilities/files/PathUtilitiesTest.php index 00553b5ef..fa421f040 100644 --- a/applications/asset_server/code_manager/tests/universal_utilities/files/PathUtilitiesTest.php +++ b/applications/asset_server/code_manager/tests/universal_utilities/files/PathUtilitiesTest.php @@ -8,7 +8,7 @@ namespace CodeManager\Tests; use QuasarSource\QualityAssurance\FileTestSuite; -use QuasarSource\Utilities\Files\PathUtilities as PATH; +use QuasarSource\Utilities\File\PathUtilities as PATH; use QuasarSource\Utilities\StringUtilities as STR; @@ -18,6 +18,24 @@ class PathUtilitiesTest extends FileTestSuite { private const RELATIVE_TEST = 'tests/universal_utilities/files/PathUtilitiesTest.php'; private const RELATIVE_BASE = 'applications/asset_server/code_manager/'; + private $app; + private $relative_path; + + public function setUp() { + /* + $kernel = new AppKernel('test', true); + $kernel->boot(); + $this->app = new Application(); + $this->app->setAutoExit(false); + + $this->relative_path = $this->app->getKernel() + */ + + $a = static::$kernel->getContainer()->getParameter('PATH_RELATIVE_PROJECT_CONFIGS'); + var_dump('PATH RELATIVE PROJECT CONFIGS IS {' . $a . '}'); + } + + /* public function test_remove_layer(): void { // Positive cases. $this->assertSame('/a/b/', PATH::remove_layer(self::DATA)); @@ -27,7 +45,7 @@ public function test_remove_layer(): void { } public function test_get(): void { - $dir_base = STR::get_matches_removed(__FILE__, self::RELATIVE_BASE . self::RELATIVE_TEST); + $dir_base = STR::remove(__FILE__, self::RELATIVE_BASE . self::RELATIVE_TEST); $dir_asset = $dir_base . 'applications/asset_server/'; $dir_node = $dir_asset . 'js/'; $dir_code_manager = $dir_asset . 'code_manager/'; @@ -37,9 +55,9 @@ public function test_get(): void { $this->sub_test_get($dir_base . 'configs/code_manager.yml', PATH::PROJECT_CONFIG); $this->sub_test_get($dir_asset, PATH::ASSET_DIR); $this->sub_test_get($dir_node, PATH::NODE_DIR); - $this->sub_test_get($dir_node . 'minify_html_file.js', PATH::JS_MINIFY_HTML); - $this->sub_test_get($dir_node . 'minify_css_file.js', PATH::JS_MINIFY_CSS); - $this->sub_test_get($dir_node . 'minify_js_file.js', PATH::JS_MINIFY_JS); + $this->sub_test_get($dir_node . 'minify_html_file.js', getenv('PATH_RELATIVE_NODE_MINIFY_HTML')); + $this->sub_test_get($dir_node . 'minify_css_file.js', getenv('PATH_RELATIVE_NODE_MINIFY_CSS')); + $this->sub_test_get($dir_node . 'minify_js_file.js', getenv('PATH_RELATIVE_NODE_MINIFY_CSS')); $this->sub_test_get($dir_code_manager, PATH::CODE_MANAGER); $this->sub_test_get($dir_code_manager . 'composer.phar', PATH::COMPOSER); $this->sub_test_get($dir_code_manager . 'report.xml', PATH::QA_REPORT); @@ -48,16 +66,7 @@ public function test_get(): void { private function sub_test_get(string $expected, int $key): void { $this->assertSame($expected, PATH::get($key)); - } - - public function test_is_valid(): void { - $path_utilities = PATH::get(PATH::TEST_PATH_UTILITIES); - - // Positive cases. - $this->assertTrue(PATH::is_valid($path_utilities)); - // Negative cases. - $this->assertFalse(PATH::is_valid($path_utilities . 'fake_path')); - } + }*/ } diff --git a/applications/asset_server/src/asset_server.sh b/applications/asset_server/src/asset_server.sh index 989583e51..2098fb50b 100755 --- a/applications/asset_server/src/asset_server.sh +++ b/applications/asset_server/src/asset_server.sh @@ -1,6 +1,24 @@ #!/usr/bin/env bash -CMD_CONSOLE_MINIFY="minify:css" +#----------------------------------------------------------------------------------------------------------------------- +export PATH_DIRECTORY_PROJECT_BASE='/quasar_source/' +export PATH_DIRECTORY_CODE_MANAGER='/quasar_source/applications/asset_server/code_manager/' +export PATH_DIRECTORY_NODE='/quasar_source/applications/asset_server/js/' +export PATH_QA_REPORT=${PATH_DIRECTORY_CODE_MANAGER}'report.xml' +export PATH_PROJECT_CONFIGS='/quasar_source/configs/code_manager.yml' +export PATH_PROJECT_BUNDLES='/quasar_source/applications/asset_server/code_manager/config/bundles.php' +export PATH_NODE_MINIFY_HTML='/quasar_source/libraries/node/minifier_html.js' +export PATH_NODE_MINIFY_CSS='/quasar_source/libraries/node/minifier_css.js' +export PATH_NODE_MINIFY_JS='/quasar_source/libraries/node/minifier_css.js' +export SYMFONY_ENV='dev' +export DB_NAME='postgres' +export PATH_RELATIVE_NODE_MINIFY_HTML='applications/asset_server/js/minify_html_file.js' +export PATH_RELATIVE_NODE_MINIFY_CSS='applications/asset_server/js/minify_css_file.js' +export PATH_RELATIVE_NODE_MINIFY_JS='applications/asset_server/js/minify_js_file.js' +#----------------------------------------------------------------------------------------------------------------------- + +#PATH_RELATIVE_PROJECT_CONFIGS='configs/code_manager.yml' + RUN_CONSOLE="php /quasar_source/libraries/php/console.php" RUN_DEPLOYER="./dep --file=/quasar_source/libraries/php/deploy.php" CMD_DEPLOYER_RUN_ALL_TESTS="run_all_tests -vvv" @@ -11,7 +29,6 @@ FILE_CSS_NEXUS_LOCAL=/quasar_source/assets/css/nexus_local.css FILE_CSS_NEXUS_LOCAL_OUTPUT=/quasar_source/var/web_assets/nexus_local.min.css FILE_CSS_NEXUS_LOCAL_OUTPUT_FINAL=/quasar_source/var/web_assets/nexus_local.min.css.gz RUN_CONSOLE_CMD="php /quasar_source/applications/asset_server/code_manager/bin/console" -RUN_COMPOSER_CMD="php composer.phar" #${RUN_DEPLOYER} ${CMD_DEPLOYER_FULL_BUILD} @@ -21,21 +38,27 @@ RUN_COMPOSER_CMD="php composer.phar" #${RUN_DEPLOYER} ${CMD_DEPLOYER_BUILD_NEXUS_COURIER} -cd /quasar_source/applications/asset_server/code_manager; +cd ${PATH_DIRECTORY_CODE_MANAGER} #php -S "0.0.0.0:80" -#${RUN_COMPOSER_CMD} install -o; +php -v + +#composer self-update +#composer validate +#composer update +#composer install -o +#composer install -o #--enable-opcache --enable-opcache-file + +#apk add --update php-opcache@php + + +#composer require symfony/config #${RUN_CONSOLE_CMD} doctrine:database:drop -vvv --force ${RUN_CONSOLE_CMD} code:health_check -vvv -#curl -s https://getcomposer.org/installer -#chmod +x ./composer.phar -#${RUN_COMPOSER_CMD} self-update; #${RUN_CONSOLE} cache:clear -#${RUN_COMPOSER_CMD} update -o; - #${RUN_CONSOLE_CMD} list #${RUN_CONSOLE_CMD} doctrine:cache:delete diff --git a/applications/ftp_server/Dockerfile b/applications/ftp_server/Dockerfile new file mode 100644 index 000000000..e69de29bb diff --git a/configs/code_manager.yml b/configs/code_manager.yml index 57f7b8dec..596419c25 100644 --- a/configs/code_manager.yml +++ b/configs/code_manager.yml @@ -4,30 +4,30 @@ global_information: assets: .css: - data_directory : '/quasar_source/assets/css/' - output_directory: '/quasar_source/var/web_assets/' - files : + PATH_DIRECTORY_DATA : '/quasar_source/assets/css/' + PATH_DIRECTORY_OUTPUT: '/quasar_source/var/web_assets/' + files : nexus_local.css: ['minify', 'gzipped'] dev.css : ['minify', 'gzipped'] .html: - data_directory : '/quasar_source/assets/html/' - output_directory: '/quasar_source/var/web_assets/' - files : + PATH_DIRECTORY_DATA : '/quasar_source/assets/html/' + PATH_DIRECTORY_OUTPUT: '/quasar_source/var/web_assets/' + files : nexus_local.html: ['pre_process', '/quasar_source/var/web_assets/nexus_local.min.css', 'minify', 'gzipped'] dev.html : ['pre_process', '/quasar_source/var/web_assets/dev.min.css' , 'minify', 'gzipped'] .json: - data_directory : '/quasar_source/assets/fonts/three_js_fonts/' - output_directory: '/quasar_source/var/web_assets/' - files : + PATH_DIRECTORY_DATA : '/quasar_source/assets/fonts/three_js_fonts/' + PATH_DIRECTORY_OUTPUT: '/quasar_source/var/web_assets/' + files : gentilis_regular.typeface.json: ['gzipped'] .vert: - data_directory : '/quasar_source/assets/shaders/' - output_directory: '/quasar_source/var/web_assets/' - files : [] + PATH_DIRECTORY_DATA : '/quasar_source/assets/shaders/' + PATH_DIRECTORY_OUTPUT: '/quasar_source/var/web_assets/' + files : [] .frag: - data_directory : '/quasar_source/assets/shaders/' - output_directory: '/quasar_source/var/web_assets/' - files : [] + PATH_DIRECTORY_DATA : '/quasar_source/assets/shaders/' + PATH_DIRECTORY_OUTPUT: '/quasar_source/var/web_assets/' + files : [] npm: - 'css-tree' diff --git a/configs/php/pre_modified.ini b/configs/php/pre_modified.ini new file mode 100644 index 000000000..fa09ade78 --- /dev/null +++ b/configs/php/pre_modified.ini @@ -0,0 +1,1932 @@ +[PHP] + +;;;;;;;;;;;;;;;;;;; +; About php.ini ; +;;;;;;;;;;;;;;;;;;; +; PHP's initialization file, generally called php.ini, is responsible for +; configuring many of the aspects of PHP's behavior. + +; PHP attempts to find and load this configuration from a number of locations. +; The following is a summary of its search order: +; 1. SAPI module specific location. +; 2. The PHPRC environment variable. (As of PHP 5.2.0) +; 3. A number of predefined registry keys on Windows (As of PHP 5.2.0) +; 4. Current working directory (except CLI) +; 5. The web server's directory (for SAPI modules), or directory of PHP +; (otherwise in Windows) +; 6. The directory from the --with-config-file-path compile time option, or the +; Windows directory (usually C:\windows) +; See the PHP docs for more specific information. +; http://php.net/configuration.file + +; The syntax of the file is extremely simple. Whitespace and lines +; beginning with a semicolon are silently ignored (as you probably guessed). +; Section headers (e.g. [Foo]) are also silently ignored, even though +; they might mean something in the future. + +; Directives following the section heading [PATH=/www/mysite] only +; apply to PHP files in the /www/mysite directory. Directives +; following the section heading [HOST=www.example.com] only apply to +; PHP files served from www.example.com. Directives set in these +; special sections cannot be overridden by user-defined INI files or +; at runtime. Currently, [PATH=] and [HOST=] sections only work under +; CGI/FastCGI. +; http://php.net/ini.sections + +; Directives are specified using the following syntax: +; directive = value +; Directive names are *case sensitive* - foo=bar is different from FOO=bar. +; Directives are variables used to configure PHP or PHP extensions. +; There is no name validation. If PHP can't find an expected +; directive because it is not set or is mistyped, a default value will be used. + +; The value can be a string, a number, a PHP constant (e.g. E_ALL or M_PI), one +; of the INI constants (On, Off, True, False, Yes, No and None) or an expression +; (e.g. E_ALL & ~E_NOTICE), a quoted string ("bar"), or a reference to a +; previously set variable or directive (e.g. ${foo}) + +; Expressions in the INI file are limited to bitwise operators and parentheses: +; | bitwise OR +; ^ bitwise XOR +; & bitwise AND +; ~ bitwise NOT +; ! boolean NOT + +; Boolean flags can be turned on using the values 1, On, True or Yes. +; They can be turned off using the values 0, Off, False or No. + +; An empty string can be denoted by simply not writing anything after the equal +; sign, or by using the None keyword: + +; foo = ; sets foo to an empty string +; foo = None ; sets foo to an empty string +; foo = "None" ; sets foo to the string 'None' + +; If you use constants in your value, and these constants belong to a +; dynamically loaded extension (either a PHP extension or a Zend extension), +; you may only use these constants *after* the line that loads the extension. + +;;;;;;;;;;;;;;;;;;; +; About this file ; +;;;;;;;;;;;;;;;;;;; +; PHP comes packaged with two INI files. One that is recommended to be used +; in production environments and one that is recommended to be used in +; development environments. + +; php.ini-production contains settings which hold security, performance and +; best practices at its core. But please be aware, these settings may break +; compatibility with older or less security conscience applications. We +; recommending using the production ini in production and testing environments. + +; php.ini-development is very similar to its production variant, except it is +; much more verbose when it comes to errors. We recommend using the +; development version only in development environments, as errors shown to +; application users can inadvertently leak otherwise secure information. + +; This is the php.ini-production INI file. + +;;;;;;;;;;;;;;;;;;; +; Quick Reference ; +;;;;;;;;;;;;;;;;;;; +; The following are all the settings which are different in either the production +; or development versions of the INIs with respect to PHP's default behavior. +; Please see the actual settings later in the document for more details as to why +; we recommend these changes in PHP's behavior. + +; display_errors +; Default Value: On +; Development Value: On +; Production Value: Off + +; display_startup_errors +; Default Value: Off +; Development Value: On +; Production Value: Off + +; error_reporting +; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED +; Development Value: E_ALL +; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT + +; html_errors +; Default Value: On +; Development Value: On +; Production value: On + +; log_errors +; Default Value: Off +; Development Value: On +; Production Value: On + +; max_input_time +; Default Value: -1 (Unlimited) +; Development Value: 60 (60 seconds) +; Production Value: 60 (60 seconds) + +; output_buffering +; Default Value: Off +; Development Value: 4096 +; Production Value: 4096 + +; register_argc_argv +; Default Value: On +; Development Value: Off +; Production Value: Off + +; request_order +; Default Value: None +; Development Value: "GP" +; Production Value: "GP" + +; session.gc_divisor +; Default Value: 100 +; Development Value: 1000 +; Production Value: 1000 + +; session.sid_bits_per_character +; Default Value: 4 +; Development Value: 5 +; Production Value: 5 + +; short_open_tag +; Default Value: On +; Development Value: Off +; Production Value: Off + +; track_errors +; Default Value: Off +; Development Value: On +; Production Value: Off + +; variables_order +; Default Value: "EGPCS" +; Development Value: "GPCS" +; Production Value: "GPCS" + +;;;;;;;;;;;;;;;;;;;; +; php.ini Options ; +;;;;;;;;;;;;;;;;;;;; +; Name for user-defined php.ini (.htaccess) files. Default is ".user.ini" +;user_ini.filename = ".user.ini" + +; To disable this feature set this option to an empty value +;user_ini.filename = + +; TTL for user-defined php.ini files (time-to-live) in seconds. Default is 300 seconds (5 minutes) +;user_ini.cache_ttl = 300 + +;;;;;;;;;;;;;;;;;;;; +; Language Options ; +;;;;;;;;;;;;;;;;;;;; + +; Enable the PHP scripting language engine under Apache. +; http://php.net/engine +engine = On + +; This directive determines whether or not PHP will recognize code between +; tags as PHP source which should be processed as such. It is +; generally recommended that should be used and that this feature +; should be disabled, as enabling it may result in issues when generating XML +; documents, however this remains supported for backward compatibility reasons. +; Note that this directive does not control the would work. +; http://php.net/syntax-highlighting +;highlight.string = #DD0000 +;highlight.comment = #FF9900 +;highlight.keyword = #007700 +;highlight.default = #0000BB +;highlight.html = #000000 + +; If enabled, the request will be allowed to complete even if the user aborts +; the request. Consider enabling it if executing long requests, which may end up +; being interrupted by the user or a browser timing out. PHP's default behavior +; is to disable this feature. +; http://php.net/ignore-user-abort +;ignore_user_abort = On + +; Determines the size of the realpath cache to be used by PHP. This value should +; be increased on systems where PHP opens many files to reflect the quantity of +; the file operations performed. +; Note: if open_basedir is set, the cache is disabled +; http://php.net/realpath-cache-size +;realpath_cache_size = 4096k + +; Duration of time, in seconds for which to cache realpath information for a given +; file or directory. For systems with rarely changing files, consider increasing this +; value. +; http://php.net/realpath-cache-ttl +;realpath_cache_ttl = 120 + +; Enables or disables the circular reference collector. +; http://php.net/zend.enable-gc +zend.enable_gc = On + +; If enabled, scripts may be written in encodings that are incompatible with +; the scanner. CP936, Big5, CP949 and Shift_JIS are the examples of such +; encodings. To use this feature, mbstring extension must be enabled. +; Default: Off +;zend.multibyte = Off + +; Allows to set the default encoding for the scripts. This value will be used +; unless "declare(encoding=...)" directive appears at the top of the script. +; Only affects if zend.multibyte is set. +; Default: "" +;zend.script_encoding = + +;;;;;;;;;;;;;;;;; +; Miscellaneous ; +;;;;;;;;;;;;;;;;; + +; Decides whether PHP may expose the fact that it is installed on the server +; (e.g. by adding its signature to the Web server header). It is no security +; threat in any way, but it makes it possible to determine whether you use PHP +; on your server or not. +; http://php.net/expose-php +expose_php = On + +;;;;;;;;;;;;;;;;;;; +; Resource Limits ; +;;;;;;;;;;;;;;;;;;; + +; Maximum execution time of each script, in seconds +; http://php.net/max-execution-time +; Note: This directive is hardcoded to 0 for the CLI SAPI +max_execution_time = 30 + +; Maximum amount of time each script may spend parsing request data. It's a good +; idea to limit this time on productions servers in order to eliminate unexpectedly +; long running scripts. +; Note: This directive is hardcoded to -1 for the CLI SAPI +; Default Value: -1 (Unlimited) +; Development Value: 60 (60 seconds) +; Production Value: 60 (60 seconds) +; http://php.net/max-input-time +max_input_time = 60 + +; Maximum input variable nesting level +; http://php.net/max-input-nesting-level +;max_input_nesting_level = 64 + +; How many GET/POST/COOKIE input variables may be accepted +;max_input_vars = 1000 + +; Maximum amount of memory a script may consume (128MB) +; http://php.net/memory-limit +memory_limit = 128M + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Error handling and logging ; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; This directive informs PHP of which errors, warnings and notices you would like +; it to take action for. The recommended way of setting values for this +; directive is through the use of the error level constants and bitwise +; operators. The error level constants are below here for convenience as well as +; some common settings and their meanings. +; By default, PHP is set to take action on all errors, notices and warnings EXCEPT +; those related to E_NOTICE and E_STRICT, which together cover best practices and +; recommended coding standards in PHP. For performance reasons, this is the +; recommend error reporting setting. Your production server shouldn't be wasting +; resources complaining about best practices and coding standards. That's what +; development servers and development settings are for. +; Note: The php.ini-development file has this setting as E_ALL. This +; means it pretty much reports everything which is exactly what you want during +; development and early testing. +; +; Error Level Constants: +; E_ALL - All errors and warnings (includes E_STRICT as of PHP 5.4.0) +; E_ERROR - fatal run-time errors +; E_RECOVERABLE_ERROR - almost fatal run-time errors +; E_WARNING - run-time warnings (non-fatal errors) +; E_PARSE - compile-time parse errors +; E_NOTICE - run-time notices (these are warnings which often result +; from a bug in your code, but it's possible that it was +; intentional (e.g., using an uninitialized variable and +; relying on the fact it is automatically initialized to an +; empty string) +; E_STRICT - run-time notices, enable to have PHP suggest changes +; to your code which will ensure the best interoperability +; and forward compatibility of your code +; E_CORE_ERROR - fatal errors that occur during PHP's initial startup +; E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's +; initial startup +; E_COMPILE_ERROR - fatal compile-time errors +; E_COMPILE_WARNING - compile-time warnings (non-fatal errors) +; E_USER_ERROR - user-generated error message +; E_USER_WARNING - user-generated warning message +; E_USER_NOTICE - user-generated notice message +; E_DEPRECATED - warn about code that will not work in future versions +; of PHP +; E_USER_DEPRECATED - user-generated deprecation warnings +; +; Common Values: +; E_ALL (Show all errors, warnings and notices including coding standards.) +; E_ALL & ~E_NOTICE (Show all errors, except for notices) +; E_ALL & ~E_NOTICE & ~E_STRICT (Show all errors, except for notices and coding standards warnings.) +; E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors) +; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED +; Development Value: E_ALL +; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT +; http://php.net/error-reporting +error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT + +; This directive controls whether or not and where PHP will output errors, +; notices and warnings too. Error output is very useful during development, but +; it could be very dangerous in production environments. Depending on the code +; which is triggering the error, sensitive information could potentially leak +; out of your application such as database usernames and passwords or worse. +; For production environments, we recommend logging errors rather than +; sending them to STDOUT. +; Possible Values: +; Off = Do not display any errors +; stderr = Display errors to STDERR (affects only CGI/CLI binaries!) +; On or stdout = Display errors to STDOUT +; Default Value: On +; Development Value: On +; Production Value: Off +; http://php.net/display-errors +display_errors = Off + +; The display of errors which occur during PHP's startup sequence are handled +; separately from display_errors. PHP's default behavior is to suppress those +; errors from clients. Turning the display of startup errors on can be useful in +; debugging configuration problems. We strongly recommend you +; set this to 'off' for production servers. +; Default Value: Off +; Development Value: On +; Production Value: Off +; http://php.net/display-startup-errors +display_startup_errors = Off + +; Besides displaying errors, PHP can also log errors to locations such as a +; server-specific log, STDERR, or a location specified by the error_log +; directive found below. While errors should not be displayed on productions +; servers they should still be monitored and logging is a great way to do that. +; Default Value: Off +; Development Value: On +; Production Value: On +; http://php.net/log-errors +log_errors = On + +; Set maximum length of log_errors. In error_log information about the source is +; added. The default is 1024 and 0 allows to not apply any maximum length at all. +; http://php.net/log-errors-max-len +log_errors_max_len = 1024 + +; Do not log repeated messages. Repeated errors must occur in same file on same +; line unless ignore_repeated_source is set true. +; http://php.net/ignore-repeated-errors +ignore_repeated_errors = Off + +; Ignore source of message when ignoring repeated messages. When this setting +; is On you will not log errors with repeated messages from different files or +; source lines. +; http://php.net/ignore-repeated-source +ignore_repeated_source = Off + +; If this parameter is set to Off, then memory leaks will not be shown (on +; stdout or in the log). This has only effect in a debug compile, and if +; error reporting includes E_WARNING in the allowed list +; http://php.net/report-memleaks +report_memleaks = On + +; This setting is on by default. +;report_zend_debug = 0 + +; Store the last error/warning message in $php_errormsg (boolean). Setting this value +; to On can assist in debugging and is appropriate for development servers. It should +; however be disabled on production servers. +; This directive is DEPRECATED. +; Default Value: Off +; Development Value: Off +; Production Value: Off +; http://php.net/track-errors +;track_errors = Off + +; Turn off normal error reporting and emit XML-RPC error XML +; http://php.net/xmlrpc-errors +;xmlrpc_errors = 0 + +; An XML-RPC faultCode +;xmlrpc_error_number = 0 + +; When PHP displays or logs an error, it has the capability of formatting the +; error message as HTML for easier reading. This directive controls whether +; the error message is formatted as HTML or not. +; Note: This directive is hardcoded to Off for the CLI SAPI +; Default Value: On +; Development Value: On +; Production value: On +; http://php.net/html-errors +html_errors = On + +; If html_errors is set to On *and* docref_root is not empty, then PHP +; produces clickable error messages that direct to a page describing the error +; or function causing the error in detail. +; You can download a copy of the PHP manual from http://php.net/docs +; and change docref_root to the base URL of your local copy including the +; leading '/'. You must also specify the file extension being used including +; the dot. PHP's default behavior is to leave these settings empty, in which +; case no links to documentation are generated. +; Note: Never use this feature for production boxes. +; http://php.net/docref-root +; Examples +;docref_root = "/phpmanual/" + +; http://php.net/docref-ext +;docref_ext = .html + +; String to output before an error message. PHP's default behavior is to leave +; this setting blank. +; http://php.net/error-prepend-string +; Example: +;error_prepend_string = "" + +; String to output after an error message. PHP's default behavior is to leave +; this setting blank. +; http://php.net/error-append-string +; Example: +;error_append_string = "" + +; Log errors to specified file. PHP's default behavior is to leave this value +; empty. +; http://php.net/error-log +; Example: +;error_log = php_errors.log +; Log errors to syslog (Event Log on Windows). +;error_log = syslog + +; The syslog ident is a string which is prepended to every message logged +; to syslog. Only used when error_log is set to syslog. +;syslog.ident = php + +; The syslog facility is used to specify what type of program is logging +; the message. Only used when error_log is set to syslog. +;syslog.facility = user + +; Set this to disable filtering control characters (the default). +; Some loggers only accept NVT-ASCII, others accept anything that's not +; control characters. If your logger accepts everything, then no filtering +; is needed at all. +; Allowed values are: +; ascii (only base ASCII characters) +; no_ctrl (all characters except control characters) +; all (all characters) +;syslog.filter = ascii + +;windows.show_crt_warning +; Default value: 0 +; Development value: 0 +; Production value: 0 + +;;;;;;;;;;;;;;;;; +; Data Handling ; +;;;;;;;;;;;;;;;;; + +; The separator used in PHP generated URLs to separate arguments. +; PHP's default setting is "&". +; http://php.net/arg-separator.output +; Example: +;arg_separator.output = "&" + +; List of separator(s) used by PHP to parse input URLs into variables. +; PHP's default setting is "&". +; NOTE: Every character in this directive is considered as separator! +; http://php.net/arg-separator.input +; Example: +;arg_separator.input = ";&" + +; This directive determines which super global arrays are registered when PHP +; starts up. G,P,C,E & S are abbreviations for the following respective super +; globals: GET, POST, COOKIE, ENV and SERVER. There is a performance penalty +; paid for the registration of these arrays and because ENV is not as commonly +; used as the others, ENV is not recommended on productions servers. You +; can still get access to the environment variables through getenv() should you +; need to. +; Default Value: "EGPCS" +; Development Value: "GPCS" +; Production Value: "GPCS"; +; http://php.net/variables-order +variables_order = "GPCS" + +; This directive determines which super global data (G,P & C) should be +; registered into the super global array REQUEST. If so, it also determines +; the order in which that data is registered. The values for this directive +; are specified in the same manner as the variables_order directive, +; EXCEPT one. Leaving this value empty will cause PHP to use the value set +; in the variables_order directive. It does not mean it will leave the super +; globals array REQUEST empty. +; Default Value: None +; Development Value: "GP" +; Production Value: "GP" +; http://php.net/request-order +request_order = "GP" + +; This directive determines whether PHP registers $argv & $argc each time it +; runs. $argv contains an array of all the arguments passed to PHP when a script +; is invoked. $argc contains an integer representing the number of arguments +; that were passed when the script was invoked. These arrays are extremely +; useful when running scripts from the command line. When this directive is +; enabled, registering these variables consumes CPU cycles and memory each time +; a script is executed. For performance reasons, this feature should be disabled +; on production servers. +; Note: This directive is hardcoded to On for the CLI SAPI +; Default Value: On +; Development Value: Off +; Production Value: Off +; http://php.net/register-argc-argv +register_argc_argv = Off + +; When enabled, the ENV, REQUEST and SERVER variables are created when they're +; first used (Just In Time) instead of when the script starts. If these +; variables are not used within a script, having this directive on will result +; in a performance gain. The PHP directive register_argc_argv must be disabled +; for this directive to have any affect. +; http://php.net/auto-globals-jit +auto_globals_jit = On + +; Whether PHP will read the POST data. +; This option is enabled by default. +; Most likely, you won't want to disable this option globally. It causes $_POST +; and $_FILES to always be empty; the only way you will be able to read the +; POST data will be through the php://input stream wrapper. This can be useful +; to proxy requests or to process the POST data in a memory efficient fashion. +; http://php.net/enable-post-data-reading +;enable_post_data_reading = Off + +; Maximum size of POST data that PHP will accept. +; Its value may be 0 to disable the limit. It is ignored if POST data reading +; is disabled through enable_post_data_reading. +; http://php.net/post-max-size +post_max_size = 8M + +; Automatically add files before PHP document. +; http://php.net/auto-prepend-file +auto_prepend_file = + +; Automatically add files after PHP document. +; http://php.net/auto-append-file +auto_append_file = + +; By default, PHP will output a media type using the Content-Type header. To +; disable this, simply set it to be empty. +; +; PHP's built-in default media type is set to text/html. +; http://php.net/default-mimetype +default_mimetype = "text/html" + +; PHP's default character set is set to UTF-8. +; http://php.net/default-charset +default_charset = "UTF-8" + +; PHP internal character encoding is set to empty. +; If empty, default_charset is used. +; http://php.net/internal-encoding +;internal_encoding = + +; PHP input character encoding is set to empty. +; If empty, default_charset is used. +; http://php.net/input-encoding +;input_encoding = + +; PHP output character encoding is set to empty. +; If empty, default_charset is used. +; See also output_buffer. +; http://php.net/output-encoding +;output_encoding = + +;;;;;;;;;;;;;;;;;;;;;;;;; +; Paths and Directories ; +;;;;;;;;;;;;;;;;;;;;;;;;; + +; UNIX: "/path1:/path2" +;include_path = ".:/php/includes" +; +; Windows: "\path1;\path2" +;include_path = ".;c:\php\includes" +; +; PHP's default setting for include_path is ".;/path/to/php/pear" +; http://php.net/include-path + +; The root of the PHP pages, used only if nonempty. +; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root +; if you are running php as a CGI under any web server (other than IIS) +; see documentation for security issues. The alternate is to use the +; cgi.force_redirect configuration below +; http://php.net/doc-root +doc_root = + +; The directory under which PHP opens the script using /~username used only +; if nonempty. +; http://php.net/user-dir +user_dir = + +; Directory in which the loadable extensions (modules) reside. +; http://php.net/extension-dir +;extension_dir = "./" +; On windows: +;extension_dir = "ext" + +; Directory where the temporary files should be placed. +; Defaults to the system default (see sys_get_temp_dir) +;sys_temp_dir = "/tmp" + +; Whether or not to enable the dl() function. The dl() function does NOT work +; properly in multithreaded servers, such as IIS or Zeus, and is automatically +; disabled on them. +; http://php.net/enable-dl +enable_dl = Off + +; cgi.force_redirect is necessary to provide security running PHP as a CGI under +; most web servers. Left undefined, PHP turns this on by default. You can +; turn it off here AT YOUR OWN RISK +; **You CAN safely turn this off for IIS, in fact, you MUST.** +; http://php.net/cgi.force-redirect +;cgi.force_redirect = 1 + +; if cgi.nph is enabled it will force cgi to always sent Status: 200 with +; every request. PHP's default behavior is to disable this feature. +;cgi.nph = 1 + +; if cgi.force_redirect is turned on, and you are not running under Apache or Netscape +; (iPlanet) web servers, you MAY need to set an environment variable name that PHP +; will look for to know it is OK to continue execution. Setting this variable MAY +; cause security issues, KNOW WHAT YOU ARE DOING FIRST. +; http://php.net/cgi.redirect-status-env +;cgi.redirect_status_env = + +; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's +; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok +; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting +; this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting +; of zero causes PHP to behave as before. Default is 1. You should fix your scripts +; to use SCRIPT_FILENAME rather than PATH_TRANSLATED. +; http://php.net/cgi.fix-pathinfo +;cgi.fix_pathinfo=1 + +; if cgi.discard_path is enabled, the PHP CGI binary can safely be placed outside +; of the web tree and people will not be able to circumvent .htaccess security. +;cgi.discard_path=1 + +; FastCGI under IIS supports the ability to impersonate +; security tokens of the calling client. This allows IIS to define the +; security context that the request runs under. mod_fastcgi under Apache +; does not currently support this feature (03/17/2002) +; Set to 1 if running under IIS. Default is zero. +; http://php.net/fastcgi.impersonate +;fastcgi.impersonate = 1 + +; Disable logging through FastCGI connection. PHP's default behavior is to enable +; this feature. +;fastcgi.logging = 0 + +; cgi.rfc2616_headers configuration option tells PHP what type of headers to +; use when sending HTTP response code. If set to 0, PHP sends Status: header that +; is supported by Apache. When this option is set to 1, PHP will send +; RFC2616 compliant header. +; Default is zero. +; http://php.net/cgi.rfc2616-headers +;cgi.rfc2616_headers = 0 + +; cgi.check_shebang_line controls whether CGI PHP checks for line starting with #! +; (shebang) at the top of the running script. This line might be needed if the +; script support running both as stand-alone script and via PHP CGI<. PHP in CGI +; mode skips this line and ignores its content if this directive is turned on. +; http://php.net/cgi.check-shebang-line +;cgi.check_shebang_line=1 + +;;;;;;;;;;;;;;;; +; File Uploads ; +;;;;;;;;;;;;;;;; + +; Whether to allow HTTP file uploads. +; http://php.net/file-uploads +file_uploads = On + +; Temporary directory for HTTP uploaded files (will use system default if not +; specified). +; http://php.net/upload-tmp-dir +;upload_tmp_dir = + +; Maximum allowed size for uploaded files. +; http://php.net/upload-max-filesize +upload_max_filesize = 2M + +; Maximum number of files that can be uploaded via a single request +max_file_uploads = 20 + +;;;;;;;;;;;;;;;;;; +; Fopen wrappers ; +;;;;;;;;;;;;;;;;;; + +; Whether to allow the treatment of URLs (like http:// or ftp://) as files. +; http://php.net/allow-url-fopen +allow_url_fopen = On + +; Whether to allow include/require to open URLs (like http:// or ftp://) as files. +; http://php.net/allow-url-include +allow_url_include = Off + +; Define the anonymous ftp password (your email address). PHP's default setting +; for this is empty. +; http://php.net/from +;from="john@doe.com" + +; Define the User-Agent string. PHP's default setting for this is empty. +; http://php.net/user-agent +;user_agent="PHP" + +; Default timeout for socket based streams (seconds) +; http://php.net/default-socket-timeout +default_socket_timeout = 60 + +; If your scripts have to deal with files from Macintosh systems, +; or you are running on a Mac and need to deal with files from +; unix or win32 systems, setting this flag will cause PHP to +; automatically detect the EOL character in those files so that +; fgets() and file() will work regardless of the source of the file. +; http://php.net/auto-detect-line-endings +;auto_detect_line_endings = Off + +;;;;;;;;;;;;;;;;;;;;;; +; Dynamic Extensions ; +;;;;;;;;;;;;;;;;;;;;;; + +; If you wish to have an extension loaded automatically, use the following +; syntax: +; +; extension=modulename +; +; For example: +; +; extension=mysqli +; +; When the extension library to load is not located in the default extension +; directory, You may specify an absolute path to the library file: +; +; extension=/path/to/extension/mysqli.so +; +; Note : The syntax used in previous PHP versions ('extension=.so' and +; 'extension='php_.dll') is supported for legacy reasons and may be +; deprecated in a future PHP major version. So, when it is possible, please +; move to the new ('extension=) syntax. +; +; Notes for Windows environments : +; +; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+) +; extension folders as well as the separate PECL DLL download (PHP 5+). +; Be sure to appropriately set the extension_dir directive. +; +;extension=bz2 +;extension=curl +;extension=fileinfo +;extension=gd2 +;extension=gettext +;extension=gmp +;extension=intl +;extension=imap +;extension=interbase +;extension=ldap +;extension=mbstring +;extension=exif ; Must be after mbstring as it depends on it +;extension=mysqli +;extension=oci8_12c ; Use with Oracle Database 12c Instant Client +;extension=odbc +;extension=openssl +;extension=pdo_firebird +;extension=pdo_mysql +;extension=pdo_oci +;extension=pdo_odbc +;extension=pdo_pgsql +;extension=pdo_sqlite +;extension=pgsql +;extension=shmop + +; The MIBS data available in the PHP distribution must be installed. +; See http://www.php.net/manual/en/snmp.installation.php +;extension=snmp + +;extension=soap +;extension=sockets +;extension=sodium +;extension=sqlite3 +;extension=tidy +;extension=xmlrpc +;extension=xsl + +;;;;;;;;;;;;;;;;;;; +; Module Settings ; +;;;;;;;;;;;;;;;;;;; + +[CLI Server] +; Whether the CLI web server uses ANSI color coding in its terminal output. +cli_server.color = On + +[Date] +; Defines the default timezone used by the date functions +; http://php.net/date.timezone +;date.timezone = + +; http://php.net/date.default-latitude +;date.default_latitude = 31.7667 + +; http://php.net/date.default-longitude +;date.default_longitude = 35.2333 + +; http://php.net/date.sunrise-zenith +;date.sunrise_zenith = 90.583333 + +; http://php.net/date.sunset-zenith +;date.sunset_zenith = 90.583333 + +[filter] +; http://php.net/filter.default +;filter.default = unsafe_raw + +; http://php.net/filter.default-flags +;filter.default_flags = + +[iconv] +; Use of this INI entry is deprecated, use global input_encoding instead. +; If empty, default_charset or input_encoding or iconv.input_encoding is used. +; The precedence is: default_charset < input_encoding < iconv.input_encoding +;iconv.input_encoding = + +; Use of this INI entry is deprecated, use global internal_encoding instead. +; If empty, default_charset or internal_encoding or iconv.internal_encoding is used. +; The precedence is: default_charset < internal_encoding < iconv.internal_encoding +;iconv.internal_encoding = + +; Use of this INI entry is deprecated, use global output_encoding instead. +; If empty, default_charset or output_encoding or iconv.output_encoding is used. +; The precedence is: default_charset < output_encoding < iconv.output_encoding +; To use an output encoding conversion, iconv's output handler must be set +; otherwise output encoding conversion cannot be performed. +;iconv.output_encoding = + +[imap] +; rsh/ssh logins are disabled by default. Use this INI entry if you want to +; enable them. Note that the IMAP library does not filter mailbox names before +; passing them to rsh/ssh command, thus passing untrusted data to this function +; with rsh/ssh enabled is insecure. +;imap.enable_insecure_rsh=0 + +[intl] +;intl.default_locale = +; This directive allows you to produce PHP errors when some error +; happens within intl functions. The value is the level of the error produced. +; Default is 0, which does not produce any errors. +;intl.error_level = E_WARNING +;intl.use_exceptions = 0 + +[sqlite3] +;sqlite3.extension_dir = + +[Pcre] +; PCRE library backtracking limit. +; http://php.net/pcre.backtrack-limit +;pcre.backtrack_limit=100000 + +; PCRE library recursion limit. +; Please note that if you set this value to a high number you may consume all +; the available process stack and eventually crash PHP (due to reaching the +; stack size limit imposed by the Operating System). +; http://php.net/pcre.recursion-limit +;pcre.recursion_limit=100000 + +; Enables or disables JIT compilation of patterns. This requires the PCRE +; library to be compiled with JIT support. +;pcre.jit=1 + +[Pdo] +; Whether to pool ODBC connections. Can be one of "strict", "relaxed" or "off" +; http://php.net/pdo-odbc.connection-pooling +;pdo_odbc.connection_pooling=strict + +;pdo_odbc.db2_instance_name + +[Pdo_mysql] +; Default socket name for local MySQL connects. If empty, uses the built-in +; MySQL defaults. +pdo_mysql.default_socket= + +[Phar] +; http://php.net/phar.readonly +;phar.readonly = On + +; http://php.net/phar.require-hash +;phar.require_hash = On + +;phar.cache_list = + +[mail function] +; For Win32 only. +; http://php.net/smtp +SMTP = localhost +; http://php.net/smtp-port +smtp_port = 25 + +; For Win32 only. +; http://php.net/sendmail-from +;sendmail_from = me@example.com + +; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). +; http://php.net/sendmail-path +;sendmail_path = + +; Force the addition of the specified parameters to be passed as extra parameters +; to the sendmail binary. These parameters will always replace the value of +; the 5th parameter to mail(). +;mail.force_extra_parameters = + +; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename +mail.add_x_header = Off + +; The path to a log file that will log all mail() calls. Log entries include +; the full path of the script, line number, To address and headers. +;mail.log = +; Log mail to syslog (Event Log on Windows). +;mail.log = syslog + +[ODBC] +; http://php.net/odbc.default-db +;odbc.default_db = Not yet implemented + +; http://php.net/odbc.default-user +;odbc.default_user = Not yet implemented + +; http://php.net/odbc.default-pw +;odbc.default_pw = Not yet implemented + +; Controls the ODBC cursor model. +; Default: SQL_CURSOR_STATIC (default). +;odbc.default_cursortype + +; Allow or prevent persistent links. +; http://php.net/odbc.allow-persistent +odbc.allow_persistent = On + +; Check that a connection is still valid before reuse. +; http://php.net/odbc.check-persistent +odbc.check_persistent = On + +; Maximum number of persistent links. -1 means no limit. +; http://php.net/odbc.max-persistent +odbc.max_persistent = -1 + +; Maximum number of links (persistent + non-persistent). -1 means no limit. +; http://php.net/odbc.max-links +odbc.max_links = -1 + +; Handling of LONG fields. Returns number of bytes to variables. 0 means +; passthru. +; http://php.net/odbc.defaultlrl +odbc.defaultlrl = 4096 + +; Handling of binary data. 0 means passthru, 1 return as is, 2 convert to char. +; See the documentation on odbc_binmode and odbc_longreadlen for an explanation +; of odbc.defaultlrl and odbc.defaultbinmode +; http://php.net/odbc.defaultbinmode +odbc.defaultbinmode = 1 + +[Interbase] +; Allow or prevent persistent links. +ibase.allow_persistent = 1 + +; Maximum number of persistent links. -1 means no limit. +ibase.max_persistent = -1 + +; Maximum number of links (persistent + non-persistent). -1 means no limit. +ibase.max_links = -1 + +; Default database name for ibase_connect(). +;ibase.default_db = + +; Default username for ibase_connect(). +;ibase.default_user = + +; Default password for ibase_connect(). +;ibase.default_password = + +; Default charset for ibase_connect(). +;ibase.default_charset = + +; Default timestamp format. +ibase.timestampformat = "%Y-%m-%d %H:%M:%S" + +; Default date format. +ibase.dateformat = "%Y-%m-%d" + +; Default time format. +ibase.timeformat = "%H:%M:%S" + +[MySQLi] + +; Maximum number of persistent links. -1 means no limit. +; http://php.net/mysqli.max-persistent +mysqli.max_persistent = -1 + +; Allow accessing, from PHP's perspective, local files with LOAD DATA statements +; http://php.net/mysqli.allow_local_infile +;mysqli.allow_local_infile = On + +; Allow or prevent persistent links. +; http://php.net/mysqli.allow-persistent +mysqli.allow_persistent = On + +; Maximum number of links. -1 means no limit. +; http://php.net/mysqli.max-links +mysqli.max_links = -1 + +; Default port number for mysqli_connect(). If unset, mysqli_connect() will use +; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the +; compile-time value defined MYSQL_PORT (in that order). Win32 will only look +; at MYSQL_PORT. +; http://php.net/mysqli.default-port +mysqli.default_port = 3306 + +; Default socket name for local MySQL connects. If empty, uses the built-in +; MySQL defaults. +; http://php.net/mysqli.default-socket +mysqli.default_socket = + +; Default host for mysql_connect() (doesn't apply in safe mode). +; http://php.net/mysqli.default-host +mysqli.default_host = + +; Default user for mysql_connect() (doesn't apply in safe mode). +; http://php.net/mysqli.default-user +mysqli.default_user = + +; Default password for mysqli_connect() (doesn't apply in safe mode). +; Note that this is generally a *bad* idea to store passwords in this file. +; *Any* user with PHP access can run 'echo get_cfg_var("mysqli.default_pw") +; and reveal this password! And of course, any users with read access to this +; file will be able to reveal the password as well. +; http://php.net/mysqli.default-pw +mysqli.default_pw = + +; Allow or prevent reconnect +mysqli.reconnect = Off + +[mysqlnd] +; Enable / Disable collection of general statistics by mysqlnd which can be +; used to tune and monitor MySQL operations. +mysqlnd.collect_statistics = On + +; Enable / Disable collection of memory usage statistics by mysqlnd which can be +; used to tune and monitor MySQL operations. +mysqlnd.collect_memory_statistics = Off + +; Records communication from all extensions using mysqlnd to the specified log +; file. +; http://php.net/mysqlnd.debug +;mysqlnd.debug = + +; Defines which queries will be logged. +;mysqlnd.log_mask = 0 + +; Default size of the mysqlnd memory pool, which is used by result sets. +;mysqlnd.mempool_default_size = 16000 + +; Size of a pre-allocated buffer used when sending commands to MySQL in bytes. +;mysqlnd.net_cmd_buffer_size = 2048 + +; Size of a pre-allocated buffer used for reading data sent by the server in +; bytes. +;mysqlnd.net_read_buffer_size = 32768 + +; Timeout for network requests in seconds. +;mysqlnd.net_read_timeout = 31536000 + +; SHA-256 Authentication Plugin related. File with the MySQL server public RSA +; key. +;mysqlnd.sha256_server_public_key = + +[OCI8] + +; Connection: Enables privileged connections using external +; credentials (OCI_SYSOPER, OCI_SYSDBA) +; http://php.net/oci8.privileged-connect +;oci8.privileged_connect = Off + +; Connection: The maximum number of persistent OCI8 connections per +; process. Using -1 means no limit. +; http://php.net/oci8.max-persistent +;oci8.max_persistent = -1 + +; Connection: The maximum number of seconds a process is allowed to +; maintain an idle persistent connection. Using -1 means idle +; persistent connections will be maintained forever. +; http://php.net/oci8.persistent-timeout +;oci8.persistent_timeout = -1 + +; Connection: The number of seconds that must pass before issuing a +; ping during oci_pconnect() to check the connection validity. When +; set to 0, each oci_pconnect() will cause a ping. Using -1 disables +; pings completely. +; http://php.net/oci8.ping-interval +;oci8.ping_interval = 60 + +; Connection: Set this to a user chosen connection class to be used +; for all pooled server requests with Oracle 11g Database Resident +; Connection Pooling (DRCP). To use DRCP, this value should be set to +; the same string for all web servers running the same application, +; the database pool must be configured, and the connection string must +; specify to use a pooled server. +;oci8.connection_class = + +; High Availability: Using On lets PHP receive Fast Application +; Notification (FAN) events generated when a database node fails. The +; database must also be configured to post FAN events. +;oci8.events = Off + +; Tuning: This option enables statement caching, and specifies how +; many statements to cache. Using 0 disables statement caching. +; http://php.net/oci8.statement-cache-size +;oci8.statement_cache_size = 20 + +; Tuning: Enables statement prefetching and sets the default number of +; rows that will be fetched automatically after statement execution. +; http://php.net/oci8.default-prefetch +;oci8.default_prefetch = 100 + +; Compatibility. Using On means oci_close() will not close +; oci_connect() and oci_new_connect() connections. +; http://php.net/oci8.old-oci-close-semantics +;oci8.old_oci_close_semantics = Off + +[PostgreSQL] +; Allow or prevent persistent links. +; http://php.net/pgsql.allow-persistent +pgsql.allow_persistent = On + +; Detect broken persistent links always with pg_pconnect(). +; Auto reset feature requires a little overheads. +; http://php.net/pgsql.auto-reset-persistent +pgsql.auto_reset_persistent = Off + +; Maximum number of persistent links. -1 means no limit. +; http://php.net/pgsql.max-persistent +pgsql.max_persistent = -1 + +; Maximum number of links (persistent+non persistent). -1 means no limit. +; http://php.net/pgsql.max-links +pgsql.max_links = -1 + +; Ignore PostgreSQL backends Notice message or not. +; Notice message logging require a little overheads. +; http://php.net/pgsql.ignore-notice +pgsql.ignore_notice = 0 + +; Log PostgreSQL backends Notice message or not. +; Unless pgsql.ignore_notice=0, module cannot log notice message. +; http://php.net/pgsql.log-notice +pgsql.log_notice = 0 + +[bcmath] +; Number of decimal digits for all bcmath functions. +; http://php.net/bcmath.scale +bcmath.scale = 0 + +[browscap] +; http://php.net/browscap +;browscap = extra/browscap.ini + +[Session] +; Handler used to store/retrieve data. +; http://php.net/session.save-handler +session.save_handler = files + +; Argument passed to save_handler. In the case of files, this is the path +; where data files are stored. Note: Windows users have to change this +; variable in order to use PHP's session functions. +; +; The path can be defined as: +; +; session.save_path = "N;/path" +; +; where N is an integer. Instead of storing all the session files in +; /path, what this will do is use subdirectories N-levels deep, and +; store the session data in those directories. This is useful if +; your OS has problems with many files in one directory, and is +; a more efficient layout for servers that handle many sessions. +; +; NOTE 1: PHP will not create this directory structure automatically. +; You can use the script in the ext/session dir for that purpose. +; NOTE 2: See the section on garbage collection below if you choose to +; use subdirectories for session storage +; +; The file storage module creates files using mode 600 by default. +; You can change that by using +; +; session.save_path = "N;MODE;/path" +; +; where MODE is the octal representation of the mode. Note that this +; does not overwrite the process's umask. +; http://php.net/session.save-path +;session.save_path = "/tmp" + +; Whether to use strict session mode. +; Strict session mode does not accept an uninitialized session ID, and +; regenerates the session ID if the browser sends an uninitialized session ID. +; Strict mode protects applications from session fixation via a session adoption +; vulnerability. It is disabled by default for maximum compatibility, but +; enabling it is encouraged. +; https://wiki.php.net/rfc/strict_sessions +session.use_strict_mode = 0 + +; Whether to use cookies. +; http://php.net/session.use-cookies +session.use_cookies = 1 + +; http://php.net/session.cookie-secure +;session.cookie_secure = + +; This option forces PHP to fetch and use a cookie for storing and maintaining +; the session id. We encourage this operation as it's very helpful in combating +; session hijacking when not specifying and managing your own session id. It is +; not the be-all and end-all of session hijacking defense, but it's a good start. +; http://php.net/session.use-only-cookies +session.use_only_cookies = 1 + +; Name of the session (used as cookie name). +; http://php.net/session.name +session.name = PHPSESSID + +; Initialize session on request startup. +; http://php.net/session.auto-start +session.auto_start = 0 + +; Lifetime in seconds of cookie or, if 0, until browser is restarted. +; http://php.net/session.cookie-lifetime +session.cookie_lifetime = 0 + +; The path for which the cookie is valid. +; http://php.net/session.cookie-path +session.cookie_path = / + +; The domain for which the cookie is valid. +; http://php.net/session.cookie-domain +session.cookie_domain = + +; Whether or not to add the httpOnly flag to the cookie, which makes it +; inaccessible to browser scripting languages such as JavaScript. +; http://php.net/session.cookie-httponly +session.cookie_httponly = + +; Add SameSite attribute to cookie to help mitigate Cross-Site Request Forgery (CSRF/XSRF) +; Current valid values are "Lax" or "Strict" +; https://tools.ietf.org/html/draft-west-first-party-cookies-07 +session.cookie_samesite = + +; Handler used to serialize data. php is the standard serializer of PHP. +; http://php.net/session.serialize-handler +session.serialize_handler = php + +; Defines the probability that the 'garbage collection' process is started +; on every session initialization. The probability is calculated by using +; gc_probability/gc_divisor. Where session.gc_probability is the numerator +; and gc_divisor is the denominator in the equation. Setting this value to 1 +; when the session.gc_divisor value is 100 will give you approximately a 1% chance +; the gc will run on any given request. +; Default Value: 1 +; Development Value: 1 +; Production Value: 1 +; http://php.net/session.gc-probability +session.gc_probability = 1 + +; Defines the probability that the 'garbage collection' process is started on every +; session initialization. The probability is calculated by using the following equation: +; gc_probability/gc_divisor. Where session.gc_probability is the numerator and +; session.gc_divisor is the denominator in the equation. Setting this value to 100 +; when the session.gc_probability value is 1 will give you approximately a 1% chance +; the gc will run on any given request. Increasing this value to 1000 will give you +; a 0.1% chance the gc will run on any given request. For high volume production servers, +; this is a more efficient approach. +; Default Value: 100 +; Development Value: 1000 +; Production Value: 1000 +; http://php.net/session.gc-divisor +session.gc_divisor = 1000 + +; After this number of seconds, stored data will be seen as 'garbage' and +; cleaned up by the garbage collection process. +; http://php.net/session.gc-maxlifetime +session.gc_maxlifetime = 1440 + +; NOTE: If you are using the subdirectory option for storing session files +; (see session.save_path above), then garbage collection does *not* +; happen automatically. You will need to do your own garbage +; collection through a shell script, cron entry, or some other method. +; For example, the following script would is the equivalent of +; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes): +; find /path/to/sessions -cmin +24 -type f | xargs rm + +; Check HTTP Referer to invalidate externally stored URLs containing ids. +; HTTP_REFERER has to contain this substring for the session to be +; considered as valid. +; http://php.net/session.referer-check +session.referer_check = + +; Set to {nocache,private,public,} to determine HTTP caching aspects +; or leave this empty to avoid sending anti-caching headers. +; http://php.net/session.cache-limiter +session.cache_limiter = nocache + +; Document expires after n minutes. +; http://php.net/session.cache-expire +session.cache_expire = 180 + +; trans sid support is disabled by default. +; Use of trans sid may risk your users' security. +; Use this option with caution. +; - User may send URL contains active session ID +; to other person via. email/irc/etc. +; - URL that contains active session ID may be stored +; in publicly accessible computer. +; - User may access your site with the same session ID +; always using URL stored in browser's history or bookmarks. +; http://php.net/session.use-trans-sid +session.use_trans_sid = 0 + +; Set session ID character length. This value could be between 22 to 256. +; Shorter length than default is supported only for compatibility reason. +; Users should use 32 or more chars. +; http://php.net/session.sid-length +; Default Value: 32 +; Development Value: 26 +; Production Value: 26 +session.sid_length = 26 + +; The URL rewriter will look for URLs in a defined set of HTML tags. +;
is special; if you include them here, the rewriter will +; add a hidden field with the info which is otherwise appended +; to URLs. tag's action attribute URL will not be modified +; unless it is specified. +; Note that all valid entries require a "=", even if no value follows. +; Default Value: "a=href,area=href,frame=src,form=" +; Development Value: "a=href,area=href,frame=src,form=" +; Production Value: "a=href,area=href,frame=src,form=" +; http://php.net/url-rewriter.tags +session.trans_sid_tags = "a=href,area=href,frame=src,form=" + +; URL rewriter does not rewrite absolute URLs by default. +; To enable rewrites for absolute paths, target hosts must be specified +; at RUNTIME. i.e. use ini_set() +; tags is special. PHP will check action attribute's URL regardless +; of session.trans_sid_tags setting. +; If no host is defined, HTTP_HOST will be used for allowed host. +; Example value: php.net,www.php.net,wiki.php.net +; Use "," for multiple hosts. No spaces are allowed. +; Default Value: "" +; Development Value: "" +; Production Value: "" +;session.trans_sid_hosts="" + +; Define how many bits are stored in each character when converting +; the binary hash data to something readable. +; Possible values: +; 4 (4 bits: 0-9, a-f) +; 5 (5 bits: 0-9, a-v) +; 6 (6 bits: 0-9, a-z, A-Z, "-", ",") +; Default Value: 4 +; Development Value: 5 +; Production Value: 5 +; http://php.net/session.hash-bits-per-character +session.sid_bits_per_character = 5 + +; Enable upload progress tracking in $_SESSION +; Default Value: On +; Development Value: On +; Production Value: On +; http://php.net/session.upload-progress.enabled +;session.upload_progress.enabled = On + +; Cleanup the progress information as soon as all POST data has been read +; (i.e. upload completed). +; Default Value: On +; Development Value: On +; Production Value: On +; http://php.net/session.upload-progress.cleanup +;session.upload_progress.cleanup = On + +; A prefix used for the upload progress key in $_SESSION +; Default Value: "upload_progress_" +; Development Value: "upload_progress_" +; Production Value: "upload_progress_" +; http://php.net/session.upload-progress.prefix +;session.upload_progress.prefix = "upload_progress_" + +; The index name (concatenated with the prefix) in $_SESSION +; containing the upload progress information +; Default Value: "PHP_SESSION_UPLOAD_PROGRESS" +; Development Value: "PHP_SESSION_UPLOAD_PROGRESS" +; Production Value: "PHP_SESSION_UPLOAD_PROGRESS" +; http://php.net/session.upload-progress.name +;session.upload_progress.name = "PHP_SESSION_UPLOAD_PROGRESS" + +; How frequently the upload progress should be updated. +; Given either in percentages (per-file), or in bytes +; Default Value: "1%" +; Development Value: "1%" +; Production Value: "1%" +; http://php.net/session.upload-progress.freq +;session.upload_progress.freq = "1%" + +; The minimum delay between updates, in seconds +; Default Value: 1 +; Development Value: 1 +; Production Value: 1 +; http://php.net/session.upload-progress.min-freq +;session.upload_progress.min_freq = "1" + +; Only write session data when session data is changed. Enabled by default. +; http://php.net/session.lazy-write +;session.lazy_write = On + +[Assertion] +; Switch whether to compile assertions at all (to have no overhead at run-time) +; -1: Do not compile at all +; 0: Jump over assertion at run-time +; 1: Execute assertions +; Changing from or to a negative value is only possible in php.ini! (For turning assertions on and off at run-time, see assert.active, when zend.assertions = 1) +; Default Value: 1 +; Development Value: 1 +; Production Value: -1 +; http://php.net/zend.assertions +zend.assertions = -1 + +; Assert(expr); active by default. +; http://php.net/assert.active +;assert.active = On + +; Throw an AssertionError on failed assertions +; http://php.net/assert.exception +;assert.exception = On + +; Issue a PHP warning for each failed assertion. (Overridden by assert.exception if active) +; http://php.net/assert.warning +;assert.warning = On + +; Don't bail out by default. +; http://php.net/assert.bail +;assert.bail = Off + +; User-function to be called if an assertion fails. +; http://php.net/assert.callback +;assert.callback = 0 + +; Eval the expression with current error_reporting(). Set to true if you want +; error_reporting(0) around the eval(). +; http://php.net/assert.quiet-eval +;assert.quiet_eval = 0 + +[COM] +; path to a file containing GUIDs, IIDs or filenames of files with TypeLibs +; http://php.net/com.typelib-file +;com.typelib_file = + +; allow Distributed-COM calls +; http://php.net/com.allow-dcom +;com.allow_dcom = true + +; autoregister constants of a component's typlib on com_load() +; http://php.net/com.autoregister-typelib +;com.autoregister_typelib = true + +; register constants casesensitive +; http://php.net/com.autoregister-casesensitive +;com.autoregister_casesensitive = false + +; show warnings on duplicate constant registrations +; http://php.net/com.autoregister-verbose +;com.autoregister_verbose = true + +; The default character set code-page to use when passing strings to and from COM objects. +; Default: system ANSI code page +;com.code_page= + +[mbstring] +; language for internal character representation. +; This affects mb_send_mail() and mbstring.detect_order. +; http://php.net/mbstring.language +;mbstring.language = Japanese + +; Use of this INI entry is deprecated, use global internal_encoding instead. +; internal/script encoding. +; Some encoding cannot work as internal encoding. (e.g. SJIS, BIG5, ISO-2022-*) +; If empty, default_charset or internal_encoding or iconv.internal_encoding is used. +; The precedence is: default_charset < internal_encoding < iconv.internal_encoding +;mbstring.internal_encoding = + +; Use of this INI entry is deprecated, use global input_encoding instead. +; http input encoding. +; mbstring.encoding_translation = On is needed to use this setting. +; If empty, default_charset or input_encoding or mbstring.input is used. +; The precedence is: default_charset < input_encoding < mbsting.http_input +; http://php.net/mbstring.http-input +;mbstring.http_input = + +; Use of this INI entry is deprecated, use global output_encoding instead. +; http output encoding. +; mb_output_handler must be registered as output buffer to function. +; If empty, default_charset or output_encoding or mbstring.http_output is used. +; The precedence is: default_charset < output_encoding < mbstring.http_output +; To use an output encoding conversion, mbstring's output handler must be set +; otherwise output encoding conversion cannot be performed. +; http://php.net/mbstring.http-output +;mbstring.http_output = + +; enable automatic encoding translation according to +; mbstring.internal_encoding setting. Input chars are +; converted to internal encoding by setting this to On. +; Note: Do _not_ use automatic encoding translation for +; portable libs/applications. +; http://php.net/mbstring.encoding-translation +;mbstring.encoding_translation = Off + +; automatic encoding detection order. +; "auto" detect order is changed according to mbstring.language +; http://php.net/mbstring.detect-order +;mbstring.detect_order = auto + +; substitute_character used when character cannot be converted +; one from another +; http://php.net/mbstring.substitute-character +;mbstring.substitute_character = none + +; overload(replace) single byte functions by mbstring functions. +; mail(), ereg(), etc are overloaded by mb_send_mail(), mb_ereg(), +; etc. Possible values are 0,1,2,4 or combination of them. +; For example, 7 for overload everything. +; 0: No overload +; 1: Overload mail() function +; 2: Overload str*() functions +; 4: Overload ereg*() functions +; http://php.net/mbstring.func-overload +;mbstring.func_overload = 0 + +; enable strict encoding detection. +; Default: Off +;mbstring.strict_detection = On + +; This directive specifies the regex pattern of content types for which mb_output_handler() +; is activated. +; Default: mbstring.http_output_conv_mimetype=^(text/|application/xhtml\+xml) +;mbstring.http_output_conv_mimetype= + +[gd] +; Tell the jpeg decode to ignore warnings and try to create +; a gd image. The warning will then be displayed as notices +; disabled by default +; http://php.net/gd.jpeg-ignore-warning +;gd.jpeg_ignore_warning = 1 + +[exif] +; Exif UNICODE user comments are handled as UCS-2BE/UCS-2LE and JIS as JIS. +; With mbstring support this will automatically be converted into the encoding +; given by corresponding encode setting. When empty mbstring.internal_encoding +; is used. For the decode settings you can distinguish between motorola and +; intel byte order. A decode setting cannot be empty. +; http://php.net/exif.encode-unicode +;exif.encode_unicode = ISO-8859-15 + +; http://php.net/exif.decode-unicode-motorola +;exif.decode_unicode_motorola = UCS-2BE + +; http://php.net/exif.decode-unicode-intel +;exif.decode_unicode_intel = UCS-2LE + +; http://php.net/exif.encode-jis +;exif.encode_jis = + +; http://php.net/exif.decode-jis-motorola +;exif.decode_jis_motorola = JIS + +; http://php.net/exif.decode-jis-intel +;exif.decode_jis_intel = JIS + +[Tidy] +; The path to a default tidy configuration file to use when using tidy +; http://php.net/tidy.default-config +;tidy.default_config = /usr/local/lib/php/default.tcfg + +; Should tidy clean and repair output automatically? +; WARNING: Do not use this option if you are generating non-html content +; such as dynamic images +; http://php.net/tidy.clean-output +tidy.clean_output = Off + +[soap] +; Enables or disables WSDL caching feature. +; http://php.net/soap.wsdl-cache-enabled +soap.wsdl_cache_enabled=1 + +; Sets the directory name where SOAP extension will put cache files. +; http://php.net/soap.wsdl-cache-dir +soap.wsdl_cache_dir="/tmp" + +; (time to live) Sets the number of second while cached file will be used +; instead of original one. +; http://php.net/soap.wsdl-cache-ttl +soap.wsdl_cache_ttl=86400 + +; Sets the size of the cache limit. (Max. number of WSDL files to cache) +soap.wsdl_cache_limit = 5 + +[sysvshm] +; A default size of the shared memory segment +;sysvshm.init_mem = 10000 + +[ldap] +; Sets the maximum number of open links or -1 for unlimited. +ldap.max_links = -1 + +[dba] +;dba.default_handler= + +[opcache] +; Determines if Zend OPCache is enabled +;opcache.enable=1 + +; Determines if Zend OPCache is enabled for the CLI version of PHP +;opcache.enable_cli=0 + +; The OPcache shared memory storage size. +;opcache.memory_consumption=128 + +; The amount of memory for interned strings in Mbytes. +;opcache.interned_strings_buffer=8 + +; The maximum number of keys (scripts) in the OPcache hash table. +; Only numbers between 200 and 1000000 are allowed. +;opcache.max_accelerated_files=10000 + +; The maximum percentage of "wasted" memory until a restart is scheduled. +;opcache.max_wasted_percentage=5 + +; When this directive is enabled, the OPcache appends the current working +; directory to the script key, thus eliminating possible collisions between +; files with the same name (basename). Disabling the directive improves +; performance, but may break existing applications. +;opcache.use_cwd=1 + +; When disabled, you must reset the OPcache manually or restart the +; webserver for changes to the filesystem to take effect. +;opcache.validate_timestamps=1 + +; How often (in seconds) to check file timestamps for changes to the shared +; memory storage allocation. ("1" means validate once per second, but only +; once per request. "0" means always validate) +;opcache.revalidate_freq=2 + +; Enables or disables file search in include_path optimization +;opcache.revalidate_path=0 + +; If disabled, all PHPDoc comments are dropped from the code to reduce the +; size of the optimized code. +;opcache.save_comments=1 + +; Allow file existence override (file_exists, etc.) performance feature. +;opcache.enable_file_override=0 + +; A bitmask, where each bit enables or disables the appropriate OPcache +; passes +;opcache.optimization_level=0x7FFFBFFF + +;opcache.dups_fix=0 + +; The location of the OPcache blacklist file (wildcards allowed). +; Each OPcache blacklist file is a text file that holds the names of files +; that should not be accelerated. The file format is to add each filename +; to a new line. The filename may be a full path or just a file prefix +; (i.e., /var/www/x blacklists all the files and directories in /var/www +; that start with 'x'). Line starting with a ; are ignored (comments). +;opcache.blacklist_filename= + +; Allows exclusion of large files from being cached. By default all files +; are cached. +;opcache.max_file_size=0 + +; Check the cache checksum each N requests. +; The default value of "0" means that the checks are disabled. +;opcache.consistency_checks=0 + +; How long to wait (in seconds) for a scheduled restart to begin if the cache +; is not being accessed. +;opcache.force_restart_timeout=180 + +; OPcache error_log file name. Empty string assumes "stderr". +;opcache.error_log= + +; All OPcache errors go to the Web server log. +; By default, only fatal errors (level 0) or errors (level 1) are logged. +; You can also enable warnings (level 2), info messages (level 3) or +; debug messages (level 4). +;opcache.log_verbosity_level=1 + +; Preferred Shared Memory back-end. Leave empty and let the system decide. +;opcache.preferred_memory_model= + +; Protect the shared memory from unexpected writing during script execution. +; Useful for internal debugging only. +;opcache.protect_memory=0 + +; Allows calling OPcache API functions only from PHP scripts which path is +; started from specified string. The default "" means no restriction +;opcache.restrict_api= + +; Mapping base of shared memory segments (for Windows only). All the PHP +; processes have to map shared memory into the same address space. This +; directive allows to manually fix the "Unable to reattach to base address" +; errors. +;opcache.mmap_base= + +; Enables and sets the second level cache directory. +; It should improve performance when SHM memory is full, at server restart or +; SHM reset. The default "" disables file based caching. +;opcache.file_cache= + +; Enables or disables opcode caching in shared memory. +;opcache.file_cache_only=0 + +; Enables or disables checksum validation when script loaded from file cache. +;opcache.file_cache_consistency_checks=1 + +; Implies opcache.file_cache_only=1 for a certain process that failed to +; reattach to the shared memory (for Windows only). Explicitly enabled file +; cache is required. +;opcache.file_cache_fallback=1 + +; Enables or disables copying of PHP code (text segment) into HUGE PAGES. +; This should improve performance, but requires appropriate OS configuration. +;opcache.huge_code_pages=1 + +; Validate cached file permissions. +;opcache.validate_permission=0 + +; Prevent name collisions in chroot'ed environment. +;opcache.validate_root=0 + +; If specified, it produces opcode dumps for debugging different stages of +; optimizations. +;opcache.opt_debug_level=0 + +[curl] +; A default value for the CURLOPT_CAINFO option. This is required to be an +; absolute path. +;curl.cainfo = + +[openssl] +; The location of a Certificate Authority (CA) file on the local filesystem +; to use when verifying the identity of SSL/TLS peers. Most users should +; not specify a value for this directive as PHP will attempt to use the +; OS-managed cert stores in its absence. If specified, this value may still +; be overridden on a per-stream basis via the "cafile" SSL stream context +; option. +;openssl.cafile= + +; If openssl.cafile is not specified or if the CA file is not found, the +; directory pointed to by openssl.capath is searched for a suitable +; certificate. This value must be a correctly hashed certificate directory. +; Most users should not specify a value for this directive as PHP will +; attempt to use the OS-managed cert stores in its absence. If specified, +; this value may still be overridden on a per-stream basis via the "capath" +; SSL stream context option. +;openssl.capath= + +; Local Variables: +; tab-width: 4 +; End: diff --git a/docker-compose.asset_server.yml b/docker-compose.asset_server.yml index 4da750c14..7e46447c4 100644 --- a/docker-compose.asset_server.yml +++ b/docker-compose.asset_server.yml @@ -18,7 +18,6 @@ services: environment : _SERVICE_NAME: 'asset_server' DATABASE_URL : 'pgsql://postgres:password@postgres_server:5432/postgres' - SYMFONY_ENV : 'dev' postgres_server: tty : true diff --git a/libraries/php/BuildProcess/Abstractions/AssetBuildSection.php b/libraries/php/BuildProcess/Abstractions/AssetBuildSection.php index 42bc75e3c..6bd8f60d2 100644 --- a/libraries/php/BuildProcess/Abstractions/AssetBuildSection.php +++ b/libraries/php/BuildProcess/Abstractions/AssetBuildSection.php @@ -1,47 +1,48 @@ -config_initialize( - [self::CONFIG_KEY_DIR_OUTPUT => null, self::CONFIG_KEY_DIR_DATA => null, 'files' => null], - $code_builder->config_get(['assets', $name]) + $this->config_yaml_set_data( + $this->config_universal_get(SCHEMAS::YAML_ASSETS), $code_builder->config_yaml_get(['assets', $name]) ); + $this->repo_entity_files = $this->get_repo(EntityFileRepository::class); - $directory_data = $this->config_get(self::CONFIG_KEY_DIR_DATA); - foreach ($this->config_get('files') as $k => $v) { + $directory_data = $this->config_yaml_get(PATHS::DIRECTORY_DATA); + foreach ($this->config_yaml_get('files') as $k => $v) { $this->file_builds[$directory_data . $k] = $v; } } private function parse_file(string $file, array $flags) { - if (!$this->repo_entity_files->has_entity($file)) { - $f = $this->repo_entity_files->create_new_entity($file); - } else { + if ($this->repo_entity_files->has_entity($file)) { $f = $this->process_entity($this->repo_entity_files->get_entity($file)); + } else { + $f = $this->repo_entity_files->create_new_entity($file); } if ($this->has_flag_processed($flags)) { @@ -67,20 +68,28 @@ protected function on_entity_update(EntityInterface $entity) { } protected function has_flag_processed(array $flags) : bool { - return in_array(EntityFile::FLAG_PRE_PROCESS, $flags, true); + return \in_array(EntityFile::FLAG_PRE_PROCESS, $flags, true); } protected function has_flag_minified(array $flags) : bool { - return in_array(EntityFile::FLAG_MINIFY, $flags, true); + return \in_array(EntityFile::FLAG_MINIFY, $flags, true); } protected function has_flag_gzipped(array $flags) : bool { - return in_array(EntityFile::FLAG_GZIP, $flags, true); + return \in_array(EntityFile::FLAG_GZIP, $flags, true); } protected function get_path_output(): string { - return $this->config_get(self::CONFIG_KEY_DIR_OUTPUT); + return $this->config_yaml_get(PATHS::DIRECTORY_OUTPUT); } abstract protected function handle_step_processed(EntityFile $file, string $output_file_path) : ?EntityFile; + + protected function pre_work(): void { + + } + + protected function post_work(): void { + + } } diff --git a/libraries/php/BuildProcess/Abstractions/BuildSection.php b/libraries/php/BuildProcess/Abstractions/BuildSection.php index 891db4b42..542ced133 100644 --- a/libraries/php/BuildProcess/Abstractions/BuildSection.php +++ b/libraries/php/BuildProcess/Abstractions/BuildSection.php @@ -1,39 +1,45 @@ -service_get_logger()); + $this->code_builder = $code_builder; } - protected function get_repo(string $repo_name): ObjectRepository { + /** + * @param string $repo_name + * @return ObjectRepository + */ + public function get_repo(string $repo_name): ObjectRepository { return $this->code_builder->get_repo($repo_name); } - protected function pre_work(): void {} - - abstract protected function perform_work(): void; - - protected function post_work(): void {} - protected function process_entity(EntityInterface $entity): ?EntityInterface { if ($entity->cache_needs_update(true)) { $entity->set_state(EntityState::STATE_UPDATED); @@ -45,4 +51,12 @@ protected function process_entity(EntityInterface $entity): ?EntityInterface { } abstract protected function on_entity_update(EntityInterface $entity); + + /** + * @param string $key + * @return mixed + */ + public function config_universal_get(string $key) { + return $this->code_builder->config_universal_get($key); + } } \ No newline at end of file diff --git a/libraries/php/BuildProcess/Abstractions/UnitOfWork.php b/libraries/php/BuildProcess/Abstractions/UnitOfWork.php index ea1ce8ac9..f854053d7 100644 --- a/libraries/php/BuildProcess/Abstractions/UnitOfWork.php +++ b/libraries/php/BuildProcess/Abstractions/UnitOfWork.php @@ -1,45 +1,73 @@ -service_set_logger($logger); $this->set_name_and_label($name, 'Step'); $this->init_trait_timer(false); - $this->code_builder = $code_builder; } public function run_unit_of_work(): void { - $this->code_builder->log('--- ' . $this->name . ' Start ---'); + $this->header($this->name); $this->timer->start(); $this->pre_work(); $this->perform_work(); $this->post_work(); $this->timer->stop(); if ($this->failed()) { - $this->code_builder->log('--- ' . $this->name . ' failed in {' . $this->timer->get_delta() . '}---'); + $this->log('--- ' . $this->name . ' failed in {' . $this->timer->get_delta() . '}---'); + $this->header(STR::brackets($this->name . ' failed in ', $this->timer->get_delta())); + $this->print_header(self::HEADER_FAILED); # TODO: stop the rest of the build! } else { - $this->code_builder->log('--- ' . $this->name . ' completed in {' . $this->timer->get_delta() . '}---'); + $this->log('--- ' . $this->name . ' completed in {' . $this->timer->get_delta() . '}---'); + $this->header(STR::brackets($this->name . ' completed in ', $this->timer->get_delta())); } } + /** + * @param string $result + */ + private function print_header(string $result): void { + $this->header(STR::brackets($this->name . ' ' . $result . ' in ', $this->timer->get_delta())); + } + protected function mark_as_failed(): void { $this->step_failed = true; } + /** + * @return bool + */ protected function failed(): bool { return $this->step_failed; } diff --git a/libraries/php/BuildProcess/CSSBuildSection.php b/libraries/php/BuildProcess/CSSBuildSection.php index 9d2025ff0..efb6bc1c2 100644 --- a/libraries/php/BuildProcess/CSSBuildSection.php +++ b/libraries/php/BuildProcess/CSSBuildSection.php @@ -1,16 +1,19 @@ -cmd_schema_update = $code_builder->get_command(PreparedCommand::CMD_DB_SCHEMA_UPDATE); - $this->cmd_schema_validate = $code_builder->get_command(PreparedCommand::CMD_DB_SCHEMA_VALIDATE); - } - - protected function perform_work(): void { - $this->run_cmd_wrapped([$this, 'run_schema_validate']); - if (!$this->cmd_schema_validate->is_healthy_mapping()) { - $this->log('Entity mapping is not healthy!'); - $this->mark_as_failed(); - } - if (!$this->cmd_schema_validate->is_healthy_schema()) { - $this->log('Updating the DB Schema!'); - $this->run_cmd_wrapped([$this, 'run_schema_update']); - - if ($this->cmd_schema_update->did_db_schema_update()) { - $this->code_builder->get_current_code_build()->setDbSchemaUpdated(true); - } - } - } - - protected function pre_work(): void {} - protected function post_work(): void {} - - private function run_schema_validate(): void { - $this->cmd_schema_validate->run_command(); - } - - private function run_schema_update(): void { - $this->cmd_schema_update->run_command(); - } - - private function run_cmd_wrapped(callable $cmd): void { - try { - $cmd(); - } catch (Exception $e) { - $this->mark_as_failed(); - $this->log('Exception{' . $e->getMessage() . '}'); - } - } - - private function log($contents): void { - $this->code_builder->log($contents); - } -} - diff --git a/libraries/php/BuildProcess/HTMLBuildSection.php b/libraries/php/BuildProcess/HTMLBuildSection.php index 77a179027..44f115860 100644 --- a/libraries/php/BuildProcess/HTMLBuildSection.php +++ b/libraries/php/BuildProcess/HTMLBuildSection.php @@ -1,11 +1,13 @@ -web_manifest_default = 'data:application/manifest+json,' . json_encode(self::RAW_WEB_MANIFEST); } @@ -61,11 +63,11 @@ protected function handle_step_processed(EntityFile $file, string $output_file_p $file_path = $file->getFullPath(); $processed_lines = []; - $lines = UFO::get_as_list($file_path); + $lines = UFO::get($file_path); foreach ($lines as $line) { - if (STR::contains($line, self::PATTERN_CSS)) { + if (STR::has($line, self::PATTERN_CSS)) { $this->process_line_css($line, $processed_lines); - } else if (STR::contains($line, self::PATTERN_MANIFEST)) { + } else if (STR::has($line, self::PATTERN_MANIFEST)) { $this->process_line_manifest($line, $processed_lines); } else { $processed_lines[] = $line; @@ -73,17 +75,17 @@ protected function handle_step_processed(EntityFile $file, string $output_file_p } $path_processed = $this->get_path_output() . $file->get_full_name_processed(); - UFO::create_or_overwrite_file($path_processed, $processed_lines); + UFO::set($path_processed, $processed_lines); return $this->repo_entity_files->ensure_file_has_child($file, $path_processed, EntityFile::FLAG_PRE_PROCESS); } private function process_line_css(string $line, array & $processed_lines): void { - $css_file_name = STR::get_matches_removed(trim($line), self::PATTERN_SUB_CSS_FILE_NAME); + $css_file_name = STR::remove(trim($line), self::PATTERN_SUB_CSS_FILE_NAME); #if (!$this->repo_entity_files->has_checked_file_by_path($css_file_name)) { # DBG::throw_exception('Needed pre-process file not found in memory {' . $css_file_name . '}'); #} - $modified_line = STR::get_matches_removed($line, self::PATTERN_SUB_CSS_FILE_LINE); - $processed_lines[] = STR::replace($modified_line, $css_file_name, UFO::get_css_minified_contents($css_file_name)); + $modified_line = STR::remove($line, self::PATTERN_SUB_CSS_FILE_LINE); + $processed_lines[] = STR::replace($modified_line, $css_file_name, CSS::get($css_file_name)); } private function process_line_manifest(string $line, array & $processed_lines): void { diff --git a/libraries/php/BuildProcess/JSONBuildSection.php b/libraries/php/BuildProcess/JSONBuildSection.php index 33ac8e8f2..1db3ea49b 100644 --- a/libraries/php/BuildProcess/JSONBuildSection.php +++ b/libraries/php/BuildProcess/JSONBuildSection.php @@ -1,16 +1,16 @@ -config_initialize( ['npm' => null], - $code_builder->config_get() + $code_builder->config_yaml_get_all() ); $this->repo = $this->get_repo(EntityNPMLibRepository::class); } protected function perform_work(): void { - foreach ($this->config_get() as $file_value) { + foreach ($this->config_yaml_get_all() as $file_value) { if (!$this->repo->has_entity($file_value)) { $this->repo->create_new_entity($file_value); } else { diff --git a/libraries/php/BuildProcess/QAReportBuildSection.php b/libraries/php/BuildProcess/QAReportBuildSection.php index 830b93745..ad8fb7192 100644 --- a/libraries/php/BuildProcess/QAReportBuildSection.php +++ b/libraries/php/BuildProcess/QAReportBuildSection.php @@ -1,12 +1,12 @@ -config_initialize( ['stats' => ['unit_tests' => null]], - $code_builder->config_get('qa_report') + $code_builder->config_yaml_get('qa_report') ); $this->repo_entity_files = $this->get_repo(EntityFileRepository::class); $this->repo = $this->get_repo(EntityQAReportRepository::class); } protected function perform_work() : void { - foreach ($this->config_get('stats') as $stat => $file_path) { + foreach ($this->config_yaml_get('stats') as $stat => $file_path) { if (!$this->repo_entity_files->has_entity($file_path)) { $this->event_qa_entity_file_not_stored_in_db($file_path); } else { diff --git a/libraries/php/DataStructure/CacheTable/CacheTableInterface.php b/libraries/php/DataStructure/CacheTable/CacheTableInterface.php new file mode 100644 index 000000000..8d71ad688 --- /dev/null +++ b/libraries/php/DataStructure/CacheTable/CacheTableInterface.php @@ -0,0 +1,26 @@ +cache_has($key)) { + $this->cache_set($key); + } + return $this->cache_table[$key]; + } + + /** + * @param string $key + */ + public function cache_set(string $key): void { + $this->cache_table[$key] = $this->cache_calculate($key); + } + + /** + * @param string $key + * @return bool + */ + public function cache_has(string $key): bool { + return array_key_exists($key, $this->cache_table); + } +} diff --git a/libraries/php/DataStructure/FlagTable/TraitFlagsTable.php b/libraries/php/DataStructure/FlagTable/TraitFlagsTable.php new file mode 100644 index 000000000..463e254b3 --- /dev/null +++ b/libraries/php/DataStructure/FlagTable/TraitFlagsTable.php @@ -0,0 +1,94 @@ +table_flags[$flag]; + } + + /** + * @param string $flag + * @return bool + */ + public function flag_is_off(string $flag): bool { + return !$this->table_flags[$flag]; + } + + /** + * @param string $flag + * @param bool $value + */ + public function flag_set(string $flag, bool $value): void { + $this->table_flags[$flag] = $value; + } + + /** + * @param string $flag + */ + public function flag_set_on(string $flag): void { + $this->table_flags[$flag] = true; + } + + /** + * @param string $flag + */ + public function flag_set_off(string $flag): void { + $this->table_flags[$flag] = false; + } + + /** + * @param array $flags_and_values + */ + public function flags_set(array $flags_and_values): void { + foreach ($flags_and_values as $flag => $value) { + $this->table_flags[$flag] = $value; + } + } + + /** + * @param string $flag + * @return bool + */ + public function flag_get(string $flag): bool { + return $this->table_flags[$flag]; + } + + /** + * @param string $flag + * @return bool + */ + public function flag_exists(string $flag): bool { + return array_key_exists($flag, $this->table_flags); + } + + /** + * @param string $flag + * @return bool + */ + public function flag_exists_as_on(string $flag): bool { + return array_key_exists($flag, $this->table_flags) && $this->table_flags[$flag]; + } + + /** + * @param string $flag + * @return bool + */ + public function flag_exists_as_off(string $flag): bool { + return array_key_exists($flag, $this->table_flags) && !$this->table_flags[$flag]; + } +} diff --git a/libraries/php/DataStructures/Cached.php b/libraries/php/DataStructures/Cached.php deleted file mode 100644 index 32b1d0de2..000000000 --- a/libraries/php/DataStructures/Cached.php +++ /dev/null @@ -1,8 +0,0 @@ -cached_values)) { - $this->cache_set($key); - } - return $this->cached_values[$key]; - } -} diff --git a/libraries/php/Enum/EnumFileCategory.php b/libraries/php/Enum/EnumFileCategory.php new file mode 100644 index 000000000..8d45ad265 --- /dev/null +++ b/libraries/php/Enum/EnumFileCategory.php @@ -0,0 +1,14 @@ + CATEGORY::ASSET, + self::HTML => CATEGORY::ASSET, + self::YAML => CATEGORY::CONFIG, + self::LICENSE => CATEGORY::LICENSE, + self::READ_ME => CATEGORY::README, + self::JS => CATEGORY::CODE, + self::PHP => CATEGORY::CODE, + self::C => CATEGORY::CODE, + self::HEADER => CATEGORY::CODE, + self::C_PLUS_PLUS => CATEGORY::CODE, + self::SHADER_FRAGMENT => CATEGORY::ASSET, + self::SHADER_VERTEX => CATEGORY::ASSET + ]; +} diff --git a/libraries/php/Enum/EnumFileTypeExtensions.php b/libraries/php/Enum/EnumFileTypeExtensions.php new file mode 100644 index 000000000..f4c17e619 --- /dev/null +++ b/libraries/php/Enum/EnumFileTypeExtensions.php @@ -0,0 +1,38 @@ + TYPE::JS, + self::C => TYPE::C, + self::CPP => TYPE::C_PLUS_PLUS, + self::HEADER => TYPE::HEADER, + self::WEB_MANIFEST => TYPE::WEB_MANIFEST, + self::YAML => TYPE::YAML, + self::SHADER_FRAGMENT => TYPE::SHADER_FRAGMENT, + self::SHADER_VERTEX => TYPE::SHADER_VERTEX, + self::JSON => TYPE::JSON, + self::CSS => TYPE::CSS, + self::XML => TYPE::XML, + self::HTML => TYPE::HTML + ]; +} diff --git a/libraries/php/Finance/Binance/BinanceAPI.php b/libraries/php/Finance/Binance/BinanceAPI.php index 5550ee100..0fc8a463b 100644 --- a/libraries/php/Finance/Binance/BinanceAPI.php +++ b/libraries/php/Finance/Binance/BinanceAPI.php @@ -1,9 +1,9 @@ -config_initialize(['binance' => ['dd' => ['api_key' => null, 'api_secret' => null]]], UFO::get_yaml($path_configs)); - $this->api_key = $this->config_get(['binance', 'dd', KEYS::API]); - $this->api_secret = $this->config_get(['binance', 'dd', KEYS::SECRET]); + #$this->config_initialize(['binance' => ['dd' => ['api_key' => null, 'api_secret' => null]]], UFO::get_yaml($path_configs)); + $this->config_initialize(['binance' => ['dd' => ['api_key' => null, 'api_secret' => null]]], YAML::get($path_configs)); + $this->api_key = $this->config_yaml_get(['binance', 'dd', KEYS::API]); + $this->api_secret = $this->config_yaml_get(['binance', 'dd', KEYS::SECRET]); // TODO: Don't create the objects until they are needed. $this->request_ping = new BinancePing(); diff --git a/libraries/php/Finance/Binance/BinanceAccountAPI.php b/libraries/php/Finance/Binance/BinanceAccountAPI.php index bfbac1131..9f76ff8ea 100644 --- a/libraries/php/Finance/Binance/BinanceAccountAPI.php +++ b/libraries/php/Finance/Binance/BinanceAccountAPI.php @@ -1,18 +1,16 @@ -request_account = new BinanceAccount($this->api_key, $this->api_secret); $this->request_account_trades = new BinanceAccountTradeHistory($this->api_key, $this->api_secret); $this->request_account_open_orders = new BinanceAccountOpenOrders($this->api_key, $this->api_secret); $this->request_account_all_orders = new BinanceAccountAllOrders($this->api_key, $this->api_secret); - $this->request_test_buy = new BinanceBuyTest($this->api_key, $this->api_secret); - $this->request_test_sell = new BinanceSellTest($this->api_key, $this->api_secret); $this->request_sell = new BinanceSell($this->api_key, $this->api_secret); $this->request_buy = new BinanceBuy($this->api_key, $this->api_secret); + $this->request_cancel_order = new BinanceCancelOrder($this->api_key, $this->api_secret); + } + + public function calculate_net_result(string $ticker): void { + #$orders = $this->account_open_orders($ticker); + $trades = $this->account_trade_history($ticker); + // TEMP + $ratio_from = COINS::IOTA; + $ratio_to = COINS::BTC; + $balances = [ + COINS::IOTA => 0, + COINS::BTC => 0, + COINS::BNB => 0, + ]; + $order_mappings = [ + [98090971, 98098576], + [98439791, 98447595, 98466851, 98473001], + ]; + foreach ($trades as $trade) { + $commission_coin = $trade['commissionAsset']; + $commission = (float) $trade['commission']; + $quantity = (float) $trade['qty']; + $price = (float) $trade['price']; + $order_id = (int) $trade['orderId']; + $is_buy = $trade['isBuyer']; + $magnitude = $price * $quantity; + if (in_array($order_id, $order_mappings[0])) { + if (!$is_buy) { + $balances[COINS::IOTA] -= $quantity; + $balances[COINS::BTC] += $magnitude; + } else { + $balances[COINS::IOTA] += $quantity; + $balances[COINS::BTC] -= $magnitude; + } + $balances[$commission_coin] -= $commission; + } + } + var_dump('----------- Transaction 0 -----------'); + $sum1 = 0.0; + foreach ($balances as $coin => $amount) { + $usd = ''; + if ($coin === COINS::BTC) { + $usd = $amount * 8782.17; + } else if ($coin === COINS::IOTA) { + $usd = $amount * 0.42; + } else if ($coin === COINS::BNB) { + $usd = $amount * 33.97; + } + $sum1 += $usd; + $amount_pretty = MATH::formatted($amount, 8); + $usd_pretty = MATH::formatted($usd, 8); + var_dump('Coin{' . $coin . '} --> {' . $amount_pretty . '}, or {$' . $usd_pretty . '}'); + } + var_dump('NET USD RESULT {$' . MATH::formatted($sum1, 8) . '}'); + var_dump(PHP_EOL); } public function print_balance(): void { @@ -68,19 +120,8 @@ public function print_balance(): void { var_dump(PHP_EOL); } - public function test_buy(string $ticker): bool { - $this->request_test_buy->param_set_symbol($ticker); - $this->request_test_buy->param_set_order_type(ORDER_TYPES::LIMIT); - $this->request_test_buy->param_set_order_time_in_force(TIME_IN_FORCE::GTC); - $this->request_test_buy->param_set_order_quantity(100); - $this->request_test_buy->param_set_order_price('0.00009000'); - return $this->request_test_buy->execute(); - } - public function buy(string $ticker, int $quantity, string $price): array { $this->request_buy->param_set_symbol($ticker); - $this->request_buy->param_set_order_type(ORDER_TYPES::LIMIT); - $this->request_buy->param_set_order_time_in_force(TIME_IN_FORCE::GTC); $this->request_buy->param_set_order_quantity($quantity); $this->request_buy->param_set_order_price($price); return $this->request_buy->execute(); @@ -88,22 +129,11 @@ public function buy(string $ticker, int $quantity, string $price): array { public function sell(string $ticker, int $quantity, string $price): array { $this->request_sell->param_set_symbol($ticker); - $this->request_sell->param_set_order_type(ORDER_TYPES::LIMIT); - $this->request_sell->param_set_order_time_in_force(TIME_IN_FORCE::GTC); $this->request_sell->param_set_order_quantity($quantity); $this->request_sell->param_set_order_price($price); return $this->request_sell->execute(); } - public function test_sell(string $ticker, int $quantity, string $price): bool { - $this->request_test_sell->param_set_symbol($ticker); - $this->request_test_sell->param_set_order_type(ORDER_TYPES::LIMIT); - $this->request_test_sell->param_set_order_time_in_force(TIME_IN_FORCE::GTC); - $this->request_test_sell->param_set_order_quantity($quantity); - $this->request_test_sell->param_set_order_price($price); - return $this->request_test_sell->execute(); - } - public function account(): array { return $this->request_account->execute(); } @@ -116,7 +146,9 @@ public function account_trade_history(string $ticker): array { } public function account_all_orders(string $ticker): array { - $this->request_account_all_orders->param_set_start_order_id(98090971); + if ($ticker === 'IOTABTC') { + $this->request_account_all_orders->param_set_start_order_id(98090971); + } $this->request_account_all_orders->param_set_limit(16); $this->request_account_all_orders->param_set_symbol($ticker); return $this->request_account_all_orders->execute(); @@ -127,4 +159,10 @@ public function account_open_orders(string $ticker): array { return $this->request_account_open_orders->execute(); } + public function account_cancel_order(string $ticker, $orderID): array { + $this->request_cancel_order->param_set_symbol($ticker); + $this->request_cancel_order->param_set_order_id($orderID); + return $this->request_cancel_order->execute(); + } + } diff --git a/libraries/php/Finance/Binance/Enum/BinanceEnumAPIKeys.php b/libraries/php/Finance/Binance/Enum/BinanceEnumAPIKeys.php index 24527a83d..0b7af650a 100644 --- a/libraries/php/Finance/Binance/Enum/BinanceEnumAPIKeys.php +++ b/libraries/php/Finance/Binance/Enum/BinanceEnumAPIKeys.php @@ -1,4 +1,4 @@ - $v) { - if (array_key_exists($k, $config)) { - $this->config_data[$k] = $config[$k]; - } else { - DBG::throw_exception_config_file($k); - } - - if (is_array($v)) { - $this->config_verify_sub_layer($v, $config[$k]); - } - } - } - - /** - * @param array $keys - * @param array $layer - * @throws ExceptionInvalidConfigurationFile - */ - public function config_verify_sub_layer(array $keys, array $layer): void { - foreach ($keys as $k => $v) { - if (!array_key_exists($k, $layer)) { - DBG::throw_exception_config_file($k); - } - if (is_array($v)) { - $this->config_verify_sub_layer($v, $layer[$k]); - } - } - } - - /** - * @param null $keys - * @return mixed - */ - public function config_get($keys=null) { - if ($keys === null) { - return $this->config_data; - } - if (is_string($keys)) { - return $this->config_data[$keys]; - } - $current = $this->config_data; - foreach ($keys as $k) { - $current = $current[$k]; - } - return $current; - } - - # TODO: - #public function config_get_leaf(string $key) { - #} - -} diff --git a/libraries/php/Traits/TraitPatternName.php b/libraries/php/Traits/TraitPatternName.php index e4d9fdbaa..9b7186b95 100644 --- a/libraries/php/Traits/TraitPatternName.php +++ b/libraries/php/Traits/TraitPatternName.php @@ -1,4 +1,4 @@ - */ + /** @var string [A basic string name commonly needed across maybe different types of classes. ]*/ protected $name; - /** @var string < Utility variable to set a label (often the Class name) for printing format such as LABEL{NAME}. > */ + + /** @var string [Utility variable to set a label (often the Class name) for printing format such as LABEL{NAME}.]*/ protected $label; /** diff --git a/libraries/php/Traits/TraitPatternTimer.php b/libraries/php/Traits/TraitPatternTimer.php index 23091f1e8..9b7fd718a 100644 --- a/libraries/php/Traits/TraitPatternTimer.php +++ b/libraries/php/Traits/TraitPatternTimer.php @@ -1,4 +1,4 @@ -parent !== null; } + /** + * @param $parent + * @param bool $raise_exception_if_parent_exists + * @throws LogicException + */ public function set_parent($parent, bool $raise_exception_if_parent_exists=true): void { if ($raise_exception_if_parent_exists && ($this->parent !== null && $parent !== $this->parent)) { - DBG::throw_exception('Can not set parent when current parent is not null!'); + throw LogicException::invalid_function_call('set_parent', 'Can not set parent when current parent is not null!'); } $this->parent = $parent; if (!$this->parent->has_child($this)) { diff --git a/libraries/php/Traits/pattern_parent_child/TraitPatternParent.php b/libraries/php/Traits/pattern_parent_child/TraitPatternParent.php index 6638bcfa6..054e9e4ef 100644 --- a/libraries/php/Traits/pattern_parent_child/TraitPatternParent.php +++ b/libraries/php/Traits/pattern_parent_child/TraitPatternParent.php @@ -1,4 +1,4 @@ -has_child($child)) { - DBG::throw_exception('Can not add child to parent when it already exists!'); + throw LogicException::invalid_function_call('add_child', 'Can not add child to parent when it already exists!'); } $this->children[] = $child; if (!$child->has_parent()) { diff --git a/libraries/php/Traits/pattern_parent_child/TraitPatternParentAndChild.php b/libraries/php/Traits/pattern_parent_child/TraitPatternParentAndChild.php index 5a010974d..116f69f03 100644 --- a/libraries/php/Traits/pattern_parent_child/TraitPatternParentAndChild.php +++ b/libraries/php/Traits/pattern_parent_child/TraitPatternParentAndChild.php @@ -1,4 +1,4 @@ -raw_line, $text); + return STR::has($this->raw_line, $text); } public function get_line_number(): int { diff --git a/libraries/php/code_abstractions/code_abstractions/code_segments/CodeSegment.php b/libraries/php/code_abstractions/code_abstractions/code_segments/CodeSegment.php index bc95c14b6..5d2304324 100644 --- a/libraries/php/code_abstractions/code_abstractions/code_segments/CodeSegment.php +++ b/libraries/php/code_abstractions/code_abstractions/code_segments/CodeSegment.php @@ -1,4 +1,4 @@ -get_path_full(), $path); + private function contains_directory_path(string $path): bool { + return STR::has($this->get_path_full(), $path); } - public function get_local_files_of_type($file_type) : array { + public function get_local_files_of_type($file_type): array { $files = []; foreach ($this->children as $child) { if ($child->is_file() && get_class($child) === $file_type) { @@ -70,8 +72,9 @@ public function get_file(string $path) : ?FileInstance { $path = DIRECTORY_SEPARATOR . $path; } $p = UPO::get_directory($path); - $f = STR::get_matches_removed($path, $p); + $f = STR::remove($path, $p); + /** @var DirectoryInstance $child */ foreach ($this->children as $child) { if (!$child->is_file() && $child->contains_directory_path($p)) { $child->load_cache(true); @@ -87,7 +90,7 @@ public function get_file(string $path) : ?FileInstance { private function find_file(string $path) { foreach ($this->children as $child) { - if ($child->is_file() && STR::contains($child->get_path_full(), $path)) { + if ($child->is_file() && STR::has($child->get_path_full(), $path)) { return $child; } } @@ -103,37 +106,18 @@ public function load_cache(bool $use_recursion=false): void { UDO::get_all_contents($path_full, $use_recursion, $path_files, $path_directories); foreach ($path_files as $path) { - $p = STR::get_matches_removed($path, $path_full); - if (!STR::contains($p, DIRECTORY_SEPARATOR)) { - $this->add_file_from_path(STR::get_matches_removed($path, $path_full)); + $p = STR::remove($path, $path_full); + if (!STR::has($p, DIRECTORY_SEPARATOR)) { + $this->add_file_from_path(STR::remove($path, $path_full)); } } foreach ($path_directories as $path) { - $directory = new DirectoryInstance(STR::get_matches_removed($path, $path_full), $this); + $directory = new DirectoryInstance(STR::remove($path, $path_full), $this); if ($use_recursion) { $directory->load_cache(true); } } } } - - public function is_cached() : bool { - return $this->cached; - } - - public function clean(): void - { - // TODO: Implement clean() method. - } - - public function is_cleanable(): bool - { - // TODO: Implement is_cleanable() method. - } - - public function is_clean(): ?bool - { - // TODO: Implement is_clean() method. - } } diff --git a/libraries/php/code_abstractions/file_abstractions/FileInstance.php b/libraries/php/code_abstractions/file_abstractions/FileInstance.php index a9f975d57..66eb57f7d 100644 --- a/libraries/php/code_abstractions/file_abstractions/FileInstance.php +++ b/libraries/php/code_abstractions/file_abstractions/FileInstance.php @@ -1,4 +1,4 @@ -loaded_lines) { - $this->file_lines = UFO::get_as_list($this->get_path_full()); + $this->file_lines = UFO::get($this->get_path_full()); $this->loaded_lines = true; } return $this->file_lines; diff --git a/libraries/php/code_abstractions/file_abstractions/FileText.php b/libraries/php/code_abstractions/file_abstractions/FileText.php index d913168c0..4341288fb 100644 --- a/libraries/php/code_abstractions/file_abstractions/FileText.php +++ b/libraries/php/code_abstractions/file_abstractions/FileText.php @@ -1,4 +1,4 @@ -get_path_full()); + return YAML::get($this->get_path_full()); } } diff --git a/libraries/php/code_abstractions/file_abstractions/discrete/docker/FileDockerCompose.php b/libraries/php/code_abstractions/file_abstractions/discrete/docker/FileDockerCompose.php index 7776deaca..3b9082c56 100644 --- a/libraries/php/code_abstractions/file_abstractions/discrete/docker/FileDockerCompose.php +++ b/libraries/php/code_abstractions/file_abstractions/discrete/docker/FileDockerCompose.php @@ -1,4 +1,4 @@ -get_path_full(), $file_text); + UFO::set($this->get_path_full(), $file_text); } public function clean(): void { diff --git a/libraries/php/code_abstractions/file_abstractions/discrete/docker/FileDockerIgnore.php b/libraries/php/code_abstractions/file_abstractions/discrete/docker/FileDockerIgnore.php index c73ff26f9..c38f16bda 100644 --- a/libraries/php/code_abstractions/file_abstractions/discrete/docker/FileDockerIgnore.php +++ b/libraries/php/code_abstractions/file_abstractions/discrete/docker/FileDockerIgnore.php @@ -1,4 +1,4 @@ -configs = FileManager::get_file_contents(self::PATH_BASE . 'quasar_source' . self::EXTENSION_YAML); - $this->services = FileManager::get_file_contents(self::PATH_BASE . 'services' . self::EXTENSION_YAML); - } - - public function get_secret(string $secret) : array { - return $this->configs['secrets'][$secret]; - } - -} - -abstract class DatabaseAbstraction implements DatabaseConnection { - - protected $db_host; - protected $db_name; - protected $db_username; - protected $db_password; - protected $db_connection; - - public function __construct(string $config_secret_key) { - $configs = new LocalConfigurations(); - $connection_configs = $configs->get_secret($config_secret_key); - $this->db_host = $connection_configs['host']; - $this->db_name = $connection_configs['database']; - $this->db_username = $connection_configs['username']; - $this->db_password = $connection_configs['password']; - } - - /** - * Connect to the database, raise exception on failed connection. - * - * @return void - */ - public function connect(): void { - $this->db_connection = $this->get_connection(); - } - - /** - * Terminate the connection to the database. - * - * @return void - */ - public function terminate(): void { - } - - abstract protected function get_connection(); - -} diff --git a/libraries/php/database_abstractions/DatabaseConnection.php b/libraries/php/database_abstractions/DatabaseConnection.php deleted file mode 100644 index fb10e15ac..000000000 --- a/libraries/php/database_abstractions/DatabaseConnection.php +++ /dev/null @@ -1,27 +0,0 @@ -db_host} dbname={$this->db_name} user={$this->db_username} password={$this->db_password}"); - if (!$this->db_connection) { - die('Could not connect: ' . pg_last_error()); - } - return $connection; - } - -} diff --git a/libraries/php/database_abstractions/postgres/PostgreSQLDoctrine.php b/libraries/php/database_abstractions/postgres/PostgreSQLDoctrine.php deleted file mode 100644 index 6227588ca..000000000 --- a/libraries/php/database_abstractions/postgres/PostgreSQLDoctrine.php +++ /dev/null @@ -1,36 +0,0 @@ - $this->db_name, - 'user' => $this->db_username, - 'password' => $this->db_password, - 'host' => $this->db_host, - 'driver' => 'pdo_pgsql' - ], - new Configuration() - ); - } catch (DBALException $e) { - return null; - } - } - -} diff --git a/libraries/php/deploy.php b/libraries/php/deploy.php index 2c4914857..10be66492 100644 --- a/libraries/php/deploy.php +++ b/libraries/php/deploy.php @@ -1,4 +1,4 @@ -children[0]; parent::__construct($nodes->children[0]); $this->num_tests = (int) $raw_data->attributes['TESTS']; diff --git a/libraries/php/qa_abstractions/TestCaseResult.php b/libraries/php/qa_abstractions/TestCaseResult.php index c6c1589f6..f36eec1b2 100644 --- a/libraries/php/qa_abstractions/TestCaseResult.php +++ b/libraries/php/qa_abstractions/TestCaseResult.php @@ -1,10 +1,9 @@ -parent = $parent; - $this->name = STR::get_matches_removed($this->name, 'CodeManager\\Tests\\'); - $this->name = STR::get_matches_removed($this->name, 'Command\\'); - $this->name = STR::get_matches_removed($this->name, 'CodeManager\\Traits\\'); + $this->name = STR::remove($this->name, 'CodeManager\\Tests\\'); + $this->name = STR::remove($this->name, 'Command\\'); + $this->name = STR::remove($this->name, 'CodeManager\\Traits\\'); $this->file = $raw_data->attributes['FILE'] ?? null; $this->parent->add_test_suite($this); foreach ($raw_data->children as $child) { diff --git a/libraries/php/universal_utilities/ArrayUtilities.php b/libraries/php/universal_utilities/ArrayUtilities.php index 702ed826f..b585268a8 100644 --- a/libraries/php/universal_utilities/ArrayUtilities.php +++ b/libraries/php/universal_utilities/ArrayUtilities.php @@ -1,4 +1,4 @@ - $max) { + $max = $num; + } + } + return $max; + } + /** * Remove the first n elements from the provided array. * - * @param array $array < The array to remove elements from. > - * @param int $number_to_remove < The number of elements to be removed from the start of the array. > + * @param array $array [The array to remove elements from. ] + * @param int $number_to_remove [The number of elements to be removed from the start of the array.] */ public static function remove_first_n(array & $array, int $number_to_remove): void { if ($number_to_remove <= 0 || !isset($array)) { @@ -30,9 +61,9 @@ public static function remove_first_n(array & $array, int $number_to_remove): vo /** * Returns a boolean indicating if two arrays comprised of strings have the same elements (but not necessarily in the same order). * - * @param array $a0 < The first array to compare to. > - * @param array $a1 < The second array to compare to. > - * @return bool < True if both arrays have the same values, order does not matter. > + * @param array $a0 [The first array to compare to. ] + * @param array $a1 [The second array to compare to. ] + * @return bool [True if both arrays have the same values, order does not matter.] */ public static function string_arrays_have_same_values(array $a0, array $a1): bool { /** @noinspection TypeUnsafeComparisonInspection */ diff --git a/libraries/php/universal_utilities/CryptographyUtilities.php b/libraries/php/universal_utilities/CryptographyUtilities.php index 25e86b6e3..53e21cdad 100644 --- a/libraries/php/universal_utilities/CryptographyUtilities.php +++ b/libraries/php/universal_utilities/CryptographyUtilities.php @@ -1,8 +1,11 @@ - + * @param bool $use_recursion < If set to true, any sub-directories will be recursively traversed. > + * @param array $all_files < A provided array to insert file paths into. > + * @param array $all_directories < A provided array to insert directory paths into. > + * @throws Exception + */ + public static function get_all_contents(string $path_directory, bool $use_recursion, array & $all_files, array & $all_directories): void { + // TODO: Check if links should be checked + ignored. + + self::is_valid($path_directory); + $files = scandir($path_directory, SCANDIR_SORT_NONE); + if (!STR::ends_with($path_directory, DIRECTORY_SEPARATOR)) { + $path_directory .= DIRECTORY_SEPARATOR; + } + foreach ($files as $key => $value) { + if ($value !== '.' && $value !== '..') { + $path = realpath($path_directory . $value); + if (!is_dir($path)) { + $all_files[] = $path; + } else { + $all_directories[] = $path; + if ($use_recursion) { + self::get_all_contents($path, $use_recursion,$all_files, $all_directories); + } + } + } + } + } + +} diff --git a/libraries/php/universal_utilities/File/Discrete/CSSUtilities.php b/libraries/php/universal_utilities/File/Discrete/CSSUtilities.php new file mode 100644 index 000000000..c332f8f3a --- /dev/null +++ b/libraries/php/universal_utilities/File/Discrete/CSSUtilities.php @@ -0,0 +1,53 @@ +getMessage()); + } + } + + /** + * @param string $path + * @return string + */ + public static function get(string $path): string { + $contents = UFO::get($path); + $num_lines = count($contents); + if ($num_lines > 1) { + throw LogicException::invalid_function_call('get', 'File{' . $path . '} has more than 1 line of code!'); + } + if ($num_lines === 0) { + throw LogicException::invalid_function_call('get', 'File{' . $path . '} has no contents!'); + } + return $contents[0]; + } + +} diff --git a/libraries/php/universal_utilities/File/Discrete/HTMLUtilities.php b/libraries/php/universal_utilities/File/Discrete/HTMLUtilities.php new file mode 100644 index 000000000..a36a84979 --- /dev/null +++ b/libraries/php/universal_utilities/File/Discrete/HTMLUtilities.php @@ -0,0 +1,34 @@ +getMessage()); + } + } + +} diff --git a/libraries/php/universal_utilities/File/Discrete/JSONUtilities.php b/libraries/php/universal_utilities/File/Discrete/JSONUtilities.php new file mode 100644 index 000000000..5ad6ccf8f --- /dev/null +++ b/libraries/php/universal_utilities/File/Discrete/JSONUtilities.php @@ -0,0 +1,36 @@ +getMessage()); + } + } +} diff --git a/libraries/php/universal_utilities/files/XMLElement.php b/libraries/php/universal_utilities/File/Discrete/XMLElement.php similarity index 57% rename from libraries/php/universal_utilities/files/XMLElement.php rename to libraries/php/universal_utilities/File/Discrete/XMLElement.php index 71d134608..85a45f4fb 100644 --- a/libraries/php/universal_utilities/files/XMLElement.php +++ b/libraries/php/universal_utilities/File/Discrete/XMLElement.php @@ -1,7 +1,11 @@ -name = $tag['tag']; + if (isset($tag['attributes'])) { + $elements[$index]->attributes = $tag['attributes']; + } + if (isset($tag['value'])) { + $elements[$index]->content = $tag['value']; + } + if ($tag_type_is_open) { // push + $elements[$index]->children = []; + $stack[count($stack)] = &$elements; + $elements = &$elements[$index]->children; + } + } + if ($tag_type === 'close') { // pop + $elements = &$stack[count($stack) - 1]; + unset($stack[count($stack) - 1]); + } + } + + return $elements[0]; // the single top-level element + } catch (Exception $e) { + throw self::exception('parse_xml_contents', $e->getMessage()); + } + } +} diff --git a/libraries/php/universal_utilities/File/Discrete/YAMLUtilities.php b/libraries/php/universal_utilities/File/Discrete/YAMLUtilities.php new file mode 100644 index 000000000..ebec6c1e3 --- /dev/null +++ b/libraries/php/universal_utilities/File/Discrete/YAMLUtilities.php @@ -0,0 +1,37 @@ +getMessage()); + } + } +} diff --git a/libraries/php/universal_utilities/File/FileUtilities.php b/libraries/php/universal_utilities/File/FileUtilities.php new file mode 100644 index 000000000..428e2e7b3 --- /dev/null +++ b/libraries/php/universal_utilities/File/FileUtilities.php @@ -0,0 +1,176 @@ +getMessage()); + } + } + + /** + * Return the sha512sum of a file as a string hex number. + * + * @param string $path [The path to the file to get a hash value for.] + * @return string [Hex digits. ] + * @throws ExceptionSystem + */ + public static function get_sha512sum(string $path): string { + try { + self::is_valid($path); + return HASH::get_file_hash($path, HASH::SHA512SUM); + } catch (Exception $e) { + throw self::exception('get_sha512sum', $e->getMessage()); + } + } + + /** + * Return the size (in bytes) of the file provided. + * + * @param string $path [The path to the file to get size of.] + * @return int [The number of bytes used by file. ] + * @throws ExceptionSystem + */ + public static function get_size(string $path): int { + try { + self::is_valid($path); + return filesize($path); + } catch (Exception $e) { + throw self::exception('get_size', $e->getMessage()); + } + } + + /** + * Take the contents of the provided file and create a gzipped version at provided output path. + * + * @param string $path_base [The path to the file to get contents of.] + * @param string $path_output [The path to create a gzipped file at. ] + * @throws ExceptionSystem + */ + public static function gzip(string $path_base, string $path_output): void { + try { + self::is_valid($path_base); + RUN::gzip_file_to($path_base, $path_output); + } catch (Exception $e) { + throw self::exception('gzip', $e->getMessage()); + } + } + + /** + * @param string $path + * @throws ExceptionSystem + */ + public static function delete(string $path): void { + try { + if (self::is_valid($path)) { + unlink($path); + } + } catch (Exception $e) { + throw self::exception('delete', $e->getMessage()); + } + } + + /** + * @param string $path + * @param mixed $contents + * @throws ExceptionSystem + */ + public static function set(string $path, $contents): void { + try { + self::is_valid($path); + #file_put_contents($path, $contents, LOCK_EX); + $f = fopen($path, 'wb'); + if (is_array($contents)) { + $contents = implode($contents); + } + fwrite($f, $contents); + fclose($f); + } catch (Exception $e) { + throw self::exception('set', $e->getMessage()); + } + } + + /** + * @param string $path + * @return array + * @throws ExceptionSystem + */ + public static function get(string $path): array { + try { + self::is_valid($path); + $file_lines = []; + $lines = file($path); + foreach ($lines as $line) { + $file_lines[] = $line; + } + return $file_lines; + } catch (Exception $e) { + throw self::exception('get', $e->getMessage()); + } + } + + /** + * @param string $function_name + * @param $data + * @return ExceptionSystem + */ + protected static function exception(string $function_name, $data): ExceptionSystem { + return ExceptionSystem::file_exception($function_name, $data); + } + +} + diff --git a/libraries/php/universal_utilities/File/PathUtilities.php b/libraries/php/universal_utilities/File/PathUtilities.php new file mode 100644 index 000000000..ab6611d62 --- /dev/null +++ b/libraries/php/universal_utilities/File/PathUtilities.php @@ -0,0 +1,99 @@ + 1) { + $return_extensions = []; + for ($i = 1; $i < $num_extensions; $i++) { + $return_extensions[] = '.' . $extensions[$i]; + } + return $return_extensions; + } + return null; + } + + public static function get_ending_extension(string $path): string { + $extension = pathinfo($path, PATHINFO_EXTENSION); + if ($extension === null || $extension === '') { + return ''; + } + if ($extension === '.') { + return $extension; + } + return '.' . $extension; + } + +} diff --git a/libraries/php/universal_utilities/MathUtilities.php b/libraries/php/universal_utilities/MathUtilities.php index 840514b11..b74dc8ec1 100644 --- a/libraries/php/universal_utilities/MathUtilities.php +++ b/libraries/php/universal_utilities/MathUtilities.php @@ -1,26 +1,50 @@ - - * @param float $new < The ending number. > - * @param bool $get_as_string < If true, output will be a string. > + * @param float $base [The starting number. ] + * @param float $new [The ending number. ] + * @param bool $get_as_string [If true, output will be a string.] * @return float|string */ - public static function get_percentage_decreased(float $base, float $new, bool $get_as_string) { + public static function percentage_decreased(float $base, float $new, bool $get_as_string) { $percentage = ($base - $new) / $base; if ($get_as_string) { - return STR::formatted_number(100.0 * $percentage) . '%'; + return self::formatted_percentage(100 * $percentage); } return $percentage; } + /** + * @param $number + * @return string + */ + public static function formatted_percentage($number): string { + return self::formatted($number) . '%'; + } + + /** + * Returns the provided number as a string with a set number of decimal places. + * + * @param float|string $number [The number to format convert. ] + * @param int $number_of_decimals [The number of decimal places to display, defaults to 3.] + * @return string [A string format representation of the number provided. ] + */ + public static function formatted($number, int $number_of_decimals=3): string { + if (is_string($number)) { + $number = (float) $number; + } + return number_format($number, $number_of_decimals, '.', ''); + } + } diff --git a/libraries/php/universal_utilities/processes/ProcessRunner.php b/libraries/php/universal_utilities/Process/ProcessRunner.php similarity index 92% rename from libraries/php/universal_utilities/processes/ProcessRunner.php rename to libraries/php/universal_utilities/Process/ProcessRunner.php index acd1d8fe1..5061aa808 100644 --- a/libraries/php/universal_utilities/processes/ProcessRunner.php +++ b/libraries/php/universal_utilities/Process/ProcessRunner.php @@ -1,4 +1,4 @@ -parse_response($this->run_http_request()); } + /** + * @return string + * @throws ParameterException + */ protected function get_url(): string { switch ($this->request_type) { case self::REQUEST_TYPE_GET: @@ -74,9 +79,10 @@ protected function get_url(): string { return $this->name; case self::REQUEST_TYPE_POST: return $this->name; + case self::REQUEST_TYPE_DELETE: + return $this->name; default: - DBG::throw_exception('Invalid request type{' . $this->request_type . '}'); - return ''; + throw ParameterException::invalid_function_parameter('get_url', $this->request_type); } } @@ -109,20 +115,6 @@ protected function get_new_stream_context() { return stream_context_create($this->get_stream_context_settings()); } - /** - * @return bool - */ - protected function is_get(): bool { - return $this->request_type === self::REQUEST_TYPE_GET; - } - - /** - * @return bool - */ - protected function is_post(): bool { - return $this->request_type === self::REQUEST_TYPE_POST; - } - /*__ __ __ |__) /\ |__) /\ |\/| /__` | /~~\ | \ /~~\ | | .__/ */ @@ -140,7 +132,7 @@ protected function get_url_query(): string { * @return string */ protected function get_params_as_query(): string { - return STR::url_GET_params($this->params); + return http_build_query($this->params, '', '&'); } /** diff --git a/libraries/php/universal_utilities/RequestsHTTP/Binance/BinanceRequest.php b/libraries/php/universal_utilities/RequestsHTTP/Binance/BinanceRequest.php index 41d3eb2f1..944783801 100644 --- a/libraries/php/universal_utilities/RequestsHTTP/Binance/BinanceRequest.php +++ b/libraries/php/universal_utilities/RequestsHTTP/Binance/BinanceRequest.php @@ -1,4 +1,4 @@ -api_secret = $api_secret; $this->api_key = $api_key; } @@ -36,7 +36,7 @@ private function get_signature(string $text): string { protected function get_stream_context_settings(): array { $settings = parent::get_stream_context_settings(); $settings['http']['ignore_errors'] = true; - if ($this->is_post()) { + if ($this->request_type === self::REQUEST_TYPE_POST || $this->request_type === self::REQUEST_TYPE_DELETE) { $settings['http']['content'] = $this->secure_query_url; } return $settings; @@ -64,9 +64,9 @@ protected function get_url_query(): string { * @return mixed|void */ protected function parse_args($args = null) { - $this->param_set('timestamp', TIME::unix_timestamp()); + $this->param_set('timestamp', UNIX::now_as_string()); $this->process_args($args); - $query = $this->get_params_as_query(); + $query = $this->get_params_as_query(); $this->secure_query_url = $query . '&signature=' . $this->get_signature($query); } diff --git a/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Public/BinancePublicEndpoint.php b/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Public/BinancePublicEndpoint.php new file mode 100644 index 000000000..5ddb9f0d6 --- /dev/null +++ b/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Public/BinancePublicEndpoint.php @@ -0,0 +1,14 @@ +allowed_parameter_limit_values = [5, 10, 20, 50, 100, 500, 1000]; } } diff --git a/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Public/Data/BinancePrice.php b/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Public/Data/BinancePrice.php index 3b89fa82f..624dc3af0 100644 --- a/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Public/Data/BinancePrice.php +++ b/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Public/Data/BinancePrice.php @@ -1,20 +1,19 @@ -set_return_key('price'); } } diff --git a/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Public/Data/BinanceStatistics.php b/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Public/Data/BinanceStatistics.php index a2e2f6a6d..486a5a92d 100644 --- a/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Public/Data/BinanceStatistics.php +++ b/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Public/Data/BinanceStatistics.php @@ -1,19 +1,18 @@ -set_return_key('serverTime'); } } diff --git a/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Secure/Account/BinanceAccount.php b/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Secure/Account/BinanceAccount.php index daee44e00..2b14ee77d 100644 --- a/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Secure/Account/BinanceAccount.php +++ b/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Secure/Account/BinanceAccount.php @@ -1,4 +1,4 @@ -cache_the_response(); } } diff --git a/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Secure/Account/BinanceAccountAllOrders.php b/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Secure/Account/BinanceAccountAllOrders.php index 27add1aa5..fd7741049 100644 --- a/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Secure/Account/BinanceAccountAllOrders.php +++ b/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Secure/Account/BinanceAccountAllOrders.php @@ -1,4 +1,4 @@ -cache_the_response(); } } diff --git a/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Secure/Account/BinanceAccountOpenOrders.php b/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Secure/Account/BinanceAccountOpenOrders.php index 5a8db81c0..af6b06584 100644 --- a/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Secure/Account/BinanceAccountOpenOrders.php +++ b/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Secure/Account/BinanceAccountOpenOrders.php @@ -1,4 +1,4 @@ -param_set_order_side(ORDER_SIDE::BUY); + parent::__construct($api_key, $api_secret); + $this->set_order_side_to_buy(); } } \ No newline at end of file diff --git a/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Secure/Orders/BinanceBuyTest.php b/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Secure/Orders/BinanceBuyTest.php deleted file mode 100644 index dc72f4d1c..000000000 --- a/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Secure/Orders/BinanceBuyTest.php +++ /dev/null @@ -1,32 +0,0 @@ -param_set_order_side(ORDER_SIDE::BUY); - } -} \ No newline at end of file diff --git a/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Secure/Orders/BinanceCancelOrder.php b/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Secure/Orders/BinanceCancelOrder.php new file mode 100644 index 000000000..54609aecc --- /dev/null +++ b/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Secure/Orders/BinanceCancelOrder.php @@ -0,0 +1,14 @@ +param_set_order_time_in_force(TIME_IN_FORCE::GOOD_TILL_CANCELLED); + $this->param_set_order_type(ORDER_TYPES::LIMIT); + } + + public function set_order_side_to_buy(): void { + $this->param_set_order_side(ORDER_SIDE::BUY); + } + + public function set_order_side_to_sell(): void { $this->param_set_order_side(ORDER_SIDE::SELL); } } \ No newline at end of file diff --git a/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Secure/Orders/BinanceSell.php b/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Secure/Orders/BinanceSell.php index 20ff03972..c1e3ff333 100644 --- a/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Secure/Orders/BinanceSell.php +++ b/libraries/php/universal_utilities/RequestsHTTP/Binance/Endpoint/Secure/Orders/BinanceSell.php @@ -1,32 +1,12 @@ -param_set_order_side(ORDER_SIDE::SELL); + parent::__construct($api_key, $api_secret); + $this->set_order_side_to_sell(); } -} \ No newline at end of file +} diff --git a/libraries/php/universal_utilities/RequestsHTTP/Binance/Traits/Output/BooleanResponse.php b/libraries/php/universal_utilities/RequestsHTTP/Binance/Traits/Output/BooleanResponse.php index fa61296ed..153aa7c75 100644 --- a/libraries/php/universal_utilities/RequestsHTTP/Binance/Traits/Output/BooleanResponse.php +++ b/libraries/php/universal_utilities/RequestsHTTP/Binance/Traits/Output/BooleanResponse.php @@ -1,4 +1,4 @@ -param_set('limit', $this->validated_limit_value($limit)); } + /** + * @param int $limit + * @return int + * @throws ParameterException + */ private function validated_limit_value(int $limit): int { if ($this->allowed_parameter_limit_values !== null && count($this->allowed_parameter_limit_values) !== 0) { if (!in_array($limit, $this->allowed_parameter_limit_values, false)) { - DBG::throw_exception('Invalid parameter{limit} value of {' . $limit . '}'); - return $this->allowed_parameter_limit_values[0]; + throw ParameterException::invalid_function_parameter('validated_limit_value', $limit); } return $limit; } diff --git a/libraries/php/universal_utilities/RequestsHTTP/Binance/Traits/Params/ParameterOrderID.php b/libraries/php/universal_utilities/RequestsHTTP/Binance/Traits/Params/ParameterOrderID.php index e753e4745..7eefd0afe 100644 --- a/libraries/php/universal_utilities/RequestsHTTP/Binance/Traits/Params/ParameterOrderID.php +++ b/libraries/php/universal_utilities/RequestsHTTP/Binance/Traits/Params/ParameterOrderID.php @@ -1,4 +1,4 @@ -$field_name === null) { + /** @noinspection PhpVariableVariableInspection */ + $this->$field_name = SQLQuery::new(); + return true; + } + return false; + } + + /** + * @param SQLQuery $query + * @return mixed|mixed[] + */ + public function first_execute(SQLQuery $query) { + return $query->prepare($this->connection)->execute(); + } + +} diff --git a/libraries/php/universal_utilities/SQL/PostgreSQL/PostgreSQLTableUtilities.php b/libraries/php/universal_utilities/SQL/PostgreSQL/PostgreSQLTableUtilities.php deleted file mode 100644 index a5a11b01f..000000000 --- a/libraries/php/universal_utilities/SQL/PostgreSQL/PostgreSQLTableUtilities.php +++ /dev/null @@ -1,34 +0,0 @@ -sql = $sql; + return $this; + } + + /** + * @param Connection $connection + * @return self + */ + public function prepare(Connection $connection): self { + $this->statement = $connection->prepare($this->sql); + if ($this->response_num_cols === 1) { + $this->statement->setFetchMode(FetchMode::COLUMN, 0); + } + return $this; + } + + /** + * @return mixed|mixed[] + */ + public function execute() { + $this->statement->execute(); + if ($this->response_num_cols === 1) { + return $this->statement->fetch(); + } + return $this->statement->fetchAll(); + } + + /** + * @param string $fields_to_count + * @return SQLQuery + */ + public function COUNT($fields_to_count='*'): self { + $this->sql .= 'COUNT(' . $fields_to_count . ') '; + return $this; + } + + /** + * @param string $from + * @return SQLQuery + */ + public function FROM(string $from): self { + $this->sql .= 'FROM ' . $from . ' '; + return $this; + } + + /** + * @return string + */ + public function __toString(): string { + return $this->sql; + } + + /** + * @param $limit + * @return SQLQuery + */ + public function LIMIT($limit=1): self { + $this->sql .= ' LIMIT ' . ((string) $limit) . ' '; + return $this; + } + + /*__ __ __ ___ __ __ + / \ |__) | \ |__ |__) |__) \ / + \__/ | \ |__/ |___ | \ |__) | */ + + /** + * @param string $field + * @return SQLQuery + */ + public function ORDER_BY(string $field): self { + $this->sql .= ' ORDER BY ' . $field . ' '; + return $this; + } + + /** + * @param string $field + * @return SQLQuery + */ + public function ORDER_BY_DESC(string $field): self { + $this->sql .= ' ORDER BY ' . $field . ' DESC '; + return $this; + } + + /** + * @param string $field + * @return SQLQuery + */ + public function ORDER_BY_ASC(string $field): self { + $this->sql .= ' ORDER BY ' . $field . ' ASC '; + return $this; + } + + /** + * @param string $field + * @param $limit + * @return SQLQuery + */ + public function ORDER_BY_DESC_LIMIT(string $field, $limit=1): self { + $this->sql .= ' ORDER BY ' . $field . ' DESC '; + return $this->LIMIT($limit); + } + + /** + * @param string $field + * @param $limit + * @return SQLQuery + */ + public function ORDER_BY_ASC_LIMIT(string $field, $limit=1): self { + $this->sql .= ' ORDER BY ' . $field . ' ASC ' . ((string) $limit) . ' '; + return $this->LIMIT($limit); + } + + /* ___ __ ___ + | | |__| |__ |__) |__ + |/\| | | |___ | \ |___ */ + + /** + * @return SQLQuery + */ + public function WHERE(): self { + $this->sql .= 'WHERE '; + return $this; + } + + /** + * @param $fields + * @param $values + * @return SQLQuery + */ + public function WHERE_EQUAL_TO($fields, $values): self { + return $this->WHERE()->EQUAL_TO($fields, $values); + } + + /** + * @param string $field + * @param string $value + * @return SQLQuery + */ + public function WHERE_EQUAL_TO_STR(string $field, string $value): self { + return $this->WHERE()->EQUAL_TO_STR($field, $value); + } + + /** + * @param $fields + * @param $values + * @return SQLQuery + */ + public function AND_WHERE_EQUAL_TO($fields, $values): self { + $this->sql .= 'AND '; + return $this->EQUAL_TO($fields, $values); + } + + /** + * @param $field + * @param $value + * @return SQLQuery + */ + public function AND_WHERE_EQUAL_TO_STR($field, string $value): self { + $this->sql .= 'AND '; + return $this->EQUAL_TO_STR($field, $value); + } + + /*___ __ ___ __ + |__ / \ | | /\ | | / \ + |___ \__X \__/ /~~\ |___ | \__/ */ + + /** + * @param $fields + * @param $values + * @return SQLQuery + */ + public function EQUAL_TO($fields, $values): self { + if (is_string($fields) && is_string($values)) { + $this->sql .= $fields . ' = '. $values . ' '; + } + return $this; + } + + /** + * @param string $field + * @param string $value + * @return SQLQuery + */ + public function EQUAL_TO_STR(string $field, string $value): self { + $this->sql .= $field . ' = '. STR::in_quotes($value) . ' '; + return $this; + } + + /*__ ___ ___ __ ___ + /__` |__ | |__ / ` | + .__/ |___ |___ |___ \__, | */ + + /** + * @param string $fields + * @param string $from + * @return SQLQuery + */ + public function SELECT_FROM(string $fields, string $from): self { + $this->sql .= 'SELECT ' . $fields . ' FROM ' . $from; + return $this; + } + + /** + * @param string $from + * @return SQLQuery + */ + public function SELECT_ALL(string $from): self { + $this->sql .= 'SELECT * FROM ' . $from . ' '; + return $this; + } + + /** + * @param string $fields + * @param string $from + * @return SQLQuery + */ + public function SELECT_COUNT_FROM(string $fields, string $from): self { + $this->sql .= 'SELECT COUNT(' . $fields . ') FROM ' . $from . ' '; + $this->response_num_cols = 1; + $this->response_num_rows = 1; + return $this; + } + + /** + * @param string $field + * @param string $as + * @return SQLQuery + */ + public function SELECT_AS(string $field, string $as): self { + $this->SELECT($field); + $this->sql .= ' AS ' . $as . ' '; + return $this; + } + + /** + * @param null $optional_fields + * @return SQLQuery + */ + public function SELECT($optional_fields = null): self { + $this->sql .= 'SELECT '; + if ($optional_fields !== null) { + if (is_string($optional_fields)) { + $this->response_num_cols = 1; + $this->sql .= $optional_fields . ' '; + } else if (is_array($optional_fields)) { + $this->response_num_cols = count($optional_fields); + if ($this->response_num_cols > 0) { + foreach ($optional_fields as $field) { + $this->sql .= ', ' . $field; + } + $this->sql .= implode(',', $optional_fields); + var_dump($this->sql); + $this->sql = STR::remove_last_n($this->sql, 2); + var_dump($this->sql); + exit(2); + #$this->sql = StringUtilities::indexed() + } + } + } + return $this; + } + +} diff --git a/libraries/php/universal_utilities/SQL/Representation/SQLQueryGroup.php b/libraries/php/universal_utilities/SQL/Representation/SQLQueryGroup.php new file mode 100644 index 000000000..15c49f6f5 --- /dev/null +++ b/libraries/php/universal_utilities/SQL/Representation/SQLQueryGroup.php @@ -0,0 +1,60 @@ +connection = $connection; + $this->db_name = SYS::get_env('DB_NAME'); + $this->db_name_quotes = STR::in_quotes($this->db_name); + $this->name_sql_safe = STR::in_quotes($table_name); + $this->name_sql_wrapped = STR::parentheses('', $this->name_sql_safe); + $this->set_name_and_label($table_name, static::class); + } + + /** + * @see https://www.postgresql.org/docs/9.1/sql-analyze.html + * + * @return mixed + */ + abstract protected function analyze(); +} diff --git a/libraries/php/universal_utilities/SQL/Schema/DBSchema.php b/libraries/php/universal_utilities/SQL/Schema/DBSchema.php new file mode 100644 index 000000000..2f0ef100d --- /dev/null +++ b/libraries/php/universal_utilities/SQL/Schema/DBSchema.php @@ -0,0 +1,100 @@ +sql_db_size = 'pg_database_size' . STR::parentheses('', $this->db_name_quotes); + $this->sql_db_size_pretty = STR::parentheses('pg_size_pretty', $this->sql_db_size); + } + + /** + * @param bool $pretty_output + * @return mixed + */ + public function get_total_size(bool $pretty_output=false) { + if ($this->cache_is_cold('query_get_db_size')) { + return $this->first_execute($this->query_get_size->SELECT( + $pretty_output ? $this->sql_db_size_pretty : $this->sql_db_size + )); + } + return $this->query_get_db_size->execute(); + } + + /** + * @return mixed|mixed[] + */ + public function get_num_tables() { + if ($this->cache_is_cold('query_get_num_tables')) { + return $this->first_execute($this->query_get_num_tables->SELECT()->COUNT() + ->FROM(self::INFO_SCHEMA_TABLES)->WHERE_EQUAL_TO_STR('table_schema', 'public') + ->AND_WHERE_EQUAL_TO_STR('table_type', 'BASE TABLE') + ); + } + return $this->query_get_num_tables->execute(); + } + + /** + * @return mixed|mixed[] + */ + public function get_table_names() { + if ($this->cache_is_cold('query_get_table_names')) { + return $this->first_execute($this->query_get_table_names->SELECT('table_name') + ->FROM(self::INFO_SCHEMA_TABLES) + ->WHERE_EQUAL_TO_STR('table_schema', 'public') + ->AND_WHERE_EQUAL_TO_STR('table_type', 'BASE TABLE') + ); + } + return $this->query_get_table_names->execute(); + } + + /** + * @see https://www.postgresql.org/docs/9.1/sql-analyze.html + * + * @return mixed + */ + protected function analyze() { + if ($this->cache_is_cold('query_analyze')) { + return $this->first_execute($this->query_analyze->raw('ANALYZE VERBOSE')); + } + return $this->query_analyze->execute(); + } + +} diff --git a/libraries/php/universal_utilities/SQL/Table/DBTable.php b/libraries/php/universal_utilities/SQL/Table/DBTable.php new file mode 100644 index 000000000..5072a175e --- /dev/null +++ b/libraries/php/universal_utilities/SQL/Table/DBTable.php @@ -0,0 +1,122 @@ +sql_table_size = 'pg_total_relation_size' . $this->name_sql_wrapped; + $this->sql_table_size_pretty = STR::parentheses('pg_size_pretty', $this->sql_table_size); + } + + /** + * @param string $field + * @return mixed|mixed[] + */ + public function get_oldest(string $field) { + if ($this->cache_is_cold('query_get_oldest')) { + return $this->first_execute($this->query_get_oldest + ->SELECT('*')->FROM($this->name_sql_safe)->ORDER_BY_ASC_LIMIT($field) + ); + } + return $this->query_get_oldest->execute(); + } + + /** + * @param string $field + * @return mixed|mixed[] + */ + public function get_latest(string $field) { + if ($this->cache_is_cold('query_get_latest')) { + return $this->first_execute($this->query_get_latest + ->SELECT('*')->FROM($this->name_sql_safe)->ORDER_BY_DESC_LIMIT($field) + ); + } + return $this->query_get_latest->execute(); + } + + /** + * @param bool $cheap_operation + * + * @return mixed + */ + public function get_num_rows(bool $cheap_operation=false) { + if ($cheap_operation) { + if ($this->cache_is_cold('query_get_num_rows_cheap')) { + return $this->first_execute($this->query_get_num_rows_cheap + ->SELECT_AS('reltuples::bigint', 'estimate')->FROM('pg_class') + ->WHERE_EQUAL_TO('relname', $this->name_sql_safe) + ); + } + return $this->query_get_num_rows_cheap->execute(); + } + if ($this->cache_is_cold('query_get_num_rows_expensive')) { + return $this->first_execute($this->query_get_num_rows_expensive + ->SELECT_COUNT_FROM('id', $this->name_sql_safe) + ); + } + return $this->query_get_num_rows_expensive->execute(); + } + + /** + * @param bool $pretty_output + * @return mixed + */ + public function get_size(bool $pretty_output=false) { + if ($this->cache_is_cold('query_get_size')) { + return $this->first_execute( + $this->query_get_size + ->SELECT($pretty_output ? $this->sql_table_size_pretty : $this->sql_table_size) + ); + } + return $this->query_get_size->execute(); + } + + /** + * @see https://www.postgresql.org/docs/9.1/sql-analyze.html + * + * @return mixed + */ + protected function analyze() { + if ($this->cache_is_cold('query_analyze')) { + return $this->first_execute($this->query_analyze->raw('ANALYZE VERBOSE ' . $this->db_name . '.' . $this->name_sql_wrapped)); + } + return $this->query_analyze->execute(); + } +} diff --git a/libraries/php/universal_utilities/StringUtilities.php b/libraries/php/universal_utilities/StringUtilities.php index b4fa4a0ad..3a9a65795 100644 --- a/libraries/php/universal_utilities/StringUtilities.php +++ b/libraries/php/universal_utilities/StringUtilities.php @@ -1,4 +1,4 @@ - |___ | | |___ | \ .__/ */ + + /** + * @param string $base + * @param string $match + * @return int + */ + public static function position_of_last_match(string $base, string $match): int { + $pos = strrpos($base, $match); + return $pos; + } + + + /** + * @param string $base + * @return bool + */ + public static function has_content(string $base): bool { + return !($base && !trim($base)); + } + + /** + * Checks if provided string has any occurrences of the secondary string provided. + * + * @param string $base [The string to search. ] + * @param string $match [The string to search for.] + * @return bool [True if contained. ] + */ + public static function has(string $base, string $match): bool { + if ($match === '') { + return false; } - return $text; + return strpos($base, $match) !== false; } /** - * Returns a string having the contents of the base string with any occurrences of secondary string provided removed. + * Checks if the provided string starts with the prefix to match. * - * @param string $base < The string to base contents off of. > - * @param string|array $match < The string (or array of strings) to find occurrences of. > - * @return string < A new string. > + * @param string $base [The string to search. ] + * @param string $prefix [The prefix to search for.] + * @return bool [True if prefix matched. ] */ - public static function get_matches_removed(string $base, $match): string { - if (is_string($match)) { - return str_replace($match, '', $base); + public static function starts_with(string $base, string $prefix): bool { + if ($prefix === '') { + return false; } - foreach ($match as $m) { - $base = str_replace($m, '', $base); + return strpos($base, $prefix) === 0; + } + + /** + * Checks if the provided string ends with the suffix to match. + * + * @param string $base [The string to search. ] + * @param string $suffix [The suffix to search for.] + * @return bool [True if suffix matched. ] + */ + public static function ends_with(string $base, string $suffix): bool { + if ($suffix === '') { + return false; } - return $base; + return substr($base, -strlen($suffix)) === $suffix; } + /*__ __ ___ __ + /__` |__) | | | /__` + .__/ | |___ | | .__/ */ + /** * Returns an array with the provided string split based of the pattern to match. * - * @param string $base < The string to base contents off of. > - * @param string $delimiter < The string to match and split by. > - * @return array < An array of string segments. > + * @param string $base [The string to base contents off of.] + * @param string $delimiter [The string to match and split by. ] + * @return array [An array of string segments. ] */ public static function split(string $base, string $delimiter=PHP_EOL): array { return explode($delimiter, $base, PHP_INT_MAX); } + /** + * @param string $base + * @param string $delimiter + * @return array + */ + public static function split_clean(string $base, string $delimiter=PHP_EOL): array { + $lines = self::split($base, $delimiter); + $cleaned = []; + foreach ($lines as $line) { + if (self::has_content($line)) { + $cleaned[] = $line; + } + } + return $cleaned; + } + + /** + * @param string $base + * @return array + */ public static function split_into_non_empty_lines(string $base): array { $lines = []; foreach (self::split($base) as $line) { @@ -78,105 +197,174 @@ public static function split_into_non_empty_lines(string $base): array { return $lines; } + /*__ ___ __ __ + |__) |__ |\/| / \ \ / /\ | /__` + | \ |___ | | \__/ \/ /~~\ |___ .__/ */ + /** - * Checks if provided string has any occurrences of the secondary string provided. + * Returns a string having the contents of the base string with any occurrences of secondary string provided removed. * - * @param string $base < The string to search. > - * @param string $match < The string to search for. > - * @return bool < True if contained. > + * @param string $base [The string to base contents off of. ] + * @param string|array $match [The string (or array of strings) to find occurrences of.] + * @return string [A new string. ] */ - public static function contains(string $base, string $match): bool { - if ($match === '') { - return false; + public static function remove(string $base, $match): string { + if (is_string($match)) { + return str_replace($match, '', $base); } - return strpos($base, $match) !== false; + foreach ($match as $m) { + $base = str_replace($m, '', $base); + } + return $base; } + public static function remove_after_last_match(string $base, string $match): string { + return self::indexed($base, 0, self::position_of_last_match($base, $match) + strlen($match)); + } + + /** + * @param string $text + * @return string + */ + public static function remove_last_character(string $text): string { + return self::remove_last_n($text, 1); + } + + /** + * @param string $text + * @return string + */ + public static function remove_first_character(string $text): string { + return self::remove_first_n($text, 1); + } + + /** + * @param string $text + * @param int $num_digits + * @return string + */ + public static function remove_first_n(string $text, int $num_digits): string { + return substr($text, $num_digits); + } + + /** + * @param string $text + * @param int $num_digits + * @return string + */ + public static function remove_last_n(string $text, int $num_digits): string { + return substr($text, 0, strlen($text) - 1 - $num_digits); + } + + /** + * @param string $base + * @return string + */ public static function remove_newline(string $base): string { return self::replace($base, PHP_EOL, ''); } - public static function position_of_last_match(string $base, string $match): int { - $pos = strrpos($base, $match); - if ($pos === false) { - var_dump('POSITION NOT FOUND!'); + /* __ __ __ ___ __ + | | |__) /\ |__) |__) |__ | \ | |\ | + |/\| | \ /~~\ | | |___ |__/ | | \| */ + + /** + * @param string $base + * @param bool $single_quotes + * @param bool $replace_incorrect_quotes + * @return string + */ + public static function in_quotes(string $base, bool $single_quotes=true, bool $replace_incorrect_quotes=true): string { + $quote = $single_quotes ? "'" : '"'; + if ($replace_incorrect_quotes) { + $wrong_quote = $single_quotes ? '"' : "'"; + if (self::starts_with($base, $wrong_quote)) { + $base = self::remove_first_character($base); + } + if (self::ends_with($base, $wrong_quote)) { + $base = self::remove_last_character($base); + } } - return $pos; + return self::ensure_wrapped_in($base, $quote, $quote); } - public static function indexed_inclusive_to_last_match(string $base, string $match): string { - return self::indexed($base, 0, self::position_of_last_match($base, $match) + strlen($match)); + /** + * @param string $text + * @param $value + * @return string + */ + public static function parentheses(string $text, $value): string { + return $text . self::ensure_wrapped_in($value, '(', ')'); } - public static function indexed(string $base, int $start, int $end=-1): string { - // TODO: Error checks on bad sizes given. - if ($end === -1) { - $end = strlen($base) - 1; - } - return substr($base, $start, $end); + /** + * @param string $text + * @param $value + * @return string + */ + public static function brackets(string $text, $value): string { + return $text . self::ensure_wrapped_in($value, '{', '}'); } /** - * Ensures the provided string starts with the provided sequence. - * - * @param string $base < The string to potentially modify. > - * @param string $prefix < The string sequence to ensure the base string starts with. > + * @param string $text + * @param string $start_with + * @param string $end_with + * @return string */ - public static function ensure_starts_with(string & $base, string $prefix): void { - if (!self::starts_with($base, $prefix)) { - $base = $prefix . $base; - } + public static function ensure_wrapped_in(string $text, string $start_with, string $end_with): string { + return self::ensure_ending(self::ensure_start($text, $start_with), $end_with); } + /*___ __ __ ___ + |__ |\ | /__` | | |__) |__ + |___ | \| .__/ \__/ | \ |___ */ + /** - * Checks if the provided string starts with the prefix to match. - * - * @param string $base < The string to search. > - * @param string $prefix < The prefix to search for. > - * @return bool < True if prefix matched. > + * @param string $base + * @param string $match + * @return string */ - public static function starts_with(string $base, string $prefix) : bool { - if ($prefix === '') { - return false; + public static function ensure_start_is_not(string $base, string $match): string { + if (self::starts_with($base, $match)) { + return self::remove_first_n($base, strlen($match)); } - return strpos($base, $prefix) === 0; + return $base; } /** - * Checks if the provided string ends with the suffix to match. - * - * @param string $base < The string to search. > - * @param string $suffix < The suffix to search for. > - * @return bool < True if suffix matched. > + * @param string $base + * @param string $match + * @return string */ - public static function ends_with(string $base, string $suffix) : bool { - if ($suffix === '') { - return false; + public static function ensure_ending_is_not(string $base, string $match): string { + if (self::ends_with($base, $match)) { + return self::remove_last_n($base, strlen($match)); } - return substr($base, -strlen($suffix)) === $suffix; + return $base; } /** - * Returns the provided number as a string with a set number of decimal places. - * - * @param float $number < The number to format convert. > - * @param int $number_of_decimals < The number of decimal places to display, defaults to 3. > - * @return string < A string format representation of the number provided. > + * @param string $text + * @param string $start_with + * @return string */ - public static function formatted_number(float $number, int $number_of_decimals=3): string { - return number_format($number, $number_of_decimals, '.', ''); + public static function ensure_start(string $text, string $start_with): string { + if (!self::starts_with($text, $start_with)) { + return $start_with . $text; + } + return $text; } /** - * Returns the provided string with any matches replaced. - * - * @param string $base < The string to return a modified version of. > - * @param string $match < Text instance to find and replace. > - * @param string $replacement < Content for replaced text instances. > + * @param string $text + * @param string $ends_with * @return string */ - public static function replace(string $base, string $match, string $replacement): string { - return str_replace($match, $replacement, $base); + public static function ensure_ending(string $text, string $ends_with): string { + if (!self::ends_with($text, $ends_with)) { + return $text . $ends_with; + } + return $text; } - } diff --git a/libraries/php/universal_utilities/SystemUtilities.php b/libraries/php/universal_utilities/SystemUtilities.php new file mode 100644 index 000000000..3ea347b45 --- /dev/null +++ b/libraries/php/universal_utilities/SystemUtilities.php @@ -0,0 +1,35 @@ + */ + /** @var bool [Indicates if the timer is currently accumulating time.] */ private $running; - /** @var mixed|null < The time instance of when time recording started. > */ + /** @var mixed|null [The time instance of when time recording started. ] */ private $time_start; - /** @var float < The total time elapsed. > */ + /** @var float [The total time elapsed. ] */ private $time_accumulated; /** * SimpleTimer constructor. * - * @param bool $auto_start < If set to true, the timer will begin recording immediately upon object creation. > + * @param bool $auto_start [If set to true, the timer will begin recording immediately upon object creation.] */ public function __construct(bool $auto_start=false) { $this->running = $auto_start; @@ -52,7 +52,7 @@ public function stop(): void { /** * Get the current amount of elapsed time. * - * @return float < The current amount of elapsed time. > + * @return float [The current amount of elapsed time.] */ public function get_delta() : float { if ($this->running) { @@ -64,12 +64,13 @@ public function get_delta() : float { /** * Get a friendly string version of the elapsed time. * - * @return string < Elapsed time in seconds. > + * @return string [Elapsed time in seconds.] */ public function __toString(): string { $delta = $this->get_delta(); if ($delta < 0.01) { - return '0s'; + return '~0s'; + #return '0s'; } return strval($delta) . 's'; } diff --git a/libraries/php/universal_utilities/Time/UnixTimeUtilities.php b/libraries/php/universal_utilities/Time/UnixTimeUtilities.php new file mode 100644 index 000000000..8d39efd52 --- /dev/null +++ b/libraries/php/universal_utilities/Time/UnixTimeUtilities.php @@ -0,0 +1,20 @@ + - * @param bool $use_recursion < If set to true, any sub-directories will be recursively traversed. > - * @param array $all_files < A provided array to insert file paths into. > - * @param array $all_directories < A provided array to insert directory paths into. > - * @throws Exception - */ - public static function get_all_contents(string $path_directory, bool $use_recursion, array & $all_files, array & $all_directories) : void { - UPO::is_valid($path_directory, true); - $files = scandir($path_directory, SCANDIR_SORT_NONE); - if (!STR::ends_with($path_directory, DIRECTORY_SEPARATOR)) { - $path_directory .= DIRECTORY_SEPARATOR; - } - foreach ($files as $key => $value) { - if ($value === '.' || $value === '..') { - continue; - } - $path = realpath($path_directory . $value); - if (!is_dir($path)) { - $all_files[] = $path; - } else { - $all_directories[] = $path; - if ($use_recursion) { - self::get_all_contents($path, $use_recursion,$all_files, $all_directories); - } - } - } - } - -} diff --git a/libraries/php/universal_utilities/files/FileUtilities.php b/libraries/php/universal_utilities/files/FileUtilities.php deleted file mode 100644 index 852f3b05e..000000000 --- a/libraries/php/universal_utilities/files/FileUtilities.php +++ /dev/null @@ -1,219 +0,0 @@ - - * @param string $sha512sum < A provided hash value to check against. > - * @return bool < True if matched. > - * @throws Exception - */ - public static function matches_sha512sum(string $path, string $sha512sum) : bool { - UPO::is_valid($path, true); - return HASH::get_file_hash($path, HASH::SHA512SUM) === $sha512sum; - } - - /** - * Return the sha512sum of a file as a string hex number. - * - * @param string $path < The path to the file to get a hash value for. > - * @return string < Hex digits. > - * @throws Exception - */ - public static function get_sha512sum(string $path): string { - UPO::is_valid($path, true); - return HASH::get_file_hash($path, HASH::SHA512SUM); - } - - /** - * Return the size (in bytes) of the file provided. - * - * @param string $path < The path to the file to get size of. > - * @return int < The number of bytes used by file. > - * @throws Exception - */ - public static function get_size(string $path): int { - UPO::is_valid($path, true); - return filesize($path); - } - - /** - * Take the contents of the provided CSS file and create a minified version at provided output path. - * - * @param string $path_base < The path to the CSS file to get contents of. > - * @param string $path_output < The path to create a minified CSS file at. > - * @throws Exception - */ - public static function minify_css(string $path_base, string $path_output): void { - UPO::is_valid($path_base, true); - RUN::minify_file_css_to($path_base, $path_output); - } - - /** - * Take the contents of the provided HTML file and create a minified version at provided output path. - * - * @param string $path_base < The path to the CSS file to get contents of. > - * @param string $path_output < The path to create a minified HTML file at. > - * @throws Exception - */ - public static function minify_html(string $path_base, string $path_output): void { - UPO::is_valid($path_base, true); - RUN::minify_file_html_to($path_base, $path_output); - } - - /** - * Take the contents of the provided file and create a gzipped version at provided output path. - * - * @param string $path_base < The path to the file to get contents of. > - * @param string $path_output < The path to create a gzipped file at. > - * @throws Exception - */ - public static function gzip(string $path_base, string $path_output): void { - UPO::is_valid($path_base, true); - RUN::gzip_file_to($path_base, $path_output); - } - - public static function delete(string $path): void { - if (UPO::is_valid($path)) { - unlink($path); - } - } - - /** - * Returns the contents of a YAML file as an association array. - * - * @param string $path < The path to the (yml/yaml) file to get contents of. > - * @return array < An association array of the file's contents. > - * @throws Exception - */ - public static function get_yaml(string $path): array { - UPO::is_valid($path, true); - return Yaml::parseFile($path); - } - - public static function get_json_contents(string $path) { - UPO::is_valid($path, true); - return json_decode(file_get_contents($path)); - } - - public static function get_css_minified_contents(string $path): string { - $contents = self::get_as_list($path); - $num_lines = count($contents); - if ($num_lines > 1) { - DBG::throw_exception('File{' . $path . '} has more than 1 line of code!'); - } else if ($num_lines === 0) { - DBG::throw_exception('File{' . $path . '} has no contents!'); - } - return $contents[0]; - } - - public static function create_or_overwrite_file(string $path, $contents): void { - $f = fopen($path, 'wb'); - if (is_array($contents)) { - $contents = implode($contents); - } - fwrite($f, $contents); - fclose($f); - } - - public static function set_contents(string $path, string $contents): void { - UPO::is_valid($path, true); - file_put_contents($path, $contents, LOCK_EX); - } - - public static function get_as_list(string $path): array { - UPO::is_valid($path, true); - $file_lines = []; - $lines = file($path); - foreach ($lines as $line) { - $file_lines[] = $line; - } - return $file_lines; - } - - /** - * @reference: https://www.php.net/manual/en/function.xml-parse-into-struct.php - * @param string $path - * @return mixed - * @throws Exception - */ - public static function parse_xml_contents(string $path) { - UPO::is_valid($path, true); - - $elements = array(); // the currently filling [child] XmlElement array - $stack = array(); - $values = []; - $index = []; - $parser = xml_parser_create(); - # xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); - xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); - xml_parse_into_struct($parser, file_get_contents($path), $values, $index); - xml_parser_free($parser); - - foreach ($values as $tag) { - $index = count($elements); - $tag_type = $tag['type']; - $tag_type_is_open = $tag_type === 'open'; - - if ($tag_type === 'complete' || $tag_type_is_open) { - $elements[$index] = new XMLElement(); - $elements[$index]->name = $tag['tag']; - if (isset($tag['attributes'])) { - $elements[$index]->attributes = $tag['attributes']; - } - if (isset($tag['value'])) { - $elements[$index]->content = $tag['value']; - } - if ($tag_type_is_open) { // push - $elements[$index]->children = array(); - $stack[count($stack)] = &$elements; - $elements = &$elements[$index]->children; - } - } - if ($tag_type === 'close') { // pop - $elements = &$stack[count($stack) - 1]; - unset($stack[count($stack) - 1]); - } - } - - return $elements[0]; // the single top-level element - } - -} - diff --git a/libraries/php/universal_utilities/files/PathUtilities.php b/libraries/php/universal_utilities/files/PathUtilities.php deleted file mode 100644 index adea8b3ad..000000000 --- a/libraries/php/universal_utilities/files/PathUtilities.php +++ /dev/null @@ -1,175 +0,0 @@ - - * @param bool $raise_exception_if_not < If the provided path is not valid then an exception is thrown. > - * @return bool - * @throws Exception - */ - public static function is_valid(string $path, bool $raise_exception_if_not=false) : bool { - // N O T E : Ensure that file check is performed first as that condition is more likely. - $is_path_valid = ($path !== '') && (is_file($path) || is_dir($path)); - if ($raise_exception_if_not && !$is_path_valid) { - DBG::throw_exception('Invalid path{' . $path . '}'); - } - return $is_path_valid; - } - - /** - * Returns a string representing the provided path with 1 less directory depth (if not already at base directory). - * - * @param string $path < The path to remove a layer from. > - * @return string < A new string representing the path provided with potentially 1 less directory depth. > - */ - public static function remove_layer(string $path) : string { - if ($path === '/') { - return '/'; - } - if (STR::ends_with($path, '/')) { - return STR::indexed_inclusive_to_last_match(STR::indexed($path, 0, strlen($path) - 2), '/'); - } - return STR::indexed_inclusive_to_last_match($path, '/'); - } - - public static function get_up_to_layer(string $path, string $layer) : string { - return STR::indexed($path, 0, STR::position_of_last_match($path, $layer)) . $layer; - } - - public static function get_current_cwd() : string { - return getcwd(); - } - - public static function set_current_cwd(string $path) : void { - chdir($path); - } - - public static function cwd_pop() : void { - if (self::$cwd !== null) { - chdir(self::$cwd); - self::$cwd = null; - } - } - - public static function cwd_push(string $path) : void { - self::$cwd = getcwd(); - chdir($path); - } - - public static function get_directory(string $path) : string { - return pathinfo($path, PATHINFO_DIRNAME) . '/'; - } - - public static function get_file_full_name(string $path) : string { - return self::get_file_name($path) . self::get_ending_extension($path); - } - - public static function get_file_name(string $path) : string { - return pathinfo($path, PATHINFO_FILENAME); - } - - public static function get_all_extensions(string $path) : ?array { - $file_full_name = self::get_file_full_name($path); - $extension = pathinfo($path, PATHINFO_EXTENSION); - if ($extension === null || $extension === '') { - return null; - } - if ($extension === '.') { - return ['.']; - } - $extensions = STR::split($file_full_name, '.'); - $num_extensions = count($extensions); - if ($num_extensions > 1) { - $return_extensions = []; - for ($i = 1; $i < $num_extensions; $i++) { - $return_extensions[] = '.' . $extensions[$i]; - } - return $return_extensions; - } - return null; - } - - public static function get_ending_extension(string $path) : string { - $extension = pathinfo($path, PATHINFO_EXTENSION); - if ($extension === null || $extension === '') { - return ''; - } - if ($extension === '.') { - return $extension; - } - return '.' . $extension; - } - -} diff --git a/scripts/test.py b/scripts/test.py index 824284567..e9af12d03 100644 --- a/scripts/test.py +++ b/scripts/test.py @@ -25,4 +25,7 @@ #print(api) -api.print_status() \ No newline at end of file +api.print_status() + + +