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
12 changes: 6 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: 2
updates:
- package-ecosystem: composer
directory: "/"
schedule:
interval: daily
time: "04:00"
open-pull-requests-limit: 10
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "daily"
time: "04:00"
open-pull-requests-limit: 10
53 changes: 34 additions & 19 deletions .github/workflows/branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,37 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run test suite
run: composer run-script php-cs-fixer-check && composer run-script test
- uses: actions/checkout@v3

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: composer:v2
coverage: xdebug

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run test suite
run: composer run-script php-cs-fixer-check && composer run-script test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./build/logs/clover.xml
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

16 changes: 4 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,20 @@ clean-dependencies: ## Clean dev dependencies
# Not implemented
.PHONY: clean-dependencies

build-php7: ## Build PHP7 container
build: ## Build PHP7 container
# Hint: force a rebuild by passing --no-cache
@UID=$(UID) GID=$(GID) docker-compose build --no-cache php7
@UID=$(UID) GID=$(GID) docker-compose build --no-cache php
.PHONY: install-web

stop: ## Stop running containers
@UID=$(UID) GID=$(GID) docker-compose stop
.PHONY: stop

shell-php7: ## Start an interactive shell session for PHP7 container
shell: ## Start an interactive shell session for PHP7 container
# Hint: adjust UID and GID to 0 if you want to use the shell as root
@UID=$(UID) GID=$(GID) docker-compose run --rm -w /var/www/html -e SHELL_VERBOSITY=1 php7 bash
@UID=$(UID) GID=$(GID) docker-compose run --rm -w /var/www/html -e SHELL_VERBOSITY=1 php bash
.PHONY: shell

test: ## Run all unit tests
test: php7-tests
.PHONY: test

test-php7: ## Run php unit tests
# Not implemented
.PHONY: php7-tests

watch-logs: ## Open a tail on all the logs
@UID=$(UID) GID=$(GID) docker-compose logs -f -t
.PHONY: watch-logs
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
],
"minimum-stability": "dev",
"require": {
"php": ">7.1.3",
"php": ">=8.1",
"ext-mbstring": "*",
"ext-json": "*",
"ext-simplexml": "*",
"ext-dom": "*"
},
"require-dev": {
"phpunit/phpunit": "^5.7 || ^6.5 || ^7.0 || ^8.0",
"friendsofphp/php-cs-fixer": "^2.19 || ^3.0"
"phpunit/phpunit": "^9.0",
"friendsofphp/php-cs-fixer": "^3.0"
},
"autoload": {
"psr-4": {
Expand Down
6 changes: 2 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
version: '3'

services:
php7:
php:
build:
context: ./docker/php/
dockerfile: Dockerfile.php7
dockerfile: Dockerfile.php8
volumes:
- .:/var/www/html
- ./docker/php/conf.d/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
Expand Down
10 changes: 6 additions & 4 deletions docker/php/Dockerfile.php7 → docker/php/Dockerfile.php8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.4-fpm
FROM php:8.1-fpm

ENV APP_DIR /var/www/html

Expand All @@ -8,9 +8,11 @@ RUN apt-get update && apt-get install -y \
git \
curl \
zip \
unzip
unzip \
&& rm -rf /var/lib/apt/lists/*

RUN pecl install xdebug-3.1.5 \
# Install and enable Xdebug (compatible version will be chosen automatically)
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug

# Get latest Composer
Expand All @@ -23,4 +25,4 @@ WORKDIR $APP_DIR
COPY ./docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh

CMD /docker-entrypoint.sh
CMD ["/docker-entrypoint.sh"]
2 changes: 0 additions & 2 deletions src/Contracts/ValidationRuleInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ interface ValidationRuleInterface
/**
* Determines if the validation rule passes. This is where we do the
* actual validation. If the validation passes return true else false.
*
* @param mixed $value
*/
public function passes($value, array $parameters): bool;

Expand Down
8 changes: 3 additions & 5 deletions src/Converter/XmlConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

namespace Oshomo\CsvUtils\Converter;

use DOMDocument;
use Oshomo\CsvUtils\Contracts\ConverterHandlerInterface;
use SimpleXMLElement;

class XmlConverter implements ConverterHandlerInterface
{
Expand Down Expand Up @@ -35,15 +33,15 @@ public function __construct(string $recordElement = self::DEFAULT_RECORD_ELEMENT
$this->recordElement = $recordElement;
}

$this->data = new SimpleXMLElement('<?xml version="1.0"?><data value=""></data>');
$this->data = new \SimpleXMLElement('<?xml version="1.0"?><data value=""></data>');
}

public function getExtension(): string
{
return self::FILE_EXTENSION;
}

protected function toXml(array $data, SimpleXMLElement $xmlData): void
protected function toXml(array $data, \SimpleXMLElement $xmlData): void
{
foreach ($data as $key => $value) {
if (is_numeric($key)) {
Expand All @@ -67,7 +65,7 @@ public function convert(array $data): ConverterHandlerInterface

public function write(string $filename): bool
{
$dom = new DOMDocument('1.0');
$dom = new \DOMDocument('1.0');

$dom->preserveWhiteSpace = false;

Expand Down
10 changes: 2 additions & 8 deletions src/Helpers/FormatsMessages.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,14 @@ protected function ruleToLower(string $rule): ?string

/**
* Replace all error message place-holders with actual values.
*
* @param mixed $value
*/
protected function makeReplacements(
string $message,
string $attribute,
$value,
ValidationRuleInterface $rule,
array $parameters,
int $lineNumber
int $lineNumber,
): string {
$message = $this->replaceAttributePlaceholder($message, $attribute);

Expand All @@ -97,7 +95,7 @@ protected function makeReplacements(
protected function replaceParameterPlaceholder(
string $message,
array $allowedParameters,
array $parameters
array $parameters,
): string {
return str_replace($allowedParameters, $parameters, $message);
}
Expand All @@ -112,8 +110,6 @@ protected function replaceAttributePlaceholder(string $message, string $attribut

/**
* Replace the :value placeholder in the given message.
*
* @param mixed $value
*/
protected function replaceValuePlaceholder(string $message, $value): string
{
Expand All @@ -122,8 +118,6 @@ protected function replaceValuePlaceholder(string $message, $value): string

/**
* Replace the :line placeholder in the given message.
*
* @return mixed
*/
protected function replaceErrorLinePlaceholder(string $message, int $lineNumber)
{
Expand Down
2 changes: 0 additions & 2 deletions src/Rules/AsciiOnly.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ class AsciiOnly implements ValidationRuleInterface
{
/**
* Determine if the validation rule passes.
*
* @param mixed $value
*/
public function passes($value, array $parameters): bool
{
Expand Down
2 changes: 0 additions & 2 deletions src/Rules/Between.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ public function allowedParameters(): array

/**
* Determine if the validation rule passes.
*
* @param mixed $value
*/
public function passes($value, array $parameters): bool
{
Expand Down
2 changes: 0 additions & 2 deletions src/Rules/ClosureValidationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ public function __construct(\Closure $callback)

/**
* Determine if the validation rule passes.
*
* @param mixed $value
*/
public function passes($value, array $parameters): bool
{
Expand Down
2 changes: 0 additions & 2 deletions src/Rules/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class Url implements ValidationRuleInterface

/**
* Determine if the validation rule passes.
*
* @param mixed $value
*/
public function passes($value, array $parameters): bool
{
Expand Down
3 changes: 1 addition & 2 deletions src/Validator/ValidationRuleParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Oshomo\CsvUtils\Validator;

use Closure;
use Oshomo\CsvUtils\Contracts\ValidationRuleInterface;
use Oshomo\CsvUtils\Contracts\ValidationRuleInterface as ValidationRule;
use Oshomo\CsvUtils\Rules\ClosureValidationRule;
Expand All @@ -18,7 +17,7 @@ class ValidationRuleParser
*/
public static function parse($rule): array
{
if ($rule instanceof Closure) {
if ($rule instanceof \Closure) {
return [new ClosureValidationRule($rule), []];
}

Expand Down
10 changes: 2 additions & 8 deletions src/Validator/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,12 @@ protected function passesParameterCheck($rule, array $parameters): bool

/**
* Validate an attribute using a custom rule object.
*
* @param mixed $value
*/
protected function validateUsingCustomRule(
string $attribute,
$value,
array $parameters,
ValidationRuleInterface $rule
ValidationRuleInterface $rule,
): void {
if (!$rule->passes($value, $parameters)) {
$this->addFailure($rule->message(), $attribute, $value, $rule, $parameters);
Expand All @@ -378,15 +376,13 @@ protected function validateUsingCustomRule(

/**
* Add a failed rule and error message to the collection.
*
* @param mixed $value
*/
protected function addFailure(
string $message,
string $attribute,
$value,
ValidationRuleInterface $rule,
array $parameters = []
array $parameters = [],
): void {
$this->currentRowMessages[] = $this->makeReplacements(
$message,
Expand All @@ -400,8 +396,6 @@ protected function addFailure(

/**
* Get the value of a given attribute.
*
* @return mixed
*/
protected function getValue(string $attribute)
{
Expand Down
Loading