WIP: #25-fix-64bit-values #26

Closed
Ghost wants to merge 15 commits from (deleted):#25-fix-64bit-values into stable

Fixes #25

Incorrectly spelled words and wrong verb tenses are also fixed. Editorconfig additions for more comfortable collaboration
+Test coverage

Successfully integrated into deeproots in this commit

test.log

Started testing


[1] Deleted deprecated database
[2] Initialized the database
[3] Initialized the record
[4][1][SUCCESS]["name"] Expected: "Arsen" (string). Actual: "Arsen" (string)
[4][2][SUCCESS]["second_name"] Expected: "Mirzaev" (string). Actual: "Mirzaev" (string)
[4][3][SUCCESS]["age"] Expected: "24" (integer). Actual: "24" (integer)
[4][4][SUCCESS]["height"] Expected: "165.5" (double). Actual: "165.5" (double)
[4][5][SUCCESS]["neuron_count"] Expected: "91000000000" (integer). Actual: "91000000000" (integer)
[4][6][SUCCESS]["motivation"] Expected: "1.7976931348623E+238" (double). Actual: "1.7976931348623E+238" (double)
[4][7][SUCCESS]["reputation"] Expected: "7355608" (integer). Actual: "7355608" (integer)
[4][8][SUCCESS]["active"] Expected: "1" (integer). Actual: "1" (integer)
[4] The record parameters checks have been completed
[5] Wrote the record into the database
[6] Initialized the record
[7] Wrote the record into the database
[8] Initialized the record
[9] Wrote the record into the database
[10] Read all records from the database
[11][1][SUCCESS][type of returned value] Expected: "array". Actual: "array"
[11][2][SUCCESS][amount of read records] Expected: 3 records. Actual: 3 records
[11][3][SUCCESS][type of read values] Expected: "object". Actual: "object"
[11][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record"
[11][5][SUCCESS]["neuron_count"] Expected: "91000000000" (integer). Actual: "91000000000" (integer)
[11] The read all records checks have been completed
[12] Read the first record from the database
[13][1][SUCCESS][type of returned value] Expected: "array". Actual: "array"
[13][2][SUCCESS][amount of read records] Expected: 1 records. Actual: 1 records
[13][3][SUCCESS][type of read values] Expected: "object". Actual: "object"
[13][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record"
[13][5][SUCCESS]["second_name"] Expected: "Mirzaev" (string). Actual: "Mirzaev" (string)
[13][6][SUCCESS]["neuron_count"] Expected: "91000000000" (integer). Actual: "91000000000" (integer)
[13] The read first record checks have been completed
[14] Read the second record from the database
[15][1][SUCCESS][type of returned value] Expected: "array". Actual: "array"
[15][2][SUCCESS][amount of read records] Expected: 1 records. Actual: 1 records
[15][3][SUCCESS][type of read values] Expected: "object". Actual: "object"
[15][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record"
[15][5][SUCCESS]["second_name"] Expected: "Ivanov" (string). Actual: "Ivanov" (string)
[15][6][SUCCESS]["motivation"] Expected: "2.2250738585072E-308" (double). Actual: "2.2250738585072E-308" (double)
[15][7][SUCCESS]["reputation"] Expected: "-9223372036854775808" (integer). Actual: "-9223372036854775808" (integer)
[15] The read second record checks have been completed
[16] Read the record from the database by filter
[17][1][SUCCESS][type of returned value] Expected: "array". Actual: "array"
[17][2][SUCCESS][amount of read records] Expected: 1 records. Actual: 1 records
[17][3][SUCCESS][type of read values] Expected: "object". Actual: "object"
[17][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record"
[17][5][SUCCESS]["second_name"] Expected: "Ivanov" (string). Actual: "Ivanov" (string)
[17][6][SUCCESS]["motivation"] Expected: "2.2250738585072E-308" (double). Actual: "2.2250738585072E-308" (double)
[17][7][SUCCESS]["reputation"] Expected: "-9223372036854775808" (integer). Actual: "-9223372036854775808" (integer)
[17] The read record by filter checks have been completed
[18] Read the record from the database by filter with amount limit
[19][1][SUCCESS][type of returned value] Expected: "array". Actual: "array"
[19][2][SUCCESS][amount of read records] Expected: 1 records. Actual: 1 records
[19][3][SUCCESS][type of read values] Expected: "object". Actual: "object"
[19][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record"
[19][5][SUCCESS]["age"] Expected: "24" (integer). Actual: "24" (integer)
[19][6][SUCCESS]["second_name"] Expected: "Mirzaev" (string). Actual: "Mirzaev" (string)
[19][7][SUCCESS]["motivation"] Expected: "2.2250738585072E-308" (double). Actual: "2.2250738585072E-308" (double)
[19][8][SUCCESS]["reputation"] Expected: "-9223372036854775808" (integer). Actual: "-9223372036854775808" (integer)
[19] The read record by filter with amount limit checks have been completed
[20] Read the record from the database by filter with amount limit and offset
[21][1][SUCCESS][type of returned value] Expected: "array". Actual: "array"
[21][2][SUCCESS][amount of read records] Expected: 1 records. Actual: 1 records
[21][3][SUCCESS][type of read values] Expected: "object". Actual: "object"
[21][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record"
[21][5][SUCCESS]["age"] Expected: "24" (integer). Actual: "24" (integer)
[21][6][SUCCESS]["second_name"] Expected: "Ivanov" (string). Actual: "Ivanov" (string)
[21][7][SUCCESS]["motivation"] Expected: "2.2250738585072E-308" (double). Actual: "2.2250738585072E-308" (double)
[21][8][SUCCESS]["reputation"] Expected: "-9223372036854775808" (integer). Actual: "-9223372036854775808" (integer)
[21] The read record by filter with amount limit and offset checks have been completed
[22] Deleted the record from the database by filter
[23] Read records from the database after deleting the record
[24][1][SUCCESS][type of returned value] Expected: "array". Actual: "array"
[24][2][SUCCESS][amount of deleted records] Expected: 1 records. Actual: 1 records
[24][3][SUCCESS][type of read values] Expected: "object". Actual: "object"
[24][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record"
[24][5][SUCCESS]["name"] Expected: "Ivan" (string). Actual: "Ivanov" (string)
[24][6][SUCCESS][amount of read records after deleting] Expected: 2 records. Actual: 2 records
[24][7][SUCCESS]["motivation"] Expected: "2.2250738585072E-308" (double). Actual: "2.2250738585072E-308" (double)
[24][8][SUCCESS]["reputation"] Expected: "-9223372036854775808" (integer). Actual: "-9223372036854775808" (integer)
[24] The deleted record by filter checks have been completed
[25] Updated the record in the database by filter
[26] Read records from the database after updating the record
[27][1][SUCCESS][type of returned value] Expected: "array". Actual: "array"
[27][2][SUCCESS][amount of updated records] Expected: 1 records. Actual: 1 records
[27][3][SUCCESS][type of read values] Expected: "object". Actual: "object"
[27][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record"
[27][5][SUCCESS]["height"] Expected: "165.5" (double). Actual: "165.5" (double)
[27][6][SUCCESS][amount of read records after updating] Expected: 2 records. Actual: 2 records
[27][7][SUCCESS] Height from `update` process response matched height from the `read` preocess response
[27][8][SUCCESS]["motivation"] Expected: "2.2250738585072E-308" (double). Actual: "2.2250738585072E-308" (double)
[27][9][SUCCESS]["reputation"] Expected: "-9223372036854775808" (integer). Actual: "-9223372036854775808" (integer)
[27] The updated record by filter checks have been completed


Completed testing
php record.php  0.01s user 0.02s system 88% cpu 0.036 total

Size: 399
Base raw: ArsenMirzaev%C0�f5�fqp<�MargaritaEsenina%C�`d@
Fixes #25 Incorrectly spelled words and wrong verb tenses are also fixed. Editorconfig additions for more comfortable collaboration +Test coverage Successfully integrated into deeproots in this [commit](https://git.svoboda.works/deeproots/deeproots_bot/commit/8147d2a3bf58ff1108955fdfe013156efe444b35) test.log ``` Started testing [1] Deleted deprecated database [2] Initialized the database [3] Initialized the record [4][1][SUCCESS]["name"] Expected: "Arsen" (string). Actual: "Arsen" (string) [4][2][SUCCESS]["second_name"] Expected: "Mirzaev" (string). Actual: "Mirzaev" (string) [4][3][SUCCESS]["age"] Expected: "24" (integer). Actual: "24" (integer) [4][4][SUCCESS]["height"] Expected: "165.5" (double). Actual: "165.5" (double) [4][5][SUCCESS]["neuron_count"] Expected: "91000000000" (integer). Actual: "91000000000" (integer) [4][6][SUCCESS]["motivation"] Expected: "1.7976931348623E+238" (double). Actual: "1.7976931348623E+238" (double) [4][7][SUCCESS]["reputation"] Expected: "7355608" (integer). Actual: "7355608" (integer) [4][8][SUCCESS]["active"] Expected: "1" (integer). Actual: "1" (integer) [4] The record parameters checks have been completed [5] Wrote the record into the database [6] Initialized the record [7] Wrote the record into the database [8] Initialized the record [9] Wrote the record into the database [10] Read all records from the database [11][1][SUCCESS][type of returned value] Expected: "array". Actual: "array" [11][2][SUCCESS][amount of read records] Expected: 3 records. Actual: 3 records [11][3][SUCCESS][type of read values] Expected: "object". Actual: "object" [11][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record" [11][5][SUCCESS]["neuron_count"] Expected: "91000000000" (integer). Actual: "91000000000" (integer) [11] The read all records checks have been completed [12] Read the first record from the database [13][1][SUCCESS][type of returned value] Expected: "array". Actual: "array" [13][2][SUCCESS][amount of read records] Expected: 1 records. Actual: 1 records [13][3][SUCCESS][type of read values] Expected: "object". Actual: "object" [13][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record" [13][5][SUCCESS]["second_name"] Expected: "Mirzaev" (string). Actual: "Mirzaev" (string) [13][6][SUCCESS]["neuron_count"] Expected: "91000000000" (integer). Actual: "91000000000" (integer) [13] The read first record checks have been completed [14] Read the second record from the database [15][1][SUCCESS][type of returned value] Expected: "array". Actual: "array" [15][2][SUCCESS][amount of read records] Expected: 1 records. Actual: 1 records [15][3][SUCCESS][type of read values] Expected: "object". Actual: "object" [15][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record" [15][5][SUCCESS]["second_name"] Expected: "Ivanov" (string). Actual: "Ivanov" (string) [15][6][SUCCESS]["motivation"] Expected: "2.2250738585072E-308" (double). Actual: "2.2250738585072E-308" (double) [15][7][SUCCESS]["reputation"] Expected: "-9223372036854775808" (integer). Actual: "-9223372036854775808" (integer) [15] The read second record checks have been completed [16] Read the record from the database by filter [17][1][SUCCESS][type of returned value] Expected: "array". Actual: "array" [17][2][SUCCESS][amount of read records] Expected: 1 records. Actual: 1 records [17][3][SUCCESS][type of read values] Expected: "object". Actual: "object" [17][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record" [17][5][SUCCESS]["second_name"] Expected: "Ivanov" (string). Actual: "Ivanov" (string) [17][6][SUCCESS]["motivation"] Expected: "2.2250738585072E-308" (double). Actual: "2.2250738585072E-308" (double) [17][7][SUCCESS]["reputation"] Expected: "-9223372036854775808" (integer). Actual: "-9223372036854775808" (integer) [17] The read record by filter checks have been completed [18] Read the record from the database by filter with amount limit [19][1][SUCCESS][type of returned value] Expected: "array". Actual: "array" [19][2][SUCCESS][amount of read records] Expected: 1 records. Actual: 1 records [19][3][SUCCESS][type of read values] Expected: "object". Actual: "object" [19][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record" [19][5][SUCCESS]["age"] Expected: "24" (integer). Actual: "24" (integer) [19][6][SUCCESS]["second_name"] Expected: "Mirzaev" (string). Actual: "Mirzaev" (string) [19][7][SUCCESS]["motivation"] Expected: "2.2250738585072E-308" (double). Actual: "2.2250738585072E-308" (double) [19][8][SUCCESS]["reputation"] Expected: "-9223372036854775808" (integer). Actual: "-9223372036854775808" (integer) [19] The read record by filter with amount limit checks have been completed [20] Read the record from the database by filter with amount limit and offset [21][1][SUCCESS][type of returned value] Expected: "array". Actual: "array" [21][2][SUCCESS][amount of read records] Expected: 1 records. Actual: 1 records [21][3][SUCCESS][type of read values] Expected: "object". Actual: "object" [21][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record" [21][5][SUCCESS]["age"] Expected: "24" (integer). Actual: "24" (integer) [21][6][SUCCESS]["second_name"] Expected: "Ivanov" (string). Actual: "Ivanov" (string) [21][7][SUCCESS]["motivation"] Expected: "2.2250738585072E-308" (double). Actual: "2.2250738585072E-308" (double) [21][8][SUCCESS]["reputation"] Expected: "-9223372036854775808" (integer). Actual: "-9223372036854775808" (integer) [21] The read record by filter with amount limit and offset checks have been completed [22] Deleted the record from the database by filter [23] Read records from the database after deleting the record [24][1][SUCCESS][type of returned value] Expected: "array". Actual: "array" [24][2][SUCCESS][amount of deleted records] Expected: 1 records. Actual: 1 records [24][3][SUCCESS][type of read values] Expected: "object". Actual: "object" [24][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record" [24][5][SUCCESS]["name"] Expected: "Ivan" (string). Actual: "Ivanov" (string) [24][6][SUCCESS][amount of read records after deleting] Expected: 2 records. Actual: 2 records [24][7][SUCCESS]["motivation"] Expected: "2.2250738585072E-308" (double). Actual: "2.2250738585072E-308" (double) [24][8][SUCCESS]["reputation"] Expected: "-9223372036854775808" (integer). Actual: "-9223372036854775808" (integer) [24] The deleted record by filter checks have been completed [25] Updated the record in the database by filter [26] Read records from the database after updating the record [27][1][SUCCESS][type of returned value] Expected: "array". Actual: "array" [27][2][SUCCESS][amount of updated records] Expected: 1 records. Actual: 1 records [27][3][SUCCESS][type of read values] Expected: "object". Actual: "object" [27][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record" [27][5][SUCCESS]["height"] Expected: "165.5" (double). Actual: "165.5" (double) [27][6][SUCCESS][amount of read records after updating] Expected: 2 records. Actual: 2 records [27][7][SUCCESS] Height from `update` process response matched height from the `read` preocess response [27][8][SUCCESS]["motivation"] Expected: "2.2250738585072E-308" (double). Actual: "2.2250738585072E-308" (double) [27][9][SUCCESS]["reputation"] Expected: "-9223372036854775808" (integer). Actual: "-9223372036854775808" (integer) [27] The updated record by filter checks have been completed Completed testing php record.php 0.01s user 0.02s system 88% cpu 0.036 total Size: 399 Base raw: ArsenMirzaev%C0�f5�fqp<�MargaritaEsenina%C�`d@ ```
Ghost added 3 commits 2025-07-12 04:27:31 +07:00

Нахера ты делаешь ARCH === 64?
Я НЕ ЗНАЮ ЧТО ТАКОЕ ARCH. Я ЗНАЮ ЧТО ТАКОЕ ARCHITECTURE

Убирай ARCH на хуй отсюда
Что ты будешь делать при PHP_INT_SIZE = 16?
Ты ничего не упростил этим. Лишняя логика.

НАРУШЕН PSR-4. УБИРАЙ НА ХУЙ ВСЁ КРОМЕ КЛАССА ИЗ ФАЙЛА.

Используй PHP_INT_SIZE === 8 ЛИБО в ядре должно быть статичное свойство core::architecture которое имеет

enum architecture: int {
  case x86 = 32;
  case x86_64 = 64;
}

$dolboeb = match(PHP_INT_SIZE) {
  4 => architecture::x86,
  8 => architecture::x86_64
  default => throw new exception_domain('Failed to determinate the system architecture');
}

var_dump($dolboeb->value) // 64
Нахера ты делаешь `ARCH === 64`? Я НЕ ЗНАЮ ЧТО ТАКОЕ `ARCH`. Я ЗНАЮ ЧТО ТАКОЕ `ARCHITECTURE` Убирай ARCH на хуй отсюда Что ты будешь делать при `PHP_INT_SIZE = 16`? Ты ничего не упростил этим. Лишняя логика. НАРУШЕН `PSR-4`. УБИРАЙ НА ХУЙ ВСЁ КРОМЕ КЛАССА ИЗ ФАЙЛА. Используй `PHP_INT_SIZE === 8` ЛИБО в ядре должно быть статичное свойство `core::architecture` которое имеет ```php enum architecture: int { case x86 = 32; case x86_64 = 64; } $dolboeb = match(PHP_INT_SIZE) { 4 => architecture::x86, 8 => architecture::x86_64 default => throw new exception_domain('Failed to determinate the system architecture'); } var_dump($dolboeb->value) // 64 ```
Arsen Mirzaev Tatyano-Muradovich requested review from Arsen Mirzaev Tatyano-Muradovich 2025-07-12 14:39:22 +07:00
Arsen Mirzaev Tatyano-Muradovich added the
Important
Status
Discussion
labels 2025-07-12 14:40:18 +07:00
Ghost added 1 commit 2025-07-12 14:46:18 +07:00
Ghost added 1 commit 2025-07-12 14:49:59 +07:00
Ghost added 1 commit 2025-07-12 14:53:58 +07:00
Ghost added 1 commit 2025-07-12 15:02:56 +07:00

ОТМЕНЯЙ e5fa761e8e
пусть английский язык празднует свою победу

ОТМЕНЯЙ https://git.svoboda.works/mirzaev/baza/commit/e5fa761e8ecf6f23c94066ea492e747751341512 пусть английский язык празднует свою победу
Ghost added 1 commit 2025-07-12 16:18:26 +07:00

Я тебе сказал свойство, а не метод

Зачем каждый раз вызывая core::architecture() ты заново определяешь архитектуру процессора?
Это можно сделать всего 1 раз при инициализации объекта и записать в статическое СВОЙСТВО

Я тебе сказал **свойство**, а не **метод** Зачем каждый раз вызывая `core::architecture()` ты заново определяешь архитектуру процессора? Это можно сделать всего 1 раз при инициализации объекта и записать в статическое **СВОЙСТВО**
Arsen Mirzaev Tatyano-Muradovich changed title from #25-fix-64bit-values to WIP: #25-fix-64bit-values 2025-07-12 16:27:33 +07:00

mirzaev/baza/system/core.php строка 27 ОШИБКА
у тебя никогда не бывает возврата null

В документации добавить @throws exception_domain Объяснение

`mirzaev/baza/system/core.php` строка 27 ОШИБКА у тебя никогда не бывает возврата `null` В документации добавить `@throws exception_domain Объяснение`

@author не забудь свой добавить

`@author` не забудь свой добавить

Я тебе сказал убрать define('ARCHITECTURE', core::architecture());
Это нарушает вообще всё: и эстетику, и стандарт PSR-4 и общепринятый почерк в проекте.

Я тебе сказал убрать `define('ARCHITECTURE', core::architecture());` Это нарушает вообще всё: и эстетику, и стандарт PSR-4 и общепринятый почерк в проекте.
Ghost added 1 commit 2025-07-12 21:35:01 +07:00
Ghost added 1 commit 2025-07-12 21:38:18 +07:00
Ghost added 1 commit 2025-07-12 21:44:39 +07:00
Ghost added 1 commit 2025-07-12 21:48:24 +07:00

Тесты проходят успешно, жду комментарии

test.log

Started testing


[1] Deleted deprecated database
[2] Initialized the database
[3] Initialized the record
[4][1][SUCCESS]["name"] Expected: "Arsen" (string). Actual: "Arsen" (string)
[4][2][SUCCESS]["second_name"] Expected: "Mirzaev" (string). Actual: "Mirzaev" (string)
[4][3][SUCCESS]["age"] Expected: "24" (integer). Actual: "24" (integer)
[4][4][SUCCESS]["height"] Expected: "165.5" (double). Actual: "165.5" (double)
[4][5][SUCCESS]["neuron_count"] Expected: "91000000000" (integer). Actual: "91000000000" (integer)
[4][6][SUCCESS]["motivation"] Expected: "1.7976931348623E+238" (double). Actual: "1.7976931348623E+238" (double)
[4][7][SUCCESS]["reputation"] Expected: "7355608" (integer). Actual: "7355608" (integer)
[4][8][SUCCESS]["active"] Expected: "1" (integer). Actual: "1" (integer)
[4] The record parameters checks have been completed
[5] Wrote the record into the database
[6] Initialized the record
[7] Wrote the record into the database
[8] Initialized the record
[9] Wrote the record into the database
[10] Read all records from the database
[11][1][SUCCESS][type of returned value] Expected: "array". Actual: "array"
[11][2][SUCCESS][amount of read records] Expected: 3 records. Actual: 3 records
[11][3][SUCCESS][type of read values] Expected: "object". Actual: "object"
[11][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record"
[11][5][SUCCESS]["neuron_count"] Expected: "91000000000" (integer). Actual: "91000000000" (integer)
[11] The read all records checks have been completed
[12] Read the first record from the database
[13][1][SUCCESS][type of returned value] Expected: "array". Actual: "array"
[13][2][SUCCESS][amount of read records] Expected: 1 records. Actual: 1 records
[13][3][SUCCESS][type of read values] Expected: "object". Actual: "object"
[13][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record"
[13][5][SUCCESS]["second_name"] Expected: "Mirzaev" (string). Actual: "Mirzaev" (string)
[13][6][SUCCESS]["neuron_count"] Expected: "91000000000" (integer). Actual: "91000000000" (integer)
[13] The read first record checks have been completed
[14] Read the second record from the database
[15][1][SUCCESS][type of returned value] Expected: "array". Actual: "array"
[15][2][SUCCESS][amount of read records] Expected: 1 records. Actual: 1 records
[15][3][SUCCESS][type of read values] Expected: "object". Actual: "object"
[15][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record"
[15][5][SUCCESS]["second_name"] Expected: "Ivanov" (string). Actual: "Ivanov" (string)
[15][6][SUCCESS]["motivation"] Expected: "2.2250738585072E-308" (double). Actual: "2.2250738585072E-308" (double)
[15][7][SUCCESS]["reputation"] Expected: "-9223372036854775808" (integer). Actual: "-9223372036854775808" (integer)
[15] The read second record checks have been completed
[16] Read the record from the database by filter
[17][1][SUCCESS][type of returned value] Expected: "array". Actual: "array"
[17][2][SUCCESS][amount of read records] Expected: 1 records. Actual: 1 records
[17][3][SUCCESS][type of read values] Expected: "object". Actual: "object"
[17][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record"
[17][5][SUCCESS]["second_name"] Expected: "Ivanov" (string). Actual: "Ivanov" (string)
[17][6][SUCCESS]["motivation"] Expected: "2.2250738585072E-308" (double). Actual: "2.2250738585072E-308" (double)
[17][7][SUCCESS]["reputation"] Expected: "-9223372036854775808" (integer). Actual: "-9223372036854775808" (integer)
[17] The read record by filter checks have been completed
[18] Read the record from the database by filter with amount limit
[19][1][SUCCESS][type of returned value] Expected: "array". Actual: "array"
[19][2][SUCCESS][amount of read records] Expected: 1 records. Actual: 1 records
[19][3][SUCCESS][type of read values] Expected: "object". Actual: "object"
[19][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record"
[19][5][SUCCESS]["age"] Expected: "24" (integer). Actual: "24" (integer)
[19][6][SUCCESS]["second_name"] Expected: "Mirzaev" (string). Actual: "Mirzaev" (string)
[19][7][SUCCESS]["motivation"] Expected: "2.2250738585072E-308" (double). Actual: "2.2250738585072E-308" (double)
[19][8][SUCCESS]["reputation"] Expected: "-9223372036854775808" (integer). Actual: "-9223372036854775808" (integer)
[19] The read record by filter with amount limit checks have been completed
[20] Read the record from the database by filter with amount limit and offset
[21][1][SUCCESS][type of returned value] Expected: "array". Actual: "array"
[21][2][SUCCESS][amount of read records] Expected: 1 records. Actual: 1 records
[21][3][SUCCESS][type of read values] Expected: "object". Actual: "object"
[21][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record"
[21][5][SUCCESS]["age"] Expected: "24" (integer). Actual: "24" (integer)
[21][6][SUCCESS]["second_name"] Expected: "Ivanov" (string). Actual: "Ivanov" (string)
[21][7][SUCCESS]["motivation"] Expected: "2.2250738585072E-308" (double). Actual: "2.2250738585072E-308" (double)
[21][8][SUCCESS]["reputation"] Expected: "-9223372036854775808" (integer). Actual: "-9223372036854775808" (integer)
[21] The read record by filter with amount limit and offset checks have been completed
[22] Deleted the record from the database by filter
[23] Read records from the database after deleting the record
[24][1][SUCCESS][type of returned value] Expected: "array". Actual: "array"
[24][2][SUCCESS][amount of deleted records] Expected: 1 records. Actual: 1 records
[24][3][SUCCESS][type of read values] Expected: "object". Actual: "object"
[24][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record"
[24][5][SUCCESS]["name"] Expected: "Ivan" (string). Actual: "Ivanov" (string)
[24][6][SUCCESS][amount of read records after deleting] Expected: 2 records. Actual: 2 records
[24][7][SUCCESS]["motivation"] Expected: "163" (double). Actual: "163" (double)
[24][8][SUCCESS]["reputation"] Expected: "9223372036854775807" (integer). Actual: "9223372036854775807" (integer)
[24] The deleted record by filter checks have been completed
[25] Updated the record in the database by filter
[26] Read records from the database after updating the record
[27][1][SUCCESS][type of returned value] Expected: "array". Actual: "array"
[27][2][SUCCESS][amount of updated records] Expected: 1 records. Actual: 1 records
[27][3][SUCCESS][type of read values] Expected: "object". Actual: "object"
[27][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record"
[27][5][SUCCESS]["height"] Expected: "165.5" (double). Actual: "165.5" (double)
[27][6][SUCCESS][amount of read records after updating] Expected: 2 records. Actual: 2 records
[27][7][SUCCESS] Height from `update` process response matched height from the `read` preocess response
[27][8][SUCCESS]["motivation"] Expected: "2.2250738585072E-308" (double). Actual: "2.2250738585072E-308" (double)
[27][9][SUCCESS]["reputation"] Expected: "-9223372036854775808" (integer). Actual: "-9223372036854775808" (integer)
[27] The updated record by filter checks have been completed


Completed testing
php record.php  0.02s user 0.02s system 88% cpu 0.037 total

Size: 399
Base raw: ArsenMirzaev%C0�f5�fqp<�MargaritaEsenina%C�`d@
Тесты проходят успешно, жду комментарии test.log ``` Started testing [1] Deleted deprecated database [2] Initialized the database [3] Initialized the record [4][1][SUCCESS]["name"] Expected: "Arsen" (string). Actual: "Arsen" (string) [4][2][SUCCESS]["second_name"] Expected: "Mirzaev" (string). Actual: "Mirzaev" (string) [4][3][SUCCESS]["age"] Expected: "24" (integer). Actual: "24" (integer) [4][4][SUCCESS]["height"] Expected: "165.5" (double). Actual: "165.5" (double) [4][5][SUCCESS]["neuron_count"] Expected: "91000000000" (integer). Actual: "91000000000" (integer) [4][6][SUCCESS]["motivation"] Expected: "1.7976931348623E+238" (double). Actual: "1.7976931348623E+238" (double) [4][7][SUCCESS]["reputation"] Expected: "7355608" (integer). Actual: "7355608" (integer) [4][8][SUCCESS]["active"] Expected: "1" (integer). Actual: "1" (integer) [4] The record parameters checks have been completed [5] Wrote the record into the database [6] Initialized the record [7] Wrote the record into the database [8] Initialized the record [9] Wrote the record into the database [10] Read all records from the database [11][1][SUCCESS][type of returned value] Expected: "array". Actual: "array" [11][2][SUCCESS][amount of read records] Expected: 3 records. Actual: 3 records [11][3][SUCCESS][type of read values] Expected: "object". Actual: "object" [11][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record" [11][5][SUCCESS]["neuron_count"] Expected: "91000000000" (integer). Actual: "91000000000" (integer) [11] The read all records checks have been completed [12] Read the first record from the database [13][1][SUCCESS][type of returned value] Expected: "array". Actual: "array" [13][2][SUCCESS][amount of read records] Expected: 1 records. Actual: 1 records [13][3][SUCCESS][type of read values] Expected: "object". Actual: "object" [13][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record" [13][5][SUCCESS]["second_name"] Expected: "Mirzaev" (string). Actual: "Mirzaev" (string) [13][6][SUCCESS]["neuron_count"] Expected: "91000000000" (integer). Actual: "91000000000" (integer) [13] The read first record checks have been completed [14] Read the second record from the database [15][1][SUCCESS][type of returned value] Expected: "array". Actual: "array" [15][2][SUCCESS][amount of read records] Expected: 1 records. Actual: 1 records [15][3][SUCCESS][type of read values] Expected: "object". Actual: "object" [15][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record" [15][5][SUCCESS]["second_name"] Expected: "Ivanov" (string). Actual: "Ivanov" (string) [15][6][SUCCESS]["motivation"] Expected: "2.2250738585072E-308" (double). Actual: "2.2250738585072E-308" (double) [15][7][SUCCESS]["reputation"] Expected: "-9223372036854775808" (integer). Actual: "-9223372036854775808" (integer) [15] The read second record checks have been completed [16] Read the record from the database by filter [17][1][SUCCESS][type of returned value] Expected: "array". Actual: "array" [17][2][SUCCESS][amount of read records] Expected: 1 records. Actual: 1 records [17][3][SUCCESS][type of read values] Expected: "object". Actual: "object" [17][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record" [17][5][SUCCESS]["second_name"] Expected: "Ivanov" (string). Actual: "Ivanov" (string) [17][6][SUCCESS]["motivation"] Expected: "2.2250738585072E-308" (double). Actual: "2.2250738585072E-308" (double) [17][7][SUCCESS]["reputation"] Expected: "-9223372036854775808" (integer). Actual: "-9223372036854775808" (integer) [17] The read record by filter checks have been completed [18] Read the record from the database by filter with amount limit [19][1][SUCCESS][type of returned value] Expected: "array". Actual: "array" [19][2][SUCCESS][amount of read records] Expected: 1 records. Actual: 1 records [19][3][SUCCESS][type of read values] Expected: "object". Actual: "object" [19][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record" [19][5][SUCCESS]["age"] Expected: "24" (integer). Actual: "24" (integer) [19][6][SUCCESS]["second_name"] Expected: "Mirzaev" (string). Actual: "Mirzaev" (string) [19][7][SUCCESS]["motivation"] Expected: "2.2250738585072E-308" (double). Actual: "2.2250738585072E-308" (double) [19][8][SUCCESS]["reputation"] Expected: "-9223372036854775808" (integer). Actual: "-9223372036854775808" (integer) [19] The read record by filter with amount limit checks have been completed [20] Read the record from the database by filter with amount limit and offset [21][1][SUCCESS][type of returned value] Expected: "array". Actual: "array" [21][2][SUCCESS][amount of read records] Expected: 1 records. Actual: 1 records [21][3][SUCCESS][type of read values] Expected: "object". Actual: "object" [21][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record" [21][5][SUCCESS]["age"] Expected: "24" (integer). Actual: "24" (integer) [21][6][SUCCESS]["second_name"] Expected: "Ivanov" (string). Actual: "Ivanov" (string) [21][7][SUCCESS]["motivation"] Expected: "2.2250738585072E-308" (double). Actual: "2.2250738585072E-308" (double) [21][8][SUCCESS]["reputation"] Expected: "-9223372036854775808" (integer). Actual: "-9223372036854775808" (integer) [21] The read record by filter with amount limit and offset checks have been completed [22] Deleted the record from the database by filter [23] Read records from the database after deleting the record [24][1][SUCCESS][type of returned value] Expected: "array". Actual: "array" [24][2][SUCCESS][amount of deleted records] Expected: 1 records. Actual: 1 records [24][3][SUCCESS][type of read values] Expected: "object". Actual: "object" [24][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record" [24][5][SUCCESS]["name"] Expected: "Ivan" (string). Actual: "Ivanov" (string) [24][6][SUCCESS][amount of read records after deleting] Expected: 2 records. Actual: 2 records [24][7][SUCCESS]["motivation"] Expected: "163" (double). Actual: "163" (double) [24][8][SUCCESS]["reputation"] Expected: "9223372036854775807" (integer). Actual: "9223372036854775807" (integer) [24] The deleted record by filter checks have been completed [25] Updated the record in the database by filter [26] Read records from the database after updating the record [27][1][SUCCESS][type of returned value] Expected: "array". Actual: "array" [27][2][SUCCESS][amount of updated records] Expected: 1 records. Actual: 1 records [27][3][SUCCESS][type of read values] Expected: "object". Actual: "object" [27][4][SUCCESS][class of read object values] Expected: "mirzaev\baza\record". Actual: "mirzaev\baza\record" [27][5][SUCCESS]["height"] Expected: "165.5" (double). Actual: "165.5" (double) [27][6][SUCCESS][amount of read records after updating] Expected: 2 records. Actual: 2 records [27][7][SUCCESS] Height from `update` process response matched height from the `read` preocess response [27][8][SUCCESS]["motivation"] Expected: "2.2250738585072E-308" (double). Actual: "2.2250738585072E-308" (double) [27][9][SUCCESS]["reputation"] Expected: "-9223372036854775808" (integer). Actual: "-9223372036854775808" (integer) [27] The updated record by filter checks have been completed Completed testing php record.php 0.02s user 0.02s system 88% cpu 0.037 total Size: 399 Base raw: ArsenMirzaev%C0�f5�fqp<�MargaritaEsenina%C�`d@ ```
@mirzaev
Ghost added 1 commit 2025-07-12 21:52:44 +07:00
Ghost added 1 commit 2025-07-13 00:38:46 +07:00
Ghost added 1 commit 2025-07-13 00:42:07 +07:00

Никаких камел кейс. Никаких МЕТОДОВ-СЕТТЕРОВ. убери этот ужас. я тебе уже говорил убрать
что за уродство внутри конструктора?

что значит PHP implementation architecture? PHP ничего не имплементирует, это МЫ имплементируем. Да и вообещ это не имплементация, а вычисление/обнаружение. Имплементация это создание интерфейса или абстрактной надстройки над чем-то. Мы здесь просто посчитали какая длина команды процессора и всё.

ужас. я тебе готовый код написал уже три раза сейчас четвёртый раз писать буду

 /**
  * Architecture
  *
  * @var architecture $architecture CPU architecture
  */
  public architecture $architecture = match(PHP_INT_SIZE) {
    4 => architecture::x86,
    8 => architecture::x86_64,
    default => throw new exception_domain('Failed to determine system architecture'),
  };

Если тебе настолько сильно нужен сеттер, то создай магическую функцию, либо хук, а не уродливую функцию-сеттер.
https://sergeymukhin.com/blog/php-84-property-hooks?ysclid=md1bnenlv4465904648

Пример ниже взят с сайта Сергея Мухина

class User
{
    public string $name {
        set (string $value) {
            // валидация имени
            if (mb_strlen(value) < 4)) {
                throw new InvalidArgumentException(
                    'Invalid Name'
                );
            }
            
            // Установка значения
            $this->name = $value;
        }
    }
}

НО ЗДЕСЬ ВООБЩЕ НЕ НУЖЕН СЕТТЕР. НИ В КАКОМ ВИДЕ. МЫ НЕ БУДЕМ МЕНЯТЬ АРХИТЕКТУРУ ПРОЦЕССОРА НА ЛЕТУ. МЫ НЕ БУДЕМ МЕНЯТЬ ПРОЦЕССОРЫ БЕЗ ПЕРЕЗАПУСКА КОМПЬЮТЕРА. ТАКОГО НЕ БЫВАЕТ. ТЫ СОЗДАЛ НЕНУЖНУЮ ВСЕХ ПУТАЮЩУЮ И НЕКРАСИВУЮ ФУНКЦИЮ, ВСЁ УСЛОЖНИЛ.

ПИШИ НОРМАЛЬНЫЕ КОММЕНТАРИИ К КОММИТАМ. ПОЧЕМУ Я ДОЛЖЕН ПО ЭТОЙ ХУЙНЕ БЕГАТЬ ПО СТО РАЗ?

Никаких камел кейс. Никаких МЕТОДОВ-СЕТТЕРОВ. убери этот ужас. я тебе уже говорил убрать что за уродство внутри конструктора? что значит ` PHP implementation architecture`? PHP ничего не имплементирует, это МЫ имплементируем. Да и вообещ это не имплементация, а вычисление/обнаружение. Имплементация это создание интерфейса или абстрактной надстройки над чем-то. Мы здесь просто посчитали какая длина команды процессора и всё. ужас. я тебе готовый код написал уже три раза сейчас четвёртый раз писать буду ```php /** * Architecture * * @var architecture $architecture CPU architecture */ public architecture $architecture = match(PHP_INT_SIZE) { 4 => architecture::x86, 8 => architecture::x86_64, default => throw new exception_domain('Failed to determine system architecture'), }; ``` Если тебе настолько сильно нужен сеттер, то создай магическую функцию, либо хук, а не уродливую функцию-сеттер. https://sergeymukhin.com/blog/php-84-property-hooks?ysclid=md1bnenlv4465904648 Пример ниже взят с сайта Сергея Мухина ```php class User { public string $name { set (string $value) { // валидация имени if (mb_strlen(value) < 4)) { throw new InvalidArgumentException( 'Invalid Name' ); } // Установка значения $this->name = $value; } } } ``` **НО ЗДЕСЬ ВООБЩЕ НЕ НУЖЕН СЕТТЕР. НИ В КАКОМ ВИДЕ. МЫ НЕ БУДЕМ МЕНЯТЬ АРХИТЕКТУРУ ПРОЦЕССОРА НА ЛЕТУ. МЫ НЕ БУДЕМ МЕНЯТЬ ПРОЦЕССОРЫ БЕЗ ПЕРЕЗАПУСКА КОМПЬЮТЕРА. ТАКОГО НЕ БЫВАЕТ. ТЫ СОЗДАЛ НЕНУЖНУЮ ВСЕХ ПУТАЮЩУЮ И НЕКРАСИВУЮ ФУНКЦИЮ, ВСЁ УСЛОЖНИЛ.** # ПИШИ НОРМАЛЬНЫЕ КОММЕНТАРИИ К КОММИТАМ. ПОЧЕМУ Я ДОЛЖЕН ПО ЭТОЙ ХУЙНЕ БЕГАТЬ ПО СТО РАЗ?

У enum объектов можно создавать функции.
Логику разделения ячейки памяти надо засунуть туда.
Чтобы разделяло в зависимости от нашего enum
Это нужно для 128-бит 256-бит 10000000-бит процессоров и так далее

ПОЕБАТЬ что таких архитектур не бывает. Это просто правильный код.
Это есть правильный подход к программированию. Мышление.

ниже это пример, ТОЛЬКО ПРИМЕР

$left = $database->architecture->offset();
У `enum` объектов можно создавать функции. Логику разделения ячейки памяти надо засунуть туда. Чтобы разделяло в зависимости от нашего `enum` Это нужно для 128-бит 256-бит 10000000-бит процессоров и так далее ПОЕБАТЬ что таких архитектур не бывает. Это просто правильный код. Это есть правильный подход к программированию. Мышление. ниже это пример, ТОЛЬКО ПРИМЕР ```php $left = $database->architecture->offset(); ```

Комментарий ты вписал так как его ни один интерпретатор документации не поймёт.

Ты засунул его внутрь конструкции
image

То же самое что и

$dolboeb = 2 + /* Здарова тут мы считаем математику */ 2;

Любой компилятор документации тебе кабину пробьёт за такие приколы

Комментарий ты вписал так как его ни один интерпретатор документации не поймёт. Ты засунул его внутрь конструкции ![image](/attachments/a2a08536-f5ea-46fd-9fa6-363d57a90226) То же самое что и ```php $dolboeb = 2 + /* Здарова тут мы считаем математику */ 2; ``` Любой компилятор документации тебе кабину пробьёт за такие приколы

Камел кейс по PSR-1 стандарту. У тебя все методы в одно слово, стиль нейминга проекта заимствовать было неоткуда (кроме как из других твоих репозиториев, туда я с этой целью не залезал)

Я бы с радостью инициализовал свойство динамически, но это невозможно сделать внутри объявления класса, PHP не даёт никаких инструментов для инлайнинга. Дело не в том, что свойство статическое, свойства в объявлении класса в принципе нельзя инициализировать не статически до создания объекта:

...
private $preved = strtoupper('preved'); // Constant expression contains invalid operations
...

Архитектуру процессора хотелось бы получить без создания новых классов и уродливых сеттеров. Давай уж остановимся на магическом методе __construct(). Хук тут, по моему мнению, не нужен. Будет то, что я сделал коммитом выше, но без уродливой ненужной функции, её заинлайним в __construct:

public static architecture $architecture;

/** 
 * От моего предыдущего решения не отличается, просто заинлайнили setArchitecture() в __construct()
 *
 * Ну не можем мы инициализировать $architecture внутри объявления класса, присваиваем значение
 * автоматически при инициализации объекта
 */ 
public function __construct() {
	if (isset(self::$architecture) ) {
		return;
	}

	self::$architecture = match(PHP_INT_SIZE) {
		4 => architecture::x86,
		8 => architecture::x86_64,
		default => throw new exception_domain('Failed to determine system architecture'),
	};
}

Это не я, это ООП

Камел кейс по [PSR-1 стандарту](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md#43-methods). У тебя все методы в одно слово, стиль нейминга проекта заимствовать было неоткуда (кроме как из других твоих репозиториев, туда я с этой целью не залезал) Я бы с радостью инициализовал свойство динамически, но это невозможно сделать внутри объявления класса, PHP не даёт никаких инструментов для инлайнинга. Дело не в том, что свойство статическое, свойства в объявлении класса в принципе нельзя инициализировать не статически до создания объекта: ```php ... private $preved = strtoupper('preved'); // Constant expression contains invalid operations ... ``` Архитектуру процессора хотелось бы получить без создания новых классов и уродливых сеттеров. Давай уж остановимся на магическом методе __construct(). Хук тут, по моему мнению, не нужен. Будет то, что я сделал коммитом выше, но без уродливой ненужной функции, её заинлайним в __construct: ```php public static architecture $architecture; /** * От моего предыдущего решения не отличается, просто заинлайнили setArchitecture() в __construct() * * Ну не можем мы инициализировать $architecture внутри объявления класса, присваиваем значение * автоматически при инициализации объекта */ public function __construct() { if (isset(self::$architecture) ) { return; } self::$architecture = match(PHP_INT_SIZE) { 4 => architecture::x86, 8 => architecture::x86_64, default => throw new exception_domain('Failed to determine system architecture'), }; } ``` Это не я, это ООП

Камел кейс по PSR-1 стандарту.

Во-первых пошёл на хуй PSR-1
Во-вторых_там_есть_вот_такое
В-третьих я пишу код где ни один из этих написаний не нужен

Я понял что заимствовать было неоткуда.
В своих проектах пиши как хочешь, но в моих пиши как я пишу.
В твоих проектах я буду писать как ты хочешь. Всё честно.
В общих проектах дерёмся насмерть.

Про динамическую инициализацию мы уже обсудили в телеграме

Код пиши в конструкторе, но убери совершенно бесполезный

	if (isset(self::$architecture) ) {
		return;
	}

Это условие не выполнится никогда и следовательно код бессмысленный

> Камел кейс по PSR-1 стандарту. Во-первых пошёл на хуй PSR-1 Во-вторых_там_есть_вот_такое В-третьих я пишу код где ни один из этих написаний не нужен Я понял что заимствовать было неоткуда. В своих проектах пиши как хочешь, но в моих пиши как я пишу. В твоих проектах я буду писать как ты хочешь. Всё честно. В общих проектах дерёмся насмерть. Про динамическую инициализацию мы уже обсудили в телеграме Код пиши в конструкторе, но убери совершенно бесполезный ```php if (isset(self::$architecture) ) { return; } ``` Это условие не выполнится никогда и следовательно код бессмысленный

Это не я, это ООП

ООП говно

> Это не я, это ООП ООП говно

Про PSR-1 я переборщил. Он на все 100% правильный.

Про `PSR-1` я переборщил. Он на все 100% правильный.

У enum объектов можно создавать функции.
Логику разделения ячейки памяти надо засунуть туда.
Чтобы разделяло в зависимости от нашего enum
Это нужно для 128-бит 256-бит 10000000-бит процессоров и так далее

Сделал два решения:

  1. оффсет функция, которая возвращает распиленное на два или более целочисленное значение
enum architecture: int
{
	case x86 = 32;
	case x86_64 = 64;	
    
    public function offset(int $number): array {
		if ($this <= architecture::x86) {
			return [$number];
		};

		$segment_count = $this->value / architecture::x86->value;

		$buffer = [];
		for($i = 0; $i < $segment_count; ++$i) {
			$r = $segment_count - $i - 1;
			$buffer[] = ($number & (0xffffffff << (32*$r))) >> (32*$r);
		}

		return $buffer;
	}
}


$arch32 = architecture::x86;
var_dump($arch32->offset(12345));

$arch64 = architecture::x86_64;
var_dump($arch64->offset(12345));
var_dump($arch64->offset(0xcccccccccccccc));

Вывод:

array(1) {
  [0]=>
  int(12345)
}
array(2) {
  [0]=>
  int(0)
  [1]=>
  int(12345)
}
array(2) {
  [0]=>
  int(13421772)
  [1]=>
  int(3435973836)
}
  1. pack() и unpack() внутри enum
enum architecture: int
{
	case x86 = 32;
	case x86_64 = 64;	

	public function pack(type $type, int $number): string {
		if ($this <= architecture::x86) {
			return pack($type->value, $number);
		};

		$segment_count = $this->value / architecture::x86->value;

		$packed = '';
		for($i = 0; $i < $segment_count; ++$i) {
			$r = $segment_count - $i - 1;
			$packed .= pack('N', ($number & (0xffffffff << (32*$r))) >> (32*$r));
		}

		return $packed;
	}

	public function unpack(type $type, string $binary): int {
		if ($this <= architecture::x86) {
			return unpack($type->value, $binary)[1];
		};

		$segment_count = $this->value / architecture::x86->value;
		$unpacked = unpack('N' . $segment_count, $binary);

		$number = 0;
		for($i = 0; $i < $segment_count; ++$i) {
			$r = $segment_count - $i;
			$number = $number | $unpacked[$r] << (32*$i);
		}

		return $number;
	}
}


$arch32 = architecture::x86;
$packed = $arch32->pack(type::integer, 12345);
var_dump($arch32->unpack(type::integer, $packed));

$arch64 = architecture::x86_64;
$packed = $arch64->pack(type::integer, 12345);
var_dump($arch64->unpack(type::integer, $packed));
$packed = $arch64->pack(type::integer, 0xcccccccccccccc);
var_dump($arch64->unpack(type::integer, $packed));

Вывод:

int(12345)
int(12345)
int(57646075230342348)
> У enum объектов можно создавать функции. > Логику разделения ячейки памяти надо засунуть туда. > Чтобы разделяло в зависимости от нашего enum > Это нужно для 128-бит 256-бит 10000000-бит процессоров и так далее Сделал два решения: 1. оффсет функция, которая возвращает распиленное на два или более целочисленное значение ```php enum architecture: int { case x86 = 32; case x86_64 = 64; public function offset(int $number): array { if ($this <= architecture::x86) { return [$number]; }; $segment_count = $this->value / architecture::x86->value; $buffer = []; for($i = 0; $i < $segment_count; ++$i) { $r = $segment_count - $i - 1; $buffer[] = ($number & (0xffffffff << (32*$r))) >> (32*$r); } return $buffer; } } $arch32 = architecture::x86; var_dump($arch32->offset(12345)); $arch64 = architecture::x86_64; var_dump($arch64->offset(12345)); var_dump($arch64->offset(0xcccccccccccccc)); ``` Вывод: ``` array(1) { [0]=> int(12345) } array(2) { [0]=> int(0) [1]=> int(12345) } array(2) { [0]=> int(13421772) [1]=> int(3435973836) } ``` 2. pack() и unpack() внутри enum ```php enum architecture: int { case x86 = 32; case x86_64 = 64; public function pack(type $type, int $number): string { if ($this <= architecture::x86) { return pack($type->value, $number); }; $segment_count = $this->value / architecture::x86->value; $packed = ''; for($i = 0; $i < $segment_count; ++$i) { $r = $segment_count - $i - 1; $packed .= pack('N', ($number & (0xffffffff << (32*$r))) >> (32*$r)); } return $packed; } public function unpack(type $type, string $binary): int { if ($this <= architecture::x86) { return unpack($type->value, $binary)[1]; }; $segment_count = $this->value / architecture::x86->value; $unpacked = unpack('N' . $segment_count, $binary); $number = 0; for($i = 0; $i < $segment_count; ++$i) { $r = $segment_count - $i; $number = $number | $unpacked[$r] << (32*$i); } return $number; } } $arch32 = architecture::x86; $packed = $arch32->pack(type::integer, 12345); var_dump($arch32->unpack(type::integer, $packed)); $arch64 = architecture::x86_64; $packed = $arch64->pack(type::integer, 12345); var_dump($arch64->unpack(type::integer, $packed)); $packed = $arch64->pack(type::integer, 0xcccccccccccccc); var_dump($arch64->unpack(type::integer, $packed)); ``` Вывод: ``` int(12345) int(12345) int(57646075230342348) ```
@mirzaev
Ghost closed this pull request 2025-07-15 19:00:46 +07:00
Arsen Mirzaev Tatyano-Muradovich added
Status
Rejected
and removed
Status
Discussion
labels 2025-08-04 10:34:41 +07:00

Pull request closed

Sign in to join this conversation.
No description provided.