for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Jaxon\Script\Call;
/**
* AbstractJsCall
*
* Base class for js (not Jaxon) calls and selectors.
* @package jaxon-core
* @author Thierry Feuzeu
* @copyright 2024 Thierry Feuzeu <[email protected]>
* @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
* @link https://github.com/jaxon-php/jaxon-core
*/
use Jaxon\Script\Action\Attr;
use Jaxon\Script\Action\Selector;
use Jaxon\Script\JsExpr;
use Closure;
abstract class AbstractJsCall extends AbstractCall
{
* The constructor.
* @param Closure|null $xExprCb
protected function __construct(protected ?Closure $xExprCb)
{}
* Get the call to add to the expression
* @return Attr|Selector
abstract protected function _exprCall(): Attr|Selector;
* Get the json expression
* @return JsExpr
protected function _expr(): JsExpr
$xJsExpr = new JsExpr($this->_exprCall());
// Apply the callback, if one was defined.
$this->xExprCb !== null && ($this->xExprCb)($xJsExpr);
return $xJsExpr;
}
* Get the value of an attribute of the current object
* @param string $sAttribute
public function __get(string $sAttribute): JsExpr
return $this->_expr()->__get( $sAttribute);
* Set the value of an attribute of the current object
* @param mixed $xValue
* @return void
public function __set(string $sAttribute, $xValue)
return $this->_expr()->__set($sAttribute, $xValue);
$this->_expr()->__set($sAttribute, $xValue)
Jaxon\Script\JsExpr::__set()
This check looks for function or method calls that always return null and whose return value is used.
class A { function getObject() { return null; } } $a = new A(); if ($a->getObject()) {
The method getObject() can return nothing but null, so it makes no sense to use the return value.
getObject()
The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.