Here's a quick overview of naming standards that we will need to follow in the upcoming WPSC.
Class names should be in StudlyCaps: AlertBox{} instead of Alert_Box{}. See also: http://www.php-fig.org/psr/psr-4/ for details about how a FQCN (Fully Qualified Class Name) should be exposed in PHP.
Method names should be in camelCase: alertBox(). However, if the name of the class is AlertBox the method name needs to be something different (regardless of caSe); e.g., shortcode() instead of alertBox(). See also: http://www.php-fig.org/psr/psr-2/
Property and/or variable names should use snake_case: $variable_one
Each class should be in a file of it's own, inside src/includes/classes/AlertBox.php
Each class should have a namespace declaration at the top that begins with: WebSharks\WpSharks\ and contain a \Classes suffix as seen in this example.
Each PHP file should be compatible with PHP 7.0.4+ and declare strict types.
<?php
declare (strict_types = 1);
namespace WebSharks\WpSharks\AlertBoxShortcode\Classes;
/**
* Shortcode handler.
*
* @since 16xxxx Naming standards.
*/
class AlertBox
{
public function shortcode();
Most class members should be written with OOP flexibility; e.g., instead of public static function use the OOP instance-compatible public function (drop the static part).
Forked from https://github.com/websharks/team/issues/59#issuecomment-213955934.
@jaswsinc writes...
Here's a quick overview of naming standards that we will need to follow in the upcoming WPSC.
AlertBox{}
instead ofAlert_Box{}
. See also: http://www.php-fig.org/psr/psr-4/ for details about how a FQCN (Fully Qualified Class Name) should be exposed in PHP.alertBox()
. However, if the name of the class isAlertBox
the method name needs to be something different (regardless of caSe); e.g.,shortcode()
instead ofalertBox()
. See also: http://www.php-fig.org/psr/psr-2/$variable_one
src/includes/classes/AlertBox.php
Each class should have a namespace declaration at the top that begins with:
WebSharks\WpSharks\
and contain a\Classes
suffix as seen in this example.Each PHP file should be compatible with PHP 7.0.4+ and declare strict types.
public static function
use the OOP instance-compatiblepublic function
(drop thestatic
part).