From a6f1280ffe5925326e682f7cf1ea6d7dbbd6fab4 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Fri, 28 May 2021 08:45:55 +0200 Subject: [PATCH] Fix code style issues in tutorial series code --- .../files/lib/acp/form/PersonAddForm.class.php | 2 +- .../files/lib/data/person/Person.class.php | 6 +++--- .../files/lib/acp/form/PersonAddForm.class.php | 2 +- .../files/lib/data/person/Person.class.php | 8 ++++---- .../part-3/files/lib/page/PersonPage.class.php | 5 +++-- .../files/lib/acp/form/PersonAddForm.class.php | 2 +- .../files/lib/data/person/Person.class.php | 8 ++++---- .../part-4/files/lib/page/PersonPage.class.php | 5 +++-- .../system/box/PersonListBoxController.class.php | 2 +- .../files/lib/acp/form/PersonAddForm.class.php | 2 +- .../files/lib/data/person/Person.class.php | 16 +++++++++++----- .../PersonInformationAction.class.php | 3 ++- .../part-5/files/lib/page/PersonPage.class.php | 5 +++-- .../system/box/PersonListBoxController.class.php | 2 +- .../worker/PersonRebuildDataWorker.class.php | 4 ++-- 15 files changed, 41 insertions(+), 31 deletions(-) diff --git a/snippets/tutorial/tutorial-series/part-1/files/lib/acp/form/PersonAddForm.class.php b/snippets/tutorial/tutorial-series/part-1/files/lib/acp/form/PersonAddForm.class.php index 21215520..2d549033 100644 --- a/snippets/tutorial/tutorial-series/part-1/files/lib/acp/form/PersonAddForm.class.php +++ b/snippets/tutorial/tutorial-series/part-1/files/lib/acp/form/PersonAddForm.class.php @@ -45,7 +45,7 @@ class PersonAddForm extends AbstractFormBuilderForm /** * @inheritDoc */ - public function createForm() + protected function createForm() { parent::createForm(); diff --git a/snippets/tutorial/tutorial-series/part-1/files/lib/data/person/Person.class.php b/snippets/tutorial/tutorial-series/part-1/files/lib/data/person/Person.class.php index 00ff194f..c19e21a2 100644 --- a/snippets/tutorial/tutorial-series/part-1/files/lib/data/person/Person.class.php +++ b/snippets/tutorial/tutorial-series/part-1/files/lib/data/person/Person.class.php @@ -13,9 +13,9 @@ use wcf\system\request\IRouteController; * @license GNU Lesser General Public License * @package WoltLabSuite\Core\Data\Person * - * @property-read integer $personID unique id of the person - * @property-read string $firstName first name of the person - * @property-read string $lastName last name of the person + * @property-read int $personID unique id of the person + * @property-read string $firstName first name of the person + * @property-read string $lastName last name of the person */ class Person extends DatabaseObject implements IRouteController { diff --git a/snippets/tutorial/tutorial-series/part-3/files/lib/acp/form/PersonAddForm.class.php b/snippets/tutorial/tutorial-series/part-3/files/lib/acp/form/PersonAddForm.class.php index 565274d1..7ecf6f87 100644 --- a/snippets/tutorial/tutorial-series/part-3/files/lib/acp/form/PersonAddForm.class.php +++ b/snippets/tutorial/tutorial-series/part-3/files/lib/acp/form/PersonAddForm.class.php @@ -46,7 +46,7 @@ class PersonAddForm extends AbstractFormBuilderForm /** * @inheritDoc */ - public function createForm() + protected function createForm() { parent::createForm(); diff --git a/snippets/tutorial/tutorial-series/part-3/files/lib/data/person/Person.class.php b/snippets/tutorial/tutorial-series/part-3/files/lib/data/person/Person.class.php index d5c6d166..a6390e12 100644 --- a/snippets/tutorial/tutorial-series/part-3/files/lib/data/person/Person.class.php +++ b/snippets/tutorial/tutorial-series/part-3/files/lib/data/person/Person.class.php @@ -15,10 +15,10 @@ use wcf\system\request\LinkHandler; * @license GNU Lesser General Public License * @package WoltLabSuite\Core\Data\Person * - * @property-read integer $personID unique id of the person - * @property-read string $firstName first name of the person - * @property-read string $lastName last name of the person - * @property-read int $enableComments is `1` if comments are enabled for the person, otherwise `0` + * @property-read int $personID unique id of the person + * @property-read string $firstName first name of the person + * @property-read string $lastName last name of the person + * @property-read int $enableComments is `1` if comments are enabled for the person, otherwise `0` */ class Person extends DatabaseObject implements ITitledLinkObject { diff --git a/snippets/tutorial/tutorial-series/part-3/files/lib/page/PersonPage.class.php b/snippets/tutorial/tutorial-series/part-3/files/lib/page/PersonPage.class.php index 24be70a8..d70feda1 100644 --- a/snippets/tutorial/tutorial-series/part-3/files/lib/page/PersonPage.class.php +++ b/snippets/tutorial/tutorial-series/part-3/files/lib/page/PersonPage.class.php @@ -2,6 +2,7 @@ namespace wcf\page; +use wcf\data\comment\StructuredCommentList; use wcf\data\person\Person; use wcf\system\comment\CommentHandler; use wcf\system\comment\manager\PersonCommentManager; @@ -32,7 +33,7 @@ class PersonPage extends AbstractPage /** * id of the person comment object type - * @var integer + * @var int */ public $commentObjectTypeID = 0; @@ -44,7 +45,7 @@ class PersonPage extends AbstractPage /** * id of the shown person - * @var integer + * @var int */ public $personID = 0; diff --git a/snippets/tutorial/tutorial-series/part-4/files/lib/acp/form/PersonAddForm.class.php b/snippets/tutorial/tutorial-series/part-4/files/lib/acp/form/PersonAddForm.class.php index 565274d1..7ecf6f87 100644 --- a/snippets/tutorial/tutorial-series/part-4/files/lib/acp/form/PersonAddForm.class.php +++ b/snippets/tutorial/tutorial-series/part-4/files/lib/acp/form/PersonAddForm.class.php @@ -46,7 +46,7 @@ class PersonAddForm extends AbstractFormBuilderForm /** * @inheritDoc */ - public function createForm() + protected function createForm() { parent::createForm(); diff --git a/snippets/tutorial/tutorial-series/part-4/files/lib/data/person/Person.class.php b/snippets/tutorial/tutorial-series/part-4/files/lib/data/person/Person.class.php index d5c6d166..a6390e12 100644 --- a/snippets/tutorial/tutorial-series/part-4/files/lib/data/person/Person.class.php +++ b/snippets/tutorial/tutorial-series/part-4/files/lib/data/person/Person.class.php @@ -15,10 +15,10 @@ use wcf\system\request\LinkHandler; * @license GNU Lesser General Public License * @package WoltLabSuite\Core\Data\Person * - * @property-read integer $personID unique id of the person - * @property-read string $firstName first name of the person - * @property-read string $lastName last name of the person - * @property-read int $enableComments is `1` if comments are enabled for the person, otherwise `0` + * @property-read int $personID unique id of the person + * @property-read string $firstName first name of the person + * @property-read string $lastName last name of the person + * @property-read int $enableComments is `1` if comments are enabled for the person, otherwise `0` */ class Person extends DatabaseObject implements ITitledLinkObject { diff --git a/snippets/tutorial/tutorial-series/part-4/files/lib/page/PersonPage.class.php b/snippets/tutorial/tutorial-series/part-4/files/lib/page/PersonPage.class.php index 24be70a8..d70feda1 100644 --- a/snippets/tutorial/tutorial-series/part-4/files/lib/page/PersonPage.class.php +++ b/snippets/tutorial/tutorial-series/part-4/files/lib/page/PersonPage.class.php @@ -2,6 +2,7 @@ namespace wcf\page; +use wcf\data\comment\StructuredCommentList; use wcf\data\person\Person; use wcf\system\comment\CommentHandler; use wcf\system\comment\manager\PersonCommentManager; @@ -32,7 +33,7 @@ class PersonPage extends AbstractPage /** * id of the person comment object type - * @var integer + * @var int */ public $commentObjectTypeID = 0; @@ -44,7 +45,7 @@ class PersonPage extends AbstractPage /** * id of the shown person - * @var integer + * @var int */ public $personID = 0; diff --git a/snippets/tutorial/tutorial-series/part-4/files/lib/system/box/PersonListBoxController.class.php b/snippets/tutorial/tutorial-series/part-4/files/lib/system/box/PersonListBoxController.class.php index 95dc305c..7d785a9c 100644 --- a/snippets/tutorial/tutorial-series/part-4/files/lib/system/box/PersonListBoxController.class.php +++ b/snippets/tutorial/tutorial-series/part-4/files/lib/system/box/PersonListBoxController.class.php @@ -50,7 +50,7 @@ class PersonListBoxController extends AbstractDatabaseObjectListBoxController /** * @inheritDoc */ - public function getObjectList() + protected function getObjectList() { return new PersonList(); } diff --git a/snippets/tutorial/tutorial-series/part-5/files/lib/acp/form/PersonAddForm.class.php b/snippets/tutorial/tutorial-series/part-5/files/lib/acp/form/PersonAddForm.class.php index 565274d1..7ecf6f87 100644 --- a/snippets/tutorial/tutorial-series/part-5/files/lib/acp/form/PersonAddForm.class.php +++ b/snippets/tutorial/tutorial-series/part-5/files/lib/acp/form/PersonAddForm.class.php @@ -46,7 +46,7 @@ class PersonAddForm extends AbstractFormBuilderForm /** * @inheritDoc */ - public function createForm() + protected function createForm() { parent::createForm(); diff --git a/snippets/tutorial/tutorial-series/part-5/files/lib/data/person/Person.class.php b/snippets/tutorial/tutorial-series/part-5/files/lib/data/person/Person.class.php index aca42237..bb382bdd 100644 --- a/snippets/tutorial/tutorial-series/part-5/files/lib/data/person/Person.class.php +++ b/snippets/tutorial/tutorial-series/part-5/files/lib/data/person/Person.class.php @@ -17,14 +17,20 @@ use wcf\system\request\LinkHandler; * @license GNU Lesser General Public License * @package WoltLabSuite\Core\Data\Person * - * @property-read integer $personID unique id of the person - * @property-read string $firstName first name of the person - * @property-read string $lastName last name of the person - * @property-read int $informationCount number of pieces of information added for the person - * @property-read int $enableComments is `1` if comments are enabled for the person, otherwise `0` + * @property-read int $personID unique id of the person + * @property-read string $firstName first name of the person + * @property-read string $lastName last name of the person + * @property-read int $informationCount number of pieces of information added for the person + * @property-read int $enableComments is `1` if comments are enabled for the person, otherwise `0` */ class Person extends DatabaseObject implements ITitledLinkObject { + /** + * all pieces of information added for the person. + * @var PersonInformation[] + */ + protected $information; + /** * Returns the first and last name of the person if a person object is treated as a string. * diff --git a/snippets/tutorial/tutorial-series/part-5/files/lib/data/person/information/PersonInformationAction.class.php b/snippets/tutorial/tutorial-series/part-5/files/lib/data/person/information/PersonInformationAction.class.php index d6f74a94..83fcc862 100644 --- a/snippets/tutorial/tutorial-series/part-5/files/lib/data/person/information/PersonInformationAction.class.php +++ b/snippets/tutorial/tutorial-series/part-5/files/lib/data/person/information/PersonInformationAction.class.php @@ -14,6 +14,7 @@ use wcf\system\form\builder\container\wysiwyg\WysiwygFormContainer; use wcf\system\form\builder\DialogFormDocument; use wcf\system\html\input\HtmlInputProcessor; use wcf\system\WCF; +use wcf\util\UserUtil; /** * Executes person information-related actions. @@ -53,7 +54,7 @@ class PersonInformationAction extends AbstractDatabaseObjectAction if (LOG_IP_ADDRESS) { if (!isset($this->parameters['data']['ipAddress'])) { - $this->parameters['data']['ipAddress'] = WCF::getSession()->ipAddress; + $this->parameters['data']['ipAddress'] = UserUtil::getIpAddress(); } } else { unset($this->parameters['data']['ipAddress']); diff --git a/snippets/tutorial/tutorial-series/part-5/files/lib/page/PersonPage.class.php b/snippets/tutorial/tutorial-series/part-5/files/lib/page/PersonPage.class.php index 24be70a8..d70feda1 100644 --- a/snippets/tutorial/tutorial-series/part-5/files/lib/page/PersonPage.class.php +++ b/snippets/tutorial/tutorial-series/part-5/files/lib/page/PersonPage.class.php @@ -2,6 +2,7 @@ namespace wcf\page; +use wcf\data\comment\StructuredCommentList; use wcf\data\person\Person; use wcf\system\comment\CommentHandler; use wcf\system\comment\manager\PersonCommentManager; @@ -32,7 +33,7 @@ class PersonPage extends AbstractPage /** * id of the person comment object type - * @var integer + * @var int */ public $commentObjectTypeID = 0; @@ -44,7 +45,7 @@ class PersonPage extends AbstractPage /** * id of the shown person - * @var integer + * @var int */ public $personID = 0; diff --git a/snippets/tutorial/tutorial-series/part-5/files/lib/system/box/PersonListBoxController.class.php b/snippets/tutorial/tutorial-series/part-5/files/lib/system/box/PersonListBoxController.class.php index 95dc305c..7d785a9c 100644 --- a/snippets/tutorial/tutorial-series/part-5/files/lib/system/box/PersonListBoxController.class.php +++ b/snippets/tutorial/tutorial-series/part-5/files/lib/system/box/PersonListBoxController.class.php @@ -50,7 +50,7 @@ class PersonListBoxController extends AbstractDatabaseObjectListBoxController /** * @inheritDoc */ - public function getObjectList() + protected function getObjectList() { return new PersonList(); } diff --git a/snippets/tutorial/tutorial-series/part-5/files/lib/system/worker/PersonRebuildDataWorker.class.php b/snippets/tutorial/tutorial-series/part-5/files/lib/system/worker/PersonRebuildDataWorker.class.php index 2dd1823f..e85c7324 100644 --- a/snippets/tutorial/tutorial-series/part-5/files/lib/system/worker/PersonRebuildDataWorker.class.php +++ b/snippets/tutorial/tutorial-series/part-5/files/lib/system/worker/PersonRebuildDataWorker.class.php @@ -47,7 +47,7 @@ class PersonRebuildDataWorker extends AbstractRebuildDataWorker if (!\count($this->objectList)) { return; } - + $sql = "UPDATE wcf" . WCF_N . "_person person SET informationCount = ( SELECT COUNT(*) @@ -56,7 +56,7 @@ class PersonRebuildDataWorker extends AbstractRebuildDataWorker ) WHERE person.personID = ?"; $statement = WCF::getDB()->prepareStatement($sql); - + WCF::getDB()->beginTransaction(); foreach ($this->getObjectList() as $person) { $statement->execute([$person->personID]); -- 2.20.1