original_string: protected function _canBeEmpty($field, $context)
      {
          $allowed = $field->isEmptyAllowed();
  
          if (!is_string($allowed) && is_callable($allowed)) {
              return $allowed($context);
          }
  
          $newRecord = $context['newRecord'];
          if (in_array($allowed, ['create', 'update'], true)) {
              $allowed = (
                  ($allowed === 'create' && $newRecord) ||
                  ($allowed === 'update' && !$newRecord)
              );
          }
  
          return $allowed;
      }
code: protected function _canBeEmpty($field, $context)
      {
          $allowed = $field->isEmptyAllowed();
  
          if (!is_string($allowed) && is_callable($allowed)) {
              return $allowed($context);
          }
  
          $newRecord = $context['newRecord'];
          if (in_array($allowed, ['create', 'update'], true)) {
              $allowed = (
                  ($allowed === 'create' && $newRecord) ||
                  ($allowed === 'update' && !$newRecord)
              );
          }
  
          return $allowed;
      }
code_tokens: protected function _canBeEmpty ( $ field , $ context ) { $ allowed = $ field -> isEmptyAllowed ( ) ; if ( ! is_string ( $ allowed ) && is_callable ( $ allowed ) ) { return $ allowed ( $ context ) ; } $ newRecord = $ context [ 'newRecord' ] ; if ( in_array ( $ allowed , [ 'create' , 'update' ] , true ) ) { $ allowed = ( ( $ allowed === 'create' && $ newRecord ) || ( $ allowed === 'update' && ! $ newRecord ) ) ; } return $ allowed ; }
docstring: Returns whether the field can be left blank according to `allowEmpty`
  
  @param \Cake\Validation\ValidationSet $field the set of rules for a field
  @param array $context a key value list of data containing the validation context.
  @return bool
docstring_tokens: Returns whether the field can be left blank according to allowEmpty