Files
2nd/10_Wiki/Dev/Topic_PHP/PHP_OOP_Classes_Abstract.md
T
Antigravity Agent 1cfd3bbb56 docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고,
Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
2026-07-05 00:10:59 +09:00

4.2 KiB

id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
id title category status verification_status canonical_id aliases duplicate_of source_trust_level confidence_score created_at updated_at review_reason merge_history tags raw_sources applied_in github_commit
php-oop-classes-abstract PHP OOP Classes Abstract Programming_Language draft conceptual
abstract methods
PHP 추상 클래스
B 0.9 2026-07-04 2026-07-04
php
programming
w3schools
oop
abstract
https://www.w3schools.com/php/php_oop_classes_abstract.asp

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):

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)

📚 출처 (Sources)

📝 변경 이력 (Change history)

  • 2026-07-04: Initial draft synthesized from the W3Schools "PHP OOP Abstract Classes" page (Astra wiki-curation, P-Reinforce v3.1 format).