PHPackages                             wand/annotation-visibility - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. wand/annotation-visibility

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wand/annotation-visibility
==========================

emulates friendship, package-private and so on with annotation.

36[4 issues](https://github.com/wand2016/annotation-visibility/issues)PHP

Since Aug 23Pushed 6y agoCompare

[ Source](https://github.com/wand2016/annotation-visibility)[ Packagist](https://packagist.org/packages/wand/annotation-visibility)[ RSS](/packages/wand-annotation-visibility/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (3)Used By (0)

PHP Annotation Visibility (TBD)
===============================

[](#php-annotation-visibility-tbd)

- friendshipやpackage privateをエミュレートするためのライブラリ

Objective
=========

[](#objective)

- デザインパターンの中には、特定のクラスにのみメソッドを公開したいケースがある
    - Visitor
    - Iterator
    - Memento
    - etc.
- しかし、PHPの言語仕様としては、アクセス制御は下記の3種類のみ
    - public
    - protected
    - private
- 下記のようなアクセス制御は提供されていない
    - 特定のクラスにのみメソッドを公開する(≒friend)
    - 同一パッケージ内にのみメソッドを公開する(package private)
- アノテーションでこれらをエミュレートすることを目的とする
- 上記のアクセス制御は実行時エラーを出すためのものではないため、本番環境での使用は想定しない
- CI環境等の自動テストで不正な呼び出しを検出することを目的とする

Sample 1. Layered Architecture
==============================

[](#sample-1-layered-architecture)

Domain.php

```
