Author: Andreas Möller (localheinz)
Committer: GitHub (web-flow)
Pusher: cmb69
Date: 2022-07-12T12:39:00+02:00

Commit: 
https://github.com/php/web-php/commit/a35d47d06026b3250d5161fc88dbdff602b99105
Raw diff: 
https://github.com/php/web-php/commit/a35d47d06026b3250d5161fc88dbdff602b99105.diff

Enhancement: Enable `ordered_class_elements` fixer

Closes GH-641.

Changed paths:
  M  .php-cs-fixer.php
  M  src/News/Entry.php


Diff:

diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php
index 5c9965fcf..92cca1483 100644
--- a/.php-cs-fixer.php
+++ b/.php-cs-fixer.php
@@ -8,12 +8,14 @@
     ->ignoreDotFiles(false)
     ->in(__DIR__)
     ->exclude('manual/en/')
-    ->name(__FILE__);
+    ->name(__FILE__)
+    ->notPath('tests/run-tests.php');
 
 $config->setRules([
     'array_indentation' => true,
     'indentation_type' => true,
     'no_trailing_whitespace' => true,
+    'ordered_class_elements' => true,
     'single_space_after_construct' => true,
     'visibility_required' => true,
     'whitespace_after_comma_in_array' => true,
diff --git a/src/News/Entry.php b/src/News/Entry.php
index ec40e2643..69a66a4a6 100755
--- a/src/News/Entry.php
+++ b/src/News/Entry.php
@@ -22,12 +22,20 @@ class Entry {
 
     protected $title = '';
 
+    protected $categories = [];
+
+    protected $conf_time = 0;
+
+    protected $image = [];
+
+    protected $content = '';
+
+    protected $id = '';
+
     public function setTitle(string $title): self {
         $this->title = $title;
         return $this;
     }
-
-    protected $categories = [];
     public function setCategories(array $cats): self {
         foreach ($cats as $cat) {
             if (!isset(self::CATEGORIES[$cat])) {
@@ -50,14 +58,10 @@ public function addCategory(string $cat): self {
     public function isConference(): bool {
         return (bool)array_intersect($this->categories, ['cfp', 
'conferences']);
     }
-
-    protected $conf_time = 0;
     public function setConfTime(int $time): self {
         $this->conf_time = $time;
         return $this;
     }
-
-    protected $image = [];
     public function setImage(string $path, string $title, ?string $link): self 
{
         if (basename($path) !== $path) {
             throw new \Exception('path must be a simple file name under ' . 
self::IMAGE_PATH_REL);
@@ -72,8 +76,6 @@ public function setImage(string $path, string $title, ?string 
$link): self {
         ];
         return $this;
     }
-
-    protected $content = '';
     public function setContent(string $content): self {
         if (empty($content)) {
             throw new \Exception('Content must not be empty');
@@ -81,19 +83,6 @@ public function setContent(string $content): self {
         $this->content = $content;
         return $this;
     }
-
-    protected $id = '';
-    private static function selectNextId(): string {
-        $filename = date("Y-m-d", $_SERVER["REQUEST_TIME"]);
-        $count = 0;
-        do {
-            ++$count;
-            $id = $filename . "-" . $count;
-            $basename  = "{$id}.xml";
-        } while (file_exists(self::ARCHIVE_ENTRIES_ABS . $basename));
-
-        return $id;
-    }
     public function getId(): string {
         return $this->id;
     }
@@ -177,6 +166,17 @@ public function updateArchiveXML(): self {
 
         return $this;
     }
+    private static function selectNextId(): string {
+        $filename = date("Y-m-d", $_SERVER["REQUEST_TIME"]);
+        $count = 0;
+        do {
+            ++$count;
+            $id = $filename . "-" . $count;
+            $basename  = "{$id}.xml";
+        } while (file_exists(self::ARCHIVE_ENTRIES_ABS . $basename));
+
+        return $id;
+    }
 
     private static function ce(\DOMDocument $d, string $name, $value, array 
$attrs = [], ?\DOMNode $to = null) {
         if ($value) {

-- 
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to