mirror of
https://github.com/LeCoupa/awesome-cheatsheets.git
synced 2025-11-08 22:11:35 +00:00
Merge branch 'master' into patch-1
This commit is contained in:
@@ -144,11 +144,11 @@ echo $! # prints process ID of the most recently invoked ba
|
||||
echo $? # displays the exit status of the last command
|
||||
export VARNAME=value # defines an environment variable (will be available in subprocesses)
|
||||
|
||||
array[0]=valA # how to define an array
|
||||
array[0]=valA # how to define an array
|
||||
array[1]=valB
|
||||
array[2]=valC
|
||||
array=([2]=valC [0]=valA [1]=valB) # another way
|
||||
array(valA valB valC) # and another
|
||||
array=([2]=valC [0]=valA [1]=valB) # another way
|
||||
array=(valA valB valC) # and another
|
||||
|
||||
${array[i]} # displays array's value for this index. If no index is supplied, array element 0 is assumed
|
||||
${#array[i]} # to find out the length of any element in the array
|
||||
@@ -407,7 +407,7 @@ function errtrap {
|
||||
echo "ERROR line $1: Command exited with status $es."
|
||||
}
|
||||
|
||||
trap 'errtrap $LINENO' ERR # is run whenever a command in the surrounding script or function exists with non-zero status
|
||||
trap 'errtrap $LINENO' ERR # is run whenever a command in the surrounding script or function exits with non-zero status
|
||||
|
||||
function dbgtrap {
|
||||
echo "badvar is $badvar"
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
|
||||
|
||||
// Global object: properties
|
||||
Array.length // Reflects the number of elements in an array
|
||||
Array.length // Reflects the number of elements in an array.
|
||||
Array.prototype // Represents the prototype for the Array constructor and allows to add new properties and methods to all Array objects.
|
||||
|
||||
// Global object: methods
|
||||
Array.from(arrayLike[, mapFn[, thisArg]]) // Creates a new Array instance from an array-like or iterable object.
|
||||
|
||||
235
languages/php.php
Normal file
235
languages/php.php
Normal file
@@ -0,0 +1,235 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class
|
||||
* http://php.net/manual/en/language.oop5.basic.php
|
||||
*/
|
||||
class NormalClass extends AbstractClassName implements InterfaceName
|
||||
{
|
||||
|
||||
use TraitName;
|
||||
|
||||
// --> PROPERTY TYPES <--
|
||||
|
||||
/**
|
||||
* Public property, everyone can access this property.
|
||||
* @var Type
|
||||
*/
|
||||
public $property;
|
||||
|
||||
/**
|
||||
* Private property, only this instance can access this property.
|
||||
* @var Type
|
||||
*/
|
||||
private $property;
|
||||
|
||||
/**
|
||||
* Protected property, this instance and childs can access this property.
|
||||
* @var Type
|
||||
*/
|
||||
protected $property;
|
||||
|
||||
/**
|
||||
* Static property, is the same for all instances of this class.
|
||||
* @var Type
|
||||
*/
|
||||
static $property;
|
||||
|
||||
// --> FUNCTION TYPES <--
|
||||
|
||||
/**
|
||||
* Public function, everyone can access this function.
|
||||
* @param Type
|
||||
* @return Type
|
||||
*/
|
||||
public function publicFunction(Type $var = null): Type
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Private function, only this instance can access this function.
|
||||
* @param Type
|
||||
* @return Type
|
||||
*/
|
||||
private function privateFunction(Type $var = null): Type
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Protected function, this instance and childs can access this function.
|
||||
* @param Type
|
||||
* @return Type
|
||||
*/
|
||||
protected function protectedFunction(Type $var = null): Type
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Static function, doesn't need an instance to be executed.
|
||||
* @param Type
|
||||
* @return Type
|
||||
*/
|
||||
public static function staticFunction(Type $var = null): Type
|
||||
{
|
||||
}
|
||||
|
||||
// --> MAGIC METHODS <--
|
||||
|
||||
/**
|
||||
* Gets triggered on creating a new class instance
|
||||
* http://php.net/manual/en/language.oop5.decon.php
|
||||
* @param Type
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Type $var = null)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets triggered on destruction of a class instance
|
||||
* http://php.net/manual/en/language.oop5.decon.php
|
||||
* @return void
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* __set() is run when writing data to inaccessible properties.
|
||||
* http://php.net/manual/en/language.oop5.overloading.php
|
||||
* @param string name
|
||||
* @param mixed value
|
||||
* @return void
|
||||
*/
|
||||
public function __set(string $name , mixed $value)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* __get() is utilized for reading data from inaccessible properties.
|
||||
* http://php.net/manual/en/language.oop5.overloading.php
|
||||
* @param string name
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get(string $name)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* __isset() is triggered by calling isset() or empty() on inaccessible properties.
|
||||
* http://php.net/manual/en/language.oop5.overloading.php
|
||||
* @param string name
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset(string $name)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* __unset() is invoked when unset() is used on inaccessible properties.
|
||||
* http://php.net/manual/en/language.oop5.overloading.php
|
||||
* @param string name
|
||||
* @return void
|
||||
*/
|
||||
public function __unset(string $name)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* __call is triggered when invoking inaccessible methods in an object context.
|
||||
* http://php.net/manual/en/language.oop5.overloading.php
|
||||
* @param string name
|
||||
* @param array arguments
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call(string $name, array $arguments)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* __callStatic() is triggered when invoking inaccessible methods in a static context.
|
||||
* http://php.net/manual/en/language.oop5.overloading.php
|
||||
* @param string name
|
||||
* @param array arguments
|
||||
* @return mixed
|
||||
*/
|
||||
public static function __callStatic(string $name, array $arguments)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* http://php.net/manual/en/language.oop5.magic.php
|
||||
* @return array
|
||||
*/
|
||||
public function __sleep()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* http://php.net/manual/en/language.oop5.magic.php
|
||||
* @return void
|
||||
*/
|
||||
public function __wakeup()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* http://php.net/manual/en/language.oop5.magic.php
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* http://php.net/manual/en/language.oop5.magic.php
|
||||
* @param Type
|
||||
* @return mixed
|
||||
*/
|
||||
public function __invoke(Type $var = null)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* http://php.net/manual/en/language.oop5.magic.php
|
||||
* @param array properties
|
||||
* @return object
|
||||
*/
|
||||
public static function __set_state(array $properties)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* http://php.net/manual/en/language.oop5.magic.php
|
||||
* @return array
|
||||
*/
|
||||
public function __debugInfo()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Every class that has implemented this interface need to have the same functions.
|
||||
*/
|
||||
interface InterfaceName
|
||||
{
|
||||
|
||||
public function FunctionName(Type $var = null): Type;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Combination of class and interface.
|
||||
*/
|
||||
abstract class AbstractClassName
|
||||
{
|
||||
|
||||
/**
|
||||
* Classes extending this abstract class need to have this function.
|
||||
* @param Type
|
||||
* @return Type
|
||||
*/
|
||||
abstract function abstractFunction(Type $var = null): Type;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user