From abc177734c785fe19ea458634a94f3f29074fcc2 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 13 Jan 2025 10:00:18 +0100 Subject: [PATCH 01/89] 3487: Update docker setup --- .docker/nginx.conf | 9 ++--- .docker/templates/default.conf.template | 47 +++++++++++++++++++++++ .docker/vhost.conf | 33 ---------------- docker-compose.dev.yml | 23 +++++------ docker-compose.override.yml | 7 ---- docker-compose.redirect.yml | 2 +- docker-compose.server.yml | 15 +++++--- docker-compose.yml | 51 ++++++++++++------------- 8 files changed, 96 insertions(+), 91 deletions(-) create mode 100644 .docker/templates/default.conf.template delete mode 100644 .docker/vhost.conf delete mode 100644 docker-compose.override.yml diff --git a/.docker/nginx.conf b/.docker/nginx.conf index 43dbd195..8fe03dbc 100644 --- a/.docker/nginx.conf +++ b/.docker/nginx.conf @@ -1,13 +1,12 @@ worker_processes auto; -error_log /var/log/nginx/error.log notice; +error_log /dev/stderr notice; pid /tmp/nginx.pid; events { worker_connections 1024; } - http { proxy_temp_path /tmp/proxy_temp; client_body_temp_path /tmp/client_temp; @@ -18,7 +17,7 @@ http { include /etc/nginx/mime.types; default_type application/octet-stream; - set_real_ip_from 172.16.0.0/8; + set_real_ip_from 172.16.0.0/16; real_ip_recursive on; real_ip_header X-Forwarded-For; @@ -26,11 +25,9 @@ http { '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; - access_log /var/log/nginx/access.log main; + access_log /dev/stdout main; sendfile on; - #tcp_nopush on; - keepalive_timeout 65; gzip on; diff --git a/.docker/templates/default.conf.template b/.docker/templates/default.conf.template new file mode 100644 index 00000000..61c4e648 --- /dev/null +++ b/.docker/templates/default.conf.template @@ -0,0 +1,47 @@ +server { + listen ${NGINX_PORT}; + server_name localhost; + + root ${NGINX_WEB_ROOT}; + + client_max_body_size ${NGINX_MAX_BODY_SIZE}; + + # This also needs to be set in the single server tag and not only in http. + set_real_ip_from 172.16.0.0/16; + real_ip_recursive on; + real_ip_header X-Forwarded-For; + + location / { + # try to serve file directly, fallback to index.php + try_files $uri /index.php$is_args$args; + } + + # Protect files and directories from prying eyes. + location ~* \.(engine|inc|install|make|module|profile|po|sh|.*sql|.tar|.gz|.bz2|theme|twig|tpl(\.php)?|xtmpl|yml)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\.(?!well-known).*|Entries.*|Repository|Root|Tag|Template|composer\.(json|lock)|web\.config)$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig|\.save)$ { + deny all; + return 404; + } + + location ~ ^/index\.php(/|$) { + fastcgi_buffers 16 32k; + fastcgi_buffer_size 64k; + fastcgi_busy_buffers_size 64k; + + fastcgi_pass ${NGINX_FPM_SERVICE}; + fastcgi_split_path_info ^(.+\.php)(/.*)$; + include fastcgi_params; + + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; + fastcgi_param DOCUMENT_ROOT $realpath_root; + + internal; + } + + location ~ \.php$ { + return 404; + } + + # Send log message to files symlinked to stdout/stderr. + error_log /dev/stderr; + access_log /dev/stdout main; +} diff --git a/.docker/vhost.conf b/.docker/vhost.conf deleted file mode 100644 index b50231d4..00000000 --- a/.docker/vhost.conf +++ /dev/null @@ -1,33 +0,0 @@ -server { - listen 8080; - server_name localhost; - root /app/public; - - location / { - # try to serve file directly, fallback to index.php - try_files $uri /index.php$is_args$args; - } - - location ~ ^/index\.php(/|$) { - fastcgi_buffers 16 32k; - fastcgi_buffer_size 64k; - fastcgi_busy_buffers_size 64k; - - fastcgi_pass phpfpm:9000; - fastcgi_split_path_info ^(.+\.php)(/.*)$; - include fastcgi_params; - - fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; - fastcgi_param DOCUMENT_ROOT $realpath_root; - - internal; - } - - location ~ \.php$ { - return 404; - } - - # Send log message to files symlinked to stdout/stderr. - error_log /dev/stderr; - access_log /dev/stdout main; -} diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 2bd447b1..4ac6fe33 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -1,26 +1,27 @@ - +# itk-version: 3.2.1 services: phpfpm: environment: - - PHP_SENDMAIL_PATH='/usr/local/bin/mhsendmail --smtp-addr="mailhog:1025"' + - PHP_SENDMAIL_PATH=/usr/sbin/sendmail -S mail:1025 nginx: labels: - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.middlewares=ITKBasicAuth@file" - mailhog: - image: itkdev/mailhog + mail: + image: axllent/mailpit + restart: unless-stopped networks: - app - frontend labels: - "traefik.enable=true" - "traefik.docker.network=frontend" - - "traefik.http.routers.mailhog_${COMPOSE_PROJECT_NAME}-http.rule=Host(`mailhog.${COMPOSE_SERVER_DOMAIN}`)" - - "traefik.http.routers.mailhog_${COMPOSE_PROJECT_NAME}-http.entrypoints=web" - - "traefik.http.routers.mailhog_${COMPOSE_PROJECT_NAME}-http.middlewares=redirect-to-https" + - "traefik.http.routers.mail_${COMPOSE_PROJECT_NAME}-http.rule=Host(`mail.${COMPOSE_SERVER_DOMAIN}`)" + - "traefik.http.routers.mail_${COMPOSE_PROJECT_NAME}-http.entrypoints=web" + - "traefik.http.routers.mail_${COMPOSE_PROJECT_NAME}-http.middlewares=redirect-to-https" - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" - - "traefik.http.routers.mailhog_${COMPOSE_PROJECT_NAME}.rule=Host(`mailhog.${COMPOSE_SERVER_DOMAIN}`)" - - "traefik.http.routers.mailhog_${COMPOSE_PROJECT_NAME}.entrypoints=websecure" - - "traefik.http.services.mailhog_${COMPOSE_PROJECT_NAME}.loadbalancer.server.port=8025" - - "traefik.http.routers.mailhog_${COMPOSE_PROJECT_NAME}.middlewares=ITKMailhogAuth@file" + - "traefik.http.routers.mail_${COMPOSE_PROJECT_NAME}.rule=Host(`mail.${COMPOSE_SERVER_DOMAIN}`)" + - "traefik.http.routers.mail_${COMPOSE_PROJECT_NAME}.entrypoints=websecure" + - "traefik.http.services.mail_${COMPOSE_PROJECT_NAME}.loadbalancer.server.port=8025" + - "traefik.http.routers.mail_${COMPOSE_PROJECT_NAME}.middlewares=ITKMailhogAuth@file" diff --git a/docker-compose.override.yml b/docker-compose.override.yml deleted file mode 100644 index c5612b0a..00000000 --- a/docker-compose.override.yml +++ /dev/null @@ -1,7 +0,0 @@ - -services: -###> doctrine/doctrine-bundle ### - database: - ports: - - "5432" -###< doctrine/doctrine-bundle ### diff --git a/docker-compose.redirect.yml b/docker-compose.redirect.yml index 88275a40..66f26e97 100644 --- a/docker-compose.redirect.yml +++ b/docker-compose.redirect.yml @@ -1,4 +1,4 @@ - +# itk-version: 3.2.1 services: nginx: labels: diff --git a/docker-compose.server.yml b/docker-compose.server.yml index d0626969..f93d8404 100644 --- a/docker-compose.server.yml +++ b/docker-compose.server.yml @@ -1,4 +1,4 @@ - +# itk-version: 3.2.1 networks: frontend: external: true @@ -8,7 +8,7 @@ networks: services: phpfpm: - image: itkdev/php8.1-fpm:alpine + image: itkdev/php8.4-fpm:alpine restart: unless-stopped networks: - app @@ -29,12 +29,15 @@ services: - frontend depends_on: - phpfpm - ports: - - '8080' volumes: - - ./.docker/vhost.conf:/etc/nginx/conf.d/default.conf:ro + - ./.docker/templates:/etc/nginx/templates:ro - ./.docker/nginx.conf:/etc/nginx/nginx.conf:ro - - ./:/app:rw + - .:/app + environment: + NGINX_FPM_SERVICE: ${COMPOSE_PROJECT_NAME}-phpfpm-1:9000 + NGINX_WEB_ROOT: /app/public + NGINX_PORT: 8080 + NGINX_MAX_BODY_SIZE: 5M labels: - "traefik.enable=true" - "traefik.docker.network=frontend" diff --git a/docker-compose.yml b/docker-compose.yml index 90f2b5c6..71f2b88a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,4 @@ +# itk-version: 3.2.1 networks: frontend: external: true @@ -12,6 +13,12 @@ services: - app ports: - '3306' + healthcheck: + test: [ "CMD", "healthcheck.sh", "--connect", "--innodb_initialized" ] + start_period: 10s + interval: 10s + timeout: 5s + retries: 3 environment: - MYSQL_ROOT_PASSWORD=password - MYSQL_USER=db @@ -20,19 +27,23 @@ services: #- ENCRYPT=1 # Uncomment to enable database encryption. phpfpm: - image: itkdev/php8.1-fpm:latest + image: itkdev/php8.4-fpm:latest networks: - app + extra_hosts: + - "host.docker.internal:host-gateway" environment: - PHP_XDEBUG_MODE=${PHP_XDEBUG_MODE:-off} - PHP_MAX_EXECUTION_TIME=30 - PHP_MEMORY_LIMIT=256M - # - PHP_MAIL=1 # Uncomment to enable mailhog. + # Depending on the setup, you may have to remove --read-envelope-from from msmtp (cf. https://marlam.de/msmtp/msmtp.html) or use SMTP to send mail + - PHP_SENDMAIL_PATH=/usr/bin/msmtp --host=mail --port=1025 --read-recipients --read-envelope-from - DOCKER_HOST_DOMAIN=${COMPOSE_DOMAIN} - COMPOSER_VERSION=2 - PHP_IDE_CONFIG=serverName=localhost depends_on: - - mariadb + mariadb: + condition: service_healthy volumes: - .:/app @@ -46,8 +57,13 @@ services: ports: - '8080' volumes: - - ./.docker/vhost.conf:/etc/nginx/conf.d/default.conf:ro + - ./.docker/templates:/etc/nginx/templates:ro - .:/app + environment: + NGINX_FPM_SERVICE: ${COMPOSE_PROJECT_NAME}-phpfpm-1:9000 + NGINX_WEB_ROOT: /app/public + NGINX_PORT: 8080 + NGINX_MAX_BODY_SIZE: 5M labels: - "traefik.enable=true" - "traefik.docker.network=frontend" @@ -56,8 +72,8 @@ services: # - "traefik.http.routers.${COMPOSE_PROJECT_NAME}.middlewares=redirect-to-https" # - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" - mailhog: - image: itkdev/mailhog + mail: + image: axllent/mailpit networks: - app - frontend @@ -67,24 +83,5 @@ services: labels: - "traefik.enable=true" - "traefik.docker.network=frontend" - - "traefik.http.routers.${COMPOSE_PROJECT_NAME}Mailhog.rule=Host(`mailhog-${COMPOSE_DOMAIN}`)" - - "traefik.http.services.${COMPOSE_PROJECT_NAME}Mailhog.loadbalancer.server.port=8025" - -###> doctrine/doctrine-bundle ### - database: - image: postgres:${POSTGRES_VERSION:-16}-alpine - environment: - POSTGRES_DB: ${POSTGRES_DB:-app} - # You should definitely change the password in production - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-!ChangeMe!} - POSTGRES_USER: ${POSTGRES_USER:-app} - volumes: - - database_data:/var/lib/postgresql/data:rw - # You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data! - # - ./docker/db/data:/var/lib/postgresql/data:rw -###< doctrine/doctrine-bundle ### - -volumes: -###> doctrine/doctrine-bundle ### - database_data: -###< doctrine/doctrine-bundle ### + - "traefik.http.routers.${COMPOSE_PROJECT_NAME}mail.rule=Host(`mail-${COMPOSE_DOMAIN}`)" + - "traefik.http.services.${COMPOSE_PROJECT_NAME}mail.loadbalancer.server.port=8025" From 653c9c0d08749348f8ad165e9768d5eb0d18ed5b Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 13 Jan 2025 10:18:36 +0100 Subject: [PATCH 02/89] 3487: Added basic actions --- .github/PULL_REQUEST_TEMPLATE.md | 25 ++++ .github/workflows/pr.yaml | 188 +++++++++++++++++++++++++++++++ .gitignore | 4 + .markdownlint.json | 11 ++ composer.json | 15 ++- composer.lock | 62 +++++++++- docker-compose.server.yml | 2 +- docker-compose.yml | 2 +- package.json | 14 +++ phpstan.dist.neon | 8 ++ symfony.lock | 12 ++ 11 files changed, 337 insertions(+), 6 deletions(-) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/pr.yaml create mode 100644 .markdownlint.json create mode 100644 package.json create mode 100644 phpstan.dist.neon diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..dc5b4aec --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,25 @@ +#### Link to ticket + +Please add a link to the ticket being addressed by this change. + +#### Description + +Please include a short description of the suggested change and the reasoning behind the approach you have chosen. + +#### Screenshot of the result + +If your change affects the user interface you should include a screenshot of the result with the pull request. + +#### Checklist + +- [ ] My code is covered by test cases. +- [ ] My code passes our test (all our tests). +- [ ] My code passes our static analysis suite. +- [ ] My code passes our continuous integration process. + +If your code does not pass all the requirements on the checklist you have to add a comment explaining why this change +should be exempt from the list. + +#### Additional comments or questions + +If you have any further comments or questions for the reviewer please add them here. diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml new file mode 100644 index 00000000..da3f978e --- /dev/null +++ b/.github/workflows/pr.yaml @@ -0,0 +1,188 @@ +on: pull_request +name: Review +jobs: + test-composer-install: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: [ '8.4' ] + name: Validate composer (${{ matrix.php}}) + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php}} + extensions: http, ctype, iconv + coverage: none + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ matrix.dependency-version }}- + restore-keys: ${{ runner.os }}-composer-${{ matrix.dependency-version }}- + + - name: Validate composer files + run: composer validate composer.json --strict + + - name: Composer install with exported .env variables + run: | + set -a && source .env && set +a + APP_ENV=prod composer install --no-dev -o + + test-suite: + name: Test suite (${{ matrix.php }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: [ '8.4' ] + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php}} + extensions: http, ctype, iconv + coverage: xdebug + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ matrix.dependency-version }}- + restore-keys: ${{ runner.os }}-composer-${{ matrix.dependency-version }}- + + - name: Install Dependencies + run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist + + - name: Test suite + run: ./vendor/bin/phpunit --coverage-clover=coverage/unit.xml + + - name: Upload coverage to Codecov test + uses: codecov/codecov-action@v2 + with: + files: ./coverage/unit.xml + flags: unittests, ${{ matrix.php }} + + php-cs-fixer: + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + php: ["8.4"] + name: PHP Coding Standards Fixer (PHP ${{ matrix.php }}) + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php}} + extensions: http, ctype, iconv + coverage: none + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache composer dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ matrix.php }}-composer- + + - name: Install Dependencies + run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist + + - name: php-cs-fixer + run: phpdbg -qrr ./vendor/bin/php-cs-fixer fix --dry-run + + psalm: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ['8.4'] + name: Psalm static analysis (${{ matrix.php}}) + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php}} + extensions: http, ctype, iconv + coverage: none + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ matrix.dependency-version }}- + restore-keys: ${{ runner.os }}-composer-${{ matrix.dependency-version }}- + + - name: Install Dependencies + run: | + composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist + bin/console cache:clear + - name: Psalm + run: ./vendor/bin/psalm --no-cache + + markdownlint: + name: Markdown Lint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + - name: Cache yarn packages + uses: actions/cache@v4 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: Yarn install + uses: actions/setup-node@v2 + with: + node-version: '18' + - run: yarn install + - name: markdownlint + run: yarn run coding-standards-check + + changelog: + runs-on: ubuntu-latest + name: Changelog should be updated + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Git fetch + run: git fetch + + - name: Check that changelog has been updated. + run: git diff --exit-code origin/${{ github.base_ref }} -- CHANGELOG.md && exit 1 || exit 0 diff --git a/.gitignore b/.gitignore index 5df0eef5..2f606159 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,7 @@ /.php-cs-fixer.php /.php-cs-fixer.cache ###< friendsofphp/php-cs-fixer ### + +###> phpstan/phpstan ### +phpstan.neon +###< phpstan/phpstan ### diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 00000000..85d45c0f --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,11 @@ +{ + "default": true, + "MD013": { + "line_length": 120, + "ignore_code_blocks": true, + "tables": false + }, + "no-duplicate-heading": { + "siblings_only": true + } +} diff --git a/composer.json b/composer.json index 39dab7f5..1c30236d 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "license": "proprietary", "type": "project", "require": { - "php": ">=8.1", + "php": ">=8.3", "ext-ctype": "*", "ext-iconv": "*", "doctrine/annotations": "^2.0", @@ -30,6 +30,7 @@ "require-dev": { "ergebnis/composer-normalize": "^2.43", "friendsofphp/php-cs-fixer": "^3.66", + "phpstan/phpstan": "^2.1", "symfony/maker-bundle": "^1.48", "symfony/phpunit-bridge": "*", "symfony/stopwatch": "6.4.*", @@ -84,6 +85,16 @@ "auto-scripts": { "cache:clear": "symfony-cmd", "assets:install %PUBLIC_DIR%": "symfony-cmd" - } + }, + "coding-standards-apply": [ + "PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix" + ], + "coding-standards-check": [ + "PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --dry-run" + ], + "phpstan": [ + "./vendor/bin/phpstan analyse src" + ] + } } diff --git a/composer.lock b/composer.lock index e6784d66..b721d0a9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "35f1f5af197f3ad45f17f8b1144ed14b", + "content-hash": "fb9bbfab1a20e6153c71f7147ec7156c", "packages": [ { "name": "behat/transliterator", @@ -8059,6 +8059,64 @@ }, "time": "2024-07-01T20:03:41+00:00" }, + { + "name": "phpstan/phpstan", + "version": "2.1.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "cd6e973e04b4c2b94c86e8612b5a65f0da0e08e7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/cd6e973e04b4c2b94c86e8612b5a65f0da0e08e7", + "reference": "cd6e973e04b4c2b94c86e8612b5a65f0da0e08e7", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + } + ], + "time": "2025-01-05T16:43:48+00:00" + }, { "name": "react/cache", "version": "v1.2.0", @@ -8980,7 +9038,7 @@ "prefer-stable": true, "prefer-lowest": false, "platform": { - "php": ">=8.1", + "php": ">=8.3", "ext-ctype": "*", "ext-iconv": "*" }, diff --git a/docker-compose.server.yml b/docker-compose.server.yml index f93d8404..e2a6888d 100644 --- a/docker-compose.server.yml +++ b/docker-compose.server.yml @@ -8,7 +8,7 @@ networks: services: phpfpm: - image: itkdev/php8.4-fpm:alpine + image: itkdev/php8.3-fpm:alpine restart: unless-stopped networks: - app diff --git a/docker-compose.yml b/docker-compose.yml index 71f2b88a..750466b3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,7 +27,7 @@ services: #- ENCRYPT=1 # Uncomment to enable database encryption. phpfpm: - image: itkdev/php8.4-fpm:latest + image: itkdev/php8.3-fpm:latest networks: - app extra_hosts: diff --git a/package.json b/package.json new file mode 100644 index 00000000..2a825967 --- /dev/null +++ b/package.json @@ -0,0 +1,14 @@ +{ + "license": "UNLICENSED", + "private": true, + "description": "Tooling setup for linting", + "devDependencies": { + "markdownlint-cli": "^0.35.0" + }, + "scripts": { + "coding-standards-check/markdownlint": "markdownlint --ignore 'node_modules' --ignore 'vendor' README.md CHANGELOG.md 'docs/**/*.md'", + "coding-standards-check": "yarn coding-standards-check/markdownlint", + "coding-standards-apply/markdownlint": "markdownlint --fix README.md CHANGELOG.md docs/*.md docs/**/*.md", + "coding-standards-apply": "yarn coding-standards-apply/markdownlint" + } +} diff --git a/phpstan.dist.neon b/phpstan.dist.neon new file mode 100644 index 00000000..e0de575f --- /dev/null +++ b/phpstan.dist.neon @@ -0,0 +1,8 @@ +parameters: + level: 6 + paths: + - bin/ + - config/ + - public/ + - src/ + - tests/ diff --git a/symfony.lock b/symfony.lock index 2584ed4c..dfe6b4af 100644 --- a/symfony.lock +++ b/symfony.lock @@ -71,6 +71,18 @@ "knplabs/knp-paginator-bundle": { "version": "v6.1.1" }, + "phpstan/phpstan": { + "version": "2.1", + "recipe": { + "repo": "github.com/symfony/recipes-contrib", + "branch": "main", + "version": "1.0", + "ref": "5e490cc197fb6bb1ae22e5abbc531ddc633b6767" + }, + "files": [ + "phpstan.dist.neon" + ] + }, "stof/doctrine-extensions-bundle": { "version": "1.7", "recipe": { From d90c159d127bd484ab6f581a90c2bbe6b0052628 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 13 Jan 2025 10:25:17 +0100 Subject: [PATCH 03/89] 3487: Updated change log format --- CHANGELOG.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61cabc6f..22fc2f8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,18 @@ -# ITStyr CHANGELOG +# Changelog -## 2.1.0 +![keep a changelog](https://img.shields.io/badge/Keep%20a%20Changelog-v1.1.0-brightgreen.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9IiNmMTVkMzAiIHZpZXdCb3g9IjAgMCAxODcgMTg1Ij48cGF0aCBkPSJNNjIgN2MtMTUgMy0yOCAxMC0zNyAyMmExMjIgMTIyIDAgMDAtMTggOTEgNzQgNzQgMCAwMDE2IDM4YzYgOSAxNCAxNSAyNCAxOGE4OSA4OSAwIDAwMjQgNCA0NSA0NSAwIDAwNiAwbDMtMSAxMy0xYTE1OCAxNTggMCAwMDU1LTE3IDYzIDYzIDAgMDAzNS01MiAzNCAzNCAwIDAwLTEtNWMtMy0xOC05LTMzLTE5LTQ3LTEyLTE3LTI0LTI4LTM4LTM3QTg1IDg1IDAgMDA2MiA3em0zMCA4YzIwIDQgMzggMTQgNTMgMzEgMTcgMTggMjYgMzcgMjkgNTh2MTJjLTMgMTctMTMgMzAtMjggMzhhMTU1IDE1NSAwIDAxLTUzIDE2bC0xMyAyaC0xYTUxIDUxIDAgMDEtMTItMWwtMTctMmMtMTMtNC0yMy0xMi0yOS0yNy01LTEyLTgtMjQtOC0zOWExMzMgMTMzIDAgMDE4LTUwYzUtMTMgMTEtMjYgMjYtMzMgMTQtNyAyOS05IDQ1LTV6TTQwIDQ1YTk0IDk0IDAgMDAtMTcgNTQgNzUgNzUgMCAwMDYgMzJjOCAxOSAyMiAzMSA0MiAzMiAyMSAyIDQxLTIgNjAtMTRhNjAgNjAgMCAwMDIxLTE5IDUzIDUzIDAgMDA5LTI5YzAtMTYtOC0zMy0yMy01MWE0NyA0NyAwIDAwLTUtNWMtMjMtMjAtNDUtMjYtNjctMTgtMTIgNC0yMCA5LTI2IDE4em0xMDggNzZhNTAgNTAgMCAwMS0yMSAyMmMtMTcgOS0zMiAxMy00OCAxMy0xMSAwLTIxLTMtMzAtOS01LTMtOS05LTEzLTE2YTgxIDgxIDAgMDEtNi0zMiA5NCA5NCAwIDAxOC0zNSA5MCA5MCAwIDAxNi0xMmwxLTJjNS05IDEzLTEzIDIzLTE2IDE2LTUgMzItMyA1MCA5IDEzIDggMjMgMjAgMzAgMzYgNyAxNSA3IDI5IDAgNDJ6bS00My03M2MtMTctOC0zMy02LTQ2IDUtMTAgOC0xNiAyMC0xOSAzN2E1NCA1NCAwIDAwNSAzNGM3IDE1IDIwIDIzIDM3IDIyIDIyLTEgMzgtOSA0OC0yNGE0MSA0MSAwIDAwOC0yNCA0MyA0MyAwIDAwLTEtMTJjLTYtMTgtMTYtMzEtMzItMzh6bS0yMyA5MWgtMWMtNyAwLTE0LTItMjEtN2EyNyAyNyAwIDAxLTEwLTEzIDU3IDU3IDAgMDEtNC0yMCA2MyA2MyAwIDAxNi0yNWM1LTEyIDEyLTE5IDI0LTIxIDktMyAxOC0yIDI3IDIgMTQgNiAyMyAxOCAyNyAzM3MtMiAzMS0xNiA0MGMtMTEgOC0yMSAxMS0zMiAxMXptMS0zNHYxNGgtOFY2OGg4djI4bDEwLTEwaDExbC0xNCAxNSAxNyAxOEg5NnoiLz48L3N2Zz4K) + +All notable changes to this project will be documented in this file. + +See [keep a changelog] for information about writing changes to this log. + +## [Unreleased] + +* Added github actions +* Added PHPStan +* Updated composer setup + +## [2.1.0] - 01-22-2020 * Merged https://github.com/aakb/itstyr/pull/14 - Upgraded symfony to 4.4.2. * Merged https://github.com/aakb/itstyr/pull/13 - Added import run entity to track import run success. Changed report fields that are imported after change in Anmeldelsesportalen. @@ -123,3 +135,7 @@ * Adding notes to each system and report. * Adding general notes. * Basic user management. + +[keep a changelog]: https://keepachangelog.com/en/1.1.0/ +[unreleased]: https://github.com/itk-dev/sysstatus/compare/main...develop +[2.1.0]: https://github.com/itk-dev/sysstatus/releases/tag/2.1.0 From bdefdac186006510f648a68b9657f8aaaa31a798 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 13 Jan 2025 10:36:17 +0100 Subject: [PATCH 04/89] 3487: Removed test migration table --- README.md | 8 ++++++-- documentation/Brugsvejledning.md | 8 ++++++-- migrations/Version20240903091717.php | 2 -- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6822bca7..c9c29dcd 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ # itstyr + Styringsværktøj til IT projekter ## Setup locally ### Preset + Make sure you have a set of JSON files for testing import Commands. ### Start Docker containers @@ -31,15 +33,17 @@ open "http://$(docker-compose port nginx 8080)" ``` ## Import systems and reports + ```sh -docker compose exec phpfpm bin/console itstyr:import:system PATH -docker compose exec phpfpm bin/console itstyr:import:report PATH +docker compose exec phpfpm bin/console itstyr:import:system +docker compose exec phpfpm bin/console itstyr:import:report ``` ### Flowchart A helpful flowchart over the Entities, and Joinedtables. Ilustrative figures meaning: + 1. Database = Database 2. Black square = Entities 3. Grey square = relations diff --git a/documentation/Brugsvejledning.md b/documentation/Brugsvejledning.md index d433b198..5b87ffcb 100644 --- a/documentation/Brugsvejledning.md +++ b/documentation/Brugsvejledning.md @@ -1,10 +1,12 @@ # ITSTYR - trin for trin opsætning. ## Setup + *Hvis der ikke er data, på 'admin/system' eller 'admin/group', eller oprettet en bruger' skal punkterne i README.md først følges* ## Generelt + Itstyr er et Smiley-oversigts-site over systemer og anmeldelser. Websitet skal konfigurers i den rigtige rækkefølge for at få vist smileys. @@ -14,6 +16,7 @@ Først skal der oprettets en Gruppe, og efterfølgende: Kategori, og Tema. Til sidst skal man gå ind på dashboarded hvorfra man tilføje status smileys. ## 1. Gruppe + - Klik på Easyadmin Menupunktet Gruppe - du er nu på gruppes index-side - Klik på "tilføj gruppe" @@ -23,6 +26,7 @@ Til sidst skal man gå ind på dashboarded hvorfra man tilføje status smileys. - klik "Opret" eller "Opret og tilføj ny" ## 2. Kategori + - Klik på Easyadmin Menupunktet Kategorier - du er nu på kategories index-side - Klik på "tilføj kategori" @@ -34,6 +38,7 @@ Til sidst skal man gå ind på dashboarded hvorfra man tilføje status smileys. - klik "Opret" eller "Opret og tilføj ny" ## 3. Tema + - Klik på Easyadmin Menupunktet Tema - du er nu på Temas index-side - Klik på "tilføj Tema" @@ -43,10 +48,9 @@ Til sidst skal man gå ind på dashboarded hvorfra man tilføje status smileys. - klik på ' Anmeldelsr' og tilføj et eller flere Anmeldelser - udfyld "Vægt" med et tal (required) - klik på 'Kategori' og tilføj en kategori - - ## 3. Dashboard Systemer + *(Samme fremgangsmåde i Dashboard Anmeldelse)* - Klik på Easyadmin Menupunktet Dashboard Systemer - du er nu på DashboardSystemer index-side diff --git a/migrations/Version20240903091717.php b/migrations/Version20240903091717.php index 3c24568d..8ca7213b 100644 --- a/migrations/Version20240903091717.php +++ b/migrations/Version20240903091717.php @@ -20,7 +20,6 @@ public function getDescription(): string public function up(Schema $schema): void { // this up() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE TABLE test_user (id INT AUTO_INCREMENT NOT NULL, username VARCHAR(180) NOT NULL, roles JSON NOT NULL COMMENT \'(DC2Type:json)\', password VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_IDENTIFIER_USERNAME (username), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); $this->addSql('ALTER TABLE ext_log_entries CHANGE object_class object_class VARCHAR(191) NOT NULL, CHANGE username username VARCHAR(191) DEFAULT NULL'); $this->addSql('DROP INDEX UNIQ_4B019DDB5E237E06 ON fos_group'); $this->addSql('ALTER TABLE fos_group CHANGE name name VARCHAR(255) NOT NULL, CHANGE roles roles JSON NOT NULL COMMENT \'(DC2Type:json)\''); @@ -32,7 +31,6 @@ public function up(Schema $schema): void public function down(Schema $schema): void { // this down() migration is auto-generated, please modify it to your needs - $this->addSql('DROP TABLE test_user'); $this->addSql('CREATE UNIQUE INDEX UNIQ_9775E7085E237E06 ON theme (name)'); $this->addSql('ALTER TABLE fos_group CHANGE name name VARCHAR(180) NOT NULL, CHANGE roles roles LONGTEXT NOT NULL COMMENT \'(DC2Type:array)\''); $this->addSql('CREATE UNIQUE INDEX UNIQ_4B019DDB5E237E06 ON fos_group (name)'); From 8ac1e4e876f020065f7742e1ffbdf82620bfc489 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 13 Jan 2025 10:39:35 +0100 Subject: [PATCH 05/89] 3487: Updated change log --- CHANGELOG.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22fc2f8d..aa8c68ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,8 +14,11 @@ See [keep a changelog] for information about writing changes to this log. ## [2.1.0] - 01-22-2020 -* Merged https://github.com/aakb/itstyr/pull/14 - Upgraded symfony to 4.4.2. -* Merged https://github.com/aakb/itstyr/pull/13 - Added import run entity to track import run success. Changed report fields that are imported after change in Anmeldelsesportalen. +* Merged [https://github.com/aakb/itstyr/pull/14](https://github.com/aakb/itstyr/pull/14) + Upgraded symfony to 4.4.2. +* Merged [https://github.com/aakb/itstyr/pull/13](https://github.com/aakb/itstyr/pull/13) + Added import run entity to track import run success. Changed report fields that are imported after change in + Anmeldelsesportalen. ## 2.0.0 @@ -112,8 +115,7 @@ See [keep a changelog] for information about writing changes to this log. * Added responsible user to systems and reports. * Changed NULL values to display as empty instead of black square. * Added reports/systems dashboards. -* Added script (itstyr:group:assign) to extract group from sysOwner for reports - and systems. +* Added script (itstyr:group:assign) to extract group from sysOwner for reports and systems. ## 1.1.0 @@ -137,5 +139,7 @@ See [keep a changelog] for information about writing changes to this log. * Basic user management. [keep a changelog]: https://keepachangelog.com/en/1.1.0/ + [unreleased]: https://github.com/itk-dev/sysstatus/compare/main...develop + [2.1.0]: https://github.com/itk-dev/sysstatus/releases/tag/2.1.0 From 16747a195c3237cf9e1898e182e5b05a2b191763 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 13 Jan 2025 10:41:08 +0100 Subject: [PATCH 06/89] 3487: Updated readme --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c9c29dcd..f67791bf 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# itstyr +# ITStyr -Styringsværktøj til IT projekter +Styringsværktøj til IT projekter. ## Setup locally @@ -10,7 +10,7 @@ Make sure you have a set of JSON files for testing import Commands. ### Start Docker containers -```sh +```shell docker compose up -d docker compose exec phpfpm composer install docker compose exec phpfpm bin/console doctrine:migrations:migrate --no-interaction @@ -26,15 +26,13 @@ docker compose exec phpfpm bin/console SuperUser You should now be able to browse to the application -``` - +```shell open "http://$(docker-compose port nginx 8080)" - ``` ## Import systems and reports -```sh +```shell docker compose exec phpfpm bin/console itstyr:import:system docker compose exec phpfpm bin/console itstyr:import:report ``` @@ -42,6 +40,7 @@ docker compose exec phpfpm bin/console itstyr:import:report ### Flowchart A helpful flowchart over the Entities, and Joinedtables. + Ilustrative figures meaning: 1. Database = Database @@ -51,6 +50,7 @@ Ilustrative figures meaning: 5. arrow = relation between DB and Entity 6. bulletin = shows the mapping Entities in Jointables, and JoinCollums + ```mermaid flowchart TD Answers[Answers] @@ -96,4 +96,4 @@ flowchart TD Question --- |ManyToOne| Category ``` - + From 8f21523689d93179493db83e82837f0c061dcf73 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 13 Jan 2025 10:48:37 +0100 Subject: [PATCH 07/89] 3487: Downgrade to php 8.3 --- .github/workflows/pr.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index da3f978e..42d83bee 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -6,7 +6,7 @@ jobs: strategy: fail-fast: false matrix: - php: [ '8.4' ] + php: [ '8.3' ] name: Validate composer (${{ matrix.php}}) steps: - uses: actions/checkout@v4 @@ -43,7 +43,7 @@ jobs: strategy: fail-fast: false matrix: - php: [ '8.4' ] + php: [ '8.3' ] steps: - uses: actions/checkout@v4 @@ -82,7 +82,7 @@ jobs: strategy: fail-fast: false matrix: - php: ["8.4"] + php: ["8.3"] name: PHP Coding Standards Fixer (PHP ${{ matrix.php }}) steps: - name: Checkout @@ -117,7 +117,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['8.4'] + php: ['8.3'] name: Psalm static analysis (${{ matrix.php}}) steps: - uses: actions/checkout@v4 From f4d5fbf25c1ce3b07b3bb5afd3c5671cbb3fed02 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 13 Jan 2025 14:54:10 +0100 Subject: [PATCH 08/89] 3487: Fixed static code errors --- .github/workflows/pr.yaml | 6 +- composer.json | 5 +- composer.lock | 121 ++++++++++++- phpstan-baseline.neon | 49 +++++ phpstan.dist.neon | 3 + src/Command/AbstractImportCommand.php | 24 ++- src/Command/AssignGroupsCommand.php | 34 ++-- src/Command/ReportImportCommand.php | 7 +- src/Command/SuperUserCommand.php | 14 +- src/Command/SystemImportCommand.php | 2 +- src/Controller/Admin/AnswerCrudController.php | 5 +- .../Admin/CustomDashboardCrudController.php | 109 ++++++----- src/Controller/ExportController.php | 19 +- src/Controller/LoginController.php | 8 +- src/Entity/Answer.php | 4 +- src/Entity/Category.php | 16 +- src/Entity/Group.php | 30 +++- src/Entity/ImportRun.php | 8 +- src/Entity/Question.php | 17 +- src/Entity/Report.php | 26 ++- src/Entity/SelfServiceAvailableFromItem.php | 7 +- src/Entity/System.php | 33 ++-- src/Entity/Theme.php | 18 +- src/Entity/ThemeCategory.php | 6 +- src/Entity/User.php | 23 ++- src/Repository/AnswerRepository.php | 30 ---- src/Repository/CategoryRepository.php | 30 ---- src/Repository/GroupRepository.php | 18 +- src/Repository/ImportRunRepository.php | 30 ---- src/Repository/QuestionRepository.php | 30 ---- src/Repository/ReportRepository.php | 30 ---- ...SelfServiceAvailableFromItemRepository.php | 32 +--- src/Repository/SystemRepository.php | 30 ---- src/Repository/TestUserRepository.php | 60 ------- src/Repository/ThemeCategoryRepository.php | 30 ---- src/Repository/ThemeRepository.php | 30 ---- src/Repository/UserRepository.php | 30 ---- src/Service/BaseImporter.php | 23 +-- src/Service/DataExporter.php | 169 +++++++++--------- src/Service/ImportInterface.php | 4 +- src/Service/ReportImporter.php | 11 +- src/Service/SystemImporter.php | 6 +- src/Service/ThemeManager.php | 17 +- src/Twig/AppExtension.php | 28 +-- 44 files changed, 562 insertions(+), 670 deletions(-) create mode 100644 phpstan-baseline.neon delete mode 100644 src/Repository/TestUserRepository.php diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 42d83bee..fd293333 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -112,13 +112,13 @@ jobs: - name: php-cs-fixer run: phpdbg -qrr ./vendor/bin/php-cs-fixer fix --dry-run - psalm: + static-analysis: runs-on: ubuntu-latest strategy: fail-fast: false matrix: php: ['8.3'] - name: Psalm static analysis (${{ matrix.php}}) + name: Static analysis (${{ matrix.php}}) steps: - uses: actions/checkout@v4 @@ -145,7 +145,7 @@ jobs: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist bin/console cache:clear - name: Psalm - run: ./vendor/bin/psalm --no-cache + run: composer run analysis markdownlint: name: Markdown Lint diff --git a/composer.json b/composer.json index 1c30236d..534c472e 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,9 @@ "require-dev": { "ergebnis/composer-normalize": "^2.43", "friendsofphp/php-cs-fixer": "^3.66", + "phpstan/extension-installer": "^1.4", "phpstan/phpstan": "^2.1", + "phpstan/phpstan-doctrine": "^2.0", "symfony/maker-bundle": "^1.48", "symfony/phpunit-bridge": "*", "symfony/stopwatch": "6.4.*", @@ -64,6 +66,7 @@ "allow-plugins": { "ergebnis/composer-normalize": true, "php-http/discovery": true, + "phpstan/extension-installer": true, "symfony/flex": true, "symfony/runtime": true }, @@ -92,7 +95,7 @@ "coding-standards-check": [ "PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --dry-run" ], - "phpstan": [ + "analysis": [ "./vendor/bin/phpstan analyse src" ] diff --git a/composer.lock b/composer.lock index b721d0a9..e138afb1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "fb9bbfab1a20e6153c71f7147ec7156c", + "content-hash": "a8cc465ed982b29a9946cf7b5d427765", "packages": [ { "name": "behat/transliterator", @@ -8059,6 +8059,54 @@ }, "time": "2024-07-01T20:03:41+00:00" }, + { + "name": "phpstan/extension-installer", + "version": "1.4.3", + "source": { + "type": "git", + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "85e90b3942d06b2326fba0403ec24fe912372936" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/85e90b3942d06b2326fba0403ec24fe912372936", + "reference": "85e90b3942d06b2326fba0403ec24fe912372936", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.0", + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.9.0 || ^2.0" + }, + "require-dev": { + "composer/composer": "^2.0", + "php-parallel-lint/php-parallel-lint": "^1.2.0", + "phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPStan\\ExtensionInstaller\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPStan\\ExtensionInstaller\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Composer plugin for automatic installation of PHPStan extensions", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpstan/extension-installer/issues", + "source": "https://github.com/phpstan/extension-installer/tree/1.4.3" + }, + "time": "2024-09-04T20:21:43+00:00" + }, { "name": "phpstan/phpstan", "version": "2.1.1", @@ -8117,6 +8165,77 @@ ], "time": "2025-01-05T16:43:48+00:00" }, + { + "name": "phpstan/phpstan-doctrine", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-doctrine.git", + "reference": "bdb6a835c5aa9725979694ae9b70591e180f4853" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-doctrine/zipball/bdb6a835c5aa9725979694ae9b70591e180f4853", + "reference": "bdb6a835c5aa9725979694ae9b70591e180f4853", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.0.3" + }, + "conflict": { + "doctrine/collections": "<1.0", + "doctrine/common": "<2.7", + "doctrine/mongodb-odm": "<1.2", + "doctrine/orm": "<2.5", + "doctrine/persistence": "<1.3" + }, + "require-dev": { + "cache/array-adapter": "^1.1", + "composer/semver": "^3.3.2", + "cweagans/composer-patches": "^1.7.3", + "doctrine/annotations": "^2.0", + "doctrine/collections": "^1.6 || ^2.1", + "doctrine/common": "^2.7 || ^3.0", + "doctrine/dbal": "^3.3.8", + "doctrine/lexer": "^2.0 || ^3.0", + "doctrine/mongodb-odm": "^2.4.3", + "doctrine/orm": "^2.16.0", + "doctrine/persistence": "^2.2.1 || ^3.2", + "gedmo/doctrine-extensions": "^3.8", + "nesbot/carbon": "^2.49", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-phpunit": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.6.20", + "ramsey/uuid": "^4.2", + "symfony/cache": "^5.4" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "extension.neon", + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Doctrine extensions for PHPStan", + "support": { + "issues": "https://github.com/phpstan/phpstan-doctrine/issues", + "source": "https://github.com/phpstan/phpstan-doctrine/tree/2.0.1" + }, + "time": "2024-12-02T16:48:00+00:00" + }, { "name": "react/cache", "version": "v1.2.0", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 00000000..6335cde5 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,49 @@ +parameters: + ignoreErrors: + - + message: '#^Access to undefined constant Symfony\\Component\\HttpFoundation\\Request\:\:HEADER_X_FORWARDED_ALL\.$#' + identifier: classConstant.notFound + count: 1 + path: public/index.php + + - + message: '#^Call to function is_null\(\) with Doctrine\\Common\\Collections\\Collection\ will always evaluate to false\.$#' + identifier: function.impossibleType + count: 2 + path: src/Command/AssignGroupsCommand.php + + - + message: '#^Access to an undefined property App\\Controller\\Admin\\CustomDashboardCrudController\:\:\$entity\.$#' + identifier: property.notFound + count: 1 + path: src/Controller/Admin/CustomDashboardCrudController.php + + - + message: '#^Call to an undefined static method App\\Controller\\Admin\\AbstractSystatusDashboardController\:\:showAction\(\)\.$#' + identifier: staticMethod.notFound + count: 1 + path: src/Controller/Admin/CustomDashboardCrudController.php + + - + message: '#^Unable to resolve the template type T in call to method Doctrine\\ORM\\EntityManagerInterface\:\:getRepository\(\)$#' + identifier: argument.templateType + count: 1 + path: src/Controller/Admin/CustomDashboardCrudController.php + + - + message: '#^Call to an undefined method Traversable\\:\:uasort\(\)\.$#' + identifier: method.notFound + count: 1 + path: src/Entity/Theme.php + + - + message: '#^Negated boolean expression is always true\.$#' + identifier: booleanNot.alwaysTrue + count: 1 + path: src/Service/DataExporter.php + + - + message: '#^Call to function method_exists\(\) with ''Symfony\\\\Component\\\\Dotenv\\\\Dotenv'' and ''bootEnv'' will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: tests/bootstrap.php diff --git a/phpstan.dist.neon b/phpstan.dist.neon index e0de575f..6b03710d 100644 --- a/phpstan.dist.neon +++ b/phpstan.dist.neon @@ -1,3 +1,6 @@ +includes: + - phpstan-baseline.neon + parameters: level: 6 paths: diff --git a/src/Command/AbstractImportCommand.php b/src/Command/AbstractImportCommand.php index b3d88d67..a88feb27 100644 --- a/src/Command/AbstractImportCommand.php +++ b/src/Command/AbstractImportCommand.php @@ -10,15 +10,11 @@ abstract class AbstractImportCommand extends Command { - protected EntityManagerInterface $entityManager; - protected BaseImporter $importer; - - public function __construct(BaseImporter $importer, EntityManagerInterface $entityManager) + public function __construct( + protected BaseImporter $importer, + protected EntityManagerInterface $entityManager) { parent::__construct(); - - $this->entityManager = $entityManager; - $this->importer = $importer; } /** @@ -26,7 +22,7 @@ public function __construct(BaseImporter $importer, EntityManagerInterface $enti * * @throws \Exception */ - protected function import(string $type, string $src, OutputInterface $output) + protected function import(string $type, string $src, OutputInterface $output): void { $success = true; $errorMessage = null; @@ -45,16 +41,16 @@ protected function import(string $type, string $src, OutputInterface $output) /** * Record import run. * - * @param string $type - * The type of the import - * @param bool $success - * Success of run + * @param string $type + * The type of the import + * @param bool $success + * Success of run * @param string|null $output - * Output message or null + * Output message or null * * @throws \Exception */ - protected function recordImportRun(string $type, bool $success, ?string $output = null) + protected function recordImportRun(string $type, bool $success, ?string $output = null): void { $importRun = new ImportRun(); $importRun->setDatetime(new \DateTime()); diff --git a/src/Command/AssignGroupsCommand.php b/src/Command/AssignGroupsCommand.php index 41f9842c..9ca27de9 100644 --- a/src/Command/AssignGroupsCommand.php +++ b/src/Command/AssignGroupsCommand.php @@ -2,6 +2,7 @@ namespace App\Command; +use App\Entity\Report; use App\Repository\GroupRepository; use App\Repository\ReportRepository; use App\Repository\SystemRepository; @@ -12,25 +13,16 @@ class AssignGroupsCommand extends Command { - private $reportRepository; - private $systemRepository; - private $groupRepository; - private $entityManager; - public function __construct( - ReportRepository $reportRepository, - SystemRepository $systemRepository, - GroupRepository $groupRepository, - EntityManagerInterface $entityManager, + private readonly ReportRepository $reportRepository, + private readonly SystemRepository $systemRepository, + private readonly GroupRepository $groupRepository, + private readonly EntityManagerInterface $entityManager, ) { parent::__construct(); - $this->reportRepository = $reportRepository; - $this->systemRepository = $systemRepository; - $this->groupRepository = $groupRepository; - $this->entityManager = $entityManager; } - protected function configure() + protected function configure(): void { $this ->setName('itstyr:group:assign') @@ -40,11 +32,12 @@ protected function configure() ; } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $reports = $this->reportRepository->findAll(); $systems = $this->systemRepository->findAll(); + /** @var Report $report */ foreach ($reports as $report) { if (!is_null($report->getSysOwner())) { $e = $report->getSysOwner(); @@ -59,8 +52,8 @@ protected function execute(InputInterface $input, OutputInterface $output) ); if ($findGroup) { - if (is_null($report->getGroup())) { - $report->setGroup($findGroup); + if (is_null($report->getGroups())) { + $report->addGroup($findGroup); } if (is_null($report->getSysOwnerSub())) { @@ -92,8 +85,8 @@ protected function execute(InputInterface $input, OutputInterface $output) ); if ($findGroup) { - if (is_null($system->getGroup())) { - $system->setGroup($findGroup); + if (is_null($system->getGroups())) { + $system->addGroup($findGroup); } if (is_null($system->getSysOwnerSub())) { @@ -112,5 +105,8 @@ protected function execute(InputInterface $input, OutputInterface $output) } $this->entityManager->flush(); + + return Command::SUCCESS; } + } diff --git a/src/Command/ReportImportCommand.php b/src/Command/ReportImportCommand.php index 0f63c045..41e19446 100644 --- a/src/Command/ReportImportCommand.php +++ b/src/Command/ReportImportCommand.php @@ -16,7 +16,7 @@ public function __construct(ReportImporter $reportImporter, EntityManagerInterfa parent::__construct($reportImporter, $entityManager); } - protected function configure() + protected function configure(): void { $this ->setName('itstyr:import:report') @@ -25,7 +25,10 @@ protected function configure() ; } - protected function execute(InputInterface $input, OutputInterface $output) + /** + * @throws \Exception + */ + protected function execute(InputInterface $input, OutputInterface $output): int { $this->import(Report::class, $input->getArgument('src'), $output); diff --git a/src/Command/SuperUserCommand.php b/src/Command/SuperUserCommand.php index dd2d64c9..e44a5eb3 100644 --- a/src/Command/SuperUserCommand.php +++ b/src/Command/SuperUserCommand.php @@ -19,13 +19,11 @@ )] class SuperUserCommand extends Command { - private $entitManager; - private $passwordHasher; - - public function __construct(EntityManagerInterface $entityManager, UserPasswordHasherInterface $passwordHasher) + public function __construct( + private readonly EntityManagerInterface $entityManager, + private readonly UserPasswordHasherInterface $passwordHasher + ) { - $this->passwordHasher = $passwordHasher; - $this->entitManager = $entityManager; parent::__construct(); } @@ -46,8 +44,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $user->setPassword($this->passwordHasher->hashPassword($user, 'a')); $user->setRoles(['ROLE_SUPER_ADMIN']); $user->setEnabled(true); - $this->entitManager->persist($user); - $this->entitManager->flush(); + $this->entityManager->persist($user); + $this->entityManager->flush(); $io->success('you have created email:: a@a , with password:: a'); diff --git a/src/Command/SystemImportCommand.php b/src/Command/SystemImportCommand.php index f70cf8b7..13ec6ef8 100644 --- a/src/Command/SystemImportCommand.php +++ b/src/Command/SystemImportCommand.php @@ -16,7 +16,7 @@ public function __construct(SystemImporter $systemImporter, EntityManagerInterfa parent::__construct($systemImporter, $entityManager); } - protected function configure() + protected function configure(): void { $this ->setName('itstyr:import:system') diff --git a/src/Controller/Admin/AnswerCrudController.php b/src/Controller/Admin/AnswerCrudController.php index 9e138cfa..97d095d1 100644 --- a/src/Controller/Admin/AnswerCrudController.php +++ b/src/Controller/Admin/AnswerCrudController.php @@ -20,9 +20,10 @@ public static function getEntityFqcn(): string return Answer::class; } - public function updateEntity(EntityManagerInterface $entityManager, $entityInstance): void + public function updateEntity(EntityManagerInterface $entityManager, mixed $entityInstance): void { - parent::updateEntity($entityManager, $entityInstance); // TODO: Change the autogenerated stub + // TODO: Change the autogenerated stub + parent::updateEntity($entityManager, $entityInstance); $url = $this->generateUrl('dashboard', ['entityType' => 'system']); $response = new RedirectResponse($url); diff --git a/src/Controller/Admin/CustomDashboardCrudController.php b/src/Controller/Admin/CustomDashboardCrudController.php index 5f14b26e..fe9c0a60 100644 --- a/src/Controller/Admin/CustomDashboardCrudController.php +++ b/src/Controller/Admin/CustomDashboardCrudController.php @@ -6,8 +6,8 @@ use App\Entity\Report; use App\Entity\SelfServiceAvailableFromItem; use App\Entity\System; -use App\Repository\CategoryRepository; -use App\Repository\ThemeCategoryRepository; +use App\Repository\ReportRepository; +use App\Repository\SystemRepository; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; @@ -16,41 +16,38 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\TextType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; use Symfony\Contracts\Translation\TranslatorInterface; class CustomDashboardCrudController extends AbstractSystatusDashboardController { - private $categoryRepository; - private $themeCategoryRepository; - protected $entityManager; - private $paginator; - protected $translator; - /** * AdminController constructor. */ public function __construct( - CategoryRepository $categoryRepository, - ThemeCategoryRepository $themeCategoryRepository, - EntityManagerInterface $entityManager, - PaginatorInterface $paginator, - TranslatorInterface $translator, + private readonly EntityManagerInterface $entityManager, + private readonly PaginatorInterface $paginator, + private readonly TranslatorInterface $translator, ) { - $this->categoryRepository = $categoryRepository; - $this->themeCategoryRepository = $themeCategoryRepository; - $this->entityManager = $entityManager; - $this->paginator = $paginator; - $this->translator = $translator; } - #[Route('admin/{entityType}', name: 'dashboard')] - public function dashboard(Request $request, $entityType): mixed + /** + * @throws \Exception + */ + #[Route(path: 'admin/{entityType}', name: 'dashboard')] + public function dashboard(Request $request, string $entityType): Response { $queryParameters = $request->query; - $queryParams = $request->query->all(); // Fetch all query parameters as an array. - $formData = $queryParams['form'] ?? []; // Safely retrieve 'form' as an array. + + // Fetch all query parameters as an array. + $queryParams = $request->query->all(); + + // Safely retrieve 'form' as an array. + $formData = $queryParams['form'] ?? []; // Ensure `formData` is always an array. if (!is_array($formData)) { @@ -133,7 +130,15 @@ public function dashboard(Request $request, $entityType): mixed ]); } - private function getUserGroupsThemesAndCategories(array $userGroups, $entityType) + /** + * @param array $userGroups + * @param string $entityType + * + * @return mixed + * + * @throws \Exception + */ + private function getUserGroupsThemesAndCategories(array $userGroups, string $entityType): mixed { return array_reduce($userGroups, function ($carry, Group $group) use ($entityType) { @@ -159,8 +164,12 @@ function ($carry, Group $group) use ($entityType) { /** * Get repository for entity type. + * + * @param string $entityType + * + * @return ReportRepository|SystemRepository|null */ - private function getRepository($entityType): ?EntityRepository + private function getRepository(string $entityType): ReportRepository|SystemRepository|null { return match ($entityType) { 'system' => $this->entityManager->getRepository(System::class), @@ -171,11 +180,13 @@ private function getRepository($entityType): ?EntityRepository /** * Apply common filters for report and system query. + * + * @param QueryBuilder $query + * @param array $formParameters + * @param string|null $entityType + * @return QueryBuilder */ - private function applyFilters( - QueryBuilder $query, - array $formParameters, - $entityType = null, + private function applyFilters(QueryBuilder $query, array $formParameters, ?string $entityType = null, ): QueryBuilder { $query->andWhere('e.archivedAt IS NULL'); @@ -222,9 +233,9 @@ private function applyFilters( } /** - * Get subowners for selected group. + * Get sub-owners for selected group. */ - private function getSubOwnerOptions($repository, $selectedGroups): mixed + private function getSubOwnerOptions(mixed $repository, mixed $selectedGroups): mixed { $groups = $this->entityManager->getRepository(Group::class)->findBy([ 'id' => $selectedGroups, @@ -260,9 +271,13 @@ function ($carry, $item) { } /** - * Get options for self service filter. + * Get options for self-service filter. + * + * @param string $entityType + * + * @return array */ - private function getSelfServiceOptions($entityType): array + private function getSelfServiceOptions(string $entityType): array { $selfServiceOptions = []; if ('system' == $entityType) { @@ -279,15 +294,23 @@ private function getSelfServiceOptions($entityType): array /** * Get filter form builder. + * + * @param mixed $userGroupsThemesAndCategories + * @param array $formParameters + * @param mixed $subownerOptions + * @param bool $filterThemes + * @param bool $filterCategories + * @param array $filterSelfServiceOptions + * @return FormBuilderInterface */ private function getFilterFormBuilder( - $userGroupsThemesAndCategories, - $formParameters, - $subownerOptions, + mixed $userGroupsThemesAndCategories, + array $formParameters, + mixed $subownerOptions, bool $filterThemes = false, bool $filterCategories = false, array $filterSelfServiceOptions = [], - ): \Symfony\Component\Form\FormBuilderInterface { + ): FormBuilderInterface { $filterFormBuilder = $this->createFormBuilder(); $filterFormBuilder->add('groups', ChoiceType::class, [ 'label' => 'filter.groups', @@ -367,9 +390,9 @@ private function getFilterFormBuilder( /** * Overrides EasyAdmin show action. * - * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response + * @return RedirectResponse|Response */ - public function showAction() + public function showAction(): RedirectResponse|Response { $entityArray = $this->entity; if (Report::class == $entityArray['class'] || System::class == $entityArray['class']) { @@ -386,8 +409,14 @@ public function showAction() return parent::showAction(); } - private function getEntity($className, $id): ?object + /** + * @param string $entityName + * @param mixed $id + * + * @return object|null + */ + private function getEntity(string $entityName, mixed $id): object|null { - return $this->entityManager->getRepository($className)->find($id); + return $this->entityManager->getRepository($entityName)->find($id); } } diff --git a/src/Controller/ExportController.php b/src/Controller/ExportController.php index 39664163..9597d6ba 100644 --- a/src/Controller/ExportController.php +++ b/src/Controller/ExportController.php @@ -18,35 +18,30 @@ class ExportController extends AbstractController { /** - * @Route("/export/report", name="export_report") - * * @throws Exception * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - public function exportReports( - DataExporter $dataExporter, - ) { + #[Route(path: '/export/report', name: 'export_report')] + public function exportReports(DataExporter $dataExporter): void + { $dataExporter->exportReport(); } /** - * @Route("/export/system", name="export_system") - * * @throws Exception * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - public function exportSystems( - DataExporter $dataExporter, - ) { + #[Route(path: '/export/system', name: 'export_system')] + public function exportSystems(DataExporter $dataExporter): void + { $dataExporter->exportSystem(); } /** - * @Route("/export", name="export_page") - * * @throws Exception * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ + #[Route(path: '/export', name: 'export_page')] public function exportPage(Request $request, DataExporter $dataExporter, GroupRepository $groupRepository): Response { $groups = $groupRepository->findAll(); diff --git a/src/Controller/LoginController.php b/src/Controller/LoginController.php index 25d234bf..6092188c 100644 --- a/src/Controller/LoginController.php +++ b/src/Controller/LoginController.php @@ -3,6 +3,7 @@ namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Authentication\AuthenticationUtils; @@ -10,13 +11,12 @@ class LoginController extends AbstractController { #[Route('/', name: 'app_login')] - // public function index(): Response public function index(AuthenticationUtils $authenticationUtils): Response { - // get the login error if there is one + // Get the login error if there is one. $error = $authenticationUtils->getLastAuthenticationError(); - // last username entered by the user + // Last username entered by the user. $lastUsername = $authenticationUtils->getLastUsername(); return $this->render('login/index.html.twig', [ @@ -26,7 +26,7 @@ public function index(AuthenticationUtils $authenticationUtils): Response } #[Route(path: '/logout', name: 'admin_logout')] - public function logout() + public function logout(): RedirectResponse { return $this->redirectToRoute('app_login'); } diff --git a/src/Entity/Answer.php b/src/Entity/Answer.php index b9c28596..3551a1e2 100644 --- a/src/Entity/Answer.php +++ b/src/Entity/Answer.php @@ -20,12 +20,12 @@ class Answer #[ORM\Id] #[ORM\GeneratedValue] - #[ORM\Column] + #[ORM\Column(nullable: true)] private ?int $id = null; #[ORM\ManyToOne(inversedBy: 'answers')] #[ORM\JoinColumn(nullable: false)] - private ?Question $question = null; + private Question $question; #[ORM\Column(type: Types::TEXT, nullable: true)] #[Versioned] diff --git a/src/Entity/Category.php b/src/Entity/Category.php index 35c7dd8e..9e8ee8fb 100644 --- a/src/Entity/Category.php +++ b/src/Entity/Category.php @@ -22,16 +22,22 @@ class Category #[ORM\Id] #[ORM\GeneratedValue] - #[ORM\Column] + #[ORM\Column(nullable: true)] private ?int $id = null; - #[ORM\Column(length: 255, unique: true)] + #[ORM\Column(length: 255, unique: true, nullable: true)] #[Versioned] private ?string $name = null; + /** + * @var Collection + */ #[ORM\OneToMany(mappedBy: 'category', targetEntity: ThemeCategory::class, orphanRemoval: true)] private Collection $themeCategories; + /** + * @var Collection + */ #[ORM\OneToMany(mappedBy: 'category', targetEntity: Question::class, cascade: ['persist'])] private Collection $questions; @@ -83,8 +89,12 @@ public function removeThemeCategory(ThemeCategory $themeCategory): self /** * Virtual. + * + * @return array + * + * @throws \Exception */ - public function getThemes() + public function getThemes(): array { $list = []; $iterator = $this->themeCategories->getIterator(); diff --git a/src/Entity/Group.php b/src/Entity/Group.php index 6270efe2..78e8aa4a 100644 --- a/src/Entity/Group.php +++ b/src/Entity/Group.php @@ -14,29 +14,47 @@ class Group { #[ORM\Id] #[ORM\GeneratedValue] - #[ORM\Column] + #[ORM\Column(nullable: true)] private ?int $id = null; + /** + * @var Collection + */ #[ORM\ManyToMany(targetEntity: Theme::class, inversedBy: 'systemGroups')] #[ORM\JoinTable(name: 'group_system_themes')] private Collection $systemThemes; + /** + * @var Collection + */ #[ORM\ManyToMany(targetEntity: Theme::class, inversedBy: 'reportGroups')] #[ORM\JoinTable(name: 'group_report_themes')] private Collection $reportThemes; + /** + * @var Collection + */ #[ORM\ManyToMany(targetEntity: Report::class, mappedBy: 'groups')] private Collection $reports; + /** + * @var Collection + */ #[ORM\ManyToMany(targetEntity: System::class, mappedBy: 'groups')] private Collection $systems; + /** + * @var Collection + */ #[ORM\ManyToMany(targetEntity: User::class, mappedBy: 'groups')] private Collection $users; - #[ORM\Column(length: 255)] + #[ORM\Column(length: 255, nullable: true)] private ?string $name = null; + /** + * @var array + */ #[ORM\Column(type: Types::JSON)] private array $roles = []; @@ -206,11 +224,19 @@ public function setName(string $name): self return $this; } + /** + * @return string[] + */ public function getRoles(): array { return $this->roles; } + /** + * @param array $roles + * + * @return $this + */ public function setRoles(array $roles): self { $this->roles = $roles; diff --git a/src/Entity/ImportRun.php b/src/Entity/ImportRun.php index 8c116036..efee43b8 100644 --- a/src/Entity/ImportRun.php +++ b/src/Entity/ImportRun.php @@ -11,19 +11,19 @@ class ImportRun { #[ORM\Id] #[ORM\GeneratedValue] - #[ORM\Column] + #[ORM\Column(nullable: true)] private ?int $id = null; - #[ORM\Column(type: Types::DATETIME_MUTABLE)] + #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)] private ?\DateTimeInterface $datetime = null; - #[ORM\Column] + #[ORM\Column(nullable: true)] private ?bool $result = null; #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $output = null; - #[ORM\Column(length: 255)] + #[ORM\Column(length: 255, nullable: true)] private ?string $type = null; public function getId(): ?int diff --git a/src/Entity/Question.php b/src/Entity/Question.php index e637616d..09727170 100644 --- a/src/Entity/Question.php +++ b/src/Entity/Question.php @@ -21,20 +21,23 @@ class Question #[ORM\Id] #[ORM\GeneratedValue] - #[ORM\Column] + #[ORM\Column(nullable: true)] private ?int $id = null; #[ORM\ManyToOne(inversedBy: 'questions')] private ?Category $category = null; - #[ORM\Column(type: Types::TEXT)] + #[ORM\Column(type: Types::TEXT, nullable: true)] #[Versioned] private ?string $question = null; - #[ORM\Column] + #[ORM\Column(nullable: true)] private ?int $sortOrder = null; - #[ORM\OneToMany(mappedBy: 'question', targetEntity: Answer::class, orphanRemoval: 'true')] + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'question', targetEntity: Answer::class, orphanRemoval: true)] private Collection $answers; public function __construct() @@ -76,17 +79,11 @@ public function setQuestion(string $question): self return $this; } - /** - * @return mixed - */ public function getSortOrder(): ?int { return $this->sortOrder; } - /** - * @param mixed $sortOrder - */ public function setSortOrder(int $sortOrder): self { $this->sortOrder = $sortOrder; diff --git a/src/Entity/Report.php b/src/Entity/Report.php index 27396f96..bbc3d85d 100644 --- a/src/Entity/Report.php +++ b/src/Entity/Report.php @@ -23,13 +23,16 @@ class Report #[ORM\Id] #[ORM\GeneratedValue] - #[ORM\Column] + #[ORM\Column(nullable: true)] private ?int $id = null; + /** + * @var Collection + */ #[ORM\OneToMany(mappedBy: 'report', targetEntity: Answer::class)] private Collection $answers; - #[ORM\Column(length: 255)] + #[ORM\Column(length: 255, nullable: true)] #[Versioned] private ?string $name = null; @@ -37,7 +40,7 @@ class Report #[Versioned] private ?string $text = null; - #[ORM\Column(length: 255)] + #[ORM\Column(length: 255, nullable: true)] #[Versioned] private ?string $sysSystemOwner = null; @@ -134,7 +137,7 @@ class Report #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $sysInternalInformation = null; - #[ORM\Column(length: 255)] + #[ORM\Column(length: 255, nullable: true)] private ?string $sysLink = null; #[ORM\Column(nullable: true)] @@ -155,9 +158,12 @@ class Report #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $sysImpactAnalysisLink = null; - #[ORM\Column(length: 255, nullable: true, name: 'edoc_url')] + #[ORM\Column(name: 'edoc_url', length: 255, nullable: true)] private ?string $eDocUrl = null; + /** + * @var Collection + */ #[ORM\ManyToMany(targetEntity: Group::class, inversedBy: 'reports')] private Collection $groups; @@ -222,7 +228,7 @@ public function setName(string $name): self /** * Virtual property. */ - public function getTextSet() + public function getTextSet(): bool { return isset($this->text); } @@ -602,9 +608,9 @@ public function setSysVersion(?string $sysVersion): self /** * Virtual property. */ - public function getShowableName() + public function getShowableName(): ?string { - return isset($this->sysTitle) ? $this->sysTitle : $this->getName(); + return $this->sysTitle ?? $this->getName(); } public function getSysOwnerSub(): ?string @@ -621,8 +627,10 @@ public function setSysOwnerSub(?string $sysOwnerSub): self /** * Virtual property. + * + * @return array */ - public function getAnswerArea() + public function getAnswerArea(): array { $themes = []; $groups = $this->getGroups(); diff --git a/src/Entity/SelfServiceAvailableFromItem.php b/src/Entity/SelfServiceAvailableFromItem.php index 7d3bc263..dc42eb52 100644 --- a/src/Entity/SelfServiceAvailableFromItem.php +++ b/src/Entity/SelfServiceAvailableFromItem.php @@ -15,12 +15,15 @@ class SelfServiceAvailableFromItem #[ORM\Id] #[ORM\GeneratedValue] - #[ORM\Column] + #[ORM\Column(nullable: true)] private ?int $id = null; - #[ORM\Column(length: 255)] + #[ORM\Column(length: 255, nullable: true)] private ?string $name = null; + /** + * @var Collection + */ #[ORM\ManyToMany(targetEntity: System::class, inversedBy: 'selfServiceAvailableFromItems')] private Collection $systems; diff --git a/src/Entity/System.php b/src/Entity/System.php index 7197fb6c..371f8867 100644 --- a/src/Entity/System.php +++ b/src/Entity/System.php @@ -23,16 +23,22 @@ class System #[ORM\Id] #[ORM\GeneratedValue] - #[ORM\Column] + #[ORM\Column(nullable: true)] private ?int $id = null; + /** + * @var Collection + */ #[ORM\ManyToMany(targetEntity: SelfServiceAvailableFromItem::class, mappedBy: 'systems')] private Collection $selfServiceAvailableFromItems; + /** + * @var Collection + */ #[ORM\OneToMany(mappedBy: 'system', targetEntity: Answer::class)] private Collection $answers; - #[ORM\Column(length: 255)] + #[ORM\Column(length: 255, nullable: true)] #[Versioned] private ?string $name = null; @@ -40,7 +46,7 @@ class System #[Versioned] private ?string $text = null; - #[ORM\Column(length: 255)] + #[ORM\Column(length: 255, nullable: true)] #[Versioned] private ?string $sysSystemOwner = null; @@ -119,7 +125,7 @@ class System #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $sysOwnerSub = null; - #[ORM\Column(length: 255)] + #[ORM\Column(length: 255, nullable: true)] private ?string $sysLink = null; #[ORM\Column(nullable: true)] @@ -131,6 +137,9 @@ class System #[ORM\Column(name: 'edoc_url', length: 255, nullable: true)] private ?string $eDocUrl = null; + /** + * @var Collection + */ #[ORM\ManyToMany(targetEntity: Group::class, inversedBy: 'systems')] private Collection $groups; @@ -667,7 +676,7 @@ public function setSysOpenData(?string $sysOpenData): self /** * Virtual property. */ - public function getSysIdAsLink() + public function getSysIdAsLink(): ?string { return $this->getSysId(); } @@ -675,23 +684,25 @@ public function getSysIdAsLink() /** * Virtual property. */ - public function getShowableName() + public function getShowableName(): ?string { - return isset($this->sysTitle) ? $this->sysTitle : $this->getName(); + return $this->sysTitle ?? $this->getName(); } /** * Virtual property. */ - public function getTextSet() + public function getTextSet(): bool { return isset($this->text); } /** * Virtual property. + * + * @return array */ - public function getAnswerArea() + public function getAnswerArea(): array { $themes = []; $groups = $this->getGroups(); @@ -703,9 +714,11 @@ public function getAnswerArea() return $themes; } - public function setSysNumberOfUsers($sysNumberOfUsers) + public function setSysNumberOfUsers(string $sysNumberOfUsers): self { $this->sysNumberOfUsers = $sysNumberOfUsers; + + return $this; } public function getSysNumberOfUsers(): ?string diff --git a/src/Entity/Theme.php b/src/Entity/Theme.php index 1d4c1cdd..413aa61f 100644 --- a/src/Entity/Theme.php +++ b/src/Entity/Theme.php @@ -25,27 +25,30 @@ class Theme #[ORM\Column] private ?int $id = null; + /** + * @var Collection + */ #[ORM\OneToMany(mappedBy: 'theme', targetEntity: ThemeCategory::class, cascade: ['persist'], orphanRemoval: true)] private Collection $themeCategories; /** - * @var ArrayCollection + * @var Collection */ - private $categories; - #[ORM\ManyToMany(targetEntity: Group::class, mappedBy: 'systemThemes')] private Collection $systemGroups; + /** + * @var Collection + */ #[ORM\ManyToMany(targetEntity: Group::class, mappedBy: 'reportThemes')] private Collection $reportGroups; - #[ORM\Column(length: 255)] + #[ORM\Column(length: 255, nullable: true)] #[Versioned] private ?string $name = null; public function __construct() { - $this->categories = new ArrayCollection(); $this->themeCategories = new ArrayCollection(); $this->systemGroups = new ArrayCollection(); $this->reportGroups = new ArrayCollection(); @@ -93,6 +96,10 @@ public function removeThemeCategory(ThemeCategory $themeCategory): self /** * Virtual. + * + * @return array + * + * @throws \Exception */ public function getOrderedCategories(): array { @@ -104,6 +111,7 @@ public function getOrderedCategories(): array return (int) $first->getSortOrder() < (int) $second->getSortOrder() ? 1 : -1; }); + /** @var ThemeCategory $item */ foreach ($iterator as $i => $item) { $list[] = $item->getCategory(); } diff --git a/src/Entity/ThemeCategory.php b/src/Entity/ThemeCategory.php index 7b2e4895..d58c0b9a 100644 --- a/src/Entity/ThemeCategory.php +++ b/src/Entity/ThemeCategory.php @@ -19,13 +19,13 @@ class ThemeCategory #[ORM\ManyToOne(inversedBy: 'themeCategories')] #[ORM\JoinColumn(nullable: false)] - private ?Theme $theme = null; + private Theme $theme; #[ORM\ManyToOne(inversedBy: 'themeCategories')] #[ORM\JoinColumn(nullable: false)] - private ?Category $category = null; + private Category $category; - #[ORM\Column(type: 'integer', options: ['default' => 0])] + #[ORM\Column(type: 'integer', nullable: true, options: ['default' => 0])] private ?int $sortOrder = 0; public function getId(): ?int diff --git a/src/Entity/User.php b/src/Entity/User.php index a494528c..4ae53ada 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -25,25 +25,31 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface #[ORM\Column] private ?int $id = null; + /** + * @var Collection + */ #[ORM\ManyToMany(targetEntity: Group::class, inversedBy: 'users')] #[ORM\JoinTable(name: 'fos_user_user_group')] private Collection $groups; - #[ORM\Column(length: 255)] + #[ORM\Column(length: 255, nullable: true)] private ?string $username = null; - #[ORM\Column] + #[ORM\Column(nullable: true)] private ?string $password = null; - #[ORM\Column(length: 255)] + #[ORM\Column(length: 255, nullable: true)] private ?string $email = null; #[ORM\Column] - private ?bool $enabled = null; + private bool $enabled = false; #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)] private ?\DateTimeInterface $lastLogin = null; + /** + * @var array + */ #[ORM\Column] private array $roles = []; @@ -65,9 +71,14 @@ public function getGroups(): Collection return $this->groups; } - public function setGroups(Collection $groups): void + /** + * @param Collection $groups + */ + public function setGroups(Collection $groups): self { $this->groups = $groups; + + return $this; } public function addGroup(Group $group): self @@ -120,7 +131,7 @@ public function setEmail(string $email): self return $this; } - public function isEnabled(): ?bool + public function isEnabled(): bool { return $this->enabled; } diff --git a/src/Repository/AnswerRepository.php b/src/Repository/AnswerRepository.php index 26529bcf..7c6e0a01 100644 --- a/src/Repository/AnswerRepository.php +++ b/src/Repository/AnswerRepository.php @@ -8,11 +8,6 @@ /** * @extends ServiceEntityRepository - * - * @method Answer|null find($id, $lockMode = null, $lockVersion = null) - * @method Answer|null findOneBy(array $criteria, array $orderBy = null) - * @method Answer[] findAll() - * @method Answer[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ class AnswerRepository extends ServiceEntityRepository { @@ -38,29 +33,4 @@ public function remove(Answer $entity, bool $flush = false): void $this->getEntityManager()->flush(); } } - - // /** - // * @return Answer[] Returns an array of Answer objects - // */ - // public function findByExampleField($value): array - // { - // return $this->createQueryBuilder('a') - // ->andWhere('a.exampleField = :val') - // ->setParameter('val', $value) - // ->orderBy('a.id', 'ASC') - // ->setMaxResults(10) - // ->getQuery() - // ->getResult() - // ; - // } - - // public function findOneBySomeField($value): ?Answer - // { - // return $this->createQueryBuilder('a') - // ->andWhere('a.exampleField = :val') - // ->setParameter('val', $value) - // ->getQuery() - // ->getOneOrNullResult() - // ; - // } } diff --git a/src/Repository/CategoryRepository.php b/src/Repository/CategoryRepository.php index b219b56b..d9623d1e 100644 --- a/src/Repository/CategoryRepository.php +++ b/src/Repository/CategoryRepository.php @@ -8,11 +8,6 @@ /** * @extends ServiceEntityRepository - * - * @method Category|null find($id, $lockMode = null, $lockVersion = null) - * @method Category|null findOneBy(array $criteria, array $orderBy = null) - * @method Category[] findAll() - * @method Category[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ class CategoryRepository extends ServiceEntityRepository { @@ -38,29 +33,4 @@ public function remove(Category $entity, bool $flush = false): void $this->getEntityManager()->flush(); } } - - // /** - // * @return Category[] Returns an array of Category objects - // */ - // public function findByExampleField($value): array - // { - // return $this->createQueryBuilder('c') - // ->andWhere('c.exampleField = :val') - // ->setParameter('val', $value) - // ->orderBy('c.id', 'ASC') - // ->setMaxResults(10) - // ->getQuery() - // ->getResult() - // ; - // } - - // public function findOneBySomeField($value): ?Category - // { - // return $this->createQueryBuilder('c') - // ->andWhere('c.exampleField = :val') - // ->setParameter('val', $value) - // ->getQuery() - // ->getOneOrNullResult() - // ; - // } } diff --git a/src/Repository/GroupRepository.php b/src/Repository/GroupRepository.php index 9bd10556..c50eefb2 100644 --- a/src/Repository/GroupRepository.php +++ b/src/Repository/GroupRepository.php @@ -3,16 +3,12 @@ namespace App\Repository; use App\Entity\Group; +use App\Entity\User; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; /** * @extends ServiceEntityRepository - * - * @method Group|null find($id, $lockMode = null, $lockVersion = null) - * @method Group|null findOneBy(array $criteria, array $orderBy = null) - * @method Group[] findAll() - * @method Group[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ class GroupRepository extends ServiceEntityRepository { @@ -42,7 +38,7 @@ public function remove(Group $entity, bool $flush = false): void /** * @return Group[] Returns an array of Group objects */ - public function findByUser($user): array + public function findByUser(User $user): array { return $this->createQueryBuilder('g') ->andWhere(':val MEMBER OF g.users') @@ -51,14 +47,4 @@ public function findByUser($user): array ->getResult() ; } - - // public function findOneBySomeField($value): ?Group - // { - // return $this->createQueryBuilder('g') - // ->andWhere('g.exampleField = :val') - // ->setParameter('val', $value) - // ->getQuery() - // ->getOneOrNullResult() - // ; - // } } diff --git a/src/Repository/ImportRunRepository.php b/src/Repository/ImportRunRepository.php index e012ac89..56de4029 100644 --- a/src/Repository/ImportRunRepository.php +++ b/src/Repository/ImportRunRepository.php @@ -8,11 +8,6 @@ /** * @extends ServiceEntityRepository - * - * @method ImportRun|null find($id, $lockMode = null, $lockVersion = null) - * @method ImportRun|null findOneBy(array $criteria, array $orderBy = null) - * @method ImportRun[] findAll() - * @method ImportRun[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ class ImportRunRepository extends ServiceEntityRepository { @@ -38,29 +33,4 @@ public function remove(ImportRun $entity, bool $flush = false): void $this->getEntityManager()->flush(); } } - - // /** - // * @return ImportRun[] Returns an array of ImportRun objects - // */ - // public function findByExampleField($value): array - // { - // return $this->createQueryBuilder('i') - // ->andWhere('i.exampleField = :val') - // ->setParameter('val', $value) - // ->orderBy('i.id', 'ASC') - // ->setMaxResults(10) - // ->getQuery() - // ->getResult() - // ; - // } - - // public function findOneBySomeField($value): ?ImportRun - // { - // return $this->createQueryBuilder('i') - // ->andWhere('i.exampleField = :val') - // ->setParameter('val', $value) - // ->getQuery() - // ->getOneOrNullResult() - // ; - // } } diff --git a/src/Repository/QuestionRepository.php b/src/Repository/QuestionRepository.php index a11848cf..fb5802ef 100644 --- a/src/Repository/QuestionRepository.php +++ b/src/Repository/QuestionRepository.php @@ -8,11 +8,6 @@ /** * @extends ServiceEntityRepository - * - * @method Question|null find($id, $lockMode = null, $lockVersion = null) - * @method Question|null findOneBy(array $criteria, array $orderBy = null) - * @method Question[] findAll() - * @method Question[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ class QuestionRepository extends ServiceEntityRepository { @@ -38,29 +33,4 @@ public function remove(Question $entity, bool $flush = false): void $this->getEntityManager()->flush(); } } - - // /** - // * @return Question[] Returns an array of Question objects - // */ - // public function findByExampleField($value): array - // { - // return $this->createQueryBuilder('q') - // ->andWhere('q.exampleField = :val') - // ->setParameter('val', $value) - // ->orderBy('q.id', 'ASC') - // ->setMaxResults(10) - // ->getQuery() - // ->getResult() - // ; - // } - - // public function findOneBySomeField($value): ?Question - // { - // return $this->createQueryBuilder('q') - // ->andWhere('q.exampleField = :val') - // ->setParameter('val', $value) - // ->getQuery() - // ->getOneOrNullResult() - // ; - // } } diff --git a/src/Repository/ReportRepository.php b/src/Repository/ReportRepository.php index 5fc16d95..d360fcc2 100644 --- a/src/Repository/ReportRepository.php +++ b/src/Repository/ReportRepository.php @@ -8,11 +8,6 @@ /** * @extends ServiceEntityRepository - * - * @method Report|null find($id, $lockMode = null, $lockVersion = null) - * @method Report|null findOneBy(array $criteria, array $orderBy = null) - * @method Report[] findAll() - * @method Report[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ class ReportRepository extends ServiceEntityRepository { @@ -38,29 +33,4 @@ public function remove(Report $entity, bool $flush = false): void $this->getEntityManager()->flush(); } } - - // /** - // * @return Report[] Returns an array of Report objects - // */ - // public function findByExampleField($value): array - // { - // return $this->createQueryBuilder('r') - // ->andWhere('r.exampleField = :val') - // ->setParameter('val', $value) - // ->orderBy('r.id', 'ASC') - // ->setMaxResults(10) - // ->getQuery() - // ->getResult() - // ; - // } - - // public function findOneBySomeField($value): ?Report - // { - // return $this->createQueryBuilder('r') - // ->andWhere('r.exampleField = :val') - // ->setParameter('val', $value) - // ->getQuery() - // ->getOneOrNullResult() - // ; - // } } diff --git a/src/Repository/SelfServiceAvailableFromItemRepository.php b/src/Repository/SelfServiceAvailableFromItemRepository.php index 9bd1f2c9..e53d0df0 100644 --- a/src/Repository/SelfServiceAvailableFromItemRepository.php +++ b/src/Repository/SelfServiceAvailableFromItemRepository.php @@ -8,11 +8,6 @@ /** * @extends ServiceEntityRepository - * - * @method SelfServiceAvailableFromItem|null find($id, $lockMode = null, $lockVersion = null) - * @method SelfServiceAvailableFromItem|null findOneBy(array $criteria, array $orderBy = null) - * @method SelfServiceAvailableFromItem[] findAll() - * @method SelfServiceAvailableFromItem[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ class SelfServiceAvailableFromItemRepository extends ServiceEntityRepository { @@ -44,7 +39,7 @@ public function remove(SelfServiceAvailableFromItem $entity, bool $flush = false * * @return SelfServiceAvailableFromItem */ - public function getItem(string $name) + public function getItem(string $name): SelfServiceAvailableFromItem { $item = $this->findOneBy(['name' => $name]); @@ -62,29 +57,4 @@ public function getItem(string $name) return $item; } - - // /** - // * @return SelfServiceAvailableFromItem[] Returns an array of SelfServiceAvailableFromItem objects - // */ - // public function findByExampleField($value): array - // { - // return $this->createQueryBuilder('s') - // ->andWhere('s.exampleField = :val') - // ->setParameter('val', $value) - // ->orderBy('s.id', 'ASC') - // ->setMaxResults(10) - // ->getQuery() - // ->getResult() - // ; - // } - - // public function findOneBySomeField($value): ?SelfServiceAvailableFromItem - // { - // return $this->createQueryBuilder('s') - // ->andWhere('s.exampleField = :val') - // ->setParameter('val', $value) - // ->getQuery() - // ->getOneOrNullResult() - // ; - // } } diff --git a/src/Repository/SystemRepository.php b/src/Repository/SystemRepository.php index c95959e3..4f08c464 100644 --- a/src/Repository/SystemRepository.php +++ b/src/Repository/SystemRepository.php @@ -8,11 +8,6 @@ /** * @extends ServiceEntityRepository - * - * @method System|null find($id, $lockMode = null, $lockVersion = null) - * @method System|null findOneBy(array $criteria, array $orderBy = null) - * @method System[] findAll() - * @method System[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ class SystemRepository extends ServiceEntityRepository { @@ -38,29 +33,4 @@ public function remove(System $entity, bool $flush = false): void $this->getEntityManager()->flush(); } } - - // /** - // * @return System[] Returns an array of System objects - // */ - // public function findByExampleField($value): array - // { - // return $this->createQueryBuilder('s') - // ->andWhere('s.exampleField = :val') - // ->setParameter('val', $value) - // ->orderBy('s.id', 'ASC') - // ->setMaxResults(10) - // ->getQuery() - // ->getResult() - // ; - // } - - // public function findOneBySomeField($value): ?System - // { - // return $this->createQueryBuilder('s') - // ->andWhere('s.exampleField = :val') - // ->setParameter('val', $value) - // ->getQuery() - // ->getOneOrNullResult() - // ; - // } } diff --git a/src/Repository/TestUserRepository.php b/src/Repository/TestUserRepository.php deleted file mode 100644 index 2a7002d4..00000000 --- a/src/Repository/TestUserRepository.php +++ /dev/null @@ -1,60 +0,0 @@ - - */ -class TestUserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface -{ - public function __construct(ManagerRegistry $registry) - { - parent::__construct($registry, TestUser::class); - } - - /** - * Used to upgrade (rehash) the user's password automatically over time. - */ - public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void - { - if (!$user instanceof TestUser) { - throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', $user::class)); - } - - $user->setPassword($newHashedPassword); - $this->getEntityManager()->persist($user); - $this->getEntityManager()->flush(); - } - - // /** - // * @return TestUser[] Returns an array of TestUser objects - // */ - // public function findByExampleField($value): array - // { - // return $this->createQueryBuilder('t') - // ->andWhere('t.exampleField = :val') - // ->setParameter('val', $value) - // ->orderBy('t.id', 'ASC') - // ->setMaxResults(10) - // ->getQuery() - // ->getResult() - // ; - // } - - // public function findOneBySomeField($value): ?TestUser - // { - // return $this->createQueryBuilder('t') - // ->andWhere('t.exampleField = :val') - // ->setParameter('val', $value) - // ->getQuery() - // ->getOneOrNullResult() - // ; - // } -} diff --git a/src/Repository/ThemeCategoryRepository.php b/src/Repository/ThemeCategoryRepository.php index 805df5eb..399394be 100644 --- a/src/Repository/ThemeCategoryRepository.php +++ b/src/Repository/ThemeCategoryRepository.php @@ -8,11 +8,6 @@ /** * @extends ServiceEntityRepository - * - * @method ThemeCategory|null find($id, $lockMode = null, $lockVersion = null) - * @method ThemeCategory|null findOneBy(array $criteria, array $orderBy = null) - * @method ThemeCategory[] findAll() - * @method ThemeCategory[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ class ThemeCategoryRepository extends ServiceEntityRepository { @@ -38,29 +33,4 @@ public function remove(ThemeCategory $entity, bool $flush = false): void $this->getEntityManager()->flush(); } } - - // /** - // * @return ThemeCategory[] Returns an array of ThemeCategory objects - // */ - // public function findByExampleField($value): array - // { - // return $this->createQueryBuilder('t') - // ->andWhere('t.exampleField = :val') - // ->setParameter('val', $value) - // ->orderBy('t.id', 'ASC') - // ->setMaxResults(10) - // ->getQuery() - // ->getResult() - // ; - // } - - // public function findOneBySomeField($value): ?ThemeCategory - // { - // return $this->createQueryBuilder('t') - // ->andWhere('t.exampleField = :val') - // ->setParameter('val', $value) - // ->getQuery() - // ->getOneOrNullResult() - // ; - // } } diff --git a/src/Repository/ThemeRepository.php b/src/Repository/ThemeRepository.php index 8640992c..752f5da1 100644 --- a/src/Repository/ThemeRepository.php +++ b/src/Repository/ThemeRepository.php @@ -8,11 +8,6 @@ /** * @extends ServiceEntityRepository - * - * @method Theme|null find($id, $lockMode = null, $lockVersion = null) - * @method Theme|null findOneBy(array $criteria, array $orderBy = null) - * @method Theme[] findAll() - * @method Theme[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ class ThemeRepository extends ServiceEntityRepository { @@ -38,29 +33,4 @@ public function remove(Theme $entity, bool $flush = false): void $this->getEntityManager()->flush(); } } - - // /** - // * @return Theme[] Returns an array of Theme objects - // */ - // public function findByExampleField($value): array - // { - // return $this->createQueryBuilder('t') - // ->andWhere('t.exampleField = :val') - // ->setParameter('val', $value) - // ->orderBy('t.id', 'ASC') - // ->setMaxResults(10) - // ->getQuery() - // ->getResult() - // ; - // } - - // public function findOneBySomeField($value): ?Theme - // { - // return $this->createQueryBuilder('t') - // ->andWhere('t.exampleField = :val') - // ->setParameter('val', $value) - // ->getQuery() - // ->getOneOrNullResult() - // ; - // } } diff --git a/src/Repository/UserRepository.php b/src/Repository/UserRepository.php index 838478d8..583d25d4 100644 --- a/src/Repository/UserRepository.php +++ b/src/Repository/UserRepository.php @@ -8,11 +8,6 @@ /** * @extends ServiceEntityRepository - * - * @method User|null find($id, $lockMode = null, $lockVersion = null) - * @method User|null findOneBy(array $criteria, array $orderBy = null) - * @method User[] findAll() - * @method User[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ class UserRepository extends ServiceEntityRepository { @@ -38,29 +33,4 @@ public function remove(User $entity, bool $flush = false): void $this->getEntityManager()->flush(); } } - - // /** - // * @return User[] Returns an array of User objects - // */ - // public function findByExampleField($value): array - // { - // return $this->createQueryBuilder('u') - // ->andWhere('u.exampleField = :val') - // ->setParameter('val', $value) - // ->orderBy('u.id', 'ASC') - // ->setMaxResults(10) - // ->getQuery() - // ->getResult() - // ; - // } - - // public function findOneBySomeField($value): ?User - // { - // return $this->createQueryBuilder('u') - // ->andWhere('u.exampleField = :val') - // ->setParameter('val', $value) - // ->getQuery() - // ->getOneOrNullResult() - // ; - // } } diff --git a/src/Service/BaseImporter.php b/src/Service/BaseImporter.php index a86424cd..71e162a1 100644 --- a/src/Service/BaseImporter.php +++ b/src/Service/BaseImporter.php @@ -9,27 +9,18 @@ abstract class BaseImporter implements ImportInterface { - protected EntityManagerInterface $entityManager; - protected ReportRepository $reportRepository; - protected SystemRepository $systemRepository; - protected GroupRepository $groupRepository; - protected string|array|false $url; + protected string $url; public function __construct( - ReportRepository $reportRepository, - SystemRepository $systemRepository, - GroupRepository $groupRepository, - EntityManagerInterface $entityManager, + protected ReportRepository $reportRepository, + protected SystemRepository $systemRepository, + protected GroupRepository $groupRepository, + protected EntityManagerInterface $entityManager, ) { - $this->reportRepository = $reportRepository; - $this->systemRepository = $systemRepository; - $this->groupRepository = $groupRepository; - $this->entityManager = $entityManager; - $this->url = getenv('SYSTEM_URL'); } - protected function sanitizeText(string $str) + protected function sanitizeText(string $str): string|null { $str = strip_tags($str, '