PHP code example of aklump / default-value

1. Go to this page and download the library: Download aklump/default-value library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aklump / default-value example snippets




$variable_types = [
  'array',
  'bool',
  'boolean',
  'double',
  'float',
  'int',
  'integer',
  'null',
  'number',
  'object',
  'string',

  // In addition you can pass fully-qualified class names, so long as their
  // constructors do not REQUIRE any parameters.
  '\Foo\Bar\Baz',
];

foreach ($variable_types as $variable_type) {
  $default_value = \AKlump\DefaultValue\DefaultValue::get($variable_type);
}



$special_drupal_variable_types = [

  // This is a service ID.
  '@current_user',
  
  // This class has a ::create method with no 
];

foreach ($special_drupal_variable_types as $variable_type) {
  $default_value = \Drupal\Component\Utility\DefaultValue::get($variable_type);
}