PHP PSR-0 语言规范翻译

摘自:https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md

 

    • A fully-qualified namespace and class must have the followingstructure \<Vendor Name>\(<Namespace>\)*<Class Name>
    • Each namespace must have a top-level namespace ("Vendor Name").
    • Each namespace can have as many sub-namespaces as it wishes.
    • Each namespace separator is converted to a DIRECTORY_SEPARATOR whenloading from the file system.
    • Each _ character in the CLASS NAME is converted to aDIRECTORY_SEPARATOR. The _ character has no special meaning in thenamespace.
    • The fully-qualified namespace and class is suffixed with .php whenloading from the file system.
    • Alphabetic characters in vendor names, namespaces, and class names maybe of any combination of lower case and upper case.

大致翻译:

    • 命名空间与类的结构为:\供应商\命名空间\类名。
    • 每个命名空间必须有顶级(供应商)
    • 每个命名空间可以有多个子命名空间。
    • 每个命名空间分割可被转化“/”(目录分割符),当从文件系统中加载的时候。
    • 类名中的_下划线可被转化成“/”(目录分割符),这个符号没有特殊的意思。
    • 类与命名空间后缀以“.php”结尾,当从文件系统中加载的时候。
    • \供应商\命名空间\类名的字符随便是小写或大写。

 

Examples

  • \Doctrine\Common\IsolatedClassLoader => /path/to/project/lib/vendor/Doctrine/Common/IsolatedClassLoader.php
  • \Symfony\Core\Request => /path/to/project/lib/vendor/Symfony/Core/Request.php
  • \Zend\Acl => /path/to/project/lib/vendor/Zend/Acl.php
  • \Zend\Mail\Message => /path/to/project/lib/vendor/Zend/Mail/Message.php

Underscores in Namespaces and Class Names

  • \namespace\package\Class_Name => /path/to/project/lib/vendor/namespace/package/Class/Name.php
  • \namespace\package_name\Class_Name => /path/to/project/lib/vendor/namespace/package_name/Class/Name.php

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值