- Code must follow PSR-2.
- Classes must have a docblock documentation describing their purpose.
- Class methods must have a docblock documentation, in this order:
- A mandatory one-line short description.
- An optional multi-line long description.
- A mandatory
@param
annotation for each parameter:@param [type] [name] [description]
[type]
is the type of the variable, primitive or class.[name]
is the name of the parameter, including the leading$
.[description]
is a short description of the parameter. If the description spans multiple lines, all lines must be indented by the same number of spaces as the first line.
- The indentation must be such as types, names and descriptions for all parameters of a single method start on the same column.
hr { | |
border: 0; | |
height: 1px; | |
background-image: linear-gradient(left , rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0.3) 50%, rgba(0, 0, 0, 0.1) 100%); | |
background-image: -o-linear-gradient(left , rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0.3) 50%, rgba(0, 0, 0, 0.1) 100%); | |
background-image: -moz-linear-gradient(left , rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0.3) 50%, rgba(0, 0, 0, 0.1) 100%); | |
background-image: -webkit-linear-gradient(left , rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0.3) 50%, rgba(0, 0, 0, 0.1) 100%); | |
background-image: -ms-linear-gradient(left , rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0.3) 50%, rgba(0, 0, 0, 0.1) 100%); | |
background-image: -webkit-gradient( |
<?php | |
function get_combinations($arrays) { | |
$result = array(array()); | |
foreach ($arrays as $property => $property_values) { | |
$tmp = array(); | |
foreach ($result as $result_item) { | |
foreach ($property_values as $property_value) { | |
$tmp[] = array_merge($result_item, array($property => $property_value)); | |
} |
This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)
The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array
it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array
part of it away. So how does that work?
The key here is that objects usually have a predefined set of keys, whereas arrays don't:
DELIMITER // | |
CREATE FUNCTION BIN_TO_UUID(b BINARY(16)) | |
RETURNS CHAR(36) | |
BEGIN | |
DECLARE hexStr CHAR(32); | |
SET hexStr = HEX(b); | |
RETURN LOWER(CONCAT( | |
SUBSTR(hexStr, 1, 8), '-', | |
SUBSTR(hexStr, 9, 4), '-', |
There are two metrics that are important to consider when discussing the size of Docker images.
- Compressed size - This is often referred to as the wire size. This affects how fast/slow images can be pulled from a registry. This impacts the first run experience on machines where images are not cached.
- Uncompressed size - This is often referred to as the size on disk. This affects how much local storage is required to support your Docker workloads.
The example commands shown below will work on Windows, MacOS, and Linux.
<?php | |
/** | |
* This script downloads the list of releases of a project via the GitHub API, | |
* and generates a changelog out of it. | |
* | |
* Example, to generate a changelog for brick/math: | |
* | |
* php changelog-from-github-api.php brick/math > CHANGELOG.md | |
*/ |
<?php | |
declare(strict_types=1); | |
// Updates all the version constraints of dependencies in the composer.json file to their latest version. | |
// | |
// usage: composer-frontline.php (updates all Nette packages) | |
// composer-frontline.php doctrine/* (updates all Doctrine packages) | |
// composer-frontline.php * (updates all packages) |