docs(10_Wiki): Dev 폴더 누락분 반영 — Topic_Programming으로 통합

이전 재구성 작업에서 Dev/ 폴더가 누락되었던 것을 반영.

- Dev/Topic_Programming(중첩 폴더, 78개)은 Dev 자체 최상위 폴더들
  (Architecture/Conventions/Engineering_Intelligence 등)과 완전 중복이라 제거.
- Dev 최상위 엔지니어링 지식 폴더(Architecture/Conventions/Engineering_Intelligence/
  Failure_Library/Generalized_Principles/Language/Pattern_Catalog/Platform_Guides/
  Subsystems, 77개)는 이미 Topic_Programming/Topic_Programming에 더 최신 버전이
  존재해 중복 제거(고유 콘텐츠 1개는 예외 처리하여 이동 보존).
- Dev의 W3Schools 언어 튜토리얼 폴더(Topic_C/CPP/CSS/CSharp/HOWTO/HTML/Java/
  JavaScript/PHP/Python/SQL/W3CSS, 1201개)는 전부 Topic_Programming 하위로 이동.
- 에이전트 운영 상태(.astra/docs)는 그대로 유지, 콘텐츠 폴더만 정리.
- Topic_Programming 최종 문서 수: 2784 → 3985.
This commit is contained in:
Antigravity Agent
2026-07-05 00:39:13 +09:00
parent 9148c358d0
commit e9cbf23ab5
1356 changed files with 0 additions and 12831 deletions
@@ -0,0 +1,84 @@
---
id: php-oop-inheritance
title: "PHP OOP Inheritance"
category: "Programming_Language"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["extends", "final keyword", "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", "inheritance"]
raw_sources: ["https://www.w3schools.com/php/php_oop_inheritance.asp"]
applied_in: []
github_commit: ""
---
# [[PHP OOP Inheritance]]
## 🎯 한 줄 통찰 (One-line insight)
Calling a `protected` method from OUTSIDE the class fails, but calling that SAME protected method from WITHIN a subclass's own method (via `$this->intro()`) succeeds — the exact rule from access modifiers applies identically to methods, and the source proves it with a direct pass/fail comparison of the two call sites. [S1]
## 🧠 핵심 개념 (Core concepts)
- **`extends`** — inherits public and protected properties/methods from a parent class. [S1]
- **Private members are NOT inherited** — a child class cannot access a parent's private methods/properties at all. [S1]
- **Method overriding** — redefining a method with the same name in the child class replaces the parent's version. [S1]
- **`final` on a class** — prevents any class from extending it. [S1]
- **`final` on a method** — prevents child classes from overriding that specific method. [S1]
## 📖 세부 내용 (Details)
- Basic inheritance: `class Fruit { public $name; public $color; public function __construct($name, $color) {...} public function intro() {...} } class Strawberry extends Fruit { public function message() {...} } $strawberry = new Strawberry("Strawberry", "red"); $strawberry->intro(); $strawberry->message();` — Strawberry uses Fruit's constructor/intro plus its own message(). [S1]
- Protected method fails from outside: `$strawberry->intro(); // ERROR if intro() is protected`. [S1]
- Protected method works from inside a child method: `public function message() { $this->intro(); }` — calling `$this->intro()` from within `message()` succeeds. [S1]
- Overriding: child class `Strawberry` redefines `__construct()` and `intro()` with the same names, completely replacing the parent's versions (adding a `$weight` property along the way). [S1]
- `final` prevents inheritance: `final class Fruit {...} class Strawberry extends Fruit {...} // error`. [S1]
- `final` prevents method override: `class Fruit { final public function intro() {...} } class Strawberry extends Fruit { public function intro() {...} // error }`. [S1]
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
- **protected 메서드 호출 위치에 따른 성패**: 클래스 외부에서 호출하면 에러, 파생 클래스 내부 메서드에서 $this로 호출하면 성공한다는 점이 두 대비 예제로 직접 증명됨. [S1]
## 🛠️ 적용 사례 (Applied in summary)
현재 발견된 실제 적용 사례가 없습니다 — Strawberry가 Fruit의 생성자/메서드를 재정의(override)하며 weight 속성을 추가하는 것이 실전 오버라이딩의 대표 사례다. [S1]
## 💻 코드 패턴 (Code patterns)
Overriding a parent's constructor and method (PHP):
```php
class Fruit {
public $name;
public $color;
public function __construct($name, $color) { $this->name = $name; $this->color = $color; }
public function intro() { echo "The fruit is $this->name and the color is $this->color."; }
}
class Strawberry extends Fruit {
public $weight;
public function __construct($name, $color, $weight) {
$this->name = $name; $this->color = $color; $this->weight = $weight;
}
public function intro() {
echo "A $this->name is $this->color, and the weight is $this->weight gram.";
}
}
```
## ✅ 검증 상태 및 신뢰도
- **상태:** draft
- **검증 단계:** conceptual
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
- **신뢰 점수:** 0.90
- **중복 검사 결과:** 신규 생성 (New discovery)
## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[PHP Tutorial]]
- **관련 개념:** [[PHP OOP Access Modifiers]], [[PHP OOP Constants]], [[PHP OOP Classes Abstract]]
- **참조 맥락:** 클래스 상속과 메서드 오버라이딩 — 클래스 상수(Constants) 챕터로 이어짐.
## 📚 출처 (Sources)
- [S1] W3Schools — PHP OOP - Inheritance — https://www.w3schools.com/php/php_oop_inheritance.asp
## 📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP OOP Inheritance" page (Astra wiki-curation, P-Reinforce v3.1 format).