Skip to content

Instantly share code, notes, and snippets.

@hkdobrev
Last active May 15, 2024 16:56
Show Gist options
  • Save hkdobrev/8578228 to your computer and use it in GitHub Desktop.
Save hkdobrev/8578228 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();
}
@TeLiXj
Copy link

TeLiXj commented Aug 17, 2023

abstract private function methods(); is an error: Private method cannot be abstract

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment