Skip to content

Commit

Permalink
Merge pull request #36 from wp-launchpad/fix/32-fix-phpcs
Browse files Browse the repository at this point in the history
Added phpcs and some fixes
  • Loading branch information
CrochetFeve0251 authored Jul 20, 2024
2 parents 4eae1b1 + d13a564 commit ab2a816
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.gitattributes export-ignore

phpcs.xml export-ignore
composer.lock export-ignore
package.json export-ignore
.gitbook.yaml export-ignore
Expand Down
23 changes: 12 additions & 11 deletions configs/parameters.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<?php
namespace Launchpad\Configs;

defined( 'ABSPATH' ) || exit;

$plugin_name = 'Launchpad';
$plugin_name = 'Launchpad'; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound

$plugin_launcher_path = dirname(__DIR__) . '/';
$plugin_launcher_path = dirname( __DIR__ ) . '/'; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound

return [
'plugin_name' => $plugin_name,
'plugin_slug' => sanitize_key( $plugin_name ),
'plugin_version' => '1.0.0',
'plugin_launcher_file' => $plugin_launcher_path . '/' . basename($plugin_launcher_path) . '.php',
'plugin_launcher_path' => $plugin_launcher_path,
'plugin_inc_path' => realpath( $plugin_launcher_path . 'inc/' ) . '/',
'prefix' => 'launchpad_',
'translation_key' => 'launchpad',
'is_mu_plugin' => false,
'plugin_name' => $plugin_name,
'plugin_slug' => sanitize_key( $plugin_name ),
'plugin_version' => '1.0.0',
'plugin_launcher_file' => $plugin_launcher_path . '/' . basename( $plugin_launcher_path ) . '.php',
'plugin_launcher_path' => $plugin_launcher_path,
'plugin_inc_path' => realpath( $plugin_launcher_path . 'inc/' ) . '/',
'prefix' => 'launchpad_',
'translation_key' => 'launchpad',
'is_mu_plugin' => false,
];
3 changes: 2 additions & 1 deletion configs/providers.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php
namespace Launchpad\Configs;

defined( 'ABSPATH' ) || exit;

return [
\Launchpad\ServiceProvider::class,
\Launchpad\ServiceProvider::class,
];
4 changes: 2 additions & 2 deletions inc/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Launchpad;

class ServiceProvider extends Dependencies\LaunchpadAutoresolver\ServiceProvider
{
class ServiceProvider extends Dependencies\LaunchpadAutoresolver\ServiceProvider {


}
3 changes: 1 addition & 2 deletions launchpad.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*
* Text Domain: launchpad
* Domain Path: languages
*
*/

use function Launchpad\Dependencies\LaunchpadCore\boot;
Expand All @@ -20,4 +19,4 @@

require __DIR__ . '/vendor-prefixed/wp-launchpad/core/inc/boot.php';

boot(__FILE__);
boot( __FILE__ );
71 changes: 71 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WP Rocket" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<description>The custom ruleset for Launchpad.</description>

<!-- For help in understanding this file: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
<!-- For help in using PHPCS: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage -->

<!-- ** WHAT TO SCAN ** -->

<file>.</file>
<!-- Ignoring Files and Folders: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-files-and-folders -->
<exclude-pattern>/inc/deprecated/*</exclude-pattern>
<exclude-pattern>/vendor-prefixed/*</exclude-pattern>
<exclude-pattern>/tests/*</exclude-pattern>
<exclude-pattern>/vendor/*</exclude-pattern>
<exclude-pattern>/node_modules/*</exclude-pattern>

<!-- ** HOW TO SCAN ** -->

<arg value="sp"/><!-- Show sniff and progress -->
<arg name="colors"/><!-- Show results with colors -->
<arg name="parallel" value="50"/><!-- Enables parallel processing when available for faster results. -->
<arg name="extensions" value="php"/><!-- Limit to PHP files -->

<!-- Rules: Check PHP version compatibility - see https://github.com/PHPCompatibility/PHPCompatibilityWP -->
<rule ref="PHPCompatibility"/>

<rule ref="WordPress">
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.TooMuchSpaceAfterComma"/>
<exclude name="Generic.PHP.NoSilencedErrors.Discouraged"/>
<exclude name="PEAR.Functions.FunctionCallSignature.Indent"/>
<exclude name="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace"/>
<exclude name="Squiz.Commenting.FileComment.Missing"/>
<exclude name="Squiz.Commenting.FileComment.MissingPackageTag"/>
<exclude name="Squiz.PHP.CommentedOutCode.Found"/>
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />
<exclude name="Generic.Arrays.DisallowShortArraySyntax" />
</rule>
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array" value="launchpad" />
</properties>
</rule>
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<property name="prefixes" type="array" value="launchpad_,Launchpad" />
</properties>
</rule>
<rule ref="WordPress.Files.FileName">
<properties>
<property name="strict_class_file_names" value="false" />
</properties>
</rule>


<rule ref="WordPress-Docs">
<exclude name="Squiz.Commenting.FileComment.Missing"/>
<exclude name="Squiz.Commenting.ClassComment.Missing"/>
</rule>

<!-- Rules: WordPress Coding Standards - see
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
WordPress-Extra includes WordPress-Core -->
<rule ref="WordPress-Extra">
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
<exclude name="WordPress.PHP.DisallowShortTernary.Found"/>
</rule>

<!-- Enforce short array syntax: `[]` in place of `array()`. -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax" />
</ruleset>

0 comments on commit ab2a816

Please sign in to comment.