1. Go to this page and download the library: Download decodelabs/tightrope 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/ */
decodelabs / tightrope example snippets
namespace DecodeLabs\Tightrope;
interface Nullable {
public function isNullable(): bool;
}
namespace DecodeLabs\Tightrope\Manifest;
use DecodeLabs\Tightrope\Nullable as StaticNullable;
interface Nullable extends StaticNullable {
public function setNullable(bool $flag): static;
}
namespace My\Project;
use DecodeLabs\Exceptional;
use DecodeLabs\Tightrope\Manifest\Nullable;
use DecodeLabs\Tightrope\Manifest\NullableTrait;
class MyClass implements Nullable {
use NullableTrait;
public function doSomething(?string $value): void {
if(
!$this->isNullable() &&
$value === null
) {
throw Exceptional::InvalidArgument(
message: 'Value cannot be null'
);
}
// ...
}
}
$myObject = new MyClass();
$myObject->setNullable(true);
$myObject->doSomething(null); // Fine
$myObject->setNullable(false);
$myObject->doSomething(null); // Not fine
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.