docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고, Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: php-oop-classes-abstract
|
||||
title: "PHP OOP Classes Abstract"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["abstract methods", "PHP 추상 클래스"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "oop", "abstract"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_oop_classes_abstract.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP OOP Classes Abstract]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
An abstract method's implementation in the child class must match or LOOSEN the access modifier, never tighten it — if the parent declares `abstract protected function`, the child MUST implement it as `protected` or `public`, but NEVER `private`, and the child can freely ADD optional parameters beyond the required ones the parent specified. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Abstract class** — contains at least one abstract method (declared but not implemented); the implementation is deferred to child classes. [S1]
|
||||
- **Abstract method** — declared with `abstract`, no body; forces every child class to implement it. [S1]
|
||||
- **Rule 1: same name** — child method must have the exact same name, redeclaring the parent's abstract method. [S1]
|
||||
- **Rule 2: same or looser access modifier** — protected can only become protected or public in the child, never private. [S1]
|
||||
- **Rule 3: same required argument count, optional extras allowed** — the child method must accept the same required parameters, but MAY add optional ones. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Abstract base with two implementing children: `abstract class Car { public $name; public function __construct($name) { $this->name = $name; } abstract public function intro(); } class Audi extends Car { public function intro() { return "German quality! I'm an $this->name!"; } } class Citroen extends Car { public function intro() { return "French extravagance! I'm a $this->name!"; } }`. [S1]
|
||||
- Abstract method with an argument: `abstract class ParentClass { abstract protected function prefixName($name); } class ChildClass extends ParentClass { public function prefixName($name) { ... } }`. [S1]
|
||||
- Child adding optional arguments beyond the parent's requirement: `public function prefixName($name, $separator = ".", $greet = "Dear") { ... }` — valid even though the parent's abstract declares only `$name`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **접근 제어자 완화만 허용**: 자식 클래스 구현부는 부모의 abstract 메서드보다 접근 제어자를 더 제한적으로 만들 수 없다는 규칙이 명시됨(protected → protected/public만 가능, private 불가). [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Car 추상 클래스를 Audi/Citroen이 각자 다른 intro() 구현으로 확장하는 것이 다형성의 대표 실전 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Abstract class forcing implementation in child classes (PHP):
|
||||
```php
|
||||
abstract class Car {
|
||||
public $name;
|
||||
public function __construct($name) { $this->name = $name; }
|
||||
abstract public function intro(); // no body — child must implement
|
||||
}
|
||||
class Audi extends Car {
|
||||
public function intro() { return "German quality! I'm an $this->name!"; }
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP OOP Constants]], [[PHP OOP Interfaces]]
|
||||
- **참조 맥락:** 추상 클래스 — 인터페이스(Interfaces) 챕터와 직접 비교됨.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP OOP - Abstract Classes — https://www.w3schools.com/php/php_oop_classes_abstract.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP OOP Abstract Classes" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Reference in New Issue
Block a user