14
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

修飾子の順番はPHPとJavaで異なる

Posted at

final や public の順番は、ひっくり返しても別に動作するのだけど、なんとなく順番を決めたほうが気持ちが良いもの。調べてたらPHPとJavaで作法が違ったのでメモ。

PHP

PSR-2が実質上の標準。
http://www.php-fig.org/psr/psr-2/

Visibility MUST be declared on all properties and methods; abstract and final MUST be declared before the visibility; static MUST be declared after the visibility.

  1. abstract / final (あれば)
  2. visibility (private / protected / public) 常に書く
  3. static (あれば)

PHPは他に修飾子がないので、3つ以上になることはない。(functionっていうキーワードを書かされるけど。。)

Java

OpenJDKのStyleGuideがあった。
http://cr.openjdk.java.net/~alundblad/styleguide/index-v6.html

  1. Access modifier (public / private / protected)
  2. abstract
  3. static
  4. final
  5. transient
  6. volatile
  7. default
  8. synchronized
  9. native
  10. strictfp
14
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?