myheritage/php-friendly 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

myheritage/php-friendly

Composer 安装命令:

composer require myheritage/php-friendly

包简介

A utility for adding non-native class friendship capabilities to PHP applications

README 文档

README

A utility for adding non-native class friendship capabilities to PHP applications

Overview

The friend classes RFC suggested that friend classes would be a php-native feature. Since it was declined we've decided to develop our own non-native solution that solves the same problem - how to make multiple classes under the same namespace "friends", and let them call each-other's protected methods.

Requirements

  • PHP >= 7.3
  • php-unit >= 8.3

Composer Install

Add the dependency myheritage/php-friendly to your project if you use Composer to manage the dependencies of your project.

$ composer require myheritage/php-friendly

Usage example

Callee

Shared / Exposed functions must be annotated with the @friendly annotation

<?php
namespace MyHeritage\Friends\Tests\Friendly;

use MyHeritage\Friends\Friendly;

class AFriendlyClass
{
    use Friendly;

    /**
     * @friendly
     * @param $message
     * @return mixed
     */
    protected function friendlyMethod($message)
    {
        return $message;
    }

    protected function notFriendly()
    {
        return "Booo";
    }
}

Caller

<?php
namespace MyHeritage\Friends\Tests\Friendly;

class MyClass
{
    public function getHelpFromAFriendlyClass()
    {
        echo (new AFriendlyClass())->friendlyMethod('hello, can you give a hand?');
    }
}

统计信息

  • 总下载量: 15
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 17
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-03-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固