The document discusses PHP coding standards and conventions. It introduces PSR (PHP Standards Recommendation), which includes standards for autoloading (PSR-0), basic coding (PSR-1), coding style (PSR-2), logging (PSR-3), and improved autoloading (PSR-4). It also discusses DocBlocks and PHP_CodeSniffer, which is a tool for checking code against coding standards.
This is an overview of C++ (based on 1999 / 2003 standard) and its use in Object Oriented Programming. The presentation assumes that the audience knows C programming.
This is an overview of C++ (based on 1999 / 2003 standard) and its use in Object Oriented Programming. The presentation assumes that the audience knows C programming.
Python is a widely used high-level programming language for general-purpose programming. Python is a simple, powerful and easy to learn the programming language. It is commonly used for Web and Internet development, Scientific and Numeric computing, Business application and Desktop GUI development etc. The basic data structures in python are lists, dictionaries, tuples, strings and sets
( ** Java Certification Training: https://www.edureka.co/java-j2ee-soa-training ** )
This Edureka tutorial on “Java ArrayList” (Java blog series: https://goo.gl/osrGrS) will give you a brief insight about ArrayList in Java and its various constructors and methods along with an example. Through this tutorial, you will learn the following topics:
Collections Framework
Hierarchy of ArrayList
What is ArrayList
Internal Working of ArrayList
Constructors of ArrayList
Constructors Example
ArrayList Methods
Methods Example and Demo
Advantages of ArrayList over Arrays
Check out our Java Tutorial blog series: https://goo.gl/osrGrS
Check out our complete Youtube playlist here: https://goo.gl/CRbgFann
Follow us to never miss an update in the future.
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
This the slide stack for the two videos on Data types in my YouTube series on JavaScript. The videos are at https://www.youtube.com/watch?v=UAtJXkGggOU and https://www.youtube.com/watch?v=H2sjsGZyYaw
Java comments:
→ Java comments are statements that are not executed by the compiler and interpreter.
→ The comments can be used to provide information about each line of code.
→ It can also be used to hide program code for specific time.
Types of Java Comments:
→ Single Line Comment:
→ The single line comment is used to comment only one line.
//This is single line comment
→ Multi Line Comment:
→ The multi line comment is used to comment multiple lines of code.
/*
This is
multi line comment
*/
→ Documentation Comment:
→ The documentation comment is used to create documentation API.
/**
This is
documentation comment
*/
-------------
about this presentation:
1) this presentation was a quickie for non-tech employees, who wanted a basic understanding of html/css, as it related to a white-label SAAS product;
2) the back-end/front-end definitions relate to the specific application (it's inaccurate if node.js is in the picture)
How else can you write the code in PHP?Maksym Hopei
Usually we are limited with our environment and habits. When we make changes to a product or when we work with a team we follow the coding standards and the existing approaches to make our life and life of our teammates easier.
But often we do the same when we start a new product on our own ruled by our habits and by the limitations of our horizon.
This talk is intended to introduce some uncustomary ways to write code.
Python is a widely used high-level programming language for general-purpose programming. Python is a simple, powerful and easy to learn the programming language. It is commonly used for Web and Internet development, Scientific and Numeric computing, Business application and Desktop GUI development etc. The basic data structures in python are lists, dictionaries, tuples, strings and sets
( ** Java Certification Training: https://www.edureka.co/java-j2ee-soa-training ** )
This Edureka tutorial on “Java ArrayList” (Java blog series: https://goo.gl/osrGrS) will give you a brief insight about ArrayList in Java and its various constructors and methods along with an example. Through this tutorial, you will learn the following topics:
Collections Framework
Hierarchy of ArrayList
What is ArrayList
Internal Working of ArrayList
Constructors of ArrayList
Constructors Example
ArrayList Methods
Methods Example and Demo
Advantages of ArrayList over Arrays
Check out our Java Tutorial blog series: https://goo.gl/osrGrS
Check out our complete Youtube playlist here: https://goo.gl/CRbgFann
Follow us to never miss an update in the future.
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
This the slide stack for the two videos on Data types in my YouTube series on JavaScript. The videos are at https://www.youtube.com/watch?v=UAtJXkGggOU and https://www.youtube.com/watch?v=H2sjsGZyYaw
Java comments:
→ Java comments are statements that are not executed by the compiler and interpreter.
→ The comments can be used to provide information about each line of code.
→ It can also be used to hide program code for specific time.
Types of Java Comments:
→ Single Line Comment:
→ The single line comment is used to comment only one line.
//This is single line comment
→ Multi Line Comment:
→ The multi line comment is used to comment multiple lines of code.
/*
This is
multi line comment
*/
→ Documentation Comment:
→ The documentation comment is used to create documentation API.
/**
This is
documentation comment
*/
-------------
about this presentation:
1) this presentation was a quickie for non-tech employees, who wanted a basic understanding of html/css, as it related to a white-label SAAS product;
2) the back-end/front-end definitions relate to the specific application (it's inaccurate if node.js is in the picture)
How else can you write the code in PHP?Maksym Hopei
Usually we are limited with our environment and habits. When we make changes to a product or when we work with a team we follow the coding standards and the existing approaches to make our life and life of our teammates easier.
But often we do the same when we start a new product on our own ruled by our habits and by the limitations of our horizon.
This talk is intended to introduce some uncustomary ways to write code.
Let's PHP in a better way! - Coding Recommendations.Leekas Shep
A short and sane session on PHP coding recommendations. In which we are going through some of the hand-picked Coding Standards, Coding Principles and Design Patterns.
There are several tools out there that help to develop and maintain high quality PHP code. They allow you to identify the most fragile and messy parts of your codebase. PHP_CodeSniffer tokenises PHP, JavaScript and CSS files and detects violations of a defined set of coding standards. Learn how it works, how you can use it and how can you bend it to meet your requirements!
Mari Memahami PSR (PHP Standards Recommendation)Mizan Riqzia
Mari belajar memahami Hasil dari PHP-FIG (Framework Interoperability Group) yaitu PHP Standards Recommendation sehingga menghasilkan php code style yang baik.
Even nowadays, PHP code is mostly manually audited. Expert pore over actual code, in search for bugs or code smells. Actually, it is possible to have PHP do this work itself ! Strengthened with the internal Tokenizer, bolstered by the manual, it is able to scan thousands of lines of code, without getting bored, and bringing pragmatic pieces of wisdom: official manual recommendations, version migration, code pruning and security. In the end, it deliver a global overview of the code, without reading it.
We've all been faced with legacy code and often decided to rewrite, feeling it will be easier. There are many reasons this can be wrong. Adam Culp will talks about the entire journey of refactoring a legacy code base. He will begin with assessment and why, move on to planning how and when, cover execution and testing, give step-by-step examples, and even show how to manage the process effectively. Attendees will gain insight and tips on how to handle their own pile of code and refactor happy.
Component Based UI Architecture - Alex MoldovanITCamp
My talk will be mostly oriented towards the JavaScript ecosystem and the modern frameworks that enforce a component based approach towards building your UI. I will try to speak a lot from my recent experience with React.js and if time permits, I will demo some smaller apps just to show everyone how easy it is to play with React.
We all know that web performance optimization is becoming critical to the success of web sites and applications. The problem is, we often don’t have the control over the UI Architecture (“middle-end”) that we need to really make things better.
We’ll talk about how to use JavaScript (client- and server-side) to revamp the middle-end so we can throttle web performance (and code maintainability) to the next level.
An intro to php standards recommendation (psr)valuebound
The PHP Standard Recommendation (PSR) is a PHP specification published by the PHP Framework Interop Group. It serves as a standardization of programming concepts in PHP, aiming to enable interoperability of components.
Here, Biswajeet Parida of Valuebound has discussed "basic coding standards, coding style guide, Logger Interface, Autoloader, and others."
The PHP Standard Recommendation (PSR) is a PHP specification published by the PHP Framework Interop Group.
The PHP-FIG is formed by several PHP frameworks founders.
Each PSR is suggested by members and voted according to an established protocol to act consistently and in line with their agreed upon processes.
All the Accepted, Draft, Rejected, Abondoned and Deprecated PSR submissions can be found on following URL: https://www.php-fig.org/psr/
Parse::Eyapp is a collection of modules
that extends Francois Desarmenien Parse::Yapp 1.05.
Eyapp extends yacc/yapp syntax with
functionalities like named attributes,
EBNF-like expressions, modifiable default action,
automatic abstract syntax tree building,
dynamic conflict resolution,
translation schemes, tree regular expressions,
tree transformations, scope analysis support,
and directed acyclic graphs among others.
This article teaches you the basics of
Compiler Construction using Parse::Eyap to
build a translator from infix expressions to Parrot
Intermediate Representation.
In-Depth Guide On WordPress Coding Standards For PHP & HTMLeSparkBiz
Before going to into the details of WordPress Coding Standards, you need to know the purpose of the coding standards & why you need to have coding standards.
In this blog, we will focus on part 1 – WordPress Coding Standards For PHP & HTML and in the next blog, we will focus on part 2 – WordPress Coding Standards For CSS & JS.
Why I like PHPStorm
Advantages of Using Docker
Client, Docker Host, Registry
Docker Usage
Solr Docker File
Every Day Docker Commands
Docker Search
One Line Scripts
Portainer
Kinematic
Docker Compose
Grafana
Coding style guide
PHPCS/MD
Documentation Rules
Xdebug
Postman
1. PHP Coding Standards
For Developers
Presented On 13-Feb-2014
By,
Sangeeta Arora – Technical Lead | CIPL
sangeeta.arora@classicinformatics.com
1
This is private and confidential material
2. Agenda
Introduce PSR
What is PSR?
Different types of PSR
Introduce DocBlocks
What is DocBlock?
Different DocBlock Tags
Introduce PHP_CodeSniffer
2
What is PHP_CodeSniffer?
This is private and confidential material
3. PSR?
PHP Standards Recommendation.
PSR stands for
Coding standards are guidelines for code style and documentation.
Purpose of coding standards is to make it so that source code looks as if it’s
written by a single developer as it sets a level of expectations for contributing
developers.
Five Types of PSR
PSR – 0 – Autoloading Standard
PSR – 1 – Basic Coding Standard
PSR – 2 – Coding Style Guide
PSR – 3 – Logger Interface
PSR – 4 – Improved Autoloading
We will discuss PSR – 0, PSR – 1 and PSR – 2 in the further slides.
We will discuss PSR – 3 and PSR – 4 in future presentations.
3
This is private and confidential material
4. PSR – 0 – Autoloading Standard
A standard recommendation that describes
“the mandatory requirements that must be
adhered to for autoloader interoperability.
4
This is private and confidential material
5. PSR – 0 – Autoloading Standard
A fully-qualified namespace and class must have the following structure <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 when loading from
the file system.
Each _ character in the CLASS NAME is converted to a DIRECTORY_SEPARATOR.
The _ character has no special meaning in the namespace.
The fully-qualified namespace and class is suffixed with .php when loading from the file
system.
Alphabetic characters in vendor names, namespaces, and class names may be of any
combination of lower case and upper case.
5
This is private and confidential material
6. PSR – 0 – Examples
DoctrineCommonIsolatedClassLoader => /path/to/project/lib/vendor/Doctrine/Common/
IsolatedClassLoader.php
SymfonyCoreRequest => /path/to/project/lib/vendor/Symfony/Core/Request.php.
ZendAcl => /path/to/project/lib/vendor/Zend/Acl.php.
ZendMailMessage => /path/to/project/lib/vendor/Zend/Mail/Message.php.
6
This is private and confidential material
7. PSR – 1 – Basic Coding Standard
It focuses on a Basic Coding Standard.
7
This is private and confidential material
8. PSR – 1 – Basic Coding Standard
Files MUST use only <?php and <?= tags.
Files MUST use only UTF-8 (without BOM) character encoding for PHP code.
Files SHOULD either declare symbols (classes, functions, constants, etc.) or cause sideeffects (e.g. generate output, change .ini settings, etc.) but SHOULD NOT do both.
Namespaces and classes MUST follow PSR-0.
Class names MUST be declared in StudlyCaps.
Class constants MUST be declared in all upper case with underscore separators, if required.
E.g. const VERSION; const DATE_APPROVED;
Class method names MUST be declared in camelCase.
8
This is private and confidential material
9. PSR – 2 – Coding Style Guide
Its purpose is to have a single style
guide for PHP code that results in
uniformly formatted shared code.
9
This is private and confidential material
10. PSR – 2 – Coding Style Guide
Basic Coding Standard
Code MUST follow PSR-1.
Files
All PHP files MUST end with a single blank line.
All PHP files MUST use the Unix LF (linefeed) line ending.
The closing ?> tag MUST be omitted from files containing only PHP.
Lines
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 NOT be trailing whitespace at the end of non-blank lines.
Blank lines MAY be added to improve readability and to indicate related blocks of code.
There MUST NOT be more than one statement per line.
10
This is private and confidential material
11. PSR – 2 – Coding Style Guide …contd.
Indenting
Code MUST use 4 spaces for indenting, and MUST NOT use tabs for indenting.
Keywords and True/False/Null
PHP keywords MUST be in lower case.
The PHP constants true, false, and null MUST be in lower case.
Namespace and Use Declarations
There MUST be one blank line after the namespace declaration.
All use declarations MUST go after the namespace declaration.
There MUST be one use keyword per declaration..
There MUST be one blank line after the use block.
11
This is private and confidential material
12. PSR – 2 – Coding Style Guide …contd.
Extends and Implements
The extends and implements keywords MUST be declared on the same line as the class
name. e.g.
Lists of implements MAY be split across multiple lines, where each subsequent line is
indented once. When doing so, the first item in the list MUST be on the next line, and
there MUST be only one interface per line.
Opening braces for classes MUST go on the next line, and closing braces MUST go on the
next line after the body.
Properties
Visibility MUST be declared on all properties.
12
This is private and confidential material
13. PSR – 2 – Coding Style Guide …contd.
Properties
The var keyword MUST NOT be used to declare a property.
There MUST NOT be more than one property declared per statement.
Property names SHOULD NOT be prefixed with a single underscore to indicate protected
or private visibility. e.g.
Methods
Visibility MUST be declared on all methods.
Method names SHOULD NOT be prefixed with a single underscore to indicate protected
or private visibility.
Method names MUST NOT be declared with a space after the method name.
The opening brace MUST go on its own line, and the closing brace MUST go on the next
line following the body.
13
This is private and confidential material
14. PSR – 2 – Coding Style Guide …contd.
Methods
There MUST NOT be a space after the opening parenthesis, and there MUST NOT be a
space before the closing parenthesis. e.g.
Method Arguments
There MUST NOT be a space before each comma.
There MUST be one space after each comma.
Method arguments with default values MUST go at the end of the argument list.
14
This is private and confidential material
15. PSR – 2 – Coding Style Guide …contd.
Method Arguments
Example of Arguments in
the same line
Example of Arguments not
in the same line, when have
a long list of arguments.
15
This is private and confidential material
16. PSR – 2 – Coding Style Guide …contd.
Qualifiers (abstract, final, and static)
When present, the abstract and final declarations MUST precede the visibility
declaration.
16
When present, the static declaration MUST come after the visibility declaration.
This is private and confidential material
17. PSR – 2 – Coding Style Guide …contd.
Method and Function Calls
There MUST NOT be a space between the method or function name and the opening
parenthesis.
There MUST NOT be a space after the opening parenthesis.
There MUST NOT be a space before the closing parenthesis.
In the argument list, there MUST NOT be a space before each comma, and there MUST
be one space after each comma.
Example of Arguments in
the same line
17
Example of Arguments not in the same
line, when have a long list of arguments.
This is private and confidential material
18. PSR – 2 – Coding Style Guide …contd.
Control Structures
There MUST be one space after the control structure keyword.
There MUST NOT be a space after the opening parenthesis.
There MUST NOT be a space before the closing parenthesis.
There MUST be one space between the closing parenthesis and the opening brace.
The structure body MUST be indented once.
The closing brace MUST be on the next line after the body.
18
This is private and confidential material
19. PSR – 2 – Coding Style Guide …contd.
if-elseif-else
The keyword elseif SHOULD be used instead of else if.
else and elseif are on the same line as the closing brace from the earlier body.
Note the placement of parentheses, spaces, and braces.
19
This is private and confidential material
20. PSR – 2 – Coding Style Guide …contd.
switch and case
The case statement MUST be indented once from switch.
The break keyword (or other terminating keyword) MUST be indented at the same level
as the case body.
There MUST be a comment such as // no break when fall-through is intentional in a nonempty case body.
Note the placement of parentheses, spaces, and braces.
20
This is private and confidential material
21. PSR – 2 – Coding Style Guide …contd.
while and do-while
Note the placement of parentheses, spaces, and braces for while statement.
Note the placement of parentheses, spaces, and braces for do-while statement.
21
This is private and confidential material
22. PSR – 2 – Coding Style Guide …contd.
for and foreach
Note the placement of parentheses, spaces, and braces for for statement.
Note the placement of parentheses, spaces, and braces for foreach statement.
22
This is private and confidential material
23. PSR – 2 – Coding Style Guide …contd.
try-catch
23
Note the placement of parentheses, spaces, and braces for try-catch statement.
This is private and confidential material
24. PSR – 2 – Coding Style Guide …contd.
In-Code Documentation
All PHP files should include a DocBlock header.
All classes should include a DocBlock for the class definition.
All class constants, properties and methods should include a DocBlock to explain their
purpose.
All functions should include a DocBlock to explain their purpose.
24
This is private and confidential material
25. PSR – 3 – Logger Interface
PSR-3 describes a shared logging
interface which improves reusability.
25
This is private and confidential material
26. PSR – 4 – Improved Autoloading
The main goal of PSR-4 is to remove the
remnants of PSR-0 and the pre-5.3 days
completely and allow for a more concise
folder structure.
26
This is private and confidential material
27. DocBlocks
DocBlock is a multi-line C-style comment
used to document a block of code.
27
This is private and confidential material
28. DocBlocks
It is a multi-line C-style comment used to document a block of code.
"DocComment" is a special type of comment which MUST
It begins with the character sequence /** followed by a whitespace character
It has an asterisk at the start of each line.
end with */
have zero or more lines in between
DocBlocks consist of three sections:
short description
long description
tags
Short description is a concise description terminated by either a new-line or a period.
Long description is where the bulk of the documentation goes; it can be multi-line and as
long you wish.
28
This is private and confidential material
29. DocBlocks …contd.
Tags
The tags are used to specify additional information, such as the expected parameters and their type.
Each tag starts on a new line, followed by an at-sign (@) and a tag-name followed by white-space and
meta-data (including a description).
29
This is private and confidential material
30. DocBlocks …contd.
Different Types of Tags
30
@api
@author
@copyright
@deprecated
@example
@global
@internal
@license
@method
@package
@param
@property
@return
@see
@since
@struct
@throws
@todo
@type
@uses
@version
This is private and confidential material
31. DocBlocks …contd.
@api – It is used to declare "Structural Elements" as being suitable for consumption by
third parties.
@author – The @author tag is used to document the author of any "Structural Element".
@copyright – The @copyright tag is used to document the copyright information of any
"Structural Element".
31
This is private and confidential material
32. DocBlocks …contd.
@deprecated – The @deprecated tag is used to indicate which 'Structural elements' are
deprecated and are to be removed in a future version.
@example – The @example tag is used to link to an external source code file which contains
an example of use for the current "Structural element".
32
This is private and confidential material
33. DocBlocks …contd.
@global – The @global tag is used to denote a global variable or its usage.
@license – The @license tag is used to indicate which license is applicable for the associated
'Structural Elements'.
@method – The @method allows a class to know which 'magic' methods are callable.
33
This is private and confidential material
34. DocBlocks …contd.
@package – The @package tag is used to categorize "Structural Elements" into logical
subdivisions.
@param – The @param tag is used to document a single parameter of a function or
method.
@property – The @property tag is used in the situation where a class contains the __get()
and __set() magic methods and allows for specific names.
34
This is private and confidential material
35. DocBlocks …contd.
@return – The @return tag is used to document the return value of functions or methods.
@see – The @see tag can be used to define a reference to other "Structural Elements" or to
a URI.
35
This is private and confidential material
36. DocBlocks …contd.
@since – The @since tag is used to denote when an element was introduced or modified,
using some description of "versioning" to that element.
The @since tag SHOULD NOT be used to show the current version of an element, the
@version tag MAY be used for that purpose.
@todo – The @todo tag is used to indicate whether any development activities should still
be executed on associated "Structural Elements".
36
This is private and confidential material
37. DocBlocks …contd.
@throws – The @throws tag is used to indicate whether "Structural Elements" throw a
specific type of exception.
@version – The @version tag is used to denote some description of "versioning" to an
element.
37
This is private and confidential material
38. DocBlocks …contd.
@type – The @type tag defines which type of data is represented by a value of a Constant,
Property or Variable.
@uses – The @uses tag describes whether any part of the associated "Structural Element"
uses, or consumes, another "Structural Element" or a file that is situated in the current
project.
38
This is private and confidential material
40. What is PHP_CodeSniffer?
PHP_CodeSniffer (PHPCS) is a PHP5 script that tokenizes PHP, JavaScript and CSS files to
detect violations of a defined coding standard.
It is an essential development tool that ensures your code remains clean and consistent.
It can also help prevent some common semantic errors made by developers.
It allows you to not only ensure that your code follows the PSR standards, but it also uses
PHP’s linter to check for syntax errors.
Multiple coding standards can be used within PHP_CodeSniffer so that the one installation
can be used across multiple projects.
The default coding standard used by PHP_CodeSniffer is the PEAR coding standard.
40
This is private and confidential material