![Phân tích tư tưởng của nhân dân qua đoạn thơ: Những người vợ nhớ chồng… Những cuộc đời đã hóa sông núi ta trong Đất nước của Nguyễn Khoa Điềm](https://timtailieu.net/upload/document/136415/phan-tich-tu-tuong-cua-nhan-dan-qua-doan-tho-039-039-nhung-nguoi-vo-nho-chong-nhung-cuoc-doi-da-hoa-song-nui-ta-039-039-trong-dat-nuoc-cua-nguyen-khoa-136415.jpg)
Bài giảng Phát triển phần mềm nguồn mở: Bài 3 - Nguyễn Hữu Thể
Số trang: 17
Loại file: pdf
Dung lượng: 998.43 KB
Lượt xem: 27
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Bài 3 - PHP standards recommendations. Những nội dung chính được trình bày trong bài này gồm có: Basic coding standard, coding style guide, logger interface, autoloading standard, caching interface, HTTP message interface. Mời các bạn cùng tham khảo.
Nội dung trích xuất từ tài liệu:
Bài giảng Phát triển phần mềm nguồn mở: Bài 3 - Nguyễn Hữu Thể PHÁT TRIỂN PHẦN MỀM NGUỒN MỞ PHP Standards Recommendations Nguyễn Hữu Thể Content Basic Coding Standard Coding Style Guide Logger Interface Autoloading Standard Caching Interface HTTP Message Interface 2 Index by Status (Accepted) Num Title Editor Coordinator Sponsor 1 Basic Coding Standard Paul M. Jones N/A N/A 2 Coding Style Guide Paul M. Jones N/A N/A Jordi 3 Logger Interface N/A N/A Boggiano 4 Autoloading Standard Paul M. Jones Phil Sturgeon Larry Garfield Paul 6 Caching Interface Larry Garfield Robert Hafner Dragoonis Matthew HTTP Message Beau 7 Weier Paul M. Jones Interface Simensen O'Phinney Matthew Marc 13 Hypermedia Links Larry Garfield Weier Alexander O'Phinney http://www.php-fig.org/psr/ 3 PSR-1: Basic Coding Standard 1. Overview Files MUST use only PSR-1: Basic Coding Standard SHOULD NOT SHOULD PSR-1: Basic Coding Standard Namespace and Class Names Namespaces and classes MUST follow an 'autoloading' PSR: [PSR-0, PSR-4]. Class names MUST be declared in StudlyCaps. // PHP 5.3 and later: namespace Vendor\Model; class Foo { } 6 PSR-1: Basic Coding Standard Class Constants, Properties, and Methods The term 'class' refers to all classes, interfaces, and traits. Class constants MUST be declared in all upper case with underscore separators. namespace Vendor\Model; class Foo { const VERSION = '1.0'; const DATE_APPROVED = '2012-06-01'; } 7 PSR-1: Basic Coding Standard Properties • This guide intentionally avoids any recommendation regarding the use of $StudlyCaps, $camelCase, or $under_score property names. Methods • Method names MUST be declared in camelCase(). 8 PSR-2: Coding Style Guide Code MUST use 4 spaces for indenting, not tabs. There MUST NOT be a hard limit on line length; the soft limit MUST be 120 characters; lines SHOULD be 80 characters or less. There MUST be one blank line after the namespace declaration, and there MUST be one blank line after the block of use declarations. Opening braces for classes MUST go on the next line, and closing braces MUST go on the next line after the body. Opening braces for methods MUST go on the next line, and closing braces MUST go on the next line after the body. 9 PSR-2: Coding Style Guide Control structure keywords MUST have one space after them; method and function calls MUST NOT. Opening braces for control structures MUST go on the same line, and closing braces MUST go on the next line after the body. Opening parentheses for control structures MUST NOT have a space after them, and closing parentheses for control structures MUST NOT have a space before. 10 namespace Vendor\Package; use FooInterface; use BarClass as Bar; use OtherVendor\OtherPackage\BazClass; class Foo extends Bar implements FooInterface { public function sampleMethod($a, $b = null) { if ($a === $b) { bar(); } elseif ($a > $b) { $foo->bar($arg1); } else { BazClass::bar($arg2, $arg3); } } final public static function bar() { // method body } } PSR-3: Logger Interface The LoggerInterface exposes eight methods to write logs to the eight RFC 5424 levels (debug, info, notice, warning, error, critical, alert, emergency). A ninth method, log, accepts a log level as the first argument. Calling this method with one of the log level constants MUST have the same result as calling the level-specific method. Users SHOULD NOT use a custom level without knowing for sure the current implementation supports it. 12 PSR-4: Autoloader The term 'class' refers to classes, interfaces, traits, and other similar structures. A fully qualified class name has the following form: \(\)*\ The fully qualified class name MUST have a top-level namespace name, also known as a 'vendor namespace'. The fully qualified class name MAY have one or more sub- namespace names. The fully qualified class name MUST have a terminating class name. 13 PSR-4: Autoloader Underscores have no special meaning in any portion of the fully qualified class name. Alphabetic characters in the fully qualified class name MAY be any combination of lower case and upper case. All class names MUST be referenced in a case-sensitive fashion. When loading a file ...
Nội dung trích xuất từ tài liệu:
Bài giảng Phát triển phần mềm nguồn mở: Bài 3 - Nguyễn Hữu Thể PHÁT TRIỂN PHẦN MỀM NGUỒN MỞ PHP Standards Recommendations Nguyễn Hữu Thể Content Basic Coding Standard Coding Style Guide Logger Interface Autoloading Standard Caching Interface HTTP Message Interface 2 Index by Status (Accepted) Num Title Editor Coordinator Sponsor 1 Basic Coding Standard Paul M. Jones N/A N/A 2 Coding Style Guide Paul M. Jones N/A N/A Jordi 3 Logger Interface N/A N/A Boggiano 4 Autoloading Standard Paul M. Jones Phil Sturgeon Larry Garfield Paul 6 Caching Interface Larry Garfield Robert Hafner Dragoonis Matthew HTTP Message Beau 7 Weier Paul M. Jones Interface Simensen O'Phinney Matthew Marc 13 Hypermedia Links Larry Garfield Weier Alexander O'Phinney http://www.php-fig.org/psr/ 3 PSR-1: Basic Coding Standard 1. Overview Files MUST use only PSR-1: Basic Coding Standard SHOULD NOT SHOULD PSR-1: Basic Coding Standard Namespace and Class Names Namespaces and classes MUST follow an 'autoloading' PSR: [PSR-0, PSR-4]. Class names MUST be declared in StudlyCaps. // PHP 5.3 and later: namespace Vendor\Model; class Foo { } 6 PSR-1: Basic Coding Standard Class Constants, Properties, and Methods The term 'class' refers to all classes, interfaces, and traits. Class constants MUST be declared in all upper case with underscore separators. namespace Vendor\Model; class Foo { const VERSION = '1.0'; const DATE_APPROVED = '2012-06-01'; } 7 PSR-1: Basic Coding Standard Properties • This guide intentionally avoids any recommendation regarding the use of $StudlyCaps, $camelCase, or $under_score property names. Methods • Method names MUST be declared in camelCase(). 8 PSR-2: Coding Style Guide Code MUST use 4 spaces for indenting, not tabs. There MUST NOT be a hard limit on line length; the soft limit MUST be 120 characters; lines SHOULD be 80 characters or less. There MUST be one blank line after the namespace declaration, and there MUST be one blank line after the block of use declarations. Opening braces for classes MUST go on the next line, and closing braces MUST go on the next line after the body. Opening braces for methods MUST go on the next line, and closing braces MUST go on the next line after the body. 9 PSR-2: Coding Style Guide Control structure keywords MUST have one space after them; method and function calls MUST NOT. Opening braces for control structures MUST go on the same line, and closing braces MUST go on the next line after the body. Opening parentheses for control structures MUST NOT have a space after them, and closing parentheses for control structures MUST NOT have a space before. 10 namespace Vendor\Package; use FooInterface; use BarClass as Bar; use OtherVendor\OtherPackage\BazClass; class Foo extends Bar implements FooInterface { public function sampleMethod($a, $b = null) { if ($a === $b) { bar(); } elseif ($a > $b) { $foo->bar($arg1); } else { BazClass::bar($arg2, $arg3); } } final public static function bar() { // method body } } PSR-3: Logger Interface The LoggerInterface exposes eight methods to write logs to the eight RFC 5424 levels (debug, info, notice, warning, error, critical, alert, emergency). A ninth method, log, accepts a log level as the first argument. Calling this method with one of the log level constants MUST have the same result as calling the level-specific method. Users SHOULD NOT use a custom level without knowing for sure the current implementation supports it. 12 PSR-4: Autoloader The term 'class' refers to classes, interfaces, traits, and other similar structures. A fully qualified class name has the following form: \(\)*\ The fully qualified class name MUST have a top-level namespace name, also known as a 'vendor namespace'. The fully qualified class name MAY have one or more sub- namespace names. The fully qualified class name MUST have a terminating class name. 13 PSR-4: Autoloader Underscores have no special meaning in any portion of the fully qualified class name. Alphabetic characters in the fully qualified class name MAY be any combination of lower case and upper case. All class names MUST be referenced in a case-sensitive fashion. When loading a file ...
Tìm kiếm theo từ khóa liên quan:
Phần mềm nguồn mở Phát triển phần mềm nguồn mở Basic coding standard Coding style guide Logger interfaceTài liệu liên quan:
-
183 trang 322 0 0
-
'Phần mềm tự do và phần mềm nguồn mở' Free and Open Source Software – Asia-Pacific Consultation
5 trang 135 0 0 -
Xây dựng hệ thống tích hợp liên tục nội bộ sử dụng công cụ nguồn mở Jenkins và Gitlab
11 trang 92 0 0 -
Giáo trình Nhập môn quản trị hệ thống Linux
145 trang 48 0 0 -
25 trang 47 0 0
-
Bài giảng Phần mềm nguồn mở: Bài 1 - Đoàn Thiện Ngân
29 trang 45 0 0 -
Bài giảng Phần mềm nguồn mở: Bài 3 - Đoàn Thiện Ngân
12 trang 45 0 0 -
Bài giảng Nhập môn công nghệ thông tin và truyền thông: Bài 7 - GV. Lê Thanh Hương
29 trang 41 0 0 -
Bài giảng Phát triển phần mềm nguồn mở: Bài 8 - Nguyễn Hữu Thể
56 trang 33 0 0 -
Đề cương ôn tập học kì 1 môn Tin học lớp 11 năm 2023-2024 - Trường THPT Hoàng Văn Thụ, Hà Nội
7 trang 33 0 0