mirror of
https://github.com/igorsimdyanov/php8.git
synced 2025-08-15 23:31:10 +00:00
Главы 30-33: корректура
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
interface BackedEnum extends UnitEnum {
|
||||
interface BackedEnum extends UnitEnum
|
||||
{
|
||||
/* Методы */
|
||||
public static from(int|string $value): static
|
||||
public static tryFrom(int|string $value): ?static
|
||||
|
@ -3,6 +3,6 @@ require_once 'rainbow.php';
|
||||
|
||||
$col = Rainbow::Green;
|
||||
|
||||
foreach($col->cases() as $object) {
|
||||
foreach ($col->cases() as $object) {
|
||||
echo $object->name . '<br />';
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
require_once 'rainbow.php';
|
||||
|
||||
foreach(Rainbow::cases() as $object) {
|
||||
foreach (Rainbow::cases() as $object) {
|
||||
echo $object->name . '<br />';
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
require_once 'rainbow_translate.php';
|
||||
|
||||
foreach(Rainbow::cases() as $object) {
|
||||
echo 'Перевод для ' . $object->russian() . ': ' . $object->english() . '<br />';
|
||||
foreach (Rainbow::cases() as $object) {
|
||||
echo 'Перевод для ' . $object->russian() . ': ' .
|
||||
$object->english() . '<br />';
|
||||
}
|
||||
|
@ -3,6 +3,6 @@ require_once('trait_rainbow.php');
|
||||
|
||||
echo 'Количество цветов: '. Rainbow::size() . '<br />' . PHP_EOL;
|
||||
|
||||
foreach(Rainbow::cases() as $object) {
|
||||
foreach (Rainbow::cases() as $object) {
|
||||
echo $object->russian() . '<br />' . PHP_EOL;
|
||||
}
|
||||
|
@ -3,7 +3,8 @@ require_once 'topic.php';
|
||||
require_once 'author.php';
|
||||
require_once 'seo.php';
|
||||
|
||||
class Article extends Topic implements Author, Seo {
|
||||
class Article extends Topic implements Author, Seo
|
||||
{
|
||||
public array $authors;
|
||||
private ?string $seo_title;
|
||||
private ?string $seo_description;
|
||||
@ -28,7 +29,7 @@ class Article extends Topic implements Author, Seo {
|
||||
}
|
||||
public function title() : ?string
|
||||
{
|
||||
if(!empty($this->seo_title)) {
|
||||
if (!empty($this->seo_title)) {
|
||||
return $this->seo_title;
|
||||
} else {
|
||||
return $this->title;
|
||||
|
@ -1,7 +1,10 @@
|
||||
<?php
|
||||
interface Seo
|
||||
{
|
||||
public function seo(?string $title, ?string $description, ?array $keywords);
|
||||
public function seo(
|
||||
?string $title,
|
||||
?string $description,
|
||||
?array $keywords);
|
||||
public function title() : ?string;
|
||||
public function description() : ?string;
|
||||
public function keywords() : ?array;
|
||||
|
@ -10,7 +10,7 @@ class Topic implements Cover
|
||||
public string $content,
|
||||
public ?int $published_at = null)
|
||||
{
|
||||
if(empty($published_at)) {
|
||||
if (empty($published_at)) {
|
||||
$this->published_at = time();
|
||||
} else {
|
||||
$this->published_at = $published_at;
|
||||
|
@ -8,7 +8,8 @@ class User
|
||||
public ?string $last_name = null)
|
||||
{}
|
||||
|
||||
public function fullName() : string {
|
||||
public function fullName() : string
|
||||
{
|
||||
$arr_name = array_filter([$this->first_name, $this->last_name]);
|
||||
$full_name = implode(' ', $arr_name);
|
||||
return empty($full_name) ? 'Анонимный пользователь' : $full_name;
|
||||
|
@ -3,7 +3,8 @@ require_once 'topic.php';
|
||||
require_once 'author.php';
|
||||
require_once 'seo.php';
|
||||
|
||||
class Article extends Topic {
|
||||
class Article extends Topic
|
||||
{
|
||||
use Author;
|
||||
use Seo;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ trait Seo
|
||||
}
|
||||
public function title() : ?string
|
||||
{
|
||||
if(!empty($this->seo_title)) {
|
||||
if (!empty($this->seo_title)) {
|
||||
return $this->seo_title;
|
||||
} else {
|
||||
return $this->title;
|
||||
|
@ -8,7 +8,8 @@ class User
|
||||
public ?string $last_name = null)
|
||||
{}
|
||||
|
||||
public function fullName() : string {
|
||||
public function fullName() : string
|
||||
{
|
||||
$arr_name = array_filter([$this->first_name, $this->last_name]);
|
||||
$full_name = implode(' ', $arr_name);
|
||||
return empty($full_name) ? 'Анонимный пользователь' : $full_name;
|
||||
|
Reference in New Issue
Block a user