Ramatou Adamou Issa

Ramatou Adamou Issa

  • Experiences
  • Formation
  • Musics
  • Blog

›Recent Posts

Recent Posts

  • Watchtower, container for updating docker images
  • PHP8 (Migrating existing PHP7 project to PHP8)
  • What news in Symfony 5
  • Command Query Segregation Responsibility (CQRS)
  • AFUP conference feedbacks

ES6 - Spread Operator && Arrow Function

May 7, 2019

Nicolás Bevacqua

Spread operator

Rest operator in function


    function foo(...spreadParam) {}  
     

Rest operator in function with few parameters


    function foo(param1, ...spreadParam) {}     

For more examples continue reading this article here

Arrow Function

Arrow function is a new way to declare a function in ES6

Simple example


    param => returnValue    

Simplify call in some functions like map

    array.map(value => value * 2)     

Object return, wrap the return with parenthesis


    param => ({returnObject})     

Zero or several params


    () => returnValue   
    (...severalParam) => ({}objectReturn)    

Multiple statements in the function


    () => {} //use brackets 

Code block do not have implicit return at the end

This Binding in array functions


The

    This    

in the arrow function is the same as the context. It can't be modify with .apply or .call

See all more examples here

ES6 - Destructuring

May 7, 2019

Nicolás Bevacqua

Set variables values by object destructuring.

Destructuring first level


    const pony = { foo: 'foo test' }
    
    const { foo } = pony
    
    //foo value is equal to = pony.foo = 'foo test'  
     

Destructuring with alias


    const pony = { foo: 'foo test with alias' }
    
    const { foo: baz }  = pony
    
    //baz value is equal to pony.foo = 'foo test with alias'
    

Destructuring with default value


const pony = {}

const { foo='default value' } = pony

//foo value is equal to pony.foo with 'default value' default value

Destructuring Level 2:


    const pony = {
        foo: {
            baz: 'baz'
        }        
    }

    const { foo: baz } = pony
    
    //baz value will be 'baz'

Destructuring response level 0 and nested


1. Destructuring level 0 raise undefined is the variable not does not exist
2. Destructing nested level raise an error when the variable does not exist

Destructing in function parameters


function foo(bar={a: 1, b: 2}) {
}

ES2019 features

May 7, 2019

Medium

What is new in ES2019 ( > Chrome 72)

Array flat


Create new array with all subArray elements

    const arrayTest = [1,2, [3, 4, [4, 6, [7, 8 ]]]

Flat level 1

    arrayTest.flat() //[ 1, 2, 3, 4, [ 4, 6 ] ]

Flat level 2

    arrayTest.flat().flat() //[ 1, 2, 3, 4, 4, 6, [7, 8]]

Flat infinity

    arrayTest.flat(infinity) //[ 1, 2, 3, 4, 4, 6 , 7, 8]

Array Flat Map


Map each element of array an then flattens the result into new array

    const arrayTest = [1, 2, 3, 4]

maps and flat

    const result = arrayTest.map(x => [x, x * 2]);
    
    // [ [ 1, 2 ], [ 2, 4 ], [ 3, 6 ], [ 4, 8 ] ]
    

Object form Entries


create object from array entries

    const arrayTest = [
  ['test1', 1],
  ['test2', 2],
  ['test3', 3]
]

Object entries

    const result  = Object.fromEntries(arrayTest)
    
    //{ "test1": 1, "test2": 2, "test3": 3 }

Strim Start & Strim End


start/end remove space form the beginning/end


const stringToTrim = '    test    ';


let result = stringToTrim.trimStart();
result = result.trimEnd()

//'test'

Optional catch binding


The error argument in the catch block is optional, Avoid creating unused binding

before

    try {
    } catch (error) {
        ....
    }

after

    try {
    } catch  {
        ....
    }

See more ES10 features here

PSR 14 - Example PSR 14 in a non-blocking application server

May 3, 2019

Steemit

PSR 14: Example

We continue our exploration of PSR-14's potential with a guest post. Cees-Jan Kiewiet was the Sponsor of PSR-14 (meaning the member of the Core Committee who bridged from the Working Group to the Core Committee), and is on the core team for ReactPHP. One wouldn't think there's any use cases for PSR-14 in an async environment like React, but one would be wrong.

Continue reading this article here

PHP News (Sort Closure)

May 3, 2019

Link to the original site [https://stitcher.io/blog/short-closures-in-php]

PHP 7.4 Short Closure

Short closures, also called arrow functions, are a way of writing shorter functions in PHP. This notation is useful when passing closures to functions like

array_map 

or

array_filter.

Current usage

// A collection of Post objects
$posts = [/* … */];

$ids = array_map(fn($post) => $post->id, $posts);

Before

$ids = array_map(function ($post) {
    return $post->id;
}, $posts);

Managing multiple PHP version via ondrej/php PPA

May 3, 2019

Feedly

Managing Multiple PHP versions via Ondrej/php PPA

Last week, I did some system updates, and then decided to compile the most recent PHP releases. I've used phpbrew to manage multiple PHP releases for a number of years, and having it install a new version is fairly routine.

Except this time, it wasn't. Due to updates I installed, I was getting errors first with compiling the GD extension, then with ext-intl

Continue reading this article here

← Prev
Ramatou Adamou Issa
Ramatou Adamou Issa
HomeExperiencesFormation
Social Networks
InstagramTwitterChat
Accounts
Gallery photoBlogGitHubStar
Copyright © 2025 Ramazaki