Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Removing warnings and fatals from php-lib/core.php #25

Merged
merged 1 commit into from

2 participants

@philix

Summary: PHP Strict Standards defines you can't declare static methods
abstract, so I just commented the __xhpAttributeDeclaration declaration.

__toString() should not throw "Exception"s, but trigger_error() is accepted, so I
just catch any Exception and trigger an E_USER_ERROR using the exception's
message.

There's almost no trade off as you probably don't handle exceptions converting
XHP objects to strings. If you have some kind of global error handling
you should make sure that the Exception handling and error handling should have
the same behavior.

@philix philix Removing warnings and fatals from php-lib/core.php
Summary: PHP Strict Standards define that you can't declare static methods
abstract, so I just commented out __xhpAttributeDeclaration declaration like
this.

__toString() should not throw "Exception"s, but trigger_error() is accepted, so I
just catch any Exception and trigger an E_USER_ERROR using the exception's
message.

There's almost no trade off as you probably don't handle exceptions when you
convert XHP objects to string. If you have some kind of global error handling
you should make sure that the Exception handling and error handling should have
the same behaviour.
a55d174
@philix

May be very useful for people trying to use XHP in their up to date PHP environments.

@rvanvelzen rvanvelzen referenced this pull request from a commit in rvanvelzen/xhp
Richard van Velzen Fix for issue #25 on facebook's repo 8434cc4
@philix

10 months later I realize this commit message has many grammar and style mistakes. :P

@Swahvay Swahvay merged commit 471ed9c into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 23, 2011
  1. @philix

    Removing warnings and fatals from php-lib/core.php

    philix authored
    Summary: PHP Strict Standards define that you can't declare static methods
    abstract, so I just commented out __xhpAttributeDeclaration declaration like
    this.
    
    __toString() should not throw "Exception"s, but trigger_error() is accepted, so I
    just catch any Exception and trigger an E_USER_ERROR using the exception's
    message.
    
    There's almost no trade off as you probably don't handle exceptions when you
    convert XHP objects to string. If you have some kind of global error handling
    you should make sure that the Exception handling and error handling should have
    the same behaviour.
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 2 deletions.
  1. +8 −2 php-lib/core.php
View
10 php-lib/core.php
@@ -22,7 +22,9 @@
abstract public function setAttribute($attr, $val);
abstract public function categoryOf($cat);
abstract public function __toString();
- abstract protected static function &__xhpAttributeDeclaration();
+ // PHP Strict Standards define that static function should not be declared
+ // abstract.
+ // abstract protected static function &__xhpAttributeDeclaration();
abstract protected function &__xhpCategoryDeclaration();
abstract protected function &__xhpChildrenDeclaration();
@@ -555,7 +557,11 @@ protected function &__xhpChildrenDeclaration() {
// Validate our children
$this->__flushElementChildren();
if (:x:base::$ENABLE_VALIDATION) {
- $this->validateChildren();
+ try {
+ $this->validateChildren();
+ } catch (Exception $e) {
+ trigger_error($e->getMessage(), E_USER_ERROR);
+ }
}
// Render to string
Something went wrong with that request. Please try again.