Skip to content
Snippets Groups Projects
Commit 394ff934 authored by Anastaszor's avatar Anastaszor
Browse files

Added base files

parents
No related branches found
No related tags found
No related merge requests found
Pipeline #977706494 failed
; This file is for unifying the coding style for different editors and IDEs.
; More information at http://editorconfig.org
root = true
[*]
end_of_line = lf
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = false
[*.bat]
indent_style = tab
tab_width = 4
end_of_line = crlf
charset = latin1
[*.json]
indent_style = tab
tab_width = 4
[*.php]
indent_style = tab
tab_width = 4
[*.yml]
indent_style = space
indent_size = 4
[*.yaml]
indent_style = space
indent_size = 4
*.bin
*.cache
*.doc
*.docx
*.gz
*.lock
*.odf
*.odg
*.odp
*.ods
*.odt
*.phar
*.ppt
*.pptx
*.xls
*.xlsx
*.zip
/vendor/
/build/
.php_cs
# phpstorm project files
.idea
# netbeans project files
nbproject
# zend studio for eclipse project files
.buildpath
.project
.settings
.metadata
# Folder view configuration files
.DS_Store
Desktop.ini
# Thumbnail cache files
._*
Thumbs.db
# Files that might appear on external disks
.Spotlight-V100
.Trashes
/lost+found/
# HELP : https://gitlab.com/help/ci/yaml/README.md
# Global defaults for all jobs
default:
interruptible: true
stages:
- test
variables:
ARTIFACT_DOWNLOAD_ATTEMPTS: 3
EXECUTOR_JOB_SECTION_ATTEMPTS: 3
GET_SOURCES_ATTEMPTS: 3
RESTORE_CACHE_ATTEMPTS: 3
TRANSFER_METER_FREQUENCY: "2s"
ARTIFACT_COMPRESSION_LEVEL: "fast"
CACHE_COMPRESSION_LEVEL: "fastest"
CACHE_REQUEST_TIMEOUT: 5
XDEBUG_MODE: coverage
# // ---- Jobs ---- \\ #
# Find container registries images at
# https://gitlab.com/php-extended/docker-images/container_registry/
# And image files at
# https://gitlab.com/php-extended/docker-images
php-7.4:
stage: test
image: "$CI_REGISTRY/php-extended/docker-images:php-7.4-cli-dev"
except:
- tags
retry:
max: 2
when:
- runner_system_failure
- stuck_or_timeout_failure
script:
- ./runtests.sh --ci
coverage: '/^\s*Lines: \s*\d+.\d+\%/'
artifacts:
when: always
expire_in: 1 month
reports:
junit: ./build/report.xml
php-8.0:
stage: test
image: "$CI_REGISTRY/php-extended/docker-images:php-8.0-cli-dev"
except:
- tags
retry:
max: 2
when:
- runner_system_failure
- stuck_or_timeout_failure
script:
- ./runtests.sh --ci
coverage: '/^\s*Lines: \s*\d+.\d+\%/'
artifacts:
when: always
expire_in: 1 month
reports:
junit: ./build/report.xml
php-8.1:
stage: test
image: "$CI_REGISTRY/php-extended/docker-images:php-8.1-cli-dev"
except:
- tags
retry:
max: 2
when:
- runner_system_failure
- stuck_or_timeout_failure
script:
- ./runtests.sh --ci
coverage: '/^\s*Lines: \s*\d+.\d+\%/'
artifacts:
when: always
expire_in: 1 month
reports:
junit: ./build/report.xml
php-8.2:
stage: test
image: "$CI_REGISTRY/php-extended/docker-images:php-8.2-cli-dev"
except:
- tags
retry:
max: 2
when:
- runner_system_failure
- stuck_or_timeout_failure
script:
- ./runtests.sh --ci
coverage: '/^\s*Lines: \s*\d+.\d+\%/'
artifacts:
when: always
expire_in: 1 month
reports:
junit: ./build/report.xml
This diff is collapsed.
LICENSE 0 → 100644
MIT License
Copyright (c) 2015-NOW() Anastaszor
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# php-extended/php-arrayable-object
A very basic psr-3 compliant logger to log activity in the console.
![coverage](https://gitlab.com/php-extended/php-arrayable-object/badges/master/pipeline.svg?style=flat-square)
![build status](https://gitlab.com/php-extended/php-arrayable-object/badges/master/coverage.svg?style=flat-square)
## Installation
The installation of this library is made via composer and the autoloading of
all classes of this library is made through their autoloader.
- Download `composer.phar` from [their website](https://getcomposer.org/download/).
- Then run the following command to install this library as dependency :
- `php composer.phar php-extended/php-arrayable-object ^6`
## Basic Usage
This library gives an `ArrayableTrait` that implements the `toArray()`
method. Then any object that implements this trait may be called the `toArray()`
method to return an array that represents its internal state.
## License
MIT (See [license file](LICENSE)).
{
"name" : "php-extended/php-arrayable-object",
"description" : "A library that implements the php-extended/php-arrayable-interface library",
"type" : "library",
"homepage" : "https://gitlab.com/php-extended/php-arrayable-object",
"license" : "MIT",
"authors" : [{
"name" : "Anastaszor",
"homepage" : "https://gitlab.com/Anastaszor",
"role" : "developer"
}
],
"support" : {
"issues" : "https://gitlab.com/php-extended/php-arrayable-object/issues",
"source" : "https://gitlab.com/php-extended/php-arrayable-object"
},
"require" : {
"php" : ">=7.4",
"php-extended/php-arrayable-interface" : "^6"
},
"require-dev" : {
"php-extended/placeholder-phpunit" : "^9"
},
"autoload" : {
"psr-4" : {
"PhpExtended\\Arrayable\\" : "src"
}
},
"keywords" : [
"php",
"arrayable",
"object",
"implementation"
]
}
\ No newline at end of file
<?xml version="1.0"?>
<ruleset name="PHPMD Rule Set"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
>
<description>Rules sets that applies to php packages</description>
<rule ref="rulesets/codesize.xml">
<exclude name="CyclomaticComplexity" />
<exclude name="TooManyPublicMethods" />
</rule>
<rule ref="rulesets/cleancode.xml">
<exclude name="BooleanArgumentFlag" />
<exclude name="ErrorControlOperator" />
<exclude name="StaticAccess" />
</rule>
<rule ref="rulesets/controversial.xml">
<exclude name="CamelCasePropertyName" />
<exclude name="CamelCaseMethodName" />
</rule>
<rule ref="rulesets/design.xml" />
<rule ref="rulesets/naming.xml">
<exclude name="LongClassName" />
<exclude name="LongVariable" />
<exclude name="ShortVariable" />
</rule>
<rule ref="rulesets/unusedcode.xml" />
<rule ref="rulesets/cleancode.xml/StaticAccess">
<priority>1</priority>
<properties>
<property name="exceptions" value="\DateTime, \DateInterval, \DateTimeImmutable, \Locale" />
</properties>
</rule>
<rule ref="rulesets/codesize.xml/CyclomaticComplexity">
<priority>1</priority>
<properties>
<property name="reportLevel" value="13" />
<property name="showClassesComplexity" value="true" />
<property name="showMethodsComplexity" value="true" />
</properties>
</rule>
<rule ref="rulesets/codesize.xml/TooManyPublicMethods">
<priority>1</priority>
<properties>
<property name="maxmethods" value="15" />
<property name="ignorepattern" value="(^(set|get|is|has|__)|^(count|current|next|key|valid|rewind)$)i" />
</properties>
</rule>
<rule ref="rulesets/controversial.xml/CamelCasePropertyName">
<priority>1</priority>
<properties>
<property name="allow-underscore" value="true" />
<property name="allow-underscore-test" value="true" />
</properties>
</rule>
<rule ref="rulesets/controversial.xml/CamelCaseMethodName">
<priority>1</priority>
<properties>
<property name="allow-underscore" value="true" />
<property name="allow-underscore-test" value="true" />
</properties>
</rule>
<rule ref="rulesets/naming.xml/LongClassName">
<priority>1</priority>
<properties>
<property name="maximum" value="40" />
<property name="subtract-suffixes" value="Interface" />
</properties>
</rule>
<rule ref="rulesets/naming.xml/LongVariable">
<priority>1</priority>
<properties>
<property name="maximum" value="40" />
</properties>
</rule>
<rule ref="rulesets/naming.xml/ShortVariable">
<priority>1</priority>
<properties>
<property name="exceptions" value="id" />
</properties>
</rule>
</ruleset>
parameters:
level: 8
paths:
- src
<?xml version="1.0" ?>
<psalm
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://psalm.dev https://psalm.dev/schema/config"
xmlns:xi="http://www.w3.org/2001/XInclude"
errorLevel="1"
reportMixedIssues="true"
resolveFromConfigFile="true"
useDocblockTypes="true"
useDocblockPropertyTypes="true"
usePhpDocMethodsWithoutMagicCall="true"
usePhpDocPropertiesWithoutMagicCall="true"
strictBinaryOperands="true"
rememberPropertyAssignmentsAfterCall="true"
allowStringToStandInForClass="true"
memoizeMethodCallResults="false"
hoistConstants="false"
addParamDefaultToDocblockType="false"
checkForThrowsDocblock="true"
checkForThrowsInGlobalScope="true"
ignoreInternalFunctionFalseReturn="false"
ignoreInternalFunctionNullReturn="false"
inferPropertyTypesFromConstructor="true"
findUnusedVariablesAndParams="true"
findUnusedCode="true"
findUnusedPsalmSuppress="true"
findUnusedBaselineEntry="true"
ensureArrayStringOffsetsExist="true"
ensureArrayIntOffsetsExist="true"
skipChecksOnUnresolvableIncludes="false"
sealAllMethods="true"
reportInfo="true"
allowNamedArgumentCalls="true"
triggerErrorExits="default"
throwExceptionOnError="false"
hideExternalErrors="true"
allowFileIncludes="true"
>
<!-- https://psalm.dev -->
<!-- error levels (1-8) : https://psalm.dev/docs/running_psalm/error_levels/ -->
<!-- configuration options : https://psalm.dev/docs/running_psalm/configuration/ -->
<projectFiles>
<directory name="./src" />
</projectFiles>
<issueHandlers>
<!-- Lower Forbidden Code (var_dump) to help debugging -->
<ForbiddenCode errorLevel="info" />
<!-- for php7.3 and 7.4, cannot detect the \Stringable interface in library -->
<MissingDependency errorLevel="suppress" />
<!-- Suppress MixedAssignment : some methods cannot return typed data -->
<MixedAssignment errorLevel="suppress" />
<!-- Suppress PossiblyUnusedMethod : we are writing libraries -->
<PossiblyUnusedMethod errorLevel="suppress" />
<!-- Suppress PossiblyUnusedParam : we are writing libraries -->
<PossiblyUnusedParam errorLevel="suppress" />
<!-- Suppress PossiblyUnusedProperty : we are writing libraries -->
<PossiblyUnusedProperty errorLevel="suppress" />
<!-- Suppress PossiblyUnusedReturnValue : we are writing libraries -->
<PossiblyUnusedReturnValue errorLevel="suppress" />
<!-- Suppress RedundantCast : sometimes does not detect nullable into non nullable usage -->
<RedundantCast errorLevel="suppress" />
<!-- Suppress RedundantCastGivenDocblockType : we cant be sure if dockblock is enforced -->
<RedundantCastGivenDocblockType errorLevel="suppress" />
<!-- Suppress RedundantConditionGivenDocblockType : we cant be sure if dockblock is enforced -->
<RedundantConditionGivenDocblockType errorLevel="suppress" />
<!-- for php7.3 and 7.4, cannot detect the \Stringable interface in library -->
<UndefinedClass errorLevel="suppress" />
<!-- Suppress UnnecessaryVarAnnotation : to have eclipse code completion -->
<UnnecessaryVarAnnotation errorLevel="suppress" />
<!-- Suppress UnusedClass : we are writing libraries -->
<UnusedClass errorLevel="suppress" />
<!-- Lower Unused Suppress to help compatibility across platforms -->
<UnusedPsalmSuppress errorLevel="info" />
</issueHandlers>
</psalm>
#!/bin/bash
set -eu
IFS=$'\n\t'
CURRDIR="$(dirname "$0")"
CURRDIR="$(realpath "$CURRDIR")"
PAREDIR="$(realpath "$CURRDIR/..")"
cd "$CURRDIR"
# {{{ FUNCTIONS
# Writes into the console the date and a message
# @var $1 string the message to write
log() {
echo -e "[$(date '+%Y-%m-%d %H:%M:%S')] $1"
}
# Writes into the console the given string in WHITE
# @var $1 string the message to write
log_info() {
log "[ INFO ] $1"
}
# Writes into the console the given string in RED
# @var $1 string the message to write
log_error() {
log "[ \033[31mERROR\033[0m ] $1"
}
# Writes into the console the given string in GREEN
# @var $1 string the message to write
log_success() {
log "[ \033[32mSUCCESS\033[0m ] $1"
}
# Writes into the console the given string in YELLOW
log_warning() {
log "[ \033[33mWARNING\033[0m ] $1"
}
# Exits prematurely if the $1 arg is not zero and if this script is running in CI
# @var $1 integer the exit code of previous function call
exit_if_failed_outside_ci() {
if [ "$RUN_IN_CI" == "0" ]
then
if [ "$1" != "0" ]
then
exit "$1"
fi
fi
}
# Function to copy the file at $1 to $2 if it exists at the source
# @var $1 string source the file to check if it exists
# @var $2 string dest the path where to copy it if we found it
copy_if_exists() {
if [ "$RUN_IN_CI" == "1" ]
then
if [ -f "$1" ]
then
cp "$1" "$2"
fi
fi
}
# Function to check the availability of a given binary
# @var $1 string the name of the binary to check
check_install() {
local RES
set +e
command -v "$1" > /dev/null 2>&1
RES=$?
set -e
if [ "$RES" != "0" ]
then
log_error "Failed to find $1, please install it"
exit 1
fi
}
# Function to download from $1 and store the result to $2
# @var $1 string the url to download
# @var $2 string the local path of the file to save
download() {
check_install "curl"
log_info "DOWNLOADING : $1"
log_info "WRITING TO : $2"
curl --location --progress-bar --fail --show-error "$1" --output "$2"
}
# Function to get the full release url for the given library
# @var $1 string the vendor name
# @var $2 string the library name
get_release_url() {
local API_URL
local RELEASE_URL
if [ "$2" == "phpunit" ]
then
echo "https://phar.phpunit.de/phpunit-9.phar"
else
check_install "curl"
check_install "jq"
check_install "sed"
API_URL="https://api.github.com/repos/$1/$2/releases"
RELEASE_URL=$(curl --location --progress-bar --fail --show-error "$API_URL" | jq '[.[]|.assets|.[]|.browser_download_url][0]' | sed 's/"//g')
echo "$RELEASE_URL"
fi
}
# Ensures that the given phar file is correctly installed
# @var $1 string the path of the file where to search it on the file system if available
# @var $2 string the path where the file should be executed
# @var $3 string the package vendor name in the github url
# @var $4 string the package library name in the github url
phar_install() {
local OLDPSTN
local RELEASE_URL
check_install "find"
copy_if_exists "$1" "$2"
set +e
OLDPSTN=$(find "$2" -mtime +7 -print > /dev/null 2>&1)
set -e
if [ ! -f "$2" ] || [ -n "$OLDPSTN" ]
then
RELEASE_URL=$(get_release_url "$3" "$4")
download "$RELEASE_URL" "$2"
else
log_warning "DO NOT INSTALL $3/$4 : not old enough"
fi
}
# Tries to install the dependancies with composer
composer_install() {
local COMPOSER_VERB
local COMPOSER_ING
local RET
printf "\n"
phar_install "/composer.phar" "$PAREDIR/composer.phar" "composer" "composer"
if [ ! -f "$CURRDIR/vendor/autoload.php" ]
then
COMPOSER_VERB="install"
COMPOSER_ING="INSTALLING"
else
COMPOSER_VERB="update"
COMPOSER_ING="UPDATING"
fi
log_info "$COMPOSER_ING composer dependancies"
set +e
php "$PAREDIR/composer.phar" "$COMPOSER_VERB" --ansi --no-interaction --no-progress --prefer-dist
RET=$?
set -e
return $RET
}
# Tries to install composer dependancies multiple times
# @var $1 integer the number of retries
composer_install_retry() {
local RET
local MAXLOOP
composer_install
RET=$?
MAXLOOP=$(($1))
if [ -z ${1+x} ]
then
MAXLOOP=3
fi
LOOP=0
while [[ $LOOP < $MAXLOOP && "$RET" != "0" ]]
do
sleep "$((39 * (LOOP + 1)))s"
LOOP=$((LOOP + 1))
composer_install
RET=$?
done
return $RET
}
# Rebuild the composer.json ordering all of its keys in the right order
rebuild_composer_json() {
if [ "$RUN_IN_CI" == "0" ]
then
printf "\n"
# we dont need to rebuild composer.json hence dont need jq when in CI
log_info "REORDERING : $CURRDIR/composer.json"
CURRCOMP=$(cat "$CURRDIR/composer.json")
# reorder composer.json according to schema
# https://getcomposer.org/doc/04-schema.md
# except minimum stability
# pretty print with tabs
# then ignore null fields
# then add space before colon
echo "$CURRCOMP" | jq --tab '{
name: .name,
description: .description,
version: .version,
type: .type,
keywords: .keywords,
homepage: .homepage,
readme: .readme,
time: .time,
license: .license,
authors: .authors,
support: .support,
funding: .funding,
require: .require,
"require-dev": ."require-dev",
conflict: .conflict,
replace: .replace,
provide: .provide,
suggest: .suggest,
autoload: .autoload,
"autoload-dev": ."autoload-dev",
"include-path": ."include-path",
"target-dir": ."target-dir",
"prefer-stable": ."prefer-stable",
repositories: .repositories,
config: .config,
scripts: .scripts,
extra: .extra,
bin: .bin,
archive: .archive,
abandoned: .abandoned,
"non-feature-branches": ."non-feature-branches"
} | del(.[] | nulls)' | sed 's/":/" :/g' | head -c -1 > "$CURRDIR/composer.json"
fi
}
# Checks whether the given piece of code exists in the codebase of this library
# and fails if this is the case
# @var $1 string the human readable value of the code checked for
# @var $2 string the regex for grep to be found
# @var $3 string the message in case this code is detected for correction
check_code() {
log_info "CHECK FOR $1 VALUES IN SOURCE CODE"
set +e
grep -q -r "$2" ./src --include="*.php"
RUN_RESULT=$((1 - $?))
set -e
if [ "$RUN_IN_CI" == "0" ]
then
if [ "$RUN_RESULT" != "0" ]
then
log_error "$3"
exit 10
fi
fi
return $RUN_RESULT
}
# Runs the php-cs-fixer binary and returns the result
run_phpcsfixer() {
RUN_RESULT_PHPCSFIXER=0
if [ "$PHPVERSIONINT" == "81" ]
then
printf "\n"
phar_install "/vendor/bin/php-cs-fixer" "$PAREDIR/php-cs-fixer.phar" "FriendsOfPHP" "PHP-CS-Fixer"
log_info "RUN PHP CS FIXER"
set +e
if [ "$RUN_IN_CI" == "0" ]
then
php "$PAREDIR/php-cs-fixer.phar" fix -vvv --allow-risky=yes
else
php "$PAREDIR/php-cs-fixer.phar" fix -v --allow-risky=yes --dry-run
fi
RUN_RESULT_PHPCSFIXER=$?
set -e
exit_if_failed_outside_ci $RUN_RESULT_PHPCSFIXER
else
log_info "SKIPPED php-cs-fixer : not php 8.1"
fi
printf "\n"
return $RUN_RESULT_PHPCSFIXER
}
# Runs the phpstan binary and returns the result
run_phpstan() {
phar_install "/vendor/bin/phpstan" "$PAREDIR/phpstan.phar" "phpstan" "phpstan"
log_info "RUN PHPSTAN"
set +e
php "$PAREDIR/phpstan.phar" --version
php "$PAREDIR/phpstan.phar" analyse --configuration="$CURRDIR/phpstan.neon" --error-format=gitlab --memory-limit 2G
RUN_RESULT_PHPSTAN=$?
set -e
exit_if_failed_outside_ci $RUN_RESULT_PHPSTAN
printf "\n"
return $RUN_RESULT_PHPSTAN
}
# Runs the psalm binary and returns the result
run_psalm() {
RUN_RESULT_PSALM=0
if (( PHPVERSIONINT >= 74 ))
then
phar_install "/vendor/bin/psalm" "$PAREDIR/psalm.phar" "vimeo" "psalm"
log_info "CLEAR PSALM CACHE"
rm -rf ~/.cache/psalm
log_info "RUN PSALM"
set +e
php "$PAREDIR/psalm.phar" --version
php "$PAREDIR/psalm.phar" --config="$CURRDIR/psalm.xml" --output-format=console --long-progress --stats --show-info=true --php-version="$PHPVERSION"
RUN_RESULT_PSALM=$?
set -e
exit_if_failed_outside_ci $RUN_RESULT_PSALM
printf "\n"
fi
return $RUN_RESULT_PSALM
}
# Runs the phpmd binary and returns the result
run_phpmd() {
phar_install "/vendor/bin/phpmd" "$PAREDIR/phpmd.phar" "phpmd" "phpmd"
log_info "RUN PHPMD"
set +e
php "$PAREDIR/phpmd.phar" --version
php "$PAREDIR/phpmd.phar" "$CURRDIR/src" ansi "$CURRDIR/phpmd.xml"
RUN_RESULT_PHPMD=$?
set -e
exit_if_failed_outside_ci $RUN_RESULT_PHPMD
printf "\n"
return $RUN_RESULT_PHPMD
}
# }}} END FUNCTIONS
# {{{ SCRIPT BEGINS HERE
check_install "cat"
check_install "curl"
check_install "grep"
check_install "head"
check_install "jq"
check_install "php"
check_install "sed"
printf "\n"
# @var PHPVERSION string the php version (we get "A.B")
# php -v :: PHP A.B.C (cli) (built: Aug XX YYYY HH:MM:SS) ( NTS )
PHPVERSION=$(php -r "echo \PHP_MAJOR_VERSION.'.'.\PHP_MINOR_VERSION;")
PHPVERSIONINT=$(($(php -r "echo \PHP_MAJOR_VERSION.\PHP_MINOR_VERSION;")))
log_info "RUNNING ON PHP : (string) $PHPVERSION / (int) $PHPVERSIONINT"
# @var RUN_IN_CI boolean whether this script runs in CI (gitlab...)
RUN_IN_CI=0
# argument management loop
# https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
for arg in "$@"
do
case $arg in
--ci*) RUN_IN_CI=1 ;;
*) ;;
esac
shift # remove arg from "$@" and reorder $ positions
done
# {{{ actual job done
rebuild_composer_json
composer_install_retry 3
EXIT_CODE=0
run_phpcsfixer
RUN_RESULT_PHPCSFIXER=$?
EXIT_CODE=$((EXIT_CODE + RUN_RESULT_PHPCSFIXER))
check_code 'MIXED ' 'mixed' "There are still 'mixed' values in the source code, please expand it with null|boolean|integer|float|string|object|array<integer|string, null|boolean|integer|float|string|object>"
RUN_RESULT_BAN_MIXED=$?
EXIT_CODE=$((EXIT_CODE + RUN_RESULT_BAN_MIXED))
check_code ': SELF ' ': self' "There are still ': self' return types values in the code, change it to the interface name."
RUN_RESULT_BAN_SELF=$?
EXIT_CODE=$((EXIT_CODE + RUN_RESULT_BAN_SELF))
check_code '@return X[] ' '@return .*\[\]' "There are still '@return X[]' return type values in the code, change it to array<integer|string, X>."
RUN_RESULT_BAN_RETURN_TAB=$?
EXIT_CODE=$((EXIT_CODE + RUN_RESULT_BAN_RETURN_TAB))
check_code '@var X[] ' '@var .*\[\]' "There are still '@var X[]' variable type values in the code, change it to array<integer|string, X>."
RUN_RESULT_BAN_VAR_TAB=$?
EXIT_CODE=$((EXIT_CODE + RUN_RESULT_BAN_VAR_TAB))
check_code '@param X[] ' '@param .*\[\]' "There are still '@param X[]' parameter type values in the code, change it to array<integer|string, X>."
RUN_RESULT_BAN_PARAM_TAB=$?
EXIT_CODE=$((EXIT_CODE + RUN_RESULT_BAN_PARAM_TAB))
check_code '?array ' '\?array' "There are still '?array' values in the code, make them non nullable."
RUN_RESULT_BAN_NULL_ARR=$?
EXIT_CODE=$((EXIT_CODE + RUN_RESULT_BAN_NULL_ARR))
check_code '?iterable ' '\?iterable' "There are still '?iterable' values in the code, make them non nullable."
RUN_RESULT_BAN_NULL_IBL=$?
EXIT_CODE=$((EXIT_CODE + RUN_RESULT_BAN_NULL_IBL))
check_code '?Iterator ' '\?Iterator' "There are still '?Iterator' values in the code, make them non nullable."
RUN_RESULT_BAN_NULL_ITE=$?
EXIT_CODE=$((EXIT_CODE + RUN_RESULT_BAN_NULL_ITE))
check_code '?Traversable' '\?Traversable' "There are still '?Traversable' values in the code, make them non nullable."
RUN_RESULT_BAN_NULL_TRV=$?
EXIT_CODE=$((EXIT_CODE + RUN_RESULT_BAN_NULL_TRV))
run_phpstan
RUN_RESULT_PHPSTAN=$?
EXIT_CODE=$((EXIT_CODE + RUN_RESULT_PHPSTAN))
run_psalm
RUN_RESULT_PSALM=$?
EXIT_CODE=$((EXIT_CODE + RUN_RESULT_PSALM))
run_phpmd
RUN_RESULT_PHPMD=$?
EXIT_CODE=$((EXIT_CODE + RUN_RESULT_PHPMD))
# }}}
# https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences
printf "\n"
PASSED="\033[32mSUCCESS\033[0m"
FAILED="\033[33mFAILED\033[0m"
log_info "---- CI/CD SCRIPT RESUME ----"
RESULT=$([ $RUN_RESULT_BAN_MIXED == 0 ] && echo -e "$PASSED" || echo -e "$FAILED")
log_info "RUN RESULT BAN MIXED : $RESULT"
RESULT=$([ $RUN_RESULT_BAN_SELF == 0 ] && echo -e "$PASSED" || echo -e "$FAILED")
log_info "RUN RESULT BAN RETURN SELF : $RESULT"
RESULT=$([ $RUN_RESULT_BAN_RETURN_TAB == 0 ] && echo -e "$PASSED" || echo -e "$FAILED")
log_info "RUN RESULT BAN RETURN TAB[] : $RESULT"
RESULT=$([ $RUN_RESULT_BAN_VAR_TAB == 0 ] && echo -e "$PASSED" || echo -e "$FAILED")
log_info "RUN RESULT BAN VAR TAB[] : $RESULT"
RESULT=$([ $RUN_RESULT_BAN_PARAM_TAB == 0 ] && echo -e "$PASSED" || echo -e "$FAILED")
log_info "RUN RESULT BAN PARAM TAB[] : $RESULT"
RESULT=$([ $RUN_RESULT_BAN_NULL_ARR == 0 ] && echo -e "$PASSED" || echo -e "$FAILED")
log_info "RUN RESULT BAN ?array : $RESULT"
RESULT=$([ $RUN_RESULT_BAN_NULL_IBL == 0 ] && echo -e "$PASSED" || echo -e "$FAILED")
log_info "RUN RESULT BAN ?iterable : $RESULT"
RESULT=$([ $RUN_RESULT_BAN_NULL_ITE == 0 ] && echo -e "$PASSED" || echo -e "$FAILED")
log_info "RUN RESULT BAN ?Iterator : $RESULT"
RESULT=$([ $RUN_RESULT_BAN_NULL_TRV == 0 ] && echo -e "$PASSED" || echo -e "$FAILED")
log_info "RUN RESULT BAN ?Traversable : $RESULT"
RESULT=$([ $RUN_RESULT_PHPCSFIXER == 0 ] && echo -e "$PASSED" || echo -e "$FAILED")
log_info "RUN RESULT PHPCSFIXER : $RESULT"
RESULT=$([ $RUN_RESULT_PHPMD == 0 ] && echo -e "$PASSED" || echo -e "$FAILED")
log_info "RUN RESULT PHPMD : $RESULT"
RESULT=$([ $RUN_RESULT_PHPSTAN == 0 ] && echo -e "$PASSED" || echo -e "$FAILED")
log_info "RUN RESULT PHPSTAN : $RESULT"
RESULT=$([ $RUN_RESULT_PSALM == 0 ] && echo -e "$PASSED" || echo -e "$FAILED")
log_info "RUN RESULT PSALM : $RESULT"
log_info "---- CI/CD END OF SCRIPT ----"
printf "\n"
log_info "EXIT CODE : $EXIT_CODE"
exit $EXIT_CODE
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment