Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create maker #160

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bin/ci/composer-require-checker
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

set -eu

readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_DIR}"/bin/common.inc.sh
. "${ROOT_DIR}"/bin/dockerise.inc.bash
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_PATH}"/bin/common.inc.sh
. "${ROOT_PATH}"/bin/dockerise.inc.bash

composer-require-checker \
--ansi \
--config-file="${ROOT_DIR}"/config/ci/composerRequireChecker.json \
--config-file="${ROOT_PATH}"/config/ci/composerRequireChecker.json \
"${@}"
6 changes: 3 additions & 3 deletions bin/ci/composer-validate
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

set -eu

readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_DIR}"/bin/common.inc.sh
. "${ROOT_DIR}"/bin/dockerise.inc.bash
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_PATH}"/bin/common.inc.sh
. "${ROOT_PATH}"/bin/dockerise.inc.bash

composer validate --ansi --strict
8 changes: 4 additions & 4 deletions bin/ci/docker
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

set -eu

readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
source "${ROOT_DIR}"/bin/common.inc.sh
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
source "${ROOT_PATH}"/bin/common.inc.sh

DOCKER_IMAGE_NAME="${CI_DOCKER_IMAGE_NAME}" \
DOCKER_FILE_PATH="${ROOT_DIR}"/docker/ci/Dockerfile \
source "${ROOT_DIR}"/bin/docker-build.inc.bash
DOCKER_FILE_PATH="${ROOT_PATH}"/docker/ci/Dockerfile \
source "${ROOT_PATH}"/bin/docker-build.inc.bash
8 changes: 4 additions & 4 deletions bin/ci/env
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

set -eu

readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_DIR}"/bin/common.inc.sh
. "${ROOT_DIR}"/bin/dockerise.inc.bash
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_PATH}"/bin/common.inc.sh
. "${ROOT_PATH}"/bin/dockerise.inc.bash

"${ROOT_DIR}"/bin/composer install
"${ROOT_PATH}"/bin/composer install
12 changes: 6 additions & 6 deletions bin/ci/phpcs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

set -eu

readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_DIR}"/bin/common.inc.sh
. "${ROOT_DIR}"/bin/dockerise.inc.bash
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_PATH}"/bin/common.inc.sh
. "${ROOT_PATH}"/bin/dockerise.inc.bash

if [ ! -d "${ROOT_DIR}"/var/ci/phpcs ]; then
mkdir -p "${ROOT_DIR}"/var/ci/phpcs
if [ ! -d "${ROOT_PATH}"/var/ci/phpcs ]; then
mkdir -p "${ROOT_PATH}"/var/ci/phpcs
fi

phpcs \
Expand All @@ -17,6 +17,6 @@ phpcs \
--bootstrap=config/ci/phpcs.php \
--standard="${COMPOSER_HOME}"/vendor/steevanb/php-code-sniffs/src/Steevanb/ruleset.xml \
--report=steevanb\\PhpCodeSniffs\\Reports\\Steevanb \
--cache="${ROOT_DIR}"/var/ci/phpcs/cache \
--cache="${ROOT_PATH}"/var/ci/phpcs/cache \
. \
"${@}"
6 changes: 3 additions & 3 deletions bin/ci/phpdd
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

set -eu

readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_DIR}"/bin/common.inc.sh
. "${ROOT_DIR}"/bin/dockerise.inc.bash
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_PATH}"/bin/common.inc.sh
. "${ROOT_PATH}"/bin/dockerise.inc.bash

ls -lah ${COMPOSER_HOME}/vendor/bin
ls -lah ${COMPOSER_HOME}/vendor/wapmorgan/php-deprecation-detector/bin
Expand Down
12 changes: 6 additions & 6 deletions bin/ci/phpstan
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

set -eu

readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"

source "${ROOT_DIR}"/bin/common.inc.sh
source "${ROOT_DIR}"/bin/dockerise.inc.bash
source "${ROOT_PATH}"/bin/common.inc.sh
source "${ROOT_PATH}"/bin/dockerise.inc.bash

phpVersion=
phpstanParameters=
Expand All @@ -20,13 +20,13 @@ for arg in "${@}"; do
fi
done

if [ "${clearCache}" == true ] && [ -d "${ROOT_DIR}"/var/ci/phpstan ]; then
if [ "${clearCache}" == true ] && [ -d "${ROOT_PATH}"/var/ci/phpstan ]; then
echo "Clear cache"
rm -rf "${ROOT_DIR}"/var/ci/phpstan
rm -rf "${ROOT_PATH}"/var/ci/phpstan
fi

if [ "${phpVersion}" == "" ]; then
php8.2 "${ROOT_DIR}"/bin/ci/phpstan.php ${phpstanParameters}
php8.3 "${ROOT_PATH}"/bin/ci/phpstan.php ${phpstanParameters}
else
echo "PHP ${phpVersion}"

Expand Down
8 changes: 4 additions & 4 deletions bin/ci/phpunit
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

set -eu

readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_DIR}"/bin/common.inc.sh
. "${ROOT_DIR}"/bin/dockerise.inc.bash
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_PATH}"/bin/common.inc.sh
. "${ROOT_PATH}"/bin/dockerise.inc.bash

phpVersion=
symfonyVersion=
Expand All @@ -20,7 +20,7 @@ for arg in "${@}"; do
done

if [ "${phpVersion}" == "" ] || [ "${symfonyVersion}" == "" ]; then
php8.2 "${ROOT_DIR}"/bin/ci/phpunit.php "${@}"
php8.2 "${ROOT_PATH}"/bin/ci/phpunit.php "${@}"
else
echo "PHP ${phpVersion} - Symfony ${symfonyVersion}"

Expand Down
12 changes: 6 additions & 6 deletions bin/ci/phpunit-coverage
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

set -eu

readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_DIR}"/bin/common.inc.sh
. "${ROOT_DIR}"/bin/dockerise.inc.bash
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_PATH}"/bin/common.inc.sh
. "${ROOT_PATH}"/bin/dockerise.inc.bash

echo "PHP 8.1 - Symfony 6.1"
set +e
XDEBUG_MODE=coverage \
php8.2 \
"${ROOT_DIR}"/vendor/bin/phpunit \
"${ROOT_PATH}"/vendor/bin/phpunit \
--bootstrap "${COMPOSER_HOME_SYMFONY_6_1}"/vendor/autoload.php \
--coverage-html "${ROOT_DIR}"/var/ci/phpunit/coverage/html \
--configuration "${ROOT_DIR}"/config/ci/phpunit.php-8.1.xml \
--coverage-html "${ROOT_PATH}"/var/ci/phpunit/coverage/html \
--configuration "${ROOT_PATH}"/config/ci/phpunit.php-8.1.xml \
"${@}"
set -e

Expand Down
8 changes: 4 additions & 4 deletions bin/ci/shellcheck
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

set -eu

readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
source "${ROOT_DIR}"/bin/common.inc.sh
source "${ROOT_DIR}"/bin/dockerise.inc.bash
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
source "${ROOT_PATH}"/bin/common.inc.sh
source "${ROOT_PATH}"/bin/dockerise.inc.bash

filesToCheck=()
files=$(find "${ROOT_DIR}"/bin)
files=$(find "${ROOT_PATH}"/bin)
for file in ${files}; do
if [ -f "${file}" ] && [ "${file:(-4)}" != ".php" ]; then
filesToCheck+=("${file}")
Expand Down
8 changes: 4 additions & 4 deletions bin/ci/unused-scanner
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

set -eu

readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_DIR}"/bin/common.inc.sh
. "${ROOT_DIR}"/bin/dockerise.inc.bash
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_PATH}"/bin/common.inc.sh
. "${ROOT_PATH}"/bin/dockerise.inc.bash

unused-scanner "${ROOT_DIR}"/config/ci/unused-scanner.php
unused-scanner "${ROOT_PATH}"/config/ci/unused-scanner.php
8 changes: 4 additions & 4 deletions bin/ci/validate
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

set -eu

readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_DIR}"/bin/common.inc.sh
. "${ROOT_DIR}"/bin/dockerise.inc.bash
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_PATH}"/bin/common.inc.sh
. "${ROOT_PATH}"/bin/dockerise.inc.bash

php8.2 "${ROOT_DIR}"/bin/ci/validate.php "${@}"
php8.2 "${ROOT_PATH}"/bin/ci/validate.php "${@}"
6 changes: 3 additions & 3 deletions bin/composer
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

set -eu

readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/..")"
. "${ROOT_DIR}"/bin/common.inc.sh
BIN_DIR=bin COMPOSER_HOME=/app/var/composer . "${ROOT_DIR}"/bin/dockerise.inc.bash
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/..")"
. "${ROOT_PATH}"/bin/common.inc.sh
BIN_DIR=bin COMPOSER_HOME=/app/var/composer . "${ROOT_PATH}"/bin/dockerise.inc.bash

php /usr/local/bin/composer "${@}"
9 changes: 9 additions & 0 deletions bin/dev/generate-php-collections
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -eu

readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
source "${ROOT_PATH}"/bin/common.inc.sh
BIN_DIR=bin/dev COMPOSER_HOME=/app/var/composer source "${ROOT_PATH}"/bin/dockerise.inc.bash

php /app/bin/dev/generate-php-collections.php
33 changes: 33 additions & 0 deletions bin/dev/generate-php-collections.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

use Steevanb\PhpCollection\{
Maker\ObjectCollectionMaker,
Maker\ObjectNullableCollectionMaker
};

$rootPath = dirname(__DIR__, 2);

require $rootPath . '/vendor/autoload.php';

$interfaces = [
'\\' . BackedEnum::class,
'\\' . Countable::class,
'\\' . DateTimeInterface::class,
'\\' . JsonSerializable::class,
'\\' . Serializable::class,
'\\' . Stringable::class,
'\\' . UnitEnum::class
];

$maker = new ObjectCollectionMaker();
$nullableMaker = new ObjectNullableCollectionMaker();

foreach ($interfaces as $interface) {
echo 'Generate collection for ' . $interface . '.' . "\n";
$maker->make($interface, $rootPath . '/src/ObjectCollection', 'Steevanb\\PhpCollection\\ObjectCollection');

echo 'Generate nullable collection for ' . $interface . '.' . "\n";
$nullableMaker->make($interface, $rootPath . '/src/ObjectCollection', 'Steevanb\\PhpCollection\\ObjectCollection');
}
6 changes: 3 additions & 3 deletions bin/dev/start
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

set -eu

readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
source "${ROOT_DIR}"/bin/common.inc.sh
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
source "${ROOT_PATH}"/bin/common.inc.sh

docker pull "${CI_DOCKER_IMAGE_NAME}"
"${ROOT_DIR}"/bin/composer up
"${ROOT_PATH}"/bin/composer up
2 changes: 1 addition & 1 deletion bin/docker-build.inc.bash
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function buildDockerImage() {
--build-arg DOCKER_UID="$(id -u)" \
--build-arg DOCKER_GID="$(id -g)" \
${refreshArguments} \
"${ROOT_DIR}"
"${ROOT_PATH}"
}

function pushDockerImage() {
Expand Down
2 changes: 1 addition & 1 deletion bin/dockerise.inc.bash
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if ! ${isInDocker}; then
--rm \
--tty \
${interactiveParameter} \
--volume "${ROOT_DIR}":/app \
--volume "${ROOT_PATH}":/app \
--user "$(id -u)":"$(id -g)" \
--entrypoint "${BIN_DIR}"/"$(basename "${0}")" \
--workdir /app \
Expand Down
8 changes: 4 additions & 4 deletions bin/release/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

set -eu

readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_DIR}"/bin/common.inc.sh
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_PATH}"/bin/common.inc.sh
BIN_DIR=bin/release \
DOCKER_IMAGE_NAME="${RELEASE_DOCKER_IMAGE_NAME}" \
. "${ROOT_DIR}"/bin/dockerise.inc.bash
. "${ROOT_PATH}"/bin/dockerise.inc.bash

php "${ROOT_DIR}"/bin/release/changelog.php "${1}"
php "${ROOT_PATH}"/bin/release/changelog.php "${1}"
6 changes: 3 additions & 3 deletions bin/release/code-lines
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

set -eu

readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_DIR}"/bin/common.inc.sh
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_PATH}"/bin/common.inc.sh
BIN_DIR=bin/release \
DOCKER_IMAGE_NAME="${RELEASE_DOCKER_IMAGE_NAME}" \
. "${ROOT_DIR}"/bin/dockerise.inc.bash
. "${ROOT_PATH}"/bin/dockerise.inc.bash

readonly lines=$(cloc \
--exclude-dir=.idea,var,vendor \
Expand Down
8 changes: 4 additions & 4 deletions bin/release/docker
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

set -eu

readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
source "${ROOT_DIR}"/bin/common.inc.sh
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
source "${ROOT_PATH}"/bin/common.inc.sh

DOCKER_IMAGE_NAME="${RELEASE_DOCKER_IMAGE_NAME}" \
DOCKER_FILE_PATH="${ROOT_DIR}"/docker/release/Dockerfile \
source "${ROOT_DIR}"/bin/docker-build.inc.bash
DOCKER_FILE_PATH="${ROOT_PATH}"/docker/release/Dockerfile \
source "${ROOT_PATH}"/bin/docker-build.inc.bash
8 changes: 4 additions & 4 deletions bin/release/env
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

set -eu

readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_DIR}"/bin/common.inc.sh
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_PATH}"/bin/common.inc.sh
BIN_DIR=bin/release \
DOCKER_IMAGE_NAME="${RELEASE_DOCKER_IMAGE_NAME}" \
. "${ROOT_DIR}"/bin/dockerise.inc.bash
. "${ROOT_PATH}"/bin/dockerise.inc.bash

"${ROOT_DIR}"/bin/composer install
"${ROOT_PATH}"/bin/composer install
12 changes: 6 additions & 6 deletions bin/release/phpunit-coverage
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

set -eu

readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_DIR}"/bin/common.inc.sh
readonly ROOT_PATH="$(realpath "$(dirname "$(realpath "$0")")/../..")"
. "${ROOT_PATH}"/bin/common.inc.sh
BIN_DIR=bin/release \
DOCKER_IMAGE_NAME="${RELEASE_DOCKER_IMAGE_NAME}" \
. "${ROOT_DIR}"/bin/dockerise.inc.bash
. "${ROOT_PATH}"/bin/dockerise.inc.bash

set +e
XDEBUG_MODE=coverage \
php \
vendor/bin/phpunit \
--bootstrap "${COMPOSER_HOME_SYMFONY_6_1}"/vendor/autoload.php \
--coverage-xml "${ROOT_DIR}"/var/release/phpunit/coverage/xml \
--configuration "${ROOT_DIR}"/config/ci/phpunit.php-8.1.xml \
--coverage-xml "${ROOT_PATH}"/var/release/phpunit/coverage/xml \
--configuration "${ROOT_PATH}"/config/ci/phpunit.php-8.1.xml \
1>/dev/null \
2>&1
set -e

php "${ROOT_DIR}"/bin/release/phpunit-coverage-percent.php
php "${ROOT_PATH}"/bin/release/phpunit-coverage-percent.php
Loading
Loading