Skip to content

Commit

Permalink
Merge pull request #1 from HanashiDev/next
Browse files Browse the repository at this point in the history
WSC 6.0
  • Loading branch information
Hanashi authored Oct 21, 2023
2 parents 567b891 + e13d855 commit 5d86633
Show file tree
Hide file tree
Showing 37 changed files with 1,147 additions and 781 deletions.
15 changes: 15 additions & 0 deletions .github/php-syntax.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"problemMatcher": [
{
"owner": "php -l",
"pattern": [
{
"regexp": "^\\s*(PHP\\s+)?([a-zA-Z\\s]+):\\s+(.*)\\s+in\\s+(\\S+)\\s+on\\s+line\\s+(\\d+)$",
"file": 4,
"line": 5,
"message": 3
}
]
}
]
}
22 changes: 22 additions & 0 deletions .github/workflows/codestyle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Code Style

on:
push:
pull_request:

jobs:
php:
name: PHP
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup PHP with tools
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
extensions: ctype, dom, exif, gd, gmp, hash, intl, json, libxml, mbstring, opcache, pcre, pdo, pdo_mysql, zlib
tools: cs2pr, phpcs, php-cs-fixer
- name: phpcs
run: phpcs -n -q --report=checkstyle | cs2pr
- name: php-cs-fixer
run: php-cs-fixer fix --dry-run --diff
25 changes: 25 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: PHP

on:
push:
pull_request:

jobs:
syntax:
name: "Check Syntax (${{ matrix.php }})"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php:
- '8.1'
- '8.2'
steps:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- uses: actions/checkout@v4
- run: echo "::add-matcher::.github/php-syntax.json"
- run: |
! find . -type f -name '*.php' -exec php -l '{}' \; 2>&1 |grep -v '^No syntax errors detected'
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Release

on:
push:
tags: ['*']
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v3
with:
node-version: 16

- name: Create package
run: |
rm -rf *.tar.gz
npx --yes wspackager@latest
- name: Check file existence
id: check_files
uses: andstor/[email protected]
with:
files: "*.tar.gz"

- name: On Build Failure
if: steps.check_files.outputs.files_exists == 'false'
run: |
echo "Packaging FAILED" && exit 1
- name: Release
uses: softprops/[email protected]
if: startsWith(github.ref, 'refs/tags/') && steps.check_files.outputs.files_exists == 'true'
with:
files: "*.tar.gz"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.tar
option.xml
.phpcs-cache
*.cache
129 changes: 129 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__.'/files/')
->notPath('lib/system/api');

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

'array_push' => true,
'backtick_to_shell_exec' => true,
'no_alias_language_construct_call' => true,
'no_mixed_echo_print' => true,
'pow_to_exponentiation' => true,
'random_api_migration' => true,

'array_syntax' => ['syntax' => 'short'],
'no_multiline_whitespace_around_double_arrow' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_whitespace_before_comma_in_array' => true,
'normalize_index_brace' => true,
'whitespace_after_comma_in_array' => true,

'non_printable_character' => ['use_escape_sequences_in_strings' => true],

'lowercase_static_reference' => true,
'magic_constant_casing' => true,
'magic_method_casing' => true,
'native_function_casing' => true,
'native_function_type_declaration_casing' => true,

'cast_spaces' => ['space' => 'none'],
'lowercase_cast' => true,
'no_unset_cast' => true,
'short_scalar_cast' => true,

'class_attributes_separation' => true,
'no_blank_lines_after_class_opening' => true,
'no_null_property_initialization' => true,
'self_accessor' => true,
'single_class_element_per_statement' => true,
'single_trait_insert_per_statement' => true,

'no_empty_comment' => true,
'single_line_comment_style' => ['comment_types' => ['hash']],

'native_constant_invocation' => ['strict' => false],

'no_alternative_syntax' => true,
'no_trailing_comma_in_list_call' => true,
'no_unneeded_control_parentheses' => ['statements' => ['break', 'clone', 'continue', 'echo_print', 'return', 'switch_case', 'yield', 'yield_from']],
'no_unneeded_curly_braces' => ['namespaces' => true],
'switch_continue_to_break' => true,
'trailing_comma_in_multiline' => ['elements' => ['arrays']],

'function_typehint_space' => true,
'lambda_not_used_import' => true,
'native_function_invocation' => ['include' => ['@internal']],
'no_unreachable_default_argument_value' => true,
'nullable_type_declaration_for_default_null_value' => true,
'return_type_declaration' => true,
'static_lambda' => true,

'fully_qualified_strict_types' => true,
'no_leading_import_slash' => true,
'no_unused_imports' => true,
'ordered_imports' => true,

'declare_equal_normalize' => true,
'dir_constant' => true,
'explicit_indirect_variable' => true,
'function_to_constant' => true,
'is_null' => true,
'no_unset_on_property' => true,

'list_syntax' => ['syntax' => 'short'],

'clean_namespace' => true,
'no_leading_namespace_whitespace' => true,
'single_blank_line_before_namespace' => true,

'no_homoglyph_names' => true,

'binary_operator_spaces' => true,
'concat_space' => ['spacing' => 'one'],
'increment_style' => ['style' => 'post'],
'logical_operators' => true,
'object_operator_without_whitespace' => true,
'operator_linebreak' => true,
'standardize_increment' => true,
'standardize_not_equals' => true,
'ternary_operator_spaces' => true,
'ternary_to_elvis_operator' => true,
'ternary_to_null_coalescing' => true,
'unary_operator_spaces' => true,

'no_useless_return' => true,
'return_assignment' => true,

'multiline_whitespace_before_semicolons' => true,
'no_empty_statement' => true,
'no_singleline_whitespace_before_semicolons' => true,
'space_after_semicolon' => ['remove_in_empty_for_expressions' => true],

'escape_implicit_backslashes' => true,
'explicit_string_variable' => true,
'heredoc_to_nowdoc' => true,
'no_binary_string' => true,
'simple_to_complex_string_variable' => true,

'array_indentation' => true,
'blank_line_before_statement' => ['statements' => ['return', 'exit']],
'compact_nullable_typehint' => true,
'method_chaining_indentation' => true,
'no_extra_blank_lines' => ['tokens' => ['case', 'continue', 'curly_brace_block', 'default', 'extra', 'parenthesis_brace_block', 'square_brace_block', 'switch', 'throw', 'use']],
'no_spaces_around_offset' => true,

'global_namespace_import' => [
'import_classes' => true,
'import_constants' => false,
'import_functions' => false,
],
'ordered_imports' => [
'imports_order' => ['class', 'function', 'const'],
],
])
->setFinder($finder);
18 changes: 18 additions & 0 deletions .phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
<arg name="basepath" value="."/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="10"/>

<!-- Show progress -->
<arg value="p"/>

<!-- Paths to check -->
<file>files</file>
<exclude-pattern>lib/system/api/*</exclude-pattern>

<!-- Include all rules from the Zend Coding Standard -->
<rule ref="PSR12"/>
</ruleset>
5 changes: 2 additions & 3 deletions acpMenu.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<data xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/tornado/acpMenu.xsd">
<data xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/6.0/acpMenu.xsd">
<import>
<acpmenuitem name="packages.acp.menu.link.package">
<parent>wcf.acp.menu.link.application</parent>
</acpmenuitem>

<acpmenuitem name="packages.acp.menu.link.package.repository.list">
<controller>packages\acp\page\RepositoryListPage</controller>
<parent>packages.acp.menu.link.package</parent>
Expand All @@ -15,7 +14,7 @@
<controller>packages\acp\form\RepositoryAddForm</controller>
<parent>packages.acp.menu.link.package.repository.list</parent>
<permissions>admin.packages.canManageRepository</permissions>
<icon>fa-plus</icon>
<icon>plus</icon>
</acpmenuitem>
</import>
</data>
6 changes: 3 additions & 3 deletions acptemplates/__haFilebaseCategoryAddPackageServer.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
<ol class="flexibleButtonGroup optionTypeBoolean">
<li>
<input type="radio" id="post_title_yes"{if $packageServer == 1} checked=""{/if} name="values[packageServer]" value="1" class="jsEnablesOptions" data-is-boolean="true" data-disable-options="[ ]" data-enable-options="[ ]">
<label for="post_title_yes" class="green"><span class="icon icon16 fa-check"></span> {lang}wcf.acp.option.type.boolean.yes{/lang}</label>
<label for="post_title_yes" class="green">{icon name='check' size=16} {lang}wcf.acp.option.type.boolean.yes{/lang}</label>
</li>
<li>
<input type="radio" id="post_title_no"{if $packageServer == 0} checked=""{/if} name="values[packageServer]" value="0" class="jsEnablesOptions" data-is-boolean="true" data-disable-options="[ ]" data-enable-options="[ ]">
<label for="post_title_no" class="red"><span class="icon icon16 fa-times"></span> {lang}wcf.acp.option.type.boolean.no{/lang}</label>
<label for="post_title_no" class="red">{icon name='times' size=16} {lang}wcf.acp.option.type.boolean.no{/lang}</label>
</li>
</ol>
<small>{lang}packages.page.filebaseCategoryAdd.packageServer.description{/lang}</small>
Expand Down Expand Up @@ -41,4 +41,4 @@
</dd>
</dl>
</section>
{/if}
{/if}
47 changes: 8 additions & 39 deletions acptemplates/repositoryAdd.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,15 @@
<div class="contentHeaderTitle">
<h1 class="contentTitle">{lang}packages.page.repositoryAdd.title{/lang}</h1>
</div>
</header>

{include file='formError'}

{if $success|isset}
<p class="success">
{lang}packages.page.repositoryAdd.scuccess{/lang}
</p>
{/if}
<nav class="contentHeaderNavigation">
<ul>
<li><a href="{link application='packages' controller='RepositoryList'}{/link}" class="button">{icon name='list' size=16} <span>{lang}packages.acp.menu.link.package.repository.list{/lang}</span></a></li>
{event name='contentHeaderNavigation'}
</ul>
</nav>
</header>

<form method="post" action="{link application='packages' controller='RepositoryAdd'}{/link}">
<section class="section">
<dl{if $errorField == 'name'} class="formError"{/if}>
<dt><label for="name">{lang}packages.page.repositoryAdd.name{/lang}</label></dt>
<dd>
<input type="text" name="name" id="name" value="{$name}" required>
{if $errorField == 'name'}
<small class="innerError">
{if $errorType == 'tooShort'}
{lang}packages.page.repositoryAdd.name.error.tooShort{/lang}
{else if $errorType == 'noNumberOnStart'}
{lang}packages.page.repositoryAdd.name.error.noNumberOnStart{/lang}
{else if $errorType == 'wrongFormat'}
{lang}packages.page.repositoryAdd.name.error.wrongFormat{/lang}
{else if $errorType == 'nameTooLong'}
{lang}packages.page.repositoryAdd.name.error.nameTooLong{/lang}
{else if $errorType == 'alreadyUsed'}
{lang}packages.page.repositoryAdd.name.error.alreadyUsed{/lang}
{/if}
</small>
{/if}
<small>{lang}packages.page.repositoryAdd.name.description{/lang}</small>
</dd>
</dl>
</section>

<div class="formSubmit">
<input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s">
{@SECURITY_TOKEN_INPUT_TAG}
</div>
</form>
{@$form->getHtml()}

{include file='footer'}
Loading

0 comments on commit 5d86633

Please sign in to comment.