Skip to content
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
42 changes: 39 additions & 3 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,44 @@
FROM splitbrain/phpfarm:jessie
FROM debian:trixie-slim

RUN apt-get update && apt-get install -y git zip
# Prevent interactive prompts
ENV DEBIAN_FRONTEND=noninteractive

# Install dependencies
RUN apt-get update && apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
git \
lsb-release \
unzip \
zip \
&& curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list \
&& apt-get update

# Supported PHP Versions
ENV PHP_VERSIONS="7.4 8.0 8.1 8.2 8.3 8.4 8.5"

# Install all PHP versions using a loop
RUN for ver in $PHP_VERSIONS; do \
apt-get install -y \
php${ver}-cli php${ver}-xml php${ver}-mbstring php${ver}-soap; \
done \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# Create symlinks (php-X.Y) using the same list
RUN for ver in $PHP_VERSIONS; do \
ln -s /usr/bin/php${ver} /usr/bin/php-${ver}; \
done

# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# Set working directory
WORKDIR /var/www

# Copy project files
COPY . /var/www/

WORKDIR /var/www/
# Default command
CMD ["bash"]
3 changes: 2 additions & 1 deletion .github/workflows/sonars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- release/*
pull_request:
types: [ opened, synchronize, reopened ]
concurrency: sonars
jobs:
sonarcloud:
name: Sonars
Expand Down Expand Up @@ -42,7 +43,7 @@ jobs:
run: sed -i 's@'$GITHUB_WORKSPACE/'@''@g' coverage.xml report.xml

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
uses: SonarSource/sonarqube-scan-action@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule ".docker"]
path = .docker
url = git@github.com:WsdlToPhp/DockerCommonImage.git
4 changes: 3 additions & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
'no_whitespace_in_blank_line' => true,
'ternary_operator_spaces' => true,
'cast_spaces' => true,
'trailing_comma_in_multiline' => true
'trailing_comma_in_multiline' => true,
'phpdoc_separation' => false,
'single_line_empty_body' => false,
))
->setFinder($finder);
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
PHP_VERSION ?= php-7.4
CONTAINER_NAME ?= package_base
COMPOSER ?= /usr/bin/composer
DOCKER_COMPOSE ?= docker compose
DOCKER_EXEC_CONTAINER ?= docker exec -t $(CONTAINER_NAME)

.PHONY: bash build cs-fixer down install phpstan phpunit rector up update

bash:
$(DOCKER_EXEC_CONTAINER) bash

build:
$(DOCKER_COMPOSE) build

cs-fixer:
$(DOCKER_EXEC_CONTAINER) $(PHP_VERSION) vendor/bin/php-cs-fixer fix --ansi --diff --verbose

down:
$(DOCKER_COMPOSE) down

install:
$(DOCKER_EXEC_CONTAINER) $(PHP_VERSION) $(COMPOSER) install

phpstan:
$(DOCKER_EXEC_CONTAINER) $(PHP_VERSION) vendor/bin/phpstan analyze src --level=2

phpunit:
$(DOCKER_EXEC_CONTAINER) $(PHP_VERSION) vendor/bin/phpunit

rector:
$(DOCKER_EXEC_CONTAINER) $(PHP_VERSION) vendor/bin/rector process

up:
$(DOCKER_COMPOSE) up -d

update:
$(DOCKER_EXEC_CONTAINER) $(PHP_VERSION) $(COMPOSER) update
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@
"phpstan": "vendor/bin/phpstan analyze src --level=5"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "~3.0",
"phpstan/phpstan": "^1.4",
"phpunit/phpunit": "^9"
"friendsofphp/php-cs-fixer": "^3.0",
"phpstan/phpstan": "^2",
"phpunit/phpunit": "^9",
"rector/rector": "^2"
},
"autoload": {
"psr-4": {
Expand Down
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.4'

services:
php:
build:
Expand All @@ -8,3 +6,4 @@ services:
volumes:
- .:/var/www:rw
container_name: package_base
tty: true
35 changes: 35 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Php84\Rector\Param\ExplicitNullableParamTypeRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNativeCallRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedPropertyRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__.'/src',
__DIR__.'/tests',
]);
$rectorConfig->skip([
__DIR__.'/tests/resources',
]);
// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_74,
]);

// replace fully qualified class name by use statements
$rectorConfig->importShortClasses(false);
// keep native PHP class short name import
$rectorConfig->importNames();

// register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
$rectorConfig->rule(ReturnTypeFromStrictNativeCallRector::class);
$rectorConfig->rule(ReturnTypeFromStrictTypedPropertyRector::class);
$rectorConfig->rule(ExplicitNullableParamTypeRector::class);
};
2 changes: 1 addition & 1 deletion src/AbstractSoapClientBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,6 @@ public function getOutputHeaders(): array
*/
public function __toString(): string
{
return get_called_class();
return static::class;
}
}
4 changes: 2 additions & 2 deletions src/AbstractStructBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function jsonSerialize(): array
*/
public static function __set_state(array $array): StructInterface
{
$reflection = new ReflectionClass(get_called_class());
$reflection = new ReflectionClass(static::class);
$object = $reflection->newInstance();
foreach ($array as $name => $value) {
$object->setPropertyValue($name, $value);
Expand Down Expand Up @@ -79,6 +79,6 @@ public function getPropertyValue(string $name)
*/
public function __toString(): string
{
return get_called_class();
return static::class;
}
}
2 changes: 1 addition & 1 deletion src/AbstractStructEnumBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ public static function valueIsValid($value): bool
*/
public function __toString(): string
{
return get_called_class();
return static::class;
}
}
4 changes: 2 additions & 2 deletions tests/CustomSoapClientService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Services can specify a custom SoapClient class
* to be used instead of PHP default by overriding
* the constant below.
*
*
* @see \WsdlToPhp\PackageBase\SoapClientInterface
* @see \WsdlToPhp\PackageBase\AbstractSoapClientBase :: getSoapClientClassName()
*/
Expand All @@ -22,5 +22,5 @@ class CustomSoapClientService extends AbstractSoapClientBase
* Custom SoapClient class used for current service.
*/
const DEFAULT_SOAP_CLIENT_CLASS = Client::class;

}
2 changes: 1 addition & 1 deletion tests/SoapClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testSoapClientNameDefault(): void
public function testCustomSoapClientNameReadFromConstant()
{
$defaultService = new DefaultSoapClientService();
$customService = new CustomSoapClientService();
$customService = new CustomSoapClientService();

$this->assertSame(SoapClientBase::class, $defaultService->getSoapClientClassName());
$this->assertSame(Client::class, $customService->getSoapClientClassName());
Expand Down