Skip to content

Instantly share code, notes, and snippets.

@RobinBastiaan
Forked from hkdobrev/class-order.php
Created August 18, 2022 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobinBastiaan/5b2d4eea98cb2c530125e3cb88c33e1b to your computer and use it in GitHub Desktop.
Save RobinBastiaan/5b2d4eea98cb2c530125e3cb88c33e1b to your computer and use it in GitHub Desktop.
PHP convention for the order in a class.

PHP Convention for the order of a class

Accepting suggestions.

<?php namespace Vendor\Library;
use Another\Vendor\Library\ClassName;
abstract class ClassName extends AnotherClass implements Countable, Serializable
{
const CONSTANTS = 'top';
use someTrait, anotherTrait {
anotherTrait::traitMethod insteadof someTrait;
someTrait::anotherTraitMethod insteadof anotherTrait;
someTrait::traitMethod as duplicate;
};
public static $properties;
protected static $properties;
private static $properties;
public static function methods() {}
protected static function methods() {}
private static function methods() {}
public $properties;
protected $properties;
private $properties;
public function __construct() {}
public function __destruct() {}
public function __get() {}
public function __set() {}
public function getters() {}
public function setters() {}
public function methods() {}
final public function methods() {}
protected function methods() {}
final protected function methods() {}
private function methods() {}
abstract public function methods();
abstract protected function methods();
abstract private function methods();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment