Skip to content

Feat/boilerplate #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 14, 2024
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
37 changes: 31 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,18 +1,43 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

# WordPress Coding Standards
# https://make.wordpress.org/core/handbook/coding-standards/

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
indent_style = tab

[*.yml]
indent_size = 2

[*.md]
trim_trailing_whitespace = false

[*.php]
indent_size = 4
[{*.txt,wp-config-sample.php}]
end_of_line = crlf

[*.blade.php]
indent_size = 2
# ====================================================================
# The rules above ↑this↑ line are the exact contents of WordPress' config file.'
# Github mirror : https://github.com/WordPress/wordpress-develop/blob/trunk/.editorconfig
# SVN original : https://core.trac.wordpress.org/browser/trunk/.editorconfig

# ======= Custom Yard rules =======

[*.{js},*.{jsx}, *.{ts}, *.{tsx}]
# This setting has precedence over VSCode user settings for tabSize
# Not included are tab_width(tabs) or indent_size(spaces) since the user can decide
# what they like visually, 2 vs 4 column size, as long as they use tabs. Default: 4
# This setting also affects Prettier.
indent_style = tab

[*.scss]
indent_style = tab

[{.eslintrc,*.json,*.yml}]
indent_style = space
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
vendor
node_modules
build
.idea
78 changes: 31 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
# Yard :package_name
# Yard php-cs-fixer-rules

[![Code Style](https://github.com/yardinternet/skeleton-package/actions/workflows/format-php.yml/badge.svg?no-cache)](https://github.com/yardinternet/skeleton-package/actions/workflows/format-php.yml)
[![PHPStan](https://github.com/yardinternet/skeleton-package/actions/workflows/phpstan.yml/badge.svg?no-cache)](https://github.com/yardinternet/skeleton-package/actions/workflows/phpstan.yml)
[![Tests](https://github.com/yardinternet/skeleton-package/actions/workflows/run-tests.yml/badge.svg?no-cache)](https://github.com/yardinternet/skeleton-package/actions/workflows/run-tests.yml)
[![Code Coverage Badge](https://github.com/yardinternet/skeleton-package/blob/badges/coverage.svg)](https://github.com/yardinternet/skeleton-package/actions/workflows/badges.yml)
[![Lines of Code Badge](https://github.com/yardinternet/skeleton-package/blob/badges/lines-of-code.svg)](https://github.com/yardinternet/skeleton-package/actions/workflows/badges.yml)
[![Code Style](https://github.com/yardinternet/php-cs-fixer-rules/actions/workflows/format-php.yml/badge.svg?no-cache)](https://github.com/yardinternet/php-cs-fixer-rules/actions/workflows/format-php.yml)
[![PHPStan](https://github.com/yardinternet/php-cs-fixer-rules/actions/workflows/phpstan.yml/badge.svg?no-cache)](https://github.com/yardinternet/php-cs-fixer-rules/actions/workflows/phpstan.yml)
[![Tests](https://github.com/yardinternet/php-cs-fixer-rules/actions/workflows/run-tests.yml/badge.svg?no-cache)](https://github.com/yardinternet/php-cs-fixer-rules/actions/workflows/run-tests.yml)
[![Code Coverage Badge](https://github.com/yardinternet/php-cs-fixer-rules/blob/badges/coverage.svg)](https://github.com/yardinternet/php-cs-fixer-rules/actions/workflows/badges.yml)
[![Lines of Code Badge](https://github.com/yardinternet/php-cs-fixer-rules/blob/badges/lines-of-code.svg)](https://github.com/yardinternet/php-cs-fixer-rules/actions/workflows/badges.yml)

<!--delete-->
---
This repository provides a scaffold for creating an Acorn package. For more detailed information, please refer to the [Acorn Package Development](https://roots.io/acorn/docs/package-development/) documentation.

Follow these steps to get started:

1. Press the "Use this template" button at the top of this repo to create a new repo with the contents of this skeleton.
2. Run "php ./configure.php" to run a script that will replace all placeholders throughout all the files.
3. Have fun creating your package.

---
<!--/delete-->

## Requirements

- [Sage](https://github.com/roots/sage) >= 10.0
- [Acorn](https://github.com/roots/acorn) >= 4.0
Enables you to easily import the Yard PHP CS Fixer rules.

## Installation

Expand All @@ -33,38 +17,38 @@ To install this package using Composer, follow these steps:
```json
{
"type": "vcs",
"url": "[email protected]:yardinternet/skeleton-package.git"
"url": "[email protected]:yardinternet/php-cs-fixer-rules.git"
}
```

2. Install this package with Composer:

```sh
composer require yard/skeleton-package
```

3. Run the Acorn WP-CLI command to discover this package:

```shell
wp acorn package:discover
composer require yard/php-cs-fixer-rules
```

You can publish the config file with:

```shell
wp acorn vendor:publish --provider="Yard\SkeletonPackage\SkeletonPackageServiceProvider"
```

## Usage

From a Blade template:

```blade
@include('skeleton-package::example')
```

From WP-CLI:

```shell
wp acorn example
```php
<?php

use PhpCsFixer\Finder;

$finder = Finder::create()
->in(__DIR__)
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true)
->exclude('public')
->exclude('node_modules')
->exclude('build')
;

return \Yard\PhpCsFixerRules\Config::setFinder($finder)
->mergeRules([ // allows you to add new rules or override rules from default
'declare_strict_types' => false,
])
->setRiskyAllowed(false) // override and disable risky setting for old projects
->get();
```
90 changes: 38 additions & 52 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,40 @@
{
"name": "yard/skeleton-package",
"type": "package",
"description": ":package_description",
"version": "1.0.0",
"license": "MIT",
"config": {
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true
}
},
"require": {
"php": "^8.0",
"spatie/laravel-package-tools": "^1.16"
},
"require-dev": {
"10up/wp_mock": "^0.4.2",
"friendsofphp/php-cs-fixer": "^3.58",
"larastan/larastan": "^2.0",
"orchestra/testbench": "^8.23",
"pestphp/pest": "^2.34",
"szepeviktor/phpstan-wordpress": "^1.0"
},
"autoload": {
"psr-4": {
"Yard\\SkeletonPackage\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Yard\\SkeletonPackage\\Tests\\": "tests/"
}
},
"scripts": {
"analyse": [
"sed -i -e 's#function __(#function ____(#' ./vendor/php-stubs/wordpress-stubs/wordpress-stubs.php",
"vendor/bin/phpstan analyse --debug --memory-limit 1G"
],
"format": "vendor/bin/php-cs-fixer fix",
"test": "vendor/bin/pest",
"test:coverage": "XDEBUG_MODE=coverage vendor/bin/pest --coverage"
},
"extra": {
"acorn": {
"providers": [
"Yard\\SkeletonPackage\\SkeletonPackageServiceProvider"
],
"aliases": {
"Example": "Yard\\SkeletonPackage\\Facades\\Example"
}
}
}
"name": "yard/php-cs-fixer-rules",
"type": "package",
"description": "Yard PHP CS Fixer rules",
"version": "1.0.0",
"license": "MIT",
"config": {
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true
}
},
"require": {
"php": ">=8.1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.58",
"pestphp/pest": "^3.5",
"phpstan/phpstan": "^1.12"
},
"autoload": {
"psr-4": {
"Yard\\PhpCsFixerRules\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Yard\\PhpCsFixerRules\\Tests\\": "tests/"
}
},
"scripts": {
"analyse": [
"sed -i -e 's#function __(#function ____(#' ./vendor/php-stubs/wordpress-stubs/wordpress-stubs.php",
"vendor/bin/phpstan analyse --debug --memory-limit 1G"
],
"format": "vendor/bin/php-cs-fixer fix",
"test": "vendor/bin/pest",
"test:coverage": "XDEBUG_MODE=coverage vendor/bin/pest --coverage"
}
}
Loading