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
26 changes: 26 additions & 0 deletions .distignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Version control
.git
.github
.gitignore
.distignore

# Development
tests
phpunit.xml
composer.json
composer.lock
DEVELOPMENT.md
API.md

# Build tools
node_modules
.env
.env.*

# IDE
.vscode
.idea
.DS_Store

# Logs
*.log
19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "ci"
include: "scope"
open-pull-requests-limit: 5

- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "deps"
include: "scope"
open-pull-requests-limit: 5
57 changes: 35 additions & 22 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,52 @@
name: PHP Composer
name: CI

on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
branches: [ "main" ]
branches: ["main"]

permissions:
contents: read

jobs:
build:

test:
name: Test (PHP ${{ matrix.php }})
runs-on: ubuntu-latest

strategy:
matrix:
php: ["8.2", "8.3", "8.4", "8.5"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none

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

- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Run tests
run: ./vendor/bin/pest

- 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-
format-check:
name: Check Code Style
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6

- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"

# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
# Docs: https://getcomposer.org/doc/articles/scripts.md
- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run test suite
run: ./vendor/bin/pest
- name: Check formatting
run: composer format:check
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Release

on:
push:
tags:
- "v*"

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"

- name: Install production dependencies
run: composer install --no-dev --optimize-autoloader

- name: Create release zip
run: |
mkdir -p release
rsync -av --exclude-from=.distignore . release/hellotext-wordpress/
cd release
zip -r hellotext-wordpress.zip hellotext-wordpress

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: release/hellotext-wordpress.zip
generate_release_notes: true
1 change: 1 addition & 0 deletions .php-cs-fixer.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"php":"8.4.8","version":"3.92.5:v3.92.5#260cc8c4a1d2f6d2f22cd4f9c70aa72e55ebac58","indent":" ","lineEnding":"\n","rules":{"binary_operator_spaces":{"default":"single_space"},"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"braces_position":{"classes_opening_brace":"same_line","functions_opening_brace":"same_line"},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_type_declaration":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"modifier_keywords":true,"new_with_parentheses":{"anonymous_class":true},"no_blank_lines_after_class_opening":true,"no_extra_blank_lines":{"tokens":["extra","throw","use"]},"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"sort_algorithm":"alpha"},"return_type_declaration":{"space_before":"none"},"short_scalar_cast":true,"single_import_per_statement":{"group_to_single_imports":false},"single_space_around_construct":{"constructs_followed_by_a_single_space":["abstract","as","case","catch","class","const_import","do","else","elseif","final","finally","for","foreach","function","function_import","if","insteadof","interface","namespace","new","private","protected","public","static","switch","trait","try","use","use_lambda","while"],"constructs_preceded_by_a_single_space":["as","else","elseif","use_lambda"]},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"unary_operator_spaces":{"only_dec_inc":true},"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":{"closure_fn_spacing":"one"},"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"trailing_comma_in_multiline":true,"single_quote":true,"no_unused_imports":true,"concat_space":{"spacing":"one"},"method_chaining_indentation":true,"no_spaces_around_offset":true,"no_whitespace_before_comma_in_array":true,"whitespace_after_comma_in_array":true,"phpdoc_scalar":true,"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"phpdoc_align":{"align":"left"},"standardize_not_equals":true,"no_unneeded_control_parentheses":true,"no_unneeded_braces":true},"ruleCustomisationPolicyVersion":"null-policy","hashes":{"src\/Misc\/Settings.php":"5e71bd024792e74350c4f1fabcab8065","src\/Misc\/Scripts.php":"e6cad7cd6433d891904071e795d7b0b5","src\/Constants.php":"d7e09100a92074fca817f5e422cf49fb","src\/Adapters\/RefundAdapter.php":"b28b6632847c1a62156d56b54f9f7c21","src\/Adapters\/ProductAdapter.php":"cc0aca0113a5011e83c87ffee4e76b2f","src\/Adapters\/PriceAdapter.php":"f745ecde0eb052560f2db758e1c3122e","src\/Adapters\/OrderAdapter.php":"3ca1bd395d356e3b75e0ceea176cb524","src\/Api\/Event.php":"d3b4144a54d899c86095fb0d9e33e7b6","src\/Api\/Webchat.php":"ef03b3ca436f233ea7ffd4e1bff0f576","src\/Api\/Client.php":"b7c6f6762ab21fcd3fd3639420901b37","src\/Events\/CartUpdates.php":"72e4d163177b381fabc2d683fd104542","src\/Events\/OrderPlaced.php":"1b39dc7198082d8189ce509041f18757","src\/Events\/OrderStatus.php":"6d120b5401afb4f186e9fac1da425bf5","src\/Events\/RefundReceived.php":"a84421a12bf84435de14aeae1442a4a7","src\/Events\/AppInstalled.php":"058e8a7e9aa362b58aa6322f562c30fe","src\/Events\/UserRegistered.php":"f228476df530692be96fb1bb89fd9a79","src\/Events\/CustomOptionsUpdated.php":"cdd61280578691aa394a98d5ad953779","src\/Events\/ProductViewed.php":"8b467111ef300987a48a227a3f8b2a81","src\/Events\/CouponRedeemed.php":"63a56657cfe882ab05a943ae455fe74d","src\/Events\/AppRemoved.php":"993fd99a136255b9261dc8c6460f175f","src\/Services\/Session.php":"5f112c07423d60c7d5f6ece58fbceed0","src\/Services\/CreateProfile.php":"2c3cc60eb9f6e4681e6b931ebdff5a40"}}
68 changes: 68 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/src')
->name('*.php');

return (new PhpCsFixer\Config())
->setRules([
'@PSR12' => true,

// Array/Hash syntax (like Ruby's modern syntax)
'array_syntax' => ['syntax' => 'short'],
'trailing_comma_in_multiline' => true,

// String literals (single quotes like Ruby)
'single_quote' => true,

// Imports/Use statements (alphabetically ordered)
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,

// Spacing rules (match Ruby spacing preferences)
'binary_operator_spaces' => ['default' => 'single_space'],
'concat_space' => ['spacing' => 'one'],
'method_chaining_indentation' => true,
'no_spaces_around_offset' => true,
'no_whitespace_before_comma_in_array' => true,
'whitespace_after_comma_in_array' => true,

// Empty lines and whitespace
'no_extra_blank_lines' => [
'tokens' => [
'extra',
'throw',
'use',
],
],
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'single_blank_line_at_eof' => true,

// Braces (your preference)
'braces_position' => [
'classes_opening_brace' => 'same_line',
'functions_opening_brace' => 'same_line',
],

// Method/Function definitions
'method_argument_space' => [
'on_multiline' => 'ensure_fully_multiline',
],
'return_type_declaration' => ['space_before' => 'none'],

// PHPDoc
'phpdoc_scalar' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_var_without_name' => true,
'phpdoc_align' => ['align' => 'left'],

// Operators
'not_operator_with_successor_space' => false,
'standardize_not_equals' => true,

// Control structures
'no_unneeded_control_parentheses' => true,
'no_unneeded_braces' => true,
])
->setFinder($finder);
Loading